@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,1269 +0,0 @@
1
- import "@vite/env";
2
- //#region ../../node_modules/.pnpm/nanoid@5.1.11/node_modules/nanoid/non-secure/index.js
3
- let urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
4
- let nanoid = (size = 21) => {
5
- let id = "";
6
- let i = size | 0;
7
- while (i--) id += urlAlphabet[Math.random() * 64 | 0];
8
- return id;
9
- };
10
- //#endregion
11
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
12
- function _typeof(o) {
13
- "@babel/helpers - typeof";
14
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
15
- return typeof o;
16
- } : function(o) {
17
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
18
- }, _typeof(o);
19
- }
20
- //#endregion
21
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
22
- function toPrimitive(t, r) {
23
- if ("object" != _typeof(t) || !t) return t;
24
- var e = t[Symbol.toPrimitive];
25
- if (void 0 !== e) {
26
- var i = e.call(t, r || "default");
27
- if ("object" != _typeof(i)) return i;
28
- throw new TypeError("@@toPrimitive must return a primitive value.");
29
- }
30
- return ("string" === r ? String : Number)(t);
31
- }
32
- //#endregion
33
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
34
- function toPropertyKey(t) {
35
- var i = toPrimitive(t, "string");
36
- return "symbol" == _typeof(i) ? i : i + "";
37
- }
38
- //#endregion
39
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
40
- function _defineProperty(e, r, t) {
41
- return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
42
- value: t,
43
- enumerable: !0,
44
- configurable: !0,
45
- writable: !0
46
- }) : e[r] = t, e;
47
- }
48
- //#endregion
49
- //#region src/shared/hmr.ts
50
- var HMRContext = class {
51
- constructor(hmrClient, ownerPath) {
52
- this.hmrClient = hmrClient;
53
- this.ownerPath = ownerPath;
54
- _defineProperty(this, "newListeners", void 0);
55
- if (!hmrClient.dataMap.has(ownerPath)) hmrClient.dataMap.set(ownerPath, {});
56
- const mod = hmrClient.hotModulesMap.get(ownerPath);
57
- if (mod) mod.callbacks = [];
58
- const staleListeners = hmrClient.ctxToListenersMap.get(ownerPath);
59
- if (staleListeners) for (const [event, staleFns] of staleListeners) {
60
- const listeners = hmrClient.customListenersMap.get(event);
61
- if (listeners) hmrClient.customListenersMap.set(event, listeners.filter((l) => !staleFns.includes(l)));
62
- }
63
- this.newListeners = /* @__PURE__ */ new Map();
64
- hmrClient.ctxToListenersMap.set(ownerPath, this.newListeners);
65
- }
66
- get data() {
67
- return this.hmrClient.dataMap.get(this.ownerPath);
68
- }
69
- accept(deps, callback) {
70
- if (typeof deps === "function" || !deps) this.acceptDeps([this.ownerPath], ([mod]) => deps?.(mod));
71
- else if (typeof deps === "string") this.acceptDeps([deps], ([mod]) => callback?.(mod));
72
- else if (Array.isArray(deps)) this.acceptDeps(deps, callback);
73
- else throw new Error(`invalid hot.accept() usage.`);
74
- }
75
- acceptExports(_, callback) {
76
- this.acceptDeps([this.ownerPath], ([mod]) => callback?.(mod));
77
- }
78
- dispose(cb) {
79
- this.hmrClient.disposeMap.set(this.ownerPath, cb);
80
- }
81
- prune(cb) {
82
- this.hmrClient.pruneMap.set(this.ownerPath, cb);
83
- }
84
- decline() {}
85
- invalidate(message) {
86
- const firstInvalidatedBy = this.hmrClient.currentFirstInvalidatedBy ?? this.ownerPath;
87
- this.hmrClient.notifyListeners("vite:invalidate", {
88
- path: this.ownerPath,
89
- message,
90
- firstInvalidatedBy
91
- });
92
- this.send("vite:invalidate", {
93
- path: this.ownerPath,
94
- message,
95
- firstInvalidatedBy
96
- });
97
- this.hmrClient.logger.debug(`invalidate ${this.ownerPath}${message ? `: ${message}` : ""}`);
98
- }
99
- on(event, cb) {
100
- const addToMap = (map) => {
101
- const existing = map.get(event) || [];
102
- existing.push(cb);
103
- map.set(event, existing);
104
- };
105
- addToMap(this.hmrClient.customListenersMap);
106
- addToMap(this.newListeners);
107
- }
108
- off(event, cb) {
109
- const removeFromMap = (map) => {
110
- const existing = map.get(event);
111
- if (existing === void 0) return;
112
- const pruned = existing.filter((l) => l !== cb);
113
- if (pruned.length === 0) {
114
- map.delete(event);
115
- return;
116
- }
117
- map.set(event, pruned);
118
- };
119
- removeFromMap(this.hmrClient.customListenersMap);
120
- removeFromMap(this.newListeners);
121
- }
122
- send(event, data) {
123
- this.hmrClient.send({
124
- type: "custom",
125
- event,
126
- data
127
- });
128
- }
129
- acceptDeps(deps, callback = () => {}) {
130
- const mod = this.hmrClient.hotModulesMap.get(this.ownerPath) || {
131
- id: this.ownerPath,
132
- callbacks: []
133
- };
134
- mod.callbacks.push({
135
- deps,
136
- fn: callback
137
- });
138
- this.hmrClient.hotModulesMap.set(this.ownerPath, mod);
139
- }
140
- };
141
- var HMRClient = class {
142
- constructor(logger, transport, importUpdatedModule) {
143
- this.logger = logger;
144
- this.transport = transport;
145
- this.importUpdatedModule = importUpdatedModule;
146
- _defineProperty(this, "hotModulesMap", /* @__PURE__ */ new Map());
147
- _defineProperty(this, "disposeMap", /* @__PURE__ */ new Map());
148
- _defineProperty(this, "pruneMap", /* @__PURE__ */ new Map());
149
- _defineProperty(this, "dataMap", /* @__PURE__ */ new Map());
150
- _defineProperty(this, "customListenersMap", /* @__PURE__ */ new Map());
151
- _defineProperty(this, "ctxToListenersMap", /* @__PURE__ */ new Map());
152
- _defineProperty(this, "currentFirstInvalidatedBy", void 0);
153
- _defineProperty(this, "updateQueue", []);
154
- _defineProperty(this, "pendingUpdateQueue", false);
155
- }
156
- async notifyListeners(event, data) {
157
- const cbs = this.customListenersMap.get(event);
158
- if (cbs) await Promise.allSettled(cbs.map((cb) => cb(data)));
159
- }
160
- send(payload) {
161
- this.transport.send(payload).catch((err) => {
162
- this.logger.error(err);
163
- });
164
- }
165
- clear() {
166
- this.hotModulesMap.clear();
167
- this.disposeMap.clear();
168
- this.pruneMap.clear();
169
- this.dataMap.clear();
170
- this.customListenersMap.clear();
171
- this.ctxToListenersMap.clear();
172
- }
173
- async prunePaths(paths) {
174
- await Promise.all(paths.map((path) => {
175
- const disposer = this.disposeMap.get(path);
176
- if (disposer) return disposer(this.dataMap.get(path));
177
- }));
178
- await Promise.all(paths.map((path) => {
179
- const fn = this.pruneMap.get(path);
180
- if (fn) return fn(this.dataMap.get(path));
181
- }));
182
- }
183
- warnFailedUpdate(err, path) {
184
- if (!(err instanceof Error) || !err.message.includes("fetch")) this.logger.error(err);
185
- this.logger.error(`Failed to reload ${path}. This could be due to syntax errors or importing non-existent modules. (see errors above)`);
186
- }
187
- /**
188
- * buffer multiple hot updates triggered by the same src change
189
- * so that they are invoked in the same order they were sent.
190
- * (otherwise the order may be inconsistent because of the http request round trip)
191
- */
192
- async queueUpdate(payload) {
193
- this.updateQueue.push(this.fetchUpdate(payload));
194
- if (!this.pendingUpdateQueue) {
195
- this.pendingUpdateQueue = true;
196
- await Promise.resolve();
197
- this.pendingUpdateQueue = false;
198
- const loading = [...this.updateQueue];
199
- this.updateQueue = [];
200
- (await Promise.all(loading)).forEach((fn) => fn && fn());
201
- }
202
- }
203
- async fetchUpdate(update) {
204
- const { path, acceptedPath, firstInvalidatedBy } = update;
205
- const mod = this.hotModulesMap.get(path);
206
- if (!mod) return;
207
- let fetchedModule;
208
- const isSelfUpdate = path === acceptedPath;
209
- const qualifiedCallbacks = mod.callbacks.filter(({ deps }) => deps.includes(acceptedPath));
210
- if (isSelfUpdate || qualifiedCallbacks.length > 0) {
211
- const disposer = this.disposeMap.get(acceptedPath);
212
- if (disposer) await disposer(this.dataMap.get(acceptedPath));
213
- try {
214
- fetchedModule = await this.importUpdatedModule(update);
215
- } catch (e) {
216
- this.warnFailedUpdate(e, acceptedPath);
217
- }
218
- }
219
- return () => {
220
- try {
221
- this.currentFirstInvalidatedBy = firstInvalidatedBy;
222
- for (const { deps, fn } of qualifiedCallbacks) fn(deps.map((dep) => dep === acceptedPath ? fetchedModule : void 0));
223
- const loggedPath = isSelfUpdate ? path : `${acceptedPath} via ${path}`;
224
- this.logger.debug(`hot updated: ${loggedPath}`);
225
- } finally {
226
- this.currentFirstInvalidatedBy = void 0;
227
- }
228
- };
229
- }
230
- };
231
- //#endregion
232
- //#region src/shared/constants.ts
233
- let SOURCEMAPPING_URL = "sourceMa";
234
- SOURCEMAPPING_URL += "ppingURL";
235
- typeof process !== "undefined" && process.platform;
236
- (async function() {}).constructor;
237
- function promiseWithResolvers() {
238
- let resolve;
239
- let reject;
240
- return {
241
- promise: new Promise((_resolve, _reject) => {
242
- resolve = _resolve;
243
- reject = _reject;
244
- }),
245
- resolve,
246
- reject
247
- };
248
- }
249
- //#endregion
250
- //#region src/shared/moduleRunnerTransport.ts
251
- function reviveInvokeError(e) {
252
- const error = new Error(e.message || "Unknown invoke error");
253
- Object.assign(error, e, { runnerError: /* @__PURE__ */ new Error("RunnerError") });
254
- return error;
255
- }
256
- const createInvokeableTransport = (transport) => {
257
- if (transport.invoke) return {
258
- ...transport,
259
- async invoke(name, data) {
260
- const result = await transport.invoke({
261
- type: "custom",
262
- event: "vite:invoke",
263
- data: {
264
- id: "send",
265
- name,
266
- data
267
- }
268
- });
269
- if ("error" in result) throw reviveInvokeError(result.error);
270
- return result.result;
271
- }
272
- };
273
- if (!transport.send || !transport.connect) throw new Error("transport must implement send and connect when invoke is not implemented");
274
- const rpcPromises = /* @__PURE__ */ new Map();
275
- return {
276
- ...transport,
277
- connect({ onMessage, onDisconnection }) {
278
- return transport.connect({
279
- onMessage(payload) {
280
- if (payload.type === "custom" && payload.event === "vite:invoke") {
281
- const data = payload.data;
282
- if (data.id.startsWith("response:")) {
283
- const invokeId = data.id.slice(9);
284
- const promise = rpcPromises.get(invokeId);
285
- if (!promise) return;
286
- if (promise.timeoutId) clearTimeout(promise.timeoutId);
287
- rpcPromises.delete(invokeId);
288
- const { error, result } = data.data;
289
- if (error) promise.reject(error);
290
- else promise.resolve(result);
291
- return;
292
- }
293
- }
294
- onMessage(payload);
295
- },
296
- onDisconnection
297
- });
298
- },
299
- disconnect() {
300
- rpcPromises.forEach((promise) => {
301
- promise.reject(/* @__PURE__ */ new Error(`transport was disconnected, cannot call ${JSON.stringify(promise.name)}`));
302
- });
303
- rpcPromises.clear();
304
- return transport.disconnect?.();
305
- },
306
- send(data) {
307
- return transport.send(data);
308
- },
309
- async invoke(name, data) {
310
- const promiseId = nanoid();
311
- const wrappedData = {
312
- type: "custom",
313
- event: "vite:invoke",
314
- data: {
315
- name,
316
- id: `send:${promiseId}`,
317
- data
318
- }
319
- };
320
- const sendPromise = transport.send(wrappedData);
321
- const { promise, resolve, reject } = promiseWithResolvers();
322
- const timeout = transport.timeout ?? 6e4;
323
- let timeoutId;
324
- if (timeout > 0) {
325
- timeoutId = setTimeout(() => {
326
- rpcPromises.delete(promiseId);
327
- reject(/* @__PURE__ */ new Error(`transport invoke timed out after ${timeout}ms (data: ${JSON.stringify(wrappedData)})`));
328
- }, timeout);
329
- timeoutId?.unref?.();
330
- }
331
- rpcPromises.set(promiseId, {
332
- resolve,
333
- reject,
334
- name,
335
- timeoutId
336
- });
337
- if (sendPromise) sendPromise.catch((err) => {
338
- clearTimeout(timeoutId);
339
- rpcPromises.delete(promiseId);
340
- reject(err);
341
- });
342
- try {
343
- return await promise;
344
- } catch (err) {
345
- throw reviveInvokeError(err);
346
- }
347
- }
348
- };
349
- };
350
- const normalizeModuleRunnerTransport = (transport) => {
351
- const invokeableTransport = createInvokeableTransport(transport);
352
- let isConnected = !invokeableTransport.connect;
353
- let connectingPromise;
354
- return {
355
- ...transport,
356
- ...invokeableTransport.connect ? { async connect(onMessage) {
357
- if (isConnected) return;
358
- if (connectingPromise) {
359
- await connectingPromise;
360
- return;
361
- }
362
- const maybePromise = invokeableTransport.connect({
363
- onMessage: onMessage ?? (() => {}),
364
- onDisconnection() {
365
- isConnected = false;
366
- }
367
- });
368
- if (maybePromise) {
369
- connectingPromise = maybePromise;
370
- await connectingPromise;
371
- connectingPromise = void 0;
372
- }
373
- isConnected = true;
374
- } } : {},
375
- ...invokeableTransport.disconnect ? { async disconnect() {
376
- if (!isConnected) return;
377
- if (connectingPromise) await connectingPromise;
378
- isConnected = false;
379
- await invokeableTransport.disconnect();
380
- } } : {},
381
- async send(data) {
382
- if (!invokeableTransport.send) return;
383
- if (!isConnected) if (connectingPromise) await connectingPromise;
384
- else throw new SendBeforeConnectError("send was called before connect");
385
- await invokeableTransport.send(data);
386
- },
387
- async invoke(name, data) {
388
- if (!isConnected) if (connectingPromise) await connectingPromise;
389
- else throw new SendBeforeConnectError("invoke was called before connect");
390
- return invokeableTransport.invoke(name, data);
391
- }
392
- };
393
- };
394
- var SendBeforeConnectError = class extends Error {
395
- constructor(message) {
396
- super(message);
397
- this.name = "SendBeforeConnectError";
398
- }
399
- };
400
- const createWebSocketModuleRunnerTransport = (options) => {
401
- const pingInterval = options.pingInterval ?? 3e4;
402
- let ws;
403
- let pingIntervalId;
404
- return {
405
- async connect({ onMessage, onDisconnection }) {
406
- const socket = options.createConnection();
407
- socket.addEventListener("message", ({ data }) => {
408
- onMessage(JSON.parse(data));
409
- });
410
- let isOpened = socket.readyState === socket.OPEN;
411
- if (!isOpened) await new Promise((resolve, reject) => {
412
- socket.addEventListener("open", () => {
413
- isOpened = true;
414
- resolve();
415
- }, { once: true });
416
- socket.addEventListener("close", () => {
417
- if (!isOpened) {
418
- reject(/* @__PURE__ */ new Error("WebSocket closed without opened."));
419
- return;
420
- }
421
- onMessage({
422
- type: "custom",
423
- event: "vite:ws:disconnect",
424
- data: { webSocket: socket }
425
- });
426
- onDisconnection();
427
- });
428
- });
429
- onMessage({
430
- type: "custom",
431
- event: "vite:ws:connect",
432
- data: { webSocket: socket }
433
- });
434
- ws = socket;
435
- pingIntervalId = setInterval(() => {
436
- if (socket.readyState === socket.OPEN) socket.send(JSON.stringify({ type: "ping" }));
437
- }, pingInterval);
438
- },
439
- disconnect() {
440
- clearInterval(pingIntervalId);
441
- ws?.close();
442
- },
443
- send(data) {
444
- ws.send(JSON.stringify(data));
445
- }
446
- };
447
- };
448
- //#endregion
449
- //#region src/shared/hmrHandler.ts
450
- function createHMRHandler(handler) {
451
- const queue = new Queue();
452
- return (payload) => queue.enqueue(() => handler(payload));
453
- }
454
- var Queue = class {
455
- constructor() {
456
- _defineProperty(this, "queue", []);
457
- _defineProperty(this, "pending", false);
458
- }
459
- enqueue(promise) {
460
- return new Promise((resolve, reject) => {
461
- this.queue.push({
462
- promise,
463
- resolve,
464
- reject
465
- });
466
- this.dequeue();
467
- });
468
- }
469
- dequeue() {
470
- if (this.pending) return false;
471
- const item = this.queue.shift();
472
- if (!item) return false;
473
- this.pending = true;
474
- item.promise().then(item.resolve).catch(item.reject).finally(() => {
475
- this.pending = false;
476
- this.dequeue();
477
- });
478
- return true;
479
- }
480
- };
481
- //#endregion
482
- //#region src/shared/forwardConsole.ts
483
- function setupForwardConsoleHandler(transport, options, console = globalThis.console) {
484
- if (!options.enabled) return;
485
- async function sendError(type, error) {
486
- await transport.send({
487
- type: "custom",
488
- event: "vite:forward-console",
489
- data: {
490
- type,
491
- data: {
492
- name: error?.name || "Unknown Error",
493
- message: error?.message || String(error),
494
- stack: error?.stack
495
- }
496
- }
497
- });
498
- }
499
- async function sendLog(level, args) {
500
- try {
501
- await transport.send({
502
- type: "custom",
503
- event: "vite:forward-console",
504
- data: {
505
- type: "log",
506
- data: {
507
- level,
508
- message: formatConsoleArgs(args)
509
- }
510
- }
511
- });
512
- } catch (err) {
513
- try {
514
- await sendError("unhandled-rejection", err);
515
- } catch (err) {
516
- if (!(err instanceof SendBeforeConnectError)) originalConsoleError("Failed to send error to Vite server:", err);
517
- }
518
- }
519
- }
520
- const originalConsoleError = console.error;
521
- for (const level of options.logLevels) {
522
- const original = console[level];
523
- if (typeof original !== "function") continue;
524
- console[level] = (...args) => {
525
- original(...args);
526
- sendLog(level, args);
527
- };
528
- }
529
- if (options.unhandledErrors && typeof window !== "undefined") {
530
- window.addEventListener("error", async (event) => {
531
- const error = event.error ?? (event.message ? new Error(event.message) : event);
532
- try {
533
- await sendError("error", error);
534
- } catch (err) {
535
- if (!(err instanceof SendBeforeConnectError)) originalConsoleError("Failed to send error to Vite server:", err);
536
- }
537
- });
538
- window.addEventListener("unhandledrejection", async (event) => {
539
- try {
540
- await sendError("unhandled-rejection", event.reason);
541
- } catch (err) {
542
- if (!(err instanceof SendBeforeConnectError)) originalConsoleError("Failed to send error to Vite server:", err);
543
- }
544
- });
545
- }
546
- }
547
- function formatConsoleArgs(args) {
548
- if (args.length === 0) return "";
549
- if (typeof args[0] !== "string") return args.map((arg) => stringifyConsoleArg(arg)).join(" ");
550
- const len = args.length;
551
- let i = 1;
552
- let message = args[0].replace(/%[sdjifoOc%]/g, (specifier) => {
553
- if (specifier === "%%") return "%";
554
- if (i >= len) return specifier;
555
- const arg = args[i++];
556
- switch (specifier) {
557
- case "%s":
558
- if (typeof arg === "bigint") return `${arg.toString()}n`;
559
- return typeof arg === "object" && arg != null ? stringifyConsoleArg(arg) : String(arg);
560
- case "%d":
561
- if (typeof arg === "bigint") return `${arg.toString()}n`;
562
- if (typeof arg === "symbol") return "NaN";
563
- return Number(arg).toString();
564
- case "%i":
565
- if (typeof arg === "bigint") return `${arg.toString()}n`;
566
- return Number.parseInt(String(arg), 10).toString();
567
- case "%f": return Number.parseFloat(String(arg)).toString();
568
- case "%o":
569
- case "%O": return stringifyConsoleArg(arg);
570
- case "%j": try {
571
- return JSON.stringify(arg) ?? "undefined";
572
- } catch {
573
- return "[Circular]";
574
- }
575
- case "%c": return "";
576
- default: return specifier;
577
- }
578
- });
579
- for (let arg = args[i]; i < len; arg = args[++i]) if (arg == null || typeof arg !== "object") message += ` ${typeof arg === "symbol" ? arg.toString() : String(arg)}`;
580
- else message += ` ${stringifyConsoleArg(arg)}`;
581
- return message;
582
- }
583
- function stringifyConsoleArg(value) {
584
- if (typeof value === "string") return value;
585
- if (typeof value === "number" || typeof value === "boolean" || typeof value === "undefined") return String(value);
586
- if (typeof value === "symbol") return value.toString();
587
- if (typeof value === "function") return value.name ? `[Function: ${value.name}]` : "[Function]";
588
- if (value instanceof Error) return value.stack || `${value.name}: ${value.message}`;
589
- if (typeof value === "bigint") return `${value}n`;
590
- const seen = /* @__PURE__ */ new WeakSet();
591
- try {
592
- return JSON.stringify(value, (_, nested) => {
593
- if (typeof nested === "bigint") return `${nested}n`;
594
- if (nested instanceof Error) return {
595
- name: nested.name,
596
- message: nested.message,
597
- stack: nested.stack
598
- };
599
- if (nested && typeof nested === "object") {
600
- if (seen.has(nested)) return "[Circular]";
601
- seen.add(nested);
602
- }
603
- return nested;
604
- }) ?? String(value);
605
- } catch {
606
- return String(value);
607
- }
608
- }
609
- //#endregion
610
- //#region src/client/overlay.ts
611
- const hmrConfigName = __HMR_CONFIG_NAME__;
612
- const base$1 = __BASE__ || "/";
613
- const cspNonce = "document" in globalThis ? document.querySelector("meta[property=csp-nonce]")?.nonce : void 0;
614
- function h(e, attrs = {}, ...children) {
615
- const elem = document.createElement(e);
616
- for (const [k, v] of Object.entries(attrs)) if (v !== void 0) elem.setAttribute(k, v);
617
- elem.append(...children);
618
- return elem;
619
- }
620
- const templateStyle = `
621
- :host {
622
- position: fixed;
623
- top: 0;
624
- left: 0;
625
- width: 100%;
626
- height: 100%;
627
- z-index: 99999;
628
- --monospace: 'SFMono-Regular', Consolas,
629
- 'Liberation Mono', Menlo, Courier, monospace;
630
- --red: #ff5555;
631
- --yellow: #e2aa53;
632
- --purple: #cfa4ff;
633
- --cyan: #2dd9da;
634
- --dim: #c9c9c9;
635
-
636
- --window-background: #181818;
637
- --window-color: #d8d8d8;
638
- }
639
-
640
- .backdrop {
641
- position: fixed;
642
- z-index: 99999;
643
- top: 0;
644
- left: 0;
645
- width: 100%;
646
- height: 100%;
647
- overflow-y: scroll;
648
- margin: 0;
649
- background: rgba(0, 0, 0, 0.66);
650
- }
651
-
652
- .window {
653
- font-family: var(--monospace);
654
- line-height: 1.5;
655
- max-width: 80vw;
656
- color: var(--window-color);
657
- box-sizing: border-box;
658
- margin: 30px auto;
659
- padding: 2.5vh 4vw;
660
- position: relative;
661
- background: var(--window-background);
662
- border-radius: 6px 6px 8px 8px;
663
- box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);
664
- overflow: hidden;
665
- border-top: 8px solid var(--red);
666
- direction: ltr;
667
- text-align: left;
668
- }
669
-
670
- pre {
671
- font-family: var(--monospace);
672
- font-size: 16px;
673
- margin-top: 0;
674
- margin-bottom: 1em;
675
- overflow-x: scroll;
676
- scrollbar-width: none;
677
- }
678
-
679
- pre::-webkit-scrollbar {
680
- display: none;
681
- }
682
-
683
- pre.frame::-webkit-scrollbar {
684
- display: block;
685
- height: 5px;
686
- }
687
-
688
- pre.frame::-webkit-scrollbar-thumb {
689
- background: #999;
690
- border-radius: 5px;
691
- }
692
-
693
- pre.frame {
694
- scrollbar-width: thin;
695
- }
696
-
697
- .message {
698
- line-height: 1.3;
699
- font-weight: 600;
700
- white-space: pre-wrap;
701
- }
702
-
703
- .message-body {
704
- color: var(--red);
705
- }
706
-
707
- .plugin {
708
- color: var(--purple);
709
- }
710
-
711
- .file {
712
- color: var(--cyan);
713
- margin-bottom: 0;
714
- white-space: pre-wrap;
715
- word-break: break-all;
716
- }
717
-
718
- .frame {
719
- color: var(--yellow);
720
- }
721
-
722
- .stack {
723
- font-size: 13px;
724
- color: var(--dim);
725
- }
726
-
727
- .tip {
728
- font-size: 13px;
729
- color: #999;
730
- border-top: 1px dotted #999;
731
- padding-top: 13px;
732
- line-height: 1.8;
733
- }
734
-
735
- code {
736
- font-size: 13px;
737
- font-family: var(--monospace);
738
- color: var(--yellow);
739
- }
740
-
741
- .file-link {
742
- text-decoration: underline;
743
- cursor: pointer;
744
- }
745
-
746
- kbd {
747
- line-height: 1.5;
748
- font-family: ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
749
- font-size: 0.75rem;
750
- font-weight: 700;
751
- background-color: rgb(38, 40, 44);
752
- color: rgb(166, 167, 171);
753
- padding: 0.15rem 0.3rem;
754
- border-radius: 0.25rem;
755
- border-width: 0.0625rem 0.0625rem 0.1875rem;
756
- border-style: solid;
757
- border-color: rgb(54, 57, 64);
758
- border-image: initial;
759
- }
760
- `;
761
- const createTemplate = () => h("div", {
762
- class: "backdrop",
763
- part: "backdrop"
764
- }, h("div", {
765
- class: "window",
766
- part: "window"
767
- }, h("pre", {
768
- class: "message",
769
- part: "message"
770
- }, h("span", {
771
- class: "plugin",
772
- part: "plugin"
773
- }), h("span", {
774
- class: "message-body",
775
- part: "message-body"
776
- })), h("pre", {
777
- class: "file",
778
- part: "file"
779
- }), h("pre", {
780
- class: "frame",
781
- part: "frame"
782
- }), h("pre", {
783
- class: "stack",
784
- part: "stack"
785
- }), h("div", {
786
- class: "tip",
787
- part: "tip"
788
- }, "Click outside, press ", h("kbd", {}, "Esc"), " key, or fix the code to dismiss.", h("br"), "You can also disable this overlay by setting ", h("code", { part: "config-option-name" }, "server.hmr.overlay"), " to ", h("code", { part: "config-option-value" }, "false"), " in ", h("code", { part: "config-file-name" }, hmrConfigName), ".")), h("style", { nonce: cspNonce }, templateStyle));
789
- const fileRE = /(?:file:\/\/)?(?:[a-zA-Z]:\\|\/).*?:\d+:\d+/g;
790
- const codeframeRE = /^(?:>?\s*\d+\s+\|.*|\s+\|\s*\^.*)\r?\n/gm;
791
- const { HTMLElement = class {} } = globalThis;
792
- var ErrorOverlay = class extends HTMLElement {
793
- constructor(err, links = true) {
794
- super();
795
- this.root = this.attachShadow({ mode: "open" });
796
- this.root.appendChild(createTemplate());
797
- codeframeRE.lastIndex = 0;
798
- const hasFrame = err.frame && codeframeRE.test(err.frame);
799
- const message = hasFrame ? err.message.replace(codeframeRE, "") : err.message;
800
- if (err.plugin) this.text(".plugin", `[plugin:${err.plugin}] `);
801
- this.text(".message-body", message.trim());
802
- const [file] = (err.loc?.file || err.id || "unknown file").split(`?`);
803
- if (err.loc) this.text(".file", `${file}:${err.loc.line}:${err.loc.column}`, links);
804
- else if (err.id) this.text(".file", file);
805
- if (hasFrame) this.text(".frame", err.frame.trim());
806
- this.text(".stack", err.stack, links);
807
- this.root.querySelector(".window").addEventListener("click", (e) => {
808
- e.stopPropagation();
809
- });
810
- this.addEventListener("click", () => {
811
- this.close();
812
- });
813
- this.closeOnEsc = (e) => {
814
- if (e.key === "Escape" || e.code === "Escape") this.close();
815
- };
816
- document.addEventListener("keydown", this.closeOnEsc);
817
- }
818
- text(selector, text, linkFiles = false) {
819
- const el = this.root.querySelector(selector);
820
- if (!linkFiles) el.textContent = text;
821
- else {
822
- let curIndex = 0;
823
- let match;
824
- fileRE.lastIndex = 0;
825
- while (match = fileRE.exec(text)) {
826
- const { 0: file, index } = match;
827
- const frag = text.slice(curIndex, index);
828
- el.appendChild(document.createTextNode(frag));
829
- const link = document.createElement("a");
830
- link.textContent = file;
831
- link.className = "file-link";
832
- link.onclick = () => {
833
- fetch(new URL(`${base$1}__open-in-editor?file=${encodeURIComponent(file)}`, import.meta.url));
834
- };
835
- el.appendChild(link);
836
- curIndex += frag.length + file.length;
837
- }
838
- if (curIndex < text.length) el.appendChild(document.createTextNode(text.slice(curIndex)));
839
- }
840
- }
841
- close() {
842
- this.parentNode?.removeChild(this);
843
- document.removeEventListener("keydown", this.closeOnEsc);
844
- }
845
- };
846
- const overlayId = "vite-error-overlay";
847
- const { customElements } = globalThis;
848
- if (customElements && !customElements.get("vite-error-overlay")) customElements.define(overlayId, ErrorOverlay);
849
- //#endregion
850
- //#region src/client/client.ts
851
- console.debug("[vite] connecting...");
852
- const importMetaUrl = new URL(import.meta.url);
853
- const serverHost = __SERVER_HOST__;
854
- const socketProtocol = __HMR_PROTOCOL__ || (importMetaUrl.protocol === "https:" ? "wss" : "ws");
855
- const hmrPort = __HMR_PORT__;
856
- const socketHost = `${__HMR_HOSTNAME__ || importMetaUrl.hostname}:${hmrPort || importMetaUrl.port}${__HMR_BASE__}`;
857
- const directSocketHost = __HMR_DIRECT_TARGET__;
858
- const base = __BASE__ || "/";
859
- const hmrTimeout = __HMR_TIMEOUT__;
860
- const wsToken = __WS_TOKEN__;
861
- const isBundleMode = __BUNDLED_DEV__;
862
- const forwardConsole = __SERVER_FORWARD_CONSOLE__;
863
- const transport = normalizeModuleRunnerTransport((() => {
864
- let wsTransport = createWebSocketModuleRunnerTransport({
865
- createConnection: () => new WebSocket(`${socketProtocol}://${socketHost}?token=${wsToken}`, "vite-hmr"),
866
- pingInterval: hmrTimeout
867
- });
868
- return {
869
- async connect(handlers) {
870
- try {
871
- await wsTransport.connect(handlers);
872
- } catch (e) {
873
- if (!hmrPort) {
874
- wsTransport = createWebSocketModuleRunnerTransport({
875
- createConnection: () => new WebSocket(`${socketProtocol}://${directSocketHost}?token=${wsToken}`, "vite-hmr"),
876
- pingInterval: hmrTimeout
877
- });
878
- try {
879
- await wsTransport.connect(handlers);
880
- console.info("[vite] Direct websocket connection fallback. Check out https://vite.dev/config/server-options.html#server-hmr to remove the previous connection error.");
881
- } catch (e) {
882
- if (e instanceof Error && e.message.includes("WebSocket closed without opened.")) {
883
- const currentScriptHostURL = new URL(import.meta.url);
884
- const currentScriptHost = currentScriptHostURL.host + currentScriptHostURL.pathname.replace(/@vite\/client$/, "");
885
- console.error(`[vite] failed to connect to websocket.
886
- your current setup:
887
- (browser) ${currentScriptHost} <--[HTTP]--> ${serverHost} (server)\n (browser) ${socketHost} <--[WebSocket (failing)]--> ${directSocketHost} (server)\nCheck out your Vite / network configuration and https://vite.dev/config/server-options.html#server-hmr .`);
888
- }
889
- }
890
- return;
891
- }
892
- console.error(`[vite] failed to connect to websocket (${e}). `);
893
- throw e;
894
- }
895
- },
896
- async disconnect() {
897
- await wsTransport.disconnect();
898
- },
899
- send(data) {
900
- wsTransport.send(data);
901
- }
902
- };
903
- })());
904
- let willUnload = false;
905
- if (typeof window !== "undefined") window.addEventListener?.("beforeunload", () => {
906
- willUnload = true;
907
- });
908
- function cleanUrl(pathname) {
909
- const url = new URL(pathname, "http://vite.dev");
910
- url.searchParams.delete("direct");
911
- return url.pathname + url.search;
912
- }
913
- let isFirstUpdate = true;
914
- const outdatedLinkTags = /* @__PURE__ */ new WeakSet();
915
- const debounceReload = (time) => {
916
- let timer;
917
- return () => {
918
- if (timer) {
919
- clearTimeout(timer);
920
- timer = null;
921
- }
922
- timer = setTimeout(() => {
923
- location.reload();
924
- }, time);
925
- };
926
- };
927
- const pageReload = debounceReload(20);
928
- const hmrClient = new HMRClient({
929
- error: (err) => console.error("[vite]", err),
930
- debug: (...msg) => console.debug("[vite]", ...msg)
931
- }, transport, isBundleMode ? async function importUpdatedModule({ url, acceptedPath, isWithinCircularImport }) {
932
- const importPromise = import(base + url).then(() => globalThis.__rolldown_runtime__.loadExports(acceptedPath));
933
- if (isWithinCircularImport) importPromise.catch(() => {
934
- console.info(`[hmr] ${acceptedPath} failed to apply HMR as it's within a circular import. Reloading page to reset the execution order. To debug and break the circular import, you can run \`vite --debug hmr\` to log the circular dependency path if a file change triggered it.`);
935
- pageReload();
936
- });
937
- return await importPromise;
938
- } : async function importUpdatedModule({ acceptedPath, timestamp, explicitImportRequired, isWithinCircularImport }) {
939
- const [acceptedPathWithoutQuery, query] = acceptedPath.split(`?`);
940
- const importPromise = import(
941
- /* @vite-ignore */
942
- base + acceptedPathWithoutQuery.slice(1) + `?${explicitImportRequired ? "import&" : ""}t=${timestamp}${query ? `&${query}` : ""}`
943
- );
944
- if (isWithinCircularImport) importPromise.catch(() => {
945
- console.info(`[hmr] ${acceptedPath} failed to apply HMR as it's within a circular import. Reloading page to reset the execution order. To debug and break the circular import, you can run \`vite --debug hmr\` to log the circular dependency path if a file change triggered it.`);
946
- pageReload();
947
- });
948
- return await importPromise;
949
- });
950
- transport.connect(createHMRHandler(handleMessage));
951
- setupForwardConsoleHandler(transport, forwardConsole);
952
- async function handleMessage(payload) {
953
- switch (payload.type) {
954
- case "connected":
955
- console.debug(`[vite] connected.`);
956
- break;
957
- case "update":
958
- await hmrClient.notifyListeners("vite:beforeUpdate", payload);
959
- if (hasDocument) if (isFirstUpdate && hasErrorOverlay()) {
960
- location.reload();
961
- return;
962
- } else {
963
- if (enableOverlay) clearErrorOverlay();
964
- isFirstUpdate = false;
965
- }
966
- await Promise.all(payload.updates.map(async (update) => {
967
- if (update.type === "js-update") return hmrClient.queueUpdate(update);
968
- const { path, timestamp } = update;
969
- const searchUrl = cleanUrl(path);
970
- const el = Array.from(document.querySelectorAll("link")).find((e) => !outdatedLinkTags.has(e) && cleanUrl(e.href).includes(searchUrl));
971
- if (!el) return;
972
- const newPath = `${base}${searchUrl.slice(1)}${searchUrl.includes("?") ? "&" : "?"}t=${timestamp}`;
973
- return new Promise((resolve) => {
974
- const newLinkTag = el.cloneNode();
975
- newLinkTag.href = new URL(newPath, el.href).href;
976
- const removeOldEl = () => {
977
- el.remove();
978
- console.debug(`[vite] css hot updated: ${searchUrl}`);
979
- resolve();
980
- };
981
- newLinkTag.addEventListener("load", removeOldEl);
982
- newLinkTag.addEventListener("error", removeOldEl);
983
- outdatedLinkTags.add(el);
984
- el.after(newLinkTag);
985
- });
986
- }));
987
- await hmrClient.notifyListeners("vite:afterUpdate", payload);
988
- break;
989
- case "custom":
990
- await hmrClient.notifyListeners(payload.event, payload.data);
991
- if (payload.event === "vite:ws:disconnect") {
992
- if (hasDocument && !willUnload) {
993
- console.log(`[vite] server connection lost. Polling for restart...`);
994
- const socket = payload.data.webSocket;
995
- const url = new URL(socket.url);
996
- url.search = "";
997
- await waitForSuccessfulPing(url.href);
998
- location.reload();
999
- }
1000
- }
1001
- break;
1002
- case "full-reload":
1003
- await hmrClient.notifyListeners("vite:beforeFullReload", payload);
1004
- if (hasDocument) if (payload.path && payload.path.endsWith(".html")) {
1005
- const pagePath = decodeURI(location.pathname);
1006
- const payloadPath = base + payload.path.slice(1);
1007
- if (pagePath === payloadPath || payload.path === "/index.html" || pagePath.endsWith("/") && pagePath + "index.html" === payloadPath) pageReload();
1008
- return;
1009
- } else pageReload();
1010
- break;
1011
- case "prune":
1012
- await hmrClient.notifyListeners("vite:beforePrune", payload);
1013
- await hmrClient.prunePaths(payload.paths);
1014
- break;
1015
- case "error":
1016
- await hmrClient.notifyListeners("vite:error", payload);
1017
- if (hasDocument) {
1018
- const err = payload.err;
1019
- if (enableOverlay) createErrorOverlay(err);
1020
- else console.error(`[vite] Internal Server Error\n${err.message}\n${err.stack}`);
1021
- }
1022
- break;
1023
- case "ping": break;
1024
- default: return payload;
1025
- }
1026
- }
1027
- const enableOverlay = __HMR_ENABLE_OVERLAY__;
1028
- const hasDocument = "document" in globalThis;
1029
- function createErrorOverlay(err) {
1030
- clearErrorOverlay();
1031
- const { customElements } = globalThis;
1032
- if (customElements) {
1033
- const ErrorOverlayConstructor = customElements.get(overlayId);
1034
- document.body.appendChild(new ErrorOverlayConstructor(err));
1035
- }
1036
- }
1037
- function clearErrorOverlay() {
1038
- document.querySelectorAll(overlayId).forEach((n) => n.close());
1039
- }
1040
- function hasErrorOverlay() {
1041
- return document.querySelectorAll(overlayId).length;
1042
- }
1043
- function waitForSuccessfulPing(socketUrl) {
1044
- if (typeof SharedWorker === "undefined") {
1045
- const visibilityManager = {
1046
- currentState: document.visibilityState,
1047
- listeners: /* @__PURE__ */ new Set()
1048
- };
1049
- const onVisibilityChange = () => {
1050
- visibilityManager.currentState = document.visibilityState;
1051
- for (const listener of visibilityManager.listeners) listener(visibilityManager.currentState);
1052
- };
1053
- document.addEventListener("visibilitychange", onVisibilityChange);
1054
- return waitForSuccessfulPingInternal(socketUrl, visibilityManager);
1055
- }
1056
- const blob = new Blob([
1057
- "\"use strict\";",
1058
- `const waitForSuccessfulPingInternal = ${waitForSuccessfulPingInternal.toString()};`,
1059
- `const fn = ${pingWorkerContentMain.toString()};`,
1060
- `fn(${JSON.stringify(socketUrl)})`
1061
- ], { type: "application/javascript" });
1062
- const objURL = URL.createObjectURL(blob);
1063
- const sharedWorker = new SharedWorker(objURL);
1064
- return new Promise((resolve, reject) => {
1065
- const onVisibilityChange = () => {
1066
- sharedWorker.port.postMessage({ visibility: document.visibilityState });
1067
- };
1068
- document.addEventListener("visibilitychange", onVisibilityChange);
1069
- sharedWorker.port.addEventListener("message", (event) => {
1070
- document.removeEventListener("visibilitychange", onVisibilityChange);
1071
- sharedWorker.port.close();
1072
- const data = event.data;
1073
- if (data.type === "error") {
1074
- reject(data.error);
1075
- return;
1076
- }
1077
- resolve();
1078
- });
1079
- onVisibilityChange();
1080
- sharedWorker.port.start();
1081
- });
1082
- }
1083
- function pingWorkerContentMain(socketUrl) {
1084
- self.addEventListener("connect", (_event) => {
1085
- const port = _event.ports[0];
1086
- if (!socketUrl) {
1087
- port.postMessage({
1088
- type: "error",
1089
- error: /* @__PURE__ */ new Error("socketUrl not found")
1090
- });
1091
- return;
1092
- }
1093
- const visibilityManager = {
1094
- currentState: "visible",
1095
- listeners: /* @__PURE__ */ new Set()
1096
- };
1097
- port.addEventListener("message", (event) => {
1098
- const { visibility } = event.data;
1099
- visibilityManager.currentState = visibility;
1100
- console.debug("[vite] new window visibility", visibility);
1101
- for (const listener of visibilityManager.listeners) listener(visibility);
1102
- });
1103
- port.start();
1104
- console.debug("[vite] connected from window");
1105
- waitForSuccessfulPingInternal(socketUrl, visibilityManager).then(() => {
1106
- console.debug("[vite] ping successful");
1107
- try {
1108
- port.postMessage({ type: "success" });
1109
- } catch (error) {
1110
- port.postMessage({
1111
- type: "error",
1112
- error
1113
- });
1114
- }
1115
- }, (error) => {
1116
- console.debug("[vite] error happened", error);
1117
- try {
1118
- port.postMessage({
1119
- type: "error",
1120
- error
1121
- });
1122
- } catch (error) {
1123
- port.postMessage({
1124
- type: "error",
1125
- error
1126
- });
1127
- }
1128
- });
1129
- });
1130
- }
1131
- async function waitForSuccessfulPingInternal(socketUrl, visibilityManager, ms = 1e3) {
1132
- function wait(ms) {
1133
- return new Promise((resolve) => setTimeout(resolve, ms));
1134
- }
1135
- async function ping() {
1136
- try {
1137
- const socket = new WebSocket(socketUrl, "vite-ping");
1138
- return new Promise((resolve) => {
1139
- function onOpen() {
1140
- resolve(true);
1141
- close();
1142
- }
1143
- function onError() {
1144
- resolve(false);
1145
- close();
1146
- }
1147
- function close() {
1148
- socket.removeEventListener("open", onOpen);
1149
- socket.removeEventListener("error", onError);
1150
- socket.close();
1151
- }
1152
- socket.addEventListener("open", onOpen);
1153
- socket.addEventListener("error", onError);
1154
- });
1155
- } catch {
1156
- return false;
1157
- }
1158
- }
1159
- function waitForWindowShow(visibilityManager) {
1160
- return new Promise((resolve) => {
1161
- const onChange = (newVisibility) => {
1162
- if (newVisibility === "visible") {
1163
- resolve();
1164
- visibilityManager.listeners.delete(onChange);
1165
- }
1166
- };
1167
- visibilityManager.listeners.add(onChange);
1168
- });
1169
- }
1170
- if (await ping()) return;
1171
- await wait(ms);
1172
- while (true) if (visibilityManager.currentState === "visible") {
1173
- if (await ping()) break;
1174
- await wait(ms);
1175
- } else await waitForWindowShow(visibilityManager);
1176
- }
1177
- const sheetsMap = /* @__PURE__ */ new Map();
1178
- const linkSheetsMap = /* @__PURE__ */ new Map();
1179
- if ("document" in globalThis) {
1180
- document.querySelectorAll("style[data-vite-dev-id]").forEach((el) => {
1181
- sheetsMap.set(el.getAttribute("data-vite-dev-id"), el);
1182
- });
1183
- document.querySelectorAll("link[rel=\"stylesheet\"][data-vite-dev-id]").forEach((el) => {
1184
- linkSheetsMap.set(el.getAttribute("data-vite-dev-id"), el);
1185
- });
1186
- }
1187
- let lastInsertedStyle;
1188
- function updateStyle(id, content) {
1189
- if (linkSheetsMap.has(id)) return;
1190
- let style = sheetsMap.get(id);
1191
- if (!style) {
1192
- style = document.createElement("style");
1193
- style.setAttribute("type", "text/css");
1194
- style.setAttribute("data-vite-dev-id", id);
1195
- style.textContent = content;
1196
- if (cspNonce) style.setAttribute("nonce", cspNonce);
1197
- if (!lastInsertedStyle) {
1198
- document.head.appendChild(style);
1199
- setTimeout(() => {
1200
- lastInsertedStyle = void 0;
1201
- }, 0);
1202
- } else lastInsertedStyle.insertAdjacentElement("afterend", style);
1203
- lastInsertedStyle = style;
1204
- } else style.textContent = content;
1205
- sheetsMap.set(id, style);
1206
- }
1207
- function removeStyle(id) {
1208
- if (linkSheetsMap.has(id)) {
1209
- document.querySelectorAll(`link[rel="stylesheet"][data-vite-dev-id="${CSS.escape(id)}"]`).forEach((el) => el.remove());
1210
- linkSheetsMap.delete(id);
1211
- }
1212
- const style = sheetsMap.get(id);
1213
- if (style) {
1214
- document.head.removeChild(style);
1215
- sheetsMap.delete(id);
1216
- }
1217
- }
1218
- function createHotContext(ownerPath) {
1219
- return new HMRContext(hmrClient, ownerPath);
1220
- }
1221
- /**
1222
- * urls here are dynamic import() urls that couldn't be statically analyzed
1223
- */
1224
- function injectQuery(url, queryToInject) {
1225
- if (url[0] !== "." && url[0] !== "/") return url;
1226
- const pathname = url.replace(/[?#].*$/, "");
1227
- const { search, hash } = new URL(url, "http://vite.dev");
1228
- return `${pathname}?${queryToInject}${search ? `&` + search.slice(1) : ""}${hash || ""}`;
1229
- }
1230
- if (isBundleMode && typeof DevRuntime !== "undefined") {
1231
- var _ref;
1232
- class ViteDevRuntime extends DevRuntime {
1233
- createModuleHotContext(moduleId) {
1234
- const ctx = createHotContext(moduleId);
1235
- ctx._internal = {
1236
- updateStyle,
1237
- removeStyle
1238
- };
1239
- return ctx;
1240
- }
1241
- applyUpdates(_boundaries) {}
1242
- }
1243
- const clientId = nanoid();
1244
- transport.send({
1245
- type: "custom",
1246
- event: "vite:module-loaded",
1247
- data: {
1248
- modules: [],
1249
- clientId
1250
- }
1251
- });
1252
- (_ref = globalThis).__rolldown_runtime__ ?? (_ref.__rolldown_runtime__ = new ViteDevRuntime({ send(message) {
1253
- switch (message.type) {
1254
- case "hmr:module-registered":
1255
- transport.send({
1256
- type: "custom",
1257
- event: "vite:module-loaded",
1258
- data: {
1259
- modules: message.modules.slice(),
1260
- clientId
1261
- }
1262
- });
1263
- break;
1264
- default: throw new Error(`Unknown message type: ${JSON.stringify(message)}`);
1265
- }
1266
- } }, clientId));
1267
- }
1268
- //#endregion
1269
- export { ErrorOverlay, createHotContext, injectQuery, removeStyle, updateStyle };