nitro-nightly 3.0.1-20251204-002632-497db05f → 3.0.1-20251209-110208-9b276e11

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 (45) hide show
  1. package/dist/_build/common.mjs +1 -1
  2. package/dist/_build/rolldown.mjs +9 -10
  3. package/dist/_build/rollup.mjs +13 -20
  4. package/dist/_build/vite.build.mjs +12 -14
  5. package/dist/_build/vite.plugin.mjs +11 -11
  6. package/dist/_chunks/{Ddt06bL8.mjs → CycPUgTQ.mjs} +1 -1
  7. package/dist/_chunks/{Dkk4dpNb.mjs → DT-wSyHv.mjs} +1 -1
  8. package/dist/_chunks/{D-63lyig.mjs → DzjzT3Xu.mjs} +1 -1
  9. package/dist/_chunks/{CvxEFBdh.mjs → vCTaGRPD.mjs} +2 -2
  10. package/dist/_libs/@pi0/vite-plugin-fullstack.mjs +1923 -0
  11. package/dist/_libs/@rollup/plugin-commonjs.mjs +3859 -0
  12. package/dist/_libs/{plugin-inject.mjs → @rollup/plugin-inject.mjs} +2 -3
  13. package/dist/_libs/{plugin-node-resolve.mjs → @rollup/plugin-node-resolve.mjs} +424 -5
  14. package/dist/_libs/{plugin-replace.mjs → @rollup/plugin-replace.mjs} +1 -1
  15. package/dist/_libs/estree-walker.mjs +1 -144
  16. package/dist/_libs/tinyglobby.mjs +1 -2
  17. package/dist/_libs/unimport.mjs +3 -4
  18. package/dist/_libs/unwasm.mjs +1 -1
  19. package/dist/_presets.mjs +2 -2
  20. package/dist/builder.mjs +7 -7
  21. package/dist/cli/_chunks/detect-acorn.mjs +2 -2
  22. package/dist/cli/_chunks/dev.mjs +2 -2
  23. package/dist/vite.mjs +12 -14
  24. package/package.json +3 -3
  25. package/dist/_libs/commondir.mjs +0 -22
  26. package/dist/_libs/deepmerge.mjs +0 -86
  27. package/dist/_libs/fdir.mjs +0 -514
  28. package/dist/_libs/function-bind.mjs +0 -63
  29. package/dist/_libs/hasown.mjs +0 -14
  30. package/dist/_libs/is-core-module.mjs +0 -220
  31. package/dist/_libs/is-module.mjs +0 -13
  32. package/dist/_libs/is-reference.mjs +0 -33
  33. package/dist/_libs/js-tokens.mjs +0 -382
  34. package/dist/_libs/magic-string.mjs +0 -939
  35. package/dist/_libs/path-parse.mjs +0 -47
  36. package/dist/_libs/picomatch.mjs +0 -1673
  37. package/dist/_libs/plugin-commonjs.mjs +0 -1491
  38. package/dist/_libs/strip-literal.mjs +0 -51
  39. package/dist/_libs/vite-plugin-fullstack.mjs +0 -561
  40. /package/dist/_chunks/{DJvLZH4H.mjs → Df3_4Pam.mjs} +0 -0
  41. /package/dist/_chunks/{Ddq6HHrM.mjs → dcDd0pkY.mjs} +0 -0
  42. /package/dist/_libs/{gen-mapping.mjs → @jridgewell/gen-mapping.mjs} +0 -0
  43. /package/dist/_libs/{remapping.mjs → @jridgewell/remapping.mjs} +0 -0
  44. /package/dist/_libs/{plugin-alias.mjs → @rollup/plugin-alias.mjs} +0 -0
  45. /package/dist/_libs/{plugin-json.mjs → @rollup/plugin-json.mjs} +0 -0
@@ -0,0 +1,1923 @@
1
+ import { i as __toESM, t as __commonJSMin } from "../../_chunks/QkUO_zA6.mjs";
2
+ import { u as encode } from "../@jridgewell/gen-mapping.mjs";
3
+ import path from "node:path";
4
+ import fs from "node:fs";
5
+ import { fileURLToPath } from "node:url";
6
+ import assert from "node:assert";
7
+ import "srvx/node";
8
+ import { createHash } from "node:crypto";
9
+ import { isCSSRequest, normalizePath } from "vite";
10
+ import assert$1 from "node:assert/strict";
11
+
12
+ //#region node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs
13
+ var BitSet = class BitSet {
14
+ constructor(arg) {
15
+ this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
16
+ }
17
+ add(n$1) {
18
+ this.bits[n$1 >> 5] |= 1 << (n$1 & 31);
19
+ }
20
+ has(n$1) {
21
+ return !!(this.bits[n$1 >> 5] & 1 << (n$1 & 31));
22
+ }
23
+ };
24
+ var Chunk = class Chunk {
25
+ constructor(start, end, content) {
26
+ this.start = start;
27
+ this.end = end;
28
+ this.original = content;
29
+ this.intro = "";
30
+ this.outro = "";
31
+ this.content = content;
32
+ this.storeName = false;
33
+ this.edited = false;
34
+ this.previous = null;
35
+ this.next = null;
36
+ }
37
+ appendLeft(content) {
38
+ this.outro += content;
39
+ }
40
+ appendRight(content) {
41
+ this.intro = this.intro + content;
42
+ }
43
+ clone() {
44
+ const chunk = new Chunk(this.start, this.end, this.original);
45
+ chunk.intro = this.intro;
46
+ chunk.outro = this.outro;
47
+ chunk.content = this.content;
48
+ chunk.storeName = this.storeName;
49
+ chunk.edited = this.edited;
50
+ return chunk;
51
+ }
52
+ contains(index) {
53
+ return this.start < index && index < this.end;
54
+ }
55
+ eachNext(fn) {
56
+ let chunk = this;
57
+ while (chunk) {
58
+ fn(chunk);
59
+ chunk = chunk.next;
60
+ }
61
+ }
62
+ eachPrevious(fn) {
63
+ let chunk = this;
64
+ while (chunk) {
65
+ fn(chunk);
66
+ chunk = chunk.previous;
67
+ }
68
+ }
69
+ edit(content, storeName, contentOnly) {
70
+ this.content = content;
71
+ if (!contentOnly) {
72
+ this.intro = "";
73
+ this.outro = "";
74
+ }
75
+ this.storeName = storeName;
76
+ this.edited = true;
77
+ return this;
78
+ }
79
+ prependLeft(content) {
80
+ this.outro = content + this.outro;
81
+ }
82
+ prependRight(content) {
83
+ this.intro = content + this.intro;
84
+ }
85
+ reset() {
86
+ this.intro = "";
87
+ this.outro = "";
88
+ if (this.edited) {
89
+ this.content = this.original;
90
+ this.storeName = false;
91
+ this.edited = false;
92
+ }
93
+ }
94
+ split(index) {
95
+ const sliceIndex = index - this.start;
96
+ const originalBefore = this.original.slice(0, sliceIndex);
97
+ const originalAfter = this.original.slice(sliceIndex);
98
+ this.original = originalBefore;
99
+ const newChunk = new Chunk(index, this.end, originalAfter);
100
+ newChunk.outro = this.outro;
101
+ this.outro = "";
102
+ this.end = index;
103
+ if (this.edited) {
104
+ newChunk.edit("", false);
105
+ this.content = "";
106
+ } else this.content = originalBefore;
107
+ newChunk.next = this.next;
108
+ if (newChunk.next) newChunk.next.previous = newChunk;
109
+ newChunk.previous = this;
110
+ this.next = newChunk;
111
+ return newChunk;
112
+ }
113
+ toString() {
114
+ return this.intro + this.content + this.outro;
115
+ }
116
+ trimEnd(rx) {
117
+ this.outro = this.outro.replace(rx, "");
118
+ if (this.outro.length) return true;
119
+ const trimmed = this.content.replace(rx, "");
120
+ if (trimmed.length) {
121
+ if (trimmed !== this.content) {
122
+ this.split(this.start + trimmed.length).edit("", void 0, true);
123
+ if (this.edited) this.edit(trimmed, this.storeName, true);
124
+ }
125
+ return true;
126
+ } else {
127
+ this.edit("", void 0, true);
128
+ this.intro = this.intro.replace(rx, "");
129
+ if (this.intro.length) return true;
130
+ }
131
+ }
132
+ trimStart(rx) {
133
+ this.intro = this.intro.replace(rx, "");
134
+ if (this.intro.length) return true;
135
+ const trimmed = this.content.replace(rx, "");
136
+ if (trimmed.length) {
137
+ if (trimmed !== this.content) {
138
+ const newChunk = this.split(this.end - trimmed.length);
139
+ if (this.edited) newChunk.edit(trimmed, this.storeName, true);
140
+ this.edit("", void 0, true);
141
+ }
142
+ return true;
143
+ } else {
144
+ this.edit("", void 0, true);
145
+ this.outro = this.outro.replace(rx, "");
146
+ if (this.outro.length) return true;
147
+ }
148
+ }
149
+ };
150
+ function getBtoa() {
151
+ if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
152
+ else if (typeof Buffer === "function") return (str) => Buffer.from(str, "utf-8").toString("base64");
153
+ else return () => {
154
+ throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
155
+ };
156
+ }
157
+ const btoa = /* @__PURE__ */ getBtoa();
158
+ var SourceMap = class {
159
+ constructor(properties) {
160
+ this.version = 3;
161
+ this.file = properties.file;
162
+ this.sources = properties.sources;
163
+ this.sourcesContent = properties.sourcesContent;
164
+ this.names = properties.names;
165
+ this.mappings = encode(properties.mappings);
166
+ if (typeof properties.x_google_ignoreList !== "undefined") this.x_google_ignoreList = properties.x_google_ignoreList;
167
+ if (typeof properties.debugId !== "undefined") this.debugId = properties.debugId;
168
+ }
169
+ toString() {
170
+ return JSON.stringify(this);
171
+ }
172
+ toUrl() {
173
+ return "data:application/json;charset=utf-8;base64," + btoa(this.toString());
174
+ }
175
+ };
176
+ function guessIndent(code) {
177
+ const lines = code.split("\n");
178
+ const tabbed = lines.filter((line) => /^\t+/.test(line));
179
+ const spaced = lines.filter((line) => /^ {2,}/.test(line));
180
+ if (tabbed.length === 0 && spaced.length === 0) return null;
181
+ if (tabbed.length >= spaced.length) return " ";
182
+ const min = spaced.reduce((previous, current) => {
183
+ const numSpaces = /^ +/.exec(current)[0].length;
184
+ return Math.min(numSpaces, previous);
185
+ }, Infinity);
186
+ return new Array(min + 1).join(" ");
187
+ }
188
+ function getRelativePath(from, to) {
189
+ const fromParts = from.split(/[/\\]/);
190
+ const toParts = to.split(/[/\\]/);
191
+ fromParts.pop();
192
+ while (fromParts[0] === toParts[0]) {
193
+ fromParts.shift();
194
+ toParts.shift();
195
+ }
196
+ if (fromParts.length) {
197
+ let i = fromParts.length;
198
+ while (i--) fromParts[i] = "..";
199
+ }
200
+ return fromParts.concat(toParts).join("/");
201
+ }
202
+ const toString = Object.prototype.toString;
203
+ function isObject(thing) {
204
+ return toString.call(thing) === "[object Object]";
205
+ }
206
+ function getLocator(source) {
207
+ const originalLines = source.split("\n");
208
+ const lineOffsets = [];
209
+ for (let i = 0, pos = 0; i < originalLines.length; i++) {
210
+ lineOffsets.push(pos);
211
+ pos += originalLines[i].length + 1;
212
+ }
213
+ return function locate(index) {
214
+ let i = 0;
215
+ let j = lineOffsets.length;
216
+ while (i < j) {
217
+ const m = i + j >> 1;
218
+ if (index < lineOffsets[m]) j = m;
219
+ else i = m + 1;
220
+ }
221
+ const line = i - 1;
222
+ return {
223
+ line,
224
+ column: index - lineOffsets[line]
225
+ };
226
+ };
227
+ }
228
+ const wordRegex = /\w/;
229
+ var Mappings = class {
230
+ constructor(hires) {
231
+ this.hires = hires;
232
+ this.generatedCodeLine = 0;
233
+ this.generatedCodeColumn = 0;
234
+ this.raw = [];
235
+ this.rawSegments = this.raw[this.generatedCodeLine] = [];
236
+ this.pending = null;
237
+ }
238
+ addEdit(sourceIndex, content, loc, nameIndex) {
239
+ if (content.length) {
240
+ const contentLengthMinusOne = content.length - 1;
241
+ let contentLineEnd = content.indexOf("\n", 0);
242
+ let previousContentLineEnd = -1;
243
+ while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
244
+ const segment$1 = [
245
+ this.generatedCodeColumn,
246
+ sourceIndex,
247
+ loc.line,
248
+ loc.column
249
+ ];
250
+ if (nameIndex >= 0) segment$1.push(nameIndex);
251
+ this.rawSegments.push(segment$1);
252
+ this.generatedCodeLine += 1;
253
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
254
+ this.generatedCodeColumn = 0;
255
+ previousContentLineEnd = contentLineEnd;
256
+ contentLineEnd = content.indexOf("\n", contentLineEnd + 1);
257
+ }
258
+ const segment = [
259
+ this.generatedCodeColumn,
260
+ sourceIndex,
261
+ loc.line,
262
+ loc.column
263
+ ];
264
+ if (nameIndex >= 0) segment.push(nameIndex);
265
+ this.rawSegments.push(segment);
266
+ this.advance(content.slice(previousContentLineEnd + 1));
267
+ } else if (this.pending) {
268
+ this.rawSegments.push(this.pending);
269
+ this.advance(content);
270
+ }
271
+ this.pending = null;
272
+ }
273
+ addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
274
+ let originalCharIndex = chunk.start;
275
+ let first = true;
276
+ let charInHiresBoundary = false;
277
+ while (originalCharIndex < chunk.end) {
278
+ if (original[originalCharIndex] === "\n") {
279
+ loc.line += 1;
280
+ loc.column = 0;
281
+ this.generatedCodeLine += 1;
282
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
283
+ this.generatedCodeColumn = 0;
284
+ first = true;
285
+ charInHiresBoundary = false;
286
+ } else {
287
+ if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
288
+ const segment = [
289
+ this.generatedCodeColumn,
290
+ sourceIndex,
291
+ loc.line,
292
+ loc.column
293
+ ];
294
+ if (this.hires === "boundary") if (wordRegex.test(original[originalCharIndex])) {
295
+ if (!charInHiresBoundary) {
296
+ this.rawSegments.push(segment);
297
+ charInHiresBoundary = true;
298
+ }
299
+ } else {
300
+ this.rawSegments.push(segment);
301
+ charInHiresBoundary = false;
302
+ }
303
+ else this.rawSegments.push(segment);
304
+ }
305
+ loc.column += 1;
306
+ this.generatedCodeColumn += 1;
307
+ first = false;
308
+ }
309
+ originalCharIndex += 1;
310
+ }
311
+ this.pending = null;
312
+ }
313
+ advance(str) {
314
+ if (!str) return;
315
+ const lines = str.split("\n");
316
+ if (lines.length > 1) {
317
+ for (let i = 0; i < lines.length - 1; i++) {
318
+ this.generatedCodeLine++;
319
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
320
+ }
321
+ this.generatedCodeColumn = 0;
322
+ }
323
+ this.generatedCodeColumn += lines[lines.length - 1].length;
324
+ }
325
+ };
326
+ const n = "\n";
327
+ const warned = {
328
+ insertLeft: false,
329
+ insertRight: false,
330
+ storeName: false
331
+ };
332
+ var MagicString = class MagicString {
333
+ constructor(string, options = {}) {
334
+ const chunk = new Chunk(0, string.length, string);
335
+ Object.defineProperties(this, {
336
+ original: {
337
+ writable: true,
338
+ value: string
339
+ },
340
+ outro: {
341
+ writable: true,
342
+ value: ""
343
+ },
344
+ intro: {
345
+ writable: true,
346
+ value: ""
347
+ },
348
+ firstChunk: {
349
+ writable: true,
350
+ value: chunk
351
+ },
352
+ lastChunk: {
353
+ writable: true,
354
+ value: chunk
355
+ },
356
+ lastSearchedChunk: {
357
+ writable: true,
358
+ value: chunk
359
+ },
360
+ byStart: {
361
+ writable: true,
362
+ value: {}
363
+ },
364
+ byEnd: {
365
+ writable: true,
366
+ value: {}
367
+ },
368
+ filename: {
369
+ writable: true,
370
+ value: options.filename
371
+ },
372
+ indentExclusionRanges: {
373
+ writable: true,
374
+ value: options.indentExclusionRanges
375
+ },
376
+ sourcemapLocations: {
377
+ writable: true,
378
+ value: new BitSet()
379
+ },
380
+ storedNames: {
381
+ writable: true,
382
+ value: {}
383
+ },
384
+ indentStr: {
385
+ writable: true,
386
+ value: void 0
387
+ },
388
+ ignoreList: {
389
+ writable: true,
390
+ value: options.ignoreList
391
+ },
392
+ offset: {
393
+ writable: true,
394
+ value: options.offset || 0
395
+ }
396
+ });
397
+ this.byStart[0] = chunk;
398
+ this.byEnd[string.length] = chunk;
399
+ }
400
+ addSourcemapLocation(char) {
401
+ this.sourcemapLocations.add(char);
402
+ }
403
+ append(content) {
404
+ if (typeof content !== "string") throw new TypeError("outro content must be a string");
405
+ this.outro += content;
406
+ return this;
407
+ }
408
+ appendLeft(index, content) {
409
+ index = index + this.offset;
410
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
411
+ this._split(index);
412
+ const chunk = this.byEnd[index];
413
+ if (chunk) chunk.appendLeft(content);
414
+ else this.intro += content;
415
+ return this;
416
+ }
417
+ appendRight(index, content) {
418
+ index = index + this.offset;
419
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
420
+ this._split(index);
421
+ const chunk = this.byStart[index];
422
+ if (chunk) chunk.appendRight(content);
423
+ else this.outro += content;
424
+ return this;
425
+ }
426
+ clone() {
427
+ const cloned = new MagicString(this.original, {
428
+ filename: this.filename,
429
+ offset: this.offset
430
+ });
431
+ let originalChunk = this.firstChunk;
432
+ let clonedChunk = cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone();
433
+ while (originalChunk) {
434
+ cloned.byStart[clonedChunk.start] = clonedChunk;
435
+ cloned.byEnd[clonedChunk.end] = clonedChunk;
436
+ const nextOriginalChunk = originalChunk.next;
437
+ const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
438
+ if (nextClonedChunk) {
439
+ clonedChunk.next = nextClonedChunk;
440
+ nextClonedChunk.previous = clonedChunk;
441
+ clonedChunk = nextClonedChunk;
442
+ }
443
+ originalChunk = nextOriginalChunk;
444
+ }
445
+ cloned.lastChunk = clonedChunk;
446
+ if (this.indentExclusionRanges) cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
447
+ cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
448
+ cloned.intro = this.intro;
449
+ cloned.outro = this.outro;
450
+ return cloned;
451
+ }
452
+ generateDecodedMap(options) {
453
+ options = options || {};
454
+ const sourceIndex = 0;
455
+ const names = Object.keys(this.storedNames);
456
+ const mappings = new Mappings(options.hires);
457
+ const locate = getLocator(this.original);
458
+ if (this.intro) mappings.advance(this.intro);
459
+ this.firstChunk.eachNext((chunk) => {
460
+ const loc = locate(chunk.start);
461
+ if (chunk.intro.length) mappings.advance(chunk.intro);
462
+ if (chunk.edited) mappings.addEdit(sourceIndex, chunk.content, loc, chunk.storeName ? names.indexOf(chunk.original) : -1);
463
+ else mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
464
+ if (chunk.outro.length) mappings.advance(chunk.outro);
465
+ });
466
+ if (this.outro) mappings.advance(this.outro);
467
+ return {
468
+ file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
469
+ sources: [options.source ? getRelativePath(options.file || "", options.source) : options.file || ""],
470
+ sourcesContent: options.includeContent ? [this.original] : void 0,
471
+ names,
472
+ mappings: mappings.raw,
473
+ x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0
474
+ };
475
+ }
476
+ generateMap(options) {
477
+ return new SourceMap(this.generateDecodedMap(options));
478
+ }
479
+ _ensureindentStr() {
480
+ if (this.indentStr === void 0) this.indentStr = guessIndent(this.original);
481
+ }
482
+ _getRawIndentString() {
483
+ this._ensureindentStr();
484
+ return this.indentStr;
485
+ }
486
+ getIndentString() {
487
+ this._ensureindentStr();
488
+ return this.indentStr === null ? " " : this.indentStr;
489
+ }
490
+ indent(indentStr, options) {
491
+ const pattern = /^[^\r\n]/gm;
492
+ if (isObject(indentStr)) {
493
+ options = indentStr;
494
+ indentStr = void 0;
495
+ }
496
+ if (indentStr === void 0) {
497
+ this._ensureindentStr();
498
+ indentStr = this.indentStr || " ";
499
+ }
500
+ if (indentStr === "") return this;
501
+ options = options || {};
502
+ const isExcluded = {};
503
+ if (options.exclude) (typeof options.exclude[0] === "number" ? [options.exclude] : options.exclude).forEach((exclusion) => {
504
+ for (let i = exclusion[0]; i < exclusion[1]; i += 1) isExcluded[i] = true;
505
+ });
506
+ let shouldIndentNextCharacter = options.indentStart !== false;
507
+ const replacer = (match) => {
508
+ if (shouldIndentNextCharacter) return `${indentStr}${match}`;
509
+ shouldIndentNextCharacter = true;
510
+ return match;
511
+ };
512
+ this.intro = this.intro.replace(pattern, replacer);
513
+ let charIndex = 0;
514
+ let chunk = this.firstChunk;
515
+ while (chunk) {
516
+ const end = chunk.end;
517
+ if (chunk.edited) {
518
+ if (!isExcluded[charIndex]) {
519
+ chunk.content = chunk.content.replace(pattern, replacer);
520
+ if (chunk.content.length) shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === "\n";
521
+ }
522
+ } else {
523
+ charIndex = chunk.start;
524
+ while (charIndex < end) {
525
+ if (!isExcluded[charIndex]) {
526
+ const char = this.original[charIndex];
527
+ if (char === "\n") shouldIndentNextCharacter = true;
528
+ else if (char !== "\r" && shouldIndentNextCharacter) {
529
+ shouldIndentNextCharacter = false;
530
+ if (charIndex === chunk.start) chunk.prependRight(indentStr);
531
+ else {
532
+ this._splitChunk(chunk, charIndex);
533
+ chunk = chunk.next;
534
+ chunk.prependRight(indentStr);
535
+ }
536
+ }
537
+ }
538
+ charIndex += 1;
539
+ }
540
+ }
541
+ charIndex = chunk.end;
542
+ chunk = chunk.next;
543
+ }
544
+ this.outro = this.outro.replace(pattern, replacer);
545
+ return this;
546
+ }
547
+ insert() {
548
+ throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)");
549
+ }
550
+ insertLeft(index, content) {
551
+ if (!warned.insertLeft) {
552
+ console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead");
553
+ warned.insertLeft = true;
554
+ }
555
+ return this.appendLeft(index, content);
556
+ }
557
+ insertRight(index, content) {
558
+ if (!warned.insertRight) {
559
+ console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead");
560
+ warned.insertRight = true;
561
+ }
562
+ return this.prependRight(index, content);
563
+ }
564
+ move(start, end, index) {
565
+ start = start + this.offset;
566
+ end = end + this.offset;
567
+ index = index + this.offset;
568
+ if (index >= start && index <= end) throw new Error("Cannot move a selection inside itself");
569
+ this._split(start);
570
+ this._split(end);
571
+ this._split(index);
572
+ const first = this.byStart[start];
573
+ const last = this.byEnd[end];
574
+ const oldLeft = first.previous;
575
+ const oldRight = last.next;
576
+ const newRight = this.byStart[index];
577
+ if (!newRight && last === this.lastChunk) return this;
578
+ const newLeft = newRight ? newRight.previous : this.lastChunk;
579
+ if (oldLeft) oldLeft.next = oldRight;
580
+ if (oldRight) oldRight.previous = oldLeft;
581
+ if (newLeft) newLeft.next = first;
582
+ if (newRight) newRight.previous = last;
583
+ if (!first.previous) this.firstChunk = last.next;
584
+ if (!last.next) {
585
+ this.lastChunk = first.previous;
586
+ this.lastChunk.next = null;
587
+ }
588
+ first.previous = newLeft;
589
+ last.next = newRight || null;
590
+ if (!newLeft) this.firstChunk = first;
591
+ if (!newRight) this.lastChunk = last;
592
+ return this;
593
+ }
594
+ overwrite(start, end, content, options) {
595
+ options = options || {};
596
+ return this.update(start, end, content, {
597
+ ...options,
598
+ overwrite: !options.contentOnly
599
+ });
600
+ }
601
+ update(start, end, content, options) {
602
+ start = start + this.offset;
603
+ end = end + this.offset;
604
+ if (typeof content !== "string") throw new TypeError("replacement content must be a string");
605
+ if (this.original.length !== 0) {
606
+ while (start < 0) start += this.original.length;
607
+ while (end < 0) end += this.original.length;
608
+ }
609
+ if (end > this.original.length) throw new Error("end is out of bounds");
610
+ if (start === end) throw new Error("Cannot overwrite a zero-length range – use appendLeft or prependRight instead");
611
+ this._split(start);
612
+ this._split(end);
613
+ if (options === true) {
614
+ if (!warned.storeName) {
615
+ console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string");
616
+ warned.storeName = true;
617
+ }
618
+ options = { storeName: true };
619
+ }
620
+ const storeName = options !== void 0 ? options.storeName : false;
621
+ const overwrite = options !== void 0 ? options.overwrite : false;
622
+ if (storeName) {
623
+ const original = this.original.slice(start, end);
624
+ Object.defineProperty(this.storedNames, original, {
625
+ writable: true,
626
+ value: true,
627
+ enumerable: true
628
+ });
629
+ }
630
+ const first = this.byStart[start];
631
+ const last = this.byEnd[end];
632
+ if (first) {
633
+ let chunk = first;
634
+ while (chunk !== last) {
635
+ if (chunk.next !== this.byStart[chunk.end]) throw new Error("Cannot overwrite across a split point");
636
+ chunk = chunk.next;
637
+ chunk.edit("", false);
638
+ }
639
+ first.edit(content, storeName, !overwrite);
640
+ } else {
641
+ const newChunk = new Chunk(start, end, "").edit(content, storeName);
642
+ last.next = newChunk;
643
+ newChunk.previous = last;
644
+ }
645
+ return this;
646
+ }
647
+ prepend(content) {
648
+ if (typeof content !== "string") throw new TypeError("outro content must be a string");
649
+ this.intro = content + this.intro;
650
+ return this;
651
+ }
652
+ prependLeft(index, content) {
653
+ index = index + this.offset;
654
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
655
+ this._split(index);
656
+ const chunk = this.byEnd[index];
657
+ if (chunk) chunk.prependLeft(content);
658
+ else this.intro = content + this.intro;
659
+ return this;
660
+ }
661
+ prependRight(index, content) {
662
+ index = index + this.offset;
663
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
664
+ this._split(index);
665
+ const chunk = this.byStart[index];
666
+ if (chunk) chunk.prependRight(content);
667
+ else this.outro = content + this.outro;
668
+ return this;
669
+ }
670
+ remove(start, end) {
671
+ start = start + this.offset;
672
+ end = end + this.offset;
673
+ if (this.original.length !== 0) {
674
+ while (start < 0) start += this.original.length;
675
+ while (end < 0) end += this.original.length;
676
+ }
677
+ if (start === end) return this;
678
+ if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
679
+ if (start > end) throw new Error("end must be greater than start");
680
+ this._split(start);
681
+ this._split(end);
682
+ let chunk = this.byStart[start];
683
+ while (chunk) {
684
+ chunk.intro = "";
685
+ chunk.outro = "";
686
+ chunk.edit("");
687
+ chunk = end > chunk.end ? this.byStart[chunk.end] : null;
688
+ }
689
+ return this;
690
+ }
691
+ reset(start, end) {
692
+ start = start + this.offset;
693
+ end = end + this.offset;
694
+ if (this.original.length !== 0) {
695
+ while (start < 0) start += this.original.length;
696
+ while (end < 0) end += this.original.length;
697
+ }
698
+ if (start === end) return this;
699
+ if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
700
+ if (start > end) throw new Error("end must be greater than start");
701
+ this._split(start);
702
+ this._split(end);
703
+ let chunk = this.byStart[start];
704
+ while (chunk) {
705
+ chunk.reset();
706
+ chunk = end > chunk.end ? this.byStart[chunk.end] : null;
707
+ }
708
+ return this;
709
+ }
710
+ lastChar() {
711
+ if (this.outro.length) return this.outro[this.outro.length - 1];
712
+ let chunk = this.lastChunk;
713
+ do {
714
+ if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
715
+ if (chunk.content.length) return chunk.content[chunk.content.length - 1];
716
+ if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
717
+ } while (chunk = chunk.previous);
718
+ if (this.intro.length) return this.intro[this.intro.length - 1];
719
+ return "";
720
+ }
721
+ lastLine() {
722
+ let lineIndex = this.outro.lastIndexOf(n);
723
+ if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
724
+ let lineStr = this.outro;
725
+ let chunk = this.lastChunk;
726
+ do {
727
+ if (chunk.outro.length > 0) {
728
+ lineIndex = chunk.outro.lastIndexOf(n);
729
+ if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
730
+ lineStr = chunk.outro + lineStr;
731
+ }
732
+ if (chunk.content.length > 0) {
733
+ lineIndex = chunk.content.lastIndexOf(n);
734
+ if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
735
+ lineStr = chunk.content + lineStr;
736
+ }
737
+ if (chunk.intro.length > 0) {
738
+ lineIndex = chunk.intro.lastIndexOf(n);
739
+ if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
740
+ lineStr = chunk.intro + lineStr;
741
+ }
742
+ } while (chunk = chunk.previous);
743
+ lineIndex = this.intro.lastIndexOf(n);
744
+ if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
745
+ return this.intro + lineStr;
746
+ }
747
+ slice(start = 0, end = this.original.length - this.offset) {
748
+ start = start + this.offset;
749
+ end = end + this.offset;
750
+ if (this.original.length !== 0) {
751
+ while (start < 0) start += this.original.length;
752
+ while (end < 0) end += this.original.length;
753
+ }
754
+ let result = "";
755
+ let chunk = this.firstChunk;
756
+ while (chunk && (chunk.start > start || chunk.end <= start)) {
757
+ if (chunk.start < end && chunk.end >= end) return result;
758
+ chunk = chunk.next;
759
+ }
760
+ if (chunk && chunk.edited && chunk.start !== start) throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
761
+ const startChunk = chunk;
762
+ while (chunk) {
763
+ if (chunk.intro && (startChunk !== chunk || chunk.start === start)) result += chunk.intro;
764
+ const containsEnd = chunk.start < end && chunk.end >= end;
765
+ if (containsEnd && chunk.edited && chunk.end !== end) throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
766
+ const sliceStart = startChunk === chunk ? start - chunk.start : 0;
767
+ const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
768
+ result += chunk.content.slice(sliceStart, sliceEnd);
769
+ if (chunk.outro && (!containsEnd || chunk.end === end)) result += chunk.outro;
770
+ if (containsEnd) break;
771
+ chunk = chunk.next;
772
+ }
773
+ return result;
774
+ }
775
+ snip(start, end) {
776
+ const clone = this.clone();
777
+ clone.remove(0, start);
778
+ clone.remove(end, clone.original.length);
779
+ return clone;
780
+ }
781
+ _split(index) {
782
+ if (this.byStart[index] || this.byEnd[index]) return;
783
+ let chunk = this.lastSearchedChunk;
784
+ let previousChunk = chunk;
785
+ const searchForward = index > chunk.end;
786
+ while (chunk) {
787
+ if (chunk.contains(index)) return this._splitChunk(chunk, index);
788
+ chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
789
+ if (chunk === previousChunk) return;
790
+ previousChunk = chunk;
791
+ }
792
+ }
793
+ _splitChunk(chunk, index) {
794
+ if (chunk.edited && chunk.content.length) {
795
+ const loc = getLocator(this.original)(index);
796
+ throw new Error(`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`);
797
+ }
798
+ const newChunk = chunk.split(index);
799
+ this.byEnd[index] = chunk;
800
+ this.byStart[index] = newChunk;
801
+ this.byEnd[newChunk.end] = newChunk;
802
+ if (chunk === this.lastChunk) this.lastChunk = newChunk;
803
+ this.lastSearchedChunk = chunk;
804
+ return true;
805
+ }
806
+ toString() {
807
+ let str = this.intro;
808
+ let chunk = this.firstChunk;
809
+ while (chunk) {
810
+ str += chunk.toString();
811
+ chunk = chunk.next;
812
+ }
813
+ return str + this.outro;
814
+ }
815
+ isEmpty() {
816
+ let chunk = this.firstChunk;
817
+ do
818
+ if (chunk.intro.length && chunk.intro.trim() || chunk.content.length && chunk.content.trim() || chunk.outro.length && chunk.outro.trim()) return false;
819
+ while (chunk = chunk.next);
820
+ return true;
821
+ }
822
+ length() {
823
+ let chunk = this.firstChunk;
824
+ let length = 0;
825
+ do
826
+ length += chunk.intro.length + chunk.content.length + chunk.outro.length;
827
+ while (chunk = chunk.next);
828
+ return length;
829
+ }
830
+ trimLines() {
831
+ return this.trim("[\\r\\n]");
832
+ }
833
+ trim(charType) {
834
+ return this.trimStart(charType).trimEnd(charType);
835
+ }
836
+ trimEndAborted(charType) {
837
+ const rx = /* @__PURE__ */ new RegExp((charType || "\\s") + "+$");
838
+ this.outro = this.outro.replace(rx, "");
839
+ if (this.outro.length) return true;
840
+ let chunk = this.lastChunk;
841
+ do {
842
+ const end = chunk.end;
843
+ const aborted = chunk.trimEnd(rx);
844
+ if (chunk.end !== end) {
845
+ if (this.lastChunk === chunk) this.lastChunk = chunk.next;
846
+ this.byEnd[chunk.end] = chunk;
847
+ this.byStart[chunk.next.start] = chunk.next;
848
+ this.byEnd[chunk.next.end] = chunk.next;
849
+ }
850
+ if (aborted) return true;
851
+ chunk = chunk.previous;
852
+ } while (chunk);
853
+ return false;
854
+ }
855
+ trimEnd(charType) {
856
+ this.trimEndAborted(charType);
857
+ return this;
858
+ }
859
+ trimStartAborted(charType) {
860
+ const rx = /* @__PURE__ */ new RegExp("^" + (charType || "\\s") + "+");
861
+ this.intro = this.intro.replace(rx, "");
862
+ if (this.intro.length) return true;
863
+ let chunk = this.firstChunk;
864
+ do {
865
+ const end = chunk.end;
866
+ const aborted = chunk.trimStart(rx);
867
+ if (chunk.end !== end) {
868
+ if (chunk === this.lastChunk) this.lastChunk = chunk.next;
869
+ this.byEnd[chunk.end] = chunk;
870
+ this.byStart[chunk.next.start] = chunk.next;
871
+ this.byEnd[chunk.next.end] = chunk.next;
872
+ }
873
+ if (aborted) return true;
874
+ chunk = chunk.next;
875
+ } while (chunk);
876
+ return false;
877
+ }
878
+ trimStart(charType) {
879
+ this.trimStartAborted(charType);
880
+ return this;
881
+ }
882
+ hasChanged() {
883
+ return this.original !== this.toString();
884
+ }
885
+ _replaceRegexp(searchValue, replacement) {
886
+ function getReplacement(match, str) {
887
+ if (typeof replacement === "string") return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
888
+ if (i === "$") return "$";
889
+ if (i === "&") return match[0];
890
+ if (+i < match.length) return match[+i];
891
+ return `$${i}`;
892
+ });
893
+ else return replacement(...match, match.index, str, match.groups);
894
+ }
895
+ function matchAll(re, str) {
896
+ let match;
897
+ const matches = [];
898
+ while (match = re.exec(str)) matches.push(match);
899
+ return matches;
900
+ }
901
+ if (searchValue.global) matchAll(searchValue, this.original).forEach((match) => {
902
+ if (match.index != null) {
903
+ const replacement$1 = getReplacement(match, this.original);
904
+ if (replacement$1 !== match[0]) this.overwrite(match.index, match.index + match[0].length, replacement$1);
905
+ }
906
+ });
907
+ else {
908
+ const match = this.original.match(searchValue);
909
+ if (match && match.index != null) {
910
+ const replacement$1 = getReplacement(match, this.original);
911
+ if (replacement$1 !== match[0]) this.overwrite(match.index, match.index + match[0].length, replacement$1);
912
+ }
913
+ }
914
+ return this;
915
+ }
916
+ _replaceString(string, replacement) {
917
+ const { original } = this;
918
+ const index = original.indexOf(string);
919
+ if (index !== -1) {
920
+ if (typeof replacement === "function") replacement = replacement(string, index, original);
921
+ if (string !== replacement) this.overwrite(index, index + string.length, replacement);
922
+ }
923
+ return this;
924
+ }
925
+ replace(searchValue, replacement) {
926
+ if (typeof searchValue === "string") return this._replaceString(searchValue, replacement);
927
+ return this._replaceRegexp(searchValue, replacement);
928
+ }
929
+ _replaceAllString(string, replacement) {
930
+ const { original } = this;
931
+ const stringLength = string.length;
932
+ for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
933
+ const previous = original.slice(index, index + stringLength);
934
+ let _replacement = replacement;
935
+ if (typeof replacement === "function") _replacement = replacement(previous, index, original);
936
+ if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
937
+ }
938
+ return this;
939
+ }
940
+ replaceAll(searchValue, replacement) {
941
+ if (typeof searchValue === "string") return this._replaceAllString(searchValue, replacement);
942
+ if (!searchValue.global) throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");
943
+ return this._replaceRegexp(searchValue, replacement);
944
+ }
945
+ };
946
+
947
+ //#endregion
948
+ //#region node_modules/.pnpm/js-tokens@9.0.1/node_modules/js-tokens/index.js
949
+ var require_js_tokens = /* @__PURE__ */ __commonJSMin(((exports, module) => {
950
+ var HashbangComment, Identifier, JSXIdentifier, JSXPunctuator, JSXString, JSXText, KeywordsWithExpressionAfter, KeywordsWithNoLineTerminatorAfter, LineTerminatorSequence, MultiLineComment, Newline, NumericLiteral, Punctuator, RegularExpressionLiteral = /\/(?![*\/])(?:\[(?:[^\]\\\n\r\u2028\u2029]+|\\.)*\]?|[^\/[\\\n\r\u2028\u2029]+|\\.)*(\/[$_\u200C\u200D\p{ID_Continue}]*|\\)?/uy, SingleLineComment, StringLiteral, Template, TokensNotPrecedingObjectLiteral, TokensPrecedingExpression, WhiteSpace;
951
+ Punctuator = /--|\+\+|=>|\.{3}|\??\.(?!\d)|(?:&&|\|\||\?\?|[+\-%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2}|\/(?![\/*]))=?|[?~,:;[\](){}]/y;
952
+ Identifier = /(\x23?)(?=[$_\p{ID_Start}\\])(?:[$_\u200C\u200D\p{ID_Continue}]+|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+/uy;
953
+ StringLiteral = /(['"])(?:[^'"\\\n\r]+|(?!\1)['"]|\\(?:\r\n|[^]))*(\1)?/y;
954
+ NumericLiteral = /(?:0[xX][\da-fA-F](?:_?[\da-fA-F])*|0[oO][0-7](?:_?[0-7])*|0[bB][01](?:_?[01])*)n?|0n|[1-9](?:_?\d)*n|(?:(?:0(?!\d)|0\d*[89]\d*|[1-9](?:_?\d)*)(?:\.(?:\d(?:_?\d)*)?)?|\.\d(?:_?\d)*)(?:[eE][+-]?\d(?:_?\d)*)?|0[0-7]+/y;
955
+ Template = /[`}](?:[^`\\$]+|\\[^]|\$(?!\{))*(`|\$\{)?/y;
956
+ WhiteSpace = /[\t\v\f\ufeff\p{Zs}]+/uy;
957
+ LineTerminatorSequence = /\r?\n|[\r\u2028\u2029]/y;
958
+ MultiLineComment = /\/\*(?:[^*]+|\*(?!\/))*(\*\/)?/y;
959
+ SingleLineComment = /\/\/.*/y;
960
+ HashbangComment = /^#!.*/;
961
+ JSXPunctuator = /[<>.:={}]|\/(?![\/*])/y;
962
+ JSXIdentifier = /[$_\p{ID_Start}][$_\u200C\u200D\p{ID_Continue}-]*/uy;
963
+ JSXString = /(['"])(?:[^'"]+|(?!\1)['"])*(\1)?/y;
964
+ JSXText = /[^<>{}]+/y;
965
+ TokensPrecedingExpression = /^(?:[\/+-]|\.{3}|\?(?:InterpolationIn(?:JSX|Template)|NoLineTerminatorHere|NonExpressionParenEnd|UnaryIncDec))?$|[{}([,;<>=*%&|^!~?:]$/;
966
+ TokensNotPrecedingObjectLiteral = /^(?:=>|[;\]){}]|else|\?(?:NoLineTerminatorHere|NonExpressionParenEnd))?$/;
967
+ KeywordsWithExpressionAfter = /^(?:await|case|default|delete|do|else|instanceof|new|return|throw|typeof|void|yield)$/;
968
+ KeywordsWithNoLineTerminatorAfter = /^(?:return|throw|yield)$/;
969
+ Newline = RegExp(LineTerminatorSequence.source);
970
+ module.exports = function* (input, { jsx = false } = {}) {
971
+ var braces, firstCodePoint, isExpression, lastIndex, lastSignificantToken, length, match, mode, nextLastIndex, nextLastSignificantToken, parenNesting, postfixIncDec, punctuator, stack;
972
+ ({length} = input);
973
+ lastIndex = 0;
974
+ lastSignificantToken = "";
975
+ stack = [{ tag: "JS" }];
976
+ braces = [];
977
+ parenNesting = 0;
978
+ postfixIncDec = false;
979
+ if (match = HashbangComment.exec(input)) {
980
+ yield {
981
+ type: "HashbangComment",
982
+ value: match[0]
983
+ };
984
+ lastIndex = match[0].length;
985
+ }
986
+ while (lastIndex < length) {
987
+ mode = stack[stack.length - 1];
988
+ switch (mode.tag) {
989
+ case "JS":
990
+ case "JSNonExpressionParen":
991
+ case "InterpolationInTemplate":
992
+ case "InterpolationInJSX":
993
+ if (input[lastIndex] === "/" && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken))) {
994
+ RegularExpressionLiteral.lastIndex = lastIndex;
995
+ if (match = RegularExpressionLiteral.exec(input)) {
996
+ lastIndex = RegularExpressionLiteral.lastIndex;
997
+ lastSignificantToken = match[0];
998
+ postfixIncDec = true;
999
+ yield {
1000
+ type: "RegularExpressionLiteral",
1001
+ value: match[0],
1002
+ closed: match[1] !== void 0 && match[1] !== "\\"
1003
+ };
1004
+ continue;
1005
+ }
1006
+ }
1007
+ Punctuator.lastIndex = lastIndex;
1008
+ if (match = Punctuator.exec(input)) {
1009
+ punctuator = match[0];
1010
+ nextLastIndex = Punctuator.lastIndex;
1011
+ nextLastSignificantToken = punctuator;
1012
+ switch (punctuator) {
1013
+ case "(":
1014
+ if (lastSignificantToken === "?NonExpressionParenKeyword") stack.push({
1015
+ tag: "JSNonExpressionParen",
1016
+ nesting: parenNesting
1017
+ });
1018
+ parenNesting++;
1019
+ postfixIncDec = false;
1020
+ break;
1021
+ case ")":
1022
+ parenNesting--;
1023
+ postfixIncDec = true;
1024
+ if (mode.tag === "JSNonExpressionParen" && parenNesting === mode.nesting) {
1025
+ stack.pop();
1026
+ nextLastSignificantToken = "?NonExpressionParenEnd";
1027
+ postfixIncDec = false;
1028
+ }
1029
+ break;
1030
+ case "{":
1031
+ Punctuator.lastIndex = 0;
1032
+ isExpression = !TokensNotPrecedingObjectLiteral.test(lastSignificantToken) && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken));
1033
+ braces.push(isExpression);
1034
+ postfixIncDec = false;
1035
+ break;
1036
+ case "}":
1037
+ switch (mode.tag) {
1038
+ case "InterpolationInTemplate":
1039
+ if (braces.length === mode.nesting) {
1040
+ Template.lastIndex = lastIndex;
1041
+ match = Template.exec(input);
1042
+ lastIndex = Template.lastIndex;
1043
+ lastSignificantToken = match[0];
1044
+ if (match[1] === "${") {
1045
+ lastSignificantToken = "?InterpolationInTemplate";
1046
+ postfixIncDec = false;
1047
+ yield {
1048
+ type: "TemplateMiddle",
1049
+ value: match[0]
1050
+ };
1051
+ } else {
1052
+ stack.pop();
1053
+ postfixIncDec = true;
1054
+ yield {
1055
+ type: "TemplateTail",
1056
+ value: match[0],
1057
+ closed: match[1] === "`"
1058
+ };
1059
+ }
1060
+ continue;
1061
+ }
1062
+ break;
1063
+ case "InterpolationInJSX": if (braces.length === mode.nesting) {
1064
+ stack.pop();
1065
+ lastIndex += 1;
1066
+ lastSignificantToken = "}";
1067
+ yield {
1068
+ type: "JSXPunctuator",
1069
+ value: "}"
1070
+ };
1071
+ continue;
1072
+ }
1073
+ }
1074
+ postfixIncDec = braces.pop();
1075
+ nextLastSignificantToken = postfixIncDec ? "?ExpressionBraceEnd" : "}";
1076
+ break;
1077
+ case "]":
1078
+ postfixIncDec = true;
1079
+ break;
1080
+ case "++":
1081
+ case "--":
1082
+ nextLastSignificantToken = postfixIncDec ? "?PostfixIncDec" : "?UnaryIncDec";
1083
+ break;
1084
+ case "<":
1085
+ if (jsx && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken))) {
1086
+ stack.push({ tag: "JSXTag" });
1087
+ lastIndex += 1;
1088
+ lastSignificantToken = "<";
1089
+ yield {
1090
+ type: "JSXPunctuator",
1091
+ value: punctuator
1092
+ };
1093
+ continue;
1094
+ }
1095
+ postfixIncDec = false;
1096
+ break;
1097
+ default: postfixIncDec = false;
1098
+ }
1099
+ lastIndex = nextLastIndex;
1100
+ lastSignificantToken = nextLastSignificantToken;
1101
+ yield {
1102
+ type: "Punctuator",
1103
+ value: punctuator
1104
+ };
1105
+ continue;
1106
+ }
1107
+ Identifier.lastIndex = lastIndex;
1108
+ if (match = Identifier.exec(input)) {
1109
+ lastIndex = Identifier.lastIndex;
1110
+ nextLastSignificantToken = match[0];
1111
+ switch (match[0]) {
1112
+ case "for":
1113
+ case "if":
1114
+ case "while":
1115
+ case "with": if (lastSignificantToken !== "." && lastSignificantToken !== "?.") nextLastSignificantToken = "?NonExpressionParenKeyword";
1116
+ }
1117
+ lastSignificantToken = nextLastSignificantToken;
1118
+ postfixIncDec = !KeywordsWithExpressionAfter.test(match[0]);
1119
+ yield {
1120
+ type: match[1] === "#" ? "PrivateIdentifier" : "IdentifierName",
1121
+ value: match[0]
1122
+ };
1123
+ continue;
1124
+ }
1125
+ StringLiteral.lastIndex = lastIndex;
1126
+ if (match = StringLiteral.exec(input)) {
1127
+ lastIndex = StringLiteral.lastIndex;
1128
+ lastSignificantToken = match[0];
1129
+ postfixIncDec = true;
1130
+ yield {
1131
+ type: "StringLiteral",
1132
+ value: match[0],
1133
+ closed: match[2] !== void 0
1134
+ };
1135
+ continue;
1136
+ }
1137
+ NumericLiteral.lastIndex = lastIndex;
1138
+ if (match = NumericLiteral.exec(input)) {
1139
+ lastIndex = NumericLiteral.lastIndex;
1140
+ lastSignificantToken = match[0];
1141
+ postfixIncDec = true;
1142
+ yield {
1143
+ type: "NumericLiteral",
1144
+ value: match[0]
1145
+ };
1146
+ continue;
1147
+ }
1148
+ Template.lastIndex = lastIndex;
1149
+ if (match = Template.exec(input)) {
1150
+ lastIndex = Template.lastIndex;
1151
+ lastSignificantToken = match[0];
1152
+ if (match[1] === "${") {
1153
+ lastSignificantToken = "?InterpolationInTemplate";
1154
+ stack.push({
1155
+ tag: "InterpolationInTemplate",
1156
+ nesting: braces.length
1157
+ });
1158
+ postfixIncDec = false;
1159
+ yield {
1160
+ type: "TemplateHead",
1161
+ value: match[0]
1162
+ };
1163
+ } else {
1164
+ postfixIncDec = true;
1165
+ yield {
1166
+ type: "NoSubstitutionTemplate",
1167
+ value: match[0],
1168
+ closed: match[1] === "`"
1169
+ };
1170
+ }
1171
+ continue;
1172
+ }
1173
+ break;
1174
+ case "JSXTag":
1175
+ case "JSXTagEnd":
1176
+ JSXPunctuator.lastIndex = lastIndex;
1177
+ if (match = JSXPunctuator.exec(input)) {
1178
+ lastIndex = JSXPunctuator.lastIndex;
1179
+ nextLastSignificantToken = match[0];
1180
+ switch (match[0]) {
1181
+ case "<":
1182
+ stack.push({ tag: "JSXTag" });
1183
+ break;
1184
+ case ">":
1185
+ stack.pop();
1186
+ if (lastSignificantToken === "/" || mode.tag === "JSXTagEnd") {
1187
+ nextLastSignificantToken = "?JSX";
1188
+ postfixIncDec = true;
1189
+ } else stack.push({ tag: "JSXChildren" });
1190
+ break;
1191
+ case "{":
1192
+ stack.push({
1193
+ tag: "InterpolationInJSX",
1194
+ nesting: braces.length
1195
+ });
1196
+ nextLastSignificantToken = "?InterpolationInJSX";
1197
+ postfixIncDec = false;
1198
+ break;
1199
+ case "/": if (lastSignificantToken === "<") {
1200
+ stack.pop();
1201
+ if (stack[stack.length - 1].tag === "JSXChildren") stack.pop();
1202
+ stack.push({ tag: "JSXTagEnd" });
1203
+ }
1204
+ }
1205
+ lastSignificantToken = nextLastSignificantToken;
1206
+ yield {
1207
+ type: "JSXPunctuator",
1208
+ value: match[0]
1209
+ };
1210
+ continue;
1211
+ }
1212
+ JSXIdentifier.lastIndex = lastIndex;
1213
+ if (match = JSXIdentifier.exec(input)) {
1214
+ lastIndex = JSXIdentifier.lastIndex;
1215
+ lastSignificantToken = match[0];
1216
+ yield {
1217
+ type: "JSXIdentifier",
1218
+ value: match[0]
1219
+ };
1220
+ continue;
1221
+ }
1222
+ JSXString.lastIndex = lastIndex;
1223
+ if (match = JSXString.exec(input)) {
1224
+ lastIndex = JSXString.lastIndex;
1225
+ lastSignificantToken = match[0];
1226
+ yield {
1227
+ type: "JSXString",
1228
+ value: match[0],
1229
+ closed: match[2] !== void 0
1230
+ };
1231
+ continue;
1232
+ }
1233
+ break;
1234
+ case "JSXChildren":
1235
+ JSXText.lastIndex = lastIndex;
1236
+ if (match = JSXText.exec(input)) {
1237
+ lastIndex = JSXText.lastIndex;
1238
+ lastSignificantToken = match[0];
1239
+ yield {
1240
+ type: "JSXText",
1241
+ value: match[0]
1242
+ };
1243
+ continue;
1244
+ }
1245
+ switch (input[lastIndex]) {
1246
+ case "<":
1247
+ stack.push({ tag: "JSXTag" });
1248
+ lastIndex++;
1249
+ lastSignificantToken = "<";
1250
+ yield {
1251
+ type: "JSXPunctuator",
1252
+ value: "<"
1253
+ };
1254
+ continue;
1255
+ case "{":
1256
+ stack.push({
1257
+ tag: "InterpolationInJSX",
1258
+ nesting: braces.length
1259
+ });
1260
+ lastIndex++;
1261
+ lastSignificantToken = "?InterpolationInJSX";
1262
+ postfixIncDec = false;
1263
+ yield {
1264
+ type: "JSXPunctuator",
1265
+ value: "{"
1266
+ };
1267
+ continue;
1268
+ }
1269
+ }
1270
+ WhiteSpace.lastIndex = lastIndex;
1271
+ if (match = WhiteSpace.exec(input)) {
1272
+ lastIndex = WhiteSpace.lastIndex;
1273
+ yield {
1274
+ type: "WhiteSpace",
1275
+ value: match[0]
1276
+ };
1277
+ continue;
1278
+ }
1279
+ LineTerminatorSequence.lastIndex = lastIndex;
1280
+ if (match = LineTerminatorSequence.exec(input)) {
1281
+ lastIndex = LineTerminatorSequence.lastIndex;
1282
+ postfixIncDec = false;
1283
+ if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) lastSignificantToken = "?NoLineTerminatorHere";
1284
+ yield {
1285
+ type: "LineTerminatorSequence",
1286
+ value: match[0]
1287
+ };
1288
+ continue;
1289
+ }
1290
+ MultiLineComment.lastIndex = lastIndex;
1291
+ if (match = MultiLineComment.exec(input)) {
1292
+ lastIndex = MultiLineComment.lastIndex;
1293
+ if (Newline.test(match[0])) {
1294
+ postfixIncDec = false;
1295
+ if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) lastSignificantToken = "?NoLineTerminatorHere";
1296
+ }
1297
+ yield {
1298
+ type: "MultiLineComment",
1299
+ value: match[0],
1300
+ closed: match[1] !== void 0
1301
+ };
1302
+ continue;
1303
+ }
1304
+ SingleLineComment.lastIndex = lastIndex;
1305
+ if (match = SingleLineComment.exec(input)) {
1306
+ lastIndex = SingleLineComment.lastIndex;
1307
+ postfixIncDec = false;
1308
+ yield {
1309
+ type: "SingleLineComment",
1310
+ value: match[0]
1311
+ };
1312
+ continue;
1313
+ }
1314
+ firstCodePoint = String.fromCodePoint(input.codePointAt(lastIndex));
1315
+ lastIndex += firstCodePoint.length;
1316
+ lastSignificantToken = firstCodePoint;
1317
+ postfixIncDec = false;
1318
+ yield {
1319
+ type: mode.tag.startsWith("JSX") ? "JSXInvalid" : "Invalid",
1320
+ value: firstCodePoint
1321
+ };
1322
+ }
1323
+ };
1324
+ }));
1325
+
1326
+ //#endregion
1327
+ //#region node_modules/.pnpm/strip-literal@3.1.0/node_modules/strip-literal/dist/index.mjs
1328
+ var import_js_tokens = /* @__PURE__ */ __toESM(require_js_tokens(), 1);
1329
+ const FILL_COMMENT = " ";
1330
+ function stripLiteralFromToken(token, fillChar, filter) {
1331
+ if (token.type === "SingleLineComment") return FILL_COMMENT.repeat(token.value.length);
1332
+ if (token.type === "MultiLineComment") return token.value.replace(/[^\n]/g, FILL_COMMENT);
1333
+ if (token.type === "StringLiteral") {
1334
+ if (!token.closed) return token.value;
1335
+ const body = token.value.slice(1, -1);
1336
+ if (filter(body)) return token.value[0] + fillChar.repeat(body.length) + token.value[token.value.length - 1];
1337
+ }
1338
+ if (token.type === "NoSubstitutionTemplate") {
1339
+ const body = token.value.slice(1, -1);
1340
+ if (filter(body)) return `\`${body.replace(/[^\n]/g, fillChar)}\``;
1341
+ }
1342
+ if (token.type === "RegularExpressionLiteral") {
1343
+ const body = token.value;
1344
+ if (filter(body)) return body.replace(/\/(.*)\/(\w?)$/g, (_, $1, $2) => `/${fillChar.repeat($1.length)}/${$2}`);
1345
+ }
1346
+ if (token.type === "TemplateHead") {
1347
+ const body = token.value.slice(1, -2);
1348
+ if (filter(body)) return `\`${body.replace(/[^\n]/g, fillChar)}\${`;
1349
+ }
1350
+ if (token.type === "TemplateTail") {
1351
+ const body = token.value.slice(0, -2);
1352
+ if (filter(body)) return `}${body.replace(/[^\n]/g, fillChar)}\``;
1353
+ }
1354
+ if (token.type === "TemplateMiddle") {
1355
+ const body = token.value.slice(1, -2);
1356
+ if (filter(body)) return `}${body.replace(/[^\n]/g, fillChar)}\${`;
1357
+ }
1358
+ return token.value;
1359
+ }
1360
+ function optionsWithDefaults(options) {
1361
+ return {
1362
+ fillChar: options?.fillChar ?? " ",
1363
+ filter: options?.filter ?? (() => true)
1364
+ };
1365
+ }
1366
+ function stripLiteral(code, options) {
1367
+ let result = "";
1368
+ const _options = optionsWithDefaults(options);
1369
+ for (const token of (0, import_js_tokens.default)(code, { jsx: false })) result += stripLiteralFromToken(token, _options.fillChar, _options.filter);
1370
+ return result;
1371
+ }
1372
+
1373
+ //#endregion
1374
+ //#region node_modules/.pnpm/@pi0+vite-plugin-fullstack@0.0.5-pr-1297_vite@7.2.6_@types+node@24.10.1_jiti@2.6.1_ligh_753e613ef6b6507e3955315025049470/node_modules/@pi0/vite-plugin-fullstack/dist/index.js
1375
+ function parseIdQuery(id) {
1376
+ if (!id.includes("?")) return {
1377
+ filename: id,
1378
+ query: {}
1379
+ };
1380
+ const [filename, rawQuery] = id.split(`?`, 2);
1381
+ return {
1382
+ filename,
1383
+ query: Object.fromEntries(new URLSearchParams(rawQuery))
1384
+ };
1385
+ }
1386
+ function toAssetsVirtual(options) {
1387
+ return `virtual:fullstack/assets?${new URLSearchParams(options)}&lang.js`;
1388
+ }
1389
+ function parseAssetsVirtual(id) {
1390
+ if (id.startsWith("\0virtual:fullstack/assets?")) return parseIdQuery(id).query;
1391
+ }
1392
+ function createVirtualPlugin(name, load) {
1393
+ name = "virtual:" + name;
1394
+ return {
1395
+ name: `rsc:virtual-${name}`,
1396
+ resolveId: { handler(source, _importer, _options) {
1397
+ return source === name ? "\0" + name : void 0;
1398
+ } },
1399
+ load: { handler(id, options) {
1400
+ if (id === "\0" + name) return load.apply(this, [id, options]);
1401
+ } }
1402
+ };
1403
+ }
1404
+ function normalizeRelativePath(s) {
1405
+ s = normalizePath(s);
1406
+ return s[0] === "." ? s : "./" + s;
1407
+ }
1408
+ function hashString(v) {
1409
+ return createHash("sha256").update(v).digest().toString("hex").slice(0, 12);
1410
+ }
1411
+ const VALID_ID_PREFIX = `/@id/`;
1412
+ const NULL_BYTE_PLACEHOLDER = `__x00__`;
1413
+ const FS_PREFIX = `/@fs/`;
1414
+ function wrapId(id) {
1415
+ return id.startsWith(VALID_ID_PREFIX) ? id : VALID_ID_PREFIX + id.replace("\0", NULL_BYTE_PLACEHOLDER);
1416
+ }
1417
+ function withTrailingSlash(path$1) {
1418
+ if (path$1[path$1.length - 1] !== "/") return `${path$1}/`;
1419
+ return path$1;
1420
+ }
1421
+ const postfixRE = /[?#].*$/;
1422
+ function cleanUrl(url) {
1423
+ return url.replace(postfixRE, "");
1424
+ }
1425
+ function splitFileAndPostfix(path$1) {
1426
+ const file = cleanUrl(path$1);
1427
+ return {
1428
+ file,
1429
+ postfix: path$1.slice(file.length)
1430
+ };
1431
+ }
1432
+ const windowsSlashRE = /\\/g;
1433
+ function slash(p) {
1434
+ return p.replace(windowsSlashRE, "/");
1435
+ }
1436
+ const isWindows = typeof process !== "undefined" && process.platform === "win32";
1437
+ function injectQuery(url, queryToInject) {
1438
+ const { file, postfix } = splitFileAndPostfix(url);
1439
+ return `${isWindows ? slash(file) : file}?${queryToInject}${postfix[0] === "?" ? `&${postfix.slice(1)}` : postfix}`;
1440
+ }
1441
+ function normalizeResolvedIdToUrl(environment, url, resolved) {
1442
+ const root = environment.config.root;
1443
+ const depsOptimizer = environment.depsOptimizer;
1444
+ if (resolved.id.startsWith(withTrailingSlash(root))) url = resolved.id.slice(root.length);
1445
+ else if (depsOptimizer?.isOptimizedDepFile(resolved.id) || resolved.id !== "/@react-refresh" && path.isAbsolute(resolved.id) && fs.existsSync(cleanUrl(resolved.id))) url = path.posix.join(FS_PREFIX, resolved.id);
1446
+ else url = resolved.id;
1447
+ if (url[0] !== "." && url[0] !== "/") url = wrapId(resolved.id);
1448
+ return url;
1449
+ }
1450
+ function normalizeViteImportAnalysisUrl(environment, id) {
1451
+ let url = normalizeResolvedIdToUrl(environment, id, { id });
1452
+ if (environment.config.consumer === "client") {
1453
+ const mod = environment.moduleGraph.getModuleById(id);
1454
+ if (mod && mod.lastHMRTimestamp > 0) url = injectQuery(url, `t=${mod.lastHMRTimestamp}`);
1455
+ }
1456
+ return url;
1457
+ }
1458
+ function evalValue(rawValue) {
1459
+ return new Function(`
1460
+ var console, exports, global, module, process, require
1461
+ return (\n${rawValue}\n)
1462
+ `)();
1463
+ }
1464
+ const directRequestRE = /(\?|&)direct=?(?:&|$)/;
1465
+ function assetsPlugin(pluginOpts) {
1466
+ let server;
1467
+ let resolvedConfig;
1468
+ const importAssetsMetaMap = {};
1469
+ const bundleMap = {};
1470
+ async function processAssetsImport(ctx, id, options) {
1471
+ if (ctx.environment.mode === "dev") {
1472
+ const result = {
1473
+ entry: void 0,
1474
+ js: [],
1475
+ css: []
1476
+ };
1477
+ const environment = server.environments[options.environment];
1478
+ assert$1(environment, `Unknown environment: ${options.environment}`);
1479
+ if (options.environment === "client") result.entry = normalizeViteImportAnalysisUrl(environment, id);
1480
+ if (environment.name !== "client") {
1481
+ const collected = await collectCss(environment, id, { eager: pluginOpts?.experimental?.devEagerTransform ?? true });
1482
+ result.css = collected.hrefs.map((href, i) => ({
1483
+ href,
1484
+ "data-vite-dev-id": collected.ids[i]
1485
+ }));
1486
+ }
1487
+ return JSON.stringify(result);
1488
+ } else {
1489
+ const map = importAssetsMetaMap[options.environment] ??= {};
1490
+ const meta = {
1491
+ id,
1492
+ key: path.relative(resolvedConfig.root, id),
1493
+ importerEnvironment: ctx.environment.name,
1494
+ isEntry: !!(map[id]?.isEntry || options.isEntry)
1495
+ };
1496
+ map[id] = meta;
1497
+ return `__assets_manifest[${JSON.stringify(options.environment)}][${JSON.stringify(meta.key)}]`;
1498
+ }
1499
+ }
1500
+ let writeAssetsManifestCalled = false;
1501
+ async function writeAssetsManifest(builder) {
1502
+ if (writeAssetsManifestCalled) return;
1503
+ writeAssetsManifestCalled = true;
1504
+ const manifest = {};
1505
+ for (const [environmentName, metas] of Object.entries(importAssetsMetaMap)) {
1506
+ const bundle = bundleMap[environmentName];
1507
+ const assetDepsMap = collectAssetDeps(bundle);
1508
+ for (const [id, meta] of Object.entries(metas)) {
1509
+ const found = assetDepsMap[id];
1510
+ if (!found) {
1511
+ builder.config.logger.error(`[vite-plugin-fullstack] failed to find built chunk for ${meta.id} imported by ${meta.importerEnvironment} environment`);
1512
+ return;
1513
+ }
1514
+ const result = {
1515
+ js: [],
1516
+ css: []
1517
+ };
1518
+ const { chunk, deps } = found;
1519
+ if (environmentName === "client") {
1520
+ result.entry = `/${chunk.fileName}`;
1521
+ result.js = deps.js.map((fileName) => ({ href: `/${fileName}` }));
1522
+ }
1523
+ result.css = deps.css.map((fileName) => ({ href: `/${fileName}` }));
1524
+ if (!builder.environments[environmentName].config.build.cssCodeSplit) {
1525
+ const singleCss = Object.values(bundle).find((v) => v.type === "asset" && v.originalFileNames.includes("style.css"));
1526
+ if (singleCss) result.css.push({ href: `/${singleCss.fileName}` });
1527
+ }
1528
+ (manifest[environmentName] ??= {})[meta.key] = result;
1529
+ }
1530
+ }
1531
+ const importerEnvironments = new Set(Object.values(importAssetsMetaMap).flatMap((metas) => Object.values(metas)).flatMap((meta) => meta.importerEnvironment));
1532
+ for (const environmentName of importerEnvironments) {
1533
+ const outDir = builder.environments[environmentName].config.build.outDir;
1534
+ fs.writeFileSync(path.join(outDir, BUILD_ASSETS_MANIFEST_NAME), `export default ${JSON.stringify(manifest, null, 2)};`);
1535
+ const clientOutDir = builder.environments["client"].config.build.outDir;
1536
+ for (const asset of Object.values(bundleMap[environmentName])) if (asset.type === "asset") {
1537
+ const srcFile = path.join(outDir, asset.fileName);
1538
+ const destFile = path.join(clientOutDir, asset.fileName);
1539
+ fs.mkdirSync(path.dirname(destFile), { recursive: true });
1540
+ fs.copyFileSync(srcFile, destFile);
1541
+ }
1542
+ }
1543
+ }
1544
+ return [
1545
+ {
1546
+ name: "fullstack:assets",
1547
+ sharedDuringBuild: true,
1548
+ configureServer(server_) {
1549
+ server = server_;
1550
+ },
1551
+ configResolved(config) {
1552
+ resolvedConfig = config;
1553
+ },
1554
+ configEnvironment(name) {
1555
+ if ((pluginOpts?.serverEnvironments ?? ["ssr"]).includes(name)) return { build: { emitAssets: true } };
1556
+ },
1557
+ transform: { async handler(code, id, _options) {
1558
+ if (!code.includes("import.meta.vite.assets")) return;
1559
+ const output = new MagicString(code);
1560
+ const strippedCode = stripLiteral(code);
1561
+ const newImports = /* @__PURE__ */ new Set();
1562
+ for (const match of code.matchAll(/import\.meta\.vite\.assets\(([\s\S]*?)\)/dg)) {
1563
+ const [start, end] = match.indices[0];
1564
+ if (!strippedCode.slice(start, end).includes("import.meta.vite.assets")) continue;
1565
+ if (this.environment.name === "client") {
1566
+ const replacement$1 = `(${JSON.stringify(EMPTY_ASSETS)})`;
1567
+ output.update(start, end, replacement$1);
1568
+ continue;
1569
+ }
1570
+ const argCode = match[1].trim();
1571
+ const options = {
1572
+ import: id,
1573
+ environment: void 0,
1574
+ asEntry: false
1575
+ };
1576
+ if (argCode) {
1577
+ const argValue = evalValue(argCode);
1578
+ Object.assign(options, argValue);
1579
+ }
1580
+ const environments = options.environment ? [options.environment] : ["client", this.environment.name];
1581
+ const importedNames = [];
1582
+ for (const environment of environments) {
1583
+ const importSource = toAssetsVirtual({
1584
+ import: options.import,
1585
+ importer: id,
1586
+ environment,
1587
+ entry: options.asEntry ? "1" : ""
1588
+ });
1589
+ const importedName = `__assets_${hashString(importSource)}`;
1590
+ newImports.add(`;import ${importedName} from ${JSON.stringify(importSource)};\n`);
1591
+ importedNames.push(importedName);
1592
+ }
1593
+ let replacement = importedNames[0];
1594
+ if (importedNames.length > 1) {
1595
+ newImports.add(`;import * as __assets_runtime from "virtual:fullstack/runtime";\n`);
1596
+ replacement = `__assets_runtime.mergeAssets(${importedNames.join(", ")})`;
1597
+ }
1598
+ output.update(start, end, `(${replacement})`);
1599
+ }
1600
+ if (output.hasChanged()) {
1601
+ for (const newImport of newImports) output.append(newImport);
1602
+ return {
1603
+ code: output.toString(),
1604
+ map: output.generateMap({ hires: "boundary" })
1605
+ };
1606
+ }
1607
+ } },
1608
+ resolveId: { handler(source) {
1609
+ if (source.startsWith("virtual:fullstack/assets?")) return "\0" + source;
1610
+ if (source === "virtual:fullstack/assets-manifest") {
1611
+ assert$1.notEqual(this.environment.name, "client");
1612
+ assert$1.equal(this.environment.mode, "build");
1613
+ return {
1614
+ id: source,
1615
+ external: true
1616
+ };
1617
+ }
1618
+ if (source === "virtual:fullstack/runtime") return { id: source };
1619
+ } },
1620
+ load: { async handler(id) {
1621
+ if (id === "virtual:fullstack/runtime") return runtimeUtils();
1622
+ const parsed = parseAssetsVirtual(id);
1623
+ if (!parsed) return;
1624
+ assert$1.notEqual(this.environment.name, "client");
1625
+ const resolved = await this.resolve(parsed.import, parsed.importer);
1626
+ assert$1(resolved, `Failed to resolve: ${parsed.import}`);
1627
+ const s = new MagicString("");
1628
+ const code = await processAssetsImport(this, resolved.id, {
1629
+ environment: parsed.environment,
1630
+ isEntry: !!parsed.entry
1631
+ });
1632
+ s.append(`export default ${code};\n`);
1633
+ if (this.environment.mode === "build") s.prepend(`import __assets_manifest from "virtual:fullstack/assets-manifest";\n`);
1634
+ return s.toString();
1635
+ } },
1636
+ renderChunk(code, chunk) {
1637
+ if (code.includes("virtual:fullstack/assets-manifest")) {
1638
+ const replacement = normalizeRelativePath(path.relative(path.join(chunk.fileName, ".."), BUILD_ASSETS_MANIFEST_NAME));
1639
+ code = code.replaceAll("virtual:fullstack/assets-manifest", () => replacement);
1640
+ return { code };
1641
+ }
1642
+ },
1643
+ writeBundle(_options, bundle) {
1644
+ bundleMap[this.environment.name] = bundle;
1645
+ },
1646
+ buildStart() {
1647
+ if (this.environment.mode == "build" && this.environment.name === "client") {
1648
+ if (importAssetsMetaMap["client"]) {
1649
+ for (const meta of Object.values(importAssetsMetaMap["client"])) if (meta.isEntry) this.emitFile({
1650
+ type: "chunk",
1651
+ id: meta.id,
1652
+ preserveSignature: "exports-only"
1653
+ });
1654
+ }
1655
+ }
1656
+ },
1657
+ buildApp: {
1658
+ order: "pre",
1659
+ async handler(builder) {
1660
+ builder.writeAssetsManifest = async () => {
1661
+ await writeAssetsManifest(builder);
1662
+ };
1663
+ }
1664
+ }
1665
+ },
1666
+ {
1667
+ name: "fullstack:write-assets-manifest-post",
1668
+ buildApp: {
1669
+ order: "post",
1670
+ async handler(builder) {
1671
+ await builder.writeAssetsManifest();
1672
+ }
1673
+ }
1674
+ },
1675
+ {
1676
+ name: "fullstack:assets-query",
1677
+ sharedDuringBuild: true,
1678
+ resolveId: {
1679
+ order: "pre",
1680
+ handler(source) {
1681
+ const { query } = parseIdQuery(source);
1682
+ if (typeof query["assets"] !== "undefined") {
1683
+ if (this.environment.name === "client") return `\0virtual:fullstack/empty-assets`;
1684
+ }
1685
+ if (source === "virtual:fullstack/runtime") return source;
1686
+ }
1687
+ },
1688
+ load: { async handler(id) {
1689
+ if (id === "\0virtual:fullstack/empty-assets") return `export default ${JSON.stringify(EMPTY_ASSETS)}`;
1690
+ if (id === "virtual:fullstack/runtime") return runtimeUtils();
1691
+ const { filename, query } = parseIdQuery(id);
1692
+ const value = query["assets"];
1693
+ if (typeof value !== "undefined") {
1694
+ const s = new MagicString("");
1695
+ const codes = [];
1696
+ if (value) {
1697
+ const code = await processAssetsImport(this, filename, {
1698
+ environment: value,
1699
+ isEntry: value === "client"
1700
+ });
1701
+ codes.push(code);
1702
+ } else {
1703
+ const code1 = await processAssetsImport(this, filename, {
1704
+ environment: "client",
1705
+ isEntry: false
1706
+ });
1707
+ const code2 = await processAssetsImport(this, filename, {
1708
+ environment: this.environment.name,
1709
+ isEntry: false
1710
+ });
1711
+ codes.push(code1, code2);
1712
+ }
1713
+ s.append(`
1714
+ import * as __assets_runtime from "virtual:fullstack/runtime";\n
1715
+ export default __assets_runtime.mergeAssets(${codes.join(", ")});
1716
+ `);
1717
+ if (this.environment.mode === "build") s.prepend(`import __assets_manifest from "virtual:fullstack/assets-manifest";\n`);
1718
+ return {
1719
+ code: s.toString(),
1720
+ moduleSideEffects: false
1721
+ };
1722
+ }
1723
+ } },
1724
+ hotUpdate(ctx) {
1725
+ if (this.environment.name === "rsc") {
1726
+ const mods = collectModuleDependents(ctx.modules);
1727
+ for (const mod of mods) if (mod.id) {
1728
+ const ids = [
1729
+ `${mod.id}?assets`,
1730
+ `${mod.id}?assets=client`,
1731
+ `${mod.id}?assets=${this.environment.name}`
1732
+ ];
1733
+ for (const id of ids) invalidteModuleById(this.environment, id);
1734
+ }
1735
+ }
1736
+ }
1737
+ },
1738
+ {
1739
+ ...createVirtualPlugin("fullstack/client-fallback", () => "export {}"),
1740
+ configEnvironment: {
1741
+ order: "post",
1742
+ handler(name, config, _env) {
1743
+ if (name === "client") {
1744
+ if ((pluginOpts?.experimental?.clientBuildFallback ?? true) && !config.build?.rollupOptions?.input) return { build: { rollupOptions: { input: { __fallback: "virtual:fullstack/client-fallback" } } } };
1745
+ }
1746
+ }
1747
+ },
1748
+ generateBundle(_optoins, bundle) {
1749
+ if (this.environment.name !== "client") return;
1750
+ for (const [k, v] of Object.entries(bundle)) if (v.type === "chunk" && v.name === "__fallback") delete bundle[k];
1751
+ }
1752
+ },
1753
+ patchViteClientPlugin(),
1754
+ patchVueScopeCssHmr(),
1755
+ patchCssLinkSelfAccept()
1756
+ ];
1757
+ }
1758
+ const EMPTY_ASSETS = {
1759
+ js: [],
1760
+ css: []
1761
+ };
1762
+ const BUILD_ASSETS_MANIFEST_NAME = "__fullstack_assets_manifest.js";
1763
+ async function collectCss(environment, entryId, options) {
1764
+ const visited = /* @__PURE__ */ new Set();
1765
+ const cssIds = /* @__PURE__ */ new Set();
1766
+ async function recurse(id) {
1767
+ if (visited.has(id) || parseAssetsVirtual(id) || "assets" in parseIdQuery(id).query) return;
1768
+ visited.add(id);
1769
+ const mod = environment.moduleGraph.getModuleById(id);
1770
+ if (!mod) return;
1771
+ if (options.eager && !mod?.transformResult) try {
1772
+ await environment.transformRequest(id);
1773
+ } catch (e) {
1774
+ console.error(`[collectCss] Failed to transform '${id}'`, e);
1775
+ }
1776
+ for (const next of mod?.importedModules ?? []) if (next.id) if (isCSSRequest(next.id)) {
1777
+ if (hasSpecialCssQuery(next.id)) continue;
1778
+ cssIds.add(next.id);
1779
+ } else await recurse(next.id);
1780
+ }
1781
+ await recurse(entryId);
1782
+ const hrefs = [...cssIds].map((id) => normalizeViteImportAnalysisUrl(environment, id));
1783
+ return {
1784
+ ids: [...cssIds],
1785
+ hrefs
1786
+ };
1787
+ }
1788
+ function invalidteModuleById(environment, id) {
1789
+ const mod = environment.moduleGraph.getModuleById(id);
1790
+ if (mod) environment.moduleGraph.invalidateModule(mod);
1791
+ return mod;
1792
+ }
1793
+ function collectModuleDependents(mods) {
1794
+ const visited = /* @__PURE__ */ new Set();
1795
+ function recurse(mod) {
1796
+ if (visited.has(mod)) return;
1797
+ visited.add(mod);
1798
+ for (const importer of mod.importers) recurse(importer);
1799
+ }
1800
+ for (const mod of mods) recurse(mod);
1801
+ return [...visited];
1802
+ }
1803
+ function hasSpecialCssQuery(id) {
1804
+ return /[?&](url|inline|raw)(\b|=|&|$)/.test(id);
1805
+ }
1806
+ function collectAssetDeps(bundle) {
1807
+ const chunkToDeps = /* @__PURE__ */ new Map();
1808
+ for (const chunk of Object.values(bundle)) if (chunk.type === "chunk") chunkToDeps.set(chunk, collectAssetDepsInner(chunk.fileName, bundle));
1809
+ const idToDeps = {};
1810
+ for (const [chunk, deps] of chunkToDeps.entries()) for (const id of chunk.moduleIds) idToDeps[id] = {
1811
+ chunk,
1812
+ deps
1813
+ };
1814
+ return idToDeps;
1815
+ }
1816
+ function collectAssetDepsInner(fileName, bundle) {
1817
+ const visited = /* @__PURE__ */ new Set();
1818
+ const css = [];
1819
+ function recurse(k) {
1820
+ if (visited.has(k)) return;
1821
+ visited.add(k);
1822
+ const v = bundle[k];
1823
+ assert$1(v, `Not found '${k}' in the bundle`);
1824
+ if (v.type === "chunk") {
1825
+ css.push(...v.viteMetadata?.importedCss ?? []);
1826
+ for (const k2 of v.imports) if (k2 in bundle) recurse(k2);
1827
+ }
1828
+ }
1829
+ recurse(fileName);
1830
+ return {
1831
+ js: [...visited],
1832
+ css: [...new Set(css)]
1833
+ };
1834
+ }
1835
+ function patchViteClientPlugin() {
1836
+ const viteClientPath = normalizePath(fileURLToPath(import.meta.resolve("vite/dist/client/client.mjs")));
1837
+ function endIndexOf(code, searchValue) {
1838
+ const i = code.lastIndexOf(searchValue);
1839
+ return i === -1 ? i : i + searchValue.length;
1840
+ }
1841
+ return {
1842
+ name: "fullstack:patch-vite-client",
1843
+ transform: { handler(code, id) {
1844
+ if (id === viteClientPath) {
1845
+ if (code.includes("linkSheetsMap")) return;
1846
+ const s = new MagicString(code);
1847
+ s.prependLeft(code.indexOf("const sheetsMap"), `\
1848
+ const linkSheetsMap = new Map();
1849
+ document
1850
+ .querySelectorAll('link[rel="stylesheet"][data-vite-dev-id]')
1851
+ .forEach((el) => {
1852
+ linkSheetsMap.set(el.getAttribute('data-vite-dev-id'), el)
1853
+ });
1854
+ `);
1855
+ s.appendLeft(endIndexOf(code, `function updateStyle(id, content) {`), `if (linkSheetsMap.has(id)) { return }`);
1856
+ s.appendLeft(endIndexOf(code, `function removeStyle(id) {`), `
1857
+ const link = linkSheetsMap.get(id);
1858
+ if (link) {
1859
+ document
1860
+ .querySelectorAll(
1861
+ 'link[rel="stylesheet"][data-vite-dev-id]',
1862
+ )
1863
+ .forEach((el) => {
1864
+ if (el.getAttribute('data-vite-dev-id') === id) {
1865
+ el.remove()
1866
+ }
1867
+ })
1868
+ linkSheetsMap.delete(id)
1869
+ }
1870
+ `);
1871
+ return s.toString();
1872
+ }
1873
+ } }
1874
+ };
1875
+ }
1876
+ function patchVueScopeCssHmr() {
1877
+ return {
1878
+ name: "fullstack:patch-vue-scoped-css-hmr",
1879
+ configureServer(server) {
1880
+ server.middlewares.use((req, _res, next) => {
1881
+ if (req.headers.accept?.includes("text/css") && req.url?.includes("&lang.css=")) req.url = req.url.replace("&lang.css=", "?lang.css");
1882
+ next();
1883
+ });
1884
+ }
1885
+ };
1886
+ }
1887
+ function patchCssLinkSelfAccept() {
1888
+ return {
1889
+ name: "fullstack:patch-css-link-self-accept",
1890
+ apply: "serve",
1891
+ transform: {
1892
+ order: "post",
1893
+ handler(_code, id, _options) {
1894
+ if (this.environment.name === "client" && this.environment.mode === "dev" && isCSSRequest(id) && directRequestRE.test(id)) {
1895
+ const mod = this.environment.moduleGraph.getModuleById(id);
1896
+ if (mod && !mod.isSelfAccepting) mod.isSelfAccepting = true;
1897
+ }
1898
+ }
1899
+ }
1900
+ };
1901
+ }
1902
+ function runtimeUtils() {
1903
+ return `
1904
+ export function mergeAssets(...args) {
1905
+ const js = uniqBy(args.flatMap((h) => h.js), (a) => a.href);
1906
+ const css = uniqBy(args.flatMap((h) => h.css), (a) => a.href);
1907
+ const entry = args.filter((arg) => arg.entry)?.[0]?.entry;
1908
+ const raw = { entry, js, css };
1909
+ return { ...raw, merge: (...args$1) => mergeAssets(raw, ...args$1) };
1910
+ }
1911
+ function uniqBy(array, key) {
1912
+ const seen = new Set();
1913
+ return array.filter((item) => {
1914
+ const k = key(item);
1915
+ if (seen.has(k)) return false;
1916
+ seen.add(k);
1917
+ return true;
1918
+ });
1919
+ }`;
1920
+ }
1921
+
1922
+ //#endregion
1923
+ export { stripLiteral as n, MagicString as r, assetsPlugin as t };