diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 591978b..5abdd47 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -28,8 +28,8 @@ jobs: uses: dtolnay/rust-toolchain@stable with: targets: wasm32-unknown-unknown - - name: Install wasm-bindgen-cli - uses: jetli/wasm-bindgen-action@v0.2.0 + - name: Install wasm-pack-cli + uses: jetli/wasm-pack-action@v0.2.0 - name: Install, build, and upload your site output uses: withastro/action@v2 with: diff --git a/astro.config.mjs b/astro.config.mjs index 26613ff..fb50448 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -3,6 +3,8 @@ import starlight from "@astrojs/starlight"; import react from "@astrojs/react"; import starlightLinksValidator from "starlight-links-validator"; import starlightUtils from "@lorenzo_lewis/starlight-utils"; +import wasm from "vite-plugin-wasm"; + import shikiConfig from "./src/utils/shiki"; const playgroundSidebarEntry = { @@ -119,4 +121,9 @@ export default defineConfig({ ], }), ], + vite: { + plugins: [ + wasm(), + ], + } }); diff --git a/package.json b/package.json index 3f9797d..16d2d9b 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "scripts": { "dev": "pnpm build-wasm && astro dev", "start": "pnpm build-wasm && astro dev", - "build-wasm": "cargo build --manifest-path ./src/wasm/webcompiler/Cargo.toml --release --target wasm32-unknown-unknown --target-dir ./target_rust && wasm-bindgen --target web --out-dir ./src/wasm/webcompiler/pkg/ --out-name webcompiler ./target_rust/wasm32-unknown-unknown/release/webcompiler.wasm", + "build-wasm": "wasm-pack build --release ./src/wasm/webcompiler -- --features wee_alloc", "build": "pnpm build-wasm && astro check && astro build", "preview": "astro preview", "astro": "astro" @@ -32,7 +32,8 @@ "starlight-links-validator": "^0.7.1", "tm-themes": "^1.4.3", "typescript": "^5.4.5", - "use-immer": "^0.10.0" + "use-immer": "^0.10.0", + "vite-plugin-wasm": "^3.3.0" }, "devDependencies": { "sass": "^1.77.6" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 69d4a76..2a89ac2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,28 +13,28 @@ importers: version: 0.5.10(typescript@5.4.5) '@astrojs/react': specifier: ^3.6.0 - version: 3.6.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1)(react@18.3.1)(vite@5.2.13) + version: 3.6.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(vite@5.2.13(sass@1.77.6)) '@astrojs/starlight': specifier: ^0.24.2 - version: 0.24.2(astro@4.10.2) + version: 0.24.2(astro@4.10.2(sass@1.77.6)(typescript@5.4.5)) '@emotion/react': specifier: ^11.11.4 version: 11.11.4(@types/react@18.3.3)(react@18.3.1) '@emotion/styled': specifier: ^11.11.5 - version: 11.11.5(@emotion/react@11.11.4)(@types/react@18.3.3)(react@18.3.1) + version: 11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1) '@lorenzo_lewis/starlight-utils': specifier: ^0.1.1 - version: 0.1.1(@astrojs/starlight@0.24.2)(astro@4.10.2) + version: 0.1.1(@astrojs/starlight@0.24.2(astro@4.10.2(sass@1.77.6)(typescript@5.4.5)))(astro@4.10.2(sass@1.77.6)(typescript@5.4.5)) '@monaco-editor/react': specifier: ^4.6.0 - version: 4.6.0(monaco-editor@0.49.0)(react-dom@18.3.1)(react@18.3.1) + version: 4.6.0(monaco-editor@0.49.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@mui/icons-material': specifier: ^5.15.20 - version: 5.15.20(@mui/material@5.15.20)(@types/react@18.3.3)(react@18.3.1) + version: 5.15.20(@mui/material@5.15.20(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@emotion/styled@11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@types/react@18.3.3)(react@18.3.1) '@mui/material': specifier: ^5.15.20 - version: 5.15.20(@emotion/react@11.11.4)(@emotion/styled@11.11.5)(@types/react@18.3.3)(react-dom@18.3.1)(react@18.3.1) + version: 5.15.20(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@emotion/styled@11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@shikijs/monaco': specifier: ^1.7.0 version: 1.7.0 @@ -64,7 +64,7 @@ importers: version: 1.7.0 starlight-links-validator: specifier: ^0.7.1 - version: 0.7.1(@astrojs/starlight@0.24.2)(astro@4.10.2) + version: 0.7.1(@astrojs/starlight@0.24.2(astro@4.10.2(sass@1.77.6)(typescript@5.4.5)))(astro@4.10.2(sass@1.77.6)(typescript@5.4.5)) tm-themes: specifier: ^1.4.3 version: 1.4.3 @@ -74,6 +74,9 @@ importers: use-immer: specifier: ^0.10.0 version: 0.10.0(immer@10.1.1)(react@18.3.1) + vite-plugin-wasm: + specifier: ^3.3.0 + version: 3.3.0(vite@5.2.13(sass@1.77.6)) devDependencies: sass: specifier: ^1.77.6 @@ -2823,6 +2826,11 @@ packages: vfile@6.0.1: resolution: {integrity: sha512-1bYqc7pt6NIADBJ98UiG0Bn/CHIVOoZ/IyEkqIruLg0mE1BKzkOXY2D6CSqQIcKqgadppE5lrxgWXJmXd7zZJw==} + vite-plugin-wasm@3.3.0: + resolution: {integrity: sha512-tVhz6w+W9MVsOCHzxo6SSMSswCeIw4HTrXEi6qL3IRzATl83jl09JVO1djBqPSwfjgnpVHNLYcaMbaDX5WB/pg==} + peerDependencies: + vite: ^2 || ^3 || ^4 || ^5 + vite@5.2.13: resolution: {integrity: sha512-SSq1noJfY9pR3I1TUENL3rQYDQCFqgD+lM6fTRAM8Nv6Lsg5hDLaXkjETVeBt+7vZBCMoibD+6IWnT2mJ+Zb/A==} engines: {node: ^18.0.0 || >=20.0.0} @@ -3082,7 +3090,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@astrojs/mdx@3.1.0(astro@4.10.2)': + '@astrojs/mdx@3.1.0(astro@4.10.2(sass@1.77.6)(typescript@5.4.5))': dependencies: '@astrojs/markdown-remark': 5.1.0 '@mdx-js/mdx': 3.0.1 @@ -3107,11 +3115,11 @@ snapshots: dependencies: prismjs: 1.29.0 - '@astrojs/react@3.6.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1)(react@18.3.1)(vite@5.2.13)': + '@astrojs/react@3.6.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(vite@5.2.13(sass@1.77.6))': dependencies: '@types/react': 18.3.3 '@types/react-dom': 18.3.0 - '@vitejs/plugin-react': 4.3.1(vite@5.2.13) + '@vitejs/plugin-react': 4.3.1(vite@5.2.13(sass@1.77.6)) react: 18.3.1 react-dom: 18.3.1(react@18.3.1) ultrahtml: 1.5.3 @@ -3125,15 +3133,15 @@ snapshots: stream-replace-string: 2.0.0 zod: 3.23.8 - '@astrojs/starlight@0.24.2(astro@4.10.2)': + '@astrojs/starlight@0.24.2(astro@4.10.2(sass@1.77.6)(typescript@5.4.5))': dependencies: - '@astrojs/mdx': 3.1.0(astro@4.10.2) + '@astrojs/mdx': 3.1.0(astro@4.10.2(sass@1.77.6)(typescript@5.4.5)) '@astrojs/sitemap': 3.1.5 '@pagefind/default-ui': 1.1.0 '@types/hast': 3.0.4 '@types/mdast': 4.0.4 astro: 4.10.2(sass@1.77.6)(typescript@5.4.5) - astro-expressive-code: 0.35.3(astro@4.10.2) + astro-expressive-code: 0.35.3(astro@4.10.2(sass@1.77.6)(typescript@5.4.5)) bcp-47: 2.1.0 hast-util-from-html: 2.0.1 hast-util-select: 6.0.2 @@ -3403,9 +3411,10 @@ snapshots: '@emotion/use-insertion-effect-with-fallbacks': 1.0.1(react@18.3.1) '@emotion/utils': 1.2.1 '@emotion/weak-memoize': 0.3.1 - '@types/react': 18.3.3 hoist-non-react-statics: 3.3.2 react: 18.3.1 + optionalDependencies: + '@types/react': 18.3.3 transitivePeerDependencies: - supports-color @@ -3419,7 +3428,7 @@ snapshots: '@emotion/sheet@1.2.2': {} - '@emotion/styled@11.11.5(@emotion/react@11.11.4)(@types/react@18.3.3)(react@18.3.1)': + '@emotion/styled@11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1)': dependencies: '@babel/runtime': 7.24.7 '@emotion/babel-plugin': 11.11.0 @@ -3428,8 +3437,9 @@ snapshots: '@emotion/serialize': 1.1.4 '@emotion/use-insertion-effect-with-fallbacks': 1.0.1(react@18.3.1) '@emotion/utils': 1.2.1 - '@types/react': 18.3.3 react: 18.3.1 + optionalDependencies: + '@types/react': 18.3.3 transitivePeerDependencies: - supports-color @@ -3615,7 +3625,7 @@ snapshots: '@floating-ui/core': 1.6.2 '@floating-ui/utils': 0.2.2 - '@floating-ui/react-dom@2.1.0(react-dom@18.3.1)(react@18.3.1)': + '@floating-ui/react-dom@2.1.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': dependencies: '@floating-ui/dom': 1.6.5 react: 18.3.1 @@ -3722,11 +3732,11 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.4.15 - '@lorenzo_lewis/starlight-utils@0.1.1(@astrojs/starlight@0.24.2)(astro@4.10.2)': + '@lorenzo_lewis/starlight-utils@0.1.1(@astrojs/starlight@0.24.2(astro@4.10.2(sass@1.77.6)(typescript@5.4.5)))(astro@4.10.2(sass@1.77.6)(typescript@5.4.5))': dependencies: - '@astrojs/starlight': 0.24.2(astro@4.10.2) + '@astrojs/starlight': 0.24.2(astro@4.10.2(sass@1.77.6)(typescript@5.4.5)) astro: 4.10.2(sass@1.77.6)(typescript@5.4.5) - astro-integration-kit: 0.13.3(astro@4.10.2) + astro-integration-kit: 0.13.3(astro@4.10.2(sass@1.77.6)(typescript@5.4.5)) transitivePeerDependencies: - '@astrojs/db' @@ -3763,46 +3773,45 @@ snapshots: monaco-editor: 0.49.0 state-local: 1.0.7 - '@monaco-editor/react@4.6.0(monaco-editor@0.49.0)(react-dom@18.3.1)(react@18.3.1)': + '@monaco-editor/react@4.6.0(monaco-editor@0.49.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': dependencies: '@monaco-editor/loader': 1.4.0(monaco-editor@0.49.0) monaco-editor: 0.49.0 react: 18.3.1 react-dom: 18.3.1(react@18.3.1) - '@mui/base@5.0.0-beta.40(@types/react@18.3.3)(react-dom@18.3.1)(react@18.3.1)': + '@mui/base@5.0.0-beta.40(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': dependencies: '@babel/runtime': 7.24.7 - '@floating-ui/react-dom': 2.1.0(react-dom@18.3.1)(react@18.3.1) + '@floating-ui/react-dom': 2.1.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@mui/types': 7.2.14(@types/react@18.3.3) '@mui/utils': 5.15.20(@types/react@18.3.3)(react@18.3.1) '@popperjs/core': 2.11.8 - '@types/react': 18.3.3 clsx: 2.1.1 prop-types: 15.8.1 react: 18.3.1 react-dom: 18.3.1(react@18.3.1) + optionalDependencies: + '@types/react': 18.3.3 '@mui/core-downloads-tracker@5.15.20': {} - '@mui/icons-material@5.15.20(@mui/material@5.15.20)(@types/react@18.3.3)(react@18.3.1)': + '@mui/icons-material@5.15.20(@mui/material@5.15.20(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@emotion/styled@11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@types/react@18.3.3)(react@18.3.1)': dependencies: '@babel/runtime': 7.24.7 - '@mui/material': 5.15.20(@emotion/react@11.11.4)(@emotion/styled@11.11.5)(@types/react@18.3.3)(react-dom@18.3.1)(react@18.3.1) - '@types/react': 18.3.3 + '@mui/material': 5.15.20(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@emotion/styled@11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) react: 18.3.1 + optionalDependencies: + '@types/react': 18.3.3 - '@mui/material@5.15.20(@emotion/react@11.11.4)(@emotion/styled@11.11.5)(@types/react@18.3.3)(react-dom@18.3.1)(react@18.3.1)': + '@mui/material@5.15.20(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@emotion/styled@11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': dependencies: '@babel/runtime': 7.24.7 - '@emotion/react': 11.11.4(@types/react@18.3.3)(react@18.3.1) - '@emotion/styled': 11.11.5(@emotion/react@11.11.4)(@types/react@18.3.3)(react@18.3.1) - '@mui/base': 5.0.0-beta.40(@types/react@18.3.3)(react-dom@18.3.1)(react@18.3.1) + '@mui/base': 5.0.0-beta.40(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@mui/core-downloads-tracker': 5.15.20 - '@mui/system': 5.15.20(@emotion/react@11.11.4)(@emotion/styled@11.11.5)(@types/react@18.3.3)(react@18.3.1) + '@mui/system': 5.15.20(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@emotion/styled@11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1) '@mui/types': 7.2.14(@types/react@18.3.3) '@mui/utils': 5.15.20(@types/react@18.3.3)(react@18.3.1) - '@types/react': 18.3.3 '@types/react-transition-group': 4.4.10 clsx: 2.1.1 csstype: 3.1.3 @@ -3810,53 +3819,61 @@ snapshots: react: 18.3.1 react-dom: 18.3.1(react@18.3.1) react-is: 18.3.1 - react-transition-group: 4.4.5(react-dom@18.3.1)(react@18.3.1) + react-transition-group: 4.4.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + optionalDependencies: + '@emotion/react': 11.11.4(@types/react@18.3.3)(react@18.3.1) + '@emotion/styled': 11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1) + '@types/react': 18.3.3 '@mui/private-theming@5.15.20(@types/react@18.3.3)(react@18.3.1)': dependencies: '@babel/runtime': 7.24.7 '@mui/utils': 5.15.20(@types/react@18.3.3)(react@18.3.1) - '@types/react': 18.3.3 prop-types: 15.8.1 react: 18.3.1 + optionalDependencies: + '@types/react': 18.3.3 - '@mui/styled-engine@5.15.14(@emotion/react@11.11.4)(@emotion/styled@11.11.5)(react@18.3.1)': + '@mui/styled-engine@5.15.14(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@emotion/styled@11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1))(react@18.3.1)': dependencies: '@babel/runtime': 7.24.7 '@emotion/cache': 11.11.0 - '@emotion/react': 11.11.4(@types/react@18.3.3)(react@18.3.1) - '@emotion/styled': 11.11.5(@emotion/react@11.11.4)(@types/react@18.3.3)(react@18.3.1) csstype: 3.1.3 prop-types: 15.8.1 react: 18.3.1 + optionalDependencies: + '@emotion/react': 11.11.4(@types/react@18.3.3)(react@18.3.1) + '@emotion/styled': 11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1) - '@mui/system@5.15.20(@emotion/react@11.11.4)(@emotion/styled@11.11.5)(@types/react@18.3.3)(react@18.3.1)': + '@mui/system@5.15.20(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@emotion/styled@11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1)': dependencies: '@babel/runtime': 7.24.7 - '@emotion/react': 11.11.4(@types/react@18.3.3)(react@18.3.1) - '@emotion/styled': 11.11.5(@emotion/react@11.11.4)(@types/react@18.3.3)(react@18.3.1) '@mui/private-theming': 5.15.20(@types/react@18.3.3)(react@18.3.1) - '@mui/styled-engine': 5.15.14(@emotion/react@11.11.4)(@emotion/styled@11.11.5)(react@18.3.1) + '@mui/styled-engine': 5.15.14(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@emotion/styled@11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1))(react@18.3.1) '@mui/types': 7.2.14(@types/react@18.3.3) '@mui/utils': 5.15.20(@types/react@18.3.3)(react@18.3.1) - '@types/react': 18.3.3 clsx: 2.1.1 csstype: 3.1.3 prop-types: 15.8.1 react: 18.3.1 + optionalDependencies: + '@emotion/react': 11.11.4(@types/react@18.3.3)(react@18.3.1) + '@emotion/styled': 11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1) + '@types/react': 18.3.3 '@mui/types@7.2.14(@types/react@18.3.3)': - dependencies: + optionalDependencies: '@types/react': 18.3.3 '@mui/utils@5.15.20(@types/react@18.3.3)(react@18.3.1)': dependencies: '@babel/runtime': 7.24.7 '@types/prop-types': 15.7.12 - '@types/react': 18.3.3 prop-types: 15.8.1 react: 18.3.1 react-is: 18.3.1 + optionalDependencies: + '@types/react': 18.3.3 '@nodelib/fs.scandir@2.1.5': dependencies: @@ -4029,7 +4046,7 @@ snapshots: '@ungap/structured-clone@1.2.0': {} - '@vitejs/plugin-react@4.3.1(vite@5.2.13)': + '@vitejs/plugin-react@4.3.1(vite@5.2.13(sass@1.77.6))': dependencies: '@babel/core': 7.24.7 '@babel/plugin-transform-react-jsx-self': 7.24.7(@babel/core@7.24.7) @@ -4149,12 +4166,12 @@ snapshots: astring@1.8.6: {} - astro-expressive-code@0.35.3(astro@4.10.2): + astro-expressive-code@0.35.3(astro@4.10.2(sass@1.77.6)(typescript@5.4.5)): dependencies: astro: 4.10.2(sass@1.77.6)(typescript@5.4.5) rehype-expressive-code: 0.35.3 - astro-integration-kit@0.13.3(astro@4.10.2): + astro-integration-kit@0.13.3(astro@4.10.2(sass@1.77.6)(typescript@5.4.5)): dependencies: astro: 4.10.2(sass@1.77.6)(typescript@5.4.5) pathe: 1.1.2 @@ -4220,7 +4237,7 @@ snapshots: unist-util-visit: 5.0.0 vfile: 6.0.1 vite: 5.2.13(sass@1.77.6) - vitefu: 0.2.5(vite@5.2.13) + vitefu: 0.2.5(vite@5.2.13(sass@1.77.6)) which-pm: 2.2.0 yargs-parser: 21.1.1 zod: 3.23.8 @@ -5780,7 +5797,7 @@ snapshots: react-refresh@0.14.2: {} - react-transition-group@4.4.5(react-dom@18.3.1)(react@18.3.1): + react-transition-group@4.4.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1): dependencies: '@babel/runtime': 7.24.7 dom-helpers: 5.2.1 @@ -6129,9 +6146,9 @@ snapshots: sprintf-js@1.0.3: {} - starlight-links-validator@0.7.1(@astrojs/starlight@0.24.2)(astro@4.10.2): + starlight-links-validator@0.7.1(@astrojs/starlight@0.24.2(astro@4.10.2(sass@1.77.6)(typescript@5.4.5)))(astro@4.10.2(sass@1.77.6)(typescript@5.4.5)): dependencies: - '@astrojs/starlight': 0.24.2(astro@4.10.2) + '@astrojs/starlight': 0.24.2(astro@4.10.2(sass@1.77.6)(typescript@5.4.5)) astro: 4.10.2(sass@1.77.6)(typescript@5.4.5) github-slugger: 2.0.0 hast-util-from-html: 2.0.1 @@ -6262,7 +6279,7 @@ snapshots: trough@2.2.0: {} tsconfck@3.1.0(typescript@5.4.5): - dependencies: + optionalDependencies: typescript: 5.4.5 tslib@2.6.3: {} @@ -6420,57 +6437,66 @@ snapshots: unist-util-stringify-position: 4.0.0 vfile-message: 4.0.2 + vite-plugin-wasm@3.3.0(vite@5.2.13(sass@1.77.6)): + dependencies: + vite: 5.2.13(sass@1.77.6) + vite@5.2.13(sass@1.77.6): dependencies: esbuild: 0.20.2 postcss: 8.4.38 rollup: 4.18.0 - sass: 1.77.6 optionalDependencies: fsevents: 2.3.3 + sass: 1.77.6 - vitefu@0.2.5(vite@5.2.13): - dependencies: + vitefu@0.2.5(vite@5.2.13(sass@1.77.6)): + optionalDependencies: vite: 5.2.13(sass@1.77.6) volar-service-css@0.0.45(@volar/language-service@2.2.5): dependencies: - '@volar/language-service': 2.2.5 vscode-css-languageservice: 6.2.14 vscode-languageserver-textdocument: 1.0.11 vscode-uri: 3.0.8 + optionalDependencies: + '@volar/language-service': 2.2.5 volar-service-emmet@0.0.45(@volar/language-service@2.2.5): dependencies: '@emmetio/css-parser': 0.4.0 '@emmetio/html-matcher': 1.3.0 - '@volar/language-service': 2.2.5 '@vscode/emmet-helper': 2.9.3 + optionalDependencies: + '@volar/language-service': 2.2.5 volar-service-html@0.0.45(@volar/language-service@2.2.5): dependencies: - '@volar/language-service': 2.2.5 vscode-html-languageservice: '@johnsoncodehk/vscode-html-languageservice@5.2.0-34a5462' vscode-languageserver-textdocument: 1.0.11 vscode-uri: 3.0.8 + optionalDependencies: + '@volar/language-service': 2.2.5 volar-service-prettier@0.0.45(@volar/language-service@2.2.5): dependencies: - '@volar/language-service': 2.2.5 vscode-uri: 3.0.8 + optionalDependencies: + '@volar/language-service': 2.2.5 volar-service-typescript-twoslash-queries@0.0.45(@volar/language-service@2.2.5): - dependencies: + optionalDependencies: '@volar/language-service': 2.2.5 volar-service-typescript@0.0.45(@volar/language-service@2.2.5): dependencies: - '@volar/language-service': 2.2.5 path-browserify: 1.0.1 semver: 7.6.2 typescript-auto-import-cache: 0.3.2 vscode-languageserver-textdocument: 1.0.11 vscode-nls: 5.2.0 + optionalDependencies: + '@volar/language-service': 2.2.5 vscode-css-languageservice@6.2.14: dependencies: diff --git a/src/components/Playground.tsx b/src/components/Playground.tsx index 706ec86..439bba1 100644 --- a/src/components/Playground.tsx +++ b/src/components/Playground.tsx @@ -7,7 +7,7 @@ import FileView from "./playground/FileView"; import Editor from "./playground/Editor"; import Header from "./playground/Header"; -import initWasm, { +import { compile, compileZip, } from "@wasm/webcompiler/pkg/webcompiler"; @@ -52,10 +52,6 @@ export default function Playground({ lang }: { lang: PlaygroundLang }) { }; }, []); - initWasm().catch((err) => { - console.error(err); - }); - const [rootDir, updateRootDir] = useImmer( getStorageOrDefault(FILE_STORAGE_KEY, DEFAULT_FILES) as Directory ); diff --git a/src/wasm/webcompiler/Cargo.lock b/src/wasm/webcompiler/Cargo.lock index cb9179e..167d867 100644 --- a/src/wasm/webcompiler/Cargo.lock +++ b/src/wasm/webcompiler/Cargo.lock @@ -54,6 +54,12 @@ version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + [[package]] name = "cfg-if" version = "1.0.0" @@ -112,7 +118,7 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "wasm-bindgen", ] @@ -122,7 +128,7 @@ version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -271,6 +277,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +[[package]] +name = "libc" +version = "0.2.159" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" + [[package]] name = "lockfree-object-pool" version = "0.1.6" @@ -289,6 +301,12 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +[[package]] +name = "memory_units" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" + [[package]] name = "miniz_oxide" version = "0.8.0" @@ -467,6 +485,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" +dependencies = [ + "serde", +] + [[package]] name = "shulkerbox" version = "0.1.0" @@ -566,6 +593,40 @@ dependencies = [ "syn", ] +[[package]] +name = "toml" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "tracing" version = "0.1.40" @@ -609,7 +670,7 @@ version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "once_cell", "wasm-bindgen-macro", ] @@ -665,15 +726,52 @@ dependencies = [ "ansi-to-html", "anyhow", "base64", + "cfg-if 1.0.0", "colored", "console_error_panic_hook", "serde", "serde-wasm-bindgen", "shulkerscript", + "toml", "wasm-bindgen", + "wee_alloc", "zip", ] +[[package]] +name = "wee_alloc" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "memory_units", + "winapi", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + [[package]] name = "windows-sys" version = "0.48.0" @@ -740,6 +838,15 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "winnow" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +dependencies = [ + "memchr", +] + [[package]] name = "zip" version = "2.2.0" diff --git a/src/wasm/webcompiler/Cargo.toml b/src/wasm/webcompiler/Cargo.toml index 2226266..1ae3a9a 100644 --- a/src/wasm/webcompiler/Cargo.toml +++ b/src/wasm/webcompiler/Cargo.toml @@ -7,7 +7,10 @@ edition = "2021" crate-type = ["cdylib"] [profile.release] -opt-level = "s" +opt-level = "z" + +[features] +wee_alloc = ["dep:wee_alloc"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -15,11 +18,13 @@ opt-level = "s" ansi-to-html = "0.2.1" anyhow = "1.0.86" base64 = "0.22.1" +cfg-if = "1.0.0" colored = "2.1.0" console_error_panic_hook = "0.1.7" serde = "1.0" serde-wasm-bindgen = "0.6.5" shulkerscript = { git = "https://github.com/moritz-hoelting/shulkerscript-lang.git", default-features = false, features = ["serde", "shulkerbox"], rev = "a9a8aff13b0ad0986ee1bdf3d44b74676385dfcd" } toml = "0.8.19" -wasm-bindgen = "0.2.92" +wasm-bindgen = "0.2.93" +wee_alloc = { version = "0.4.5", optional = true } zip = { version = "2.1.3", default-features = false, features = ["deflate"] } diff --git a/src/wasm/webcompiler/src/lib.rs b/src/wasm/webcompiler/src/lib.rs index 034eb9d..b2117a4 100644 --- a/src/wasm/webcompiler/src/lib.rs +++ b/src/wasm/webcompiler/src/lib.rs @@ -18,6 +18,13 @@ use zip::{write::SimpleFileOptions, ZipWriter}; mod fs; mod pack_toml; +cfg_if::cfg_if! { + if #[cfg(feature = "wee_alloc")] { + #[global_allocator] + static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; + } +} + #[wasm_bindgen] extern "C" { #[wasm_bindgen(js_namespace = console)]