Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
target:
- nodejs
- bundler
include:
- crate: sandbox
target: bundler
steps:
- uses: actions/checkout@v6

Expand Down
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ src := 'target/' + target + '/release/saturn-v' + binary_ext
package_name := 'saturn-v-' + github_ref_name + package_postfix

wasm crate target:
RUSTFLAGS="-C opt-level=z -C codegen-units=1 -C panic=abort" wasm-pack build crates/{{crate}} --release --target {{target}}
RUSTFLAGS="-C opt-level=z -C codegen-units=1 -C panic=abort" wasm-pack build crates/{{crate}} --release --target {{target}} --keep-going
wasm-pack pack crates/{{crate}}
mkdir -p pkg
mv crates/{{crate}}/pkg/*.tgz pkg/{{crate}}-{{target}}.tgz
Expand Down
1 change: 1 addition & 0 deletions crates/sandbox/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/dist
21 changes: 21 additions & 0 deletions crates/sandbox/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "saturn-v-sandbox"
license.workspace = true
edition.workspace = true
version.workspace = true
authors.workspace = true
repository.workspace = true
rust-version.workspace = true

[lib]
crate-type = ["rlib", "cdylib"]

[dependencies]
console_error_panic_hook.workspace = true
leptos.workspace = true
saturn-v-lsp.workspace = true
wasm-bindgen.workspace = true

[dependencies.web-sys]
workspace = true
features = ["Element"]
10 changes: 10 additions & 0 deletions crates/sandbox/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Saturn V Sandbox</title>
<link data-trunk rel="rust" data-bin="saturn-v-sandbox" data- data-wasm-opt="z"/>
</head>
<body>
</body>
</html>
61 changes: 61 additions & 0 deletions crates/sandbox/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright (C) 2025-2026 Marceline Cramer
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// Saturn V is free software: you can redistribute it and/or modify it under
// the terms of the GNU Affero General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option) any
// later version.
//
// Saturn V is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
// more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Saturn V. If not, see <https://www.gnu.org/licenses/>.

use leptos::{html::Div, prelude::*};
use wasm_bindgen::prelude::*;
use web_sys::{
js_sys::{self, Reflect},
Element,
};

#[wasm_bindgen]
pub fn mount(el: Element) {
console_error_panic_hook::set_once();
mount_to(el.dyn_into().unwrap(), App).forget();
}

#[component]
pub fn App() -> impl IntoView {
view! {
<p>"The sandbox will go here."</p>
<Editor/>
}
}

#[component]
fn Editor() -> impl IntoView {
let node = NodeRef::<Div>::new();

node.on_load(|node| {
let config = js_sys::Object::new();
Reflect::set(&config, &"doc".into(), &"test contents\n".into()).unwrap();
Reflect::set(&config, &"parent".into(), node.dyn_ref().unwrap()).unwrap();
Reflect::set(&config, &"extensions".into(), &basicSetup).unwrap();

Check warning on line 46 in crates/sandbox/src/lib.rs

View workflow job for this annotation

GitHub Actions / Tests

use of deprecated static `basicSetup`: use with `#[wasm_bindgen(thread_local_v2)]` instead

Check warning on line 46 in crates/sandbox/src/lib.rs

View workflow job for this annotation

GitHub Actions / WebAssembly packages / Build WebAssembly (sandbox, bundler)

use of deprecated static `basicSetup`: use with `#[wasm_bindgen(thread_local_v2)]` instead
EditorView::new(config);
});

view! { <div node_ref=node /> }
}

#[wasm_bindgen(module = "https://esm.sh/codemirror@6.0.2")]
extern "C" {
pub type EditorView;

#[wasm_bindgen(constructor)]
pub fn new(args: js_sys::Object) -> EditorView;

static basicSetup: JsValue;

Check warning on line 60 in crates/sandbox/src/lib.rs

View workflow job for this annotation

GitHub Actions / Tests

static variable `basicSetup` should have an upper case name

Check warning on line 60 in crates/sandbox/src/lib.rs

View workflow job for this annotation

GitHub Actions / Tests

use of deprecated field `wasm_bindgen::JsStatic::__inner`: use with `#[wasm_bindgen(thread_local_v2)]` instead

Check warning on line 60 in crates/sandbox/src/lib.rs

View workflow job for this annotation

GitHub Actions / Tests

use of deprecated struct `wasm_bindgen::JsStatic`: use with `#[wasm_bindgen(thread_local_v2)]` instead

Check warning on line 60 in crates/sandbox/src/lib.rs

View workflow job for this annotation

GitHub Actions / WebAssembly packages / Build WebAssembly (sandbox, bundler)

static variable `basicSetup` should have an upper case name

Check warning on line 60 in crates/sandbox/src/lib.rs

View workflow job for this annotation

GitHub Actions / WebAssembly packages / Build WebAssembly (sandbox, bundler)

use of deprecated field `wasm_bindgen::JsStatic::__inner`: use with `#[wasm_bindgen(thread_local_v2)]` instead

Check warning on line 60 in crates/sandbox/src/lib.rs

View workflow job for this annotation

GitHub Actions / WebAssembly packages / Build WebAssembly (sandbox, bundler)

use of deprecated struct `wasm_bindgen::JsStatic`: use with `#[wasm_bindgen(thread_local_v2)]` instead
}
20 changes: 20 additions & 0 deletions crates/sandbox/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (C) 2025-2026 Marceline Cramer
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// Saturn V is free software: you can redistribute it and/or modify it under
// the terms of the GNU Affero General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option) any
// later version.
//
// Saturn V is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
// more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Saturn V. If not, see <https://www.gnu.org/licenses/>.

fn main() {
console_error_panic_hook::set_once();
leptos::mount::mount_to_body(saturn_v_sandbox::App);
}
Loading