toiljs 0.0.4 → 0.0.6
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 +193 -68
- 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/channel/channel.d.ts +23 -0
- package/build/client/channel/channel.js +94 -0
- package/build/client/error-boundary.d.ts +16 -0
- package/build/client/error-boundary.js +19 -0
- package/build/client/head/head.d.ts +26 -0
- package/build/client/head/head.js +87 -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 +18 -6
- package/build/client/index.js +10 -3
- 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/Link.d.ts +8 -0
- package/build/client/navigation/Link.js +44 -0
- package/build/client/navigation/NavLink.d.ts +14 -0
- package/build/client/navigation/NavLink.js +37 -0
- package/build/client/navigation/navigation.d.ts +13 -0
- package/build/client/navigation/navigation.js +97 -0
- package/build/client/navigation/prefetch.d.ts +11 -0
- package/build/client/navigation/prefetch.js +100 -0
- package/build/client/navigation/scroll.d.ts +8 -0
- package/build/client/navigation/scroll.js +36 -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/routing/Router.d.ts +7 -0
- package/build/client/routing/Router.js +55 -0
- package/build/client/routing/error-boundary.d.ts +16 -0
- package/build/client/routing/error-boundary.js +19 -0
- package/build/client/routing/hooks.d.ts +17 -0
- package/build/client/routing/hooks.js +48 -0
- package/build/client/routing/lazy.d.ts +16 -0
- package/build/client/routing/lazy.js +53 -0
- package/build/client/routing/match.d.ts +2 -0
- package/build/client/routing/match.js +32 -0
- package/build/client/routing/mount.d.ts +2 -0
- package/build/client/routing/mount.js +13 -0
- package/build/client/routing/params-context.d.ts +2 -0
- package/build/client/routing/params-context.js +2 -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 +14 -2
- package/build/compiler/docs.d.ts +10 -0
- package/build/compiler/docs.js +59 -0
- package/build/compiler/generate.js +144 -16
- package/build/compiler/index.d.ts +4 -2
- package/build/compiler/index.js +4 -3
- package/build/compiler/plugin.js +16 -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/components/HoneycombBackground.tsx +162 -0
- package/examples/basic/client/layout.tsx +43 -26
- package/examples/basic/client/public/favicon.ico +0 -0
- 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 +16 -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 +2 -2
- 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 +267 -82
- 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/head/head.ts +140 -0
- package/src/client/index.ts +39 -9
- package/src/client/navigation/Link.tsx +99 -0
- package/src/client/navigation/NavLink.tsx +86 -0
- package/src/client/navigation/navigation.ts +142 -0
- package/src/client/navigation/prefetch.ts +130 -0
- package/src/client/navigation/scroll.ts +53 -0
- package/src/client/routing/Router.tsx +95 -0
- package/src/client/routing/error-boundary.tsx +43 -0
- package/src/client/routing/hooks.ts +115 -0
- package/src/client/routing/lazy.ts +93 -0
- package/src/client/{match.ts → routing/match.ts} +11 -3
- package/src/client/routing/mount.tsx +28 -0
- package/src/client/routing/params-context.ts +10 -0
- package/src/client/types.ts +36 -0
- package/src/compiler/config.ts +26 -10
- package/src/compiler/docs.ts +87 -0
- package/src/compiler/generate.ts +180 -23
- package/src/compiler/index.ts +6 -4
- package/src/compiler/plugin.ts +22 -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/templates/app/client/404.tsx +11 -0
- package/templates/app/client/components/.gitkeep +1 -0
- package/templates/app/client/components/Footer.tsx +8 -0
- package/templates/app/client/components/HoneycombBackground.tsx +162 -0
- package/templates/app/client/layout.tsx +53 -0
- package/templates/app/client/public/favicon.ico +0 -0
- package/templates/app/client/public/images/.gitkeep +1 -0
- package/templates/app/client/public/images/logo.svg +37 -0
- package/templates/app/client/public/index.html +16 -0
- package/templates/app/client/public/robots.txt +2 -0
- package/templates/app/client/routes/about.tsx +11 -0
- package/templates/app/client/routes/blog/[id].tsx +12 -0
- package/templates/app/client/routes/docs/[...slug].tsx +12 -0
- package/templates/app/client/routes/get-started.tsx +84 -0
- package/templates/app/client/routes/index.tsx +80 -0
- package/templates/app/client/routes/io.tsx +24 -0
- package/templates/app/client/styles/main.css +461 -0
- package/templates/app/client/toil.tsx +7 -0
- package/test/channel.test.ts +1 -1
- 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 +16 -1
- 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
- /package/src/client/{channel.ts → channel/channel.ts} +0 -0
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
import * as process from "./process.js";
|
|
2
|
+
|
|
3
|
+
// https://github.com/browserify/path-browserify v1.0.1
|
|
4
|
+
//
|
|
5
|
+
// Copyright (c) 2013 James Halliday
|
|
6
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
7
|
+
//
|
|
8
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
9
|
+
// copy of this software and associated documentation files (the
|
|
10
|
+
// "Software"), to deal in the Software without restriction, including
|
|
11
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
12
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
13
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
14
|
+
// following conditions:
|
|
15
|
+
//
|
|
16
|
+
// The above copyright notice and this permission notice shall be included
|
|
17
|
+
// in all copies or substantial portions of the Software.
|
|
18
|
+
//
|
|
19
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
20
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
21
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
22
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
23
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
24
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
25
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
26
|
+
|
|
27
|
+
function assertPath(path) {
|
|
28
|
+
if (typeof path !== 'string') {
|
|
29
|
+
throw new TypeError('Path must be a string. Received ' + JSON.stringify(path));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Resolves . and .. elements in a path with directory names
|
|
34
|
+
function normalizeStringPosix(path, allowAboveRoot) {
|
|
35
|
+
var res = '';
|
|
36
|
+
var lastSegmentLength = 0;
|
|
37
|
+
var lastSlash = -1;
|
|
38
|
+
var dots = 0;
|
|
39
|
+
var code;
|
|
40
|
+
for (var i = 0; i <= path.length; ++i) {
|
|
41
|
+
if (i < path.length)
|
|
42
|
+
code = path.charCodeAt(i);
|
|
43
|
+
else if (code === 47 /*/*/)
|
|
44
|
+
break;
|
|
45
|
+
else
|
|
46
|
+
code = 47 /*/*/;
|
|
47
|
+
if (code === 47 /*/*/) {
|
|
48
|
+
if (lastSlash === i - 1 || dots === 1) {
|
|
49
|
+
// NOOP
|
|
50
|
+
} else if (lastSlash !== i - 1 && dots === 2) {
|
|
51
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 || res.charCodeAt(res.length - 2) !== 46) {
|
|
52
|
+
if (res.length > 2) {
|
|
53
|
+
var lastSlashIndex = res.lastIndexOf('/');
|
|
54
|
+
if (lastSlashIndex !== res.length - 1) {
|
|
55
|
+
if (lastSlashIndex === -1) {
|
|
56
|
+
res = '';
|
|
57
|
+
lastSegmentLength = 0;
|
|
58
|
+
} else {
|
|
59
|
+
res = res.slice(0, lastSlashIndex);
|
|
60
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf('/');
|
|
61
|
+
}
|
|
62
|
+
lastSlash = i;
|
|
63
|
+
dots = 0;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
} else if (res.length === 2 || res.length === 1) {
|
|
67
|
+
res = '';
|
|
68
|
+
lastSegmentLength = 0;
|
|
69
|
+
lastSlash = i;
|
|
70
|
+
dots = 0;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (allowAboveRoot) {
|
|
75
|
+
if (res.length > 0)
|
|
76
|
+
res += '/..';
|
|
77
|
+
else
|
|
78
|
+
res = '..';
|
|
79
|
+
lastSegmentLength = 2;
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
if (res.length > 0)
|
|
83
|
+
res += '/' + path.slice(lastSlash + 1, i);
|
|
84
|
+
else
|
|
85
|
+
res = path.slice(lastSlash + 1, i);
|
|
86
|
+
lastSegmentLength = i - lastSlash - 1;
|
|
87
|
+
}
|
|
88
|
+
lastSlash = i;
|
|
89
|
+
dots = 0;
|
|
90
|
+
} else if (code === 46 && dots !== -1) {
|
|
91
|
+
++dots;
|
|
92
|
+
} else {
|
|
93
|
+
dots = -1;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return res;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function _format(sep, pathObject) {
|
|
100
|
+
var dir = pathObject.dir || pathObject.root;
|
|
101
|
+
var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || '');
|
|
102
|
+
if (!dir) {
|
|
103
|
+
return base;
|
|
104
|
+
}
|
|
105
|
+
if (dir === pathObject.root) {
|
|
106
|
+
return dir + base;
|
|
107
|
+
}
|
|
108
|
+
return dir + sep + base;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// path.resolve([from ...], to)
|
|
112
|
+
export function resolve() {
|
|
113
|
+
var resolvedPath = '';
|
|
114
|
+
var resolvedAbsolute = false;
|
|
115
|
+
var cwd;
|
|
116
|
+
|
|
117
|
+
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
118
|
+
var path;
|
|
119
|
+
if (i >= 0)
|
|
120
|
+
path = arguments[i];
|
|
121
|
+
else {
|
|
122
|
+
if (cwd === undefined)
|
|
123
|
+
cwd = process.cwd();
|
|
124
|
+
path = cwd;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
assertPath(path);
|
|
128
|
+
|
|
129
|
+
// Skip empty entries
|
|
130
|
+
if (path.length === 0) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
resolvedPath = path + '/' + resolvedPath;
|
|
135
|
+
resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// At this point the path should be resolved to a full absolute path, but
|
|
139
|
+
// handle relative paths to be safe (might happen when process.cwd() fails)
|
|
140
|
+
|
|
141
|
+
// Normalize the path
|
|
142
|
+
resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
|
|
143
|
+
|
|
144
|
+
if (resolvedAbsolute) {
|
|
145
|
+
if (resolvedPath.length > 0)
|
|
146
|
+
return '/' + resolvedPath;
|
|
147
|
+
else
|
|
148
|
+
return '/';
|
|
149
|
+
} else if (resolvedPath.length > 0) {
|
|
150
|
+
return resolvedPath;
|
|
151
|
+
} else {
|
|
152
|
+
return '.';
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function normalize(path) {
|
|
157
|
+
assertPath(path);
|
|
158
|
+
|
|
159
|
+
if (path.length === 0) return '.';
|
|
160
|
+
|
|
161
|
+
var isAbsolute = path.charCodeAt(0) === 47 /*/*/;
|
|
162
|
+
var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/;
|
|
163
|
+
|
|
164
|
+
// Normalize the path
|
|
165
|
+
path = normalizeStringPosix(path, !isAbsolute);
|
|
166
|
+
|
|
167
|
+
if (path.length === 0 && !isAbsolute) path = '.';
|
|
168
|
+
if (path.length > 0 && trailingSeparator) path += '/';
|
|
169
|
+
|
|
170
|
+
if (isAbsolute) return '/' + path;
|
|
171
|
+
return path;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function isAbsolute(path) {
|
|
175
|
+
assertPath(path);
|
|
176
|
+
return path.length > 0 && path.charCodeAt(0) === 47 /*/*/;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function join() {
|
|
180
|
+
if (arguments.length === 0)
|
|
181
|
+
return '.';
|
|
182
|
+
var joined;
|
|
183
|
+
for (var i = 0; i < arguments.length; ++i) {
|
|
184
|
+
var arg = arguments[i];
|
|
185
|
+
assertPath(arg);
|
|
186
|
+
if (arg.length > 0) {
|
|
187
|
+
if (joined === undefined)
|
|
188
|
+
joined = arg;
|
|
189
|
+
else
|
|
190
|
+
joined += '/' + arg;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (joined === undefined)
|
|
194
|
+
return '.';
|
|
195
|
+
return normalize(joined);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export function relative(from, to) {
|
|
199
|
+
assertPath(from);
|
|
200
|
+
assertPath(to);
|
|
201
|
+
|
|
202
|
+
if (from === to) return '';
|
|
203
|
+
|
|
204
|
+
from = resolve(from);
|
|
205
|
+
to = resolve(to);
|
|
206
|
+
|
|
207
|
+
if (from === to) return '';
|
|
208
|
+
|
|
209
|
+
if (from === ".") return to; // FIX for 'odule.ts' (see issue #1398)
|
|
210
|
+
|
|
211
|
+
// Trim any leading backslashes
|
|
212
|
+
var fromStart = 1;
|
|
213
|
+
for (; fromStart < from.length; ++fromStart) {
|
|
214
|
+
if (from.charCodeAt(fromStart) !== 47 /*/*/)
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
var fromEnd = from.length;
|
|
218
|
+
var fromLen = fromEnd - fromStart;
|
|
219
|
+
|
|
220
|
+
// Trim any leading backslashes
|
|
221
|
+
var toStart = 1;
|
|
222
|
+
for (; toStart < to.length; ++toStart) {
|
|
223
|
+
if (to.charCodeAt(toStart) !== 47 /*/*/)
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
var toEnd = to.length;
|
|
227
|
+
var toLen = toEnd - toStart;
|
|
228
|
+
|
|
229
|
+
// Compare paths to find the longest common path from root
|
|
230
|
+
var length = fromLen < toLen ? fromLen : toLen;
|
|
231
|
+
var lastCommonSep = -1;
|
|
232
|
+
var i = 0;
|
|
233
|
+
for (; i <= length; ++i) {
|
|
234
|
+
if (i === length) {
|
|
235
|
+
if (toLen > length) {
|
|
236
|
+
if (to.charCodeAt(toStart + i) === 47 /*/*/) {
|
|
237
|
+
// We get here if `from` is the exact base path for `to`.
|
|
238
|
+
// For example: from='/foo/bar'; to='/foo/bar/baz'
|
|
239
|
+
return to.slice(toStart + i + 1);
|
|
240
|
+
} else if (i === 0) {
|
|
241
|
+
// We get here if `from` is the root
|
|
242
|
+
// For example: from='/'; to='/foo'
|
|
243
|
+
return to.slice(toStart + i);
|
|
244
|
+
}
|
|
245
|
+
} else if (fromLen > length) {
|
|
246
|
+
if (from.charCodeAt(fromStart + i) === 47 /*/*/) {
|
|
247
|
+
// We get here if `to` is the exact base path for `from`.
|
|
248
|
+
// For example: from='/foo/bar/baz'; to='/foo/bar'
|
|
249
|
+
lastCommonSep = i;
|
|
250
|
+
} else if (i === 0) {
|
|
251
|
+
// We get here if `to` is the root.
|
|
252
|
+
// For example: from='/foo'; to='/'
|
|
253
|
+
lastCommonSep = 0;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
var fromCode = from.charCodeAt(fromStart + i);
|
|
259
|
+
var toCode = to.charCodeAt(toStart + i);
|
|
260
|
+
if (fromCode !== toCode)
|
|
261
|
+
break;
|
|
262
|
+
else if (fromCode === 47 /*/*/)
|
|
263
|
+
lastCommonSep = i;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
var out = '';
|
|
267
|
+
// Generate the relative path based on the path difference between `to`
|
|
268
|
+
// and `from`
|
|
269
|
+
for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
|
|
270
|
+
if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {
|
|
271
|
+
if (out.length === 0)
|
|
272
|
+
out += '..';
|
|
273
|
+
else
|
|
274
|
+
out += '/..';
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Lastly, append the rest of the destination (`to`) path that comes after
|
|
279
|
+
// the common path parts
|
|
280
|
+
if (out.length > 0)
|
|
281
|
+
return out + to.slice(toStart + lastCommonSep);
|
|
282
|
+
else {
|
|
283
|
+
toStart += lastCommonSep;
|
|
284
|
+
if (to.charCodeAt(toStart) === 47 /*/*/)
|
|
285
|
+
++toStart;
|
|
286
|
+
return to.slice(toStart);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export function dirname(path) {
|
|
291
|
+
assertPath(path);
|
|
292
|
+
if (path.length === 0) return '.';
|
|
293
|
+
var code = path.charCodeAt(0);
|
|
294
|
+
var hasRoot = code === 47 /*/*/;
|
|
295
|
+
var end = -1;
|
|
296
|
+
var matchedSlash = true;
|
|
297
|
+
for (var i = path.length - 1; i >= 1; --i) {
|
|
298
|
+
code = path.charCodeAt(i);
|
|
299
|
+
if (code === 47 /*/*/) {
|
|
300
|
+
if (!matchedSlash) {
|
|
301
|
+
end = i;
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
} else {
|
|
305
|
+
// We saw the first non-path separator
|
|
306
|
+
matchedSlash = false;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (end === -1) return hasRoot ? '/' : '.';
|
|
311
|
+
if (hasRoot && end === 1) return '//';
|
|
312
|
+
return path.slice(0, end);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export function basename(path, ext) {
|
|
316
|
+
if (ext !== undefined && typeof ext !== 'string') throw new TypeError('"ext" argument must be a string');
|
|
317
|
+
assertPath(path);
|
|
318
|
+
|
|
319
|
+
var start = 0;
|
|
320
|
+
var end = -1;
|
|
321
|
+
var matchedSlash = true;
|
|
322
|
+
var i;
|
|
323
|
+
|
|
324
|
+
if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
|
|
325
|
+
if (ext.length === path.length && ext === path) return '';
|
|
326
|
+
var extIdx = ext.length - 1;
|
|
327
|
+
var firstNonSlashEnd = -1;
|
|
328
|
+
for (i = path.length - 1; i >= 0; --i) {
|
|
329
|
+
var code = path.charCodeAt(i);
|
|
330
|
+
if (code === 47 /*/*/) {
|
|
331
|
+
// If we reached a path separator that was not part of a set of path
|
|
332
|
+
// separators at the end of the string, stop now
|
|
333
|
+
if (!matchedSlash) {
|
|
334
|
+
start = i + 1;
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
} else {
|
|
338
|
+
if (firstNonSlashEnd === -1) {
|
|
339
|
+
// We saw the first non-path separator, remember this index in case
|
|
340
|
+
// we need it if the extension ends up not matching
|
|
341
|
+
matchedSlash = false;
|
|
342
|
+
firstNonSlashEnd = i + 1;
|
|
343
|
+
}
|
|
344
|
+
if (extIdx >= 0) {
|
|
345
|
+
// Try to match the explicit extension
|
|
346
|
+
if (code === ext.charCodeAt(extIdx)) {
|
|
347
|
+
if (--extIdx === -1) {
|
|
348
|
+
// We matched the extension, so mark this as the end of our path
|
|
349
|
+
// component
|
|
350
|
+
end = i;
|
|
351
|
+
}
|
|
352
|
+
} else {
|
|
353
|
+
// Extension does not match, so our result is the entire path
|
|
354
|
+
// component
|
|
355
|
+
extIdx = -1;
|
|
356
|
+
end = firstNonSlashEnd;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length;
|
|
363
|
+
return path.slice(start, end);
|
|
364
|
+
} else {
|
|
365
|
+
for (i = path.length - 1; i >= 0; --i) {
|
|
366
|
+
if (path.charCodeAt(i) === 47 /*/*/) {
|
|
367
|
+
// If we reached a path separator that was not part of a set of path
|
|
368
|
+
// separators at the end of the string, stop now
|
|
369
|
+
if (!matchedSlash) {
|
|
370
|
+
start = i + 1;
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
} else if (end === -1) {
|
|
374
|
+
// We saw the first non-path separator, mark this as the end of our
|
|
375
|
+
// path component
|
|
376
|
+
matchedSlash = false;
|
|
377
|
+
end = i + 1;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (end === -1) return '';
|
|
382
|
+
return path.slice(start, end);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export function extname(path) {
|
|
387
|
+
assertPath(path);
|
|
388
|
+
var startDot = -1;
|
|
389
|
+
var startPart = 0;
|
|
390
|
+
var end = -1;
|
|
391
|
+
var matchedSlash = true;
|
|
392
|
+
// Track the state of characters (if any) we see before our first dot and
|
|
393
|
+
// after any path separator we find
|
|
394
|
+
var preDotState = 0;
|
|
395
|
+
for (var i = path.length - 1; i >= 0; --i) {
|
|
396
|
+
var code = path.charCodeAt(i);
|
|
397
|
+
if (code === 47 /*/*/) {
|
|
398
|
+
// If we reached a path separator that was not part of a set of path
|
|
399
|
+
// separators at the end of the string, stop now
|
|
400
|
+
if (!matchedSlash) {
|
|
401
|
+
startPart = i + 1;
|
|
402
|
+
break;
|
|
403
|
+
}
|
|
404
|
+
continue;
|
|
405
|
+
}
|
|
406
|
+
if (end === -1) {
|
|
407
|
+
// We saw the first non-path separator, mark this as the end of our
|
|
408
|
+
// extension
|
|
409
|
+
matchedSlash = false;
|
|
410
|
+
end = i + 1;
|
|
411
|
+
}
|
|
412
|
+
if (code === 46) {
|
|
413
|
+
// If this is our first dot, mark it as the start of our extension
|
|
414
|
+
if (startDot === -1)
|
|
415
|
+
startDot = i;
|
|
416
|
+
else if (preDotState !== 1)
|
|
417
|
+
preDotState = 1;
|
|
418
|
+
} else if (startDot !== -1) {
|
|
419
|
+
// We saw a non-dot and non-path separator before our dot, so we should
|
|
420
|
+
// have a good chance at having a non-empty extension
|
|
421
|
+
preDotState = -1;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
if (startDot === -1 || end === -1 ||
|
|
426
|
+
// We saw a non-dot character immediately before the dot
|
|
427
|
+
preDotState === 0 ||
|
|
428
|
+
// The (right-most) trimmed path component is exactly '..'
|
|
429
|
+
preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
430
|
+
return '';
|
|
431
|
+
}
|
|
432
|
+
return path.slice(startDot, end);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
export function format(pathObject) {
|
|
436
|
+
if (pathObject === null || typeof pathObject !== 'object') {
|
|
437
|
+
throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
|
|
438
|
+
}
|
|
439
|
+
return _format('/', pathObject);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
export function parse(path) {
|
|
443
|
+
assertPath(path);
|
|
444
|
+
|
|
445
|
+
var ret = { root: '', dir: '', base: '', ext: '', name: '' };
|
|
446
|
+
if (path.length === 0) return ret;
|
|
447
|
+
var code = path.charCodeAt(0);
|
|
448
|
+
var isAbsolute = code === 47 /*/*/;
|
|
449
|
+
var start;
|
|
450
|
+
if (isAbsolute) {
|
|
451
|
+
ret.root = '/';
|
|
452
|
+
start = 1;
|
|
453
|
+
} else {
|
|
454
|
+
start = 0;
|
|
455
|
+
}
|
|
456
|
+
var startDot = -1;
|
|
457
|
+
var startPart = 0;
|
|
458
|
+
var end = -1;
|
|
459
|
+
var matchedSlash = true;
|
|
460
|
+
var i = path.length - 1;
|
|
461
|
+
|
|
462
|
+
// Track the state of characters (if any) we see before our first dot and
|
|
463
|
+
// after any path separator we find
|
|
464
|
+
var preDotState = 0;
|
|
465
|
+
|
|
466
|
+
// Get non-dir info
|
|
467
|
+
for (; i >= start; --i) {
|
|
468
|
+
code = path.charCodeAt(i);
|
|
469
|
+
if (code === 47 /*/*/) {
|
|
470
|
+
// If we reached a path separator that was not part of a set of path
|
|
471
|
+
// separators at the end of the string, stop now
|
|
472
|
+
if (!matchedSlash) {
|
|
473
|
+
startPart = i + 1;
|
|
474
|
+
break;
|
|
475
|
+
}
|
|
476
|
+
continue;
|
|
477
|
+
}
|
|
478
|
+
if (end === -1) {
|
|
479
|
+
// We saw the first non-path separator, mark this as the end of our
|
|
480
|
+
// extension
|
|
481
|
+
matchedSlash = false;
|
|
482
|
+
end = i + 1;
|
|
483
|
+
}
|
|
484
|
+
if (code === 46) {
|
|
485
|
+
// If this is our first dot, mark it as the start of our extension
|
|
486
|
+
if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;
|
|
487
|
+
} else if (startDot !== -1) {
|
|
488
|
+
// We saw a non-dot and non-path separator before our dot, so we should
|
|
489
|
+
// have a good chance at having a non-empty extension
|
|
490
|
+
preDotState = -1;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
if (startDot === -1 || end === -1 ||
|
|
495
|
+
// We saw a non-dot character immediately before the dot
|
|
496
|
+
preDotState === 0 ||
|
|
497
|
+
// The (right-most) trimmed path component is exactly '..'
|
|
498
|
+
preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
499
|
+
if (end !== -1) {
|
|
500
|
+
if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end);
|
|
501
|
+
}
|
|
502
|
+
} else {
|
|
503
|
+
if (startPart === 0 && isAbsolute) {
|
|
504
|
+
ret.name = path.slice(1, startDot);
|
|
505
|
+
ret.base = path.slice(1, end);
|
|
506
|
+
} else {
|
|
507
|
+
ret.name = path.slice(startPart, startDot);
|
|
508
|
+
ret.base = path.slice(startPart, end);
|
|
509
|
+
}
|
|
510
|
+
ret.ext = path.slice(startDot, end);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/';
|
|
514
|
+
|
|
515
|
+
return ret;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
export const sep = '/';
|
|
519
|
+
export const delimiter = ':';
|
|
520
|
+
export const win32 = null;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export const platform = "linux";
|
|
2
|
+
|
|
3
|
+
export function cwd() {
|
|
4
|
+
return ".";
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function umask() {
|
|
8
|
+
return 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const argv = [];
|
|
12
|
+
|
|
13
|
+
export function exit(code = 0) {
|
|
14
|
+
throw Error(`exit ${code}`);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// https://github.com/kumavis/browser-process-hrtime v1.0.0
|
|
18
|
+
//
|
|
19
|
+
// Copyright 2014 kumavis
|
|
20
|
+
//
|
|
21
|
+
// Redistribution and use in source and binary forms, with or without
|
|
22
|
+
// modification, are permitted provided that the following conditions are met:
|
|
23
|
+
//
|
|
24
|
+
// 1. Redistributions of source code must retain the above copyright notice,
|
|
25
|
+
// this list of conditions and the following disclaimer.
|
|
26
|
+
//
|
|
27
|
+
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
28
|
+
// this list of conditions and the following disclaimer in the documentation
|
|
29
|
+
// and/or other materials provided with the distribution.
|
|
30
|
+
//
|
|
31
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
32
|
+
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
33
|
+
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
34
|
+
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
35
|
+
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
36
|
+
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
37
|
+
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
38
|
+
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
39
|
+
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
40
|
+
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
41
|
+
// POSSIBILITY OF SUCH DAMAGE.
|
|
42
|
+
|
|
43
|
+
var performance = globalThis.performance || {};
|
|
44
|
+
var performanceNow = performance.now || function() { return new Date().getTime(); };
|
|
45
|
+
|
|
46
|
+
export function hrtime(previousTimestamp) {
|
|
47
|
+
var clocktime = performanceNow.call(performance);
|
|
48
|
+
var seconds = Math.floor(clocktime * 1e-3);
|
|
49
|
+
var nanoseconds = Math.floor(clocktime * 1e6 - seconds * 1e9);
|
|
50
|
+
if (previousTimestamp) {
|
|
51
|
+
seconds -= previousTimestamp[0];
|
|
52
|
+
nanoseconds -= previousTimestamp[1];
|
|
53
|
+
if (nanoseconds < 0) {
|
|
54
|
+
seconds--;
|
|
55
|
+
nanoseconds += 1e9;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return [ seconds, nanoseconds ];
|
|
59
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as path from "./path.js";
|
|
2
|
+
|
|
3
|
+
function encodePathChars(filepath) {
|
|
4
|
+
return filepath
|
|
5
|
+
.replace(/%/g, "%25")
|
|
6
|
+
.replace(/\\/g, "%5C")
|
|
7
|
+
.replace(/\n/g, "%0A")
|
|
8
|
+
.replace(/\r/g, "%0D")
|
|
9
|
+
.replace(/\t/g, "%09");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function pathToFileURL(filepath) {
|
|
13
|
+
let resolved = path.resolve(filepath);
|
|
14
|
+
if (
|
|
15
|
+
filepath.charCodeAt(filepath.length - 1) === /* SLASH */ 47 &&
|
|
16
|
+
resolved[resolved.length - 1] !== path.sep
|
|
17
|
+
) {
|
|
18
|
+
resolved += "/";
|
|
19
|
+
}
|
|
20
|
+
const url = new URL("file://");
|
|
21
|
+
url.pathname = encodePathChars(resolved);
|
|
22
|
+
return url;
|
|
23
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview CPU utility.
|
|
3
|
+
* @license Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// https://www.npmjs.com/package/physical-cpu-count
|
|
7
|
+
|
|
8
|
+
import os from "os";
|
|
9
|
+
import childProcess from "child_process";
|
|
10
|
+
|
|
11
|
+
const cpus = os.cpus();
|
|
12
|
+
|
|
13
|
+
function exec(command) {
|
|
14
|
+
return childProcess.execSync(command, {encoding: 'utf8'});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
var coreCount;
|
|
18
|
+
|
|
19
|
+
const platform = os.platform();
|
|
20
|
+
if (platform === "linux") {
|
|
21
|
+
const output = exec("lscpu -p | egrep -v \"^#\" | sort -u -t, -k 2,4 | wc -l");
|
|
22
|
+
coreCount = parseInt(output.trim(), 10);
|
|
23
|
+
} else if (platform === "darwin") {
|
|
24
|
+
const output = exec("sysctl -n hw.physicalcpu_max");
|
|
25
|
+
coreCount = parseInt(output.trim(), 10);
|
|
26
|
+
} else if (platform === "windows") {
|
|
27
|
+
const output = exec("WMIC CPU Get NumberOfCores");
|
|
28
|
+
coreCount = output.split(os.EOL)
|
|
29
|
+
.map(line => parseInt(line))
|
|
30
|
+
.filter(value => !isNaN(value))
|
|
31
|
+
.reduce((sum, number) => sum + number, 0);
|
|
32
|
+
} else {
|
|
33
|
+
const cores = cpus.filter(function (cpu, index) {
|
|
34
|
+
const hasHyperthreading = cpu.model.includes("Intel");
|
|
35
|
+
const isOdd = index % 2 === 1;
|
|
36
|
+
return !hasHyperthreading || isOdd;
|
|
37
|
+
});
|
|
38
|
+
coreCount = cores.length;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const threadCount = cpus.length;
|
|
42
|
+
export { coreCount };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview File finding utility.
|
|
3
|
+
* @license Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { fs, path } from "./node.js";
|
|
7
|
+
|
|
8
|
+
export function findFiles(dirname, filter) {
|
|
9
|
+
var out = [];
|
|
10
|
+
fs.readdirSync(dirname).forEach(name => {
|
|
11
|
+
if (fs.statSync(path.join(dirname, name)).isDirectory()) {
|
|
12
|
+
findFiles(path.join(dirname, name), filter).forEach(iname => out.push(name + "/" + iname));
|
|
13
|
+
} else if (!filter || typeof filter === "function" ? filter(name) : filter.test(name)) {
|
|
14
|
+
out.push(name);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return out;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default findFiles;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Node polyfill definitions.
|
|
3
|
+
* @license Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import fs from "fs";
|
|
7
|
+
import module from "module";
|
|
8
|
+
import path from "path";
|
|
9
|
+
import process from "process";
|
|
10
|
+
import url from "url";
|
|
11
|
+
|
|
12
|
+
/** Whether the environment is Node.js. */
|
|
13
|
+
export const isNode: boolean;
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
fs,
|
|
17
|
+
module,
|
|
18
|
+
path,
|
|
19
|
+
process,
|
|
20
|
+
url
|
|
21
|
+
};
|