Skip to content

Commit

Permalink
Update to v1.1.1; refactor code structure, enhance worker processes, …
Browse files Browse the repository at this point in the history
…and improve default behavior
  • Loading branch information
oligamiq committed Dec 18, 2024
1 parent ae27672 commit d1b7df7
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 30 deletions.
4 changes: 4 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ File size reduction due to brotli compression.
Change wasm compile method from compile to compileStreaming.
- lazy loading monaco editor

# v1.1.1 (2024-12-18)
- change default code.
- moved the file with the code that runs on the worker to another directory.

## v1.0.0 (2024-11-26)
- Initial release
Binary file modified bun.lockb
Binary file not shown.
10 changes: 3 additions & 7 deletions lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oligami/rustc-browser-wasi_shim",
"version": "1.1.0",
"version": "1.1.1",
"type": "module",
"scripts": {
"dev": "vite",
Expand All @@ -14,8 +14,7 @@
"@bjorn3/browser_wasi_shim": "^0.3.0",
"@oligami/browser_wasi_shim-threads": "^0.1.1",
"@oligami/rustc-browser-wasi_shim": "file:",
"brotli-dec-wasm": "^2.3.0",
"nanotar": "^0.1.1"
"brotli-dec-wasm": "^2.3.0"
},
"private": false,
"publishConfig": {
Expand Down Expand Up @@ -52,9 +51,6 @@
"default": "./dist/rustc-browser-wasi_shim.es.js"
}
},
"files": [
"dist",
"src"
],
"files": ["dist", "src"],
"keywords": []
}
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rubrc",
"version": "1.1.0",
"version": "1.1.1",
"description": "rubrc root",
"private": true,
"directories": {
Expand All @@ -9,17 +9,18 @@
},
"author": "oligami <nziq53@gmail.com> (https://github.com/oligamiq)",
"license": "MIT OR Apache-2.0",
"type": "module",
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@swc/cli": "^0.5.2",
"@swc/core": "^1.10.0",
"@swc/core": "^1.10.1",
"@types/tar-stream": "^3.1.3",
"autoprefixer": "^10.4.20",
"better-typescript-lib": "^2.10.0",
"npm-watch": "^0.13.0",
"postcss": "^8.4.49",
"solid-devtools": "^0.30.1",
"tailwindcss": "^3.4.16",
"solid-devtools": "^0.31.4",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
"unplugin-swc": "^1.5.1",
"vite": "^6.0.3",
Expand Down
4 changes: 2 additions & 2 deletions page/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "rubrc",
"version": "1.1.0",
"version": "1.1.1",
"description": "rubrc example page",
"private": true,
"author": "oligami <nziq53@gmail.com> (https://github.com/oligamiq)",
"license": "MIT OR Apache-2.0",
"type": "module",
"scripts": {
"start": "vite",
"dev": "vite",
Expand All @@ -20,7 +21,6 @@
"@xterm/addon-fit": "^0.10.0",
"@xterm/addon-search": "^0.15.0",
"@xterm/xterm": "^5.5.0",
"install": "^0.13.0",
"nanotar": "^0.1.1",
"rubrc": "file:",
"solid-js": "^1.9.3",
Expand Down
2 changes: 1 addition & 1 deletion page/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
purge: ["./index.html", "./src/**/*.{vue,js,ts,jsx,tsx}"],
plugins: {
tailwindcss: {},
Expand Down
11 changes: 10 additions & 1 deletion page/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@ import type { Ctx } from "./ctx";
import { default_value, rust_file } from "./config";
import { DownloadButton, RunButton } from "./btn";
import { triples } from "./sysroot";
import { Select } from "@thisbeyond/solid-select";

const Select = lazy(async () => {
const selector = import("@thisbeyond/solid-select");
const css_load = import("@thisbeyond/solid-select/style.css");

const [mod] = await Promise.all([selector, css_load]);

return { default: mod.Select };
});

import { SharedObjectRef } from "@oligami/shared-object";
const MonacoEditor = lazy(() =>
import("solid-monaco").then((mod) => ({ default: mod.MonacoEditor })),
Expand Down
12 changes: 11 additions & 1 deletion page/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@ import { File } from "@bjorn3/browser_wasi_shim";

export const default_value = `// /main.rs
fn main() {
println!("Hello, world!");
let first_time = std::time::SystemTime::now();
let count = std::env::args()
.nth(1)
.map(|arg| arg.parse::<usize>().ok())
.flatten()
.unwrap_or(10);
(0..=count).for_each(|i| println!("{i}"));
println!("Time: {:?}", first_time.elapsed().unwrap());
}
`;

Expand Down
3 changes: 1 addition & 2 deletions page/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import { render } from "solid-js/web";

import App from "./App";
import { gen_ctx } from "./ctx";
import MainWorker from "./worker?worker";
import MainWorker from "./worker_process/worker?worker";
import { parser_setup } from "./cmd_parser";
import "./monaco_worker";
import { compile_and_run_setup } from "./compile_and_run";
import "@thisbeyond/solid-select/style.css";

const root = document.getElementById("root");

Expand Down
1 change: 1 addition & 0 deletions page/src/solid_xterm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// solid-xterm's code fork
// https://github.com/WVAviator/solid-xterm

import { createEffect, createSignal, onCleanup } from "solid-js";
import {
Expand Down
2 changes: 2 additions & 0 deletions page/src/sysroot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export const triples = [
"riscv64gc-unknown-linux-musl",
"s390x-unknown-linux-gnu",
"sparcv9-sun-solaris",
"wasm32-unknown-emscripten",
"wasm32-unknown-unknown",
"wasm32-wasip1-threads",
"wasm32-wasip1",
"x86_64-pc-windows-gnu",
Expand Down
4 changes: 2 additions & 2 deletions page/src/llvm.ts → page/src/worker_process/llvm.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SharedObject, SharedObjectRef } from "@oligami/shared-object";
import { WASIFarmAnimal } from "@oligami/browser_wasi_shim-threads";
import type { Ctx } from "./ctx";
import type { Ctx } from "../ctx";

const shared: SharedObject[] = [];

Expand Down Expand Up @@ -28,7 +28,7 @@ globalThis.addEventListener("message", async (event) => {
await ready_llvm_wasm(wasi_refs, ctx);
});

import { get_llvm_wasm } from "../../lib/src/get_llvm_wasm";
import { get_llvm_wasm } from "../../../lib/src/get_llvm_wasm";
import { strace } from "@bjorn3/browser_wasi_shim";
let linker: WebAssembly.Instance & {
exports: { memory: WebAssembly.Memory; _start: () => unknown };
Expand Down
4 changes: 2 additions & 2 deletions page/src/rustc.ts → page/src/worker_process/rustc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SharedObject, SharedObjectRef } from "@oligami/shared-object";
import { get_rustc_wasm } from "../../lib/src/get_rustc_wasm";
import { get_rustc_wasm } from "../../../lib/src/get_rustc_wasm";
import { WASIFarmAnimal } from "@oligami/browser_wasi_shim-threads";
import type { Ctx } from "./ctx";
import type { Ctx } from "../ctx";

import thread_spawn_path from "./thread_spawn.ts?worker&url";

Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions page/src/util_cmd.ts → page/src/worker_process/util_cmd.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { SharedObject, SharedObjectRef } from "@oligami/shared-object";
import { WASIFarmAnimal } from "@oligami/browser_wasi_shim-threads";
import type { Ctx } from "./ctx";
import lsr from "./wasm/lsr.wasm?url";
import tre from "./wasm/tre.wasm?url";
import { get_data } from "./cat";
import type { Ctx } from "../ctx";
import lsr from "../wasm/lsr.wasm?url";
import tre from "../wasm/tre.wasm?url";
import { get_data } from "../cat";

const shared: SharedObject[] = [];

Expand Down
8 changes: 4 additions & 4 deletions page/src/worker.ts → page/src/worker_process/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { SharedObject, SharedObjectRef } from "@oligami/shared-object";
import {
get_default_sysroot_wasi_farm,
load_additional_sysroot,
} from "../../lib/src/sysroot";
import type { Ctx } from "./ctx";
} from "../../../lib/src/sysroot";
import type { Ctx } from "../ctx";

let terminal: (string) => Promise<void>;
let rustc_worker: Worker;
Expand Down Expand Up @@ -56,8 +56,8 @@ globalThis.addEventListener("message", async (event) => {
}
});

import util_cmd_worker from "./util_cmd.ts?worker";
import run_llvm_worker from "./llvm.ts?worker";
import util_cmd_worker from "./util_cmd?worker";
import run_llvm_worker from "./llvm?worker";

const setup_util_worker = (
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
Expand Down

0 comments on commit d1b7df7

Please sign in to comment.