@omnitron-dev/lumen 0.4.12 → 0.4.14

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