inital commit

This commit is contained in:
Rachel
2024-03-17 15:37:45 -07:00
commit de8503b745
27 changed files with 11715 additions and 0 deletions

53
.github/workflows/actions.yml vendored Normal file
View File

@@ -0,0 +1,53 @@
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 'latest'
- name: Install rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Install wasm-pack
uses: jetli/wasm-pack-action@v0.4.0
with:
version: 'latest'
- name: Build ic10lsp
run: |
cd ic10lsp_wasm
wasm-pack build
- name: Build Page
run: |
cd www
pnpm install
pnpm build
- name: Fix permissions
run: |
chmod -c -R +rX "www/dist/" | while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
- name: Upload artifacts
uses: actions/upload-pages-artifact@v3
with:
path: www/dist
deploy:
needs: build
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
pkg/
dist/
mode_modules/
target/

201
LICENSE-APACHE Normal file
View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

25
LICENSE-MIT Normal file
View File

@@ -0,0 +1,25 @@
Copyright (c) [year] [name]
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

43
README.md Normal file
View File

@@ -0,0 +1,43 @@
<div align="center">
<h1>IC10Emu</h1>
<strong>An Stationeers IC10 Emulator and code Editor</strong>
<p>
Complete with an in built LSP running locally in your browser!
</p>
<sub>Built with 🦀🕸</sub>
</div>
## About
This project is divided into four parts:
- The IC10 Emulator library
- A wasm wrapper for the emulator library
- A wasm wrapper for the [ic10lsp](https://github.com/Xandaros/ic10lsp) (with modifications not currently merged see: https://github.com/Ryex/ic10lsp/tree/wasm )
- A Webapp
## 🚴 Usage
Visit https://github.com/Ryex/ic10emu
## License
Licensed under either of
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally
submitted for inclusion in the work by you, as defined in the Apache-2.0
license, shall be dual licensed as above, without any additional terms or
conditions.

205
ic10emu/Cargo.lock generated Normal file
View File

@@ -0,0 +1,205 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "bumpalo"
version = "3.15.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "console_error_panic_hook"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc"
dependencies = [
"cfg-if",
"wasm-bindgen",
]
[[package]]
name = "const-crc32"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68d13f542d70e5b339bf46f6f74704ac052cfd526c58cd87996bd1ef4615b9a0"
[[package]]
name = "ic10emu"
version = "0.1.0"
dependencies = [
"console_error_panic_hook",
"const-crc32",
"wasm-bindgen",
"wasm-bindgen-test",
"web-sys",
]
[[package]]
name = "js-sys"
version = "0.3.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d"
dependencies = [
"wasm-bindgen",
]
[[package]]
name = "log"
version = "0.4.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
[[package]]
name = "once_cell"
version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]]
name = "proc-macro2"
version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
dependencies = [
"proc-macro2",
]
[[package]]
name = "scoped-tls"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294"
[[package]]
name = "syn"
version = "2.0.52"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "wasm-bindgen"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8"
dependencies = [
"cfg-if",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da"
dependencies = [
"bumpalo",
"log",
"once_cell",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-futures"
version = "0.4.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0"
dependencies = [
"cfg-if",
"js-sys",
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
dependencies = [
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
[[package]]
name = "wasm-bindgen-test"
version = "0.3.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9bf62a58e0780af3e852044583deee40983e5886da43a271dd772379987667b"
dependencies = [
"console_error_panic_hook",
"js-sys",
"scoped-tls",
"wasm-bindgen",
"wasm-bindgen-futures",
"wasm-bindgen-test-macro",
]
[[package]]
name = "wasm-bindgen-test-macro"
version = "0.3.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "web-sys"
version = "0.3.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef"
dependencies = [
"js-sys",
"wasm-bindgen",
]

35
ic10emu/Cargo.toml Normal file
View File

@@ -0,0 +1,35 @@
[package]
name = "ic10emu"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
crate-type = ["cdylib", "rlib"]
[features]
default = ["console_error_panic_hook"]
[dependencies]
wasm-bindgen = "0.2.92"
# The `console_error_panic_hook` crate provides better debugging of panics by
# logging them with `console.error`. This is great for development, but requires
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
# code size when deploying.
console_error_panic_hook = { version = "0.1.7", optional = true }
const-crc32 = "1.3.0"
[dependencies.web-sys]
version = "0.3"
features = [
"console",
]
[dev-dependencies]
wasm-bindgen-test = "0.3.42"
[profile.release]
# Tell `rustc` to optimize for small code size.
opt-level = "s"

45
ic10emu/src/lib.rs Normal file
View File

@@ -0,0 +1,45 @@
#[macro_use]
mod utils;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
fn alert(s: &str);
}
#[wasm_bindgen]
pub fn init() {
utils::set_panic_hook();
log!("Hello from ic10emu!");
}
#[wasm_bindgen]
#[derive(Debug)]
pub struct VM {
ip: u8,
ra: f64,
registers: [f64; 16], // r[0-15]
sp: f64,
stack: [f64; 512],
}
impl Default for VM {
fn default() -> Self {
VM {
ip: 0,
ra: 0.0,
registers: [0.0; 16],
sp: 0.0,
stack: [0.0; 512],
}
}
}
#[wasm_bindgen]
impl VM {
pub fn new() -> VM {
VM::default()
}
}

20
ic10emu/src/utils.rs Normal file
View File

@@ -0,0 +1,20 @@
pub fn set_panic_hook() {
// When the `console_error_panic_hook` feature is enabled, we can call the
// `set_panic_hook` function at least once during initialization, and then
// we will get better error messages if our code ever panics.
//
// For more details see
// https://github.com/rustwasm/console_error_panic_hook#readme
#[cfg(feature = "console_error_panic_hook")]
console_error_panic_hook::set_once();
}
extern crate web_sys;
// A macro to provide `println!(..)`-style syntax for `console.log` logging.
macro_rules! log {
( $( $t:tt )* ) => {
web_sys::console::log_1(&format!( $( $t )* ).into());
}
}

1326
ic10lsp_wasm/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

26
ic10lsp_wasm/Cargo.toml Normal file
View File

@@ -0,0 +1,26 @@
[package]
name = "ic10lsp_wasm"
version = "0.1.0"
edition = "2021"
# [features]
# default = ["tower-lsp/runtime-agnostic"]
[lib]
crate-type = ["cdylib", "rlib"]
[dependencies]
console_error_panic_hook = "0.1.7"
futures = "0.3.21"
js-sys = "0.3.69"
web-sys = {version = "0.3.69", features = ["WritableStream", "console"]}
tokio = { version = "1.26.0", features = ["sync"] }
tower-lsp = { version = "0.20.0", default-features = false, features = ["runtime-agnostic"]}
# tree-sitter = { version = "0.9.0", package = "tree-sitter-facade" }
wasm-bindgen = "0.2.81"
wasm-bindgen-futures = { version = "0.4.30", features = ["futures-core-03-stream"] }
wasm-streams = "0.3"
# web-tree-sitter-sys = "1.3"
ic10lsp = { git = "https://github.com/Ryex/ic10lsp.git", branch = "wasm" }

3
ic10lsp_wasm/config.toml Normal file
View File

@@ -0,0 +1,3 @@
[env]
CFLAGS_wasm32_unknown_unknown = "-I wasm-sysroot"
AR = 'llvm-ar'

73
ic10lsp_wasm/src/lib.rs Normal file
View File

@@ -0,0 +1,73 @@
use std::{collections::HashMap, sync::Arc};
use tokio::sync::RwLock;
use futures::stream::TryStreamExt;
use tower_lsp::{LspService, Server};
use wasm_bindgen::{prelude::*, JsCast};
use wasm_bindgen_futures::stream::JsStream;
#[wasm_bindgen]
pub struct ServerConfig {
into_server: js_sys::AsyncIterator,
from_server: web_sys::WritableStream,
}
#[wasm_bindgen]
impl ServerConfig {
#[wasm_bindgen(constructor)]
pub fn new(into_server: js_sys::AsyncIterator, from_server: web_sys::WritableStream) -> Self {
Self {
into_server,
from_server,
}
}
}
// NOTE: we don't use web_sys::ReadableStream for input here because on the
// browser side we need to use a ReadableByteStreamController to construct it
// and so far only Chromium-based browsers support that functionality.
// NOTE: input needs to be an AsyncIterator<Uint8Array, never, void> specifically
#[wasm_bindgen]
pub async fn serve(config: ServerConfig) -> Result<(), JsValue> {
console_error_panic_hook::set_once();
web_sys::console::log_1(&"server::serve".into());
let ServerConfig {
into_server,
from_server,
} = config;
// tree_sitter::TreeSitter::init().await?;
// let language = demo_lsp_language::language::javascript().await.unwrap();
let input = JsStream::from(into_server);
let input = input
.map_ok(|value| {
value
.dyn_into::<js_sys::Uint8Array>()
.expect("could not cast stream item to Uint8Array")
.to_vec()
})
.map_err(|err| {
web_sys::console::log_2(&"server::input Error: ".into(), &err);
std::io::Error::from(std::io::ErrorKind::Other)
})
.into_async_read();
let output = JsCast::unchecked_into::<wasm_streams::writable::sys::WritableStream>(from_server);
let output = wasm_streams::WritableStream::from_raw(output);
let output = output.try_into_async_write().map_err(|err| err.0)?;
let (service, messages) = LspService::new(|client| ic10lsp_lib::server::Backend{
client,
files: Arc::new(RwLock::new(HashMap::new())),
config: Arc::new(RwLock::new(ic10lsp_lib::server::Configuration::default())),
});
Server::new(input, output, messages).serve(service).await;
web_sys::console::log_1(&"server::serve ic10lsp started".into());
Ok(())
}

2
www/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
node_modules
dist

1
www/cspell.json Normal file
View File

@@ -0,0 +1 @@
{"version":"0.2","language":"en","flagWords":[],"words":["brgtz","brlez","brgez","brltz","brna","brap","brne","breq","brge","brle","brgt","brlt","brdns","brdse","bnaz","bapz","bnez","beqz","bgtz","blez","bgez","bltz","bdse","bdns","snaz","sapz","snez","seqz","sgez","slez","sgtz","sltz","sdns","sdse","bdnsal","bdseal","bapal","bapzal","beqal","beqzal","bgeal","bgezal","bgtal","bgtzal","bleal","blezal","bltal","bltzal","bnaal","bnazal","bneal","bnezal","brapz","brnaz","breqz","brnez","trunc","bnan","brnan","lbns","snan","snanz","Mineables","logictype","rocketstation","whos","sattellite","Stationeers","Hardsuit","jetpack","stationpedia","slottype","getd","putd","preproc","tokentype","overcolumn","overcolumn","QUICKFIX","infile","codegen","splitn","Circuitboard","hashables","logictypes","slotlogictypes","Astroloy","Autolathe","slotlogictype","reagentmodes","batchmodes","batchmode","reagentmode","ninf","endpos","Overlength","serde","bgezal","beqzal"]}

123
www/css/dark.css Normal file
View File

@@ -0,0 +1,123 @@
body {
background-color: #212529;
}
.ace_tooltip {
background-color: #343a40;
color: #dee2e6;
}
code {
color: #e685b5
}
.navbar {
position: relative;
min-height: 30px;
margin-bottom: 5px;
border: 1px solid;
}
.navbar-default {
background-color: #343a40 ;
border-color: #495057;
}
@media (min-width: 768px) {
.navbar {
border-radius: 4px;
}
}
.navbar-brand {
float: left;
height: 20px;
padding: 5px 5px;
font-size: 18px;
line-height: 20px;
}
.navbar-default .navbar-brand {
color: #fff;
}
.navbar-brand a {
text-decoration: none;
}
.nav {
padding-left: 0;
margin-bottom: 0;
list-style: none;
}
ol, ul {
margin-top: 0;
margin-bottom: 10px;
}
.nav > li {
position: relative;
display: block;
}
.navbar-default .navbar-nav > li > a {
color: #fff;
}
.navbar-default .navbar-text {
color: #fff;
}
.navbar-text {
margin-top: 10px;
margin-bottom: 10px;
padding: 0;
position: relative;
}
@media (min-width: 768px) {
.navbar-right {
float: right !important;
margin-right: -15px;
}
}
@media (min-width: 768px) {
.navbar-nav > li {
float: left;
}
}
.navbar-nav {
margin: 7.5px -15px;
display: block;
}
@media (min-width: 768px) {
.navbar-header {
float: left;
}
}
@media (min-width: 768px) {
.navbar > .container .navbar-brand, .navbar > .container-fluid .navbar-brand {
margin-left: -15px;
}
}
@media (min-width: 768px) {
.navbar-nav {
float: left;
margin: 0;
}
}
.navbar-nav > li > a {
padding-top: 10px;
padding-bottom: 10px;
line-height: 20px;
}
@media (min-width: 768px) {
.navbar-nav > li > a {
padding-top: 15px;
padding-bottom: 15px;
}
}
.nav > li > a {
position: relative;
display: block;
padding: 10px 15px;
padding-top: 10px;
padding-bottom: 10px;
}
@media (min-width: 768px) {
.navbar-text {
float: left;
margin-right: 15px;
margin-left: 15px;
}
}

72
www/index.html Normal file
View File

@@ -0,0 +1,72 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello wasm-pack!</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/js/bootstrap.min.js" integrity="sha512-ykZ1QQr0Jy/4ZkvKuqWn4iF3lqPZyij9iRv6sGqLRdTPkY69YX6+7wvVGmsdBbiIfN/8OdsI7HABjvEok6ZopQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/css/bootstrap.min.css" integrity="sha512-jnSuA4Ss2PkkikSOLtYs8BlYIeeIK1h99ty4YfvRPAlzr377vr3CXDb7sb7eEEBYjDtcYj+AjBH3FLv5uSJuXg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/css/bootstrap-grid.min.css" integrity="sha512-i1b/nzkVo97VN5WbEtaPebBG8REvjWeqNclJ6AItj7msdVcaveKrlIIByDpvjk5nwHjXkIqGZscVxOrTb9tsMA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/js/fontawesome.min.js" integrity="sha512-C8qHv0HOaf4yoA7ISuuCTrsPX8qjolYTZyoFRKNA9dFKnxgzIHnYTOJhXQIt6zwpIFzCrRzUBuVgtC4e5K1nhA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/js/solid.min.js" integrity="sha512-+fI924YJzeYFv7M0R29zJvRThPinSUOAmo5rpR9v6G4eWIbva/prHdZGSPN440vuf781/sOd/Fr+5ey0pqdW9w==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/fontawesome.min.css" integrity="sha512-d0olNN35C6VLiulAobxYHZiXJmq+vl+BGIgAxQtD5+kqudro/xNMvv2yIHAciGHpExsIbKX3iLg+0B6d0k4+ZA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/solid.min.css" integrity="sha512-pZlKGs7nEqF4zoG0egeK167l6yovsuL8ap30d07kA5AJUq+WysFlQ02DLXAmN3n0+H3JVz5ni8SJZnrOaYXWBA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="css/dark.css" />
<style type="text/css" media="screen">
#editor {
height: 100vh;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
</style>
</head>
<body>
<noscript>This page contains webassembly and javascript content, please enable javascript in your browser.</noscript>
<script src="./bootstrap.js"></script>
<div class="App" data-bs-theme="dark">
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand active" aria-current="page" href="/">IC10Emu</a>
</div>
<div>
<ul class="nav navbar-nav"></ul>
<ul class="nav navbar-nav navbar-right">
<p class="navbar-text">Official Stationeers:</p>
<li role="presentation" class="">
<a href="https://store.steampowered.com/app/544550/Stationeers/"><svg aria-hidden="true" focusable="false" data-prefix="fab" data-icon="steam" class="svg-inline--fa fa-steam fa-w-16 " role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path fill="currentColor" d="M496 256c0 137-111.2 248-248.4 248-113.8 0-209.6-76.3-239-180.4l95.2 39.3c6.4 32.1 34.9 56.4 68.9 56.4 39.2 0 71.9-32.4 70.2-73.5l84.5-60.2c52.1 1.3 95.8-40.9 95.8-93.5 0-51.6-42-93.5-93.7-93.5s-93.7 42-93.7 93.5v1.2L176.6 279c-15.5-.9-30.7 3.4-43.5 12.1L0 236.1C10.2 108.4 117.1 8 247.6 8 384.8 8 496 119 496 256zM155.7 384.3l-30.5-12.6a52.79 52.79 0 0 0 27.2 25.8c26.9 11.2 57.8-1.6 69-28.4 5.4-13 5.5-27.3.1-40.3-5.4-13-15.5-23.2-28.5-28.6-12.9-5.4-26.7-5.2-38.9-.6l31.5 13c19.8 8.2 29.2 30.9 20.9 50.7-8.3 19.9-31 29.2-50.8 21zm173.8-129.9c-34.4 0-62.4-28-62.4-62.3s28-62.3 62.4-62.3 62.4 28 62.4 62.3-27.9 62.3-62.4 62.3zm.1-15.6c25.9 0 46.9-21 46.9-46.8 0-25.9-21-46.8-46.9-46.8s-46.9 21-46.9 46.8c.1 25.8 21.1 46.8 46.9 46.8z"></path></svg>
</a>
</li>
<li role="presentation" class="">
<a href="https://stationeers.com/">
<svg aria-hidden="true" focusable="false" data-prefix="fa" data-icon="globe" class="svg-inline--fa fa-globe fa-w-16 " role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path fill="currentColor" d="M336.5 160C322 70.7 287.8 8 248 8s-74 62.7-88.5 152h177zM152 256c0 22.2 1.2 43.5 3.3 64h185.3c2.1-20.5 3.3-41.8 3.3-64s-1.2-43.5-3.3-64H155.3c-2.1 20.5-3.3 41.8-3.3 64zm324.7-96c-28.6-67.9-86.5-120.4-158-141.6 24.4 33.8 41.2 84.7 50 141.6h108zM177.2 18.4C105.8 39.6 47.8 92.1 19.3 160h108c8.7-56.9 25.5-107.8 49.9-141.6zM487.4 192H372.7c2.1 21 3.3 42.5 3.3 64s-1.2 43-3.3 64h114.6c5.5-20.5 8.6-41.8 8.6-64s-3.1-43.5-8.5-64zM120 256c0-21.5 1.2-43 3.3-64H8.6C3.2 212.5 0 233.8 0 256s3.2 43.5 8.6 64h114.6c-2-21-3.2-42.5-3.2-64zm39.5 96c14.5 89.3 48.7 152 88.5 152s74-62.7 88.5-152h-177zm159.3 141.6c71.4-21.2 129.4-73.7 158-141.6h-108c-8.8 56.9-25.6 107.8-50 141.6zM19.3 352c28.6 67.9 86.5 120.4 158 141.6-24.4-33.8-41.2-84.7-50-141.6h-108z"></path></svg>
</a>
</li>
<li role="presentation" class="">
<a href="https://twitter.com/stationeers">
<svg aria-hidden="true" focusable="false" data-prefix="fab" data-icon="twitter" class="svg-inline--fa fa-twitter fa-w-16 " role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"></path></svg>
</a>
</li>
<li role="presentation" class="">
<a href="https://discordapp.com/invite/CxR3mRy">
<svg aria-hidden="true" focusable="false" data-prefix="fab" data-icon="discord" class="svg-inline--fa fa-discord fa-w-14 " role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M297.216 243.2c0 15.616-11.52 28.416-26.112 28.416-14.336 0-26.112-12.8-26.112-28.416s11.52-28.416 26.112-28.416c14.592 0 26.112 12.8 26.112 28.416zm-119.552-28.416c-14.592 0-26.112 12.8-26.112 28.416s11.776 28.416 26.112 28.416c14.592 0 26.112-12.8 26.112-28.416.256-15.616-11.52-28.416-26.112-28.416zM448 52.736V512c-64.494-56.994-43.868-38.128-118.784-107.776l13.568 47.36H52.48C23.552 451.584 0 428.032 0 398.848V52.736C0 23.552 23.552 0 52.48 0h343.04C424.448 0 448 23.552 448 52.736zm-72.96 242.688c0-82.432-36.864-149.248-36.864-149.248-36.864-27.648-71.936-26.88-71.936-26.88l-3.584 4.096c43.52 13.312 63.744 32.512 63.744 32.512-60.811-33.329-132.244-33.335-191.232-7.424-9.472 4.352-15.104 7.424-15.104 7.424s21.248-20.224 67.328-33.536l-2.56-3.072s-35.072-.768-71.936 26.88c0 0-36.864 66.816-36.864 149.248 0 0 21.504 37.12 78.08 38.912 0 0 9.472-11.52 17.152-21.248-32.512-9.728-44.8-30.208-44.8-30.208 3.766 2.636 9.976 6.053 10.496 6.4 43.21 24.198 104.588 32.126 159.744 8.96 8.96-3.328 18.944-8.192 29.44-15.104 0 0-12.8 20.992-46.336 30.464 7.68 9.728 16.896 20.736 16.896 20.736 56.576-1.792 78.336-38.912 78.336-38.912z"></path></svg>
</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="contianer" >
<div class="row">
<div class="col w-100 flex-grow-1">
<div id ="editor" class="" style="font-size: 16px;">alias test r0</div>
</div>
</div>
</div>
</div>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.32.7/ace.js" type="text/javascript" charset="utf-8"></script> -->
<script>
</script>
</body>
</html>

5845
www/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

42
www/package.json Normal file
View File

@@ -0,0 +1,42 @@
{
"name": "ic10emu",
"version": "0.1.0",
"description": "an IC10 emulator for IC10 mips from Stationeers",
"main": "index.js",
"scripts": {
"build": "webpack --config webpack.config.js",
"start": "webpack-dev-server"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ryex/ic10emu.git"
},
"keywords": [
"webassembly",
"wasm",
"rust",
"webpack"
],
"author": "Rachel Powers <powers.e.rachel@gmail.com>",
"license": "(MIT OR Apache-2.0)",
"bugs": {
"url": "https://github.com/ryex/ic10emu/issues"
},
"homepage": "https://github.com/ryex/ic10emu#readme",
"devDependencies": {
"copy-webpack-plugin": "^12.0.2",
"hello-wasm-pack": "^0.1.0",
"ts-loader": "^9.5.1",
"typescript": "^5.4.2",
"webpack": "^5.90.3",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.0.3"
},
"dependencies": {
"ace-code": "^1.32.7",
"ace-linters": "^1.1.1",
"uuid": "^9.0.1",
"ic10emu_wasm": "file:../ic10emu_wasm/pkg",
"ic10lsp_wasm": "file:../ic10lsp_wasm/pkg"
}
}

2876
www/pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

5
www/src/bootstrap.js vendored Normal file
View File

@@ -0,0 +1,5 @@
// A dependency graph that contains any wasm must all be imported
// asynchronously. This `bootstrap.js` file does the single async import, so
// that no one else needs to worry about it again.
import("./index.js")
.catch(e => console.error("Error importing `index.js`:", e));

View File

@@ -0,0 +1,316 @@
"use strict";
var oop = require("ace-code/src/lib/oop");
var TextHighlightRules = require("ace-code/src/mode/text_highlight_rules").TextHighlightRules;
var IC10HighlightRules = function() {
// regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used
var ops = (
"abs|acos|add|alias|and|asin|atan|atan2|bap|bapal|bapz|bapzal|bdns|"+
"bdnsal|bdse|bdseal|beq|beqal|beqz|beqzal|bge|bgeal|bgez|bgezal|bgt|"+
"bgtal|bgtz|bgtzal|ble|bleal|blez|blezal|blt|bltal|bltz|bltzal|bna|"+
"bnaal|bnan|bnaz|bnazal|bne|bneal|bnez|bnezal|brap|brapz|brdns|brdse|"+
"breq|breqz|brge|brgez|brgt|brgtz|brle|brlez|brlt|brltz|brna|brnan|"+
"brnaz|brne|brnez|ceil|cos|define|div|exp|floor|get|getd|hcf|j|jal|jr|"+
"l|label|lb|lbn|lbns|lbs|ld|log|lr|ls|max|min|mod|move|mul|nor|not|or|"+
"peek|poke|pop|push|put|putd|rand|round|s|sap|sapz|sb|sbn|sbs|sd|sdns|"+
"sdse|select|seq|seqz|sge|sgez|sgt|sgtz|sin|sla|sle|sleep|slez|sll|"+
"slt|sltz|sna|snan|snanz|snaz|sne|snez|sqrt|sra|srl|ss|sub|tan|trunc|"+
"xor|yield"
);
var enums = (
"LogicType\\.Power|LogicType\\.Open|LogicType\\.Mode|LogicType\\.Error|"+
"LogicType\\.Pressure|LogicType\\.Temperature|LogicType\\.PressureExternal|"+
"LogicType\\.PressureInternal|LogicType\\.Activate|LogicType\\.Lock|"+
"LogicType\\.Charge|LogicType\\.Setting|LogicType\\.Reagents|"+
"LogicType\\.RatioOxygen|LogicType\\.RatioCarbonDioxide|"+
"LogicType\\.RatioNitrogen|LogicType\\.RatioPollutant|"+
"LogicType\\.RatioVolatiles|LogicType\\.RatioWater|LogicType\\.Horizontal|"+
"LogicType\\.Vertical|LogicType\\.SolarAngle|LogicType\\.Maximum|"+
"LogicType\\.Ratio|LogicType\\.PowerPotential|LogicType\\.PowerActual|"+
"LogicType\\.Quantity|LogicType\\.On|LogicType\\.RequiredPower|"+
"LogicType\\.HorizontalRatio|LogicType\\.VerticalRatio|"+
"LogicType\\.PowerRequired|LogicType\\.Idle|LogicType\\.Color|"+
"LogicType\\.ElevatorSpeed|LogicType\\.ElevatorLevel|"+
"LogicType\\.RecipeHash|LogicType\\.RequestHash|LogicType\\.CompletionRatio|"+
"LogicType\\.ClearMemory|LogicType\\.ExportCount|LogicType\\.ImportCount|"+
"LogicType\\.PowerGeneration|LogicType\\.TotalMoles|LogicType\\.Volume|"+
"LogicType\\.Plant|LogicType\\.Harvest|LogicType\\.Output|"+
"LogicType\\.PressureSetting|LogicType\\.TemperatureSetting|"+
"LogicType\\.TemperatureExternal|LogicType\\.Filtration|"+
"LogicType\\.AirRelease|LogicType\\.PositionX|LogicType\\.PositionZ|"+
"LogicType\\.VelocityMagnitude|LogicType\\.VelocityRelativeX|"+
"LogicType\\.VelocityRelativeY|LogicType\\.VelocityRelativeZ|"+
"LogicType\\.RatioNitrousOxide|LogicType\\.PrefabHash|"+
"LogicType\\.ForceWrite|LogicType\\.SignalStrength|LogicType\\.SignalID|"+
"LogicType\\.TargetX|LogicType\\.TargetY|LogicType\\.TargetZ|"+
"LogicType\\.SettingInput|LogicType\\.SettingOutput|"+
"LogicType\\.CurrentResearchPodType|LogicType\\.ManualResearchRequiredPod|"+
"LogicType\\.MineablesInVicinity|LogicType\\.MineablesInQueue|"+
"LogicType\\.NextWeatherEventTime|LogicType\\.Combustion|LogicType\\.Fuel|"+
"LogicType\\.ReturnFuelCost|LogicType\\.CollectableGoods|LogicType\\.Time|"+
"LogicType\\.Bpm|LogicType\\.EnvironmentEfficiency|"+
"LogicType\\.WorkingGasEfficiency|LogicType\\.PressureInput|"+
"LogicType\\.TemperatureInput|LogicType\\.RatioOxygenInput|"+
"LogicType\\.RatioCarbonDioxideInput|LogicType\\.RatioNitrogenInput|"+
"LogicType\\.RatioPollutantInput|LogicType\\.RatioVolatilesInput|"+
"LogicType\\.RatioWaterInput|LogicType\\.RatioNitrousOxideInput|"+
"LogicType\\.TotalMolesInput|LogicType\\.PressureInput2|"+
"LogicType\\.TemperatureInput2|LogicType\\.RatioOxygenInput2|"+
"LogicType\\.RatioCarbonDioxideInput2|"+
"LogicType\\.RatioLiquidCarbonDioxide|LogicType\\.RatioNitrogenInput2|"+
"LogicType\\.RatioPollutantInput2|LogicType\\.RatioVolatilesInput2|"+
"LogicType\\.RatioWaterInput2|LogicType\\.RatioNitrousOxideInput2|"+
"LogicType\\.TotalMolesInput2|LogicType\\.PressureOutput|"+
"LogicType\\.TemperatureOutput|LogicType\\.RatioOxygenOutput|"+
"LogicType\\.RatioCarbonDioxideOutput|LogicType\\.RatioNitrogenOutput|"+
"LogicType\\.RatioPollutantOutput|LogicType\\.RatioVolatilesOutput|"+
"LogicType\\.RatioWaterOutput|LogicType\\.RatioNitrousOxideOutput|"+
"LogicType\\.TotalMolesOutput|LogicType\\.PressureOutput2|"+
"LogicType\\.TemperatureOutput2|LogicType\\.RatioOxygenOutput2|"+
"LogicType\\.RatioCarbonDioxideOutput2|LogicType\\.RatioNitrogenOutput2|"+
"LogicType\\.RatioPollutantOutput2|LogicType\\.RatioVolatilesOutput2|"+
"LogicType\\.RatioWaterOutput2|LogicType\\.RatioNitrousOxideOutput2|"+
"LogicType\\.TotalMolesOutput2|LogicType\\.CombustionInput|"+
"LogicType\\.CombustionInput2|LogicType\\.CombustionOutput|"+
"LogicType\\.CombustionOutput2|"+
"LogicType\\.OperationalTemperatureEfficiency|"+
"LogicType\\.TemperatureDifferentialEfficiency|"+
"LogicType\\.PressureEfficiency|LogicType\\.CombustionLimiter|"+
"LogicType\\.Throttle|LogicType\\.Rpm|LogicType\\.Stress|"+
"LogicType\\.InterrogationProgress|LogicType\\.TargetPadIndex|"+
"LogicType\\.SizeX|LogicType\\.SizeY|LogicType\\.SizeZ|"+
"LogicType\\.MinimumWattsToContact|LogicType\\.WattsReachingContact|"+
"LogicType\\.Channel0|LogicType\\.Channel1|LogicType\\.Channel2|"+
"LogicType\\.Channel3|LogicType\\.Channel4|LogicType\\.Channel5|"+
"LogicType\\.Channel6|LogicType\\.LineNumber|LogicType\\.Flush|"+
"LogicType\\.Channel7|LogicType\\.SoundAlert|LogicType\\.SolarIrradiance|"+
"LogicType\\.RatioLiquidNitrogen|LogicType\\.RatioLiquidNitrogenInput|"+
"LogicType\\.RatioLiquidNitrogenInput2|"+
"LogicType\\.RatioLiquidNitrogenOutput|"+
"LogicType\\.RatioLiquidNitrogenOutput2|"+
"LogicType\\.VolumeOfLiquid|LogicType\\.RatioLiquidOxygen|"+
"LogicType\\.RatioLiquidOxygenInput|LogicType\\.RatioLiquidOxygenInput2|"+
"LogicType\\.RatioLiquidOxygenOutput|"+
"LogicType\\.RatioLiquidOxygenOutput2|LogicType\\.RatioLiquidVolatiles|"+
"LogicType\\.RatioLiquidVolatilesInput|"+
"LogicType\\.RatioLiquidVolatilesInput2|"+
"LogicType\\.RatioLiquidVolatilesOutput|"+
"LogicType\\.RatioLiquidVolatilesOutput2|LogicType\\.RatioSteam|"+
"LogicType\\.RatioSteamInput|LogicType\\.RatioSteamInput2|"+
"LogicType\\.RatioSteamOutput|LogicType\\.RatioSteamOutput2|"+
"LogicType\\.ContactTypeId|LogicType\\.RatioLiquidCarbonDioxideInput|"+
"LogicType\\.RatioLiquidCarbonDioxideInput2|"+
"LogicType\\.RatioLiquidCarbonDioxideOutput|"+
"LogicType\\.RatioLiquidCarbonDioxideOutput2|"+
"LogicType\\.RatioLiquidPollutant|LogicType\\.RatioLiquidPollutantInput|"+
"LogicType\\.RatioLiquidPollutantInput2|"+
"LogicType\\.RatioLiquidPollutantOutput|"+
"LogicType\\.RatioLiquidPollutantOutput2|"+
"LogicType\\.RatioLiquidNitrousOxide|"+
"LogicType\\.RatioLiquidNitrousOxideInput|"+
"LogicType\\.RatioLiquidNitrousOxideInput2|"+
"LogicType\\.RatioLiquidNitrousOxideOutput|"+
"LogicType\\.RatioLiquidNitrousOxideOutput2|"+
"LogicType\\.Progress|LogicType\\.DestinationCode|"+
"LogicType\\.Acceleration|LogicType\\.ReferenceId|"+
"LogicType\\.AutoShutOff|LogicType\\.Mass|LogicType\\.DryMass|"+
"LogicType\\.Thrust|LogicType\\.Weight|LogicType\\.ThrustToWeight|"+
"LogicType\\.TimeToDestination|LogicType\\.BurnTimeRemaining|"+
"LogicType\\.AutoLand|LogicType\\.ForwardX|LogicType\\.ForwardY|"+
"LogicType\\.ForwardZ|LogicType\\.Orientation|LogicType\\.VelocityX|"+
"LogicType\\.VelocityY|LogicType\\.VelocityZ|LogicType\\.PassedMoles|"+
"LogicType\\.ExhaustVelocity|LogicType\\.FlightControlRule|"+
"LogicType\\.ReEntryAltitude|LogicType\\.Apex|LogicType\\.EntityState|"+
"LogicType\\.DrillCondition|LogicType\\.Index|LogicType\\.CelestialHash|"+
"LogicType\\.AlignmentError|LogicType\\.DistanceAu|LogicType\\.OrbitPeriod|"+
"LogicType\\.Inclination|LogicType\\.Eccentricity|LogicType\\.SemiMajorAxis|"+
"LogicType\\.DistanceKm|LogicType\\.CelestialParentHash|"+
"LogicType\\.TrueAnomaly|"+
"LogicSlotType\\.None|LogicSlotType\\.Occupied|LogicSlotType\\.OccupantHash|"+
"LogicSlotType\\.Quantity|LogicSlotType\\.Damage|LogicSlotType\\.Efficiency|"+
"LogicSlotType\\.Health|LogicSlotType\\.Growth|LogicSlotType\\.Pressure|"+
"LogicSlotType\\.Temperature|LogicSlotType\\.Charge|"+
"LogicSlotType\\.ChargeRatio|LogicSlotType\\.Class|"+
"LogicSlotType\\.PressureWaste|LogicSlotType\\.PressureAir|"+
"LogicSlotType\\.MaxQuantity|LogicSlotType\\.Mature|"+
"LogicSlotType\\.PrefabHash|LogicSlotType\\.Seeding|"+
"LogicSlotType\\.LineNumber|LogicSlotType\\.Volume|"+
"LogicSlotType\\.Open|LogicSlotType\\.On|LogicSlotType\\.Lock|"+
"LogicSlotType\\.SortingClass|LogicSlotType\\.FilterType|"+
"LogicSlotType\\.ReferenceId|"+
"SlotClass\\.None|SlotClass\\.Helmet|SlotClass\\.Suit|SlotClass\\.Back|"+
"SlotClass\\.GasFilter|SlotClass\\.Motherboard|SlotClass\\.Circuitboard|"+
"SlotClass\\.DataDisk|SlotClass\\.Organ|SlotClass\\.Ore|SlotClass\\.Plant|"+
"SlotClass\\.Uniform|SlotClass\\.Battery|SlotClass\\.Egg|SlotClass\\.Belt|"+
"SlotClass\\.Tool|SlotClass\\.Appliance|SlotClass\\.Ingot|SlotClass\\.Torpedo|"+
"SlotClass\\.Cartridge|SlotClass\\.AccessCard|SlotClass\\.Magazine|"+
"SlotClass\\.Circuit|SlotClass\\.Bottle|SlotClass\\.ProgrammableChip|"+
"SlotClass\\.Glasses|SlotClass\\.CreditCard|SlotClass\\.DirtCanister|"+
"SlotClass\\.SensorProcessingUnit|SlotClass\\.LiquidCanister|"+
"SlotClass\\.LiquidBottle|SlotClass\\.Wreckage|SlotClass\\.SoundCartridge|"+
"SlotClass\\.DrillHead|SlotClass\\.ScanningHead|SlotClass\\.Flare|"+
"SlotClass\\.Blocked|GasType\\.Undefined|GasType\\.Oxygen|GasType\\.Nitrogen|"+
"GasType\\.CarbonDioxide|GasType\\.Volatiles|GasType\\.Pollutant|"+
"GasType\\.Water|GasType\\.NitrousOxide|GasType\\.LiquidNitrogen|"+
"GasType\\.LiquidVolatiles|GasType\\.Steam|GasType\\.LiquidCarbonDioxide|"+
"GasType\\.LiquidPollutant|GasType\\.LiquidNitrousOxide|"+
"Equals|Greater|Less|NotEquals|"+
"AirCon\\.Cold|AirCon\\.Hot|AirControl\\.None|AirControl\\.Offline|"+
"AirControl\\.Pressure|AirControl\\.Draught|"+
"Color\\.Blue|Color\\.Gray|Color\\.Green|Color\\.Orange|Color\\.Red|Color\\.Yellow|"+
"Color\\.White|Color\\.Black|Color\\.Brown|Color\\.Khaki|Color\\.Pink|"+
"Color\\.Purple|"+
"DaylightSensorMode\\.Default|DaylightSensorMode\\.Horizontal|"+
"DaylightSensorMode\\.Vertical|"+
"ElevatorMode\\.Stationary|ElevatorMode\\.Upward|ElevatorMode\\.Downward|"+
"EntityState\\.Alive|EntityState\\.Dead|EntityState\\.Unconscious"+
"|EntityState\\.Decay|"+
"PowerMode\\.Idle|PowerMode\\.Discharged|PowerMode\\.Discharging|"+
"PowerMode\\.Charging|PowerMode\\.Charged|"+
"RobotMode\\.None|RobotMode\\.Follow|RobotMode\\.MoveToTarget|"+
"RobotMode\\.Roam|RobotMode\\.Unload|RobotMode\\.PathToTarget|"+
"RobotMode\\.StorageFull|"+
"SortingClass\\.Default|SortingClass\\.Kits|SortingClass\\.Tools|"+
"SortingClass\\.Resources|SortingClass\\.Food|SortingClass\\.Clothing|"+
"SortingClass\\.Appliances|SortingClass\\.Atmospherics|"+
"SortingClass\\.Storage|SortingClass\\.Ores|SortingClass\\.Ices|"+
"TransmitterMode\\.Passive|TransmitterMode\\.Active|"+
"Vent\\.Outward|Vent\\.Inward"
);
var logictypes = (
"Acceleration|Activate|AirRelease|AlignmentError|Apex|AutoLand|"+
"AutoShutOff|Average|Bpm|BurnTimeRemaining|Bypass|CelestialHash|"+
"CelestialParentHash|Channel|Channel0|Channel1|Channel2|Channel3|"+
"Channel4|Channel5|Channel6|Channel7|Charge|ChargeRatio|Class|"+
"ClearMemory|CollectableGoods|Color|Combustion|CombustionInput|"+
"CombustionInput2|CombustionLimiter|CombustionOutput|CombustionOutput2|"+
"CompletionRatio|ContactTypeId|Contents|CurrentResearchPodType|Damage|"+
"DestinationCode|DistanceAu|DistanceKm|DrillCondition|DryMass|"+
"Eccentricity|Efficiency|ElevatorLevel|ElevatorSpeed|EntityState|"+
"EnvironmentEfficiency|Error|ExhaustVelocity|ExportCount|"+
"ExportQuantity|ExportSlotHash|ExportSlotOccupant|FilterType|"+
"Filtration|FlightControlRule|Flush|ForceWrite|ForwardX|ForwardY|"+
"ForwardZ|Fuel|Growth|Harvest|Health|Horizontal|HorizontalRatio|"+
"Idle|ImportCount|ImportQuantity|ImportSlotHash|ImportSlotOccupant|"+
"Inclination|Index|InterrogationProgress|LineNumber|Lock|"+
"ManualResearchRequiredPod|Mass|Mature|MaxQuantity|Maximum|"+
"MinWattsToContact|MineablesInQueue|MineablesInVicinity|Minimum|"+
"MinimumWattsToContact|Mode|NextWeatherEventTime|None|OccupantHash|"+
"Occupied|On|Open|OperationalTemperatureEfficiency|OrbitPeriod|"+
"Orientation|Output|OverShootTarget|PassedMoles|Plant|"+
"PlantEfficiency1|PlantEfficiency2|PlantEfficiency3|PlantEfficiency4|"+
"PlantGrowth1|PlantGrowth2|PlantGrowth3|PlantGrowth4|PlantHash1|"+
"PlantHash2|PlantHash3|PlantHash4|PlantHealth1|PlantHealth2|"+
"PlantHealth3|PlantHealth4|PositionX|PositionY|PositionZ|Power|"+
"PowerActual|PowerGeneration|PowerPotential|PowerRequired|"+
"PrefabHash|Pressure|PressureAir|PressureEfficiency|PressureExternal|"+
"PressureInput|PressureInput2|PressureInternal|PressureOutput|"+
"PressureOutput2|PressureSetting|PressureWaste|Progress|Quantity|"+
"Ratio|RatioCarbonDioxide|RatioCarbonDioxideInput|"+
"RatioCarbonDioxideInput2|RatioCarbonDioxideOutput|"+
"RatioCarbonDioxideOutput2|RatioLiquidCarbonDioxide|"+
"RatioLiquidCarbonDioxideInput|RatioLiquidCarbonDioxideInput2|"+
"RatioLiquidCarbonDioxideOutput|RatioLiquidCarbonDioxideOutput2|"+
"RatioLiquidNitrogen|RatioLiquidNitrogenInput|"+
"RatioLiquidNitrogenInput2|RatioLiquidNitrogenOutput|"+
"RatioLiquidNitrogenOutput2|RatioLiquidNitrousOxide|"+
"RatioLiquidNitrousOxideInput|RatioLiquidNitrousOxideInput2|"+
"RatioLiquidNitrousOxideOutput|RatioLiquidNitrousOxideOutput2|"+
"RatioLiquidOxygen|RatioLiquidOxygenInput|RatioLiquidOxygenInput2|"+
"RatioLiquidOxygenOutput|RatioLiquidOxygenOutput2|"+
"RatioLiquidPollutant|RatioLiquidPollutantInput|"+
"RatioLiquidPollutantInput2|RatioLiquidPollutantOutput|"+
"RatioLiquidPollutantOutput2|RatioLiquidVolatiles|"+
"RatioLiquidVolatilesInput|RatioLiquidVolatilesInput2|"+
"RatioLiquidVolatilesOutput|RatioLiquidVolatilesOutput2|"+
"RatioNitrogen|RatioNitrogenInput|RatioNitrogenInput2|"+
"RatioNitrogenOutput|RatioNitrogenOutput2|RatioNitrousOxide|"+
"RatioNitrousOxideInput|RatioNitrousOxideInput2|"+
"RatioNitrousOxideOutput|RatioNitrousOxideOutput2|RatioOxygen|"+
"RatioOxygenInput|RatioOxygenInput2|RatioOxygenOutput|"+
"RatioOxygenOutput2|RatioPollutant|RatioPollutantInput|"+
"RatioPollutantInput2|RatioPollutantOutput|RatioPollutantOutput2|"+
"RatioSteam|RatioSteamInput|RatioSteamInput2|RatioSteamOutput|"+
"RatioSteamOutput2|RatioVolatiles|RatioVolatilesInput|"+
"RatioVolatilesInput2|RatioVolatilesOutput|RatioVolatilesOutput2|"+
"RatioWater|RatioWaterInput|RatioWaterInput2|RatioWaterOutput|"+
"RatioWaterOutput2|ReEntryAltitude|Reagents|Recipe|RecipeHash|"+
"ReferenceId|RequestHash|Required|RequiredPower|ReturnFuelCost|Rpm|"+
"Seeding|SemiMajorAxis|Setting|SettingInput|SettingInputHash|"+
"SettingOutput|SettingOutputHash|SignalID|SignalStrength|SizeX|SizeY|"+
"SizeZ|SolarAngle|SolarConstant|SolarIrradiance|SortingClass|"+
"SoundAlert|Stress|Sum|TargetPadIndex|TargetX|TargetY|TargetZ|"+
"Temperature|TemperatureDifferentialEfficiency|TemperatureExternal|"+
"TemperatureInput|TemperatureInput2|TemperatureOutput|"+
"TemperatureOutput2|TemperatureSetting|Throttle|Thrust|ThrustToWeight|"+
"Time|TimeToDestination|TotalMoles|TotalMolesInput|TotalMolesInput2|"+
"TotalMolesOutput|TotalMolesOutput2|TrueAnomaly|Unknown|"+
"VelocityMagnitude|VelocityRelativeX|VelocityRelativeY|"+
"VelocityRelativeZ|VelocityX|VelocityY|VelocityZ|Vertical|"+
"VerticalRatio|Volume|VolumeOfLiquid|WattsReachingContact|Weight"+
"|WorkingGasEfficiency"
);
var constants = ("nan|pinf|ninf|pi|deg2rad|rad2deg|epsilon")
this.$rules = {
start: [{
token : "comment.line.number-sign",
regex: /#.*$/,
}, {
token: ["text", "keyword", "text", "entity.name.tag"],
regex: /^(\s*)(j(?:al)?)(\s+)([a-zA-Z_.][a-zA-Z0-9_.]*)/,
comment: "absolute jumps | branches with a label"
}, {
token: "keyword",
regex: "^\\s*(?:" + ops + ")\\b",
}, {
token: "entity.name.tag",
regex: /^\s*[a-zA-Z_.][a-zA-Z0-9_.]*\b:/,
comment: "Labels at line start: begin_repeat: add ..."
}, {
token: "variable.parameter",
regex: /\b(?:sp|r(?:a|r*)(?:[0-9]|1[0-5]))\b/,
}, {
token: "variable.language",
regex: /\b(?:d(?:b|r*)(?:[0-9]|1[0-5])(?::[0-9]+)?)\b/,
}, {
token: "support.type",
regex: "\\b(?:" + logictypes + ")\\b",
}, {
token: "constant.language",
regex: "\\b(?:" + constants + ")\\b",
}, {
token: "variable.language",
regex: "\\b(?:" + enums + ")\\b",
}, {
token: "constant.numeric.ic10",
regex: /\-?[0-9]+(?:\.[0-9]+)?|\$[a-fA-F0-9_]+|%[01_]+/,
comment: "Numbers like 12, -3.0, 55, $3F, %1000"
}, {
token: ["support.function", "paren.lparen", "string.quoted", "paren.rparen"],
regex: /\b(HASH)(\()(\".*\")(\))/,
}, {
token: "identifier",
regex: /\b[a-zA-Z_.][a-zA-Z0-9_.]*\b/,
}]
};
this.normalizeRules();
};
IC10HighlightRules.metaData = {
fileTypes: ["ic10"],
name: "ic10",
scopeName: "source.ic10"
};
oop.inherits(IC10HighlightRules, TextHighlightRules);
exports.IC10HighlightRules = IC10HighlightRules;

22
www/src/ic10_mode.js Normal file
View File

@@ -0,0 +1,22 @@
"use strict";
var oop = require("ace-code/src/lib/oop");
var TextMode = require("ace-code/src/mode/text").Mode;
var FoldMode = require("ace-code/src/mode/folding/cstyle").FoldMode;
var IC10HighlightRules = require("./ic10_highlight_rules.js").IC10HighlightRules;
var Mode = function() {
this.HighlightRules = IC10HighlightRules;
this.foldingRules = new FoldMode();
}
oop.inherits(Mode, TextMode);
(function() {
// configure comment start/end characters
this.lineCommentStart = ["#"];
this.$id = "ace/mode/ic10";
}).call(Mode.prototype);
exports.Mode = Mode;

78
www/src/index.js Normal file
View File

@@ -0,0 +1,78 @@
// import {init, VM} from "ic10emu_wasm";
import * as ace from "ace-code";
import {Mode as IC10Mode} from "./ic10_mode";
import * as theme from "ace-code/src/theme/one_dark";
import {AceLanguageClient} from "ace-linters/build/ace-language-client";
// init();
//
// const vm = VM.new();
// console.log(vm);
const demoCode = `# This is a comment
define a_def 10
define a_hash HASH("This is a String")
alias a_var r0
alias a_device d0
s d0 12 0
move r2 LogicType.Temperature
move r3 pinf
main:
l r1 dr15 RatioWater
move r2 100000.001
move r0 HASH("AccessCardBlack")
beqz r1 test
move r1 -2045627372
jal test
move r1 $FF
beqz 0 test
move r1 %1000
yield
j main
test:
add r15 r15 1
j ra
`
const mode = new IC10Mode()
var editor = ace.edit("editor", {
mode: mode,
value: demoCode,
// enableBasicAutocompletion: true,
// enableLiveAutocompletion: true,
// enableSnippets: true,
theme: theme,
customScrollbar: true,
});
const loaded = w =>
new Promise(r => w.addEventListener("message", r, { once: true }));
async function setupLsp() {
// Create a web worker
let worker = new Worker(new URL('./lspWorker.js', import.meta.url));
await Promise.all([loaded(worker)]);
const serverData = {
module: () => import("ace-linters/build/language-client"),
modes: "ic10",
type: "webworker",
worker: worker,
}
// Create a language provider for web worker
let languageProvider = AceLanguageClient.for(serverData);
// Register the editor with the language provider
languageProvider.registerEditor(editor);
let options = mode.options ?? {};
languageProvider.setSessionOptions(editor.session, options);
}
setupLsp();
editor.session.setValue(demoCode)

221
www/src/lspWorker.js Normal file
View File

@@ -0,0 +1,221 @@
import { ServerConfig, serve } from "ic10lsp_wasm";
import { v4 as uuidv4 } from 'uuid';
export const encoder = new TextEncoder();
export const decoder = new TextDecoder();
export default class Bytes {
static encode(input) {
return encoder.encode(input);
}
static decode(input) {
return decoder.decode(input);
}
static append(
constructor,
...arrays
) {
let totalLength = 0;
for (const arr of arrays) {
totalLength += arr.length;
}
const result = new constructor(totalLength);
let offset = 0;
for (const arr of arrays) {
result.set(arr, offset);
offset += arr.length;
}
return result;
}
}
export class AsyncStreamQueue {
promises = [];
resolvers = [];
observers = [];
closed = false;
locked = false;
tag = "";
static __add(promises, resolvers) {
promises.push(new Promise((resolve) => {
resolvers.push(resolve);
}))
}
static __enqueue(closed, promises, resolvers, item) {
if (!closed) {
if (!resolvers.length) AsyncStreamQueue.__add(promises, resolvers);
const resolve = resolvers.shift();
resolve(item);
}
}
constructor(tag) {
this.tag = tag;
const closed = this.closed;
// invariant: at least one of the arrays is empty
const promises = this.promises;
const resolvers = this.resolvers;
this.stream = new WritableStream({
write(item) {
AsyncStreamQueue.__enqueue(closed, promises, resolvers, item)
}
})
}
_add() {
return AsyncStreamQueue.__add(this.promises, this.resolvers);
}
enqueue(item) {
return AsyncStreamQueue.__enqueue(this.closed, this.promises, this.resolvers, item);
}
dequeue() {
if (!this.promises.length) this._add();
const item = this.promises.shift();
return item;
}
// now some utilities:
isEmpty() { // there are no values available
return !this.promises.length; // this.length <= 0
}
isBlocked() { // it's waiting for values
return !!this.resolvers.length; // this.length < 0
}
get length() {
return this.promises.length - this.resolvers.length;
}
return() {
return new Promise(() => { })
}
throw(err) {
return new Promise((_resolve, reject) => {
reject(err);
})
}
async next() {
const done = false;
console.log(`AsyncStream(${this.tag}) waiting for message`)
const value = await this.dequeue();
console.log(`AsyncStream(${this.tag}) got message`, decoder.decode(value))
return { done, value };
}
[Symbol.asyncIterator]() {
return this;
}
locked() {
return this.stream.locked;
}
abort(reason) {
return this.stream.abort(reason);
}
close() {
return this.stream.close();
}
getWriter() {
return this.stream.getWriter();
}
}
let clientMsgStream = new AsyncStreamQueue("client");
let serverMsgStream = new AsyncStreamQueue("server");
async function start() {
let config = new ServerConfig(clientMsgStream, serverMsgStream);
await serve(config);
}
function fixup(data) {
// data.id = uuidv4();
if (data.hasOwnProperty("params") && data.params.hasOwnProperty("rootUri") && data.params.rootUri === "") {
data.params.rootUri = null
}
if (data.hasOwnProperty("params") && data.params.hasOwnProperty("textDocument")) {
if (data.params.textDocument.hasOwnProperty("uri")) {
const match = data.params.textDocument.uri.match(/^file:\/\/\/(.*)/);
if (null == match) {
data.params.textDocument.uri = `file:///${data.params.textDocument.uri}`;
}
}
data.params.rootUri = null
}
return data
}
function sendClient(data) {
data = fixup(data);
const data_j = JSON.stringify(data);
const msg = `Content-Length: ${data_j.length}\r\n\r\n${data_j}`
clientMsgStream.enqueue(encoder.encode(msg));
}
async function listen() {
let contentLength = null;
let buffer = new Uint8Array();
console.log("Worker: listening for lsp messages...");
for await (const bytes of serverMsgStream) {
buffer = Bytes.append(Uint8Array, buffer, bytes);
// check if the content length is known
if (null == contentLength) {
// if not, try to match the prefixed headers
const match = Bytes.decode(buffer).match(/^Content-Length:\s*(\d+)\s*/);
if (null == match) continue;
// try to parse the content-length from the headers
const length = parseInt(match[1]);
if (isNaN(length)) throw new Error("invalid content length");
// slice the headers since we now have the content length
buffer = buffer.slice(match[0].length);
// set the content length
contentLength = length;
}
// if the buffer doesn't contain a full message; await another iteration
if (buffer.length < contentLength) continue;
// decode buffer to a string
const delimited = Bytes.decode(buffer);
// reset the buffer
buffer = buffer.slice(contentLength);
// reset the contentLength
contentLength = null;
const message = JSON.parse(delimited);
console.log("Lsp Message:", message);
postMessage(message)
}
console.log("Worker: lsp message queue done?");
}
listen();
postMessage("ready");
onmessage = function(e) {
console.log("Client Message:", e.data);
sendClient(e.data)
}
console.log("Starting LSP...");
start();

12
www/tsconfig.json Normal file
View File

@@ -0,0 +1,12 @@
{
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
"noImplicitAny": true,
"module": "es6",
"target": "es6",
"jsx": "react",
"allowJs": true,
"moduleResolution": "node"
}
}

41
www/webpack.config.js Normal file
View File

@@ -0,0 +1,41 @@
const CopyWebpackPlugin = require("copy-webpack-plugin");
const path = require('path');
module.exports = {
entry: "./src/bootstrap.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "bootstrap.js",
},
mode: "development",
plugins: [
new CopyWebpackPlugin({ patterns: ['index.html', 'css/*.css'] })
],
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.css$/i,
use: ["style-loader", "css-loader"],
}
],
// parser: {
// javascript : { importMeta: false }
// }
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
experiments: {
asyncWebAssembly: true,
syncWebAssembly: true,
},
// output: {
// filename: 'bundle.js',
// path: path.resolve(__dirname, 'dist'),
// },
};