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.
Files changed (359) hide show
  1. package/.idea/prettier.xml +1 -0
  2. package/as-pect.config.js +1 -1
  3. package/build/backend/.tsbuildinfo +1 -1
  4. package/build/backend/index.js +1 -2
  5. package/build/cli/.tsbuildinfo +1 -1
  6. package/build/cli/configure.d.ts +15 -0
  7. package/build/cli/configure.js +201 -0
  8. package/build/cli/create.d.ts +4 -0
  9. package/build/cli/create.js +168 -57
  10. package/build/cli/features.d.ts +23 -0
  11. package/build/cli/features.js +85 -0
  12. package/build/cli/index.js +42 -2
  13. package/build/cli/proc.d.ts +1 -0
  14. package/build/cli/proc.js +11 -0
  15. package/build/cli/ui.js +1 -2
  16. package/build/cli/validate.d.ts +4 -0
  17. package/build/cli/validate.js +19 -0
  18. package/build/client/.tsbuildinfo +1 -1
  19. package/build/client/Link.d.ts +8 -0
  20. package/build/client/Link.js +44 -0
  21. package/build/client/NavLink.d.ts +14 -0
  22. package/build/client/NavLink.js +37 -0
  23. package/build/client/Router.d.ts +7 -0
  24. package/build/client/Router.js +55 -0
  25. package/build/client/error-boundary.d.ts +16 -0
  26. package/build/client/error-boundary.js +19 -0
  27. package/build/client/head.d.ts +26 -0
  28. package/build/client/head.js +87 -0
  29. package/build/client/hooks.d.ts +17 -0
  30. package/build/client/hooks.js +48 -0
  31. package/build/client/index.d.ts +14 -2
  32. package/build/client/index.js +8 -1
  33. package/build/client/lazy.d.ts +16 -0
  34. package/build/client/lazy.js +53 -0
  35. package/build/client/match.js +7 -0
  36. package/build/client/mount.d.ts +2 -0
  37. package/build/client/mount.js +13 -0
  38. package/build/client/navigation.d.ts +13 -0
  39. package/build/client/navigation.js +97 -0
  40. package/build/client/params-context.d.ts +2 -0
  41. package/build/client/params-context.js +2 -0
  42. package/build/client/prefetch.d.ts +11 -0
  43. package/build/client/prefetch.js +100 -0
  44. package/build/client/scroll.d.ts +8 -0
  45. package/build/client/scroll.js +36 -0
  46. package/build/client/types.d.ts +27 -0
  47. package/build/client/types.js +1 -0
  48. package/build/compiler/.tsbuildinfo +1 -1
  49. package/build/compiler/config.d.ts +2 -0
  50. package/build/compiler/config.js +4 -1
  51. package/build/compiler/docs.d.ts +10 -0
  52. package/build/compiler/docs.js +59 -0
  53. package/build/compiler/generate.js +134 -16
  54. package/build/compiler/index.d.ts +4 -2
  55. package/build/compiler/index.js +4 -3
  56. package/build/compiler/plugin.js +2 -1
  57. package/build/compiler/routes.js +5 -1
  58. package/build/compiler/vite.d.ts +1 -1
  59. package/build/compiler/vite.js +17 -1
  60. package/build/io/.tsbuildinfo +1 -1
  61. package/build/io/BinaryWriter.js +2 -2
  62. package/eslint.config.js +1 -1
  63. package/examples/basic/.toil/docs/cli.md +3 -0
  64. package/examples/basic/.toil/docs/client.md +3 -0
  65. package/examples/basic/.toil/docs/index.md +3 -0
  66. package/examples/basic/.toil/docs/routing.md +3 -0
  67. package/examples/basic/.toil/docs/server.md +3 -0
  68. package/examples/basic/.toil/docs/styling.md +3 -0
  69. package/examples/basic/.toil/entry.tsx +3 -8
  70. package/examples/basic/.toil/globals.ts +6 -0
  71. package/examples/basic/.toil/index.html +16 -12
  72. package/examples/basic/.toil/public/images/.gitkeep +1 -0
  73. package/examples/basic/.toil/public/images/logo.svg +37 -0
  74. package/examples/basic/.toil/public/robots.txt +2 -0
  75. package/examples/basic/.toil/routes.ts +9 -7
  76. package/examples/basic/build/client/assets/404-Bq0jNTUo.js +1 -0
  77. package/examples/basic/build/client/assets/_...slug_-CXKf6qnB.js +1 -0
  78. package/examples/basic/build/client/assets/_id_-BadAyQnb.js +1 -0
  79. package/examples/basic/build/client/assets/about-BOhoEcEO.js +1 -0
  80. package/examples/basic/build/client/assets/get-started-BIXpcjkT.js +9 -0
  81. package/examples/basic/build/client/assets/index-BmqcTaBB.js +1 -0
  82. package/examples/basic/build/client/assets/io-DEVjjaJj.js +1 -0
  83. package/examples/basic/build/client/assets/layout-DJegirdz.js +1 -0
  84. package/examples/basic/build/client/assets/react-DEQrz1q7.js +9 -0
  85. package/examples/basic/build/client/assets/rolldown-runtime-KL5VtC6j.js +1 -0
  86. package/examples/basic/build/client/assets/routes-BYWn6TxK.js +1 -0
  87. package/examples/basic/build/client/css/style.css +2 -0
  88. package/examples/basic/build/client/images/.gitkeep +1 -0
  89. package/examples/basic/build/client/images/logo.svg +37 -0
  90. package/examples/basic/build/client/index.html +17 -0
  91. package/examples/basic/build/client/robots.txt +2 -0
  92. package/examples/basic/client/404.tsx +2 -5
  93. package/examples/basic/client/components/.gitkeep +1 -0
  94. package/examples/basic/client/components/Footer.tsx +8 -0
  95. package/examples/basic/client/layout.tsx +39 -26
  96. package/examples/basic/client/public/images/.gitkeep +1 -0
  97. package/examples/basic/client/public/images/logo.svg +37 -0
  98. package/examples/basic/client/public/index.html +15 -0
  99. package/examples/basic/client/public/robots.txt +2 -0
  100. package/examples/basic/client/routes/about.tsx +1 -3
  101. package/examples/basic/client/routes/blog/[id].tsx +2 -4
  102. package/examples/basic/client/routes/docs/[...slug].tsx +3 -6
  103. package/examples/basic/client/routes/get-started.tsx +84 -0
  104. package/examples/basic/client/routes/index.tsx +74 -7
  105. package/examples/basic/client/routes/io.tsx +3 -7
  106. package/examples/basic/client/styles/main.css +461 -0
  107. package/examples/basic/client/toil.tsx +7 -0
  108. package/examples/basic/node_modules/.bin/toilinit +16 -0
  109. package/examples/basic/node_modules/.bin/toilinit.cmd +17 -0
  110. package/examples/basic/node_modules/.bin/toilinit.ps1 +28 -0
  111. package/examples/basic/node_modules/.bin/toilscript +16 -0
  112. package/examples/basic/node_modules/.bin/toilscript.cmd +17 -0
  113. package/examples/basic/node_modules/.bin/toilscript.ps1 +28 -0
  114. package/examples/basic/node_modules/.bin/wasm-as +16 -0
  115. package/examples/basic/node_modules/.bin/wasm-as.cmd +17 -0
  116. package/examples/basic/node_modules/.bin/wasm-as.ps1 +28 -0
  117. package/examples/basic/node_modules/.bin/wasm-ctor-eval +16 -0
  118. package/examples/basic/node_modules/.bin/wasm-ctor-eval.cmd +17 -0
  119. package/examples/basic/node_modules/.bin/wasm-ctor-eval.ps1 +28 -0
  120. package/examples/basic/node_modules/.bin/wasm-dis +16 -0
  121. package/examples/basic/node_modules/.bin/wasm-dis.cmd +17 -0
  122. package/examples/basic/node_modules/.bin/wasm-dis.ps1 +28 -0
  123. package/examples/basic/node_modules/.bin/wasm-merge +16 -0
  124. package/examples/basic/node_modules/.bin/wasm-merge.cmd +17 -0
  125. package/examples/basic/node_modules/.bin/wasm-merge.ps1 +28 -0
  126. package/examples/basic/node_modules/.bin/wasm-metadce +16 -0
  127. package/examples/basic/node_modules/.bin/wasm-metadce.cmd +17 -0
  128. package/examples/basic/node_modules/.bin/wasm-metadce.ps1 +28 -0
  129. package/examples/basic/node_modules/.bin/wasm-opt +16 -0
  130. package/examples/basic/node_modules/.bin/wasm-opt.cmd +17 -0
  131. package/examples/basic/node_modules/.bin/wasm-opt.ps1 +28 -0
  132. package/examples/basic/node_modules/.bin/wasm-reduce +16 -0
  133. package/examples/basic/node_modules/.bin/wasm-reduce.cmd +17 -0
  134. package/examples/basic/node_modules/.bin/wasm-reduce.ps1 +28 -0
  135. package/examples/basic/node_modules/.bin/wasm-shell +16 -0
  136. package/examples/basic/node_modules/.bin/wasm-shell.cmd +17 -0
  137. package/examples/basic/node_modules/.bin/wasm-shell.ps1 +28 -0
  138. package/examples/basic/node_modules/.bin/wasm2js +16 -0
  139. package/examples/basic/node_modules/.bin/wasm2js.cmd +17 -0
  140. package/examples/basic/node_modules/.bin/wasm2js.ps1 +28 -0
  141. package/examples/basic/node_modules/.package-lock.json +49 -1
  142. package/examples/basic/node_modules/.vite/deps/_metadata.json +9 -9
  143. package/examples/basic/node_modules/binaryen/LICENSE +201 -0
  144. package/examples/basic/node_modules/binaryen/README.md +1362 -0
  145. package/examples/basic/node_modules/binaryen/bin/package.json +3 -0
  146. package/examples/basic/node_modules/binaryen/bin/wasm-as +0 -0
  147. package/examples/basic/node_modules/binaryen/bin/wasm-ctor-eval +0 -0
  148. package/examples/basic/node_modules/binaryen/bin/wasm-dis +0 -0
  149. package/examples/basic/node_modules/binaryen/bin/wasm-merge +0 -0
  150. package/examples/basic/node_modules/binaryen/bin/wasm-metadce +0 -0
  151. package/examples/basic/node_modules/binaryen/bin/wasm-opt +0 -0
  152. package/examples/basic/node_modules/binaryen/bin/wasm-reduce +0 -0
  153. package/examples/basic/node_modules/binaryen/bin/wasm-shell +0 -0
  154. package/examples/basic/node_modules/binaryen/bin/wasm2js +0 -0
  155. package/examples/basic/node_modules/binaryen/index.d.ts +2371 -0
  156. package/examples/basic/node_modules/binaryen/index.js +30552 -0
  157. package/examples/basic/node_modules/binaryen/package.json +50 -0
  158. package/examples/basic/node_modules/long/LICENSE +202 -0
  159. package/examples/basic/node_modules/long/README.md +286 -0
  160. package/examples/basic/node_modules/long/index.d.ts +2 -0
  161. package/examples/basic/node_modules/long/index.js +1581 -0
  162. package/examples/basic/node_modules/long/package.json +58 -0
  163. package/examples/basic/node_modules/long/types.d.ts +474 -0
  164. package/examples/basic/node_modules/long/umd/index.d.ts +3 -0
  165. package/examples/basic/node_modules/long/umd/index.js +1622 -0
  166. package/examples/basic/node_modules/long/umd/package.json +3 -0
  167. package/examples/basic/node_modules/long/umd/types.d.ts +474 -0
  168. package/examples/basic/node_modules/toilscript/LICENSE +201 -0
  169. package/examples/basic/node_modules/toilscript/NOTICE +94 -0
  170. package/examples/basic/node_modules/toilscript/README.md +66 -0
  171. package/examples/basic/node_modules/toilscript/bin/toilinit.js +468 -0
  172. package/examples/basic/node_modules/toilscript/bin/toilscript.js +35 -0
  173. package/examples/basic/node_modules/toilscript/dist/cli.d.ts +4 -0
  174. package/examples/basic/node_modules/toilscript/dist/cli.generated.d.ts +10027 -0
  175. package/examples/basic/node_modules/toilscript/dist/cli.js +24474 -0
  176. package/examples/basic/node_modules/toilscript/dist/cli.js.map +7 -0
  177. package/examples/basic/node_modules/toilscript/dist/importmap.json +9 -0
  178. package/examples/basic/node_modules/toilscript/dist/toilscript.d.ts +4 -0
  179. package/examples/basic/node_modules/toilscript/dist/toilscript.generated.d.ts +11242 -0
  180. package/examples/basic/node_modules/toilscript/dist/toilscript.js +337 -0
  181. package/examples/basic/node_modules/toilscript/dist/toilscript.js.map +7 -0
  182. package/examples/basic/node_modules/toilscript/dist/transform.cjs +1 -0
  183. package/examples/basic/node_modules/toilscript/dist/transform.d.ts +1 -0
  184. package/examples/basic/node_modules/toilscript/dist/transform.js +1 -0
  185. package/examples/basic/node_modules/toilscript/dist/web.js +22 -0
  186. package/examples/basic/node_modules/toilscript/lib/binaryen.d.ts +2 -0
  187. package/examples/basic/node_modules/toilscript/lib/binaryen.js +2 -0
  188. package/examples/basic/node_modules/toilscript/package.json +115 -0
  189. package/examples/basic/node_modules/toilscript/std/README.md +6 -0
  190. package/examples/basic/node_modules/toilscript/std/assembly/array.ts +550 -0
  191. package/examples/basic/node_modules/toilscript/std/assembly/arraybuffer.ts +77 -0
  192. package/examples/basic/node_modules/toilscript/std/assembly/atomics.ts +127 -0
  193. package/examples/basic/node_modules/toilscript/std/assembly/bindings/asyncify.ts +16 -0
  194. package/examples/basic/node_modules/toilscript/std/assembly/bindings/dom.ts +291 -0
  195. package/examples/basic/node_modules/toilscript/std/assembly/bindings/node.ts +6 -0
  196. package/examples/basic/node_modules/toilscript/std/assembly/bitflags.ts +53 -0
  197. package/examples/basic/node_modules/toilscript/std/assembly/builtins.ts +2650 -0
  198. package/examples/basic/node_modules/toilscript/std/assembly/byteslice.ts +177 -0
  199. package/examples/basic/node_modules/toilscript/std/assembly/compat.ts +2 -0
  200. package/examples/basic/node_modules/toilscript/std/assembly/console.ts +42 -0
  201. package/examples/basic/node_modules/toilscript/std/assembly/crypto.ts +9 -0
  202. package/examples/basic/node_modules/toilscript/std/assembly/dataview.ts +181 -0
  203. package/examples/basic/node_modules/toilscript/std/assembly/date.ts +375 -0
  204. package/examples/basic/node_modules/toilscript/std/assembly/diagnostics.ts +11 -0
  205. package/examples/basic/node_modules/toilscript/std/assembly/encoding.ts +151 -0
  206. package/examples/basic/node_modules/toilscript/std/assembly/endian.ts +45 -0
  207. package/examples/basic/node_modules/toilscript/std/assembly/error.ts +44 -0
  208. package/examples/basic/node_modules/toilscript/std/assembly/fixedarray.ts +173 -0
  209. package/examples/basic/node_modules/toilscript/std/assembly/fixedmap.ts +326 -0
  210. package/examples/basic/node_modules/toilscript/std/assembly/fixedset.ts +275 -0
  211. package/examples/basic/node_modules/toilscript/std/assembly/function.ts +42 -0
  212. package/examples/basic/node_modules/toilscript/std/assembly/index.d.ts +2892 -0
  213. package/examples/basic/node_modules/toilscript/std/assembly/iterator.ts +35 -0
  214. package/examples/basic/node_modules/toilscript/std/assembly/map.ts +269 -0
  215. package/examples/basic/node_modules/toilscript/std/assembly/math.ts +3289 -0
  216. package/examples/basic/node_modules/toilscript/std/assembly/memory.ts +123 -0
  217. package/examples/basic/node_modules/toilscript/std/assembly/number.ts +388 -0
  218. package/examples/basic/node_modules/toilscript/std/assembly/object.ts +36 -0
  219. package/examples/basic/node_modules/toilscript/std/assembly/performance.ts +9 -0
  220. package/examples/basic/node_modules/toilscript/std/assembly/pointer.ts +80 -0
  221. package/examples/basic/node_modules/toilscript/std/assembly/polyfills.ts +27 -0
  222. package/examples/basic/node_modules/toilscript/std/assembly/process.ts +50 -0
  223. package/examples/basic/node_modules/toilscript/std/assembly/reference.ts +48 -0
  224. package/examples/basic/node_modules/toilscript/std/assembly/regexp.ts +12 -0
  225. package/examples/basic/node_modules/toilscript/std/assembly/rt/README.md +83 -0
  226. package/examples/basic/node_modules/toilscript/std/assembly/rt/common.ts +81 -0
  227. package/examples/basic/node_modules/toilscript/std/assembly/rt/index-incremental.ts +2 -0
  228. package/examples/basic/node_modules/toilscript/std/assembly/rt/index-memory.ts +1 -0
  229. package/examples/basic/node_modules/toilscript/std/assembly/rt/index-minimal.ts +2 -0
  230. package/examples/basic/node_modules/toilscript/std/assembly/rt/index-stub.ts +1 -0
  231. package/examples/basic/node_modules/toilscript/std/assembly/rt/index.d.ts +37 -0
  232. package/examples/basic/node_modules/toilscript/std/assembly/rt/itcms.ts +419 -0
  233. package/examples/basic/node_modules/toilscript/std/assembly/rt/memory-runtime.ts +94 -0
  234. package/examples/basic/node_modules/toilscript/std/assembly/rt/rtrace.ts +15 -0
  235. package/examples/basic/node_modules/toilscript/std/assembly/rt/stub.ts +133 -0
  236. package/examples/basic/node_modules/toilscript/std/assembly/rt/tcms.ts +254 -0
  237. package/examples/basic/node_modules/toilscript/std/assembly/rt/tlsf.ts +592 -0
  238. package/examples/basic/node_modules/toilscript/std/assembly/rt.ts +90 -0
  239. package/examples/basic/node_modules/toilscript/std/assembly/set.ts +225 -0
  240. package/examples/basic/node_modules/toilscript/std/assembly/shared/feature.ts +68 -0
  241. package/examples/basic/node_modules/toilscript/std/assembly/shared/runtime.ts +13 -0
  242. package/examples/basic/node_modules/toilscript/std/assembly/shared/target.ts +11 -0
  243. package/examples/basic/node_modules/toilscript/std/assembly/shared/tsconfig.json +11 -0
  244. package/examples/basic/node_modules/toilscript/std/assembly/shared/typeinfo.ts +72 -0
  245. package/examples/basic/node_modules/toilscript/std/assembly/staticarray.ts +423 -0
  246. package/examples/basic/node_modules/toilscript/std/assembly/string.ts +850 -0
  247. package/examples/basic/node_modules/toilscript/std/assembly/symbol.ts +114 -0
  248. package/examples/basic/node_modules/toilscript/std/assembly/table.ts +16 -0
  249. package/examples/basic/node_modules/toilscript/std/assembly/toilscript.ts +16 -0
  250. package/examples/basic/node_modules/toilscript/std/assembly/tsconfig.json +6 -0
  251. package/examples/basic/node_modules/toilscript/std/assembly/typedarray.ts +1954 -0
  252. package/examples/basic/node_modules/toilscript/std/assembly/uri.ts +17 -0
  253. package/examples/basic/node_modules/toilscript/std/assembly/util/bytes.ts +107 -0
  254. package/examples/basic/node_modules/toilscript/std/assembly/util/casemap.ts +497 -0
  255. package/examples/basic/node_modules/toilscript/std/assembly/util/error.ts +58 -0
  256. package/examples/basic/node_modules/toilscript/std/assembly/util/hash.ts +117 -0
  257. package/examples/basic/node_modules/toilscript/std/assembly/util/math.ts +1922 -0
  258. package/examples/basic/node_modules/toilscript/std/assembly/util/memory.ts +290 -0
  259. package/examples/basic/node_modules/toilscript/std/assembly/util/number.ts +873 -0
  260. package/examples/basic/node_modules/toilscript/std/assembly/util/sort.ts +313 -0
  261. package/examples/basic/node_modules/toilscript/std/assembly/util/string.ts +1202 -0
  262. package/examples/basic/node_modules/toilscript/std/assembly/util/uri.ts +275 -0
  263. package/examples/basic/node_modules/toilscript/std/assembly/vector.ts +4 -0
  264. package/examples/basic/node_modules/toilscript/std/assembly.json +16 -0
  265. package/examples/basic/node_modules/toilscript/std/portable/index.d.ts +461 -0
  266. package/examples/basic/node_modules/toilscript/std/portable/index.js +416 -0
  267. package/examples/basic/node_modules/toilscript/std/portable.json +11 -0
  268. package/examples/basic/node_modules/toilscript/std/types/assembly/index.d.ts +1 -0
  269. package/examples/basic/node_modules/toilscript/std/types/assembly/package.json +3 -0
  270. package/examples/basic/node_modules/toilscript/std/types/portable/index.d.ts +1 -0
  271. package/examples/basic/node_modules/toilscript/std/types/portable/package.json +3 -0
  272. package/examples/basic/node_modules/toilscript/tsconfig-base.json +13 -0
  273. package/examples/basic/node_modules/toilscript/util/README.md +23 -0
  274. package/examples/basic/node_modules/toilscript/util/browser/fs.js +1 -0
  275. package/examples/basic/node_modules/toilscript/util/browser/module.js +5 -0
  276. package/examples/basic/node_modules/toilscript/util/browser/path.js +520 -0
  277. package/examples/basic/node_modules/toilscript/util/browser/process.js +59 -0
  278. package/examples/basic/node_modules/toilscript/util/browser/url.js +23 -0
  279. package/examples/basic/node_modules/toilscript/util/cpu.d.ts +9 -0
  280. package/examples/basic/node_modules/toilscript/util/cpu.js +42 -0
  281. package/examples/basic/node_modules/toilscript/util/find.d.ts +6 -0
  282. package/examples/basic/node_modules/toilscript/util/find.js +20 -0
  283. package/examples/basic/node_modules/toilscript/util/node.d.ts +21 -0
  284. package/examples/basic/node_modules/toilscript/util/node.js +34 -0
  285. package/examples/basic/node_modules/toilscript/util/options.d.ts +70 -0
  286. package/examples/basic/node_modules/toilscript/util/options.js +262 -0
  287. package/examples/basic/node_modules/toilscript/util/terminal.d.ts +52 -0
  288. package/examples/basic/node_modules/toilscript/util/terminal.js +35 -0
  289. package/examples/basic/node_modules/toilscript/util/text.d.ts +26 -0
  290. package/examples/basic/node_modules/toilscript/util/text.js +114 -0
  291. package/examples/basic/node_modules/toilscript/util/tsconfig.json +9 -0
  292. package/examples/basic/node_modules/toilscript/util/web.d.ts +11 -0
  293. package/examples/basic/node_modules/toilscript/util/web.js +33 -0
  294. package/examples/basic/package-lock.json +50 -1
  295. package/examples/basic/package.json +5 -2
  296. package/examples/basic/server/index.ts +3 -0
  297. package/examples/basic/server/main.ts +6 -0
  298. package/examples/basic/server/tsconfig.json +7 -0
  299. package/examples/basic/toil-env.d.ts +20 -1
  300. package/examples/basic/toil.config.ts +2 -5
  301. package/examples/basic/toilconfig.json +30 -0
  302. package/package.json +1 -1
  303. package/presets/eslint.js +2 -7
  304. package/presets/no-uint8array-tostring.js +4 -5
  305. package/presets/prettier.json +8 -1
  306. package/src/backend/index.ts +11 -18
  307. package/src/cli/configure.ts +272 -0
  308. package/src/cli/create.ts +227 -69
  309. package/src/cli/features.ts +128 -0
  310. package/src/cli/index.ts +44 -3
  311. package/src/cli/proc.ts +20 -0
  312. package/src/cli/ui.ts +4 -6
  313. package/src/cli/validate.ts +31 -0
  314. package/src/client/Link.tsx +99 -0
  315. package/src/client/NavLink.tsx +86 -0
  316. package/src/client/Router.tsx +95 -0
  317. package/src/client/error-boundary.tsx +43 -0
  318. package/src/client/head.ts +140 -0
  319. package/src/client/hooks.ts +115 -0
  320. package/src/client/index.ts +35 -5
  321. package/src/client/lazy.ts +93 -0
  322. package/src/client/match.ts +11 -3
  323. package/src/client/mount.tsx +28 -0
  324. package/src/client/navigation.ts +142 -0
  325. package/src/client/params-context.ts +10 -0
  326. package/src/client/prefetch.ts +130 -0
  327. package/src/client/scroll.ts +53 -0
  328. package/src/client/types.ts +36 -0
  329. package/src/compiler/config.ts +15 -8
  330. package/src/compiler/docs.ts +87 -0
  331. package/src/compiler/generate.ts +164 -23
  332. package/src/compiler/index.ts +6 -4
  333. package/src/compiler/plugin.ts +3 -1
  334. package/src/compiler/routes.ts +13 -7
  335. package/src/compiler/vite.ts +28 -5
  336. package/src/io/BinaryReader.ts +1 -5
  337. package/src/io/BinaryWriter.ts +3 -3
  338. package/src/server/index.ts +3 -4
  339. package/src/server/tsconfig.json +4 -0
  340. package/test/configure.test.ts +90 -0
  341. package/test/features.test.ts +111 -0
  342. package/test/head.test.ts +35 -0
  343. package/test/io.test.ts +8 -0
  344. package/test/navlink.test.ts +28 -0
  345. package/test/routes.test.ts +15 -0
  346. package/test/validate.test.ts +42 -0
  347. package/vitest.config.ts +1 -1
  348. package/examples/basic/dist/assets/404-D1bS2aH_.js +0 -1
  349. package/examples/basic/dist/assets/_...slug_-wR3shlWn.js +0 -1
  350. package/examples/basic/dist/assets/_id_-EWYvHfi2.js +0 -1
  351. package/examples/basic/dist/assets/about-Ddvj1tjF.js +0 -1
  352. package/examples/basic/dist/assets/index-CdG0me90.js +0 -1
  353. package/examples/basic/dist/assets/io-CODNJU57.js +0 -1
  354. package/examples/basic/dist/assets/layout-C15ZTPYI.js +0 -1
  355. package/examples/basic/dist/assets/react-JbAfoxYe.js +0 -9
  356. package/examples/basic/dist/assets/rolldown-runtime-1VNLd2iN.js +0 -1
  357. package/examples/basic/dist/assets/routes-GoydenoY.js +0 -1
  358. package/examples/basic/dist/index.html +0 -12
  359. package/src/client/runtime.tsx +0 -190
@@ -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,9 @@
1
+ /**
2
+ * @fileoverview CPU utility definitions.
3
+ * @license Apache-2.0
4
+ */
5
+
6
+ /** Number of threads. */
7
+ export const threadCount: number;
8
+ /** Number of cores. */
9
+ export const coreCount: number;
@@ -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,6 @@
1
+ /**
2
+ * @fileoverview File finding utility definitions.
3
+ * @license Apache-2.0
4
+ */
5
+
6
+ export function findFiles(dirname: string, filter?: ((name: string) => boolean) | RegExp): string[];
@@ -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
+ };