toiljs 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/prettier.xml +1 -0
- package/as-pect.config.js +1 -1
- package/build/backend/.tsbuildinfo +1 -1
- package/build/backend/index.js +1 -2
- package/build/cli/.tsbuildinfo +1 -1
- package/build/cli/configure.d.ts +15 -0
- package/build/cli/configure.js +201 -0
- package/build/cli/create.d.ts +4 -0
- package/build/cli/create.js +168 -57
- package/build/cli/features.d.ts +23 -0
- package/build/cli/features.js +85 -0
- package/build/cli/index.js +42 -2
- package/build/cli/proc.d.ts +1 -0
- package/build/cli/proc.js +11 -0
- package/build/cli/ui.js +1 -2
- package/build/cli/validate.d.ts +4 -0
- package/build/cli/validate.js +19 -0
- package/build/client/.tsbuildinfo +1 -1
- package/build/client/Link.d.ts +8 -0
- package/build/client/Link.js +44 -0
- package/build/client/NavLink.d.ts +14 -0
- package/build/client/NavLink.js +37 -0
- package/build/client/Router.d.ts +7 -0
- package/build/client/Router.js +55 -0
- package/build/client/error-boundary.d.ts +16 -0
- package/build/client/error-boundary.js +19 -0
- package/build/client/head.d.ts +26 -0
- package/build/client/head.js +87 -0
- package/build/client/hooks.d.ts +17 -0
- package/build/client/hooks.js +48 -0
- package/build/client/index.d.ts +14 -2
- package/build/client/index.js +8 -1
- package/build/client/lazy.d.ts +16 -0
- package/build/client/lazy.js +53 -0
- package/build/client/match.js +7 -0
- package/build/client/mount.d.ts +2 -0
- package/build/client/mount.js +13 -0
- package/build/client/navigation.d.ts +13 -0
- package/build/client/navigation.js +97 -0
- package/build/client/params-context.d.ts +2 -0
- package/build/client/params-context.js +2 -0
- package/build/client/prefetch.d.ts +11 -0
- package/build/client/prefetch.js +100 -0
- package/build/client/scroll.d.ts +8 -0
- package/build/client/scroll.js +36 -0
- package/build/client/types.d.ts +27 -0
- package/build/client/types.js +1 -0
- package/build/compiler/.tsbuildinfo +1 -1
- package/build/compiler/config.d.ts +2 -0
- package/build/compiler/config.js +4 -1
- package/build/compiler/docs.d.ts +10 -0
- package/build/compiler/docs.js +59 -0
- package/build/compiler/generate.js +134 -16
- package/build/compiler/index.d.ts +4 -2
- package/build/compiler/index.js +4 -3
- package/build/compiler/plugin.js +2 -1
- package/build/compiler/routes.js +5 -1
- package/build/compiler/vite.d.ts +1 -1
- package/build/compiler/vite.js +17 -1
- package/build/io/.tsbuildinfo +1 -1
- package/build/io/BinaryWriter.js +2 -2
- package/eslint.config.js +1 -1
- package/examples/basic/.toil/docs/cli.md +3 -0
- package/examples/basic/.toil/docs/client.md +3 -0
- package/examples/basic/.toil/docs/index.md +3 -0
- package/examples/basic/.toil/docs/routing.md +3 -0
- package/examples/basic/.toil/docs/server.md +3 -0
- package/examples/basic/.toil/docs/styling.md +3 -0
- package/examples/basic/.toil/entry.tsx +3 -8
- package/examples/basic/.toil/globals.ts +6 -0
- package/examples/basic/.toil/index.html +16 -12
- package/examples/basic/.toil/public/images/.gitkeep +1 -0
- package/examples/basic/.toil/public/images/logo.svg +37 -0
- package/examples/basic/.toil/public/robots.txt +2 -0
- package/examples/basic/.toil/routes.ts +9 -7
- package/examples/basic/build/client/assets/404-Bq0jNTUo.js +1 -0
- package/examples/basic/build/client/assets/_...slug_-CXKf6qnB.js +1 -0
- package/examples/basic/build/client/assets/_id_-BadAyQnb.js +1 -0
- package/examples/basic/build/client/assets/about-BOhoEcEO.js +1 -0
- package/examples/basic/build/client/assets/get-started-BIXpcjkT.js +9 -0
- package/examples/basic/build/client/assets/index-BmqcTaBB.js +1 -0
- package/examples/basic/build/client/assets/io-DEVjjaJj.js +1 -0
- package/examples/basic/build/client/assets/layout-DJegirdz.js +1 -0
- package/examples/basic/build/client/assets/react-DEQrz1q7.js +9 -0
- package/examples/basic/build/client/assets/rolldown-runtime-KL5VtC6j.js +1 -0
- package/examples/basic/build/client/assets/routes-BYWn6TxK.js +1 -0
- package/examples/basic/build/client/css/style.css +2 -0
- package/examples/basic/build/client/images/.gitkeep +1 -0
- package/examples/basic/build/client/images/logo.svg +37 -0
- package/examples/basic/build/client/index.html +17 -0
- package/examples/basic/build/client/robots.txt +2 -0
- package/examples/basic/client/404.tsx +2 -5
- package/examples/basic/client/components/.gitkeep +1 -0
- package/examples/basic/client/components/Footer.tsx +8 -0
- package/examples/basic/client/layout.tsx +39 -26
- package/examples/basic/client/public/images/.gitkeep +1 -0
- package/examples/basic/client/public/images/logo.svg +37 -0
- package/examples/basic/client/public/index.html +15 -0
- package/examples/basic/client/public/robots.txt +2 -0
- package/examples/basic/client/routes/about.tsx +1 -3
- package/examples/basic/client/routes/blog/[id].tsx +2 -4
- package/examples/basic/client/routes/docs/[...slug].tsx +3 -6
- package/examples/basic/client/routes/get-started.tsx +84 -0
- package/examples/basic/client/routes/index.tsx +74 -7
- package/examples/basic/client/routes/io.tsx +3 -7
- package/examples/basic/client/styles/main.css +461 -0
- package/examples/basic/client/toil.tsx +7 -0
- package/examples/basic/node_modules/.bin/toilinit +16 -0
- package/examples/basic/node_modules/.bin/toilinit.cmd +17 -0
- package/examples/basic/node_modules/.bin/toilinit.ps1 +28 -0
- package/examples/basic/node_modules/.bin/toilscript +16 -0
- package/examples/basic/node_modules/.bin/toilscript.cmd +17 -0
- package/examples/basic/node_modules/.bin/toilscript.ps1 +28 -0
- package/examples/basic/node_modules/.bin/wasm-as +16 -0
- package/examples/basic/node_modules/.bin/wasm-as.cmd +17 -0
- package/examples/basic/node_modules/.bin/wasm-as.ps1 +28 -0
- package/examples/basic/node_modules/.bin/wasm-ctor-eval +16 -0
- package/examples/basic/node_modules/.bin/wasm-ctor-eval.cmd +17 -0
- package/examples/basic/node_modules/.bin/wasm-ctor-eval.ps1 +28 -0
- package/examples/basic/node_modules/.bin/wasm-dis +16 -0
- package/examples/basic/node_modules/.bin/wasm-dis.cmd +17 -0
- package/examples/basic/node_modules/.bin/wasm-dis.ps1 +28 -0
- package/examples/basic/node_modules/.bin/wasm-merge +16 -0
- package/examples/basic/node_modules/.bin/wasm-merge.cmd +17 -0
- package/examples/basic/node_modules/.bin/wasm-merge.ps1 +28 -0
- package/examples/basic/node_modules/.bin/wasm-metadce +16 -0
- package/examples/basic/node_modules/.bin/wasm-metadce.cmd +17 -0
- package/examples/basic/node_modules/.bin/wasm-metadce.ps1 +28 -0
- package/examples/basic/node_modules/.bin/wasm-opt +16 -0
- package/examples/basic/node_modules/.bin/wasm-opt.cmd +17 -0
- package/examples/basic/node_modules/.bin/wasm-opt.ps1 +28 -0
- package/examples/basic/node_modules/.bin/wasm-reduce +16 -0
- package/examples/basic/node_modules/.bin/wasm-reduce.cmd +17 -0
- package/examples/basic/node_modules/.bin/wasm-reduce.ps1 +28 -0
- package/examples/basic/node_modules/.bin/wasm-shell +16 -0
- package/examples/basic/node_modules/.bin/wasm-shell.cmd +17 -0
- package/examples/basic/node_modules/.bin/wasm-shell.ps1 +28 -0
- package/examples/basic/node_modules/.bin/wasm2js +16 -0
- package/examples/basic/node_modules/.bin/wasm2js.cmd +17 -0
- package/examples/basic/node_modules/.bin/wasm2js.ps1 +28 -0
- package/examples/basic/node_modules/.package-lock.json +49 -1
- package/examples/basic/node_modules/.vite/deps/_metadata.json +9 -9
- package/examples/basic/node_modules/binaryen/LICENSE +201 -0
- package/examples/basic/node_modules/binaryen/README.md +1362 -0
- package/examples/basic/node_modules/binaryen/bin/package.json +3 -0
- package/examples/basic/node_modules/binaryen/bin/wasm-as +0 -0
- package/examples/basic/node_modules/binaryen/bin/wasm-ctor-eval +0 -0
- package/examples/basic/node_modules/binaryen/bin/wasm-dis +0 -0
- package/examples/basic/node_modules/binaryen/bin/wasm-merge +0 -0
- package/examples/basic/node_modules/binaryen/bin/wasm-metadce +0 -0
- package/examples/basic/node_modules/binaryen/bin/wasm-opt +0 -0
- package/examples/basic/node_modules/binaryen/bin/wasm-reduce +0 -0
- package/examples/basic/node_modules/binaryen/bin/wasm-shell +0 -0
- package/examples/basic/node_modules/binaryen/bin/wasm2js +0 -0
- package/examples/basic/node_modules/binaryen/index.d.ts +2371 -0
- package/examples/basic/node_modules/binaryen/index.js +30552 -0
- package/examples/basic/node_modules/binaryen/package.json +50 -0
- package/examples/basic/node_modules/long/LICENSE +202 -0
- package/examples/basic/node_modules/long/README.md +286 -0
- package/examples/basic/node_modules/long/index.d.ts +2 -0
- package/examples/basic/node_modules/long/index.js +1581 -0
- package/examples/basic/node_modules/long/package.json +58 -0
- package/examples/basic/node_modules/long/types.d.ts +474 -0
- package/examples/basic/node_modules/long/umd/index.d.ts +3 -0
- package/examples/basic/node_modules/long/umd/index.js +1622 -0
- package/examples/basic/node_modules/long/umd/package.json +3 -0
- package/examples/basic/node_modules/long/umd/types.d.ts +474 -0
- package/examples/basic/node_modules/toilscript/LICENSE +201 -0
- package/examples/basic/node_modules/toilscript/NOTICE +94 -0
- package/examples/basic/node_modules/toilscript/README.md +66 -0
- package/examples/basic/node_modules/toilscript/bin/toilinit.js +468 -0
- package/examples/basic/node_modules/toilscript/bin/toilscript.js +35 -0
- package/examples/basic/node_modules/toilscript/dist/cli.d.ts +4 -0
- package/examples/basic/node_modules/toilscript/dist/cli.generated.d.ts +10027 -0
- package/examples/basic/node_modules/toilscript/dist/cli.js +24474 -0
- package/examples/basic/node_modules/toilscript/dist/cli.js.map +7 -0
- package/examples/basic/node_modules/toilscript/dist/importmap.json +9 -0
- package/examples/basic/node_modules/toilscript/dist/toilscript.d.ts +4 -0
- package/examples/basic/node_modules/toilscript/dist/toilscript.generated.d.ts +11242 -0
- package/examples/basic/node_modules/toilscript/dist/toilscript.js +337 -0
- package/examples/basic/node_modules/toilscript/dist/toilscript.js.map +7 -0
- package/examples/basic/node_modules/toilscript/dist/transform.cjs +1 -0
- package/examples/basic/node_modules/toilscript/dist/transform.d.ts +1 -0
- package/examples/basic/node_modules/toilscript/dist/transform.js +1 -0
- package/examples/basic/node_modules/toilscript/dist/web.js +22 -0
- package/examples/basic/node_modules/toilscript/lib/binaryen.d.ts +2 -0
- package/examples/basic/node_modules/toilscript/lib/binaryen.js +2 -0
- package/examples/basic/node_modules/toilscript/package.json +115 -0
- package/examples/basic/node_modules/toilscript/std/README.md +6 -0
- package/examples/basic/node_modules/toilscript/std/assembly/array.ts +550 -0
- package/examples/basic/node_modules/toilscript/std/assembly/arraybuffer.ts +77 -0
- package/examples/basic/node_modules/toilscript/std/assembly/atomics.ts +127 -0
- package/examples/basic/node_modules/toilscript/std/assembly/bindings/asyncify.ts +16 -0
- package/examples/basic/node_modules/toilscript/std/assembly/bindings/dom.ts +291 -0
- package/examples/basic/node_modules/toilscript/std/assembly/bindings/node.ts +6 -0
- package/examples/basic/node_modules/toilscript/std/assembly/bitflags.ts +53 -0
- package/examples/basic/node_modules/toilscript/std/assembly/builtins.ts +2650 -0
- package/examples/basic/node_modules/toilscript/std/assembly/byteslice.ts +177 -0
- package/examples/basic/node_modules/toilscript/std/assembly/compat.ts +2 -0
- package/examples/basic/node_modules/toilscript/std/assembly/console.ts +42 -0
- package/examples/basic/node_modules/toilscript/std/assembly/crypto.ts +9 -0
- package/examples/basic/node_modules/toilscript/std/assembly/dataview.ts +181 -0
- package/examples/basic/node_modules/toilscript/std/assembly/date.ts +375 -0
- package/examples/basic/node_modules/toilscript/std/assembly/diagnostics.ts +11 -0
- package/examples/basic/node_modules/toilscript/std/assembly/encoding.ts +151 -0
- package/examples/basic/node_modules/toilscript/std/assembly/endian.ts +45 -0
- package/examples/basic/node_modules/toilscript/std/assembly/error.ts +44 -0
- package/examples/basic/node_modules/toilscript/std/assembly/fixedarray.ts +173 -0
- package/examples/basic/node_modules/toilscript/std/assembly/fixedmap.ts +326 -0
- package/examples/basic/node_modules/toilscript/std/assembly/fixedset.ts +275 -0
- package/examples/basic/node_modules/toilscript/std/assembly/function.ts +42 -0
- package/examples/basic/node_modules/toilscript/std/assembly/index.d.ts +2892 -0
- package/examples/basic/node_modules/toilscript/std/assembly/iterator.ts +35 -0
- package/examples/basic/node_modules/toilscript/std/assembly/map.ts +269 -0
- package/examples/basic/node_modules/toilscript/std/assembly/math.ts +3289 -0
- package/examples/basic/node_modules/toilscript/std/assembly/memory.ts +123 -0
- package/examples/basic/node_modules/toilscript/std/assembly/number.ts +388 -0
- package/examples/basic/node_modules/toilscript/std/assembly/object.ts +36 -0
- package/examples/basic/node_modules/toilscript/std/assembly/performance.ts +9 -0
- package/examples/basic/node_modules/toilscript/std/assembly/pointer.ts +80 -0
- package/examples/basic/node_modules/toilscript/std/assembly/polyfills.ts +27 -0
- package/examples/basic/node_modules/toilscript/std/assembly/process.ts +50 -0
- package/examples/basic/node_modules/toilscript/std/assembly/reference.ts +48 -0
- package/examples/basic/node_modules/toilscript/std/assembly/regexp.ts +12 -0
- package/examples/basic/node_modules/toilscript/std/assembly/rt/README.md +83 -0
- package/examples/basic/node_modules/toilscript/std/assembly/rt/common.ts +81 -0
- package/examples/basic/node_modules/toilscript/std/assembly/rt/index-incremental.ts +2 -0
- package/examples/basic/node_modules/toilscript/std/assembly/rt/index-memory.ts +1 -0
- package/examples/basic/node_modules/toilscript/std/assembly/rt/index-minimal.ts +2 -0
- package/examples/basic/node_modules/toilscript/std/assembly/rt/index-stub.ts +1 -0
- package/examples/basic/node_modules/toilscript/std/assembly/rt/index.d.ts +37 -0
- package/examples/basic/node_modules/toilscript/std/assembly/rt/itcms.ts +419 -0
- package/examples/basic/node_modules/toilscript/std/assembly/rt/memory-runtime.ts +94 -0
- package/examples/basic/node_modules/toilscript/std/assembly/rt/rtrace.ts +15 -0
- package/examples/basic/node_modules/toilscript/std/assembly/rt/stub.ts +133 -0
- package/examples/basic/node_modules/toilscript/std/assembly/rt/tcms.ts +254 -0
- package/examples/basic/node_modules/toilscript/std/assembly/rt/tlsf.ts +592 -0
- package/examples/basic/node_modules/toilscript/std/assembly/rt.ts +90 -0
- package/examples/basic/node_modules/toilscript/std/assembly/set.ts +225 -0
- package/examples/basic/node_modules/toilscript/std/assembly/shared/feature.ts +68 -0
- package/examples/basic/node_modules/toilscript/std/assembly/shared/runtime.ts +13 -0
- package/examples/basic/node_modules/toilscript/std/assembly/shared/target.ts +11 -0
- package/examples/basic/node_modules/toilscript/std/assembly/shared/tsconfig.json +11 -0
- package/examples/basic/node_modules/toilscript/std/assembly/shared/typeinfo.ts +72 -0
- package/examples/basic/node_modules/toilscript/std/assembly/staticarray.ts +423 -0
- package/examples/basic/node_modules/toilscript/std/assembly/string.ts +850 -0
- package/examples/basic/node_modules/toilscript/std/assembly/symbol.ts +114 -0
- package/examples/basic/node_modules/toilscript/std/assembly/table.ts +16 -0
- package/examples/basic/node_modules/toilscript/std/assembly/toilscript.ts +16 -0
- package/examples/basic/node_modules/toilscript/std/assembly/tsconfig.json +6 -0
- package/examples/basic/node_modules/toilscript/std/assembly/typedarray.ts +1954 -0
- package/examples/basic/node_modules/toilscript/std/assembly/uri.ts +17 -0
- package/examples/basic/node_modules/toilscript/std/assembly/util/bytes.ts +107 -0
- package/examples/basic/node_modules/toilscript/std/assembly/util/casemap.ts +497 -0
- package/examples/basic/node_modules/toilscript/std/assembly/util/error.ts +58 -0
- package/examples/basic/node_modules/toilscript/std/assembly/util/hash.ts +117 -0
- package/examples/basic/node_modules/toilscript/std/assembly/util/math.ts +1922 -0
- package/examples/basic/node_modules/toilscript/std/assembly/util/memory.ts +290 -0
- package/examples/basic/node_modules/toilscript/std/assembly/util/number.ts +873 -0
- package/examples/basic/node_modules/toilscript/std/assembly/util/sort.ts +313 -0
- package/examples/basic/node_modules/toilscript/std/assembly/util/string.ts +1202 -0
- package/examples/basic/node_modules/toilscript/std/assembly/util/uri.ts +275 -0
- package/examples/basic/node_modules/toilscript/std/assembly/vector.ts +4 -0
- package/examples/basic/node_modules/toilscript/std/assembly.json +16 -0
- package/examples/basic/node_modules/toilscript/std/portable/index.d.ts +461 -0
- package/examples/basic/node_modules/toilscript/std/portable/index.js +416 -0
- package/examples/basic/node_modules/toilscript/std/portable.json +11 -0
- package/examples/basic/node_modules/toilscript/std/types/assembly/index.d.ts +1 -0
- package/examples/basic/node_modules/toilscript/std/types/assembly/package.json +3 -0
- package/examples/basic/node_modules/toilscript/std/types/portable/index.d.ts +1 -0
- package/examples/basic/node_modules/toilscript/std/types/portable/package.json +3 -0
- package/examples/basic/node_modules/toilscript/tsconfig-base.json +13 -0
- package/examples/basic/node_modules/toilscript/util/README.md +23 -0
- package/examples/basic/node_modules/toilscript/util/browser/fs.js +1 -0
- package/examples/basic/node_modules/toilscript/util/browser/module.js +5 -0
- package/examples/basic/node_modules/toilscript/util/browser/path.js +520 -0
- package/examples/basic/node_modules/toilscript/util/browser/process.js +59 -0
- package/examples/basic/node_modules/toilscript/util/browser/url.js +23 -0
- package/examples/basic/node_modules/toilscript/util/cpu.d.ts +9 -0
- package/examples/basic/node_modules/toilscript/util/cpu.js +42 -0
- package/examples/basic/node_modules/toilscript/util/find.d.ts +6 -0
- package/examples/basic/node_modules/toilscript/util/find.js +20 -0
- package/examples/basic/node_modules/toilscript/util/node.d.ts +21 -0
- package/examples/basic/node_modules/toilscript/util/node.js +34 -0
- package/examples/basic/node_modules/toilscript/util/options.d.ts +70 -0
- package/examples/basic/node_modules/toilscript/util/options.js +262 -0
- package/examples/basic/node_modules/toilscript/util/terminal.d.ts +52 -0
- package/examples/basic/node_modules/toilscript/util/terminal.js +35 -0
- package/examples/basic/node_modules/toilscript/util/text.d.ts +26 -0
- package/examples/basic/node_modules/toilscript/util/text.js +114 -0
- package/examples/basic/node_modules/toilscript/util/tsconfig.json +9 -0
- package/examples/basic/node_modules/toilscript/util/web.d.ts +11 -0
- package/examples/basic/node_modules/toilscript/util/web.js +33 -0
- package/examples/basic/package-lock.json +50 -1
- package/examples/basic/package.json +5 -2
- package/examples/basic/server/index.ts +3 -0
- package/examples/basic/server/main.ts +6 -0
- package/examples/basic/server/tsconfig.json +7 -0
- package/examples/basic/toil-env.d.ts +20 -1
- package/examples/basic/toil.config.ts +2 -5
- package/examples/basic/toilconfig.json +30 -0
- package/package.json +1 -1
- package/presets/eslint.js +2 -7
- package/presets/no-uint8array-tostring.js +4 -5
- package/presets/prettier.json +8 -1
- package/src/backend/index.ts +11 -18
- package/src/cli/configure.ts +272 -0
- package/src/cli/create.ts +227 -69
- package/src/cli/features.ts +128 -0
- package/src/cli/index.ts +44 -3
- package/src/cli/proc.ts +20 -0
- package/src/cli/ui.ts +4 -6
- package/src/cli/validate.ts +31 -0
- package/src/client/Link.tsx +99 -0
- package/src/client/NavLink.tsx +86 -0
- package/src/client/Router.tsx +95 -0
- package/src/client/error-boundary.tsx +43 -0
- package/src/client/head.ts +140 -0
- package/src/client/hooks.ts +115 -0
- package/src/client/index.ts +35 -5
- package/src/client/lazy.ts +93 -0
- package/src/client/match.ts +11 -3
- package/src/client/mount.tsx +28 -0
- package/src/client/navigation.ts +142 -0
- package/src/client/params-context.ts +10 -0
- package/src/client/prefetch.ts +130 -0
- package/src/client/scroll.ts +53 -0
- package/src/client/types.ts +36 -0
- package/src/compiler/config.ts +15 -8
- package/src/compiler/docs.ts +87 -0
- package/src/compiler/generate.ts +164 -23
- package/src/compiler/index.ts +6 -4
- package/src/compiler/plugin.ts +3 -1
- package/src/compiler/routes.ts +13 -7
- package/src/compiler/vite.ts +28 -5
- package/src/io/BinaryReader.ts +1 -5
- package/src/io/BinaryWriter.ts +3 -3
- package/src/server/index.ts +3 -4
- package/src/server/tsconfig.json +4 -0
- package/test/configure.test.ts +90 -0
- package/test/features.test.ts +111 -0
- package/test/head.test.ts +35 -0
- package/test/io.test.ts +8 -0
- package/test/navlink.test.ts +28 -0
- package/test/routes.test.ts +15 -0
- package/test/validate.test.ts +42 -0
- package/vitest.config.ts +1 -1
- package/examples/basic/dist/assets/404-D1bS2aH_.js +0 -1
- package/examples/basic/dist/assets/_...slug_-wR3shlWn.js +0 -1
- package/examples/basic/dist/assets/_id_-EWYvHfi2.js +0 -1
- package/examples/basic/dist/assets/about-Ddvj1tjF.js +0 -1
- package/examples/basic/dist/assets/index-CdG0me90.js +0 -1
- package/examples/basic/dist/assets/io-CODNJU57.js +0 -1
- package/examples/basic/dist/assets/layout-C15ZTPYI.js +0 -1
- package/examples/basic/dist/assets/react-JbAfoxYe.js +0 -9
- package/examples/basic/dist/assets/rolldown-runtime-1VNLd2iN.js +0 -1
- package/examples/basic/dist/assets/routes-GoydenoY.js +0 -1
- package/examples/basic/dist/index.html +0 -12
- package/src/client/runtime.tsx +0 -190
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
The following authors have all licensed their contributions to ToilScript
|
|
2
|
+
under the licensing terms detailed in LICENSE:
|
|
3
|
+
|
|
4
|
+
* Daniel Wirtz <dcode@dcode.io>
|
|
5
|
+
* Max Graey <maxgraey@gmail.com>
|
|
6
|
+
* Igor Sbitnev <PinkaminaDianePie@gmail.com>
|
|
7
|
+
* Norton Wang <me@nortonwang.com>
|
|
8
|
+
* Alan Pierce <alangpierce@gmail.com>
|
|
9
|
+
* Palmer <pengliao@live.cn>
|
|
10
|
+
* Linus Unnebäck <linus@folkdatorn.se>
|
|
11
|
+
* Joshua Tenner <tenner.joshua@gmail.com>
|
|
12
|
+
* Nidin Vinayakan <01@01alchemist.com>
|
|
13
|
+
* Aaron Turner <aaron@aaronthedev.com>
|
|
14
|
+
* Willem Wyndham <willem@cs.umd.edu>
|
|
15
|
+
* Bowen Wang <bowen@nearprotocol.com>
|
|
16
|
+
* Emil Laine <laine.emil@gmail.com>
|
|
17
|
+
* Stephen Paul Weber <stephen.weber@shopify.com>
|
|
18
|
+
* Jay Phelps <hello@jayphelps.com>
|
|
19
|
+
* jhwgh1968 <jhwgh1968@protonmail.com>
|
|
20
|
+
* Jeffrey Charles <jeffreycharles@gmail.com>
|
|
21
|
+
* Vladimir Tikhonov <reg@tikhonov.by>
|
|
22
|
+
* Duncan Uszkay <duncan.uszkay@shopify.com>
|
|
23
|
+
* Surma <surma@surma.dev>
|
|
24
|
+
* Julien Letellier <letellier.julien@gmail.com>
|
|
25
|
+
* Guido Zuidhof <me@guido.io>
|
|
26
|
+
* ncave <777696+ncave@users.noreply.github.com>
|
|
27
|
+
* Andrew Davis <pulpdrew@gmail.com>
|
|
28
|
+
* Maël Nison <nison.mael@gmail.com>
|
|
29
|
+
* Valeria Viana Gusmao <valeria.viana.gusmao@gmail.com>
|
|
30
|
+
* Gabor Greif <ggreif@gmail.com>
|
|
31
|
+
* Martin Fredriksson <martin.fredriksson@vikinganalytics.se>
|
|
32
|
+
* forcepusher <bionitsoup@gmail.com>
|
|
33
|
+
* Piotr Oleś <piotrek.oles@gmail.com>
|
|
34
|
+
* Saúl Cabrera <saulecabrera@gmail.com>
|
|
35
|
+
* Chance Snow <git@chancesnow.me>
|
|
36
|
+
* Peter Salomonsen <petersalomonsen@runbox.com>
|
|
37
|
+
* ookangzheng <git-ed@runbox.no>
|
|
38
|
+
* yjhmelody <yjh465402634@gmail.com>
|
|
39
|
+
* bnbarak <bn.barak@gmail.com>
|
|
40
|
+
* Colin Eberhardt <colin.eberhardt@gmail.com>
|
|
41
|
+
* Ryan Pivovar <ryanpivovar@gmail.com>
|
|
42
|
+
* Roman F. <70765447+romdotdog@users.noreply.github.com>
|
|
43
|
+
* Joe Pea <trusktr@gmail.com>
|
|
44
|
+
* Felipe Gasper <FGasper@users.noreply.github.com>
|
|
45
|
+
* Congcong Cai <congcongcai0907@163.com>
|
|
46
|
+
* mooooooi <emwings@outlook.com>
|
|
47
|
+
* Yasushi Ando <andyjpn@gmail.com>
|
|
48
|
+
* Syed Jafri <syed@metalpay.co>
|
|
49
|
+
* Peter Hayman <peteyhayman@gmail.com>
|
|
50
|
+
* ApsarasX <apsarax@outlook.com>
|
|
51
|
+
* Adrien Zinger <zinger.ad@gmail.com>
|
|
52
|
+
* Ruixiang Chen <xiang19890319@gmail.com>
|
|
53
|
+
* Daniel Salvadori <danaugrs@gmail.com>
|
|
54
|
+
* Jairus Tanaka <me@jairus.dev>
|
|
55
|
+
* CountBleck <Mr.YouKnowWhoIAm@protonmail.com>
|
|
56
|
+
* Abdul Rauf <abdulraufmujahid@gmail.com>
|
|
57
|
+
* Bach Le <bach@bullno1.com>
|
|
58
|
+
* Xinquan Xu <xinquan0203@163.com>
|
|
59
|
+
* Matt Johnson-Pint <mattjohnsonpint@gmail.com>
|
|
60
|
+
* Fabián Heredia Montiel <fabianhjr@users.noreply.github.com>
|
|
61
|
+
* Jonas Minnberg <sasq64@gmail.com>
|
|
62
|
+
* Kam Chehresa <kaz.che@gmail.com>
|
|
63
|
+
* Mopsgamer <79159094+Mopsgamer@users.noreply.github.com>
|
|
64
|
+
* EDM115 <github@edm115.dev>
|
|
65
|
+
* Weixie Cui <cuiweixie@gmail.com>
|
|
66
|
+
* Anakun <anakun@opnet.org>
|
|
67
|
+
|
|
68
|
+
Portions of this software are derived from third-party works licensed under
|
|
69
|
+
the following terms:
|
|
70
|
+
|
|
71
|
+
* TypeScript: https://github.com/Microsoft/TypeScript
|
|
72
|
+
|
|
73
|
+
Copyright (c) Microsoft Corporation
|
|
74
|
+
Apache License, Version 2.0 (https://opensource.org/licenses/Apache-2.0)
|
|
75
|
+
|
|
76
|
+
* Binaryen: https://github.com/WebAssembly/binaryen
|
|
77
|
+
|
|
78
|
+
Copyright (c) WebAssembly Community Group participants
|
|
79
|
+
Apache License, Version 2.0 (https://opensource.org/licenses/Apache-2.0)
|
|
80
|
+
|
|
81
|
+
* musl libc: http://www.musl-libc.org
|
|
82
|
+
|
|
83
|
+
Copyright (c) Rich Felker, et al.
|
|
84
|
+
The MIT License (https://opensource.org/licenses/MIT)
|
|
85
|
+
|
|
86
|
+
* V8: https://developers.google.com/v8/
|
|
87
|
+
|
|
88
|
+
Copyright (c) the V8 project authors
|
|
89
|
+
The 3-Clause BSD License (https://opensource.org/licenses/BSD-3-Clause)
|
|
90
|
+
|
|
91
|
+
* Arm Optimized Routines: https://github.com/ARM-software/optimized-routines
|
|
92
|
+
|
|
93
|
+
Copyright (c) Arm Limited
|
|
94
|
+
The MIT License (https://opensource.org/licenses/MIT)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://toil.org" target="_blank" rel="noopener"><img width="256" src="media/icon.png" alt="ToilScript logo"></a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/toilscript"><img src="https://img.shields.io/npm/v/toilscript.svg?color=007acc&logo=npm" alt="npm version" /></a>
|
|
7
|
+
<a href="https://github.com/dacely-cloud/toilscript/releases"><img src="https://img.shields.io/github/v/release/dacely-cloud/toilscript?color=green&logo=github" alt="GitHub release" /></a>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## ToilScript
|
|
13
|
+
|
|
14
|
+
**ToilScript is a fork of [AssemblyScript](https://github.com/AssemblyScript/assemblyscript)** that tracks the latest upstream and adds language features not yet available in the official release.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
npm install toilscript
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Usage
|
|
25
|
+
|
|
26
|
+
This fork is a drop-in replacement for ToilScript. Simply replace your import:
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"toilscript": "^0.1.0"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Or if migrating from official ToilScript:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
npm uninstall toilscript
|
|
40
|
+
npm install toilscript
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The CLI is `toilscript` (with `toilinit` to scaffold a project):
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
npx toilscript your-file.ts --outFile output.wasm
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Development instructions
|
|
52
|
+
|
|
53
|
+
A development environment can be set up by cloning the repository:
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
git clone https://github.com/dacely-cloud/toilscript.git
|
|
57
|
+
cd toilscript
|
|
58
|
+
npm install
|
|
59
|
+
npm link
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The link step is optional and makes the development instance available globally. The full process is documented as part of the repository:
|
|
63
|
+
|
|
64
|
+
* [Compiler instructions](./src)
|
|
65
|
+
* [Runtime instructions](./std/assembly/rt)
|
|
66
|
+
* [Test instructions](./tests)
|
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { createRequire } from "module";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
|
+
import { stdoutColors } from "../util/terminal.js";
|
|
8
|
+
import * as optionsUtil from "../util/options.js";
|
|
9
|
+
|
|
10
|
+
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const require = createRequire(import.meta.url);
|
|
12
|
+
const version = require("../package.json").version; // TODO
|
|
13
|
+
|
|
14
|
+
const npmDefaultTest = "echo \"Error: no test specified\" && exit 1";
|
|
15
|
+
|
|
16
|
+
const commands = {
|
|
17
|
+
"npm": {
|
|
18
|
+
install: "npm install",
|
|
19
|
+
run: "npm run",
|
|
20
|
+
test: "npm test"
|
|
21
|
+
},
|
|
22
|
+
"yarn": {
|
|
23
|
+
install: "yarn install",
|
|
24
|
+
run: "yarn",
|
|
25
|
+
test: "yarn test"
|
|
26
|
+
},
|
|
27
|
+
"pnpm": {
|
|
28
|
+
install: "pnpm install",
|
|
29
|
+
run: "pnpm run",
|
|
30
|
+
test: "pnpm test"
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
let pm = "npm";
|
|
35
|
+
if (typeof process.env.npm_config_user_agent === "string") {
|
|
36
|
+
if (/\byarn\//.test(process.env.npm_config_user_agent)) {
|
|
37
|
+
pm = "yarn";
|
|
38
|
+
} else if (/\bpnpm\//.test(process.env.npm_config_user_agent)) {
|
|
39
|
+
pm = "pnpm";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const toilinitOptions = {
|
|
44
|
+
"help": {
|
|
45
|
+
"category": "General",
|
|
46
|
+
"description": "Prints this help message.",
|
|
47
|
+
"type": "b",
|
|
48
|
+
"alias": "h"
|
|
49
|
+
},
|
|
50
|
+
"yes": {
|
|
51
|
+
"category": "General",
|
|
52
|
+
"description": [
|
|
53
|
+
"Answers all questions with their default option",
|
|
54
|
+
"for non-interactive usage."
|
|
55
|
+
],
|
|
56
|
+
"type": "b",
|
|
57
|
+
"alias": "y"
|
|
58
|
+
},
|
|
59
|
+
"noColors": {
|
|
60
|
+
"description": "Disables terminal colors.",
|
|
61
|
+
"type": "b",
|
|
62
|
+
"default": false
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const cliOptions = optionsUtil.parse(process.argv.slice(2), toilinitOptions);
|
|
67
|
+
|
|
68
|
+
if (cliOptions.options.noColors) {
|
|
69
|
+
stdoutColors.enabled = false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (cliOptions.options.help || cliOptions.arguments.length === 0) printHelp();
|
|
73
|
+
|
|
74
|
+
function printHelp() {
|
|
75
|
+
console.log([
|
|
76
|
+
"Sets up a new ToilScript project or updates an existing one.",
|
|
77
|
+
"",
|
|
78
|
+
stdoutColors.white("SYNTAX"),
|
|
79
|
+
" " + stdoutColors.cyan("toilinit") + " directory [options]",
|
|
80
|
+
"",
|
|
81
|
+
stdoutColors.white("EXAMPLES"),
|
|
82
|
+
" " + stdoutColors.cyan("toilinit") + " .",
|
|
83
|
+
" " + stdoutColors.cyan("toilinit") + " ./newProject -y",
|
|
84
|
+
"",
|
|
85
|
+
stdoutColors.white("OPTIONS"),
|
|
86
|
+
optionsUtil.help(toilinitOptions, { noCategories: true })
|
|
87
|
+
].join("\n"));
|
|
88
|
+
process.exit(0);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const compilerDir = path.join(dirname, "..");
|
|
92
|
+
const projectDir = path.resolve(cliOptions.arguments[0]);
|
|
93
|
+
const assemblyDir = path.join(projectDir, "assembly");
|
|
94
|
+
const tsconfigFile = path.join(assemblyDir, "tsconfig.json");
|
|
95
|
+
const toilconfigFile = path.join(projectDir, "toilconfig.json");
|
|
96
|
+
let tsconfigBase = path.relative(assemblyDir, path.join(compilerDir, "std", "assembly.json"));
|
|
97
|
+
if (/^(\.\.[/\\])*node_modules[/\\]toilscript[/\\]/.test(tsconfigBase)) {
|
|
98
|
+
// Use node resolution if the compiler is a normal dependency
|
|
99
|
+
tsconfigBase = "toilscript/std/assembly.json";
|
|
100
|
+
}
|
|
101
|
+
const entryFile = path.join(assemblyDir, "index.ts");
|
|
102
|
+
const buildDir = path.join(projectDir, "build");
|
|
103
|
+
const testsDir = path.join(projectDir, "test");
|
|
104
|
+
const gitignoreFile = path.join(buildDir, ".gitignore");
|
|
105
|
+
const packageFile = path.join(projectDir, "package.json");
|
|
106
|
+
|
|
107
|
+
const indexHtmlFile = path.join(projectDir, "index.html");
|
|
108
|
+
const testsIndexFile = path.join(testsDir, "index.js");
|
|
109
|
+
|
|
110
|
+
const paths = [
|
|
111
|
+
[assemblyDir, "Directory holding the ToilScript sources being compiled to WebAssembly."],
|
|
112
|
+
[tsconfigFile, "TypeScript configuration inheriting recommended ToilScript settings."],
|
|
113
|
+
[entryFile, "Example entry file being compiled to WebAssembly to get you started."],
|
|
114
|
+
[buildDir, "Build artifact directory where compiled WebAssembly files are stored."],
|
|
115
|
+
[gitignoreFile, "Git configuration that excludes compiled binaries from source control."],
|
|
116
|
+
[toilconfigFile, "Configuration file defining both a 'debug' and a 'release' target."],
|
|
117
|
+
[packageFile, "Package info containing the necessary commands to compile to WebAssembly."],
|
|
118
|
+
[testsIndexFile, "Starter test to check that the module is functioning."],
|
|
119
|
+
[indexHtmlFile, "Starter HTML file that loads the module in a browser."]
|
|
120
|
+
];
|
|
121
|
+
|
|
122
|
+
const formatPath = filePath => "./" + path.relative(projectDir, filePath).replace(/\\/g, "/");
|
|
123
|
+
|
|
124
|
+
if (fs.existsSync(packageFile)) {
|
|
125
|
+
const pkg = JSON.parse(fs.readFileSync(packageFile));
|
|
126
|
+
if ("type" in pkg && pkg["type"] !== "module") {
|
|
127
|
+
console.error(stdoutColors.red([
|
|
128
|
+
`Error: The "type" field in ${formatPath(packageFile)} is set to "${pkg["type"]}".`,
|
|
129
|
+
` toilinit requires the "type" field to be set to "module" (ES modules).`
|
|
130
|
+
].join("\n")));
|
|
131
|
+
process.exit(1);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
console.log([
|
|
136
|
+
"Version: " + version,
|
|
137
|
+
"",
|
|
138
|
+
stdoutColors.white([
|
|
139
|
+
"This command will make sure that the following files exist in the project",
|
|
140
|
+
"directory '" + projectDir + "':"
|
|
141
|
+
].join("\n")),
|
|
142
|
+
...paths.map(([filePath, description]) => "\n " + stdoutColors.cyan(formatPath(filePath)) + "\n " + description),
|
|
143
|
+
"",
|
|
144
|
+
"The command will try to update existing files to match the correct settings",
|
|
145
|
+
"for this instance of the compiler in '" + compilerDir + "'.",
|
|
146
|
+
""
|
|
147
|
+
].join("\n"));
|
|
148
|
+
|
|
149
|
+
function createProject(answer) {
|
|
150
|
+
if (!/^y?$/i.test(answer)) {
|
|
151
|
+
process.exit(1);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
console.log();
|
|
155
|
+
ensureProjectDirectory();
|
|
156
|
+
ensureAssemblyDirectory();
|
|
157
|
+
ensureTsconfigJson();
|
|
158
|
+
ensureEntryFile();
|
|
159
|
+
ensureBuildDirectory();
|
|
160
|
+
ensureGitignore();
|
|
161
|
+
ensurePackageJson();
|
|
162
|
+
ensureToilconfigJson();
|
|
163
|
+
ensureTestsDirectory();
|
|
164
|
+
ensureTestsIndexJs();
|
|
165
|
+
ensureIndexHtml();
|
|
166
|
+
|
|
167
|
+
console.log([
|
|
168
|
+
stdoutColors.green("Done!"),
|
|
169
|
+
"",
|
|
170
|
+
"Don't forget to install dependencies before you start:",
|
|
171
|
+
"",
|
|
172
|
+
stdoutColors.white(" " + commands[pm].install),
|
|
173
|
+
"",
|
|
174
|
+
"To edit the entry file, open '" + stdoutColors.cyan("assembly/index.ts") + "' in your editor of choice.",
|
|
175
|
+
"Create as many additional files as necessary and use them as imports.",
|
|
176
|
+
"",
|
|
177
|
+
"To build the entry file to WebAssembly when you are ready, run:",
|
|
178
|
+
"",
|
|
179
|
+
stdoutColors.white(" " + commands[pm].run + " asbuild"),
|
|
180
|
+
"",
|
|
181
|
+
"Running the command above creates the following binaries incl. their respective",
|
|
182
|
+
"text format representations and source maps:",
|
|
183
|
+
"",
|
|
184
|
+
stdoutColors.cyan(" ./build/debug.wasm"),
|
|
185
|
+
stdoutColors.cyan(" ./build/debug.wasm.map"),
|
|
186
|
+
stdoutColors.cyan(" ./build/debug.wat"),
|
|
187
|
+
"",
|
|
188
|
+
" ^ The debuggable WebAssembly module as generated by the compiler.",
|
|
189
|
+
" This one matches your sources exactly, without any optimizations.",
|
|
190
|
+
"",
|
|
191
|
+
stdoutColors.cyan(" ./build/release.wasm"),
|
|
192
|
+
stdoutColors.cyan(" ./build/release.wasm.map"),
|
|
193
|
+
stdoutColors.cyan(" ./build/release.wat"),
|
|
194
|
+
"",
|
|
195
|
+
" ^ The optimized WebAssembly module using default optimization settings.",
|
|
196
|
+
" You can change the optimization settings in '" + stdoutColors.cyan("package.json")+ "'.",
|
|
197
|
+
"",
|
|
198
|
+
"To run the tests, do:",
|
|
199
|
+
"",
|
|
200
|
+
stdoutColors.white(" " + commands[pm].test),
|
|
201
|
+
"",
|
|
202
|
+
"The ToilScript documentation covers all the details:",
|
|
203
|
+
"",
|
|
204
|
+
" https://www.assemblyscript.org",
|
|
205
|
+
"",
|
|
206
|
+
"Have a nice day!"
|
|
207
|
+
].join("\n"));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (cliOptions.options.yes) {
|
|
211
|
+
createProject("y");
|
|
212
|
+
} else {
|
|
213
|
+
const rl = require("readline").createInterface({
|
|
214
|
+
input: process.stdin,
|
|
215
|
+
output: process.stdout
|
|
216
|
+
});
|
|
217
|
+
rl.question(stdoutColors.white("Do you want to proceed?") + " [Y/n] ", result => {
|
|
218
|
+
rl.close();
|
|
219
|
+
createProject(result);
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function ensureProjectDirectory() {
|
|
224
|
+
console.log("- Making sure that the project directory exists...");
|
|
225
|
+
if (!fs.existsSync(projectDir)) {
|
|
226
|
+
fs.mkdirSync(projectDir);
|
|
227
|
+
console.log(stdoutColors.green(" Created: ") + projectDir);
|
|
228
|
+
} else {
|
|
229
|
+
console.log(stdoutColors.yellow(" Exists: ") + projectDir);
|
|
230
|
+
}
|
|
231
|
+
console.log();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function ensureAssemblyDirectory() {
|
|
235
|
+
console.log("- Making sure that the 'assembly' directory exists...");
|
|
236
|
+
if (!fs.existsSync(assemblyDir)) {
|
|
237
|
+
fs.mkdirSync(assemblyDir);
|
|
238
|
+
console.log(stdoutColors.green(" Created: ") + assemblyDir);
|
|
239
|
+
} else {
|
|
240
|
+
console.log(stdoutColors.yellow(" Exists: ") + assemblyDir);
|
|
241
|
+
}
|
|
242
|
+
console.log();
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function ensureTsconfigJson() {
|
|
246
|
+
console.log("- Making sure that 'assembly/tsconfig.json' is set up...");
|
|
247
|
+
const base = tsconfigBase.replace(/\\/g, "/");
|
|
248
|
+
if (!fs.existsSync(tsconfigFile)) {
|
|
249
|
+
fs.writeFileSync(tsconfigFile, JSON.stringify({
|
|
250
|
+
"extends": base,
|
|
251
|
+
"include": [
|
|
252
|
+
"./**/*.ts"
|
|
253
|
+
]
|
|
254
|
+
}, null, 2));
|
|
255
|
+
console.log(stdoutColors.green(" Created: ") + tsconfigFile);
|
|
256
|
+
|
|
257
|
+
} else {
|
|
258
|
+
let tsconfig = JSON.parse(fs.readFileSync(tsconfigFile, "utf8"));
|
|
259
|
+
tsconfig["extends"] = base;
|
|
260
|
+
fs.writeFileSync(tsconfigFile, JSON.stringify(tsconfig, null, 2));
|
|
261
|
+
console.log(stdoutColors.green(" Updated: ") + tsconfigFile);
|
|
262
|
+
}
|
|
263
|
+
console.log();
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function ensureToilconfigJson() {
|
|
267
|
+
console.log("- Making sure that 'toilconfig.json' is set up...");
|
|
268
|
+
if (!fs.existsSync(toilconfigFile)) {
|
|
269
|
+
fs.writeFileSync(toilconfigFile, JSON.stringify({
|
|
270
|
+
targets: {
|
|
271
|
+
debug: {
|
|
272
|
+
// -o build/debug.wasm -t build/debug.wat --sourceMap --debug
|
|
273
|
+
outFile: "build/debug.wasm",
|
|
274
|
+
textFile: "build/debug.wat",
|
|
275
|
+
sourceMap: true,
|
|
276
|
+
debug: true
|
|
277
|
+
},
|
|
278
|
+
release: {
|
|
279
|
+
// -o build/release.wasm -t build/release.wat --sourceMap --optimize
|
|
280
|
+
outFile: "build/release.wasm",
|
|
281
|
+
textFile: "build/release.wat",
|
|
282
|
+
sourceMap: true,
|
|
283
|
+
optimizeLevel: 3,
|
|
284
|
+
shrinkLevel: 0,
|
|
285
|
+
converge: false,
|
|
286
|
+
noAssert: false
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
options: {
|
|
290
|
+
bindings: "esm"
|
|
291
|
+
}
|
|
292
|
+
}, null, 2));
|
|
293
|
+
console.log(stdoutColors.green(" Created: ") + toilconfigFile);
|
|
294
|
+
} else {
|
|
295
|
+
console.log(stdoutColors.yellow(" Exists: ") + toilconfigFile);
|
|
296
|
+
}
|
|
297
|
+
console.log();
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function ensureEntryFile() {
|
|
301
|
+
console.log("- Making sure that 'assembly/index.ts' exists...");
|
|
302
|
+
if (!fs.existsSync(entryFile)) {
|
|
303
|
+
fs.writeFileSync(entryFile, [
|
|
304
|
+
"// The entry file of your WebAssembly module.",
|
|
305
|
+
"",
|
|
306
|
+
"export function add(a: i32, b: i32): i32 {",
|
|
307
|
+
" return a + b;",
|
|
308
|
+
"}"
|
|
309
|
+
].join("\n") + "\n");
|
|
310
|
+
console.log(stdoutColors.green(" Created: ") + entryFile);
|
|
311
|
+
} else {
|
|
312
|
+
console.log(stdoutColors.yellow(" Exists: ") + entryFile);
|
|
313
|
+
}
|
|
314
|
+
console.log();
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function ensureBuildDirectory() {
|
|
318
|
+
console.log("- Making sure that the 'build' directory exists...");
|
|
319
|
+
if (!fs.existsSync(buildDir)) {
|
|
320
|
+
fs.mkdirSync(buildDir);
|
|
321
|
+
console.log(stdoutColors.green(" Created: ") + buildDir);
|
|
322
|
+
} else {
|
|
323
|
+
console.log(stdoutColors.yellow(" Exists: ") + buildDir);
|
|
324
|
+
}
|
|
325
|
+
console.log();
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function ensureGitignore() {
|
|
329
|
+
console.log("- Making sure that 'build/.gitignore' is set up...");
|
|
330
|
+
if (!fs.existsSync(gitignoreFile)) {
|
|
331
|
+
fs.writeFileSync(gitignoreFile, [
|
|
332
|
+
"*",
|
|
333
|
+
"!.gitignore"
|
|
334
|
+
].join("\n") + "\n");
|
|
335
|
+
console.log(stdoutColors.green(" Created: ") + gitignoreFile);
|
|
336
|
+
} else {
|
|
337
|
+
console.log(stdoutColors.yellow(" Exists: ") + gitignoreFile);
|
|
338
|
+
}
|
|
339
|
+
console.log();
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function ensurePackageJson() {
|
|
343
|
+
console.log("- Making sure that 'package.json' contains the build commands...");
|
|
344
|
+
const entryPath = path.relative(projectDir, entryFile).replace(/\\/g, "/");
|
|
345
|
+
const buildDebug = "toilscript " + entryPath + " --target debug";
|
|
346
|
+
const buildRelease = "toilscript " + entryPath + " --target release";
|
|
347
|
+
const buildAll = commands[pm].run + " asbuild:debug && " + commands[pm].run + " asbuild:release";
|
|
348
|
+
if (!fs.existsSync(packageFile)) {
|
|
349
|
+
fs.writeFileSync(packageFile, JSON.stringify({
|
|
350
|
+
"type": "module",
|
|
351
|
+
"exports": {
|
|
352
|
+
".": {
|
|
353
|
+
"import": "./build/release.js",
|
|
354
|
+
"types": "./build/release.d.ts"
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
"scripts": {
|
|
358
|
+
"asbuild:debug": buildDebug,
|
|
359
|
+
"asbuild:release": buildRelease,
|
|
360
|
+
"asbuild": buildAll,
|
|
361
|
+
"test": "node --test",
|
|
362
|
+
"start": "npx serve ."
|
|
363
|
+
},
|
|
364
|
+
"devDependencies": {
|
|
365
|
+
"toilscript": "^" + version
|
|
366
|
+
}
|
|
367
|
+
}, null, 2));
|
|
368
|
+
console.log(stdoutColors.green(" Created: ") + packageFile);
|
|
369
|
+
} else {
|
|
370
|
+
let pkg = JSON.parse(fs.readFileSync(packageFile));
|
|
371
|
+
let scripts = pkg.scripts || {};
|
|
372
|
+
let updated = false;
|
|
373
|
+
if (!pkg["type"]) {
|
|
374
|
+
pkg["type"] = "module";
|
|
375
|
+
updated = true;
|
|
376
|
+
}
|
|
377
|
+
if (!pkg["exports"]) {
|
|
378
|
+
pkg["exports"] = {
|
|
379
|
+
".": {
|
|
380
|
+
"import": "./build/release.js",
|
|
381
|
+
"types": "./build/release.d.ts"
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
if (!scripts["asbuild"]) {
|
|
386
|
+
scripts["asbuild:debug"] = buildDebug;
|
|
387
|
+
scripts["asbuild:release"] = buildRelease;
|
|
388
|
+
scripts["asbuild"] = buildAll;
|
|
389
|
+
pkg["scripts"] = scripts;
|
|
390
|
+
updated = true;
|
|
391
|
+
}
|
|
392
|
+
if (!scripts["test"] || scripts["test"] == npmDefaultTest) {
|
|
393
|
+
scripts["test"] = "node --test";
|
|
394
|
+
pkg["scripts"] = scripts;
|
|
395
|
+
updated = true;
|
|
396
|
+
}
|
|
397
|
+
if (!scripts["start"]) {
|
|
398
|
+
scripts["start"] = "npx serve .";
|
|
399
|
+
pkg["scripts"] = scripts;
|
|
400
|
+
updated = true;
|
|
401
|
+
}
|
|
402
|
+
let devDependencies = pkg["devDependencies"] || {};
|
|
403
|
+
if (!devDependencies["toilscript"]) {
|
|
404
|
+
devDependencies["toilscript"] = "^" + version;
|
|
405
|
+
pkg["devDependencies"] = devDependencies;
|
|
406
|
+
updated = true;
|
|
407
|
+
}
|
|
408
|
+
if (updated) {
|
|
409
|
+
fs.writeFileSync(packageFile, JSON.stringify(pkg, null, 2));
|
|
410
|
+
console.log(stdoutColors.green(" Updated: ") + packageFile);
|
|
411
|
+
} else {
|
|
412
|
+
console.log(stdoutColors.yellow(" Exists: ") + packageFile);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
console.log();
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
function ensureTestsDirectory() {
|
|
419
|
+
console.log("- Making sure that the 'test' directory exists...");
|
|
420
|
+
if (!fs.existsSync(testsDir)) {
|
|
421
|
+
fs.mkdirSync(testsDir);
|
|
422
|
+
console.log(stdoutColors.green(" Created: ") + testsDir);
|
|
423
|
+
} else {
|
|
424
|
+
console.log(stdoutColors.yellow(" Exists: ") + testsDir);
|
|
425
|
+
}
|
|
426
|
+
console.log();
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function ensureTestsIndexJs() {
|
|
430
|
+
console.log("- Making sure that 'test/index.js' exists...");
|
|
431
|
+
if (!fs.existsSync(testsIndexFile)) {
|
|
432
|
+
fs.writeFileSync(testsIndexFile, [
|
|
433
|
+
"import assert from \"node:assert/strict\";",
|
|
434
|
+
"import { it } from \"node:test\";",
|
|
435
|
+
"import { add } from \"../build/debug.js\";",
|
|
436
|
+
"",
|
|
437
|
+
"it(\"add\", () => {",
|
|
438
|
+
" assert.equal(add(1, 2), 3);",
|
|
439
|
+
"});"
|
|
440
|
+
].join("\n") + "\n");
|
|
441
|
+
console.log(stdoutColors.green(" Created: ") + testsIndexFile);
|
|
442
|
+
} else {
|
|
443
|
+
console.log(stdoutColors.yellow(" Exists: ") + testsIndexFile);
|
|
444
|
+
}
|
|
445
|
+
console.log();
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
function ensureIndexHtml() {
|
|
449
|
+
console.log("- Making sure that 'index.html' exists...");
|
|
450
|
+
if (!fs.existsSync(indexHtmlFile)) {
|
|
451
|
+
fs.writeFileSync(indexHtmlFile, [
|
|
452
|
+
"<!DOCTYPE html>",
|
|
453
|
+
"<html lang=\"en\">",
|
|
454
|
+
"<head>",
|
|
455
|
+
"<script type=\"module\">",
|
|
456
|
+
"import { add } from \"./build/release.js\";",
|
|
457
|
+
"document.body.innerText = add(1, 2);",
|
|
458
|
+
"</script>",
|
|
459
|
+
"</head>",
|
|
460
|
+
"<body></body>",
|
|
461
|
+
"</html>",
|
|
462
|
+
].join("\n") + "\n");
|
|
463
|
+
console.log(stdoutColors.green(" Created: ") + indexHtmlFile);
|
|
464
|
+
} else {
|
|
465
|
+
console.log(stdoutColors.yellow(" Exists: ") + indexHtmlFile);
|
|
466
|
+
}
|
|
467
|
+
console.log();
|
|
468
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const [ nodePath, thisPath, ...args ] = process.argv;
|
|
4
|
+
const nodeArgs = process.execArgv;
|
|
5
|
+
|
|
6
|
+
const hasSourceMaps = nodeArgs.includes("--enable-source-maps");
|
|
7
|
+
const posCustomArgs = args.indexOf("--");
|
|
8
|
+
const isDeno = typeof Deno !== "undefined";
|
|
9
|
+
|
|
10
|
+
if (isDeno) {
|
|
11
|
+
process.on = function() { /* suppress 'not implemented' message */ };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if ((!hasSourceMaps || ~posCustomArgs) && !isDeno) {
|
|
15
|
+
if (!hasSourceMaps) {
|
|
16
|
+
nodeArgs.push("--enable-source-maps");
|
|
17
|
+
}
|
|
18
|
+
if (~posCustomArgs) {
|
|
19
|
+
nodeArgs.push(...args.slice(posCustomArgs + 1));
|
|
20
|
+
args.length = posCustomArgs;
|
|
21
|
+
}
|
|
22
|
+
const { status, signal } = (await import("child_process")).spawnSync(
|
|
23
|
+
nodePath,
|
|
24
|
+
[...nodeArgs, thisPath, ...args],
|
|
25
|
+
{ stdio: "inherit" }
|
|
26
|
+
);
|
|
27
|
+
if (status || signal) process.exitCode = 1;
|
|
28
|
+
} else {
|
|
29
|
+
const apiResult = (await import("../dist/cli.js")).main(process.argv.slice(2), {
|
|
30
|
+
stdout: process.stdout,
|
|
31
|
+
stderr: process.stderr
|
|
32
|
+
});
|
|
33
|
+
const { error } = await apiResult;
|
|
34
|
+
if (error) process.exitCode = 1;
|
|
35
|
+
}
|