@noodleseed/one 0.5.0 → 0.6.0

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 (279) hide show
  1. package/dist/cli.js +5 -0
  2. package/dist/cli.js.map +1 -1
  3. package/dist/commands/shared.d.ts +1 -1
  4. package/dist/commands/shared.d.ts.map +1 -1
  5. package/dist/commands/shared.js +2 -2
  6. package/dist/commands/shared.js.map +1 -1
  7. package/dist/react-widget-build.js +20 -1
  8. package/dist/react-widget-build.js.map +1 -1
  9. package/node_modules/@noodle-borg/agent-kit/dist/curated/command-groups.d.ts.map +1 -1
  10. package/node_modules/@noodle-borg/agent-kit/dist/curated/command-groups.js +1 -0
  11. package/node_modules/@noodle-borg/agent-kit/dist/curated/command-groups.js.map +1 -1
  12. package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.d.ts.map +1 -1
  13. package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.js +1 -0
  14. package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.js.map +1 -1
  15. package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
  16. package/package.json +2 -20
  17. package/node_modules/@oxc-project/types/LICENSE +0 -22
  18. package/node_modules/@oxc-project/types/README.md +0 -3
  19. package/node_modules/@oxc-project/types/package.json +0 -26
  20. package/node_modules/@oxc-project/types/types.d.ts +0 -1912
  21. package/node_modules/@rolldown/binding-linux-x64-gnu/README.md +0 -3
  22. package/node_modules/@rolldown/binding-linux-x64-gnu/package.json +0 -40
  23. package/node_modules/@rolldown/binding-linux-x64-gnu/rolldown-binding.linux-x64-gnu.node +0 -0
  24. package/node_modules/@rolldown/pluginutils/LICENSE +0 -21
  25. package/node_modules/@rolldown/pluginutils/README.md +0 -145
  26. package/node_modules/@rolldown/pluginutils/dist/filter/index.d.mts +0 -194
  27. package/node_modules/@rolldown/pluginutils/dist/filter/index.mjs +0 -2
  28. package/node_modules/@rolldown/pluginutils/dist/filter-B_mD-HGz.mjs +0 -323
  29. package/node_modules/@rolldown/pluginutils/dist/index.d.mts +0 -2
  30. package/node_modules/@rolldown/pluginutils/dist/index.mjs +0 -2
  31. package/node_modules/@rolldown/pluginutils/package.json +0 -40
  32. package/node_modules/@vitejs/plugin-react/LICENSE +0 -21
  33. package/node_modules/@vitejs/plugin-react/README.md +0 -169
  34. package/node_modules/@vitejs/plugin-react/dist/index.d.ts +0 -48
  35. package/node_modules/@vitejs/plugin-react/dist/index.js +0 -200
  36. package/node_modules/@vitejs/plugin-react/dist/refresh-runtime.js +0 -663
  37. package/node_modules/@vitejs/plugin-react/package.json +0 -87
  38. package/node_modules/@vitejs/plugin-react/types/optionalTypes.d.ts +0 -12
  39. package/node_modules/@vitejs/plugin-react/types/preamble.d.ts +0 -1
  40. package/node_modules/detect-libc/LICENSE +0 -201
  41. package/node_modules/detect-libc/README.md +0 -163
  42. package/node_modules/detect-libc/index.d.ts +0 -14
  43. package/node_modules/detect-libc/lib/detect-libc.js +0 -313
  44. package/node_modules/detect-libc/lib/elf.js +0 -39
  45. package/node_modules/detect-libc/lib/filesystem.js +0 -51
  46. package/node_modules/detect-libc/lib/process.js +0 -24
  47. package/node_modules/detect-libc/package.json +0 -44
  48. package/node_modules/fdir/LICENSE +0 -7
  49. package/node_modules/fdir/README.md +0 -91
  50. package/node_modules/fdir/dist/index.cjs +0 -588
  51. package/node_modules/fdir/dist/index.d.cts +0 -155
  52. package/node_modules/fdir/dist/index.d.mts +0 -155
  53. package/node_modules/fdir/dist/index.mjs +0 -570
  54. package/node_modules/fdir/package.json +0 -103
  55. package/node_modules/lightningcss/LICENSE +0 -373
  56. package/node_modules/lightningcss/README.md +0 -105
  57. package/node_modules/lightningcss/node/ast.d.ts +0 -9892
  58. package/node_modules/lightningcss/node/ast.js.flow +0 -10539
  59. package/node_modules/lightningcss/node/browserslistToTargets.js +0 -48
  60. package/node_modules/lightningcss/node/composeVisitors.js +0 -450
  61. package/node_modules/lightningcss/node/flags.js +0 -28
  62. package/node_modules/lightningcss/node/index.d.ts +0 -494
  63. package/node_modules/lightningcss/node/index.js +0 -59
  64. package/node_modules/lightningcss/node/index.js.flow +0 -843
  65. package/node_modules/lightningcss/node/index.mjs +0 -4
  66. package/node_modules/lightningcss/node/targets.d.ts +0 -40
  67. package/node_modules/lightningcss/node/targets.js.flow +0 -39
  68. package/node_modules/lightningcss/package.json +0 -110
  69. package/node_modules/lightningcss-linux-x64-gnu/LICENSE +0 -373
  70. package/node_modules/lightningcss-linux-x64-gnu/README.md +0 -1
  71. package/node_modules/lightningcss-linux-x64-gnu/lightningcss.linux-x64-gnu.node +0 -0
  72. package/node_modules/lightningcss-linux-x64-gnu/package.json +0 -37
  73. package/node_modules/nanoid/.claude/settings.local.json +0 -14
  74. package/node_modules/nanoid/LICENSE +0 -20
  75. package/node_modules/nanoid/README.md +0 -39
  76. package/node_modules/nanoid/async/index.browser.cjs +0 -69
  77. package/node_modules/nanoid/async/index.browser.js +0 -34
  78. package/node_modules/nanoid/async/index.cjs +0 -71
  79. package/node_modules/nanoid/async/index.d.ts +0 -56
  80. package/node_modules/nanoid/async/index.js +0 -35
  81. package/node_modules/nanoid/async/index.native.js +0 -26
  82. package/node_modules/nanoid/async/package.json +0 -12
  83. package/node_modules/nanoid/bin/nanoid.cjs +0 -55
  84. package/node_modules/nanoid/index.browser.cjs +0 -72
  85. package/node_modules/nanoid/index.browser.js +0 -34
  86. package/node_modules/nanoid/index.cjs +0 -86
  87. package/node_modules/nanoid/index.d.cts +0 -91
  88. package/node_modules/nanoid/index.d.ts +0 -91
  89. package/node_modules/nanoid/index.js +0 -46
  90. package/node_modules/nanoid/nanoid.js +0 -1
  91. package/node_modules/nanoid/non-secure/index.cjs +0 -34
  92. package/node_modules/nanoid/non-secure/index.d.ts +0 -33
  93. package/node_modules/nanoid/non-secure/index.js +0 -21
  94. package/node_modules/nanoid/non-secure/package.json +0 -6
  95. package/node_modules/nanoid/package.json +0 -89
  96. package/node_modules/nanoid/url-alphabet/index.cjs +0 -7
  97. package/node_modules/nanoid/url-alphabet/index.js +0 -3
  98. package/node_modules/nanoid/url-alphabet/package.json +0 -6
  99. package/node_modules/picocolors/LICENSE +0 -15
  100. package/node_modules/picocolors/README.md +0 -21
  101. package/node_modules/picocolors/package.json +0 -25
  102. package/node_modules/picocolors/picocolors.browser.js +0 -4
  103. package/node_modules/picocolors/picocolors.d.ts +0 -5
  104. package/node_modules/picocolors/picocolors.js +0 -75
  105. package/node_modules/picocolors/types.d.ts +0 -51
  106. package/node_modules/picomatch/LICENSE +0 -21
  107. package/node_modules/picomatch/README.md +0 -749
  108. package/node_modules/picomatch/index.js +0 -17
  109. package/node_modules/picomatch/lib/constants.js +0 -184
  110. package/node_modules/picomatch/lib/parse.js +0 -1386
  111. package/node_modules/picomatch/lib/picomatch.js +0 -349
  112. package/node_modules/picomatch/lib/scan.js +0 -391
  113. package/node_modules/picomatch/lib/utils.js +0 -72
  114. package/node_modules/picomatch/package.json +0 -82
  115. package/node_modules/picomatch/posix.js +0 -3
  116. package/node_modules/postcss/LICENSE +0 -20
  117. package/node_modules/postcss/README.md +0 -28
  118. package/node_modules/postcss/lib/at-rule.d.ts +0 -139
  119. package/node_modules/postcss/lib/at-rule.js +0 -25
  120. package/node_modules/postcss/lib/comment.d.ts +0 -67
  121. package/node_modules/postcss/lib/comment.js +0 -13
  122. package/node_modules/postcss/lib/container.d.ts +0 -478
  123. package/node_modules/postcss/lib/container.js +0 -447
  124. package/node_modules/postcss/lib/css-syntax-error.d.ts +0 -247
  125. package/node_modules/postcss/lib/css-syntax-error.js +0 -133
  126. package/node_modules/postcss/lib/declaration.d.ts +0 -150
  127. package/node_modules/postcss/lib/declaration.js +0 -24
  128. package/node_modules/postcss/lib/document.d.ts +0 -68
  129. package/node_modules/postcss/lib/document.js +0 -33
  130. package/node_modules/postcss/lib/fromJSON.d.ts +0 -9
  131. package/node_modules/postcss/lib/fromJSON.js +0 -54
  132. package/node_modules/postcss/lib/input.d.ts +0 -226
  133. package/node_modules/postcss/lib/input.js +0 -273
  134. package/node_modules/postcss/lib/lazy-result.d.ts +0 -189
  135. package/node_modules/postcss/lib/lazy-result.js +0 -563
  136. package/node_modules/postcss/lib/list.d.ts +0 -60
  137. package/node_modules/postcss/lib/list.js +0 -58
  138. package/node_modules/postcss/lib/map-generator.js +0 -376
  139. package/node_modules/postcss/lib/no-work-result.d.ts +0 -45
  140. package/node_modules/postcss/lib/no-work-result.js +0 -137
  141. package/node_modules/postcss/lib/node.d.ts +0 -555
  142. package/node_modules/postcss/lib/node.js +0 -449
  143. package/node_modules/postcss/lib/parse.d.ts +0 -9
  144. package/node_modules/postcss/lib/parse.js +0 -42
  145. package/node_modules/postcss/lib/parser.js +0 -618
  146. package/node_modules/postcss/lib/postcss.d.mts +0 -66
  147. package/node_modules/postcss/lib/postcss.d.ts +0 -461
  148. package/node_modules/postcss/lib/postcss.js +0 -101
  149. package/node_modules/postcss/lib/postcss.mjs +0 -30
  150. package/node_modules/postcss/lib/previous-map.d.ts +0 -80
  151. package/node_modules/postcss/lib/previous-map.js +0 -161
  152. package/node_modules/postcss/lib/processor.d.ts +0 -114
  153. package/node_modules/postcss/lib/processor.js +0 -67
  154. package/node_modules/postcss/lib/result.d.ts +0 -204
  155. package/node_modules/postcss/lib/result.js +0 -42
  156. package/node_modules/postcss/lib/root.d.ts +0 -86
  157. package/node_modules/postcss/lib/root.js +0 -61
  158. package/node_modules/postcss/lib/rule.d.ts +0 -126
  159. package/node_modules/postcss/lib/rule.js +0 -27
  160. package/node_modules/postcss/lib/stringifier.d.ts +0 -45
  161. package/node_modules/postcss/lib/stringifier.js +0 -374
  162. package/node_modules/postcss/lib/stringify.d.ts +0 -9
  163. package/node_modules/postcss/lib/stringify.js +0 -11
  164. package/node_modules/postcss/lib/symbols.js +0 -5
  165. package/node_modules/postcss/lib/terminal-highlight.js +0 -70
  166. package/node_modules/postcss/lib/tokenize.js +0 -270
  167. package/node_modules/postcss/lib/warn-once.js +0 -13
  168. package/node_modules/postcss/lib/warning.d.ts +0 -146
  169. package/node_modules/postcss/lib/warning.js +0 -37
  170. package/node_modules/postcss/package.json +0 -88
  171. package/node_modules/rolldown/LICENSE +0 -25
  172. package/node_modules/rolldown/README.md +0 -11
  173. package/node_modules/rolldown/bin/cli.mjs +0 -2
  174. package/node_modules/rolldown/dist/cli.d.mts +0 -1
  175. package/node_modules/rolldown/dist/cli.mjs +0 -1202
  176. package/node_modules/rolldown/dist/config.d.mts +0 -14
  177. package/node_modules/rolldown/dist/config.mjs +0 -4
  178. package/node_modules/rolldown/dist/experimental-index.d.mts +0 -280
  179. package/node_modules/rolldown/dist/experimental-index.mjs +0 -330
  180. package/node_modules/rolldown/dist/experimental-runtime-types.d.ts +0 -107
  181. package/node_modules/rolldown/dist/filter-index.d.mts +0 -195
  182. package/node_modules/rolldown/dist/filter-index.mjs +0 -380
  183. package/node_modules/rolldown/dist/get-log-filter.d.mts +0 -3
  184. package/node_modules/rolldown/dist/get-log-filter.mjs +0 -68
  185. package/node_modules/rolldown/dist/index.d.mts +0 -4
  186. package/node_modules/rolldown/dist/index.mjs +0 -50
  187. package/node_modules/rolldown/dist/parallel-plugin-worker.d.mts +0 -1
  188. package/node_modules/rolldown/dist/parallel-plugin-worker.mjs +0 -28
  189. package/node_modules/rolldown/dist/parallel-plugin.d.mts +0 -13
  190. package/node_modules/rolldown/dist/parallel-plugin.mjs +0 -6
  191. package/node_modules/rolldown/dist/parse-ast-index.d.mts +0 -32
  192. package/node_modules/rolldown/dist/parse-ast-index.mjs +0 -60
  193. package/node_modules/rolldown/dist/plugins-index.d.mts +0 -33
  194. package/node_modules/rolldown/dist/plugins-index.mjs +0 -40
  195. package/node_modules/rolldown/dist/shared/binding-B1q9aYT-.d.mts +0 -1947
  196. package/node_modules/rolldown/dist/shared/binding-Dh6LYCIB.mjs +0 -589
  197. package/node_modules/rolldown/dist/shared/bindingify-input-options-CzVhGygm.mjs +0 -2240
  198. package/node_modules/rolldown/dist/shared/constructors-688OwP2q.mjs +0 -65
  199. package/node_modules/rolldown/dist/shared/constructors-awZ1VNvg.d.mts +0 -36
  200. package/node_modules/rolldown/dist/shared/define-config-Demdg3_4.mjs +0 -6
  201. package/node_modules/rolldown/dist/shared/define-config-sxBscJ3M.d.mts +0 -3901
  202. package/node_modules/rolldown/dist/shared/error-B68YLzl3.mjs +0 -85
  203. package/node_modules/rolldown/dist/shared/get-log-filter-BpNVNJ5-.d.mts +0 -35
  204. package/node_modules/rolldown/dist/shared/load-config-BvPPEM7l.mjs +0 -120
  205. package/node_modules/rolldown/dist/shared/logging-BSNejiLS.d.mts +0 -50
  206. package/node_modules/rolldown/dist/shared/logs-aMKUxRpj.mjs +0 -180
  207. package/node_modules/rolldown/dist/shared/misc-CoQm4NHO.mjs +0 -21
  208. package/node_modules/rolldown/dist/shared/normalize-string-or-regex-BpXHYeN4.mjs +0 -68
  209. package/node_modules/rolldown/dist/shared/parse-CTgsjpo8.mjs +0 -74
  210. package/node_modules/rolldown/dist/shared/prompt-B1Yc1NPt.mjs +0 -847
  211. package/node_modules/rolldown/dist/shared/resolve-tsconfig-BkhP9bkX.mjs +0 -124
  212. package/node_modules/rolldown/dist/shared/rolldown-Brph2NSU.mjs +0 -40
  213. package/node_modules/rolldown/dist/shared/rolldown-build-DR0wzp0V.mjs +0 -3264
  214. package/node_modules/rolldown/dist/shared/transform-CEmFsvJW.d.mts +0 -149
  215. package/node_modules/rolldown/dist/shared/watch-FrHSqg24.mjs +0 -374
  216. package/node_modules/rolldown/dist/utils-index.d.mts +0 -376
  217. package/node_modules/rolldown/dist/utils-index.mjs +0 -2414
  218. package/node_modules/rolldown/package.json +0 -153
  219. package/node_modules/source-map-js/LICENSE +0 -28
  220. package/node_modules/source-map-js/README.md +0 -765
  221. package/node_modules/source-map-js/lib/array-set.js +0 -121
  222. package/node_modules/source-map-js/lib/base64-vlq.js +0 -140
  223. package/node_modules/source-map-js/lib/base64.js +0 -67
  224. package/node_modules/source-map-js/lib/binary-search.js +0 -111
  225. package/node_modules/source-map-js/lib/mapping-list.js +0 -79
  226. package/node_modules/source-map-js/lib/quick-sort.js +0 -132
  227. package/node_modules/source-map-js/lib/source-map-consumer.d.ts +0 -1
  228. package/node_modules/source-map-js/lib/source-map-consumer.js +0 -1188
  229. package/node_modules/source-map-js/lib/source-map-generator.d.ts +0 -1
  230. package/node_modules/source-map-js/lib/source-map-generator.js +0 -444
  231. package/node_modules/source-map-js/lib/source-node.d.ts +0 -1
  232. package/node_modules/source-map-js/lib/source-node.js +0 -413
  233. package/node_modules/source-map-js/lib/util.js +0 -594
  234. package/node_modules/source-map-js/package.json +0 -71
  235. package/node_modules/source-map-js/source-map.d.ts +0 -104
  236. package/node_modules/source-map-js/source-map.js +0 -8
  237. package/node_modules/tinyglobby/LICENSE +0 -21
  238. package/node_modules/tinyglobby/README.md +0 -25
  239. package/node_modules/tinyglobby/dist/index.cjs +0 -335
  240. package/node_modules/tinyglobby/dist/index.d.cts +0 -148
  241. package/node_modules/tinyglobby/dist/index.d.mts +0 -148
  242. package/node_modules/tinyglobby/dist/index.mjs +0 -307
  243. package/node_modules/tinyglobby/package.json +0 -70
  244. package/node_modules/vite/LICENSE.md +0 -2287
  245. package/node_modules/vite/README.md +0 -20
  246. package/node_modules/vite/bin/openChrome.js +0 -68
  247. package/node_modules/vite/bin/vite.js +0 -79
  248. package/node_modules/vite/client.d.ts +0 -285
  249. package/node_modules/vite/dist/client/client.mjs +0 -1269
  250. package/node_modules/vite/dist/client/env.mjs +0 -18
  251. package/node_modules/vite/dist/node/chunks/build.js +0 -5371
  252. package/node_modules/vite/dist/node/chunks/dist.js +0 -6784
  253. package/node_modules/vite/dist/node/chunks/lib.js +0 -371
  254. package/node_modules/vite/dist/node/chunks/logger.js +0 -364
  255. package/node_modules/vite/dist/node/chunks/moduleRunnerTransport.d.ts +0 -96
  256. package/node_modules/vite/dist/node/chunks/node.js +0 -35770
  257. package/node_modules/vite/dist/node/chunks/postcss-import.js +0 -467
  258. package/node_modules/vite/dist/node/cli.js +0 -836
  259. package/node_modules/vite/dist/node/index.d.ts +0 -4010
  260. package/node_modules/vite/dist/node/index.js +0 -3
  261. package/node_modules/vite/dist/node/internal.d.ts +0 -2
  262. package/node_modules/vite/dist/node/internal.js +0 -2
  263. package/node_modules/vite/dist/node/module-runner.d.ts +0 -314
  264. package/node_modules/vite/dist/node/module-runner.js +0 -1274
  265. package/node_modules/vite/misc/false.js +0 -1
  266. package/node_modules/vite/misc/true.js +0 -1
  267. package/node_modules/vite/package.json +0 -194
  268. package/node_modules/vite/types/customEvent.d.ts +0 -79
  269. package/node_modules/vite/types/hmrPayload.d.ts +0 -80
  270. package/node_modules/vite/types/hot.d.ts +0 -39
  271. package/node_modules/vite/types/import-meta.d.ts +0 -5
  272. package/node_modules/vite/types/importGlob.d.ts +0 -131
  273. package/node_modules/vite/types/importMeta.d.ts +0 -30
  274. package/node_modules/vite/types/internal/cssPreprocessorOptions.d.ts +0 -44
  275. package/node_modules/vite/types/internal/esbuildOptions.d.ts +0 -28
  276. package/node_modules/vite/types/internal/lightningcssOptions.d.ts +0 -18
  277. package/node_modules/vite/types/internal/rollupTypeCompat.d.ts +0 -24
  278. package/node_modules/vite/types/internal/terserOptions.d.ts +0 -11
  279. package/node_modules/vite/types/metadata.d.ts +0 -47
@@ -1,1274 +0,0 @@
1
- let SOURCEMAPPING_URL = "sourceMa";
2
- SOURCEMAPPING_URL += "ppingURL";
3
- //#endregion
4
- //#region src/shared/utils.ts
5
- const isWindows = typeof process < "u" && process.platform === "win32";
6
- /**
7
- * Undo {@link wrapId}'s `/@id/` and null byte replacements.
8
- */
9
- function unwrapId(id) {
10
- return id.startsWith("/@id/") ? id.slice(5).replace("__x00__", "\0") : id;
11
- }
12
- const windowsSlashRE = /\\/g;
13
- function slash(p) {
14
- return p.replace(windowsSlashRE, "/");
15
- }
16
- const postfixRE = /[?#].*$/;
17
- function cleanUrl(url) {
18
- return url.replace(postfixRE, "");
19
- }
20
- function isPrimitive(value) {
21
- return !value || typeof value != "object" && typeof value != "function";
22
- }
23
- const AsyncFunction = async function() {}.constructor;
24
- let asyncFunctionDeclarationPaddingLineCount;
25
- function getAsyncFunctionDeclarationPaddingLineCount() {
26
- if (asyncFunctionDeclarationPaddingLineCount === void 0) {
27
- let body = "/*code*/", source = new AsyncFunction("a", "b", body).toString();
28
- asyncFunctionDeclarationPaddingLineCount = source.slice(0, source.indexOf(body)).split("\n").length - 1;
29
- }
30
- return asyncFunctionDeclarationPaddingLineCount;
31
- }
32
- function promiseWithResolvers() {
33
- let resolve, reject;
34
- return {
35
- promise: new Promise((_resolve, _reject) => {
36
- resolve = _resolve, reject = _reject;
37
- }),
38
- resolve,
39
- reject
40
- };
41
- }
42
- //#endregion
43
- //#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
44
- const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
45
- function normalizeWindowsPath(input = "") {
46
- return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
47
- }
48
- const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
49
- function cwd() {
50
- return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
51
- }
52
- const resolve = function(...arguments_) {
53
- arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
54
- let resolvedPath = "", resolvedAbsolute = !1;
55
- for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
56
- let path = index >= 0 ? arguments_[index] : cwd();
57
- !path || path.length === 0 || (resolvedPath = `${path}/${resolvedPath}`, resolvedAbsolute = isAbsolute(path));
58
- }
59
- return resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute), resolvedAbsolute && !isAbsolute(resolvedPath) ? `/${resolvedPath}` : resolvedPath.length > 0 ? resolvedPath : ".";
60
- };
61
- function normalizeString(path, allowAboveRoot) {
62
- let res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, char = null;
63
- for (let index = 0; index <= path.length; ++index) {
64
- if (index < path.length) char = path[index];
65
- else if (char === "/") break;
66
- else char = "/";
67
- if (char === "/") {
68
- if (!(lastSlash === index - 1 || dots === 1)) if (dots === 2) {
69
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
70
- if (res.length > 2) {
71
- let lastSlashIndex = res.lastIndexOf("/");
72
- lastSlashIndex === -1 ? (res = "", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/")), lastSlash = index, dots = 0;
73
- continue;
74
- } else if (res.length > 0) {
75
- res = "", lastSegmentLength = 0, lastSlash = index, dots = 0;
76
- continue;
77
- }
78
- }
79
- allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
80
- } else res.length > 0 ? res += `/${path.slice(lastSlash + 1, index)}` : res = path.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
81
- lastSlash = index, dots = 0;
82
- } else char === "." && dots !== -1 ? ++dots : dots = -1;
83
- }
84
- return res;
85
- }
86
- const isAbsolute = function(p) {
87
- return _IS_ABSOLUTE_RE.test(p);
88
- }, dirname = function(p) {
89
- let segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
90
- return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute(p) ? "/" : ".");
91
- }, textDecoder = new TextDecoder(), decodeBase64 = typeof Buffer == "function" && typeof Buffer.from == "function" ? (base64) => Buffer.from(base64, "base64").toString("utf-8") : (base64) => textDecoder.decode(Uint8Array.from(atob(base64), (c) => c.charCodeAt(0))), percentRegEx = /%/g, backslashRegEx = /\\/g, newlineRegEx = /\n/g, carriageReturnRegEx = /\r/g, tabRegEx = /\t/g, questionRegex = /\?/g, hashRegex = /#/g;
92
- function encodePathChars(filepath) {
93
- return filepath.includes("%") && (filepath = filepath.replace(percentRegEx, "%25")), !isWindows && filepath.includes("\\") && (filepath = filepath.replace(backslashRegEx, "%5C")), filepath.includes("\n") && (filepath = filepath.replace(newlineRegEx, "%0A")), filepath.includes("\r") && (filepath = filepath.replace(carriageReturnRegEx, "%0D")), filepath.includes(" ") && (filepath = filepath.replace(tabRegEx, "%09")), filepath;
94
- }
95
- const posixDirname = dirname, posixResolve = resolve;
96
- function posixPathToFileHref(posixPath) {
97
- let resolved = posixResolve(posixPath), filePathLast = posixPath.charCodeAt(posixPath.length - 1);
98
- return (filePathLast === 47 || isWindows && filePathLast === 92) && resolved[resolved.length - 1] !== "/" && (resolved += "/"), resolved = encodePathChars(resolved), resolved.includes("?") && (resolved = resolved.replace(questionRegex, "%3F")), resolved.includes("#") && (resolved = resolved.replace(hashRegex, "%23")), new URL(`file://${resolved}`).href;
99
- }
100
- function toWindowsPath(path) {
101
- return path.replace(/\//g, "\\");
102
- }
103
- //#endregion
104
- //#region ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
105
- var comma = 44, chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", intToChar = /* @__PURE__ */ new Uint8Array(64), charToInt = /* @__PURE__ */ new Uint8Array(128);
106
- for (let i = 0; i < chars.length; i++) {
107
- let c = chars.charCodeAt(i);
108
- intToChar[i] = c, charToInt[c] = i;
109
- }
110
- function decodeInteger(reader, relative) {
111
- let value = 0, shift = 0, integer = 0;
112
- do
113
- integer = charToInt[reader.next()], value |= (integer & 31) << shift, shift += 5;
114
- while (integer & 32);
115
- let shouldNegate = value & 1;
116
- return value >>>= 1, shouldNegate && (value = -2147483648 | -value), relative + value;
117
- }
118
- function hasMoreVlq(reader, max) {
119
- return reader.pos >= max ? !1 : reader.peek() !== comma;
120
- }
121
- var StringReader = class {
122
- constructor(buffer) {
123
- this.pos = 0, this.buffer = buffer;
124
- }
125
- next() {
126
- return this.buffer.charCodeAt(this.pos++);
127
- }
128
- peek() {
129
- return this.buffer.charCodeAt(this.pos);
130
- }
131
- indexOf(char) {
132
- let { buffer, pos } = this, idx = buffer.indexOf(char, pos);
133
- return idx === -1 ? buffer.length : idx;
134
- }
135
- };
136
- function decode(mappings) {
137
- let { length } = mappings, reader = new StringReader(mappings), decoded = [], genColumn = 0, sourcesIndex = 0, sourceLine = 0, sourceColumn = 0, namesIndex = 0;
138
- do {
139
- let semi = reader.indexOf(";"), line = [], sorted = !0, lastCol = 0;
140
- for (genColumn = 0; reader.pos < semi;) {
141
- let seg;
142
- genColumn = decodeInteger(reader, genColumn), genColumn < lastCol && (sorted = !1), lastCol = genColumn, hasMoreVlq(reader, semi) ? (sourcesIndex = decodeInteger(reader, sourcesIndex), sourceLine = decodeInteger(reader, sourceLine), sourceColumn = decodeInteger(reader, sourceColumn), hasMoreVlq(reader, semi) ? (namesIndex = decodeInteger(reader, namesIndex), seg = [
143
- genColumn,
144
- sourcesIndex,
145
- sourceLine,
146
- sourceColumn,
147
- namesIndex
148
- ]) : seg = [
149
- genColumn,
150
- sourcesIndex,
151
- sourceLine,
152
- sourceColumn
153
- ]) : seg = [genColumn], line.push(seg), reader.pos++;
154
- }
155
- sorted || sort(line), decoded.push(line), reader.pos = semi + 1;
156
- } while (reader.pos <= length);
157
- return decoded;
158
- }
159
- function sort(line) {
160
- line.sort(sortComparator);
161
- }
162
- function sortComparator(a, b) {
163
- return a[0] - b[0];
164
- }
165
- //#endregion
166
- //#region ../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs
167
- var COLUMN = 0, SOURCES_INDEX = 1, SOURCE_LINE = 2, SOURCE_COLUMN = 3, NAMES_INDEX = 4, found = !1;
168
- function binarySearch(haystack, needle, low, high) {
169
- for (; low <= high;) {
170
- let mid = low + (high - low >> 1), cmp = haystack[mid][COLUMN] - needle;
171
- if (cmp === 0) return found = !0, mid;
172
- cmp < 0 ? low = mid + 1 : high = mid - 1;
173
- }
174
- return found = !1, low - 1;
175
- }
176
- function upperBound(haystack, needle, index) {
177
- for (let i = index + 1; i < haystack.length && haystack[i][COLUMN] === needle; index = i++);
178
- return index;
179
- }
180
- function lowerBound(haystack, needle, index) {
181
- for (let i = index - 1; i >= 0 && haystack[i][COLUMN] === needle; index = i--);
182
- return index;
183
- }
184
- function memoizedBinarySearch(haystack, needle, state, key) {
185
- let { lastKey, lastNeedle, lastIndex } = state, low = 0, high = haystack.length - 1;
186
- if (key === lastKey) {
187
- if (needle === lastNeedle) return found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle, lastIndex;
188
- needle >= lastNeedle ? low = lastIndex === -1 ? 0 : lastIndex : high = lastIndex;
189
- }
190
- return state.lastKey = key, state.lastNeedle = needle, state.lastIndex = binarySearch(haystack, needle, low, high);
191
- }
192
- var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)", COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
193
- function cast(map) {
194
- return map;
195
- }
196
- function decodedMappings(map) {
197
- var _a;
198
- return (_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded));
199
- }
200
- function originalPositionFor(map, needle) {
201
- let { line, column, bias } = needle;
202
- if (line--, line < 0) throw Error(LINE_GTR_ZERO);
203
- if (column < 0) throw Error(COL_GTR_EQ_ZERO);
204
- let decoded = decodedMappings(map);
205
- if (line >= decoded.length) return OMapping(null, null, null, null);
206
- let segments = decoded[line], index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || 1);
207
- if (index === -1) return OMapping(null, null, null, null);
208
- let segment = segments[index];
209
- if (segment.length === 1) return OMapping(null, null, null, null);
210
- let { names, resolvedSources } = map;
211
- return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
212
- }
213
- function OMapping(source, line, column, name) {
214
- return {
215
- source,
216
- line,
217
- column,
218
- name
219
- };
220
- }
221
- function traceSegmentInternal(segments, memo, line, column, bias) {
222
- let index = memoizedBinarySearch(segments, column, memo, line);
223
- return found ? index = (bias === -1 ? upperBound : lowerBound)(segments, column, index) : bias === -1 && index++, index === -1 || index === segments.length ? -1 : index;
224
- }
225
- //#endregion
226
- //#region src/module-runner/sourcemap/decoder.ts
227
- var DecodedMap = class {
228
- map;
229
- _encoded;
230
- _decoded;
231
- _decodedMemo;
232
- url;
233
- file;
234
- version;
235
- names = [];
236
- resolvedSources;
237
- constructor(map, from) {
238
- this.map = map;
239
- let { mappings, names, sources } = map;
240
- this.version = map.version, this.names = names || [], this._encoded = mappings || "", this._decodedMemo = memoizedState(), this.url = from, this.file = from;
241
- let originDir = posixDirname(from);
242
- this.resolvedSources = (sources || []).map((s) => posixResolve(originDir, s || ""));
243
- }
244
- };
245
- function memoizedState() {
246
- return {
247
- lastKey: -1,
248
- lastNeedle: -1,
249
- lastIndex: -1
250
- };
251
- }
252
- function getOriginalPosition(map, needle) {
253
- let result = originalPositionFor(map, needle);
254
- return result.column == null ? null : result;
255
- }
256
- //#endregion
257
- //#region src/module-runner/evaluatedModules.ts
258
- const MODULE_RUNNER_SOURCEMAPPING_REGEXP = RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json;base64,(.+)`);
259
- var EvaluatedModuleNode = class {
260
- id;
261
- url;
262
- importers = /* @__PURE__ */ new Set();
263
- imports = /* @__PURE__ */ new Set();
264
- evaluated = !1;
265
- meta;
266
- promise;
267
- exports;
268
- file;
269
- map;
270
- constructor(id, url) {
271
- this.id = id, this.url = url, this.file = cleanUrl(id);
272
- }
273
- }, EvaluatedModules = class {
274
- idToModuleMap = /* @__PURE__ */ new Map();
275
- fileToModulesMap = /* @__PURE__ */ new Map();
276
- urlToIdModuleMap = /* @__PURE__ */ new Map();
277
- /**
278
- * Returns the module node by the resolved module ID. Usually, module ID is
279
- * the file system path with query and/or hash. It can also be a virtual module.
280
- *
281
- * Module runner graph will have 1 to 1 mapping with the server module graph.
282
- * @param id Resolved module ID
283
- */
284
- getModuleById(id) {
285
- return this.idToModuleMap.get(id);
286
- }
287
- /**
288
- * Returns all modules related to the file system path. Different modules
289
- * might have different query parameters or hash, so it's possible to have
290
- * multiple modules for the same file.
291
- * @param file The file system path of the module
292
- */
293
- getModulesByFile(file) {
294
- return this.fileToModulesMap.get(file);
295
- }
296
- /**
297
- * Returns the module node by the URL that was used in the import statement.
298
- * Unlike module graph on the server, the URL is not resolved and is used as is.
299
- * @param url Server URL that was used in the import statement
300
- */
301
- getModuleByUrl(url) {
302
- return this.urlToIdModuleMap.get(unwrapId(url));
303
- }
304
- /**
305
- * Ensure that module is in the graph. If the module is already in the graph,
306
- * it will return the existing module node. Otherwise, it will create a new
307
- * module node and add it to the graph.
308
- * @param id Resolved module ID
309
- * @param url URL that was used in the import statement
310
- */
311
- ensureModule(id, url) {
312
- if (id = normalizeModuleId(id), this.idToModuleMap.has(id)) {
313
- let moduleNode = this.idToModuleMap.get(id);
314
- return this.urlToIdModuleMap.set(url, moduleNode), moduleNode;
315
- }
316
- let moduleNode = new EvaluatedModuleNode(id, url);
317
- this.idToModuleMap.set(id, moduleNode), this.urlToIdModuleMap.set(url, moduleNode);
318
- let fileModules = this.fileToModulesMap.get(moduleNode.file) || /* @__PURE__ */ new Set();
319
- return fileModules.add(moduleNode), this.fileToModulesMap.set(moduleNode.file, fileModules), moduleNode;
320
- }
321
- invalidateModule(node) {
322
- node.evaluated = !1, node.meta = void 0, node.map = void 0, node.promise = void 0, node.exports = void 0, node.imports.clear();
323
- }
324
- /**
325
- * Extracts the inlined source map from the module code and returns the decoded
326
- * source map. If the source map is not inlined, it will return null.
327
- * @param id Resolved module ID
328
- */
329
- getModuleSourceMapById(id) {
330
- let mod = this.getModuleById(id);
331
- if (!mod) return null;
332
- if (mod.map) return mod.map;
333
- if (!mod.meta || !("code" in mod.meta)) return null;
334
- let pattern = `//# ${SOURCEMAPPING_URL}=data:application/json;base64,`, lastIndex = mod.meta.code.lastIndexOf(pattern);
335
- if (lastIndex === -1) return null;
336
- let mapString = MODULE_RUNNER_SOURCEMAPPING_REGEXP.exec(mod.meta.code.slice(lastIndex))?.[1];
337
- return mapString ? (mod.map = new DecodedMap(JSON.parse(decodeBase64(mapString)), mod.file), mod.map) : null;
338
- }
339
- clear() {
340
- this.idToModuleMap.clear(), this.fileToModulesMap.clear(), this.urlToIdModuleMap.clear();
341
- }
342
- };
343
- const prefixedBuiltins = /* @__PURE__ */ new Set([
344
- "node:sea",
345
- "node:sqlite",
346
- "node:test",
347
- "node:test/reporters"
348
- ]);
349
- function normalizeModuleId(file) {
350
- return prefixedBuiltins.has(file) ? file : slash(file).replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^node:/, "").replace(/^\/+/, "/").replace(/^file:\/+/, isWindows ? "" : "/");
351
- }
352
- //#endregion
353
- //#region src/shared/hmr.ts
354
- var HMRContext = class {
355
- hmrClient;
356
- ownerPath;
357
- newListeners;
358
- constructor(hmrClient, ownerPath) {
359
- this.hmrClient = hmrClient, this.ownerPath = ownerPath, hmrClient.dataMap.has(ownerPath) || hmrClient.dataMap.set(ownerPath, {});
360
- let mod = hmrClient.hotModulesMap.get(ownerPath);
361
- mod && (mod.callbacks = []);
362
- let staleListeners = hmrClient.ctxToListenersMap.get(ownerPath);
363
- if (staleListeners) for (let [event, staleFns] of staleListeners) {
364
- let listeners = hmrClient.customListenersMap.get(event);
365
- listeners && hmrClient.customListenersMap.set(event, listeners.filter((l) => !staleFns.includes(l)));
366
- }
367
- this.newListeners = /* @__PURE__ */ new Map(), hmrClient.ctxToListenersMap.set(ownerPath, this.newListeners);
368
- }
369
- get data() {
370
- return this.hmrClient.dataMap.get(this.ownerPath);
371
- }
372
- accept(deps, callback) {
373
- if (typeof deps == "function" || !deps) this.acceptDeps([this.ownerPath], ([mod]) => deps?.(mod));
374
- else if (typeof deps == "string") this.acceptDeps([deps], ([mod]) => callback?.(mod));
375
- else if (Array.isArray(deps)) this.acceptDeps(deps, callback);
376
- else throw Error("invalid hot.accept() usage.");
377
- }
378
- acceptExports(_, callback) {
379
- this.acceptDeps([this.ownerPath], ([mod]) => callback?.(mod));
380
- }
381
- dispose(cb) {
382
- this.hmrClient.disposeMap.set(this.ownerPath, cb);
383
- }
384
- prune(cb) {
385
- this.hmrClient.pruneMap.set(this.ownerPath, cb);
386
- }
387
- decline() {}
388
- invalidate(message) {
389
- let firstInvalidatedBy = this.hmrClient.currentFirstInvalidatedBy ?? this.ownerPath;
390
- this.hmrClient.notifyListeners("vite:invalidate", {
391
- path: this.ownerPath,
392
- message,
393
- firstInvalidatedBy
394
- }), this.send("vite:invalidate", {
395
- path: this.ownerPath,
396
- message,
397
- firstInvalidatedBy
398
- }), this.hmrClient.logger.debug(`invalidate ${this.ownerPath}${message ? `: ${message}` : ""}`);
399
- }
400
- on(event, cb) {
401
- let addToMap = (map) => {
402
- let existing = map.get(event) || [];
403
- existing.push(cb), map.set(event, existing);
404
- };
405
- addToMap(this.hmrClient.customListenersMap), addToMap(this.newListeners);
406
- }
407
- off(event, cb) {
408
- let removeFromMap = (map) => {
409
- let existing = map.get(event);
410
- if (existing === void 0) return;
411
- let pruned = existing.filter((l) => l !== cb);
412
- if (pruned.length === 0) {
413
- map.delete(event);
414
- return;
415
- }
416
- map.set(event, pruned);
417
- };
418
- removeFromMap(this.hmrClient.customListenersMap), removeFromMap(this.newListeners);
419
- }
420
- send(event, data) {
421
- this.hmrClient.send({
422
- type: "custom",
423
- event,
424
- data
425
- });
426
- }
427
- acceptDeps(deps, callback = () => {}) {
428
- let mod = this.hmrClient.hotModulesMap.get(this.ownerPath) || {
429
- id: this.ownerPath,
430
- callbacks: []
431
- };
432
- mod.callbacks.push({
433
- deps,
434
- fn: callback
435
- }), this.hmrClient.hotModulesMap.set(this.ownerPath, mod);
436
- }
437
- }, HMRClient = class {
438
- logger;
439
- transport;
440
- importUpdatedModule;
441
- hotModulesMap = /* @__PURE__ */ new Map();
442
- disposeMap = /* @__PURE__ */ new Map();
443
- pruneMap = /* @__PURE__ */ new Map();
444
- dataMap = /* @__PURE__ */ new Map();
445
- customListenersMap = /* @__PURE__ */ new Map();
446
- ctxToListenersMap = /* @__PURE__ */ new Map();
447
- currentFirstInvalidatedBy;
448
- constructor(logger, transport, importUpdatedModule) {
449
- this.logger = logger, this.transport = transport, this.importUpdatedModule = importUpdatedModule;
450
- }
451
- async notifyListeners(event, data) {
452
- let cbs = this.customListenersMap.get(event);
453
- cbs && await Promise.allSettled(cbs.map((cb) => cb(data)));
454
- }
455
- send(payload) {
456
- this.transport.send(payload).catch((err) => {
457
- this.logger.error(err);
458
- });
459
- }
460
- clear() {
461
- this.hotModulesMap.clear(), this.disposeMap.clear(), this.pruneMap.clear(), this.dataMap.clear(), this.customListenersMap.clear(), this.ctxToListenersMap.clear();
462
- }
463
- async prunePaths(paths) {
464
- await Promise.all(paths.map((path) => {
465
- let disposer = this.disposeMap.get(path);
466
- if (disposer) return disposer(this.dataMap.get(path));
467
- })), await Promise.all(paths.map((path) => {
468
- let fn = this.pruneMap.get(path);
469
- if (fn) return fn(this.dataMap.get(path));
470
- }));
471
- }
472
- warnFailedUpdate(err, path) {
473
- (!(err instanceof Error) || !err.message.includes("fetch")) && this.logger.error(err), this.logger.error(`Failed to reload ${path}. This could be due to syntax errors or importing non-existent modules. (see errors above)`);
474
- }
475
- updateQueue = [];
476
- pendingUpdateQueue = !1;
477
- /**
478
- * buffer multiple hot updates triggered by the same src change
479
- * so that they are invoked in the same order they were sent.
480
- * (otherwise the order may be inconsistent because of the http request round trip)
481
- */
482
- async queueUpdate(payload) {
483
- if (this.updateQueue.push(this.fetchUpdate(payload)), !this.pendingUpdateQueue) {
484
- this.pendingUpdateQueue = !0, await Promise.resolve(), this.pendingUpdateQueue = !1;
485
- let loading = [...this.updateQueue];
486
- this.updateQueue = [], (await Promise.all(loading)).forEach((fn) => fn && fn());
487
- }
488
- }
489
- async fetchUpdate(update) {
490
- let { path, acceptedPath, firstInvalidatedBy } = update, mod = this.hotModulesMap.get(path);
491
- if (!mod) return;
492
- let fetchedModule, isSelfUpdate = path === acceptedPath, qualifiedCallbacks = mod.callbacks.filter(({ deps }) => deps.includes(acceptedPath));
493
- if (isSelfUpdate || qualifiedCallbacks.length > 0) {
494
- let disposer = this.disposeMap.get(acceptedPath);
495
- disposer && await disposer(this.dataMap.get(acceptedPath));
496
- try {
497
- fetchedModule = await this.importUpdatedModule(update);
498
- } catch (e) {
499
- this.warnFailedUpdate(e, acceptedPath);
500
- }
501
- }
502
- return () => {
503
- try {
504
- this.currentFirstInvalidatedBy = firstInvalidatedBy;
505
- for (let { deps, fn } of qualifiedCallbacks) fn(deps.map((dep) => dep === acceptedPath ? fetchedModule : void 0));
506
- let loggedPath = isSelfUpdate ? path : `${acceptedPath} via ${path}`;
507
- this.logger.debug(`hot updated: ${loggedPath}`);
508
- } finally {
509
- this.currentFirstInvalidatedBy = void 0;
510
- }
511
- };
512
- }
513
- };
514
- //#endregion
515
- //#region src/shared/ssrTransform.ts
516
- /**
517
- * Vite converts `import { } from 'foo'` to `const _ = __vite_ssr_import__('foo')`.
518
- * Top-level imports and dynamic imports work slightly differently in Node.js.
519
- * This function normalizes the differences so it matches prod behaviour.
520
- */
521
- function analyzeImportedModDifference(mod, rawId, moduleType, metadata) {
522
- if (!metadata?.isDynamicImport && metadata?.importedNames?.length) {
523
- let missingBindings = metadata.importedNames.filter((s) => !(s in mod));
524
- if (missingBindings.length) {
525
- let lastBinding = missingBindings[missingBindings.length - 1];
526
- throw SyntaxError(moduleType === "module" ? `[vite] The requested module '${rawId}' does not provide an export named '${lastBinding}'` : `\
527
- [vite] Named export '${lastBinding}' not found. The requested module '${rawId}' is a CommonJS module, which may not support all module.exports as named exports.
528
- CommonJS modules can always be imported via the default export, for example using:
529
-
530
- import pkg from '${rawId}';
531
- const {${missingBindings.join(", ")}} = pkg;
532
- `);
533
- }
534
- }
535
- }
536
- //#endregion
537
- //#region ../../node_modules/.pnpm/nanoid@5.1.11/node_modules/nanoid/non-secure/index.js
538
- let nanoid = (size = 21) => {
539
- let id = "", i = size | 0;
540
- for (; i--;) id += "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[Math.random() * 64 | 0];
541
- return id;
542
- };
543
- //#endregion
544
- //#region src/shared/moduleRunnerTransport.ts
545
- function reviveInvokeError(e) {
546
- let error = Error(e.message || "Unknown invoke error");
547
- return Object.assign(error, e, { runnerError: /* @__PURE__ */ Error("RunnerError") }), error;
548
- }
549
- const createInvokeableTransport = (transport) => {
550
- if (transport.invoke) return {
551
- ...transport,
552
- async invoke(name, data) {
553
- let result = await transport.invoke({
554
- type: "custom",
555
- event: "vite:invoke",
556
- data: {
557
- id: "send",
558
- name,
559
- data
560
- }
561
- });
562
- if ("error" in result) throw reviveInvokeError(result.error);
563
- return result.result;
564
- }
565
- };
566
- if (!transport.send || !transport.connect) throw Error("transport must implement send and connect when invoke is not implemented");
567
- let rpcPromises = /* @__PURE__ */ new Map();
568
- return {
569
- ...transport,
570
- connect({ onMessage, onDisconnection }) {
571
- return transport.connect({
572
- onMessage(payload) {
573
- if (payload.type === "custom" && payload.event === "vite:invoke") {
574
- let data = payload.data;
575
- if (data.id.startsWith("response:")) {
576
- let invokeId = data.id.slice(9), promise = rpcPromises.get(invokeId);
577
- if (!promise) return;
578
- promise.timeoutId && clearTimeout(promise.timeoutId), rpcPromises.delete(invokeId);
579
- let { error, result } = data.data;
580
- error ? promise.reject(error) : promise.resolve(result);
581
- return;
582
- }
583
- }
584
- onMessage(payload);
585
- },
586
- onDisconnection
587
- });
588
- },
589
- disconnect() {
590
- return rpcPromises.forEach((promise) => {
591
- promise.reject(/* @__PURE__ */ Error(`transport was disconnected, cannot call ${JSON.stringify(promise.name)}`));
592
- }), rpcPromises.clear(), transport.disconnect?.();
593
- },
594
- send(data) {
595
- return transport.send(data);
596
- },
597
- async invoke(name, data) {
598
- let promiseId = nanoid(), wrappedData = {
599
- type: "custom",
600
- event: "vite:invoke",
601
- data: {
602
- name,
603
- id: `send:${promiseId}`,
604
- data
605
- }
606
- }, sendPromise = transport.send(wrappedData), { promise, resolve, reject } = promiseWithResolvers(), timeout = transport.timeout ?? 6e4, timeoutId;
607
- timeout > 0 && (timeoutId = setTimeout(() => {
608
- rpcPromises.delete(promiseId), reject(/* @__PURE__ */ Error(`transport invoke timed out after ${timeout}ms (data: ${JSON.stringify(wrappedData)})`));
609
- }, timeout), timeoutId?.unref?.()), rpcPromises.set(promiseId, {
610
- resolve,
611
- reject,
612
- name,
613
- timeoutId
614
- }), sendPromise && sendPromise.catch((err) => {
615
- clearTimeout(timeoutId), rpcPromises.delete(promiseId), reject(err);
616
- });
617
- try {
618
- return await promise;
619
- } catch (err) {
620
- throw reviveInvokeError(err);
621
- }
622
- }
623
- };
624
- }, normalizeModuleRunnerTransport = (transport) => {
625
- let invokeableTransport = createInvokeableTransport(transport), isConnected = !invokeableTransport.connect, connectingPromise;
626
- return {
627
- ...transport,
628
- ...invokeableTransport.connect ? { async connect(onMessage) {
629
- if (isConnected) return;
630
- if (connectingPromise) {
631
- await connectingPromise;
632
- return;
633
- }
634
- let maybePromise = invokeableTransport.connect({
635
- onMessage: onMessage ?? (() => {}),
636
- onDisconnection() {
637
- isConnected = !1;
638
- }
639
- });
640
- maybePromise && (connectingPromise = maybePromise, await connectingPromise, connectingPromise = void 0), isConnected = !0;
641
- } } : {},
642
- ...invokeableTransport.disconnect ? { async disconnect() {
643
- isConnected && (connectingPromise && await connectingPromise, isConnected = !1, await invokeableTransport.disconnect());
644
- } } : {},
645
- async send(data) {
646
- if (invokeableTransport.send) {
647
- if (!isConnected) if (connectingPromise) await connectingPromise;
648
- else throw new SendBeforeConnectError("send was called before connect");
649
- await invokeableTransport.send(data);
650
- }
651
- },
652
- async invoke(name, data) {
653
- if (!isConnected) if (connectingPromise) await connectingPromise;
654
- else throw new SendBeforeConnectError("invoke was called before connect");
655
- return invokeableTransport.invoke(name, data);
656
- }
657
- };
658
- };
659
- var SendBeforeConnectError = class extends Error {
660
- constructor(message) {
661
- super(message), this.name = "SendBeforeConnectError";
662
- }
663
- };
664
- const createWebSocketModuleRunnerTransport = (options) => {
665
- let pingInterval = options.pingInterval ?? 3e4, ws, pingIntervalId;
666
- return {
667
- async connect({ onMessage, onDisconnection }) {
668
- let socket = options.createConnection();
669
- socket.addEventListener("message", ({ data }) => {
670
- onMessage(JSON.parse(data));
671
- });
672
- let isOpened = socket.readyState === socket.OPEN;
673
- isOpened || await new Promise((resolve, reject) => {
674
- socket.addEventListener("open", () => {
675
- isOpened = !0, resolve();
676
- }, { once: !0 }), socket.addEventListener("close", () => {
677
- if (!isOpened) {
678
- reject(/* @__PURE__ */ Error("WebSocket closed without opened."));
679
- return;
680
- }
681
- onMessage({
682
- type: "custom",
683
- event: "vite:ws:disconnect",
684
- data: { webSocket: socket }
685
- }), onDisconnection();
686
- });
687
- }), onMessage({
688
- type: "custom",
689
- event: "vite:ws:connect",
690
- data: { webSocket: socket }
691
- }), ws = socket, pingIntervalId = setInterval(() => {
692
- socket.readyState === socket.OPEN && socket.send(JSON.stringify({ type: "ping" }));
693
- }, pingInterval);
694
- },
695
- disconnect() {
696
- clearInterval(pingIntervalId), ws?.close();
697
- },
698
- send(data) {
699
- ws.send(JSON.stringify(data));
700
- }
701
- };
702
- };
703
- //#endregion
704
- //#region src/shared/builtin.ts
705
- function createIsBuiltin(builtins) {
706
- let plainBuiltinsSet = new Set(builtins.filter((builtin) => typeof builtin == "string")), regexBuiltins = builtins.filter((builtin) => typeof builtin != "string");
707
- return (id) => plainBuiltinsSet.has(id) || regexBuiltins.some((regexp) => regexp.test(id));
708
- }
709
- //#endregion
710
- //#region src/module-runner/constants.ts
711
- const ssrModuleExportsKey = "__vite_ssr_exports__", ssrImportKey = "__vite_ssr_import__", ssrDynamicImportKey = "__vite_ssr_dynamic_import__", ssrExportAllKey = "__vite_ssr_exportAll__", ssrExportNameKey = "__vite_ssr_exportName__", ssrImportMetaKey = "__vite_ssr_import_meta__", noop = () => {}, silentConsole = {
712
- debug: noop,
713
- error: noop
714
- }, hmrLogger = {
715
- debug: (...msg) => console.log("[vite]", ...msg),
716
- error: (error) => console.log("[vite]", error)
717
- };
718
- //#endregion
719
- //#region src/shared/hmrHandler.ts
720
- function createHMRHandler(handler) {
721
- let queue = new Queue();
722
- return (payload) => queue.enqueue(() => handler(payload));
723
- }
724
- var Queue = class {
725
- queue = [];
726
- pending = !1;
727
- enqueue(promise) {
728
- return new Promise((resolve, reject) => {
729
- this.queue.push({
730
- promise,
731
- resolve,
732
- reject
733
- }), this.dequeue();
734
- });
735
- }
736
- dequeue() {
737
- if (this.pending) return !1;
738
- let item = this.queue.shift();
739
- return item ? (this.pending = !0, item.promise().then(item.resolve).catch(item.reject).finally(() => {
740
- this.pending = !1, this.dequeue();
741
- }), !0) : !1;
742
- }
743
- };
744
- //#endregion
745
- //#region src/module-runner/hmrHandler.ts
746
- function createHMRHandlerForRunner(runner) {
747
- return createHMRHandler(async (payload) => {
748
- let hmrClient = runner.hmrClient;
749
- if (!(!hmrClient || runner.isClosed())) switch (payload.type) {
750
- case "connected":
751
- hmrClient.logger.debug("connected.");
752
- break;
753
- case "update":
754
- await hmrClient.notifyListeners("vite:beforeUpdate", payload), await Promise.all(payload.updates.map(async (update) => {
755
- if (update.type === "js-update") return update.acceptedPath = unwrapId(update.acceptedPath), update.path = unwrapId(update.path), hmrClient.queueUpdate(update);
756
- hmrClient.logger.error("css hmr is not supported in runner mode.");
757
- })), await hmrClient.notifyListeners("vite:afterUpdate", payload);
758
- break;
759
- case "custom":
760
- await hmrClient.notifyListeners(payload.event, payload.data);
761
- break;
762
- case "full-reload": {
763
- let { triggeredBy } = payload, clearEntrypointUrls = triggeredBy ? getModulesEntrypoints(runner, getModulesByFile(runner, slash(triggeredBy))) : findAllEntrypoints(runner);
764
- if (!clearEntrypointUrls.size) break;
765
- hmrClient.logger.debug("program reload"), await hmrClient.notifyListeners("vite:beforeFullReload", payload), runner.evaluatedModules.clear();
766
- for (let url of clearEntrypointUrls) {
767
- if (runner.isClosed()) break;
768
- try {
769
- await runner.import(url);
770
- } catch (err) {
771
- if (runner.isClosed()) break;
772
- err.code !== "ERR_OUTDATED_OPTIMIZED_DEP" && hmrClient.logger.error(`An error happened during full reload\n${err.message}\n${err.stack}`);
773
- }
774
- }
775
- break;
776
- }
777
- case "prune":
778
- await hmrClient.notifyListeners("vite:beforePrune", payload), await hmrClient.prunePaths(payload.paths);
779
- break;
780
- case "error": {
781
- await hmrClient.notifyListeners("vite:error", payload);
782
- let err = payload.err;
783
- hmrClient.logger.error(`Internal Server Error\n${err.message}\n${err.stack}`);
784
- break;
785
- }
786
- case "ping": break;
787
- default: return payload;
788
- }
789
- });
790
- }
791
- function getModulesByFile(runner, file) {
792
- let nodes = runner.evaluatedModules.getModulesByFile(file);
793
- return nodes ? [...nodes].map((node) => node.id) : [];
794
- }
795
- function getModulesEntrypoints(runner, modules, visited = /* @__PURE__ */ new Set(), entrypoints = /* @__PURE__ */ new Set()) {
796
- for (let moduleId of modules) {
797
- if (visited.has(moduleId)) continue;
798
- visited.add(moduleId);
799
- let module = runner.evaluatedModules.getModuleById(moduleId);
800
- if (module) {
801
- if (!module.importers.size) {
802
- entrypoints.add(module.url);
803
- continue;
804
- }
805
- for (let importer of module.importers) getModulesEntrypoints(runner, [importer], visited, entrypoints);
806
- }
807
- }
808
- return entrypoints;
809
- }
810
- function findAllEntrypoints(runner, entrypoints = /* @__PURE__ */ new Set()) {
811
- for (let mod of runner.evaluatedModules.idToModuleMap.values()) mod.importers.size || entrypoints.add(mod.url);
812
- return entrypoints;
813
- }
814
- //#endregion
815
- //#region src/module-runner/sourcemap/interceptor.ts
816
- const sourceMapCache = {}, fileContentsCache = {}, evaluatedModulesCache = /* @__PURE__ */ new Set(), retrieveFileHandlers = /* @__PURE__ */ new Set(), retrieveSourceMapHandlers = /* @__PURE__ */ new Set(), createExecHandlers = (handlers) => ((...args) => {
817
- for (let handler of handlers) {
818
- let result = handler(...args);
819
- if (result) return result;
820
- }
821
- return null;
822
- }), retrieveFileFromHandlers = createExecHandlers(retrieveFileHandlers), retrieveSourceMapFromHandlers = createExecHandlers(retrieveSourceMapHandlers);
823
- let overridden = !1;
824
- const originalPrepare = Error.prepareStackTrace;
825
- function resetInterceptor(runner, options) {
826
- evaluatedModulesCache.delete(runner.evaluatedModules), options.retrieveFile && retrieveFileHandlers.delete(options.retrieveFile), options.retrieveSourceMap && retrieveSourceMapHandlers.delete(options.retrieveSourceMap), evaluatedModulesCache.size === 0 && (Error.prepareStackTrace = originalPrepare, overridden = !1);
827
- }
828
- function interceptStackTrace(runner, options = {}) {
829
- return overridden ||= (Error.prepareStackTrace = prepareStackTrace, !0), evaluatedModulesCache.add(runner.evaluatedModules), options.retrieveFile && retrieveFileHandlers.add(options.retrieveFile), options.retrieveSourceMap && retrieveSourceMapHandlers.add(options.retrieveSourceMap), () => resetInterceptor(runner, options);
830
- }
831
- function supportRelativeURL(file, url) {
832
- if (!file) return url;
833
- let dir = posixDirname(slash(file)), match = /^\w+:\/\/[^/]*/.exec(dir), protocol = match ? match[0] : "", startPath = dir.slice(protocol.length);
834
- return protocol && /^\/\w:/.test(startPath) ? (protocol += "/", protocol + slash(posixResolve(startPath, url))) : protocol + posixResolve(startPath, url);
835
- }
836
- function getRunnerSourceMap(position) {
837
- for (let moduleGraph of evaluatedModulesCache) {
838
- let sourceMap = moduleGraph.getModuleSourceMapById(position.source);
839
- if (sourceMap) return {
840
- url: position.source,
841
- map: sourceMap,
842
- vite: !0
843
- };
844
- }
845
- return null;
846
- }
847
- function retrieveFile(path) {
848
- if (path in fileContentsCache) return fileContentsCache[path];
849
- let content = retrieveFileFromHandlers(path);
850
- return typeof content == "string" ? (fileContentsCache[path] = content, content) : null;
851
- }
852
- function retrieveSourceMapURL(source) {
853
- let fileData = retrieveFile(source);
854
- if (!fileData) return null;
855
- let re = /\/\/[@#]\s*sourceMappingURL=([^\s'"]+)\s*$|\/\*[@#]\s*sourceMappingURL=[^\s*'"]+\s*\*\/\s*$/gm, lastMatch, match;
856
- for (; match = re.exec(fileData);) lastMatch = match;
857
- return lastMatch ? lastMatch[1] : null;
858
- }
859
- const reSourceMap = /^data:application\/json[^,]+base64,/;
860
- function retrieveSourceMap(source) {
861
- let urlAndMap = retrieveSourceMapFromHandlers(source);
862
- if (urlAndMap) return urlAndMap;
863
- let sourceMappingURL = retrieveSourceMapURL(source);
864
- if (!sourceMappingURL) return null;
865
- let sourceMapData;
866
- if (reSourceMap.test(sourceMappingURL)) {
867
- let rawData = sourceMappingURL.slice(sourceMappingURL.indexOf(",") + 1);
868
- sourceMapData = Buffer.from(rawData, "base64").toString(), sourceMappingURL = source;
869
- } else sourceMappingURL = supportRelativeURL(source, sourceMappingURL), sourceMapData = retrieveFile(sourceMappingURL);
870
- return sourceMapData ? {
871
- url: sourceMappingURL,
872
- map: sourceMapData
873
- } : null;
874
- }
875
- function mapSourcePosition(position) {
876
- if (!position.source) return position;
877
- let sourceMap = getRunnerSourceMap(position);
878
- if (sourceMap ||= sourceMapCache[position.source], !sourceMap) {
879
- let urlAndMap = retrieveSourceMap(position.source);
880
- if (urlAndMap && urlAndMap.map) {
881
- let url = urlAndMap.url;
882
- sourceMap = sourceMapCache[position.source] = {
883
- url,
884
- map: new DecodedMap(typeof urlAndMap.map == "string" ? JSON.parse(urlAndMap.map) : urlAndMap.map, url)
885
- };
886
- let contents = sourceMap.map?.map.sourcesContent;
887
- sourceMap.map && contents && sourceMap.map.resolvedSources.forEach((source, i) => {
888
- let content = contents[i];
889
- if (content && source && url) {
890
- let contentUrl = supportRelativeURL(url, source);
891
- fileContentsCache[contentUrl] = content;
892
- }
893
- });
894
- } else sourceMap = sourceMapCache[position.source] = {
895
- url: null,
896
- map: null
897
- };
898
- }
899
- if (sourceMap.map && sourceMap.url) {
900
- let originalPosition = getOriginalPosition(sourceMap.map, position);
901
- if (originalPosition && originalPosition.source != null) return originalPosition.source = supportRelativeURL(sourceMap.url, originalPosition.source), sourceMap.vite && (originalPosition._vite = !0), originalPosition;
902
- }
903
- return position;
904
- }
905
- function mapEvalOrigin(origin) {
906
- let match = /^eval at ([^(]+) \((.+):(\d+):(\d+)\)$/.exec(origin);
907
- if (match) {
908
- let position = mapSourcePosition({
909
- name: null,
910
- source: match[2],
911
- line: +match[3],
912
- column: match[4] - 1
913
- });
914
- return `eval at ${match[1]} (${position.source}:${position.line}:${position.column + 1})`;
915
- }
916
- return match = /^eval at ([^(]+) \((.+)\)$/.exec(origin), match ? `eval at ${match[1]} (${mapEvalOrigin(match[2])})` : origin;
917
- }
918
- function CallSiteToString() {
919
- let fileName, fileLocation = "";
920
- if (this.isNative()) fileLocation = "native";
921
- else {
922
- fileName = this.getScriptNameOrSourceURL(), !fileName && this.isEval() && (fileLocation = this.getEvalOrigin(), fileLocation += ", "), fileName ? fileLocation += fileName : fileLocation += "<anonymous>";
923
- let lineNumber = this.getLineNumber();
924
- if (lineNumber != null) {
925
- fileLocation += `:${lineNumber}`;
926
- let columnNumber = this.getColumnNumber();
927
- columnNumber && (fileLocation += `:${columnNumber}`);
928
- }
929
- }
930
- let line = "", functionName = this.getFunctionName(), addSuffix = !0, isConstructor = this.isConstructor();
931
- if (this.isToplevel() || isConstructor) isConstructor ? line += `new ${functionName || "<anonymous>"}` : functionName ? line += functionName : (line += fileLocation, addSuffix = !1);
932
- else {
933
- let typeName = this.getTypeName();
934
- typeName === "[object Object]" && (typeName = "null");
935
- let methodName = this.getMethodName();
936
- functionName ? (typeName && functionName.indexOf(typeName) !== 0 && (line += `${typeName}.`), line += functionName, methodName && functionName.indexOf(`.${methodName}`) !== functionName.length - methodName.length - 1 && (line += ` [as ${methodName}]`)) : line += `${typeName}.${methodName || "<anonymous>"}`;
937
- }
938
- return addSuffix && (line += ` (${fileLocation})`), line;
939
- }
940
- function cloneCallSite(frame) {
941
- let object = {};
942
- return Object.getOwnPropertyNames(Object.getPrototypeOf(frame)).forEach((name) => {
943
- let key = name;
944
- object[key] = /^(?:is|get)/.test(name) ? function() {
945
- return frame[key].call(frame);
946
- } : frame[key];
947
- }), object.toString = CallSiteToString, object;
948
- }
949
- function wrapCallSite(frame, state) {
950
- if (state === void 0 && (state = {
951
- nextPosition: null,
952
- curPosition: null
953
- }), frame.isNative()) return state.curPosition = null, frame;
954
- let source = frame.getFileName() || frame.getScriptNameOrSourceURL();
955
- if (source) {
956
- let position = mapSourcePosition({
957
- name: null,
958
- source,
959
- line: frame.getLineNumber() ?? 0,
960
- column: (frame.getColumnNumber() ?? 1) - 1
961
- });
962
- state.curPosition = position, frame = cloneCallSite(frame);
963
- let originalFunctionName = frame.getFunctionName;
964
- return frame.getFunctionName = function() {
965
- let name = state.nextPosition == null ? originalFunctionName() : state.nextPosition.name || originalFunctionName();
966
- return name === "eval" && "_vite" in position ? null : name;
967
- }, frame.getFileName = function() {
968
- return position.source ?? null;
969
- }, frame.getLineNumber = function() {
970
- return position.line;
971
- }, frame.getColumnNumber = function() {
972
- return position.column + 1;
973
- }, frame.getScriptNameOrSourceURL = function() {
974
- return position.source;
975
- }, frame;
976
- }
977
- let origin = frame.isEval() && frame.getEvalOrigin();
978
- return origin ? (origin = mapEvalOrigin(origin), frame = cloneCallSite(frame), frame.getEvalOrigin = function() {
979
- return origin || void 0;
980
- }, frame) : frame;
981
- }
982
- function prepareStackTrace(error, stack) {
983
- let errorString = `${error.name || "Error"}: ${error.message || ""}`, state = {
984
- nextPosition: null,
985
- curPosition: null
986
- }, processedStack = [];
987
- for (let i = stack.length - 1; i >= 0; i--) processedStack.push(`\n at ${wrapCallSite(stack[i], state)}`), state.nextPosition = state.curPosition;
988
- return state.curPosition = state.nextPosition = null, errorString + processedStack.reverse().join("");
989
- }
990
- //#endregion
991
- //#region src/module-runner/sourcemap/index.ts
992
- function enableSourceMapSupport(runner) {
993
- if (runner.options.sourcemapInterceptor === "node") {
994
- if (typeof process > "u") throw TypeError("Cannot use \"sourcemapInterceptor: 'node'\" because global \"process\" variable is not available.");
995
- if (typeof process.setSourceMapsEnabled != "function") throw TypeError("Cannot use \"sourcemapInterceptor: 'node'\" because \"process.setSourceMapsEnabled\" function is not available. Please use Node >= 16.6.0.");
996
- let isEnabledAlready = process.sourceMapsEnabled ?? !1;
997
- return process.setSourceMapsEnabled(!0), () => !isEnabledAlready && process.setSourceMapsEnabled(!1);
998
- }
999
- return interceptStackTrace(runner, typeof runner.options.sourcemapInterceptor == "object" ? runner.options.sourcemapInterceptor : void 0);
1000
- }
1001
- //#endregion
1002
- //#region src/module-runner/esmEvaluator.ts
1003
- var ESModulesEvaluator = class {
1004
- startOffset = getAsyncFunctionDeclarationPaddingLineCount();
1005
- async runInlinedModule(context, code) {
1006
- await new AsyncFunction(ssrModuleExportsKey, ssrImportMetaKey, ssrImportKey, ssrDynamicImportKey, ssrExportAllKey, ssrExportNameKey, "\"use strict\";" + code)(context[ssrModuleExportsKey], context[ssrImportMetaKey], context[ssrImportKey], context[ssrDynamicImportKey], context[ssrExportAllKey], context[ssrExportNameKey]), Object.seal(context[ssrModuleExportsKey]);
1007
- }
1008
- runExternalModule(filepath) {
1009
- return import(filepath);
1010
- }
1011
- };
1012
- //#endregion
1013
- //#region src/module-runner/importMetaResolver.ts
1014
- const customizationHookNamespace = "vite-module-runner:import-meta-resolve/v1/", customizationHooksModule = `
1015
-
1016
- export async function resolve(specifier, context, nextResolve) {
1017
- if (specifier.startsWith(${JSON.stringify(customizationHookNamespace)})) {
1018
- const data = specifier.slice(${JSON.stringify(customizationHookNamespace)}.length)
1019
- const [parsedSpecifier, parsedImporter] = JSON.parse(data)
1020
- specifier = parsedSpecifier
1021
- context.parentURL = parsedImporter
1022
- }
1023
- return nextResolve(specifier, context)
1024
- }
1025
-
1026
- `;
1027
- function customizationHookResolve(specifier, context, nextResolve) {
1028
- if (specifier.startsWith(customizationHookNamespace)) {
1029
- let data = specifier.slice(42), [parsedSpecifier, parsedImporter] = JSON.parse(data);
1030
- specifier = parsedSpecifier, context.parentURL = parsedImporter;
1031
- }
1032
- return nextResolve(specifier, context);
1033
- }
1034
- let isHookRegistered = !1;
1035
- function createImportMetaResolver() {
1036
- if (isHookRegistered) return importMetaResolveWithCustomHook;
1037
- let module;
1038
- try {
1039
- module = typeof process < "u" ? process.getBuiltinModule("node:module").Module : void 0;
1040
- } catch {
1041
- return;
1042
- }
1043
- if (module) {
1044
- if (module.registerHooks) return module.registerHooks({ resolve: customizationHookResolve }), isHookRegistered = !0, importMetaResolveWithCustomHook;
1045
- if (module.register) {
1046
- try {
1047
- let hookModuleContent = `data:text/javascript,${encodeURI(customizationHooksModule)}`;
1048
- module.register(hookModuleContent);
1049
- } catch (e) {
1050
- if ("code" in e && e.code === "ERR_NETWORK_IMPORT_DISALLOWED") return;
1051
- throw e;
1052
- }
1053
- return isHookRegistered = !0, importMetaResolveWithCustomHook;
1054
- }
1055
- }
1056
- }
1057
- function importMetaResolveWithCustomHook(specifier, importer) {
1058
- return import.meta.resolve(`${customizationHookNamespace}${JSON.stringify([specifier, importer])}`);
1059
- }
1060
- //#endregion
1061
- //#region src/module-runner/createImportMeta.ts
1062
- const envProxy = new Proxy({}, { get(_, p) {
1063
- throw Error(`[module runner] Dynamic access of "import.meta.env" is not supported. Please, use "import.meta.env.${String(p)}" instead.`);
1064
- } });
1065
- function createDefaultImportMeta(modulePath) {
1066
- let href = posixPathToFileHref(modulePath), filename = modulePath, dirname = posixDirname(modulePath);
1067
- return {
1068
- filename: isWindows ? toWindowsPath(filename) : filename,
1069
- dirname: isWindows ? toWindowsPath(dirname) : dirname,
1070
- url: href,
1071
- env: envProxy,
1072
- resolve(_id, _parent) {
1073
- throw Error("[module runner] \"import.meta.resolve\" is not supported.");
1074
- },
1075
- glob() {
1076
- throw Error("[module runner] \"import.meta.glob\" is statically replaced during file transformation. Make sure to reference it by the full name.");
1077
- }
1078
- };
1079
- }
1080
- /**
1081
- * Create import.meta object for Node.js.
1082
- */
1083
- function createNodeImportMeta(modulePath) {
1084
- let defaultMeta = createDefaultImportMeta(modulePath), href = defaultMeta.url, importMetaResolver = createImportMetaResolver();
1085
- return {
1086
- ...defaultMeta,
1087
- main: !1,
1088
- resolve(id, parent) {
1089
- return (importMetaResolver ?? defaultMeta.resolve)(id, parent ?? href);
1090
- }
1091
- };
1092
- }
1093
- //#endregion
1094
- //#region src/module-runner/runner.ts
1095
- var ModuleRunner = class {
1096
- options;
1097
- evaluator;
1098
- debug;
1099
- evaluatedModules;
1100
- hmrClient;
1101
- transport;
1102
- resetSourceMapSupport;
1103
- concurrentModuleNodePromises = /* @__PURE__ */ new Map();
1104
- isBuiltin;
1105
- builtinsPromise;
1106
- closed = !1;
1107
- constructor(options, evaluator = new ESModulesEvaluator(), debug) {
1108
- if (this.options = options, this.evaluator = evaluator, this.debug = debug, this.evaluatedModules = options.evaluatedModules ?? new EvaluatedModules(), this.transport = normalizeModuleRunnerTransport(options.transport), options.hmr !== !1) {
1109
- let optionsHmr = options.hmr ?? !0, resolvedHmrLogger = optionsHmr === !0 || optionsHmr.logger === void 0 ? hmrLogger : optionsHmr.logger === !1 ? silentConsole : optionsHmr.logger;
1110
- if (this.hmrClient = new HMRClient(resolvedHmrLogger, this.transport, ({ acceptedPath }) => this.import(acceptedPath)), !this.transport.connect) throw Error("HMR is not supported by this runner transport, but `hmr` option was set to true");
1111
- this.transport.connect(createHMRHandlerForRunner(this));
1112
- } else this.transport.connect?.();
1113
- options.sourcemapInterceptor !== !1 && (this.resetSourceMapSupport = enableSourceMapSupport(this));
1114
- }
1115
- /**
1116
- * URL to execute. Accepts file path, server path or id relative to the root.
1117
- */
1118
- async import(url) {
1119
- let fetchedModule = await this.cachedModule(url);
1120
- return await this.cachedRequest(url, fetchedModule);
1121
- }
1122
- /**
1123
- * Clear all caches including HMR listeners.
1124
- */
1125
- clearCache() {
1126
- this.evaluatedModules.clear(), this.hmrClient?.clear();
1127
- }
1128
- /**
1129
- * Clears all caches, removes all HMR listeners, and resets source map support.
1130
- * This method doesn't stop the HMR connection.
1131
- */
1132
- async close() {
1133
- this.resetSourceMapSupport?.(), this.clearCache(), this.hmrClient = void 0, this.closed = !0, await this.transport.disconnect?.();
1134
- }
1135
- /**
1136
- * Returns `true` if the runtime has been closed by calling `close()` method.
1137
- */
1138
- isClosed() {
1139
- return this.closed;
1140
- }
1141
- processImport(exports, fetchResult, metadata) {
1142
- if (!("externalize" in fetchResult)) return exports;
1143
- let { url, type } = fetchResult;
1144
- return type !== "module" && type !== "commonjs" || analyzeImportedModDifference(exports, url, type, metadata), exports;
1145
- }
1146
- isCircularRequest(mod, callstack, visited = /* @__PURE__ */ new Set()) {
1147
- if (visited.has(mod.id)) return !1;
1148
- visited.add(mod.id);
1149
- for (let importedModuleId of mod.imports) {
1150
- if (callstack.includes(importedModuleId)) return !0;
1151
- let importedModule = this.evaluatedModules.getModuleById(importedModuleId);
1152
- if (importedModule?.promise && !importedModule.evaluated && this.isCircularRequest(importedModule, callstack, visited)) return !0;
1153
- }
1154
- return !1;
1155
- }
1156
- async cachedRequest(url, mod, callstack = [], metadata) {
1157
- let meta = mod.meta, moduleId = meta.id, importee = callstack[callstack.length - 1];
1158
- if (importee && mod.importers.add(importee), mod.evaluated && mod.promise) return this.processImport(await mod.promise, meta, metadata);
1159
- if (mod.promise) return mod.exports && (callstack.includes(moduleId) || this.isCircularRequest(mod, callstack)) ? this.processImport(mod.exports, meta, metadata) : this.processImport(await mod.promise, meta, metadata);
1160
- let debugTimer;
1161
- this.debug && (debugTimer = setTimeout(() => {
1162
- this.debug(`[module runner] module ${moduleId} takes over 2s to load.\n${`stack:\n${[...callstack, moduleId].reverse().map((p) => ` - ${p}`).join("\n")}`}`);
1163
- }, 2e3));
1164
- try {
1165
- let promise = this.directRequest(url, mod, callstack);
1166
- return mod.promise = promise, mod.evaluated = !1, this.processImport(await promise, meta, metadata);
1167
- } finally {
1168
- mod.evaluated = !0, debugTimer && clearTimeout(debugTimer);
1169
- }
1170
- }
1171
- async cachedModule(url, importer) {
1172
- let cached = this.concurrentModuleNodePromises.get(url);
1173
- if (cached) this.debug?.("[module runner] using cached module info for", url);
1174
- else {
1175
- let cachedModule = this.evaluatedModules.getModuleByUrl(url);
1176
- cached = this.getModuleInformation(url, importer, cachedModule).finally(() => {
1177
- this.concurrentModuleNodePromises.delete(url);
1178
- }), this.concurrentModuleNodePromises.set(url, cached);
1179
- }
1180
- return cached;
1181
- }
1182
- ensureBuiltins() {
1183
- if (!this.isBuiltin) return this.builtinsPromise ??= (async () => {
1184
- try {
1185
- this.debug?.("[module runner] fetching builtins from server");
1186
- let builtins = (await this.transport.invoke("getBuiltins", [])).map((builtin) => typeof builtin == "object" && builtin && "type" in builtin ? builtin.type === "string" ? builtin.value : new RegExp(builtin.source, builtin.flags) : builtin);
1187
- this.isBuiltin = createIsBuiltin(builtins), this.debug?.("[module runner] builtins loaded:", builtins);
1188
- } finally {
1189
- this.builtinsPromise = void 0;
1190
- }
1191
- })(), this.builtinsPromise;
1192
- }
1193
- async getModuleInformation(url, importer, cachedModule) {
1194
- if (this.closed) throw Error("Vite module runner has been closed.");
1195
- await this.ensureBuiltins(), this.debug?.("[module runner] fetching", url);
1196
- let isCached = !!(typeof cachedModule == "object" && cachedModule.meta), fetchedModule = url.startsWith("data:") || this.isBuiltin?.(url) ? {
1197
- externalize: url,
1198
- type: "builtin"
1199
- } : await this.transport.invoke("fetchModule", [
1200
- url,
1201
- importer,
1202
- {
1203
- cached: isCached,
1204
- startOffset: this.evaluator.startOffset
1205
- }
1206
- ]);
1207
- if ("cache" in fetchedModule) {
1208
- if (!cachedModule || !cachedModule.meta) throw Error(`Module "${url}" was mistakenly invalidated during fetch phase.`);
1209
- return cachedModule;
1210
- }
1211
- let moduleId = "externalize" in fetchedModule ? fetchedModule.externalize : fetchedModule.id, moduleUrl = "url" in fetchedModule ? fetchedModule.url : url, module = this.evaluatedModules.ensureModule(moduleId, moduleUrl);
1212
- return "invalidate" in fetchedModule && fetchedModule.invalidate && this.evaluatedModules.invalidateModule(module), fetchedModule.url = moduleUrl, fetchedModule.id = moduleId, module.meta = fetchedModule, module;
1213
- }
1214
- async directRequest(url, mod, _callstack) {
1215
- let fetchResult = mod.meta, moduleId = fetchResult.id, callstack = [..._callstack, moduleId], request = async (dep, metadata) => {
1216
- let importer = "file" in fetchResult && fetchResult.file || moduleId, depMod = await this.cachedModule(dep, importer);
1217
- return depMod.importers.add(moduleId), mod.imports.add(depMod.id), this.cachedRequest(dep, depMod, callstack, metadata);
1218
- }, dynamicRequest = async (dep) => (dep = String(dep), dep[0] === "." && (dep = posixResolve(posixDirname(url), dep)), request(dep, { isDynamicImport: !0 }));
1219
- if ("externalize" in fetchResult) {
1220
- let { externalize } = fetchResult;
1221
- this.debug?.("[module runner] externalizing", externalize);
1222
- let exports = await this.evaluator.runExternalModule(externalize);
1223
- return mod.exports = exports, exports;
1224
- }
1225
- let { code, file } = fetchResult;
1226
- if (code == null) {
1227
- let importer = callstack[callstack.length - 2];
1228
- throw Error(`[module runner] Failed to load "${url}"${importer ? ` imported from ${importer}` : ""}`);
1229
- }
1230
- let createImportMeta = this.options.createImportMeta ?? createDefaultImportMeta, modulePath = cleanUrl(file || moduleId), href = posixPathToFileHref(modulePath), meta = await createImportMeta(modulePath), exports = Object.create(null);
1231
- Object.defineProperty(exports, Symbol.toStringTag, {
1232
- value: "Module",
1233
- enumerable: !1,
1234
- configurable: !1
1235
- }), mod.exports = exports;
1236
- let hotContext;
1237
- this.hmrClient && Object.defineProperty(meta, "hot", {
1238
- enumerable: !0,
1239
- get: () => {
1240
- if (!this.hmrClient) throw Error("[module runner] HMR client was closed.");
1241
- return this.debug?.("[module runner] creating hmr context for", mod.url), hotContext ||= new HMRContext(this.hmrClient, mod.url), hotContext;
1242
- },
1243
- set: (value) => {
1244
- hotContext = value;
1245
- }
1246
- });
1247
- let context = {
1248
- [ssrImportKey]: request,
1249
- [ssrDynamicImportKey]: dynamicRequest,
1250
- [ssrModuleExportsKey]: exports,
1251
- [ssrExportAllKey]: (obj) => exportAll(exports, obj),
1252
- [ssrExportNameKey]: (name, getter) => Object.defineProperty(exports, name, {
1253
- enumerable: !0,
1254
- configurable: !0,
1255
- get: getter
1256
- }),
1257
- [ssrImportMetaKey]: meta
1258
- };
1259
- return this.debug?.("[module runner] executing", href), await this.evaluator.runInlinedModule(context, code, mod), exports;
1260
- }
1261
- };
1262
- function exportAll(exports, sourceModule) {
1263
- if (exports !== sourceModule && !(isPrimitive(sourceModule) || Array.isArray(sourceModule) || sourceModule instanceof Promise)) {
1264
- for (let key in sourceModule) if (key !== "default" && key !== "__esModule" && !(key in exports)) try {
1265
- Object.defineProperty(exports, key, {
1266
- enumerable: !0,
1267
- configurable: !0,
1268
- get: () => sourceModule[key]
1269
- });
1270
- } catch {}
1271
- }
1272
- }
1273
- //#endregion
1274
- export { ESModulesEvaluator, EvaluatedModules, ModuleRunner, createDefaultImportMeta, createNodeImportMeta, createWebSocketModuleRunnerTransport, normalizeModuleId, ssrDynamicImportKey, ssrExportAllKey, ssrExportNameKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey };