@fulgurjs/federation 6.9.2 → 6.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.en.md +2 -0
  3. package/README.md +2 -0
  4. package/dist/bridge-host-vue.cjs +1 -1
  5. package/dist/bridge-host-vue.js +1 -1
  6. package/dist/cli.js +2059 -314
  7. package/dist/index.cjs +149 -129
  8. package/dist/index.js +149 -129
  9. package/dist/react.js +3 -3
  10. package/dist/runtime.js +1 -1
  11. package/dist/vue-adapter.cjs +1 -1
  12. package/dist/vue-adapter.js +1 -1
  13. package/dist/vue.js +2 -2
  14. package/examples/templates/README.md +6 -0
  15. package/examples/templates/react-host-vue-remote/pnpm-lock.yaml +7 -7
  16. package/examples/templates/react-host-vue-remote/pnpm-workspace.yaml +1 -1
  17. package/examples/templates/react-host-vue-remote/react-host/package.json +1 -1
  18. package/examples/templates/react-host-vue-remote/vue-remote/package.json +1 -1
  19. package/examples/templates/react-react/host/package.json +1 -1
  20. package/examples/templates/react-react/pnpm-lock.yaml +7 -7
  21. package/examples/templates/react-react/pnpm-workspace.yaml +1 -1
  22. package/examples/templates/react-react/remote/package.json +1 -1
  23. package/examples/templates/showcase/pnpm-lock.yaml +11 -11
  24. package/examples/templates/showcase/pnpm-workspace.yaml +1 -1
  25. package/examples/templates/showcase/react-host/package.json +1 -1
  26. package/examples/templates/showcase/react-remote/package.json +1 -1
  27. package/examples/templates/showcase/vue-host/package.json +1 -1
  28. package/examples/templates/showcase/vue-remote/package.json +1 -1
  29. package/examples/templates/vue-host-react-remote/pnpm-lock.yaml +7 -7
  30. package/examples/templates/vue-host-react-remote/pnpm-workspace.yaml +1 -1
  31. package/examples/templates/vue-host-react-remote/react-remote/package.json +1 -1
  32. package/examples/templates/vue-host-react-remote/vue-host/package.json +1 -1
  33. package/examples/templates/vue-vue/host/package.json +1 -1
  34. package/examples/templates/vue-vue/pnpm-lock.yaml +7 -7
  35. package/examples/templates/vue-vue/pnpm-workspace.yaml +1 -1
  36. package/examples/templates/vue-vue/remote/package.json +1 -1
  37. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -175,6 +175,1150 @@ var init_manifest = __esm({
175
175
  }
176
176
  });
177
177
 
178
+ // node_modules/es-module-lexer/dist/lexer.js
179
+ function parse(E2, g = "@") {
180
+ if (!C) return init.then((() => parse(E2)));
181
+ const I = E2.length + 1, w = (C.__heap_base.value || C.__heap_base) + 4 * I - C.memory.buffer.byteLength;
182
+ w > 0 && C.memory.grow(Math.ceil(w / 65536));
183
+ const K = C.sa(I - 1);
184
+ if ((A ? B : Q)(E2, new Uint16Array(C.memory.buffer, K, I)), !C.parse()) throw Object.assign(new Error(`Parse error ${g}:${E2.slice(0, C.e()).split("\n").length}:${C.e() - E2.lastIndexOf("\n", C.e() - 1)}`), { idx: C.e() });
185
+ const o = [], D = [];
186
+ for (; C.ri(); ) {
187
+ const A2 = C.is(), Q2 = C.ie(), B2 = C.it(), g2 = C.ai(), I2 = C.id(), w2 = C.ss(), K2 = C.se();
188
+ let D2;
189
+ C.ip() && (D2 = k(E2.slice(-1 === I2 ? A2 - 1 : A2, -1 === I2 ? Q2 + 1 : Q2))), o.push({ n: D2, t: B2, s: A2, e: Q2, ss: w2, se: K2, d: I2, a: g2 });
190
+ }
191
+ for (; C.re(); ) {
192
+ const A2 = C.es(), Q2 = C.ee(), B2 = C.els(), g2 = C.ele(), I2 = E2.slice(A2, Q2), w2 = I2[0], K2 = B2 < 0 ? void 0 : E2.slice(B2, g2), o2 = K2 ? K2[0] : "";
193
+ D.push({ s: A2, e: Q2, ls: B2, le: g2, n: '"' === w2 || "'" === w2 ? k(I2) : I2, ln: '"' === o2 || "'" === o2 ? k(K2) : K2 });
194
+ }
195
+ function k(A2) {
196
+ try {
197
+ return (0, eval)(A2);
198
+ } catch (A3) {
199
+ }
200
+ }
201
+ return [o, D, !!C.f(), !!C.ms()];
202
+ }
203
+ function Q(A2, Q2) {
204
+ const B2 = A2.length;
205
+ let C2 = 0;
206
+ for (; C2 < B2; ) {
207
+ const B3 = A2.charCodeAt(C2);
208
+ Q2[C2++] = (255 & B3) << 8 | B3 >>> 8;
209
+ }
210
+ }
211
+ function B(A2, Q2) {
212
+ const B2 = A2.length;
213
+ let C2 = 0;
214
+ for (; C2 < B2; ) Q2[C2] = A2.charCodeAt(C2++);
215
+ }
216
+ var ImportType, A, C, E, init;
217
+ var init_lexer = __esm({
218
+ "node_modules/es-module-lexer/dist/lexer.js"() {
219
+ !(function(A2) {
220
+ A2[A2.Static = 1] = "Static", A2[A2.Dynamic = 2] = "Dynamic", A2[A2.ImportMeta = 3] = "ImportMeta", A2[A2.StaticSourcePhase = 4] = "StaticSourcePhase", A2[A2.DynamicSourcePhase = 5] = "DynamicSourcePhase", A2[A2.StaticDeferPhase = 6] = "StaticDeferPhase", A2[A2.DynamicDeferPhase = 7] = "DynamicDeferPhase";
221
+ })(ImportType || (ImportType = {}));
222
+ A = 1 === new Uint8Array(new Uint16Array([1]).buffer)[0];
223
+ E = () => {
224
+ return A2 = "AGFzbQEAAAABKwhgAX8Bf2AEf39/fwBgAAF/YAAAYAF/AGADf39/AX9gAn9/AX9gA39/fwADMTAAAQECAgICAgICAgICAgICAgICAgIAAwMDBAQAAAUAAAAAAAMDAwAGAAAABwAGAgUEBQFwAQEBBQMBAAEGDwJ/AUHA8gALfwBBwPIACwd6FQZtZW1vcnkCAAJzYQAAAWUAAwJpcwAEAmllAAUCc3MABgJzZQAHAml0AAgCYWkACQJpZAAKAmlwAAsCZXMADAJlZQANA2VscwAOA2VsZQAPAnJpABACcmUAEQFmABICbXMAEwVwYXJzZQAUC19faGVhcF9iYXNlAwEKzkQwaAEBf0EAIAA2AoAKQQAoAtwJIgEgAEEBdGoiAEEAOwEAQQAgAEECaiIANgKECkEAIAA2AogKQQBBADYC4AlBAEEANgLwCUEAQQA2AugJQQBBADYC5AlBAEEANgL4CUEAQQA2AuwJIAEL0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NASAAIQIgARAoDQJBACECQQBBACgCsAoiAEECajYCsAogAC8BAiIADQAMAgsLIAAhAgsgAkH//wNxC6sBAQR/AkACQEEAKAKwCiICLwEAIgNB4QBGDQAgASEEIAAhBQwBC0EAIAJBBGo2ArAKQQEQKSECQQAoArAKIQUCQAJAIAJBIkYNACACQSdGDQAgAhAsGkEAKAKwCiEEDAELIAIQGkEAQQAoArAKQQJqIgQ2ArAKC0EBECkhA0EAKAKwCiECCwJAIAIgBUYNACAFIARBACAAIAAgAUYiAhtBACABIAIbEAILIAMLcgEEf0EAKAKwCiEAQQAoArQKIQECQAJAA0AgAEECaiECIAAgAU8NAQJAAkAgAi8BACIDQaR/ag4CAQQACyACIQAgA0F2ag4EAgEBAgELIABBBGohAAwACwtBACACNgKwChAlQQAPC0EAIAI2ArAKQd0AC0kBA39BACEDAkAgAkUNAAJAA0AgAC0AACIEIAEtAAAiBUcNASABQQFqIQEgAEEBaiEAIAJBf2oiAg0ADAILCyAEIAVrIQMLIAMLC+wBAgBBgAgLzgEAAHgAcABvAHIAdABtAHAAbwByAHQAZgBvAHIAZQB0AGEAbwB1AHIAYwBlAHIAbwBtAHUAbgBjAHQAaQBvAG4AcwBzAGUAcgB0AHYAbwB5AGkAZQBkAGUAbABlAGMAbwBuAHQAaQBuAGkAbgBzAHQAYQBuAHQAeQBiAHIAZQBhAHIAZQB0AHUAcgBkAGUAYgB1AGcAZwBlAGEAdwBhAGkAdABoAHIAdwBoAGkAbABlAGkAZgBjAGEAdABjAGYAaQBuAGEAbABsAGUAbABzAABB0AkLEAEAAAACAAAAAAQAAEA5AAA=", "undefined" != typeof Buffer ? Buffer.from(A2, "base64") : Uint8Array.from(atob(A2), ((A3) => A3.charCodeAt(0)));
225
+ var A2;
226
+ };
227
+ init = WebAssembly.compile(E()).then(WebAssembly.instantiate).then((({ exports: A2 }) => {
228
+ C = A2;
229
+ }));
230
+ }
231
+ });
232
+
233
+ // node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
234
+ function encodeInteger(builder, num) {
235
+ do {
236
+ let clamped = num & 31;
237
+ num >>>= 5;
238
+ if (num > 0) clamped |= 32;
239
+ builder.write(intToChar[clamped]);
240
+ } while (num > 0);
241
+ }
242
+ function encodeSign(num) {
243
+ return num < 0 ? -num << 1 | 1 : num << 1;
244
+ }
245
+ function encode(decoded) {
246
+ const writer = new StringWriter();
247
+ let sourcesIndex = 0;
248
+ let sourceLine = 0;
249
+ let sourceColumn = 0;
250
+ let namesIndex = 0;
251
+ for (let i = 0; i < decoded.length; i++) {
252
+ const line = decoded[i];
253
+ if (i > 0) writer.write(semicolon);
254
+ if (line.length === 0) continue;
255
+ let genColumn = 0;
256
+ for (let j = 0; j < line.length; j++) {
257
+ const segment = line[j];
258
+ if (j > 0) writer.write(comma);
259
+ encodeInteger(writer, encodeSign(segment[0] - genColumn));
260
+ genColumn = segment[0];
261
+ if (segment.length === 1) continue;
262
+ encodeInteger(writer, encodeSign(segment[1] - sourcesIndex));
263
+ encodeInteger(writer, encodeSign(segment[2] - sourceLine));
264
+ encodeInteger(writer, encodeSign(segment[3] - sourceColumn));
265
+ sourcesIndex = segment[1];
266
+ sourceLine = segment[2];
267
+ sourceColumn = segment[3];
268
+ if (segment.length === 4) continue;
269
+ encodeInteger(writer, encodeSign(segment[4] - namesIndex));
270
+ namesIndex = segment[4];
271
+ }
272
+ }
273
+ return writer.flush();
274
+ }
275
+ var comma, semicolon, chars, intToChar, charToInt, bufLength, td, StringWriter;
276
+ var init_sourcemap_codec = __esm({
277
+ "node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs"() {
278
+ comma = ",".charCodeAt(0);
279
+ semicolon = ";".charCodeAt(0);
280
+ chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
281
+ intToChar = new Uint8Array(64);
282
+ charToInt = new Uint8Array(128);
283
+ for (let i = 0; i < chars.length; i++) {
284
+ const c = chars.charCodeAt(i);
285
+ intToChar[i] = c;
286
+ charToInt[c] = i;
287
+ }
288
+ bufLength = 1024 * 16;
289
+ td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? {
290
+ decode(buf) {
291
+ const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
292
+ return out.toString();
293
+ }
294
+ } : {
295
+ decode(buf) {
296
+ let out = "";
297
+ for (let i = 0; i < buf.length; i++) {
298
+ out += String.fromCharCode(buf[i]);
299
+ }
300
+ return out;
301
+ }
302
+ };
303
+ StringWriter = class {
304
+ constructor() {
305
+ this.pos = 0;
306
+ this.out = "";
307
+ this.buffer = new Uint8Array(bufLength);
308
+ }
309
+ write(v) {
310
+ const { buffer } = this;
311
+ buffer[this.pos++] = v;
312
+ if (this.pos === bufLength) {
313
+ this.out += td.decode(buffer);
314
+ this.pos = 0;
315
+ }
316
+ }
317
+ flush() {
318
+ const { buffer, out, pos } = this;
319
+ return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
320
+ }
321
+ };
322
+ }
323
+ });
324
+
325
+ // node_modules/magic-string/dist/magic-string.es.mjs
326
+ function getBtoa() {
327
+ if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") {
328
+ return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
329
+ } else if (typeof Buffer === "function") {
330
+ return (str) => Buffer.from(str, "utf-8").toString("base64");
331
+ } else {
332
+ return () => {
333
+ throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
334
+ };
335
+ }
336
+ }
337
+ function guessIndent(code) {
338
+ const lines = code.split("\n");
339
+ const tabbed = lines.filter((line) => /^\t+/.test(line));
340
+ const spaced = lines.filter((line) => /^ {2,}/.test(line));
341
+ if (tabbed.length === 0 && spaced.length === 0) {
342
+ return null;
343
+ }
344
+ if (tabbed.length >= spaced.length) {
345
+ return " ";
346
+ }
347
+ const min = spaced.reduce((previous, current) => {
348
+ const numSpaces = /^ +/.exec(current)[0].length;
349
+ return Math.min(numSpaces, previous);
350
+ }, Infinity);
351
+ return new Array(min + 1).join(" ");
352
+ }
353
+ function getRelativePath(from, to) {
354
+ const fromParts = from.split(/[/\\]/);
355
+ const toParts = to.split(/[/\\]/);
356
+ fromParts.pop();
357
+ while (fromParts[0] === toParts[0]) {
358
+ fromParts.shift();
359
+ toParts.shift();
360
+ }
361
+ if (fromParts.length) {
362
+ let i = fromParts.length;
363
+ while (i--) fromParts[i] = "..";
364
+ }
365
+ return fromParts.concat(toParts).join("/");
366
+ }
367
+ function isObject(thing) {
368
+ return toString.call(thing) === "[object Object]";
369
+ }
370
+ function getLocator(source) {
371
+ const originalLines = source.split("\n");
372
+ const lineOffsets = [];
373
+ for (let i = 0, pos = 0; i < originalLines.length; i++) {
374
+ lineOffsets.push(pos);
375
+ pos += originalLines[i].length + 1;
376
+ }
377
+ return function locate(index) {
378
+ let i = 0;
379
+ let j = lineOffsets.length;
380
+ while (i < j) {
381
+ const m = i + j >> 1;
382
+ if (index < lineOffsets[m]) {
383
+ j = m;
384
+ } else {
385
+ i = m + 1;
386
+ }
387
+ }
388
+ const line = i - 1;
389
+ const column = index - lineOffsets[line];
390
+ return { line, column };
391
+ };
392
+ }
393
+ var BitSet, Chunk, btoa, SourceMap, toString, wordRegex, Mappings, n, warned, MagicString;
394
+ var init_magic_string_es = __esm({
395
+ "node_modules/magic-string/dist/magic-string.es.mjs"() {
396
+ init_sourcemap_codec();
397
+ BitSet = class _BitSet {
398
+ constructor(arg) {
399
+ this.bits = arg instanceof _BitSet ? arg.bits.slice() : [];
400
+ }
401
+ add(n2) {
402
+ this.bits[n2 >> 5] |= 1 << (n2 & 31);
403
+ }
404
+ has(n2) {
405
+ return !!(this.bits[n2 >> 5] & 1 << (n2 & 31));
406
+ }
407
+ };
408
+ Chunk = class _Chunk {
409
+ constructor(start, end, content) {
410
+ this.start = start;
411
+ this.end = end;
412
+ this.original = content;
413
+ this.intro = "";
414
+ this.outro = "";
415
+ this.content = content;
416
+ this.storeName = false;
417
+ this.edited = false;
418
+ {
419
+ this.previous = null;
420
+ this.next = null;
421
+ }
422
+ }
423
+ appendLeft(content) {
424
+ this.outro += content;
425
+ }
426
+ appendRight(content) {
427
+ this.intro = this.intro + content;
428
+ }
429
+ clone() {
430
+ const chunk = new _Chunk(this.start, this.end, this.original);
431
+ chunk.intro = this.intro;
432
+ chunk.outro = this.outro;
433
+ chunk.content = this.content;
434
+ chunk.storeName = this.storeName;
435
+ chunk.edited = this.edited;
436
+ return chunk;
437
+ }
438
+ contains(index) {
439
+ return this.start < index && index < this.end;
440
+ }
441
+ eachNext(fn) {
442
+ let chunk = this;
443
+ while (chunk) {
444
+ fn(chunk);
445
+ chunk = chunk.next;
446
+ }
447
+ }
448
+ eachPrevious(fn) {
449
+ let chunk = this;
450
+ while (chunk) {
451
+ fn(chunk);
452
+ chunk = chunk.previous;
453
+ }
454
+ }
455
+ edit(content, storeName, contentOnly) {
456
+ this.content = content;
457
+ if (!contentOnly) {
458
+ this.intro = "";
459
+ this.outro = "";
460
+ }
461
+ this.storeName = storeName;
462
+ this.edited = true;
463
+ return this;
464
+ }
465
+ prependLeft(content) {
466
+ this.outro = content + this.outro;
467
+ }
468
+ prependRight(content) {
469
+ this.intro = content + this.intro;
470
+ }
471
+ reset() {
472
+ this.intro = "";
473
+ this.outro = "";
474
+ if (this.edited) {
475
+ this.content = this.original;
476
+ this.storeName = false;
477
+ this.edited = false;
478
+ }
479
+ }
480
+ split(index) {
481
+ const sliceIndex = index - this.start;
482
+ const originalBefore = this.original.slice(0, sliceIndex);
483
+ const originalAfter = this.original.slice(sliceIndex);
484
+ this.original = originalBefore;
485
+ const newChunk = new _Chunk(index, this.end, originalAfter);
486
+ newChunk.outro = this.outro;
487
+ this.outro = "";
488
+ this.end = index;
489
+ if (this.edited) {
490
+ newChunk.edit("", false);
491
+ this.content = "";
492
+ } else {
493
+ this.content = originalBefore;
494
+ }
495
+ newChunk.next = this.next;
496
+ if (newChunk.next) newChunk.next.previous = newChunk;
497
+ newChunk.previous = this;
498
+ this.next = newChunk;
499
+ return newChunk;
500
+ }
501
+ toString() {
502
+ return this.intro + this.content + this.outro;
503
+ }
504
+ trimEnd(rx) {
505
+ this.outro = this.outro.replace(rx, "");
506
+ if (this.outro.length) return true;
507
+ const trimmed = this.content.replace(rx, "");
508
+ if (trimmed.length) {
509
+ if (trimmed !== this.content) {
510
+ this.split(this.start + trimmed.length).edit("", void 0, true);
511
+ if (this.edited) {
512
+ this.edit(trimmed, this.storeName, true);
513
+ }
514
+ }
515
+ return true;
516
+ } else {
517
+ this.edit("", void 0, true);
518
+ this.intro = this.intro.replace(rx, "");
519
+ if (this.intro.length) return true;
520
+ }
521
+ }
522
+ trimStart(rx) {
523
+ this.intro = this.intro.replace(rx, "");
524
+ if (this.intro.length) return true;
525
+ const trimmed = this.content.replace(rx, "");
526
+ if (trimmed.length) {
527
+ if (trimmed !== this.content) {
528
+ const newChunk = this.split(this.end - trimmed.length);
529
+ if (this.edited) {
530
+ newChunk.edit(trimmed, this.storeName, true);
531
+ }
532
+ this.edit("", void 0, true);
533
+ }
534
+ return true;
535
+ } else {
536
+ this.edit("", void 0, true);
537
+ this.outro = this.outro.replace(rx, "");
538
+ if (this.outro.length) return true;
539
+ }
540
+ }
541
+ };
542
+ btoa = /* @__PURE__ */ getBtoa();
543
+ SourceMap = class {
544
+ constructor(properties) {
545
+ this.version = 3;
546
+ this.file = properties.file;
547
+ this.sources = properties.sources;
548
+ this.sourcesContent = properties.sourcesContent;
549
+ this.names = properties.names;
550
+ this.mappings = encode(properties.mappings);
551
+ if (typeof properties.x_google_ignoreList !== "undefined") {
552
+ this.x_google_ignoreList = properties.x_google_ignoreList;
553
+ }
554
+ if (typeof properties.debugId !== "undefined") {
555
+ this.debugId = properties.debugId;
556
+ }
557
+ }
558
+ toString() {
559
+ return JSON.stringify(this);
560
+ }
561
+ toUrl() {
562
+ return "data:application/json;charset=utf-8;base64," + btoa(this.toString());
563
+ }
564
+ };
565
+ toString = Object.prototype.toString;
566
+ wordRegex = /\w/;
567
+ Mappings = class {
568
+ constructor(hires) {
569
+ this.hires = hires;
570
+ this.generatedCodeLine = 0;
571
+ this.generatedCodeColumn = 0;
572
+ this.raw = [];
573
+ this.rawSegments = this.raw[this.generatedCodeLine] = [];
574
+ this.pending = null;
575
+ }
576
+ addEdit(sourceIndex, content, loc, nameIndex) {
577
+ if (content.length) {
578
+ const contentLengthMinusOne = content.length - 1;
579
+ let contentLineEnd = content.indexOf("\n", 0);
580
+ let previousContentLineEnd = -1;
581
+ while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
582
+ const segment2 = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
583
+ if (nameIndex >= 0) {
584
+ segment2.push(nameIndex);
585
+ }
586
+ this.rawSegments.push(segment2);
587
+ this.generatedCodeLine += 1;
588
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
589
+ this.generatedCodeColumn = 0;
590
+ previousContentLineEnd = contentLineEnd;
591
+ contentLineEnd = content.indexOf("\n", contentLineEnd + 1);
592
+ }
593
+ const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
594
+ if (nameIndex >= 0) {
595
+ segment.push(nameIndex);
596
+ }
597
+ this.rawSegments.push(segment);
598
+ this.advance(content.slice(previousContentLineEnd + 1));
599
+ } else if (this.pending) {
600
+ this.rawSegments.push(this.pending);
601
+ this.advance(content);
602
+ }
603
+ this.pending = null;
604
+ }
605
+ addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
606
+ let originalCharIndex = chunk.start;
607
+ let first = true;
608
+ let charInHiresBoundary = false;
609
+ while (originalCharIndex < chunk.end) {
610
+ if (original[originalCharIndex] === "\n") {
611
+ loc.line += 1;
612
+ loc.column = 0;
613
+ this.generatedCodeLine += 1;
614
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
615
+ this.generatedCodeColumn = 0;
616
+ first = true;
617
+ charInHiresBoundary = false;
618
+ } else {
619
+ if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
620
+ const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
621
+ if (this.hires === "boundary") {
622
+ if (wordRegex.test(original[originalCharIndex])) {
623
+ if (!charInHiresBoundary) {
624
+ this.rawSegments.push(segment);
625
+ charInHiresBoundary = true;
626
+ }
627
+ } else {
628
+ this.rawSegments.push(segment);
629
+ charInHiresBoundary = false;
630
+ }
631
+ } else {
632
+ this.rawSegments.push(segment);
633
+ }
634
+ }
635
+ loc.column += 1;
636
+ this.generatedCodeColumn += 1;
637
+ first = false;
638
+ }
639
+ originalCharIndex += 1;
640
+ }
641
+ this.pending = null;
642
+ }
643
+ advance(str) {
644
+ if (!str) return;
645
+ const lines = str.split("\n");
646
+ if (lines.length > 1) {
647
+ for (let i = 0; i < lines.length - 1; i++) {
648
+ this.generatedCodeLine++;
649
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
650
+ }
651
+ this.generatedCodeColumn = 0;
652
+ }
653
+ this.generatedCodeColumn += lines[lines.length - 1].length;
654
+ }
655
+ };
656
+ n = "\n";
657
+ warned = {
658
+ insertLeft: false,
659
+ insertRight: false,
660
+ storeName: false
661
+ };
662
+ MagicString = class _MagicString {
663
+ constructor(string, options = {}) {
664
+ const chunk = new Chunk(0, string.length, string);
665
+ Object.defineProperties(this, {
666
+ original: { writable: true, value: string },
667
+ outro: { writable: true, value: "" },
668
+ intro: { writable: true, value: "" },
669
+ firstChunk: { writable: true, value: chunk },
670
+ lastChunk: { writable: true, value: chunk },
671
+ lastSearchedChunk: { writable: true, value: chunk },
672
+ byStart: { writable: true, value: {} },
673
+ byEnd: { writable: true, value: {} },
674
+ filename: { writable: true, value: options.filename },
675
+ indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
676
+ sourcemapLocations: { writable: true, value: new BitSet() },
677
+ storedNames: { writable: true, value: {} },
678
+ indentStr: { writable: true, value: void 0 },
679
+ ignoreList: { writable: true, value: options.ignoreList },
680
+ offset: { writable: true, value: options.offset || 0 }
681
+ });
682
+ this.byStart[0] = chunk;
683
+ this.byEnd[string.length] = chunk;
684
+ }
685
+ addSourcemapLocation(char) {
686
+ this.sourcemapLocations.add(char);
687
+ }
688
+ append(content) {
689
+ if (typeof content !== "string") throw new TypeError("outro content must be a string");
690
+ this.outro += content;
691
+ return this;
692
+ }
693
+ appendLeft(index, content) {
694
+ index = index + this.offset;
695
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
696
+ this._split(index);
697
+ const chunk = this.byEnd[index];
698
+ if (chunk) {
699
+ chunk.appendLeft(content);
700
+ } else {
701
+ this.intro += content;
702
+ }
703
+ return this;
704
+ }
705
+ appendRight(index, content) {
706
+ index = index + this.offset;
707
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
708
+ this._split(index);
709
+ const chunk = this.byStart[index];
710
+ if (chunk) {
711
+ chunk.appendRight(content);
712
+ } else {
713
+ this.outro += content;
714
+ }
715
+ return this;
716
+ }
717
+ clone() {
718
+ const cloned = new _MagicString(this.original, { filename: this.filename, offset: this.offset });
719
+ let originalChunk = this.firstChunk;
720
+ let clonedChunk = cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone();
721
+ while (originalChunk) {
722
+ cloned.byStart[clonedChunk.start] = clonedChunk;
723
+ cloned.byEnd[clonedChunk.end] = clonedChunk;
724
+ const nextOriginalChunk = originalChunk.next;
725
+ const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
726
+ if (nextClonedChunk) {
727
+ clonedChunk.next = nextClonedChunk;
728
+ nextClonedChunk.previous = clonedChunk;
729
+ clonedChunk = nextClonedChunk;
730
+ }
731
+ originalChunk = nextOriginalChunk;
732
+ }
733
+ cloned.lastChunk = clonedChunk;
734
+ if (this.indentExclusionRanges) {
735
+ cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
736
+ }
737
+ cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
738
+ cloned.intro = this.intro;
739
+ cloned.outro = this.outro;
740
+ return cloned;
741
+ }
742
+ generateDecodedMap(options) {
743
+ options = options || {};
744
+ const sourceIndex = 0;
745
+ const names = Object.keys(this.storedNames);
746
+ const mappings = new Mappings(options.hires);
747
+ const locate = getLocator(this.original);
748
+ if (this.intro) {
749
+ mappings.advance(this.intro);
750
+ }
751
+ this.firstChunk.eachNext((chunk) => {
752
+ const loc = locate(chunk.start);
753
+ if (chunk.intro.length) mappings.advance(chunk.intro);
754
+ if (chunk.edited) {
755
+ mappings.addEdit(
756
+ sourceIndex,
757
+ chunk.content,
758
+ loc,
759
+ chunk.storeName ? names.indexOf(chunk.original) : -1
760
+ );
761
+ } else {
762
+ mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
763
+ }
764
+ if (chunk.outro.length) mappings.advance(chunk.outro);
765
+ });
766
+ if (this.outro) {
767
+ mappings.advance(this.outro);
768
+ }
769
+ return {
770
+ file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
771
+ sources: [
772
+ options.source ? getRelativePath(options.file || "", options.source) : options.file || ""
773
+ ],
774
+ sourcesContent: options.includeContent ? [this.original] : void 0,
775
+ names,
776
+ mappings: mappings.raw,
777
+ x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0
778
+ };
779
+ }
780
+ generateMap(options) {
781
+ return new SourceMap(this.generateDecodedMap(options));
782
+ }
783
+ _ensureindentStr() {
784
+ if (this.indentStr === void 0) {
785
+ this.indentStr = guessIndent(this.original);
786
+ }
787
+ }
788
+ _getRawIndentString() {
789
+ this._ensureindentStr();
790
+ return this.indentStr;
791
+ }
792
+ getIndentString() {
793
+ this._ensureindentStr();
794
+ return this.indentStr === null ? " " : this.indentStr;
795
+ }
796
+ indent(indentStr, options) {
797
+ const pattern = /^[^\r\n]/gm;
798
+ if (isObject(indentStr)) {
799
+ options = indentStr;
800
+ indentStr = void 0;
801
+ }
802
+ if (indentStr === void 0) {
803
+ this._ensureindentStr();
804
+ indentStr = this.indentStr || " ";
805
+ }
806
+ if (indentStr === "") return this;
807
+ options = options || {};
808
+ const isExcluded2 = {};
809
+ if (options.exclude) {
810
+ const exclusions = typeof options.exclude[0] === "number" ? [options.exclude] : options.exclude;
811
+ exclusions.forEach((exclusion) => {
812
+ for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
813
+ isExcluded2[i] = true;
814
+ }
815
+ });
816
+ }
817
+ let shouldIndentNextCharacter = options.indentStart !== false;
818
+ const replacer = (match) => {
819
+ if (shouldIndentNextCharacter) return `${indentStr}${match}`;
820
+ shouldIndentNextCharacter = true;
821
+ return match;
822
+ };
823
+ this.intro = this.intro.replace(pattern, replacer);
824
+ let charIndex = 0;
825
+ let chunk = this.firstChunk;
826
+ while (chunk) {
827
+ const end = chunk.end;
828
+ if (chunk.edited) {
829
+ if (!isExcluded2[charIndex]) {
830
+ chunk.content = chunk.content.replace(pattern, replacer);
831
+ if (chunk.content.length) {
832
+ shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === "\n";
833
+ }
834
+ }
835
+ } else {
836
+ charIndex = chunk.start;
837
+ while (charIndex < end) {
838
+ if (!isExcluded2[charIndex]) {
839
+ const char = this.original[charIndex];
840
+ if (char === "\n") {
841
+ shouldIndentNextCharacter = true;
842
+ } else if (char !== "\r" && shouldIndentNextCharacter) {
843
+ shouldIndentNextCharacter = false;
844
+ if (charIndex === chunk.start) {
845
+ chunk.prependRight(indentStr);
846
+ } else {
847
+ this._splitChunk(chunk, charIndex);
848
+ chunk = chunk.next;
849
+ chunk.prependRight(indentStr);
850
+ }
851
+ }
852
+ }
853
+ charIndex += 1;
854
+ }
855
+ }
856
+ charIndex = chunk.end;
857
+ chunk = chunk.next;
858
+ }
859
+ this.outro = this.outro.replace(pattern, replacer);
860
+ return this;
861
+ }
862
+ insert() {
863
+ throw new Error(
864
+ "magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)"
865
+ );
866
+ }
867
+ insertLeft(index, content) {
868
+ if (!warned.insertLeft) {
869
+ console.warn(
870
+ "magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"
871
+ );
872
+ warned.insertLeft = true;
873
+ }
874
+ return this.appendLeft(index, content);
875
+ }
876
+ insertRight(index, content) {
877
+ if (!warned.insertRight) {
878
+ console.warn(
879
+ "magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"
880
+ );
881
+ warned.insertRight = true;
882
+ }
883
+ return this.prependRight(index, content);
884
+ }
885
+ move(start, end, index) {
886
+ start = start + this.offset;
887
+ end = end + this.offset;
888
+ index = index + this.offset;
889
+ if (index >= start && index <= end) throw new Error("Cannot move a selection inside itself");
890
+ this._split(start);
891
+ this._split(end);
892
+ this._split(index);
893
+ const first = this.byStart[start];
894
+ const last = this.byEnd[end];
895
+ const oldLeft = first.previous;
896
+ const oldRight = last.next;
897
+ const newRight = this.byStart[index];
898
+ if (!newRight && last === this.lastChunk) return this;
899
+ const newLeft = newRight ? newRight.previous : this.lastChunk;
900
+ if (oldLeft) oldLeft.next = oldRight;
901
+ if (oldRight) oldRight.previous = oldLeft;
902
+ if (newLeft) newLeft.next = first;
903
+ if (newRight) newRight.previous = last;
904
+ if (!first.previous) this.firstChunk = last.next;
905
+ if (!last.next) {
906
+ this.lastChunk = first.previous;
907
+ this.lastChunk.next = null;
908
+ }
909
+ first.previous = newLeft;
910
+ last.next = newRight || null;
911
+ if (!newLeft) this.firstChunk = first;
912
+ if (!newRight) this.lastChunk = last;
913
+ return this;
914
+ }
915
+ overwrite(start, end, content, options) {
916
+ options = options || {};
917
+ return this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
918
+ }
919
+ update(start, end, content, options) {
920
+ start = start + this.offset;
921
+ end = end + this.offset;
922
+ if (typeof content !== "string") throw new TypeError("replacement content must be a string");
923
+ if (this.original.length !== 0) {
924
+ while (start < 0) start += this.original.length;
925
+ while (end < 0) end += this.original.length;
926
+ }
927
+ if (end > this.original.length) throw new Error("end is out of bounds");
928
+ if (start === end)
929
+ throw new Error(
930
+ "Cannot overwrite a zero-length range \u2013 use appendLeft or prependRight instead"
931
+ );
932
+ this._split(start);
933
+ this._split(end);
934
+ if (options === true) {
935
+ if (!warned.storeName) {
936
+ console.warn(
937
+ "The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"
938
+ );
939
+ warned.storeName = true;
940
+ }
941
+ options = { storeName: true };
942
+ }
943
+ const storeName = options !== void 0 ? options.storeName : false;
944
+ const overwrite = options !== void 0 ? options.overwrite : false;
945
+ if (storeName) {
946
+ const original = this.original.slice(start, end);
947
+ Object.defineProperty(this.storedNames, original, {
948
+ writable: true,
949
+ value: true,
950
+ enumerable: true
951
+ });
952
+ }
953
+ const first = this.byStart[start];
954
+ const last = this.byEnd[end];
955
+ if (first) {
956
+ let chunk = first;
957
+ while (chunk !== last) {
958
+ if (chunk.next !== this.byStart[chunk.end]) {
959
+ throw new Error("Cannot overwrite across a split point");
960
+ }
961
+ chunk = chunk.next;
962
+ chunk.edit("", false);
963
+ }
964
+ first.edit(content, storeName, !overwrite);
965
+ } else {
966
+ const newChunk = new Chunk(start, end, "").edit(content, storeName);
967
+ last.next = newChunk;
968
+ newChunk.previous = last;
969
+ }
970
+ return this;
971
+ }
972
+ prepend(content) {
973
+ if (typeof content !== "string") throw new TypeError("outro content must be a string");
974
+ this.intro = content + this.intro;
975
+ return this;
976
+ }
977
+ prependLeft(index, content) {
978
+ index = index + this.offset;
979
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
980
+ this._split(index);
981
+ const chunk = this.byEnd[index];
982
+ if (chunk) {
983
+ chunk.prependLeft(content);
984
+ } else {
985
+ this.intro = content + this.intro;
986
+ }
987
+ return this;
988
+ }
989
+ prependRight(index, content) {
990
+ index = index + this.offset;
991
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
992
+ this._split(index);
993
+ const chunk = this.byStart[index];
994
+ if (chunk) {
995
+ chunk.prependRight(content);
996
+ } else {
997
+ this.outro = content + this.outro;
998
+ }
999
+ return this;
1000
+ }
1001
+ remove(start, end) {
1002
+ start = start + this.offset;
1003
+ end = end + this.offset;
1004
+ if (this.original.length !== 0) {
1005
+ while (start < 0) start += this.original.length;
1006
+ while (end < 0) end += this.original.length;
1007
+ }
1008
+ if (start === end) return this;
1009
+ if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
1010
+ if (start > end) throw new Error("end must be greater than start");
1011
+ this._split(start);
1012
+ this._split(end);
1013
+ let chunk = this.byStart[start];
1014
+ while (chunk) {
1015
+ chunk.intro = "";
1016
+ chunk.outro = "";
1017
+ chunk.edit("");
1018
+ chunk = end > chunk.end ? this.byStart[chunk.end] : null;
1019
+ }
1020
+ return this;
1021
+ }
1022
+ reset(start, end) {
1023
+ start = start + this.offset;
1024
+ end = end + this.offset;
1025
+ if (this.original.length !== 0) {
1026
+ while (start < 0) start += this.original.length;
1027
+ while (end < 0) end += this.original.length;
1028
+ }
1029
+ if (start === end) return this;
1030
+ if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
1031
+ if (start > end) throw new Error("end must be greater than start");
1032
+ this._split(start);
1033
+ this._split(end);
1034
+ let chunk = this.byStart[start];
1035
+ while (chunk) {
1036
+ chunk.reset();
1037
+ chunk = end > chunk.end ? this.byStart[chunk.end] : null;
1038
+ }
1039
+ return this;
1040
+ }
1041
+ lastChar() {
1042
+ if (this.outro.length) return this.outro[this.outro.length - 1];
1043
+ let chunk = this.lastChunk;
1044
+ do {
1045
+ if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
1046
+ if (chunk.content.length) return chunk.content[chunk.content.length - 1];
1047
+ if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
1048
+ } while (chunk = chunk.previous);
1049
+ if (this.intro.length) return this.intro[this.intro.length - 1];
1050
+ return "";
1051
+ }
1052
+ lastLine() {
1053
+ let lineIndex = this.outro.lastIndexOf(n);
1054
+ if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
1055
+ let lineStr = this.outro;
1056
+ let chunk = this.lastChunk;
1057
+ do {
1058
+ if (chunk.outro.length > 0) {
1059
+ lineIndex = chunk.outro.lastIndexOf(n);
1060
+ if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
1061
+ lineStr = chunk.outro + lineStr;
1062
+ }
1063
+ if (chunk.content.length > 0) {
1064
+ lineIndex = chunk.content.lastIndexOf(n);
1065
+ if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
1066
+ lineStr = chunk.content + lineStr;
1067
+ }
1068
+ if (chunk.intro.length > 0) {
1069
+ lineIndex = chunk.intro.lastIndexOf(n);
1070
+ if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
1071
+ lineStr = chunk.intro + lineStr;
1072
+ }
1073
+ } while (chunk = chunk.previous);
1074
+ lineIndex = this.intro.lastIndexOf(n);
1075
+ if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
1076
+ return this.intro + lineStr;
1077
+ }
1078
+ slice(start = 0, end = this.original.length - this.offset) {
1079
+ start = start + this.offset;
1080
+ end = end + this.offset;
1081
+ if (this.original.length !== 0) {
1082
+ while (start < 0) start += this.original.length;
1083
+ while (end < 0) end += this.original.length;
1084
+ }
1085
+ let result = "";
1086
+ let chunk = this.firstChunk;
1087
+ while (chunk && (chunk.start > start || chunk.end <= start)) {
1088
+ if (chunk.start < end && chunk.end >= end) {
1089
+ return result;
1090
+ }
1091
+ chunk = chunk.next;
1092
+ }
1093
+ if (chunk && chunk.edited && chunk.start !== start)
1094
+ throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
1095
+ const startChunk = chunk;
1096
+ while (chunk) {
1097
+ if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
1098
+ result += chunk.intro;
1099
+ }
1100
+ const containsEnd = chunk.start < end && chunk.end >= end;
1101
+ if (containsEnd && chunk.edited && chunk.end !== end)
1102
+ throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
1103
+ const sliceStart = startChunk === chunk ? start - chunk.start : 0;
1104
+ const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
1105
+ result += chunk.content.slice(sliceStart, sliceEnd);
1106
+ if (chunk.outro && (!containsEnd || chunk.end === end)) {
1107
+ result += chunk.outro;
1108
+ }
1109
+ if (containsEnd) {
1110
+ break;
1111
+ }
1112
+ chunk = chunk.next;
1113
+ }
1114
+ return result;
1115
+ }
1116
+ // TODO deprecate this? not really very useful
1117
+ snip(start, end) {
1118
+ const clone = this.clone();
1119
+ clone.remove(0, start);
1120
+ clone.remove(end, clone.original.length);
1121
+ return clone;
1122
+ }
1123
+ _split(index) {
1124
+ if (this.byStart[index] || this.byEnd[index]) return;
1125
+ let chunk = this.lastSearchedChunk;
1126
+ let previousChunk = chunk;
1127
+ const searchForward = index > chunk.end;
1128
+ while (chunk) {
1129
+ if (chunk.contains(index)) return this._splitChunk(chunk, index);
1130
+ chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
1131
+ if (chunk === previousChunk) return;
1132
+ previousChunk = chunk;
1133
+ }
1134
+ }
1135
+ _splitChunk(chunk, index) {
1136
+ if (chunk.edited && chunk.content.length) {
1137
+ const loc = getLocator(this.original)(index);
1138
+ throw new Error(
1139
+ `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} \u2013 "${chunk.original}")`
1140
+ );
1141
+ }
1142
+ const newChunk = chunk.split(index);
1143
+ this.byEnd[index] = chunk;
1144
+ this.byStart[index] = newChunk;
1145
+ this.byEnd[newChunk.end] = newChunk;
1146
+ if (chunk === this.lastChunk) this.lastChunk = newChunk;
1147
+ this.lastSearchedChunk = chunk;
1148
+ return true;
1149
+ }
1150
+ toString() {
1151
+ let str = this.intro;
1152
+ let chunk = this.firstChunk;
1153
+ while (chunk) {
1154
+ str += chunk.toString();
1155
+ chunk = chunk.next;
1156
+ }
1157
+ return str + this.outro;
1158
+ }
1159
+ isEmpty() {
1160
+ let chunk = this.firstChunk;
1161
+ do {
1162
+ if (chunk.intro.length && chunk.intro.trim() || chunk.content.length && chunk.content.trim() || chunk.outro.length && chunk.outro.trim())
1163
+ return false;
1164
+ } while (chunk = chunk.next);
1165
+ return true;
1166
+ }
1167
+ length() {
1168
+ let chunk = this.firstChunk;
1169
+ let length = 0;
1170
+ do {
1171
+ length += chunk.intro.length + chunk.content.length + chunk.outro.length;
1172
+ } while (chunk = chunk.next);
1173
+ return length;
1174
+ }
1175
+ trimLines() {
1176
+ return this.trim("[\\r\\n]");
1177
+ }
1178
+ trim(charType) {
1179
+ return this.trimStart(charType).trimEnd(charType);
1180
+ }
1181
+ trimEndAborted(charType) {
1182
+ const rx = new RegExp((charType || "\\s") + "+$");
1183
+ this.outro = this.outro.replace(rx, "");
1184
+ if (this.outro.length) return true;
1185
+ let chunk = this.lastChunk;
1186
+ do {
1187
+ const end = chunk.end;
1188
+ const aborted = chunk.trimEnd(rx);
1189
+ if (chunk.end !== end) {
1190
+ if (this.lastChunk === chunk) {
1191
+ this.lastChunk = chunk.next;
1192
+ }
1193
+ this.byEnd[chunk.end] = chunk;
1194
+ this.byStart[chunk.next.start] = chunk.next;
1195
+ this.byEnd[chunk.next.end] = chunk.next;
1196
+ }
1197
+ if (aborted) return true;
1198
+ chunk = chunk.previous;
1199
+ } while (chunk);
1200
+ return false;
1201
+ }
1202
+ trimEnd(charType) {
1203
+ this.trimEndAborted(charType);
1204
+ return this;
1205
+ }
1206
+ trimStartAborted(charType) {
1207
+ const rx = new RegExp("^" + (charType || "\\s") + "+");
1208
+ this.intro = this.intro.replace(rx, "");
1209
+ if (this.intro.length) return true;
1210
+ let chunk = this.firstChunk;
1211
+ do {
1212
+ const end = chunk.end;
1213
+ const aborted = chunk.trimStart(rx);
1214
+ if (chunk.end !== end) {
1215
+ if (chunk === this.lastChunk) this.lastChunk = chunk.next;
1216
+ this.byEnd[chunk.end] = chunk;
1217
+ this.byStart[chunk.next.start] = chunk.next;
1218
+ this.byEnd[chunk.next.end] = chunk.next;
1219
+ }
1220
+ if (aborted) return true;
1221
+ chunk = chunk.next;
1222
+ } while (chunk);
1223
+ return false;
1224
+ }
1225
+ trimStart(charType) {
1226
+ this.trimStartAborted(charType);
1227
+ return this;
1228
+ }
1229
+ hasChanged() {
1230
+ return this.original !== this.toString();
1231
+ }
1232
+ _replaceRegexp(searchValue, replacement) {
1233
+ function getReplacement(match, str) {
1234
+ if (typeof replacement === "string") {
1235
+ return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
1236
+ if (i === "$") return "$";
1237
+ if (i === "&") return match[0];
1238
+ const num = +i;
1239
+ if (num < match.length) return match[+i];
1240
+ return `$${i}`;
1241
+ });
1242
+ } else {
1243
+ return replacement(...match, match.index, str, match.groups);
1244
+ }
1245
+ }
1246
+ function matchAll(re, str) {
1247
+ let match;
1248
+ const matches = [];
1249
+ while (match = re.exec(str)) {
1250
+ matches.push(match);
1251
+ }
1252
+ return matches;
1253
+ }
1254
+ if (searchValue.global) {
1255
+ const matches = matchAll(searchValue, this.original);
1256
+ matches.forEach((match) => {
1257
+ if (match.index != null) {
1258
+ const replacement2 = getReplacement(match, this.original);
1259
+ if (replacement2 !== match[0]) {
1260
+ this.overwrite(match.index, match.index + match[0].length, replacement2);
1261
+ }
1262
+ }
1263
+ });
1264
+ } else {
1265
+ const match = this.original.match(searchValue);
1266
+ if (match && match.index != null) {
1267
+ const replacement2 = getReplacement(match, this.original);
1268
+ if (replacement2 !== match[0]) {
1269
+ this.overwrite(match.index, match.index + match[0].length, replacement2);
1270
+ }
1271
+ }
1272
+ }
1273
+ return this;
1274
+ }
1275
+ _replaceString(string, replacement) {
1276
+ const { original } = this;
1277
+ const index = original.indexOf(string);
1278
+ if (index !== -1) {
1279
+ if (typeof replacement === "function") {
1280
+ replacement = replacement(string, index, original);
1281
+ }
1282
+ if (string !== replacement) {
1283
+ this.overwrite(index, index + string.length, replacement);
1284
+ }
1285
+ }
1286
+ return this;
1287
+ }
1288
+ replace(searchValue, replacement) {
1289
+ if (typeof searchValue === "string") {
1290
+ return this._replaceString(searchValue, replacement);
1291
+ }
1292
+ return this._replaceRegexp(searchValue, replacement);
1293
+ }
1294
+ _replaceAllString(string, replacement) {
1295
+ const { original } = this;
1296
+ const stringLength = string.length;
1297
+ for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
1298
+ const previous = original.slice(index, index + stringLength);
1299
+ let _replacement = replacement;
1300
+ if (typeof replacement === "function") {
1301
+ _replacement = replacement(previous, index, original);
1302
+ }
1303
+ if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
1304
+ }
1305
+ return this;
1306
+ }
1307
+ replaceAll(searchValue, replacement) {
1308
+ if (typeof searchValue === "string") {
1309
+ return this._replaceAllString(searchValue, replacement);
1310
+ }
1311
+ if (!searchValue.global) {
1312
+ throw new TypeError(
1313
+ "MagicString.prototype.replaceAll called with a non-global RegExp argument"
1314
+ );
1315
+ }
1316
+ return this._replaceRegexp(searchValue, replacement);
1317
+ }
1318
+ };
1319
+ }
1320
+ });
1321
+
178
1322
  // src/app-config.ts
179
1323
  import { createRequire } from "node:module";
180
1324
  import { pathToFileURL } from "node:url";
@@ -236,18 +1380,18 @@ function validateHostPages(value) {
236
1380
  }
237
1381
  return hp;
238
1382
  }
239
- function validatePathsInsideApp(options, appRoot, fs11, path10) {
1383
+ function validatePathsInsideApp(options, appRoot, fs12, path12) {
240
1384
  const checkModule = (field, value) => {
241
1385
  if (typeof value !== "string" || value.trim() === "") return;
242
- if (/^(https?:)?\/\//.test(value) || path10.isAbsolute(value)) {
1386
+ if (/^(https?:)?\/\//.test(value) || path12.isAbsolute(value)) {
243
1387
  appConfigError(
244
1388
  `${field} "${value}" \u4E0D\u662F\u672C\u9879\u76EE\u5185\u7684\u6A21\u5757\u8DEF\u5F84`,
245
1389
  "exposes/setup \u7684\u503C\u662F\u76F8\u5BF9\u672C\u5E94\u7528\u6839\u76EE\u5F55\u7684\u6E90\u6587\u4EF6\u8DEF\u5F84\uFF08URL/\u7EDD\u5BF9\u8DEF\u5F84\u65E0\u6CD5\u5728\u72EC\u7ACB\u4ED3\u5E93\u95F4\u79FB\u690D\uFF09",
246
1390
  `\u6539\u4E3A\u76F8\u5BF9\u8DEF\u5F84\uFF0C\u5982 './src/views/Home.vue'\uFF08\u914D\u7F6E\u6587\u4EF6\u76EE\u5F55 = \u5E94\u7528\u6839 ${appRoot}\uFF09`
247
1391
  );
248
1392
  }
249
- const abs = path10.resolve(appRoot, value);
250
- if (!fs11.existsSync(abs)) {
1393
+ const abs = path12.resolve(appRoot, value);
1394
+ if (!fs12.existsSync(abs)) {
251
1395
  appConfigError(
252
1396
  `${field} \u6307\u5411\u7684\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${value}`,
253
1397
  `\u6309\u5E94\u7528\u6839 ${appRoot} \u89E3\u6790\u540E\u672A\u627E\u5230\u8BE5\u6587\u4EF6`,
@@ -316,11 +1460,11 @@ function resolveEsbuild(configPath) {
316
1460
  );
317
1461
  }
318
1462
  async function loadAppConfig(configPath) {
319
- const fs11 = await import("node:fs");
1463
+ const fs12 = await import("node:fs");
320
1464
  const os = await import("node:os");
321
- const path10 = await import("node:path");
322
- const abs = path10.resolve(configPath);
323
- if (!fs11.existsSync(abs)) {
1465
+ const path12 = await import("node:path");
1466
+ const abs = path12.resolve(configPath);
1467
+ if (!fs12.existsSync(abs)) {
324
1468
  appConfigError(
325
1469
  `\u914D\u7F6E\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${abs}`,
326
1470
  "--config \u6307\u5411\u7684\u8DEF\u5F84\u5728\u672C\u673A\u4E0D\u5B58\u5728\uFF08\u76F8\u5BF9\u8DEF\u5F84\u4EE5 CLI \u8FDB\u7A0B cwd \u89E3\u6790\uFF09",
@@ -328,11 +1472,11 @@ async function loadAppConfig(configPath) {
328
1472
  );
329
1473
  }
330
1474
  if (abs.endsWith(".json")) {
331
- const parsed = JSON.parse(fs11.readFileSync(abs, "utf8"));
1475
+ const parsed = JSON.parse(fs12.readFileSync(abs, "utf8"));
332
1476
  if (isAggregateShape(parsed)) aggregateMigrationError();
333
- return finishAppShape(parsed, {}, abs, path10.dirname(abs), fs11, path10);
1477
+ return finishAppShape(parsed, {}, abs, path12.dirname(abs), fs12, path12);
334
1478
  }
335
- const rawSource = fs11.readFileSync(abs, "utf8");
1479
+ const rawSource = fs12.readFileSync(abs, "utf8");
336
1480
  if (/@fulgurjs\/federation\/config/.test(rawSource)) {
337
1481
  appConfigError(
338
1482
  `\u914D\u7F6E\u5BFC\u5165\u4E86\u5DF2\u5220\u9664\u7684\u5B50\u8DEF\u5F84 "@fulgurjs/federation/config"`,
@@ -363,21 +1507,21 @@ async function loadAppConfig(configPath) {
363
1507
  plugins: [selfRedirect],
364
1508
  logLevel: "silent"
365
1509
  });
366
- const tmpDir = fs11.mkdtempSync(path10.join(os.tmpdir(), "fulgurjs-appcfg-"));
1510
+ const tmpDir = fs12.mkdtempSync(path12.join(os.tmpdir(), "fulgurjs-appcfg-"));
367
1511
  try {
368
- const bundleFile = path10.join(tmpDir, "fulgurjs.config.bundle.mjs");
369
- fs11.writeFileSync(bundleFile, out.outputFiles[0].text);
1512
+ const bundleFile = path12.join(tmpDir, "fulgurjs.config.bundle.mjs");
1513
+ fs12.writeFileSync(bundleFile, out.outputFiles[0].text);
370
1514
  const mod = await import(
371
1515
  /* @vite-ignore */
372
1516
  `${pathToFileURL(bundleFile).href}?t=${Date.now()}`
373
1517
  );
374
1518
  if (isAggregateShape(mod.default)) aggregateMigrationError();
375
- return finishAppShape(mod.default, { hostPages: mod.hostPages }, abs, path10.dirname(abs), fs11, path10);
1519
+ return finishAppShape(mod.default, { hostPages: mod.hostPages }, abs, path12.dirname(abs), fs12, path12);
376
1520
  } finally {
377
- fs11.rmSync(tmpDir, { recursive: true, force: true });
1521
+ fs12.rmSync(tmpDir, { recursive: true, force: true });
378
1522
  }
379
1523
  }
380
- function finishAppShape(def, named, configPath, appRoot, fs11, path10) {
1524
+ function finishAppShape(def, named, configPath, appRoot, fs12, path12) {
381
1525
  if (def === void 0 || def === null) {
382
1526
  appConfigError(
383
1527
  "fulgurjs.config.ts \u6CA1\u6709\u53EF\u7528\u7684\u9ED8\u8BA4\u5BFC\u51FA",
@@ -390,7 +1534,7 @@ function finishAppShape(def, named, configPath, appRoot, fs11, path10) {
390
1534
  }
391
1535
  const options = def;
392
1536
  validateAppOptions(options);
393
- validatePathsInsideApp(options, appRoot, fs11, path10);
1537
+ validatePathsInsideApp(options, appRoot, fs12, path12);
394
1538
  const hostPages = named.hostPages !== void 0 ? validateHostPages(named.hostPages) : void 0;
395
1539
  return {
396
1540
  kind: "app",
@@ -644,6 +1788,543 @@ var init_init = __esm({
644
1788
  }
645
1789
  });
646
1790
 
1791
+ // src/init-plan.ts
1792
+ var init_plan_exports = {};
1793
+ __export(init_plan_exports, {
1794
+ applyIntegration: () => applyIntegration,
1795
+ formatIntegrationPlan: () => formatIntegrationPlan,
1796
+ planIntegration: () => planIntegration,
1797
+ rollbackIntegration: () => rollbackIntegration
1798
+ });
1799
+ import fs2 from "node:fs";
1800
+ import path2 from "node:path";
1801
+ import { createRequire as createRequire2 } from "node:module";
1802
+ async function validateSource(file, source) {
1803
+ const { transform } = requireHere("esbuild");
1804
+ const loader = /\.tsx$/.test(file) ? "tsx" : /\.jsx$/.test(file) ? "jsx" : /\.[cm]?ts$/.test(file) ? "ts" : "js";
1805
+ await transform(source, { loader, sourcefile: file, format: "esm", target: "es2022", logLevel: "silent" });
1806
+ }
1807
+ function rejectSymlink(file, label) {
1808
+ try {
1809
+ if (fs2.lstatSync(file).isSymbolicLink()) throw new Error(`\u4E0D\u6539\u5199\u7B26\u53F7\u94FE\u63A5\uFF1A${label}`);
1810
+ } catch (error) {
1811
+ if (error.code !== "ENOENT") throw error;
1812
+ }
1813
+ }
1814
+ function tokens(source) {
1815
+ const out = [];
1816
+ for (let i = 0; i < source.length; ) {
1817
+ const start = i, c = source[i];
1818
+ if (/\s/.test(c)) {
1819
+ i++;
1820
+ continue;
1821
+ }
1822
+ if (source.startsWith("//", i)) {
1823
+ const end = source.indexOf("\n", i);
1824
+ i = end < 0 ? source.length : end + 1;
1825
+ continue;
1826
+ }
1827
+ if (source.startsWith("/*", i)) {
1828
+ const end = source.indexOf("*/", i + 2);
1829
+ if (end < 0) throw new Error("\u6CE8\u91CA\u672A\u95ED\u5408");
1830
+ i = end + 2;
1831
+ continue;
1832
+ }
1833
+ if (c === "`") {
1834
+ i++;
1835
+ while (i < source.length && source[i] !== "`") {
1836
+ if (source[i] === "\\") {
1837
+ i += 2;
1838
+ continue;
1839
+ }
1840
+ if (source.startsWith("${", i)) throw new Error("\u542B\u63D2\u503C\u6A21\u677F\uFF0C\u8BF7\u6309\u9884\u89C8\u4E2D\u7684\u63A5\u5165\u5757\u624B\u52A8\u4FEE\u6539\u914D\u7F6E");
1841
+ i++;
1842
+ }
1843
+ if (i >= source.length) throw new Error("\u6A21\u677F\u672A\u95ED\u5408");
1844
+ out.push({ value: source.slice(start + 1, i), start, end: ++i, literal: true });
1845
+ continue;
1846
+ }
1847
+ if (c === "/") {
1848
+ const previous = out.at(-1);
1849
+ const regex = !previous || !previous.literal && ["=", ":", ",", "(", "[", "{", "!", "?", ">", "return"].includes(previous.value);
1850
+ if (!regex) throw new Error("\u659C\u6760\u8868\u8FBE\u5F0F\u65E0\u6CD5\u786E\u5B9A\u662F\u6B63\u5219\u8FD8\u662F\u9664\u6CD5\uFF0C\u8BF7\u624B\u52A8\u5408\u5E76\u914D\u7F6E");
1851
+ i++;
1852
+ let inClass = false;
1853
+ while (i < source.length) {
1854
+ const char = source[i++];
1855
+ if (char === "\\") {
1856
+ i++;
1857
+ continue;
1858
+ }
1859
+ if (char === "[") inClass = true;
1860
+ else if (char === "]") inClass = false;
1861
+ else if (char === "/" && !inClass) break;
1862
+ }
1863
+ while (i < source.length && /[a-z]/i.test(source[i])) i++;
1864
+ out.push({ value: source.slice(start, i), start, end: i, literal: true });
1865
+ continue;
1866
+ }
1867
+ if (c === '"' || c === "'") {
1868
+ i++;
1869
+ while (i < source.length && source[i] !== c) {
1870
+ if (source[i] === "\\") throw new Error("\u542B\u8F6C\u4E49\u5B57\u7B26\u4E32\uFF0C\u8BF7\u4EBA\u5DE5\u786E\u8BA4\u914D\u7F6E");
1871
+ i++;
1872
+ }
1873
+ if (i >= source.length) throw new Error("\u5B57\u7B26\u4E32\u672A\u95ED\u5408");
1874
+ i++;
1875
+ out.push({ value: source.slice(start + 1, i - 1), start, end: i, literal: true });
1876
+ continue;
1877
+ }
1878
+ if (/[\w$]/.test(c)) {
1879
+ while (i < source.length && /[\w$]/.test(source[i])) i++;
1880
+ out.push({ value: source.slice(start, i), start, end: i });
1881
+ continue;
1882
+ }
1883
+ if (source.startsWith("...", i)) {
1884
+ out.push({ value: "...", start, end: i + 3 });
1885
+ i += 3;
1886
+ continue;
1887
+ }
1888
+ out.push({ value: c, start, end: ++i });
1889
+ }
1890
+ return out;
1891
+ }
1892
+ function closeAt(ts, at) {
1893
+ const closes = { "{": "}", "[": "]", "(": ")" };
1894
+ const stack = [];
1895
+ for (let i = at; i < ts.length; i++) {
1896
+ const token = ts[i];
1897
+ if (token.literal) continue;
1898
+ if (closes[token.value]) stack.push(closes[token.value]);
1899
+ else if (["}", "]", ")"].includes(token.value) && stack.pop() !== token.value) throw new Error("\u65E0\u6CD5\u786E\u8BA4\u914D\u7F6E\u62EC\u53F7\u8FB9\u754C");
1900
+ if (!stack.length) return i;
1901
+ }
1902
+ throw new Error("\u65E0\u6CD5\u786E\u8BA4\u914D\u7F6E\u7ED3\u675F\u4F4D\u7F6E");
1903
+ }
1904
+ async function wireVite(file, source) {
1905
+ await validateSource(file, source);
1906
+ await init;
1907
+ const [imports] = parse(source);
1908
+ const pluginImport = imports.find((item) => item.d === -1 && item.n === "@fulgurjs/federation");
1909
+ if (pluginImport) throw new Error("\u5DF2\u6709 federation \u5BFC\u5165\uFF0C\u9700\u6838\u5B9E\u5B83\u662F\u5426\u5DF2\u5728\u5B9E\u9645 plugins \u4E2D\u6CE8\u518C\uFF1B\u4E0D\u4F1A\u91CD\u590D\u63D2\u5165\u53E6\u4E00\u5957\u914D\u7F6E");
1910
+ const ts = tokens(source);
1911
+ if (ts.some((t) => !t.literal && ["fulgurjsFederation", "fulgurjsConfig"].includes(t.value))) throw new Error("\u63A5\u5165\u53D8\u91CF\u540D\u5DF2\u88AB\u4F7F\u7528\uFF0C\u8BF7\u4EBA\u5DE5\u5408\u5E76\u914D\u7F6E");
1912
+ const exports = ts.map((t, i) => t.value === "export" && !t.literal && ts[i + 1]?.value === "default" ? i : -1).filter((i) => i >= 0);
1913
+ if (exports.length !== 1) throw new Error("\u9700\u8981\u552F\u4E00\u7684 export default \u914D\u7F6E");
1914
+ let obj = exports[0] + 2;
1915
+ let outerEnd = -1, expressionEnd = -1;
1916
+ if (ts[obj]?.value !== "{" && ts[obj + 1]?.value === "(") {
1917
+ const call = ts[obj]?.value;
1918
+ const viteImport = imports.find((item) => item.d === -1 && item.n === "vite");
1919
+ const declaration = viteImport ? source.slice(viteImport.ss, viteImport.se) : "";
1920
+ const binding = declaration.match(/\bdefineConfig(?:\s+as\s+(\w+))?\b/);
1921
+ if (!binding || call !== (binding[1] ?? "defineConfig")) throw new Error("\u81EA\u5B9A\u4E49\u914D\u7F6E\u5305\u88C5\u5668\u9700\u8981\u624B\u52A8\u5408\u5E76 federation \u63D2\u4EF6");
1922
+ outerEnd = closeAt(ts, obj + 1);
1923
+ obj += 2;
1924
+ }
1925
+ if (ts[obj]?.value !== "{") {
1926
+ if (ts[obj]?.value === "async") throw new Error("\u5F02\u6B65\u914D\u7F6E\u9700\u624B\u52A8\u6838\u5B9E\u63D2\u4EF6\u6CE8\u518C");
1927
+ let arrow = obj;
1928
+ if (ts[arrow]?.value === "(") arrow = closeAt(ts, arrow) + 1;
1929
+ else arrow++;
1930
+ if (ts[arrow]?.value === ":") {
1931
+ arrow++;
1932
+ while (ts[arrow] && ts[arrow].value !== "=") arrow++;
1933
+ }
1934
+ if (ts[arrow]?.value !== "=" || ts[arrow + 1]?.value !== ">") throw new Error("\u914D\u7F6E\u4E0D\u662F\u53EF\u8BC6\u522B\u7684\u5BF9\u8C61\u6216\u7BAD\u5934\u5DE5\u5382\uFF0C\u8BF7\u624B\u52A8\u5408\u5E76");
1935
+ let body = arrow + 2;
1936
+ if (ts[body]?.value === "(" && ts[body + 1]?.value === "{") {
1937
+ obj = body + 1;
1938
+ expressionEnd = closeAt(ts, body);
1939
+ if (closeAt(ts, obj) + 1 !== expressionEnd) throw new Error("\u914D\u7F6E\u4E0D\u662F\u5355\u4E2A\u8FD4\u56DE\u5BF9\u8C61\uFF0C\u8BF7\u4EBA\u5DE5\u5408\u5E76");
1940
+ if (outerEnd < 0) outerEnd = expressionEnd;
1941
+ } else {
1942
+ if (ts[body]?.value !== "{") throw new Error("\u914D\u7F6E\u5DE5\u5382\u8FD4\u56DE\u53D8\u91CF\u6216\u590D\u6742\u8868\u8FBE\u5F0F\uFF0C\u8BF7\u624B\u52A8\u5408\u5E76");
1943
+ const bodyEnd = closeAt(ts, body);
1944
+ expressionEnd = bodyEnd;
1945
+ if (outerEnd < 0) outerEnd = bodyEnd;
1946
+ let found = -1;
1947
+ for (let i = body + 1; i < bodyEnd; i++) {
1948
+ if (!ts[i].literal && ["if", "switch", "try", "for", "while", "function"].includes(ts[i].value)) throw new Error("\u914D\u7F6E\u5DE5\u5382\u6709\u63A7\u5236\u6D41\u6216\u5C40\u90E8\u51FD\u6570\uFF0C\u9700\u8981\u4EBA\u5DE5\u786E\u8BA4\u6240\u6709\u8FD4\u56DE\u5206\u652F");
1949
+ if (ts[i].value === "return" && !ts[i].literal) {
1950
+ found = i + 1;
1951
+ break;
1952
+ }
1953
+ if (!ts[i].literal && ["{", "[", "("].includes(ts[i].value)) i = closeAt(ts, i);
1954
+ }
1955
+ if (found < 0 || ts[found]?.value !== "{") throw new Error("\u672A\u627E\u5230\u552F\u4E00\u7684\u76F4\u63A5 return \u914D\u7F6E\u5BF9\u8C61");
1956
+ obj = found;
1957
+ const rest = ts.slice(closeAt(ts, obj) + 1, bodyEnd).map((t) => t.value).join("");
1958
+ if (!["", ";"].includes(rest)) throw new Error("return \u540E\u4ECD\u6709\u8BED\u53E5\uFF0C\u914D\u7F6E\u5DE5\u5382\u9700\u4EBA\u5DE5\u786E\u8BA4");
1959
+ }
1960
+ }
1961
+ const end = closeAt(ts, obj);
1962
+ if (expressionEnd < 0) expressionEnd = end;
1963
+ if (outerEnd < 0) outerEnd = end;
1964
+ else if (outerEnd !== expressionEnd && expressionEnd + 1 !== outerEnd) throw new Error("\u914D\u7F6E\u5BF9\u8C61\u540E\u6709\u989D\u5916\u8868\u8FBE\u5F0F\u6216\u53C2\u6570\uFF0C\u8BF7\u624B\u52A8\u5408\u5E76");
1965
+ const tail = ts.slice(outerEnd + 1).map((t) => t.value).join("");
1966
+ if (!["", ";"].includes(tail)) throw new Error("\u914D\u7F6E\u540E\u5B58\u5728\u5305\u88C5\u6216\u9644\u52A0\u8BED\u53E5\uFF0C\u8BF7\u4EBA\u5DE5\u5408\u5E76");
1967
+ let plugins = -1, pluginsEnd = -1;
1968
+ for (let i = obj + 1; i < end; ) {
1969
+ if (ts[i].value === ",") {
1970
+ i++;
1971
+ continue;
1972
+ }
1973
+ const key = ts[i];
1974
+ if (key.value === "...") throw new Error("\u9876\u5C42 spread \u53EF\u80FD\u8986\u76D6 plugins\uFF0C\u8BF7\u4EBA\u5DE5\u5408\u5E76");
1975
+ if (ts[i + 1]?.value !== ":") {
1976
+ if (!key.literal && /^[A-Za-z_$][\w$]*$/.test(key.value) && [",", "}"].includes(ts[i + 1]?.value)) {
1977
+ if (key.value === "plugins") throw new Error("plugins \u4F7F\u7528\u7B80\u5199\u53D8\u91CF\uFF0C\u8BF7\u4EBA\u5DE5\u5408\u5E76");
1978
+ i++;
1979
+ continue;
1980
+ }
1981
+ throw new Error("\u9876\u5C42\u8BA1\u7B97\u5C5E\u6027\u6216\u65B9\u6CD5\u9700\u4EBA\u5DE5\u786E\u8BA4");
1982
+ }
1983
+ if (key.value === "plugins") {
1984
+ if (plugins >= 0) throw new Error("\u5B58\u5728\u91CD\u590D plugins \u5C5E\u6027");
1985
+ plugins = i + 2;
1986
+ }
1987
+ i += 2;
1988
+ while (i < end && ts[i].value !== ",") {
1989
+ if (!ts[i].literal && ["[", "{", "("].includes(ts[i].value)) i = closeAt(ts, i) + 1;
1990
+ else i++;
1991
+ }
1992
+ if (key.value === "plugins") pluginsEnd = i;
1993
+ }
1994
+ const edit = new MagicString(source);
1995
+ if (plugins >= 0) {
1996
+ if (ts[plugins]?.value === "[") {
1997
+ const last = closeAt(ts, plugins);
1998
+ const separator = last === plugins + 1 || ts[last - 1].value === "," ? "" : ",";
1999
+ edit.appendLeft(ts[last].start, separator + "\n fulgurjsFederation(fulgurjsConfig),\n ");
2000
+ } else {
2001
+ const finish = ts[pluginsEnd].start;
2002
+ edit.appendLeft(ts[plugins].start, "[");
2003
+ edit.appendLeft(finish, ", fulgurjsFederation(fulgurjsConfig)]");
2004
+ }
2005
+ } else edit.appendLeft(ts[obj].end, "\n plugins: [fulgurjsFederation(fulgurjsConfig)],");
2006
+ edit.prepend(`${OWNER}
2007
+ import fulgurjsFederation from '@fulgurjs/federation'
2008
+ import fulgurjsConfig from './fulgurjs.config'
2009
+ `);
2010
+ const result = edit.toString();
2011
+ await validateSource(file, result);
2012
+ return result;
2013
+ }
2014
+ async function applicationFromEntry(file, source, framework) {
2015
+ await validateSource(file, source);
2016
+ await init;
2017
+ const header2 = source.match(/^\s*(?:(?:\/\/[^\n]*(?:\n|$)|\/\*[\s\S]*?\*\/)\s*)*/)?.[0] ?? "";
2018
+ let body = source.slice(header2.length);
2019
+ const declarations = [];
2020
+ const importStatements = [];
2021
+ while (true) {
2022
+ const comment = body.match(/^\s*(?:\/\/[^\n]*(?:\n|$)|\/\*[\s\S]*?\*\/)/);
2023
+ if (comment) {
2024
+ declarations.push(comment[0]);
2025
+ body = body.slice(comment[0].length);
2026
+ continue;
2027
+ }
2028
+ const match = body.match(/^\s*(import\s+(?:(?:type\s+)?[\w*$ {},\r\n]+?\s+from\s+)?(['"])([^'"\n]+)\2\s*;?)/);
2029
+ if (!match) break;
2030
+ const statement = match[1];
2031
+ const [items] = parse(statement);
2032
+ if (items.length !== 1 || items[0].d !== -1) throw new Error("\u5165\u53E3 import \u7ED3\u6784\u9700\u4EBA\u5DE5\u6838\u5B9E");
2033
+ const spec = items[0].n;
2034
+ if (/router|pinia|vuex|redux|zustand/i.test(spec)) throw new Error("\u5165\u53E3\u4F9D\u8D56\u4E1A\u52A1\u8DEF\u7531\u6216\u72B6\u6001\uFF1B\u6309 existing-apps \u6307\u5357\u5C06\u5B83\u4EEC\u5728\u5DE5\u5382\u5185\u6309\u5B9E\u4F8B\u521B\u5EFA\uFF0C\u4E0D\u81EA\u52A8\u6539\u5199");
2035
+ importStatements.push({ spec, code: statement });
2036
+ if (spec !== "react-dom/client") declarations.push(statement);
2037
+ body = body.slice(match[0].length);
2038
+ }
2039
+ body = body.trim();
2040
+ let expression, target;
2041
+ if (framework === "vue") {
2042
+ const named = declarations.join("\n").match(/import\s*\{\s*createApp\s*\}\s*from\s*['"]vue['"]/);
2043
+ const direct = body.match(/^createApp\(\s*([A-Za-z_$][\w$]*)\s*\)\.mount\(\s*(['"])(#[\w-]+)\2\s*\)\s*;?$/);
2044
+ const variable = body.match(/^const\s+(\w+)\s*=\s*createApp\(\s*([A-Za-z_$][\w$]*)\s*\)\s*;?\s*\1\.mount\(\s*(['"])(#[\w-]+)\3\s*\)\s*;?$/);
2045
+ if (!named || !direct && !variable) throw new Error("\u4EC5\u81EA\u52A8\u63D0\u53D6\u6700\u5C0F createApp(App).mount \u5165\u53E3\uFF1B\u63D2\u4EF6\u3001\u5B88\u536B\u4E0E\u5F02\u6B65\u4E1A\u52A1\u88C5\u914D\u8BF7\u6309\u6307\u5357\u8FC1\u5165 defineApplication \u5DE5\u5382");
2046
+ expression = `createApp(${direct?.[1] ?? variable[2]})`;
2047
+ target = direct?.[3] ?? variable[4];
2048
+ } else {
2049
+ const named = importStatements.find((item) => item.spec === "react-dom/client");
2050
+ if (!named || !/^import\s*\{\s*createRoot\s*\}\s*from/.test(named.code)) throw new Error("\u4EC5\u81EA\u52A8\u63D0\u53D6\u5177\u540D createRoot \u5BFC\u5165\u7684\u5165\u53E3\uFF1B\u5176\u4ED6\u542F\u52A8\u5F62\u5F0F\u8BF7\u6309\u6307\u5357\u8FC1\u79FB");
2051
+ const direct = body.match(/^createRoot\(\s*document\.getElementById\(\s*(['"])([\w-]+)\1\s*\)!?\s*\)\.render\(([\s\S]+)\)\s*;?$/);
2052
+ if (!direct) throw new Error("\u4EC5\u81EA\u52A8\u63D0\u53D6 createRoot(document.getElementById(...)).render(...)\uFF1B\u5176\u4F59\u5165\u53E3\u9700\u4EBA\u5DE5\u5408\u5E76");
2053
+ expression = direct[3].trim().replace(/,\s*$/, "");
2054
+ target = "#" + direct[2];
2055
+ if (!expression.startsWith("<") || !expression.endsWith(">")) throw new Error("React \u6839\u6E32\u67D3\u4E0D\u662F\u660E\u786E JSX \u8868\u8FBE\u5F0F\uFF0C\u8BF7\u4EBA\u5DE5\u5408\u5E76");
2056
+ }
2057
+ const application = `${OWNER}
2058
+ /** \u72EC\u7ACB\u542F\u52A8\u4E0E\u6865\u63A5\u5171\u7528\u5DE5\u5382\uFF1B\u6BCF\u6B21\u6302\u8F7D\u521B\u5EFA\u81EA\u5DF1\u7684\u5B9E\u4F8B\u3002\u4E1A\u52A1\u63D2\u4EF6\u5728\u5DE5\u5382\u5185\u88C5\u914D\uFF0C\u4E0D\u5728\u6A21\u5757\u9876\u5C42\u6302\u8F7D\u3002 */
2059
+ ${declarations.join("\n")}
2060
+ import { defineApplication } from '@fulgurjs/federation/${framework}'
2061
+
2062
+ export default defineApplication(() => ${expression})
2063
+ `;
2064
+ const main2 = `${OWNER}
2065
+ ${header2}// \u72EC\u7ACB\u5165\u53E3\u4F7F\u7528\u540C\u4E00\u4EFD\u88C5\u914D\uFF1B\u5BBF\u4E3B\u76F4\u63A5\u52A0\u8F7D application \u7684\u9ED8\u8BA4\u5BFC\u51FA\uFF0C\u4E0D\u590D\u5236\u542F\u52A8\u903B\u8F91\u3002
2066
+ import application from './application'
2067
+ void application.start(${JSON.stringify(target)}).catch(console.error)
2068
+ `;
2069
+ await validateSource(framework === "react" ? "application.tsx" : "application.ts", application);
2070
+ return { application, main: main2 };
2071
+ }
2072
+ async function planIntegration(input) {
2073
+ const root = fs2.realpathSync(path2.resolve(input.cwd));
2074
+ const pkgFile = path2.join(root, "package.json");
2075
+ const pkg = JSON.parse(fs2.readFileSync(pkgFile, "utf8"));
2076
+ const framework = input.framework ?? detectFrameworkFromPackageJson(pkg);
2077
+ const plan = { root, framework, role: input.role ?? "dual", kind: input.kind ?? "component", edits: [], tasks: [], evidence: [], commands: [] };
2078
+ const task = (file, message, blocking = true) => plan.tasks.push({ file, message, blocking });
2079
+ const read = (file) => {
2080
+ safe(file);
2081
+ return fs2.existsSync(path2.join(root, file)) ? fs2.readFileSync(path2.join(root, file), "utf8") : null;
2082
+ };
2083
+ const safe = (file) => {
2084
+ const absolute = path2.resolve(root, file), relative = path2.relative(root, absolute);
2085
+ if (!relative || relative.startsWith("..") || path2.isAbsolute(relative)) throw new Error(`\u8DEF\u5F84\u5FC5\u987B\u5728\u5F53\u524D\u5E94\u7528\u5185\uFF1A${file}`);
2086
+ let current = root;
2087
+ for (const part of relative.split(path2.sep)) {
2088
+ current = path2.join(current, part);
2089
+ rejectSymlink(current, file);
2090
+ }
2091
+ return relative.split(path2.sep).join("/");
2092
+ };
2093
+ const add = (file, after, reason, replace = false) => {
2094
+ file = safe(file);
2095
+ const before = read(file);
2096
+ if (before !== after) {
2097
+ if (before !== null && !replace) task(file, "\u5DF2\u6709\u4E0D\u540C\u5185\u5BB9\uFF0C\u4FDD\u7559\u539F\u6587\u4EF6\uFF1B\u8BF7\u4EBA\u5DE5\u5408\u5E76\uFF0C\u4E0D\u8986\u76D6\u5DF2\u6709\u63A5\u5165\u6216\u4E1A\u52A1\u4FEE\u6539");
2098
+ else plan.edits.push({ file, before, after, reason });
2099
+ }
2100
+ };
2101
+ if (fs2.existsSync(path2.join(root, JOURNAL))) task(JOURNAL, "\u4E0A\u6B21\u5199\u5165\u88AB\u4E2D\u65AD\uFF1B\u5148\u8FD0\u884C fulgurjs init --rollback \u6062\u590D\uFF0C\u518D\u91CD\u65B0\u9884\u89C8");
2102
+ if (!framework) {
2103
+ task("package.json", "\u65E0\u6CD5\u552F\u4E00\u5224\u65AD Vue/React\uFF0C\u8BF7\u663E\u5F0F\u6307\u5B9A --framework vue|react");
2104
+ return plan;
2105
+ }
2106
+ plan.evidence.push(`\u6846\u67B6\uFF1A${framework}\uFF08${input.framework ? "\u663E\u5F0F\u9009\u62E9" : "package.json \u4F9D\u8D56"}\uFF09`, `\u573A\u666F\uFF1A${plan.kind}\uFF1B\u89D2\u8272\uFF1A${plan.role}`);
2107
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
2108
+ const manager = typeof pkg.packageManager === "string" && pkg.packageManager.startsWith("pnpm@") ? "pnpm" : fs2.existsSync(path2.join(root, "pnpm-lock.yaml")) ? "pnpm" : "npm";
2109
+ if (!deps["@fulgurjs/federation"]) task("package.json", `\u5148\u8FD0\u884C ${manager === "pnpm" ? "pnpm add" : "npm install"} @fulgurjs/federation\uFF1B\u8BA1\u5212\u4E0D\u4F1A\u81EA\u884C\u5B89\u88C5\u6216\u6539\u9501\u6587\u4EF6`, false);
2110
+ const viteFiles = ["vite.config.ts", "vite.config.mts", "vite.config.js", "vite.config.mjs"].filter((f) => read(f) !== null);
2111
+ const viteFile = viteFiles.length === 1 ? viteFiles[0] : null;
2112
+ if (!viteFile) task("vite.config", "\u672A\u627E\u5230\u552F\u4E00 Vite \u914D\u7F6E\uFF08\u652F\u6301 ts/mts/js/mjs\uFF09\uFF1B\u660E\u786E\u5B9E\u9645\u914D\u7F6E\u540E\u624B\u52A8\u6CE8\u518C federation(fulgurjsConfig)");
2113
+ else {
2114
+ try {
2115
+ const code = read(viteFile);
2116
+ if (code.startsWith(OWNER)) plan.evidence.push(`${viteFile}\uFF1A\u5DF2\u6709\u672C\u5DE5\u5177\u63A5\u7EBF\uFF0C\u4FDD\u7559\u539F\u6587\u4EF6\uFF1B\u518D\u8FD0\u884C doctor \u6838\u67E5`);
2117
+ else add(viteFile, await wireVite(viteFile, code), "\u5728\u5B9E\u9645\u9876\u5C42 plugins \u6570\u7EC4\u6CE8\u518C\u63D2\u4EF6\uFF0C\u4FDD\u7559\u539F\u6709\u914D\u7F6E\u4E0E\u6CE8\u91CA", true);
2118
+ } catch (error) {
2119
+ task(viteFile, `${error.message}\u3002\u624B\u52A8\u63A5\u5165\u5757\uFF1Aimport federation from '@fulgurjs/federation'; import fulgurjsConfig from './fulgurjs.config'; plugins: [...\u539F\u63D2\u4EF6, federation(fulgurjsConfig)]`);
2120
+ }
2121
+ }
2122
+ const appExt = framework === "react" ? "tsx" : "ts";
2123
+ let exposes = input.exposes ?? {};
2124
+ if (plan.kind === "app" && plan.role !== "consumer") {
2125
+ const appFile = `src/application.${appExt}`;
2126
+ const existing = read(appFile);
2127
+ if (existing) {
2128
+ if (!existing.startsWith(OWNER) && !/export\s+default\s+defineApplication(?:<[^;]+?>)?\s*\(/.test(existing)) task(appFile, "\u5DF2\u6709\u5E94\u7528\u88C5\u914D\u6587\u4EF6\uFF0C\u65E0\u6CD5\u786E\u8BA4\u9ED8\u8BA4\u5BFC\u51FA\u7684 defineApplication\uFF1B\u4FDD\u7559\u539F\u4EE3\u7801\uFF0C\u5148\u6309\u6307\u5357\u6838\u5B9E\u88C5\u914D");
2129
+ else {
2130
+ exposes = { ...exposes, "./bridge": "./" + appFile };
2131
+ plan.evidence.push(`${appFile}\uFF1A\u4FDD\u7559\u5DF2\u751F\u6210\u88C5\u914D`);
2132
+ }
2133
+ } else {
2134
+ const candidates = input.entry ? [safe(input.entry)] : [`src/main.${framework === "react" ? "tsx" : "ts"}`, `src/main.${framework === "react" ? "jsx" : "js"}`].filter((f) => read(f) !== null);
2135
+ if (candidates.length !== 1 || read(candidates[0]) === null) task("src/main", "\u65E0\u6CD5\u5B9A\u4F4D\u552F\u4E00\u542F\u52A8\u5165\u53E3\uFF0C\u8BF7\u663E\u5F0F\u6307\u5B9A --entry <\u5F53\u524D\u5E94\u7528\u5185\u8DEF\u5F84>");
2136
+ else {
2137
+ try {
2138
+ const entry = candidates[0], result = await applicationFromEntry(entry, read(entry), framework);
2139
+ add(appFile, result.application, "\u5C06\u53EF\u8BC1\u660E\u7684\u6700\u5C0F\u542F\u52A8\u903B\u8F91\u63D0\u53D6\u4E3A\u72EC\u7ACB/\u6865\u63A5\u5171\u7528\u5DE5\u5382");
2140
+ add(entry, result.main, "\u72EC\u7ACB\u5165\u53E3\u6539\u4E3A application.start\uFF1B\u6302\u8F7D\u8D23\u4EFB\u4EA4\u7ED9\u63D2\u4EF6", true);
2141
+ exposes = { ...exposes, "./bridge": "./" + appFile };
2142
+ } catch (error) {
2143
+ task(candidates[0], `${error.message}\u3002\u53C2\u8003 docs/zh/guide/existing-apps.md\uFF1B\u6865\u63A5\u8DEF\u7531\u5FC5\u987B\u4F7F\u7528\u53D7\u63A7 memory\uFF0C\u72EC\u7ACB\u6A21\u5F0F\u7EE7\u7EED web history\u3002`);
2144
+ }
2145
+ }
2146
+ }
2147
+ }
2148
+ const remoteEntries = Object.entries(input.remotes ?? {});
2149
+ if (plan.role === "provider" && remoteEntries.length) task("\u89D2\u8272", "\u63D0\u4F9B/\u6D88\u8D39\u540C\u65F6\u5B58\u5728\u8BF7\u4F7F\u7528 --role dual\uFF1Bprovider \u4E0D\u63A5\u53D7 --remote");
2150
+ if (plan.role === "consumer" && Object.keys(exposes).length) task("\u89D2\u8272", "\u63D0\u4F9B/\u6D88\u8D39\u540C\u65F6\u5B58\u5728\u8BF7\u4F7F\u7528 --role dual\uFF1Bconsumer \u4E0D\u63A5\u53D7 --expose");
2151
+ for (const [key, url] of remoteEntries) {
2152
+ let validURL = false;
2153
+ try {
2154
+ const parsed = new URL(url);
2155
+ validURL = ["http:", "https:"].includes(parsed.protocol) && !!parsed.hostname;
2156
+ } catch {
2157
+ }
2158
+ if (!/^[A-Za-z0-9_-]+$/.test(key) || !validURL) task("remotes", `--remote \u5FC5\u987B\u4E3A \u5BB9\u5668\u540D=http(s)://\u5F00\u53D1\u5730\u5740\uFF0C\u5B9E\u9645\uFF1A${key}=${url}`);
2159
+ }
2160
+ for (const [key, file] of Object.entries(exposes)) {
2161
+ if (!key.startsWith("./") || !file.startsWith("./")) {
2162
+ task("exposes", `\u66B4\u9732\u952E\u4E0E\u8DEF\u5F84\u987B\u4EE5 ./ \u5F00\u5934\uFF1A${key}=${file}`);
2163
+ continue;
2164
+ }
2165
+ const relative = safe(file);
2166
+ if (read(relative) === null && !plan.edits.some((edit) => edit.file === relative)) task(relative, "expose \u6307\u5411\u4E0D\u5B58\u5728\u7684\u6587\u4EF6\uFF1B\u9009\u62E9\u771F\u5B9E\u6A21\u5757\u6216\u7EC4\u4EF6\uFF0C\u4E0D\u751F\u6210\u5047\u4E1A\u52A1\u7EC4\u4EF6");
2167
+ }
2168
+ const configFile = "fulgurjs.config.ts";
2169
+ const config = read(configFile);
2170
+ if (!config) {
2171
+ if (plan.role !== "consumer" && !Object.keys(exposes).length) task(configFile, "\u63D0\u4F9B\u65B9\u5FC5\u987B\u9009\u62E9\u771F\u5B9E\u66B4\u9732\u6587\u4EF6\uFF1A--expose ./Button=./src/components/Button.vue\uFF1B\u666E\u901A\u51FD\u6570\u4E5F\u53EF\u76F4\u63A5\u66B4\u9732");
2172
+ if (plan.role !== "provider" && !remoteEntries.length) task(configFile, "\u6D88\u8D39\u65B9\u9700\u8981\u771F\u5B9E\u8FDC\u7A0B\u5F00\u53D1\u5730\u5740\uFF1A--remote remote-a=http://localhost:5174/remote-a\uFF1B\u4E0D\u4F1A\u731C\u7AEF\u53E3");
2173
+ const name = input.name ?? (typeof pkg.name === "string" ? pkg.name.replace(/^@/, "").replace(/[^A-Za-z0-9_-]/g, "-") : "");
2174
+ if (!name || !/^[A-Za-z0-9_-]+$/.test(name)) task(configFile, "\u8BF7\u7528 --name \u6307\u5B9A\u540C\u4E00\u9875\u9762\u5185\u552F\u4E00\u7684\u5BB9\u5668\u540D\uFF08\u5B57\u6BCD/\u6570\u5B57/\u4E0B\u5212\u7EBF/\u8FDE\u5B57\u7B26\uFF09");
2175
+ const shared = framework === "vue" ? { vue: { singleton: true } } : { react: { singleton: true }, "react-dom": { singleton: true } };
2176
+ const body = { name, ...Object.keys(exposes).length ? { exposes } : {}, ...remoteEntries.length ? { remotes: Object.fromEntries(remoteEntries.map(([key, url]) => [key, { dev: url, prod: "/" + key }])) } : {}, shared };
2177
+ add(configFile, `${OWNER}
2178
+ /** \u63D0\u4F9B/\u6D88\u8D39\u58F0\u660E\uFF1B\u5F00\u53D1\u5730\u5740\u6765\u81EA\u663E\u5F0F\u8F93\u5165\uFF0C\u751F\u4EA7\u8DEF\u5F84\u9700\u6309\u5B9E\u9645\u90E8\u7F72\u6838\u5BF9\u3002 */
2179
+ import type { FederationOptions } from '@fulgurjs/federation'
2180
+
2181
+ export default ${JSON.stringify(body, null, 2)} satisfies FederationOptions
2182
+ `, "\u751F\u6210\u4F7F\u7528\u771F\u5B9E\u6587\u4EF6\u548C\u663E\u5F0F\u5730\u5740\u7684\u914D\u7F6E\uFF0C\u4E0D\u589E\u52A0\u65E0\u5173 setup/\u83DC\u5355/\u4F1A\u8BDD\u6587\u4EF6");
2183
+ } else {
2184
+ plan.evidence.push(`${configFile} \u5DF2\u5B58\u5728\uFF0C\u4FDD\u7559\u6240\u6709\u8005\u914D\u7F6E\uFF0C\u4E0D\u6309\u547D\u4EE4\u53C2\u6570\u8986\u76D6`);
2185
+ if (!config.startsWith(OWNER)) task(configFile, "\u5DF2\u6709\u914D\u7F6E\u9700\u624B\u52A8\u6838\u5BF9\u672C\u6B21 remotes/exposes\uFF0C\u6216\u53EA\u4F7F\u7528 init --config/doctor --config \u68C0\u67E5");
2186
+ }
2187
+ if (plan.kind === "app" && plan.role !== "provider") {
2188
+ const remote = remoteEntries[0]?.[0];
2189
+ if (remote) add(`src/fulgurjs/RemoteApplication.${framework === "react" ? "tsx" : "vue"}`, hostView(framework, remote), "\u751F\u6210\u53EF\u653E\u8FDB\u5DF2\u6709\u8DEF\u7531\u7684\u6302\u8F7D\u89C6\u56FE\uFF1B\u8DEF\u7531\u548C\u767B\u5F55\u4E0A\u4E0B\u6587\u7531\u5E94\u7528\u660E\u786E\u51B3\u5B9A");
2190
+ task("\u5BBF\u4E3B\u8DEF\u7531", "\u5C06 RemoteApplication \u89C6\u56FE\u52A0\u5165\u5DF2\u6709\u9875\u9762/\u8DEF\u7531\u3002\u542F\u7528 URL \u540C\u6B65\u65F6\uFF0C\u6309\u6307\u5357\u7ED1\u5B9A\u5BBF\u4E3B\u5BFC\u822A\u7AEF\u53E3\u4E0E\u4E00\u4E2A\u9759\u6001\u6302\u8F7D\u524D\u7F00\uFF1B\u4E0D\u91CD\u590D\u767B\u8BB0\u5B50\u5E94\u7528\u83DC\u5355\u3002", false);
2191
+ task("\u4F1A\u8BDD\u4E0E\u4E1A\u52A1\u4E0A\u4E0B\u6587", "\u6709\u767B\u5F55\u9700\u6C42\u65F6\u660E\u786E token getter/sessionKey\u3001\u6743\u9650\u4E0E\u4E3B\u9898\u5F52\u5C5E\uFF1B\u6CA1\u6709\u9700\u6C42\u4E0D\u589E\u52A0\u6587\u4EF6\u3002\u5DE5\u5177\u4E0D\u731C\u51ED\u636E\uFF0C\u4E5F\u4E0D\u590D\u5236\u6574\u4E2A\u4E1A\u52A1 app \u7684\u72B6\u6001\u3002", false);
2192
+ } else if (plan.role !== "provider") {
2193
+ task("\u5DF2\u6709\u6D88\u8D39\u9875\u9762", "\u6A21\u5757\u7528 loadRemote\uFF1B\u540C\u6846\u67B6\u7EC4\u4EF6\u7528 remoteComponent\uFF0C\u5728\u5DF2\u6709\u89C6\u56FE\u6E32\u67D3\u5E76\u4F20\u771F\u5B9E props\uFF1B\u4E0D\u751F\u6210\u5E94\u7528\u5DE5\u5382\u3001\u83DC\u5355\u3001Provider \u6216\u4F1A\u8BDD\u6587\u4EF6\u3002", false);
2194
+ }
2195
+ if (plan.kind === "app") task("\u8DEF\u7531\u4E0E\u4E1A\u52A1\u88C5\u914D", "\u672C\u5DE5\u5177\u4EC5\u81EA\u52A8\u63D0\u53D6\u65E0 Router/store \u7684\u6700\u5C0F\u5165\u53E3\u3002\u5DF2\u6709\u590D\u6742\u5E94\u7528\u6309\u6307\u5357\u8FD4\u56DE\u6BCF\u6B21\u65B0\u5EFA\u7684 app/router \u6216 element/dispose\uFF1B\u786E\u4FDD memory \u8DEF\u7531\u3001\u5B88\u536B\u3001\u4E3B\u9898\u548C\u6743\u9650\u5C31\u7EEA\u540E\u518D\u6302\u8F7D\u3002", false);
2196
+ plan.commands.push("npx fulgurjs doctor --config ./fulgurjs.config.ts", "\u8FD0\u884C\u672C\u9879\u76EE\u6709\u6548\u914D\u7F6E\u4E0B\u7684\u7C7B\u578B\u68C0\u67E5\u4E0E\u6784\u5EFA\uFF0C\u518D\u9A8C\u8BC1\u771F\u5B9E\u6302\u8F7D\u3001\u4EA4\u4E92\u3001\u91CD\u8FDB/\u5378\u8F7D");
2197
+ return plan;
2198
+ }
2199
+ function hostView(framework, remote) {
2200
+ if (framework === "vue") return `${OWNER.replace("//", "<!--")} -->
2201
+ <script setup lang="ts">
2202
+ // \u628A\u6B64\u89C6\u56FE\u653E\u8FDB\u5DF2\u6709\u9875\u9762\u3002\u65E0\u767B\u5F55/URL \u540C\u6B65\u9700\u6C42\u65E0\u9700\u589E\u52A0\u989D\u5916\u914D\u7F6E\u3002
2203
+ import { createVueBridgeApp } from '@fulgurjs/federation/vue'
2204
+ const RemoteApplication = createVueBridgeApp('${remote}/bridge')
2205
+ </script>
2206
+ <template><RemoteApplication /></template>
2207
+ `;
2208
+ return `${OWNER}
2209
+ // \u653E\u8FDB\u5DF2\u6709\u9875\u9762\uFF1B\u9700\u8981 URL \u540C\u6B65/\u767B\u5F55\u65F6\u663E\u5F0F\u4F20 routing/sessionKey/getContext\uFF0C\u4E0D\u731C\u5BBF\u4E3B\u5B9E\u73B0\u3002
2210
+ import { createReactBridgeApp } from '@fulgurjs/federation/react'
2211
+ export default createReactBridgeApp('${remote}/bridge')
2212
+ `;
2213
+ }
2214
+ function targetOf(root, relative) {
2215
+ const absolute = path2.resolve(root, relative);
2216
+ if (!absolute.startsWith(root + path2.sep)) throw new Error("\u8BA1\u5212\u6587\u4EF6\u8D8A\u8FC7\u5E94\u7528\u76EE\u5F55");
2217
+ let cursor = root;
2218
+ for (const part of path2.relative(root, absolute).split(path2.sep)) {
2219
+ cursor = path2.join(cursor, part);
2220
+ rejectSymlink(cursor, relative);
2221
+ }
2222
+ return absolute;
2223
+ }
2224
+ function currentSource(file) {
2225
+ return fs2.existsSync(file) ? fs2.readFileSync(file, "utf8") : null;
2226
+ }
2227
+ function replaceSource(file, content, exclusive = false) {
2228
+ const temp = file + `.fulgurjs-${process.pid}.tmp`;
2229
+ let created = false;
2230
+ try {
2231
+ fs2.writeFileSync(temp, content, { flag: "wx", mode: fs2.existsSync(file) ? fs2.statSync(file).mode : 420 });
2232
+ created = true;
2233
+ if (exclusive) {
2234
+ fs2.linkSync(temp, file);
2235
+ fs2.unlinkSync(temp);
2236
+ } else fs2.renameSync(temp, file);
2237
+ } finally {
2238
+ if (created && fs2.existsSync(temp)) fs2.unlinkSync(temp);
2239
+ }
2240
+ }
2241
+ function applyIntegration(plan) {
2242
+ if (plan.tasks.some((t) => t.blocking)) throw new Error("\u8BA1\u5212\u5305\u542B\u963B\u65AD\u9879\uFF0C\u672A\u5199\u5165\u4EFB\u4F55\u6587\u4EF6\uFF1B\u5148\u5904\u7406\u6240\u5217\u6587\u4EF6\u518D\u9884\u89C8\u3002");
2243
+ const root = fs2.realpathSync(plan.root);
2244
+ for (const edit of plan.edits) {
2245
+ const target = targetOf(root, edit.file);
2246
+ if (currentSource(target) !== edit.before) throw new Error(`\u9884\u89C8\u540E\u6587\u4EF6\u5DF2\u53D8\u5316\uFF1A${edit.file}\uFF1B\u8BF7\u91CD\u65B0\u751F\u6210\u8BA1\u5212\u3002`);
2247
+ if (fs2.existsSync(target + `.fulgurjs-${process.pid}.tmp`)) throw new Error(`\u4E34\u65F6\u6587\u4EF6\u5DF2\u5B58\u5728\uFF0C\u4FDD\u7559\u5E76\u8BF7\u5148\u6838\u67E5\uFF1A${edit.file}`);
2248
+ }
2249
+ if (!plan.edits.length) return;
2250
+ const journal = targetOf(root, JOURNAL);
2251
+ const directories = /* @__PURE__ */ new Set();
2252
+ for (const edit of plan.edits) {
2253
+ let dir = path2.dirname(targetOf(root, edit.file));
2254
+ while (dir !== root && !fs2.existsSync(dir)) {
2255
+ directories.add(path2.relative(root, dir));
2256
+ dir = path2.dirname(dir);
2257
+ }
2258
+ }
2259
+ fs2.writeFileSync(journal, JSON.stringify({ root, pid: process.pid, directories: [...directories], edits: plan.edits }), { flag: "wx", mode: 384 });
2260
+ try {
2261
+ for (const edit of plan.edits) {
2262
+ const file = targetOf(root, edit.file);
2263
+ if (currentSource(file) !== edit.before) throw new Error(`\u5199\u5165\u524D\u6587\u4EF6\u53D1\u751F\u53D8\u5316\uFF1A${edit.file}`);
2264
+ fs2.mkdirSync(path2.dirname(file), { recursive: true });
2265
+ replaceSource(file, edit.after, edit.before === null);
2266
+ }
2267
+ fs2.unlinkSync(journal);
2268
+ } catch (error) {
2269
+ try {
2270
+ rollbackIntegration(root);
2271
+ } catch {
2272
+ }
2273
+ throw error;
2274
+ }
2275
+ }
2276
+ function rollbackIntegration(cwd) {
2277
+ const root = fs2.realpathSync(cwd), journal = targetOf(root, JOURNAL);
2278
+ const saved = JSON.parse(fs2.readFileSync(journal, "utf8"));
2279
+ if (saved.root !== root || !Array.isArray(saved.edits)) throw new Error("\u6062\u590D\u8BB0\u5F55\u4E0E\u5F53\u524D\u76EE\u5F55\u4E0D\u4E00\u81F4\uFF0C\u62D2\u7EDD\u81EA\u52A8\u56DE\u9000");
2280
+ for (const edit of saved.edits) {
2281
+ if (typeof edit.file !== "string" || typeof edit.after !== "string" || edit.before !== null && typeof edit.before !== "string") throw new Error("\u6062\u590D\u8BB0\u5F55\u683C\u5F0F\u65E0\u6548");
2282
+ const value = currentSource(targetOf(root, edit.file));
2283
+ if (value !== edit.before && value !== edit.after) throw new Error(`\u6587\u4EF6\u6709\u540E\u7EED\u7F16\u8F91\uFF0C\u4FDD\u7559\u5185\u5BB9\u548C\u6062\u590D\u8BB0\u5F55\uFF1A${edit.file}\uFF1B\u8BF7\u4EBA\u5DE5\u5408\u5E76\u540E\u518D\u6062\u590D\u3002`);
2284
+ }
2285
+ for (const edit of [...saved.edits].reverse()) {
2286
+ const file = targetOf(root, edit.file);
2287
+ if (currentSource(file) !== edit.before) {
2288
+ if (edit.before === null) fs2.unlinkSync(file);
2289
+ else replaceSource(file, edit.before);
2290
+ }
2291
+ if (Number.isSafeInteger(saved.pid) && saved.pid > 0) {
2292
+ const temp = file + `.fulgurjs-${saved.pid}.tmp`;
2293
+ if (fs2.existsSync(temp)) fs2.unlinkSync(temp);
2294
+ }
2295
+ }
2296
+ for (const dir of [...saved.directories ?? []].sort((a, b) => b.length - a.length)) {
2297
+ const directory = targetOf(root, dir);
2298
+ if (fs2.existsSync(directory) && fs2.readdirSync(directory).length === 0) fs2.rmdirSync(directory);
2299
+ }
2300
+ fs2.unlinkSync(journal);
2301
+ }
2302
+ function formatIntegrationPlan(plan) {
2303
+ const lines = ["[fulgurjs:init] \u63A5\u5165\u9884\u89C8\uFF08\u9ED8\u8BA4\u4E0D\u5199\u5165\u3001\u4E0D\u5B89\u88C5\u4F9D\u8D56\u3001\u4E0D\u6267\u884C\u4E1A\u52A1\u4EE3\u7801\uFF09", ...plan.evidence];
2304
+ for (const edit of plan.edits) {
2305
+ lines.push(`
2306
+ --- ${edit.before === null ? "/dev/null" : edit.file}
2307
+ +++ ${edit.file}
2308
+ \u539F\u56E0\uFF1A${edit.reason}`);
2309
+ if (edit.before !== null) lines.push(...edit.before.split("\n").map((line) => "- " + line));
2310
+ lines.push(...edit.after.split("\n").map((line) => "+ " + line));
2311
+ }
2312
+ lines.push("\n\u5F85\u529E\uFF08\u4E0D\u7B49\u4E8E\u6D4F\u89C8\u5668\u5DF2\u9A8C\u6536\uFF09\uFF1A", ...plan.tasks.map((t) => `${t.blocking ? "\u963B\u65AD" : "\u4EBA\u5DE5\u63A5\u7EBF/\u6838\u67E5"} ${t.file}\uFF1A${t.message}`), "\n\u540E\u7EED\u547D\u4EE4\uFF1A", ...plan.commands);
2313
+ return lines.join("\n");
2314
+ }
2315
+ var requireHere, OWNER, JOURNAL;
2316
+ var init_init_plan = __esm({
2317
+ "src/init-plan.ts"() {
2318
+ "use strict";
2319
+ init_lexer();
2320
+ init_magic_string_es();
2321
+ init_init();
2322
+ requireHere = createRequire2(import.meta.url);
2323
+ OWNER = "// @fulgurjs generated: existing-app integration";
2324
+ JOURNAL = ".fulgurjs-init-pending.json";
2325
+ }
2326
+ });
2327
+
647
2328
  // src/create.ts
648
2329
  var create_exports = {};
649
2330
  __export(create_exports, {
@@ -664,16 +2345,16 @@ __export(create_exports, {
664
2345
  templateEnginesNode: () => templateEnginesNode,
665
2346
  validateTemplateDir: () => validateTemplateDir
666
2347
  });
667
- import fs2 from "node:fs";
668
- import path2 from "node:path";
2348
+ import fs3 from "node:fs";
2349
+ import path3 from "node:path";
669
2350
  import { fileURLToPath } from "node:url";
670
2351
  import { spawn } from "node:child_process";
671
2352
  function packageRootOf(moduleUrl) {
672
2353
  return fileURLToPath(new URL("..", moduleUrl));
673
2354
  }
674
2355
  function resolveTemplatesRoot(moduleUrl) {
675
- const root = path2.join(packageRootOf(moduleUrl), "examples", "templates");
676
- if (!fs2.existsSync(root)) {
2356
+ const root = path3.join(packageRootOf(moduleUrl), "examples", "templates");
2357
+ if (!fs3.existsSync(root)) {
677
2358
  throw new Error(
678
2359
  "[fulgurjs:create] \u5F53\u524D\u5B89\u88C5\u7F3A\u5C11\u6A21\u677F\u8D44\u4EA7\uFF08examples/templates\uFF09\u3002\n \u6839\u56E0\uFF1A\u6A21\u677F\u7531 npm \u6B63\u5F0F\u5305\u9644\u5E26\uFF1B\u4ECE\u4ED3\u5E93\u6E90\u7801\u76F4\u63A5\u8FD0\u884C CLI \u65F6\u8BE5\u76EE\u5F55\u53EA\u5728 build \u540E\u751F\u6210\u3002\n \u4FEE\u6CD5\uFF1A\u7528 npm \u6B63\u5F0F\u5305\u8FD0\u884C\uFF08npx @fulgurjs/federation create\uFF09\uFF0C\u6216\u5728\u63D2\u4EF6\u4ED3\u5E93\u6267\u884C npm --prefix packages/plugin run build \u540E\u91CD\u8BD5"
679
2360
  );
@@ -688,14 +2369,14 @@ function isExcluded(name) {
688
2369
  function scanTemplateConflicts(from, to) {
689
2370
  const conflicts = [];
690
2371
  const walk = (srcDir, relDir) => {
691
- for (const entry of fs2.readdirSync(srcDir, { withFileTypes: true })) {
2372
+ for (const entry of fs3.readdirSync(srcDir, { withFileTypes: true })) {
692
2373
  if (isExcluded(entry.name)) continue;
693
2374
  const rel = relDir ? `${relDir}/${entry.name}` : entry.name;
694
- const src = path2.join(srcDir, entry.name);
695
- const dest = path2.join(to, rel);
2375
+ const src = path3.join(srcDir, entry.name);
2376
+ const dest = path3.join(to, rel);
696
2377
  let destStat;
697
2378
  try {
698
- destStat = fs2.lstatSync(dest);
2379
+ destStat = fs3.lstatSync(dest);
699
2380
  } catch {
700
2381
  }
701
2382
  if (!destStat) {
@@ -722,12 +2403,12 @@ function copyMissingFiles(from, to, conflicts) {
722
2403
  const blocked = new Set(conflicts.map((c) => c.rel));
723
2404
  const outcome = { copied: [], skipped: [] };
724
2405
  const walk = (srcDir, relDir) => {
725
- fs2.mkdirSync(to, { recursive: true });
726
- for (const entry of fs2.readdirSync(srcDir, { withFileTypes: true })) {
2406
+ fs3.mkdirSync(to, { recursive: true });
2407
+ for (const entry of fs3.readdirSync(srcDir, { withFileTypes: true })) {
727
2408
  if (isExcluded(entry.name)) continue;
728
2409
  const rel = relDir ? `${relDir}/${entry.name}` : entry.name;
729
- const src = path2.join(srcDir, entry.name);
730
- const dest = path2.join(to, rel);
2410
+ const src = path3.join(srcDir, entry.name);
2411
+ const dest = path3.join(to, rel);
731
2412
  if (blocked.has(rel)) {
732
2413
  outcome.skipped.push({ rel, reason: conflicts.find((c) => c.rel === rel)?.reason ?? "\u540C\u540D\u51B2\u7A81" });
733
2414
  continue;
@@ -736,8 +2417,8 @@ function copyMissingFiles(from, to, conflicts) {
736
2417
  walk(src, rel);
737
2418
  continue;
738
2419
  }
739
- fs2.mkdirSync(path2.dirname(dest), { recursive: true });
740
- fs2.copyFileSync(src, dest);
2420
+ fs3.mkdirSync(path3.dirname(dest), { recursive: true });
2421
+ fs3.copyFileSync(src, dest);
741
2422
  outcome.copied.push(rel);
742
2423
  }
743
2424
  };
@@ -757,11 +2438,11 @@ function copyTemplate(from, to) {
757
2438
  }
758
2439
  function validateTemplateDir(dir) {
759
2440
  const required = ["package.json", "pnpm-workspace.yaml", "pnpm-lock.yaml", "scripts/dev.mjs", "scripts/dev.config.json"];
760
- return required.filter((f) => !fs2.existsSync(path2.join(dir, f)));
2441
+ return required.filter((f) => !fs3.existsSync(path3.join(dir, f)));
761
2442
  }
762
2443
  function readDevConfig(templateDir) {
763
- const file = path2.join(templateDir, "scripts", "dev.config.json");
764
- const parsed = JSON.parse(fs2.readFileSync(file, "utf8"));
2444
+ const file = path3.join(templateDir, "scripts", "dev.config.json");
2445
+ const parsed = JSON.parse(fs3.readFileSync(file, "utf8"));
765
2446
  if (!Array.isArray(parsed.apps) || parsed.apps.length === 0) {
766
2447
  throw new Error(`[fulgurjs:create] ${file} \u7F3A\u5C11 apps \u6570\u7EC4`);
767
2448
  }
@@ -775,7 +2456,7 @@ function readDevConfig(templateDir) {
775
2456
  function pluginVersionOf(templateDir, apps) {
776
2457
  for (const app of apps) {
777
2458
  try {
778
- const pkg = JSON.parse(fs2.readFileSync(path2.join(templateDir, app.dir, "package.json"), "utf8"));
2459
+ const pkg = JSON.parse(fs3.readFileSync(path3.join(templateDir, app.dir, "package.json"), "utf8"));
779
2460
  const version = pkg.dependencies?.["@fulgurjs/federation"];
780
2461
  if (version) return version;
781
2462
  } catch {
@@ -864,19 +2545,19 @@ async function createProject(opts, io) {
864
2545
  \u4FEE\u6CD5\uFF1Afulgurjs create --list \u67E5\u770B\u8BF4\u660E\uFF0C\u6216 fulgurjs create <\u6A21\u677F\u540D> --dir <\u76EE\u6807\u76EE\u5F55>`
865
2546
  );
866
2547
  }
867
- const templateDir = path2.join(opts.templatesRoot, templateName);
868
- if (!fs2.existsSync(path2.join(templateDir, "package.json"))) {
2548
+ const templateDir = path3.join(opts.templatesRoot, templateName);
2549
+ if (!fs3.existsSync(path3.join(templateDir, "package.json"))) {
869
2550
  throw new Error(`[fulgurjs:create] \u5305\u5185\u6A21\u677F\u4E0D\u5B8C\u6574\uFF1A${templateDir} \u7F3A\u5C11 package.json`);
870
2551
  }
871
- const target = path2.resolve(opts.cwd, opts.dir ?? templateName);
872
- if (fs2.existsSync(target) && !fs2.statSync(target).isDirectory()) {
2552
+ const target = path3.resolve(opts.cwd, opts.dir ?? templateName);
2553
+ if (fs3.existsSync(target) && !fs3.statSync(target).isDirectory()) {
873
2554
  throw new Error(
874
2555
  `[fulgurjs:create] \u76EE\u6807\u8DEF\u5F84\u5DF2\u5B58\u5728\u4E14\u662F\u6587\u4EF6\uFF0C\u65E0\u6CD5\u4F5C\u4E3A\u5DE5\u7A0B\u76EE\u5F55\uFF1A${target}
875
2556
  \u4FEE\u6CD5\uFF1A\u6362\u4E00\u4E2A\u76EE\u5F55\uFF08--dir\uFF09\uFF0C\u6216\u5148\u79FB\u8D70\u8BE5\u6587\u4EF6`
876
2557
  );
877
2558
  }
878
- if (fs2.existsSync(target)) {
879
- const existing = fs2.readdirSync(target);
2559
+ if (fs3.existsSync(target)) {
2560
+ const existing = fs3.readdirSync(target);
880
2561
  if (existing.length > 0 && !opts.force) {
881
2562
  throw new Error(
882
2563
  `[fulgurjs:create] \u76EE\u6807\u76EE\u5F55\u975E\u7A7A\uFF0C\u62D2\u7EDD\u8986\u76D6\uFF1A${target}
@@ -903,7 +2584,7 @@ async function createProject(opts, io) {
903
2584
  }
904
2585
  let outcome;
905
2586
  try {
906
- if (fs2.existsSync(target) && fs2.readdirSync(target).length > 0) {
2587
+ if (fs3.existsSync(target) && fs3.readdirSync(target).length > 0) {
907
2588
  const conflicts = scanTemplateConflicts(templateDir, target);
908
2589
  io.log(
909
2590
  `[fulgurjs:create] --force\uFF1A\u5411\u975E\u7A7A\u76EE\u5F55 ${target} \u590D\u5236\uFF08\u53EA\u8865\u7F3A\u5931\u6587\u4EF6\uFF0C\u4E0D\u6539\u5199\u5DF2\u6709\u5185\u5BB9\uFF1B\u9884\u68C0\u5230 ${conflicts.length} \u4E2A\u540C\u540D\u51B2\u7A81\u5C06\u4FDD\u7559\u4F60\u7684\u7248\u672C\uFF09`
@@ -959,7 +2640,7 @@ async function createProject(opts, io) {
959
2640
  }
960
2641
  function templateEnginesNode(templateDir) {
961
2642
  try {
962
- const pkg = JSON.parse(fs2.readFileSync(path2.join(templateDir, "package.json"), "utf8"));
2643
+ const pkg = JSON.parse(fs3.readFileSync(path3.join(templateDir, "package.json"), "utf8"));
963
2644
  return pkg.engines?.node;
964
2645
  } catch {
965
2646
  return void 0;
@@ -1134,7 +2815,7 @@ __export(commands_exports, {
1134
2815
  manifestUrlForRemoteAddress: () => manifestUrlForRemoteAddress,
1135
2816
  stripRemoteNamePrefix: () => stripRemoteNamePrefix
1136
2817
  });
1137
- import fs3 from "node:fs";
2818
+ import fs4 from "node:fs";
1138
2819
  function mappingsOf(hp, deriveFallback) {
1139
2820
  const pages = hp.pages ?? [];
1140
2821
  const prefixes = Object.entries(hp.remotePrefixes ?? {}).sort((a, b) => b[0].length - a[0].length);
@@ -1289,7 +2970,7 @@ function formatExplain(r) {
1289
2970
  }
1290
2971
  function manifestFromFile(p) {
1291
2972
  try {
1292
- const parsed = parseManifest(JSON.parse(fs3.readFileSync(p, "utf8")));
2973
+ const parsed = parseManifest(JSON.parse(fs4.readFileSync(p, "utf8")));
1293
2974
  if (parsed.manifest && !parsed.unsupportedVersion) return parsed.manifest;
1294
2975
  } catch {
1295
2976
  }
@@ -1458,7 +3139,7 @@ var RUNTIME_VERSION;
1458
3139
  var init_version = __esm({
1459
3140
  "src/version.ts"() {
1460
3141
  "use strict";
1461
- RUNTIME_VERSION = "6.9.2";
3142
+ RUNTIME_VERSION = "6.10.0";
1462
3143
  }
1463
3144
  });
1464
3145
 
@@ -1482,9 +3163,9 @@ var init_dev_cors = __esm({
1482
3163
  });
1483
3164
 
1484
3165
  // src/options.ts
1485
- import { createRequire as createRequire2 } from "node:module";
1486
- import fs4 from "node:fs";
1487
- import path3 from "node:path";
3166
+ import { createRequire as createRequire3 } from "node:module";
3167
+ import fs5 from "node:fs";
3168
+ import path4 from "node:path";
1488
3169
  function joinUrl(base, file) {
1489
3170
  const b = base.endsWith("/") ? base : `${base}/`;
1490
3171
  return `${b}${file.replace(/^\//, "")}`;
@@ -1539,8 +3220,8 @@ function normalizeRemoteValue(key, value, filename, warnings) {
1539
3220
  }
1540
3221
  function readPkgDependencies(root) {
1541
3222
  try {
1542
- const pkgPath = path3.join(root, "package.json");
1543
- const pkg = JSON.parse(fs4.readFileSync(pkgPath, "utf8"));
3223
+ const pkgPath = path4.join(root, "package.json");
3224
+ const pkg = JSON.parse(fs5.readFileSync(pkgPath, "utf8"));
1544
3225
  return {
1545
3226
  ...pkg.dependencies ?? {},
1546
3227
  ...pkg.optionalDependencies ?? {},
@@ -1553,9 +3234,9 @@ function readPkgDependencies(root) {
1553
3234
  }
1554
3235
  function readInstalledVersion(root, specifier) {
1555
3236
  try {
1556
- const req = createRequire2(path3.join(root, "package.json"));
3237
+ const req = createRequire3(path4.join(root, "package.json"));
1557
3238
  const pkgJsonPath = req.resolve(`${specifier}/package.json`, { paths: [root] });
1558
- const pkg = JSON.parse(fs4.readFileSync(pkgJsonPath, "utf8"));
3239
+ const pkg = JSON.parse(fs5.readFileSync(pkgJsonPath, "utf8"));
1559
3240
  return typeof pkg.version === "string" ? pkg.version : null;
1560
3241
  } catch {
1561
3242
  return null;
@@ -1885,7 +3566,7 @@ function normalizeOptions(options, root, command) {
1885
3566
  shared,
1886
3567
  shareScope: shareScopeDefault,
1887
3568
  manifest: options.manifest === void 0 ? true : !!options.manifest,
1888
- runtimePlugins: (options.runtimePlugins ?? []).map((id) => id.startsWith(".") ? path3.resolve(root, id) : id),
3569
+ runtimePlugins: (options.runtimePlugins ?? []).map((id) => id.startsWith(".") ? path4.resolve(root, id) : id),
1889
3570
  dts: options.dts === void 0 ? true : options.dts,
1890
3571
  root,
1891
3572
  pluginVersion: RUNTIME_VERSION,
@@ -1925,6 +3606,34 @@ var init_options = __esm({
1925
3606
  }
1926
3607
  });
1927
3608
 
3609
+ // src/dts-diagnostics.ts
3610
+ import path5 from "node:path";
3611
+ function formatDeclarationDiagnostics(stdout, stderr, fallback, root, closure) {
3612
+ const groups = [];
3613
+ let current;
3614
+ const clean = (text) => text.replace(/\u001b\[[0-9;]*m/g, "");
3615
+ for (const line of clean(`${stdout}
3616
+ ${stderr}`).split(/\r?\n/)) {
3617
+ const file = line.match(/^(.+)\(\d+,\d+\): error TS\d+:/);
3618
+ const global = /^(?:error )?TS\d+:/.test(line);
3619
+ if (file || global) {
3620
+ current = global || file && closure.has(path5.resolve(root, file[1].trim())) ? [line] : void 0;
3621
+ if (current) groups.push(current);
3622
+ } else if (current && line.trim()) {
3623
+ current.push(line);
3624
+ }
3625
+ }
3626
+ if (!groups.length) return clean(stderr || stdout || fallback).split(/\r?\n/).slice(0, 40).join("\n");
3627
+ const shown = groups.slice(0, 5).flatMap((group) => group.slice(0, 8));
3628
+ if (groups.length > 5) shown.push(`\u53E6\u6709 ${groups.length - 5} \u9879\u516C\u5F00\u58F0\u660E\u8BCA\u65AD\uFF0C\u8BF7\u8FD0\u884C\u63D0\u4F9B\u65B9\u7C7B\u578B\u68C0\u67E5\u67E5\u770B\u3002`);
3629
+ return shown.join("\n");
3630
+ }
3631
+ var init_dts_diagnostics = __esm({
3632
+ "src/dts-diagnostics.ts"() {
3633
+ "use strict";
3634
+ }
3635
+ });
3636
+
1928
3637
  // src/dts-shared.ts
1929
3638
  function isSafeBundlePath(v) {
1930
3639
  if (typeof v !== "string" || v.length === 0) return false;
@@ -2016,13 +3725,13 @@ var init_dts_shared = __esm({
2016
3725
  });
2017
3726
 
2018
3727
  // src/dts-generate.ts
2019
- import fs5 from "node:fs";
2020
- import path4 from "node:path";
3728
+ import fs6 from "node:fs";
3729
+ import path6 from "node:path";
2021
3730
  import crypto from "node:crypto";
2022
- import { createRequire as createRequire3 } from "node:module";
3731
+ import { createRequire as createRequire4 } from "node:module";
2023
3732
  import { execFile } from "node:child_process";
2024
3733
  function resolveFromRoot(root, pkg) {
2025
- const req = createRequire3(path4.join(root, "package.json"));
3734
+ const req = createRequire4(path6.join(root, "package.json"));
2026
3735
  let resolved = null;
2027
3736
  for (const spec of [`${pkg}/package.json`, pkg]) {
2028
3737
  try {
@@ -2032,18 +3741,18 @@ function resolveFromRoot(root, pkg) {
2032
3741
  }
2033
3742
  }
2034
3743
  if (!resolved) return null;
2035
- let dir = path4.dirname(resolved);
2036
- for (let i = 0; i < 5 && !fs5.existsSync(path4.join(dir, "package.json")); i++) {
2037
- const parent = path4.dirname(dir);
3744
+ let dir = path6.dirname(resolved);
3745
+ for (let i = 0; i < 5 && !fs6.existsSync(path6.join(dir, "package.json")); i++) {
3746
+ const parent = path6.dirname(dir);
2038
3747
  if (parent === dir) return null;
2039
3748
  dir = parent;
2040
3749
  }
2041
- return fs5.existsSync(path4.join(dir, "package.json")) ? dir : null;
3750
+ return fs6.existsSync(path6.join(dir, "package.json")) ? dir : null;
2042
3751
  }
2043
3752
  function installHint(root, pkg) {
2044
3753
  const pkgManager = (() => {
2045
- if (fs5.existsSync(path4.join(root, "pnpm-lock.yaml"))) return "pnpm";
2046
- if (fs5.existsSync(path4.join(root, "yarn.lock"))) return "yarn";
3754
+ if (fs6.existsSync(path6.join(root, "pnpm-lock.yaml"))) return "pnpm";
3755
+ if (fs6.existsSync(path6.join(root, "yarn.lock"))) return "yarn";
2047
3756
  return "npm";
2048
3757
  })();
2049
3758
  const devFlag = pkgManager === "pnpm" ? "-D" : "--save-dev";
@@ -2068,12 +3777,12 @@ function computeStaticClosure(ts, entryFiles, resolver, root) {
2068
3777
  closure.add(file);
2069
3778
  let text;
2070
3779
  try {
2071
- text = fs5.readFileSync(file, "utf8");
3780
+ text = fs6.readFileSync(file, "utf8");
2072
3781
  } catch {
2073
3782
  continue;
2074
3783
  }
2075
3784
  if (file.endsWith(".vue")) {
2076
- const req = createRequire3(path4.join(root, "package.json"));
3785
+ const req = createRequire4(path6.join(root, "package.json"));
2077
3786
  const { parse: parse2 } = req("vue/compiler-sfc");
2078
3787
  const { descriptor } = parse2(text);
2079
3788
  text = [descriptor.script?.content, descriptor.scriptSetup?.content].filter(Boolean).join("\n");
@@ -2095,16 +3804,16 @@ import ${JSON.stringify(descriptor.script.src)}`;
2095
3804
  const r = resolver(spec, file);
2096
3805
  let resolved = r && !r.fromNodeModules ? r.resolved : null;
2097
3806
  if (!resolved) {
2098
- const base = path4.resolve(path4.dirname(file), spec);
2099
- for (const c of [base, `${base}.vue`, `${base}.ts`, `${base}.tsx`, path4.join(base, "index.ts")]) {
2100
- if (fs5.existsSync(c)) {
3807
+ const base = path6.resolve(path6.dirname(file), spec);
3808
+ for (const c of [base, `${base}.vue`, `${base}.ts`, `${base}.tsx`, path6.join(base, "index.ts")]) {
3809
+ if (fs6.existsSync(c)) {
2101
3810
  resolved = c;
2102
3811
  break;
2103
3812
  }
2104
3813
  }
2105
3814
  }
2106
- if (resolved && !resolved.includes(`${path4.sep}node_modules${path4.sep}`)) {
2107
- queue.push(path4.resolve(resolved));
3815
+ if (resolved && !resolved.includes(`${path6.sep}node_modules${path6.sep}`)) {
3816
+ queue.push(path6.resolve(resolved));
2108
3817
  }
2109
3818
  }
2110
3819
  }
@@ -2115,7 +3824,7 @@ function parseErrorFiles(stdout, root) {
2115
3824
  const out = /* @__PURE__ */ new Set();
2116
3825
  for (const line of stdout.split("\n")) {
2117
3826
  const m = line.match(/^([^)(]+)\((\d+),(\d+)\): error TS/);
2118
- if (m) out.add(path4.resolve(root, m[1].trim()));
3827
+ if (m) out.add(path6.resolve(root, m[1].trim()));
2119
3828
  }
2120
3829
  return out;
2121
3830
  }
@@ -2124,17 +3833,17 @@ function resolveTypesEntries(root, baseCo, diagnostics) {
2124
3833
  if (raw === void 0) return [];
2125
3834
  baseCo.types = [];
2126
3835
  if (!Array.isArray(raw)) return [];
2127
- const req = createRequire3(path4.join(root, "package.json"));
3836
+ const req = createRequire4(path6.join(root, "package.json"));
2128
3837
  const out = [];
2129
3838
  for (const entry of raw) {
2130
3839
  if (typeof entry !== "string" || entry.length === 0) continue;
2131
- const direct = [path4.resolve(root, `${entry}.d.ts`), path4.resolve(root, entry, "index.d.ts"), path4.resolve(root, "node_modules", `${entry}.d.ts`), path4.resolve(root, "node_modules", entry, "index.d.ts"), path4.resolve(root, "node_modules/@types", entry, "index.d.ts")];
2132
- let hit = direct.find((c) => fs5.existsSync(c));
2133
- if (!hit && !entry.startsWith(".") && !path4.isAbsolute(entry)) {
3840
+ const direct = [path6.resolve(root, `${entry}.d.ts`), path6.resolve(root, entry, "index.d.ts"), path6.resolve(root, "node_modules", `${entry}.d.ts`), path6.resolve(root, "node_modules", entry, "index.d.ts"), path6.resolve(root, "node_modules/@types", entry, "index.d.ts")];
3841
+ let hit = direct.find((c) => fs6.existsSync(c));
3842
+ if (!hit && !entry.startsWith(".") && !path6.isAbsolute(entry)) {
2134
3843
  try {
2135
3844
  const r = req.resolve(entry);
2136
3845
  for (const c of [r.replace(/\.js$/, ".d.ts"), `${r}.d.ts`, r]) {
2137
- if (c.endsWith(".d.ts") && fs5.existsSync(c)) {
3846
+ if (c.endsWith(".d.ts") && fs6.existsSync(c)) {
2138
3847
  hit = c;
2139
3848
  break;
2140
3849
  }
@@ -2152,33 +3861,33 @@ function hasVueFilesUnderSources(root) {
2152
3861
  if (budget.left <= 0) return false;
2153
3862
  let entries;
2154
3863
  try {
2155
- entries = fs5.readdirSync(dir, { withFileTypes: true });
3864
+ entries = fs6.readdirSync(dir, { withFileTypes: true });
2156
3865
  } catch {
2157
3866
  return false;
2158
3867
  }
2159
3868
  for (const e of entries) {
2160
3869
  if (e.name === "node_modules" || e.name === ".git" || e.name === "dist") continue;
2161
- const p = path4.join(dir, e.name);
3870
+ const p = path6.join(dir, e.name);
2162
3871
  budget.left -= 1;
2163
3872
  if (e.isFile() && e.name.endsWith(".vue")) return true;
2164
3873
  if (e.isDirectory() && scan(p, budget)) return true;
2165
3874
  }
2166
3875
  return false;
2167
3876
  };
2168
- const srcDir = path4.join(root, "src");
2169
- return scan(fs5.existsSync(srcDir) ? srcDir : root, { left: 2e3 });
3877
+ const srcDir = path6.join(root, "src");
3878
+ return scan(fs6.existsSync(srcDir) ? srcDir : root, { left: 2e3 });
2170
3879
  }
2171
3880
  function commonDirOf(files) {
2172
3881
  if (files.length === 0) return "";
2173
- let dir = path4.dirname(files[0]);
3882
+ let dir = path6.dirname(files[0]);
2174
3883
  for (const f of files) {
2175
- const rel = path4.relative(dir, f);
3884
+ const rel = path6.relative(dir, f);
2176
3885
  if (rel.startsWith("..")) {
2177
- const parts = path4.dirname(f).split(path4.sep);
2178
- const cur = dir.split(path4.sep);
3886
+ const parts = path6.dirname(f).split(path6.sep);
3887
+ const cur = dir.split(path6.sep);
2179
3888
  let i = 0;
2180
3889
  while (i < parts.length && i < cur.length && parts[i] === cur[i]) i++;
2181
- dir = parts.slice(0, i).join(path4.sep) || path4.sep;
3890
+ dir = parts.slice(0, i).join(path6.sep) || path6.sep;
2182
3891
  }
2183
3892
  }
2184
3893
  return dir;
@@ -2219,10 +3928,10 @@ function loadTsContext(root, ts, diagnostics) {
2219
3928
  diagnostics.push(`tsconfig \u89E3\u6790\u5931\u8D25\uFF08${tsconfigFile}\uFF09\uFF1A${ts.flattenDiagnosticMessageText(raw.error.messageText, " ")}`);
2220
3929
  return null;
2221
3930
  }
2222
- const parsed = ts.parseJsonConfigFileContent(raw.config, ts.sys, path4.dirname(tsconfigFile));
3931
+ const parsed = ts.parseJsonConfigFileContent(raw.config, ts.sys, path6.dirname(tsconfigFile));
2223
3932
  const co = { ...parsed.options };
2224
- if (typeof co.baseUrl === "string" && !path4.isAbsolute(co.baseUrl)) {
2225
- co.baseUrl = path4.resolve(path4.dirname(tsconfigFile), co.baseUrl);
3933
+ if (typeof co.baseUrl === "string" && !path6.isAbsolute(co.baseUrl)) {
3934
+ co.baseUrl = path6.resolve(path6.dirname(tsconfigFile), co.baseUrl);
2226
3935
  }
2227
3936
  if (parsed.errors.length > 0) {
2228
3937
  const fatal = parsed.errors.filter((e) => e.category === ts.DiagnosticCategory.Error);
@@ -2238,7 +3947,7 @@ function loadTsContext(root, ts, diagnostics) {
2238
3947
  compilerOptions: co,
2239
3948
  rawOptions: raw.config.compilerOptions ?? {},
2240
3949
  projectFiles: parsed.fileNames.filter((f) => !f.endsWith(".d.ts")),
2241
- ambientInputs: parsed.fileNames.filter((f) => f.endsWith(".d.ts") && !f.includes(`${path4.sep}node_modules${path4.sep}`)),
3950
+ ambientInputs: parsed.fileNames.filter((f) => f.endsWith(".d.ts") && !f.includes(`${path6.sep}node_modules${path6.sep}`)),
2242
3951
  tsconfigFile
2243
3952
  };
2244
3953
  }
@@ -2249,7 +3958,7 @@ function makeResolver(ts, co) {
2249
3958
  let resolved = r.resolvedModule?.resolvedFileName;
2250
3959
  if (resolved?.endsWith(".vue.ts") && ts.sys.fileExists(resolved.slice(0, -3))) resolved = resolved.slice(0, -3);
2251
3960
  if (!resolved) return null;
2252
- return { resolved, fromNodeModules: resolved.includes(`${path4.sep}node_modules${path4.sep}`) };
3961
+ return { resolved, fromNodeModules: resolved.includes(`${path6.sep}node_modules${path6.sep}`) };
2253
3962
  };
2254
3963
  }
2255
3964
  async function generateTypesBundle(input) {
@@ -2262,7 +3971,7 @@ async function generateTypesBundle(input) {
2262
3971
  if (!tsPkgDir) {
2263
3972
  return { ok: false, diagnostics: [`\u63D0\u4F9B\u65B9\u5DE5\u7A0B\u672A\u5B89\u88C5 typescript\uFF08\u58F0\u660E\u751F\u6210\u5FC5\u9700\uFF09\u3002${installHint(root, "typescript")}`] };
2264
3973
  }
2265
- const tsReq = createRequire3(path4.join(tsPkgDir, "package.json"));
3974
+ const tsReq = createRequire4(path6.join(tsPkgDir, "package.json"));
2266
3975
  const ts = tsReq("typescript");
2267
3976
  const ctx = loadTsContext(root, ts, diagnostics);
2268
3977
  if (!ctx) return { ok: false, diagnostics };
@@ -2270,15 +3979,15 @@ async function generateTypesBundle(input) {
2270
3979
  const entryMap = /* @__PURE__ */ new Map();
2271
3980
  for (const expose of exposes) {
2272
3981
  const raw = expose.import.replace(/^\.?\//, "");
2273
- let abs = path4.resolve(root, raw);
2274
- if (!fs5.existsSync(abs)) {
2275
- const viaResolver = resolver(expose.import, path4.join(root, "package.json"));
3982
+ let abs = path6.resolve(root, raw);
3983
+ if (!fs6.existsSync(abs)) {
3984
+ const viaResolver = resolver(expose.import, path6.join(root, "package.json"));
2276
3985
  if (viaResolver && !viaResolver.fromNodeModules) abs = viaResolver.resolved;
2277
3986
  }
2278
3987
  abs = abs.replace(/\.js$/, ".ts");
2279
- if (!fs5.existsSync(abs) && fs5.existsSync(`${abs}.ts`)) abs = `${abs}.ts`;
2280
- if (!fs5.existsSync(abs) && fs5.existsSync(`${abs}.tsx`)) abs = `${abs}.tsx`;
2281
- if (!fs5.existsSync(abs)) {
3988
+ if (!fs6.existsSync(abs) && fs6.existsSync(`${abs}.ts`)) abs = `${abs}.ts`;
3989
+ if (!fs6.existsSync(abs) && fs6.existsSync(`${abs}.tsx`)) abs = `${abs}.tsx`;
3990
+ if (!fs6.existsSync(abs)) {
2282
3991
  diagnostics.push(`\u66B4\u9732\u5165\u53E3 ${expose.name} \u7684\u6E90\u6587\u4EF6\u4E0D\u5B58\u5728\uFF08${expose.import}\uFF09\u3002\u8BF7\u6838\u5BF9 exposes \u914D\u7F6E\u3002`);
2283
3992
  continue;
2284
3993
  }
@@ -2304,14 +4013,14 @@ async function generateTypesBundle(input) {
2304
4013
  };
2305
4014
  }
2306
4015
  tool = "vue-tsc";
2307
- const vueTscPkg = JSON.parse(fs5.readFileSync(path4.join(vueTscDir, "package.json"), "utf8"));
4016
+ const vueTscPkg = JSON.parse(fs6.readFileSync(path6.join(vueTscDir, "package.json"), "utf8"));
2308
4017
  const binRel = vueTscPkg.bin?.["vue-tsc"] ?? vueTscPkg.bin?.["vue-tsc.js"] ?? "bin/vue-tsc.js";
2309
- const binPath = path4.resolve(vueTscDir, binRel);
2310
- if (!fs5.existsSync(binPath)) {
4018
+ const binPath = path6.resolve(vueTscDir, binRel);
4019
+ if (!fs6.existsSync(binPath)) {
2311
4020
  return { ok: false, diagnostics: [`vue-tsc \u5165\u53E3\u4E0D\u5B58\u5728\uFF08${binPath}\uFF09\u3002\u8BF7\u91CD\u65B0\u5B89\u88C5 vue-tsc\u3002`] };
2312
4021
  }
2313
- const tmpCfg = path4.join(root, `.fulgurjs-types-tsconfig-${process.pid}-${crypto.randomUUID()}.json`);
2314
- const outDir = fs5.mkdtempSync(path4.join(root, "node_modules", ".fulgurjs-types-emit-"));
4022
+ const tmpCfg = path6.join(root, `.fulgurjs-types-tsconfig-${process.pid}-${crypto.randomUUID()}.json`);
4023
+ const outDir = fs6.mkdtempSync(path6.join(root, "node_modules", ".fulgurjs-types-emit-"));
2315
4024
  const baseCo = { ...rawOptionsWithInherited(ctx) };
2316
4025
  delete baseCo.noEmit;
2317
4026
  delete baseCo.incremental;
@@ -2321,7 +4030,7 @@ async function generateTypesBundle(input) {
2321
4030
  delete baseCo.declarationDir;
2322
4031
  delete baseCo.extends;
2323
4032
  const resolvedTypeFiles = resolveTypesEntries(root, baseCo, diagnostics);
2324
- fs5.writeFileSync(tmpCfg, JSON.stringify({
4033
+ fs6.writeFileSync(tmpCfg, JSON.stringify({
2325
4034
  compilerOptions: {
2326
4035
  ...baseCo,
2327
4036
  noEmit: false,
@@ -2336,17 +4045,17 @@ async function generateTypesBundle(input) {
2336
4045
  rootDir
2337
4046
  },
2338
4047
  include: [
2339
- ...entryFiles.map((f) => path4.relative(root, f)),
2340
- ...ctx.ambientInputs.map((f) => path4.relative(root, f)),
2341
- ...resolvedTypeFiles.map((f) => path4.relative(root, f))
4048
+ ...entryFiles.map((f) => path6.relative(root, f)),
4049
+ ...ctx.ambientInputs.map((f) => path6.relative(root, f)),
4050
+ ...resolvedTypeFiles.map((f) => path6.relative(root, f))
2342
4051
  ]
2343
4052
  }));
2344
- if (process.env.FG_DUMP_TSCFG) fs5.writeFileSync(process.env.FG_DUMP_TSCFG, fs5.readFileSync(tmpCfg, "utf8"));
4053
+ if (process.env.FG_DUMP_TSCFG) fs6.writeFileSync(process.env.FG_DUMP_TSCFG, fs6.readFileSync(tmpCfg, "utf8"));
2345
4054
  try {
2346
4055
  await new Promise((resolve2, reject) => {
2347
4056
  const child = execFile(
2348
4057
  process.execPath,
2349
- [binPath, "-p", tmpCfg, "--noErrorTruncation"],
4058
+ [binPath, "-p", tmpCfg, "--noErrorTruncation", "--pretty", "false"],
2350
4059
  { cwd: root, encoding: "utf8", maxBuffer: 64 * 1024 * 1024, timeout: 10 * 60 * 1e3 },
2351
4060
  (err, stdout, stderr) => {
2352
4061
  if (err) {
@@ -2359,12 +4068,7 @@ async function generateTypesBundle(input) {
2359
4068
  const closureErrs = new Set([...errFiles].filter((f) => closure.has(f)));
2360
4069
  const globalError = /(?:^|\n)(?:error )?TS\d+:/.test(String(stdout ?? "") + "\n" + String(stderr ?? ""));
2361
4070
  if (closureErrs.size > 0 || globalError || errFiles.size === 0) {
2362
- const tail = `${String(stdout ?? "")}
2363
- ${String(stderr ?? "")}
2364
- ${err.message}`.split("\n").filter((line) => {
2365
- const m = line.match(/^([^)(]+)\(\d+,\d+\): error TS/);
2366
- return !m || closureErrs.has(path4.resolve(root, m[1].trim()));
2367
- }).slice(-40).join("\n");
4071
+ const tail = formatDeclarationDiagnostics(String(stdout ?? ""), String(stderr ?? ""), err.message, root, closure);
2368
4072
  diagnostics.push(`vue-tsc \u58F0\u660E\u751F\u6210\u5931\u8D25\uFF08\u66B4\u9732\u95ED\u5305\u5185\u5B58\u5728\u7F16\u8BD1\u9519\u8BEF\uFF09\u2014\u2014\u7C7B\u578B\u8D44\u6E90\u672A\u4EA7\u51FA\uFF1A
2369
4073
  ${tail}`);
2370
4074
  reject(err);
@@ -2379,16 +4083,16 @@ ${tail}`);
2379
4083
  signal?.addEventListener("abort", () => child.kill("SIGKILL"), { once: true });
2380
4084
  });
2381
4085
  } catch {
2382
- fs5.rmSync(outDir, { recursive: true, force: true });
2383
- fs5.rmSync(tmpCfg, { force: true });
4086
+ fs6.rmSync(outDir, { recursive: true, force: true });
4087
+ fs6.rmSync(tmpCfg, { force: true });
2384
4088
  return { ok: false, diagnostics };
2385
4089
  } finally {
2386
- fs5.rmSync(tmpCfg, { force: true });
4090
+ fs6.rmSync(tmpCfg, { force: true });
2387
4091
  }
2388
4092
  collectEmitted(ts, outDir, rootDir, emitted, closure);
2389
- fs5.rmSync(outDir, { recursive: true, force: true });
4093
+ fs6.rmSync(outDir, { recursive: true, force: true });
2390
4094
  } else {
2391
- const outDir = fs5.mkdtempSync(path4.join(root, "node_modules", ".fulgurjs-types-emit-"));
4095
+ const outDir = fs6.mkdtempSync(path6.join(root, "node_modules", ".fulgurjs-types-emit-"));
2392
4096
  const program = ts.createProgram([...entryFiles, ...ctx.ambientInputs, ...resolveTypesEntries(root, ctx.rawOptions, [])], {
2393
4097
  ...ctx.compilerOptions,
2394
4098
  noEmit: false,
@@ -2406,13 +4110,13 @@ ${tail}`);
2406
4110
  ...program.getOptionsDiagnostics(),
2407
4111
  ...program.getSemanticDiagnostics(),
2408
4112
  ...program.getDeclarationDiagnostics()
2409
- ].filter((d) => d.category === ts.DiagnosticCategory.Error).filter((d) => !d.file || closure.has(path4.resolve(d.file.fileName)));
4113
+ ].filter((d) => d.category === ts.DiagnosticCategory.Error).filter((d) => !d.file || closure.has(path6.resolve(d.file.fileName)));
2410
4114
  if (errs.length > 0) {
2411
- fs5.rmSync(outDir, { recursive: true, force: true });
4115
+ fs6.rmSync(outDir, { recursive: true, force: true });
2412
4116
  diagnostics.push(
2413
4117
  `\u58F0\u660E\u751F\u6210\u5931\u8D25\uFF1A\u66B4\u9732\u95ED\u5305\u5185\u5B58\u5728 ${errs.length} \u4E2A\u7F16\u8BD1\u9519\u8BEF\u2014\u2014\u7C7B\u578B\u8D44\u6E90\u672A\u4EA7\u51FA\uFF08\u4FEE\u590D\u540E\u91CD\u65B0\u6784\u5EFA/\u91CD\u542F dev\uFF09\u3002\u524D\u82E5\u5E72\u6761\uFF1A`,
2414
4118
  ...errs.slice(0, 20).map((d) => {
2415
- const f = d.file ? path4.relative(root, d.file.fileName) : "?";
4119
+ const f = d.file ? path6.relative(root, d.file.fileName) : "?";
2416
4120
  const pos = d.file ? d.file.getLineAndCharacterOfPosition(d.start ?? 0) : { line: 0 };
2417
4121
  return ` ${f}:${pos.line + 1} TS${d.code}: ${ts.flattenDiagnosticMessageText(d.messageText, " ")}`;
2418
4122
  })
@@ -2421,14 +4125,14 @@ ${tail}`);
2421
4125
  }
2422
4126
  const emitResult = program.emit();
2423
4127
  if (emitResult.emitSkipped) {
2424
- fs5.rmSync(outDir, { recursive: true, force: true });
4128
+ fs6.rmSync(outDir, { recursive: true, force: true });
2425
4129
  return { ok: false, diagnostics: ["TypeScript \u58F0\u660E emit \u5931\u8D25\uFF08emitSkipped\uFF09\u3002\u8BF7\u68C0\u67E5 tsconfig \u7F16\u8BD1\u9009\u9879\u3002"] };
2426
4130
  }
2427
4131
  collectEmitted(ts, outDir, rootDir, emitted, closure);
2428
- fs5.rmSync(outDir, { recursive: true, force: true });
4132
+ fs6.rmSync(outDir, { recursive: true, force: true });
2429
4133
  }
2430
4134
  for (const file of closure) {
2431
- if (file.endsWith(".d.ts")) emitted.set(file, fs5.readFileSync(file, "utf8"));
4135
+ if (file.endsWith(".d.ts")) emitted.set(file, fs6.readFileSync(file, "utf8"));
2432
4136
  }
2433
4137
  if (signal?.aborted) return { ok: false, diagnostics: ["\u58F0\u660E\u751F\u6210\u88AB\u4E2D\u6B62\u3002"] };
2434
4138
  if (emitted.size === 0) {
@@ -2437,7 +4141,7 @@ ${tail}`);
2437
4141
  const externals = /* @__PURE__ */ new Set();
2438
4142
  const srcToRel = /* @__PURE__ */ new Map();
2439
4143
  for (const srcAbs of emitted.keys()) {
2440
- const rel = path4.relative(rootDir, srcAbs).split(path4.sep).join("/");
4144
+ const rel = path6.relative(rootDir, srcAbs).split(path6.sep).join("/");
2441
4145
  const declRel = rel.endsWith(".d.ts") ? `files/${rel}` : rel.endsWith(".vue") ? `files/${rel}.d.ts` : `files/${rel.replace(/\.(mts|cts|ts|tsx|jsx|js)$/, "")}.d.ts`;
2442
4146
  srcToRel.set(srcAbs, declRel);
2443
4147
  }
@@ -2452,7 +4156,7 @@ ${tail}`);
2452
4156
  for (const [srcAbs, text] of emitted) {
2453
4157
  const rel = srcToRel.get(srcAbs);
2454
4158
  if (text.includes(root)) {
2455
- diagnostics.push(`\u58F0\u660E\u6587\u4EF6\u5305\u542B\u672C\u673A\u7EDD\u5BF9\u8DEF\u5F84\uFF08${path4.relative(root, srcAbs)}\uFF09\uFF0C\u5DF2\u62D2\u7EDD\u4EA7\u51FA\u3002\u8BF7\u68C0\u67E5\u8BE5\u6587\u4EF6\u7684\u7C7B\u578B\u662F\u5426\u5F15\u7528\u4E86\u5B57\u9762\u8DEF\u5F84\u3002`);
4159
+ diagnostics.push(`\u58F0\u660E\u6587\u4EF6\u5305\u542B\u672C\u673A\u7EDD\u5BF9\u8DEF\u5F84\uFF08${path6.relative(root, srcAbs)}\uFF09\uFF0C\u5DF2\u62D2\u7EDD\u4EA7\u51FA\u3002\u8BF7\u68C0\u67E5\u8BE5\u6587\u4EF6\u7684\u7C7B\u578B\u662F\u5426\u5F15\u7528\u4E86\u5B57\u9762\u8DEF\u5F84\u3002`);
2456
4160
  leaked = true;
2457
4161
  }
2458
4162
  files.set(rel, text);
@@ -2483,27 +4187,27 @@ ${tail}`);
2483
4187
  return { ok: true, files, index: fullIndex, tool, fileCount: filesDigest ? Object.keys(filesDigest).length : 0 };
2484
4188
  }
2485
4189
  function collectEmitted(ts, outDir, rootDir, out, closure) {
2486
- const walk = (dir) => fs5.readdirSync(dir, { withFileTypes: true }).flatMap((d) => {
2487
- const p = path4.join(dir, d.name);
4190
+ const walk = (dir) => fs6.readdirSync(dir, { withFileTypes: true }).flatMap((d) => {
4191
+ const p = path6.join(dir, d.name);
2488
4192
  return d.isDirectory() ? walk(p) : [p];
2489
4193
  });
2490
- if (!fs5.existsSync(outDir)) return;
4194
+ if (!fs6.existsSync(outDir)) return;
2491
4195
  for (const file of walk(outDir)) {
2492
4196
  if (!file.endsWith(".d.ts")) continue;
2493
- const rel = path4.relative(outDir, file);
4197
+ const rel = path6.relative(outDir, file);
2494
4198
  const srcRel = rel.endsWith(".vue.d.ts") ? rel.replace(/\.d\.ts$/, "") : rel.replace(/\.d\.ts$/, ".ts");
2495
- let srcAbs = path4.join(rootDir, srcRel);
2496
- if (!out.has(srcAbs) && !fs5.existsSync(srcAbs)) {
4199
+ let srcAbs = path6.join(rootDir, srcRel);
4200
+ if (!out.has(srcAbs) && !fs6.existsSync(srcAbs)) {
2497
4201
  for (const ext of [".tsx", ".jsx", ".mts", ".cts", ".js"]) {
2498
- const candidate = path4.join(rootDir, rel.replace(/\.d\.ts$/, ext));
2499
- if (fs5.existsSync(candidate)) {
4202
+ const candidate = path6.join(rootDir, rel.replace(/\.d\.ts$/, ext));
4203
+ if (fs6.existsSync(candidate)) {
2500
4204
  srcAbs = candidate;
2501
4205
  break;
2502
4206
  }
2503
4207
  }
2504
4208
  }
2505
4209
  if (!closure.has(srcAbs)) continue;
2506
- out.set(srcAbs, fs5.readFileSync(file, "utf8"));
4210
+ out.set(srcAbs, fs6.readFileSync(file, "utf8"));
2507
4211
  }
2508
4212
  void ts;
2509
4213
  }
@@ -2511,7 +4215,7 @@ function rewriteSpecifiers(ts, text, srcAbs, srcToRel, resolver, externals, root
2511
4215
  const declRel = srcToRel.get(srcAbs);
2512
4216
  const fail = (spec) => {
2513
4217
  diagnostics.push(
2514
- `\u58F0\u660E\u4F9D\u8D56\u4E0D\u5B8C\u6574\uFF1A${path4.relative(root, srcAbs)} \u7684\u5BFC\u5165 "${spec}" \u65E0\u6CD5\u89E3\u6790\u5230\u5DE5\u7A0B\u5185\u6587\u4EF6\u3002\u8BF7\u68C0\u67E5 tsconfig paths/include \u662F\u5426\u8986\u76D6\u8BE5\u4F9D\u8D56\u3002`
4218
+ `\u58F0\u660E\u4F9D\u8D56\u4E0D\u5B8C\u6574\uFF1A${path6.relative(root, srcAbs)} \u7684\u5BFC\u5165 "${spec}" \u65E0\u6CD5\u89E3\u6790\u5230\u5DE5\u7A0B\u5185\u6587\u4EF6\u3002\u8BF7\u68C0\u67E5 tsconfig paths/include \u662F\u5426\u8986\u76D6\u8BE5\u4F9D\u8D56\u3002`
2515
4219
  );
2516
4220
  return null;
2517
4221
  };
@@ -2536,9 +4240,9 @@ function rewriteSpecifiers(ts, text, srcAbs, srcToRel, resolver, externals, root
2536
4240
  return srcToRel.get(resolved) ?? fail(spec);
2537
4241
  };
2538
4242
  const rewriteTo = (targetRel) => {
2539
- const fromDir = path4.posix.dirname(declRel);
4243
+ const fromDir = path6.posix.dirname(declRel);
2540
4244
  const toNoExt = targetRel.replace(/\.d\.ts$/, "");
2541
- let rel = path4.posix.relative(fromDir, toNoExt);
4245
+ let rel = path6.posix.relative(fromDir, toNoExt);
2542
4246
  if (!rel.startsWith(".")) rel = `./${rel}`;
2543
4247
  return rel;
2544
4248
  };
@@ -2610,6 +4314,7 @@ var INHERITABLE_KEYS;
2610
4314
  var init_dts_generate = __esm({
2611
4315
  "src/dts-generate.ts"() {
2612
4316
  "use strict";
4317
+ init_dts_diagnostics();
2613
4318
  init_dts_shared();
2614
4319
  INHERITABLE_KEYS = [
2615
4320
  "paths",
@@ -2648,8 +4353,8 @@ function buildAmbientDeclarations(input) {
2648
4353
  if (!isSafeBundlePath(meta.declaration)) continue;
2649
4354
  const exposeName = expose.replace(/^\.\//, "");
2650
4355
  let name = `${alias}/${exposeName}`;
2651
- let n = 2;
2652
- while (used.has(name)) name = `${alias}/${exposeName}$${n++}`;
4356
+ let n2 = 2;
4357
+ while (used.has(name)) name = `${alias}/${exposeName}$${n2++}`;
2653
4358
  used.add(name);
2654
4359
  ambientOf.set(meta.declaration, name);
2655
4360
  }
@@ -2657,8 +4362,8 @@ function buildAmbientDeclarations(input) {
2657
4362
  if (ambientOf.has(rel)) continue;
2658
4363
  const internal = rel.replace(/^files\//, "").replace(/(\.vue)?\.d\.ts$/, "");
2659
4364
  let name = `${alias}/__internal/${internal}`;
2660
- let n = 2;
2661
- while (used.has(name)) name = `${alias}/__internal/${internal}$${n++}`;
4365
+ let n2 = 2;
4366
+ while (used.has(name)) name = `${alias}/__internal/${internal}$${n2++}`;
2662
4367
  used.add(name);
2663
4368
  ambientOf.set(rel, name);
2664
4369
  }
@@ -2708,11 +4413,11 @@ ${indented.trimEnd()}
2708
4413
  ``
2709
4414
  ].join("\n")
2710
4415
  );
2711
- return { files, publicModules: [...ambientOf.values()].filter((n) => !n.includes("/__internal/")), warnings };
4416
+ return { files, publicModules: [...ambientOf.values()].filter((n2) => !n2.includes("/__internal/")), warnings };
2712
4417
  }
2713
4418
  function rewriteRelativeSpecifiers(text, bundleRel, resolve2, warnings) {
2714
4419
  const dir = bundleRel.includes("/") ? bundleRel.slice(0, bundleRel.lastIndexOf("/")) : "";
2715
- const targetOf = (spec) => {
4420
+ const targetOf2 = (spec) => {
2716
4421
  const joined = dir ? `${dir}/${spec}` : spec;
2717
4422
  const norm = pathNormalize(joined);
2718
4423
  const candidates = [norm, `${norm}.d.ts`, norm.endsWith(".vue") ? `${norm}.d.ts` : `${norm}.vue.d.ts`];
@@ -2723,19 +4428,19 @@ function rewriteRelativeSpecifiers(text, bundleRel, resolve2, warnings) {
2723
4428
  return null;
2724
4429
  };
2725
4430
  let out = text.replace(/(\bfrom\s*)(['"])(\.\.?\/[^'"]+)\2/g, (full, pre, q, spec) => {
2726
- const name = targetOf(spec);
4431
+ const name = targetOf2(spec);
2727
4432
  return name ? `${pre}${q}${name}${q}` : full;
2728
4433
  });
2729
4434
  out = out.replace(/(\bimport\s*)(['"])(\.\.?\/[^'"]+)\2/g, (full, pre, q, spec) => {
2730
- const name = targetOf(spec);
4435
+ const name = targetOf2(spec);
2731
4436
  return name ? `${pre}${q}${name}${q}` : full;
2732
4437
  });
2733
4438
  out = out.replace(/(\bexport\s*\*\s*from\s*)(['"])(\.\.?\/[^'"]+)\2/g, (full, pre, q, spec) => {
2734
- const name = targetOf(spec);
4439
+ const name = targetOf2(spec);
2735
4440
  return name ? `${pre}${q}${name}${q}` : full;
2736
4441
  });
2737
4442
  out = out.replace(/import\((['"])(\.\.?\/[^'"]+)\1\)/g, (full, q, spec) => {
2738
- const name = targetOf(spec);
4443
+ const name = targetOf2(spec);
2739
4444
  return name ? `import(${q}${name}${q})` : full;
2740
4445
  });
2741
4446
  if (/(?:\bfrom\s*|\bimport\s*|import\()['"]\.\.?\/[^'"]+['"]/.test(out)) {
@@ -2770,15 +4475,15 @@ var init_dts_ambient = __esm({
2770
4475
  });
2771
4476
 
2772
4477
  // src/dts-discovery.ts
2773
- import fs6 from "node:fs";
2774
- import path5 from "node:path";
4478
+ import fs7 from "node:fs";
4479
+ import path7 from "node:path";
2775
4480
  function stripJsoncForConfig(text) {
2776
4481
  let out = "";
2777
4482
  let i = 0;
2778
- const n = text.length;
4483
+ const n2 = text.length;
2779
4484
  let inStr = false;
2780
4485
  let esc = false;
2781
- while (i < n) {
4486
+ while (i < n2) {
2782
4487
  const c = text[i];
2783
4488
  if (inStr) {
2784
4489
  out += c;
@@ -2795,12 +4500,12 @@ function stripJsoncForConfig(text) {
2795
4500
  continue;
2796
4501
  }
2797
4502
  if (c === "/" && text[i + 1] === "/") {
2798
- while (i < n && text[i] !== "\n") i++;
4503
+ while (i < n2 && text[i] !== "\n") i++;
2799
4504
  continue;
2800
4505
  }
2801
4506
  if (c === "/" && text[i + 1] === "*") {
2802
4507
  i += 2;
2803
- while (i < n && !(text[i] === "*" && text[i + 1] === "/")) i++;
4508
+ while (i < n2 && !(text[i] === "*" && text[i + 1] === "/")) i++;
2804
4509
  i += 2;
2805
4510
  continue;
2806
4511
  }
@@ -2811,7 +4516,7 @@ function stripJsoncForConfig(text) {
2811
4516
  }
2812
4517
  function readCfg(file) {
2813
4518
  try {
2814
- const raw = JSON.parse(stripJsoncForConfig(fs6.readFileSync(file, "utf8")));
4519
+ const raw = JSON.parse(stripJsoncForConfig(fs7.readFileSync(file, "utf8")));
2815
4520
  const cfg = { file };
2816
4521
  for (const key of ["include", "files", "exclude"]) {
2817
4522
  const v = raw[key];
@@ -2835,25 +4540,25 @@ function effectiveCfg(cfg, depth = 0) {
2835
4540
  const parentFile = resolveConfigFile(parent, cfg.file);
2836
4541
  if (!parentFile) continue;
2837
4542
  const parentCfg = effectiveCfg(readCfg(parentFile) ?? { file: parentFile }, depth + 1);
2838
- const dirOf = (f, base) => path5.resolve(path5.dirname(base), f);
4543
+ const dirOf = (f, base) => path7.resolve(path7.dirname(base), f);
2839
4544
  if (parentCfg.include && !cfg.include) {
2840
- merged.include = parentCfg.include.map((p) => path5.relative(path5.dirname(cfg.file), dirOf(p, parentFile)) || ".");
4545
+ merged.include = parentCfg.include.map((p) => path7.relative(path7.dirname(cfg.file), dirOf(p, parentFile)) || ".");
2841
4546
  }
2842
4547
  if (parentCfg.files && !cfg.files) {
2843
- merged.files = parentCfg.files.map((p) => path5.relative(path5.dirname(cfg.file), dirOf(p, parentFile)));
4548
+ merged.files = parentCfg.files.map((p) => path7.relative(path7.dirname(cfg.file), dirOf(p, parentFile)));
2844
4549
  }
2845
4550
  if (parentCfg.exclude && !cfg.exclude) {
2846
- merged.exclude = parentCfg.exclude.map((p) => path5.relative(path5.dirname(cfg.file), dirOf(p, parentFile)));
4551
+ merged.exclude = parentCfg.exclude.map((p) => path7.relative(path7.dirname(cfg.file), dirOf(p, parentFile)));
2847
4552
  }
2848
4553
  }
2849
4554
  return merged;
2850
4555
  }
2851
4556
  function resolveConfigFile(value, declaringFile) {
2852
- let candidate = path5.resolve(path5.dirname(declaringFile), value);
4557
+ let candidate = path7.resolve(path7.dirname(declaringFile), value);
2853
4558
  if (!candidate.endsWith(".json")) candidate += ".json";
2854
- if (fs6.existsSync(candidate)) return candidate;
2855
- const asDir = path5.join(candidate, "tsconfig.json");
2856
- return fs6.existsSync(asDir) ? asDir : null;
4559
+ if (fs7.existsSync(candidate)) return candidate;
4560
+ const asDir = path7.join(candidate, "tsconfig.json");
4561
+ return fs7.existsSync(asDir) ? asDir : null;
2857
4562
  }
2858
4563
  function patternCoversDir(pattern, target, cfgDir) {
2859
4564
  const norm = pattern.replace(/^\.\//, "");
@@ -2863,15 +4568,15 @@ function patternCoversDir(pattern, target, cfgDir) {
2863
4568
  if (norm.includes("**")) base = norm.slice(0, norm.indexOf("**")).replace(/\/+$/, "");
2864
4569
  else if (norm.endsWith("/*")) base = norm.slice(0, -2);
2865
4570
  else base = norm.replace(/\/+$/, "");
2866
- const abs = base === "" || base === "." ? cfgDir : path5.resolve(cfgDir, base);
2867
- return target === abs || target.startsWith(abs + path5.sep);
4571
+ const abs = base === "" || base === "." ? cfgDir : path7.resolve(cfgDir, base);
4572
+ return target === abs || target.startsWith(abs + path7.sep);
2868
4573
  }
2869
4574
  function checkTypesDiscovery(root, typesRoot) {
2870
- const relTypes = path5.relative(root, typesRoot) || ".";
4575
+ const relTypes = path7.relative(root, typesRoot) || ".";
2871
4576
  const configs = [];
2872
- let primary = path5.join(root, "tsconfig.json");
2873
- if (!fs6.existsSync(primary)) {
2874
- const candidates = fs6.existsSync(root) ? fs6.readdirSync(root).filter((f) => /^tsconfig[\w.-]*\.json$/i.test(f)).map((f) => path5.join(root, f)) : [];
4577
+ let primary = path7.join(root, "tsconfig.json");
4578
+ if (!fs7.existsSync(primary)) {
4579
+ const candidates = fs7.existsSync(root) ? fs7.readdirSync(root).filter((f) => /^tsconfig[\w.-]*\.json$/i.test(f)).map((f) => path7.join(root, f)) : [];
2875
4580
  if (candidates.length === 0) {
2876
4581
  return {
2877
4582
  covered: false,
@@ -2883,7 +4588,7 @@ function checkTypesDiscovery(root, typesRoot) {
2883
4588
  if (candidates.length > 1) {
2884
4589
  let covered = false;
2885
4590
  for (const file of candidates) {
2886
- configs.push(path5.relative(root, file));
4591
+ configs.push(path7.relative(root, file));
2887
4592
  if (configCovers(file, typesRoot)) covered = true;
2888
4593
  }
2889
4594
  if (covered) return { covered: true, configs, fixHint: null };
@@ -2894,34 +4599,34 @@ function checkTypesDiscovery(root, typesRoot) {
2894
4599
  };
2895
4600
  }
2896
4601
  }
2897
- configs.push(path5.relative(root, primary));
4602
+ configs.push(path7.relative(root, primary));
2898
4603
  if (configCovers(primary, typesRoot)) return { covered: true, configs, fixHint: null };
2899
4604
  return {
2900
4605
  covered: false,
2901
4606
  configs,
2902
- fixHint: `TYP-006 \u7C7B\u578B\u76EE\u5F55 ${relTypes} \u672A\u88AB ${path5.relative(root, primary)} \u7684 include/files \u8986\u76D6\uFF08exclude \u6216\u4E25\u683C files \u767D\u540D\u5355\u90FD\u4F1A\u8BA9\u751F\u6210\u58F0\u660E\u5BF9 IDE/tsc \u4E0D\u53EF\u89C1\uFF09\u3002\u6700\u5C0F\u4FEE\u6CD5\uFF1Ainclude \u52A0\u5165 "${relTypes}/**/*.d.ts"\uFF0C\u6216\u79FB\u9664\u5BF9\u5B83\u7684 exclude/files \u9650\u5236\u3002`
4607
+ fixHint: `TYP-006 \u7C7B\u578B\u76EE\u5F55 ${relTypes} \u672A\u88AB ${path7.relative(root, primary)} \u7684 include/files \u8986\u76D6\uFF08exclude \u6216\u4E25\u683C files \u767D\u540D\u5355\u90FD\u4F1A\u8BA9\u751F\u6210\u58F0\u660E\u5BF9 IDE/tsc \u4E0D\u53EF\u89C1\uFF09\u3002\u6700\u5C0F\u4FEE\u6CD5\uFF1Ainclude \u52A0\u5165 "${relTypes}/**/*.d.ts"\uFF0C\u6216\u79FB\u9664\u5BF9\u5B83\u7684 exclude/files \u9650\u5236\u3002`
2903
4608
  };
2904
4609
  }
2905
4610
  function configCovers(cfgFile, typesRoot) {
2906
4611
  const raw = readCfg(cfgFile);
2907
4612
  if (!raw) return false;
2908
4613
  const cfg = effectiveCfg(raw);
2909
- const cfgDir = path5.dirname(cfgFile);
4614
+ const cfgDir = path7.dirname(cfgFile);
2910
4615
  const isSolution = Array.isArray(cfg.files) && cfg.files.length === 0 && !cfg.include;
2911
4616
  if (isSolution && cfg.references && cfg.references.length > 0) {
2912
4617
  return cfg.references.some((ref) => {
2913
- const refFile = resolveConfigFile(ref.startsWith(".") || path5.isAbsolute(ref) ? ref : `./${ref}`, cfgFile);
4618
+ const refFile = resolveConfigFile(ref.startsWith(".") || path7.isAbsolute(ref) ? ref : `./${ref}`, cfgFile);
2914
4619
  return refFile !== null && configCovers(refFile, typesRoot);
2915
4620
  });
2916
4621
  }
2917
4622
  if (Array.isArray(cfg.files) && cfg.files.length > 0) {
2918
4623
  return cfg.files.some((f) => {
2919
- const abs = path5.resolve(cfgDir, f);
2920
- return abs === typesRoot || abs.startsWith(typesRoot + path5.sep);
4624
+ const abs = path7.resolve(cfgDir, f);
4625
+ return abs === typesRoot || abs.startsWith(typesRoot + path7.sep);
2921
4626
  });
2922
4627
  }
2923
4628
  const includes = cfg.include;
2924
- if (!includes) return typesRoot === cfgDir || typesRoot.startsWith(cfgDir + path5.sep);
4629
+ if (!includes) return typesRoot === cfgDir || typesRoot.startsWith(cfgDir + path7.sep);
2925
4630
  const included = includes.some((p) => patternCoversDir(p, typesRoot, cfgDir));
2926
4631
  if (!included) return false;
2927
4632
  if (cfg.exclude && cfg.exclude.some((p) => patternCoversDir(p, typesRoot, cfgDir))) return false;
@@ -2934,8 +4639,8 @@ var init_dts_discovery = __esm({
2934
4639
  });
2935
4640
 
2936
4641
  // src/dts-sync.ts
2937
- import fs7 from "node:fs";
2938
- import path6 from "node:path";
4642
+ import fs8 from "node:fs";
4643
+ import path8 from "node:path";
2939
4644
  import crypto2 from "node:crypto";
2940
4645
  function readManifestTypes(m) {
2941
4646
  const t = m.types;
@@ -2971,7 +4676,7 @@ async function fetchText(url, timeoutMs) {
2971
4676
  }
2972
4677
  function readMetadata(dir) {
2973
4678
  try {
2974
- const raw = JSON.parse(fs7.readFileSync(path6.join(dir, METADATA_FILE), "utf8"));
4679
+ const raw = JSON.parse(fs8.readFileSync(path8.join(dir, METADATA_FILE), "utf8"));
2975
4680
  if (raw.generator !== "@fulgurjs/federation" || typeof raw.revision !== "string" || !Array.isArray(raw.files)) return null;
2976
4681
  return raw;
2977
4682
  } catch {
@@ -2981,19 +4686,19 @@ function readMetadata(dir) {
2981
4686
  function cleanupOwnFiles(dir, meta) {
2982
4687
  for (const f of meta.files) {
2983
4688
  if (!isSafeBundlePath(f)) continue;
2984
- fs7.rmSync(path6.join(dir, f), { force: true });
4689
+ fs8.rmSync(path8.join(dir, f), { force: true });
2985
4690
  }
2986
- fs7.rmSync(path6.join(dir, METADATA_FILE), { force: true });
4691
+ fs8.rmSync(path8.join(dir, METADATA_FILE), { force: true });
2987
4692
  try {
2988
- if (fs7.readdirSync(dir).length === 0) fs7.rmdirSync(dir);
4693
+ if (fs8.readdirSync(dir).length === 0) fs8.rmdirSync(dir);
2989
4694
  } catch {
2990
4695
  }
2991
4696
  }
2992
4697
  function sweepStaleStaging(typesRoot, alias) {
2993
- if (!fs7.existsSync(typesRoot)) return;
2994
- for (const name of fs7.readdirSync(typesRoot)) {
4698
+ if (!fs8.existsSync(typesRoot)) return;
4699
+ for (const name of fs8.readdirSync(typesRoot)) {
2995
4700
  if (name.startsWith(`.fg-staging-${alias}-`) || name.startsWith(`.fg-trash-${alias}-`)) {
2996
- fs7.rmSync(path6.join(typesRoot, name), { recursive: true, force: true });
4701
+ fs8.rmSync(path8.join(typesRoot, name), { recursive: true, force: true });
2997
4702
  }
2998
4703
  }
2999
4704
  }
@@ -3002,7 +4707,7 @@ async function syncRemoteTypes(input) {
3002
4707
  const fetchJsonFn = input.fetchJsonImpl ?? fetchJson;
3003
4708
  const fetchTextFn = input.fetchTextImpl ?? fetchText;
3004
4709
  const timeoutMs = input.timeoutMs ?? 15e3;
3005
- const dir = path6.join(typesRoot, alias);
4710
+ const dir = path8.join(typesRoot, alias);
3006
4711
  let manifest;
3007
4712
  try {
3008
4713
  const parsed = parseManifest(await fetchJsonFn(manifestUrl, timeoutMs));
@@ -3015,7 +4720,7 @@ async function syncRemoteTypes(input) {
3015
4720
  }
3016
4721
  manifest = parsed.manifest;
3017
4722
  } catch (e) {
3018
- const meta = fs7.existsSync(dir) ? readMetadata(dir) : null;
4723
+ const meta = fs8.existsSync(dir) ? readMetadata(dir) : null;
3019
4724
  return {
3020
4725
  status: "failed",
3021
4726
  alias,
@@ -3025,7 +4730,7 @@ async function syncRemoteTypes(input) {
3025
4730
  }
3026
4731
  const types = readManifestTypes(manifest);
3027
4732
  if (!types) {
3028
- const meta = fs7.existsSync(dir) ? readMetadata(dir) : null;
4733
+ const meta = fs8.existsSync(dir) ? readMetadata(dir) : null;
3029
4734
  if (isDevManifest(manifest) && manifest.typesPending === true) {
3030
4735
  return {
3031
4736
  status: meta ? "stale" : "failed",
@@ -3045,7 +4750,7 @@ async function syncRemoteTypes(input) {
3045
4750
  };
3046
4751
  }
3047
4752
  const indexUrl = new URL(types.index, manifestUrl).toString();
3048
- const existing = fs7.existsSync(dir) ? readMetadata(dir) : null;
4753
+ const existing = fs8.existsSync(dir) ? readMetadata(dir) : null;
3049
4754
  if (existing && existing.revision === types.revision && existing.ambientFormat === AMBIENT_FORMAT) {
3050
4755
  return { status: "unchanged", alias, revision: types.revision, message: `\u8FDC\u7A0B ${alias} \u7C7B\u578B\u5DF2\u662F\u6700\u65B0\uFF08revision ${types.revision}\uFF09\u3002` };
3051
4756
  }
@@ -3103,15 +4808,15 @@ async function syncRemoteTypes(input) {
3103
4808
  }
3104
4809
  const ambient = buildAmbientDeclarations({ alias, index, readFile: (rel) => indexRaw[rel] ?? "", source });
3105
4810
  sweepStaleStaging(typesRoot, alias);
3106
- const staging = path6.join(typesRoot, `.fg-staging-${alias}-${process.pid}-${Date.now()}`);
3107
- fs7.rmSync(staging, { recursive: true, force: true });
3108
- fs7.mkdirSync(staging, { recursive: true });
4811
+ const staging = path8.join(typesRoot, `.fg-staging-${alias}-${process.pid}-${Date.now()}`);
4812
+ fs8.rmSync(staging, { recursive: true, force: true });
4813
+ fs8.mkdirSync(staging, { recursive: true });
3109
4814
  const written = [];
3110
4815
  try {
3111
4816
  for (const [name, content] of ambient.files) {
3112
- const dest = path6.join(staging, name);
3113
- fs7.mkdirSync(path6.dirname(dest), { recursive: true });
3114
- fs7.writeFileSync(dest, content);
4817
+ const dest = path8.join(staging, name);
4818
+ fs8.mkdirSync(path8.dirname(dest), { recursive: true });
4819
+ fs8.writeFileSync(dest, content);
3115
4820
  written.push(name);
3116
4821
  }
3117
4822
  const meta = {
@@ -3124,22 +4829,22 @@ async function syncRemoteTypes(input) {
3124
4829
  externals: index.externals,
3125
4830
  syncedAt: Date.now()
3126
4831
  };
3127
- fs7.writeFileSync(path6.join(staging, METADATA_FILE), JSON.stringify(meta, null, 2));
3128
- const trash = path6.join(typesRoot, `.fg-trash-${alias}-${Date.now()}`);
4832
+ fs8.writeFileSync(path8.join(staging, METADATA_FILE), JSON.stringify(meta, null, 2));
4833
+ const trash = path8.join(typesRoot, `.fg-trash-${alias}-${Date.now()}`);
3129
4834
  let swapped = false;
3130
- if (fs7.existsSync(dir)) {
3131
- fs7.renameSync(dir, trash);
4835
+ if (fs8.existsSync(dir)) {
4836
+ fs8.renameSync(dir, trash);
3132
4837
  swapped = true;
3133
4838
  }
3134
4839
  try {
3135
- fs7.renameSync(staging, dir);
4840
+ fs8.renameSync(staging, dir);
3136
4841
  } catch (e) {
3137
- if (swapped) fs7.renameSync(trash, dir);
4842
+ if (swapped) fs8.renameSync(trash, dir);
3138
4843
  throw e;
3139
4844
  }
3140
- if (swapped) fs7.rmSync(trash, { recursive: true, force: true });
4845
+ if (swapped) fs8.rmSync(trash, { recursive: true, force: true });
3141
4846
  } catch (e) {
3142
- fs7.rmSync(staging, { recursive: true, force: true });
4847
+ fs8.rmSync(staging, { recursive: true, force: true });
3143
4848
  return { status: "failed", alias, message: `\u8FDC\u7A0B ${alias} \u7684\u7C7B\u578B\u5199\u5165\u5931\u8D25\uFF08${e.message}\uFF09\u3002\u672C\u5730\u58F0\u660E\u4FDD\u6301\u539F\u72B6\u3002` };
3144
4849
  }
3145
4850
  return {
@@ -3169,16 +4874,16 @@ __export(dts_cli_exports, {
3169
4874
  hostTypesRoot: () => hostTypesRoot,
3170
4875
  runTypesCommand: () => runTypesCommand
3171
4876
  });
3172
- import fs8 from "node:fs";
3173
- import path7 from "node:path";
3174
- import { createRequire as createRequire4 } from "node:module";
4877
+ import fs9 from "node:fs";
4878
+ import path9 from "node:path";
4879
+ import { createRequire as createRequire5 } from "node:module";
3175
4880
  function hostTypesRoot(root, dtsDirOverride) {
3176
- if (dtsDirOverride) return path7.resolve(root, dtsDirOverride);
3177
- return path7.join(root, fs8.existsSync(path7.join(root, "src")) ? "src/fulgurjs/types" : ".fulgurjs/types");
4881
+ if (dtsDirOverride) return path9.resolve(root, dtsDirOverride);
4882
+ return path9.join(root, fs9.existsSync(path9.join(root, "src")) ? "src/fulgurjs/types" : ".fulgurjs/types");
3178
4883
  }
3179
4884
  async function runTypesCommand(opts) {
3180
4885
  const cwd = opts.cwd ?? process.cwd();
3181
- const configPath = path7.resolve(cwd, opts.configPath ?? "fulgurjs.config.ts");
4886
+ const configPath = path9.resolve(cwd, opts.configPath ?? "fulgurjs.config.ts");
3182
4887
  const lines = [];
3183
4888
  let failed = false;
3184
4889
  let cfg;
@@ -3187,16 +4892,16 @@ async function runTypesCommand(opts) {
3187
4892
  } catch (e) {
3188
4893
  return { exitCode: 2, lines: [String(e.message ?? e)] };
3189
4894
  }
3190
- const root = path7.dirname(configPath);
4895
+ const root = path9.dirname(configPath);
3191
4896
  const mode = opts.mode ?? "dev";
3192
- const n = normalizeOptions(cfg.options, root, mode === "dev" ? "serve" : "build");
3193
- const dtsEnabled = n.dts !== false;
4897
+ const n2 = normalizeOptions(cfg.options, root, mode === "dev" ? "serve" : "build");
4898
+ const dtsEnabled = n2.dts !== false;
3194
4899
  if (!dtsEnabled) {
3195
4900
  lines.push(`dts: false\u2014\u2014\u672C\u5DE5\u7A0B\u4E3B\u52A8\u5173\u95ED\u8FDC\u7A0B\u7C7B\u578B\u652F\u6301\uFF0Ctypes \u547D\u4EE4\u4E0D\u6267\u884C\u4EFB\u4F55\u751F\u6210\u6216\u540C\u6B65\u3002`);
3196
4901
  return { exitCode: 0, lines };
3197
4902
  }
3198
- const typesRoot = hostTypesRoot(root, typeof n.dts === "object" ? n.dts.dir : void 0);
3199
- const publicExposes = n.exposes.filter((e) => !e.internal);
4903
+ const typesRoot = hostTypesRoot(root, typeof n2.dts === "object" ? n2.dts.dir : void 0);
4904
+ const publicExposes = n2.exposes.filter((e) => !e.internal);
3200
4905
  if (publicExposes.length > 0) {
3201
4906
  const result = await generateTypesBundle({
3202
4907
  root,
@@ -3213,10 +4918,10 @@ async function runTypesCommand(opts) {
3213
4918
  for (const d of result.diagnostics) lines.push(` ${d.replaceAll("\n", "\n ")}`);
3214
4919
  }
3215
4920
  }
3216
- const syncable = n.remotes.filter((r) => !r.promise && (mode === "dev" ? r.devEntry : r.prodEntry));
4921
+ const syncable = n2.remotes.filter((r) => !r.promise && (mode === "dev" ? r.devEntry : r.prodEntry));
3217
4922
  if (opts.check) {
3218
- for (const remote of n.remotes) {
3219
- const meta = readMetadata(path7.join(typesRoot, remote.key));
4923
+ for (const remote of n2.remotes) {
4924
+ const meta = readMetadata(path9.join(typesRoot, remote.key));
3220
4925
  if (!meta) {
3221
4926
  failed = true;
3222
4927
  lines.push(`[check] \u8FDC\u7A0B ${remote.key}\uFF1A\u672C\u5730\u65E0\u5DF2\u540C\u6B65\u7C7B\u578B\uFF08\u5148\u8FD0\u884C fulgurjs types\uFF09\u3002`);
@@ -3227,7 +4932,7 @@ async function runTypesCommand(opts) {
3227
4932
  return { exitCode: failed ? 1 : 0, lines };
3228
4933
  }
3229
4934
  if (syncable.length > 0) {
3230
- lines.push(`[consumer] \u5F00\u59CB\u540C\u6B65 ${syncable.length} \u4E2A\u8FDC\u7A0B\u7684\u7C7B\u578B\uFF08--mode ${mode}\uFF0C\u76EE\u5F55 ${path7.relative(root, typesRoot) || typesRoot}\uFF09\u2026\u2026`);
4935
+ lines.push(`[consumer] \u5F00\u59CB\u540C\u6B65 ${syncable.length} \u4E2A\u8FDC\u7A0B\u7684\u7C7B\u578B\uFF08--mode ${mode}\uFF0C\u76EE\u5F55 ${path9.relative(root, typesRoot) || typesRoot}\uFF09\u2026\u2026`);
3231
4936
  const externalsMissing = /* @__PURE__ */ new Map();
3232
4937
  for (const remote of syncable) {
3233
4938
  const entry = mode === "dev" ? remote.devEntry : remote.prodEntry;
@@ -3250,7 +4955,7 @@ async function runTypesCommand(opts) {
3250
4955
  if (result.status === "absent") {
3251
4956
  failed = true;
3252
4957
  }
3253
- const meta = readMetadata(path7.join(typesRoot, remote.key));
4958
+ const meta = readMetadata(path9.join(typesRoot, remote.key));
3254
4959
  if (meta) {
3255
4960
  for (const ext of meta.externals) {
3256
4961
  if (!resolvePackage(root, ext)) {
@@ -3284,11 +4989,11 @@ async function runTypesCommand(opts) {
3284
4989
  }
3285
4990
  function resolvePackage(root, pkg) {
3286
4991
  try {
3287
- createRequire4(path7.join(root, "package.json")).resolve(`${pkg}/package.json`);
4992
+ createRequire5(path9.join(root, "package.json")).resolve(`${pkg}/package.json`);
3288
4993
  return true;
3289
4994
  } catch {
3290
4995
  try {
3291
- createRequire4(path7.join(root, "package.json")).resolve(pkg);
4996
+ createRequire5(path9.join(root, "package.json")).resolve(pkg);
3292
4997
  return true;
3293
4998
  } catch {
3294
4999
  return false;
@@ -3314,16 +5019,16 @@ __export(port_exports, {
3314
5019
  formatPortPlan: () => formatPortPlan,
3315
5020
  planPortChange: () => planPortChange
3316
5021
  });
3317
- import fs9 from "node:fs";
3318
- import path8 from "node:path";
5022
+ import fs10 from "node:fs";
5023
+ import path10 from "node:path";
3319
5024
  function readDevConfig2(root) {
3320
- const file = path8.join(root, "scripts", "dev.config.json");
3321
- if (!fs9.existsSync(file)) {
5025
+ const file = path10.join(root, "scripts", "dev.config.json");
5026
+ if (!fs10.existsSync(file)) {
3322
5027
  throw new Error(
3323
5028
  "[fulgurjs:port] \u672A\u627E\u5230 scripts/dev.config.json\u2014\u2014\u672C\u547D\u4EE4\u7528\u4E8E\u6A21\u677F\u5DE5\u7A0B\uFF08create \u751F\u6210\uFF09\u3002\n \u4FEE\u6CD5\uFF1A\u5728\u6A21\u677F\u5DE5\u7A0B\u6839\u76EE\u5F55\u8FD0\u884C\uFF1B\u81EA\u5EFA\u5DE5\u7A0B\u8BF7\u6309\u6587\u6863\u56DB\u5904\u6E05\u5355\u624B\u5DE5\u6539\u7AEF\u53E3"
3324
5029
  );
3325
5030
  }
3326
- return JSON.parse(fs9.readFileSync(file, "utf8"));
5031
+ return JSON.parse(fs10.readFileSync(file, "utf8"));
3327
5032
  }
3328
5033
  function replacePort(text, from, to) {
3329
5034
  const re = new RegExp(`(?<![0-9])${from}(?![0-9])`, "g");
@@ -3348,23 +5053,23 @@ function planPortChange(root, app, to) {
3348
5053
  }
3349
5054
  const notes = [];
3350
5055
  const candidates = [
3351
- { file: path8.join(root, target.dir, "package.json"), required: true },
3352
- { file: path8.join(root, "scripts", "dev.config.json"), required: true },
3353
- { file: path8.join(root, "fulgurjs.config.ts"), required: false },
3354
- { file: path8.join(root, "README.md"), required: false }
5056
+ { file: path10.join(root, target.dir, "package.json"), required: true },
5057
+ { file: path10.join(root, "scripts", "dev.config.json"), required: true },
5058
+ { file: path10.join(root, "fulgurjs.config.ts"), required: false },
5059
+ { file: path10.join(root, "README.md"), required: false }
3355
5060
  ];
3356
5061
  for (const a of cfg.apps) {
3357
5062
  if (a.host && a.dir !== target.dir) {
3358
- candidates.push({ file: path8.join(root, a.dir, "fulgurjs.config.ts"), required: false });
5063
+ candidates.push({ file: path10.join(root, a.dir, "fulgurjs.config.ts"), required: false });
3359
5064
  }
3360
5065
  }
3361
5066
  const plans = [];
3362
5067
  for (const c of candidates) {
3363
- if (!fs9.existsSync(c.file)) {
5068
+ if (!fs10.existsSync(c.file)) {
3364
5069
  if (c.required) plans.push({ file: c.file, hits: 0, status: "missing-file" });
3365
5070
  continue;
3366
5071
  }
3367
- const text = fs9.readFileSync(c.file, "utf8");
5072
+ const text = fs10.readFileSync(c.file, "utf8");
3368
5073
  const { hits } = replacePort(text, from, to);
3369
5074
  plans.push({ file: c.file, hits, status: hits > 0 ? "planned" : "not-found" });
3370
5075
  }
@@ -3375,7 +5080,7 @@ function planPortChange(root, app, to) {
3375
5080
  }
3376
5081
  const notFound = plans.filter((p) => p.status === "not-found" || p.status === "missing-file");
3377
5082
  if (notFound.length) {
3378
- notes.push(`\u4EE5\u4E0B\u6587\u4EF6\u672A\u53D1\u73B0\u65E7\u7AEF\u53E3 ${from}\uFF08\u53EF\u80FD\u5DF2\u6539\u6216\u5F62\u6001\u4E0D\u540C\uFF0C\u8BF7\u4EBA\u5DE5\u786E\u8BA4\uFF09\uFF1A${notFound.map((p) => path8.relative(root, p.file)).join("\u3001")}`);
5083
+ notes.push(`\u4EE5\u4E0B\u6587\u4EF6\u672A\u53D1\u73B0\u65E7\u7AEF\u53E3 ${from}\uFF08\u53EF\u80FD\u5DF2\u6539\u6216\u5F62\u6001\u4E0D\u540C\uFF0C\u8BF7\u4EBA\u5DE5\u786E\u8BA4\uFF09\uFF1A${notFound.map((p) => path10.relative(root, p.file)).join("\u3001")}`);
3379
5084
  }
3380
5085
  return { app: target.name, dir: target.dir, from, to, plans, notes };
3381
5086
  }
@@ -3383,10 +5088,10 @@ function applyPortChange(root, plan) {
3383
5088
  let written = 0;
3384
5089
  for (const p of plan.plans) {
3385
5090
  if (p.status !== "planned" || p.hits === 0) continue;
3386
- const text = fs9.readFileSync(p.file, "utf8");
5091
+ const text = fs10.readFileSync(p.file, "utf8");
3387
5092
  const { text: out, hits } = replacePort(text, plan.from, plan.to);
3388
5093
  if (hits > 0) {
3389
- fs9.writeFileSync(p.file, out);
5094
+ fs10.writeFileSync(p.file, out);
3390
5095
  written++;
3391
5096
  }
3392
5097
  }
@@ -3396,12 +5101,12 @@ function formatPortPlan(root, plan) {
3396
5101
  const lines = [];
3397
5102
  lines.push(`[fulgurjs:port] \u8BA1\u5212\uFF1A${plan.app}\uFF08\u76EE\u5F55 ${plan.dir}\uFF09\u7AEF\u53E3 ${plan.from} \u2192 ${plan.to}`);
3398
5103
  for (const p of plan.plans) {
3399
- const rel = path8.relative(root, p.file);
5104
+ const rel = path10.relative(root, p.file);
3400
5105
  if (p.status === "planned") lines.push(` \u6539\u5199 ${rel}\uFF08${p.hits} \u5904\uFF09`);
3401
5106
  else if (p.status === "not-found") lines.push(` \u8DF3\u8FC7 ${rel}\uFF08\u672A\u53D1\u73B0\u65E7\u7AEF\u53E3 ${plan.from}\uFF09`);
3402
5107
  else lines.push(` \u8DF3\u8FC7 ${rel}\uFF08\u6587\u4EF6\u4E0D\u5B58\u5728\uFF09`);
3403
5108
  }
3404
- for (const n of plan.notes) lines.push(` \u6CE8\uFF1A${n}`);
5109
+ for (const n2 of plan.notes) lines.push(` \u6CE8\uFF1A${n2}`);
3405
5110
  lines.push("\u9884\u89C8\u6A21\u5F0F\u672A\u5199\u76D8\uFF1B\u786E\u8BA4\u65E0\u8BEF\u540E\u52A0 --write \u6267\u884C\u3002\u5199\u5165\u53EF\u7528 git checkout <file> \u56DE\u9000\u3002");
3406
5111
  return lines.join("\n");
3407
5112
  }
@@ -3411,69 +5116,14 @@ var init_port = __esm({
3411
5116
  }
3412
5117
  });
3413
5118
 
3414
- // node_modules/es-module-lexer/dist/lexer.js
3415
- function parse(E2, g = "@") {
3416
- if (!C) return init.then((() => parse(E2)));
3417
- const I = E2.length + 1, w = (C.__heap_base.value || C.__heap_base) + 4 * I - C.memory.buffer.byteLength;
3418
- w > 0 && C.memory.grow(Math.ceil(w / 65536));
3419
- const K = C.sa(I - 1);
3420
- if ((A ? B : Q)(E2, new Uint16Array(C.memory.buffer, K, I)), !C.parse()) throw Object.assign(new Error(`Parse error ${g}:${E2.slice(0, C.e()).split("\n").length}:${C.e() - E2.lastIndexOf("\n", C.e() - 1)}`), { idx: C.e() });
3421
- const o = [], D = [];
3422
- for (; C.ri(); ) {
3423
- const A2 = C.is(), Q2 = C.ie(), B2 = C.it(), g2 = C.ai(), I2 = C.id(), w2 = C.ss(), K2 = C.se();
3424
- let D2;
3425
- C.ip() && (D2 = k(E2.slice(-1 === I2 ? A2 - 1 : A2, -1 === I2 ? Q2 + 1 : Q2))), o.push({ n: D2, t: B2, s: A2, e: Q2, ss: w2, se: K2, d: I2, a: g2 });
3426
- }
3427
- for (; C.re(); ) {
3428
- const A2 = C.es(), Q2 = C.ee(), B2 = C.els(), g2 = C.ele(), I2 = E2.slice(A2, Q2), w2 = I2[0], K2 = B2 < 0 ? void 0 : E2.slice(B2, g2), o2 = K2 ? K2[0] : "";
3429
- D.push({ s: A2, e: Q2, ls: B2, le: g2, n: '"' === w2 || "'" === w2 ? k(I2) : I2, ln: '"' === o2 || "'" === o2 ? k(K2) : K2 });
3430
- }
3431
- function k(A2) {
3432
- try {
3433
- return (0, eval)(A2);
3434
- } catch (A3) {
3435
- }
3436
- }
3437
- return [o, D, !!C.f(), !!C.ms()];
3438
- }
3439
- function Q(A2, Q2) {
3440
- const B2 = A2.length;
3441
- let C2 = 0;
3442
- for (; C2 < B2; ) {
3443
- const B3 = A2.charCodeAt(C2);
3444
- Q2[C2++] = (255 & B3) << 8 | B3 >>> 8;
3445
- }
3446
- }
3447
- function B(A2, Q2) {
3448
- const B2 = A2.length;
3449
- let C2 = 0;
3450
- for (; C2 < B2; ) Q2[C2] = A2.charCodeAt(C2++);
3451
- }
3452
- var ImportType, A, C, E, init;
3453
- var init_lexer = __esm({
3454
- "node_modules/es-module-lexer/dist/lexer.js"() {
3455
- !(function(A2) {
3456
- A2[A2.Static = 1] = "Static", A2[A2.Dynamic = 2] = "Dynamic", A2[A2.ImportMeta = 3] = "ImportMeta", A2[A2.StaticSourcePhase = 4] = "StaticSourcePhase", A2[A2.DynamicSourcePhase = 5] = "DynamicSourcePhase", A2[A2.StaticDeferPhase = 6] = "StaticDeferPhase", A2[A2.DynamicDeferPhase = 7] = "DynamicDeferPhase";
3457
- })(ImportType || (ImportType = {}));
3458
- A = 1 === new Uint8Array(new Uint16Array([1]).buffer)[0];
3459
- E = () => {
3460
- return A2 = "AGFzbQEAAAABKwhgAX8Bf2AEf39/fwBgAAF/YAAAYAF/AGADf39/AX9gAn9/AX9gA39/fwADMTAAAQECAgICAgICAgICAgICAgICAgIAAwMDBAQAAAUAAAAAAAMDAwAGAAAABwAGAgUEBQFwAQEBBQMBAAEGDwJ/AUHA8gALfwBBwPIACwd6FQZtZW1vcnkCAAJzYQAAAWUAAwJpcwAEAmllAAUCc3MABgJzZQAHAml0AAgCYWkACQJpZAAKAmlwAAsCZXMADAJlZQANA2VscwAOA2VsZQAPAnJpABACcmUAEQFmABICbXMAEwVwYXJzZQAUC19faGVhcF9iYXNlAwEKzkQwaAEBf0EAIAA2AoAKQQAoAtwJIgEgAEEBdGoiAEEAOwEAQQAgAEECaiIANgKECkEAIAA2AogKQQBBADYC4AlBAEEANgLwCUEAQQA2AugJQQBBADYC5AlBAEEANgL4CUEAQQA2AuwJIAEL0wEBA39BACgC8AkhBEEAQQA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BACgCsAoiAEECajYCsAogAC8BAiIADQAMAgsLIAAhAgsgAkH//wNxC6sBAQR/AkACQEEAKAKwCiICLwEAIgNB4QBGDQAgASEEIAAhBQwBC0EAIAJBBGo2ArAKQQEQKSECQQAoArAKIQUCQAJAIAJBIkYNACACQSdGDQAgAhAsGkEAKAKwCiEEDAELIAIQGkEAQQAoArAKQQJqIgQ2ArAKC0EBECkhA0EAKAKwCiECCwJAIAIgBUYNACAFIARBACAAIAAgAUYiAhtBACABIAIbEAILIAMLcgEEf0EAKAKwCiEAQQAoArQKIQECQAJAA0AgAEECaiECIAAgAU8NAQJAAkAgAi8BACIDQaR/ag4CAQQACyACIQAgA0F2ag4EAgEBAgELIABBBGohAAwACwtBACACNgKwChAlQQAPC0EAIAI2ArAKQd0AC0kBA39BACEDAkAgAkUNAAJAA0AgAC0AACIEIAEtAAAiBUcNASABQQFqIQEgAEEBaiEAIAJBf2oiAg0ADAILCyAEIAVrIQMLIAMLC+wBAgBBgAgLzgEAAHgAcABvAHIAdABtAHAAbwByAHQAZgBvAHIAZQB0AGEAbwB1AHIAYwBlAHIAbwBtAHUAbgBjAHQAaQBvAG4AcwBzAGUAcgB0AHYAbwB5AGkAZQBkAGUAbABlAGMAbwBuAHQAaQBuAGkAbgBzAHQAYQBuAHQAeQBiAHIAZQBhAHIAZQB0AHUAcgBkAGUAYgB1AGcAZwBlAGEAdwBhAGkAdABoAHIAdwBoAGkAbABlAGkAZgBjAGEAdABjAGYAaQBuAGEAbABsAGUAbABzAABB0AkLEAEAAAACAAAAAAQAAEA5AAA=", "undefined" != typeof Buffer ? Buffer.from(A2, "base64") : Uint8Array.from(atob(A2), ((A3) => A3.charCodeAt(0)));
3461
- var A2;
3462
- };
3463
- init = WebAssembly.compile(E()).then(WebAssembly.instantiate).then((({ exports: A2 }) => {
3464
- C = A2;
3465
- }));
3466
- }
3467
- });
3468
-
3469
5119
  // src/doctor-source.ts
3470
5120
  var doctor_source_exports = {};
3471
5121
  __export(doctor_source_exports, {
3472
5122
  runSourceDoctor: () => runSourceDoctor
3473
5123
  });
3474
- import fs10 from "node:fs";
3475
- import path9 from "node:path";
3476
- import { createRequire as createRequire5 } from "node:module";
5124
+ import fs11 from "node:fs";
5125
+ import path11 from "node:path";
5126
+ import { createRequire as createRequire6 } from "node:module";
3477
5127
  async function runSourceDoctor(configPath) {
3478
5128
  let loaded;
3479
5129
  try {
@@ -3497,7 +5147,7 @@ async function runSourceDoctor(configPath) {
3497
5147
  integrationFiles: { required: [], optional: [], existing: [] }
3498
5148
  };
3499
5149
  }
3500
- const root = fs10.realpathSync(loaded.appRoot);
5150
+ const root = fs11.realpathSync(loaded.appRoot);
3501
5151
  const options = loaded.options;
3502
5152
  const app = options.name;
3503
5153
  const checks = [];
@@ -3506,23 +5156,36 @@ async function runSourceDoctor(configPath) {
3506
5156
  const imports = /* @__PURE__ */ new Set();
3507
5157
  const sources = /* @__PURE__ */ new Map();
3508
5158
  let complete = true;
3509
- const relative = (file) => path9.relative(root, file).split(path9.sep).join("/");
3510
- const within = (file) => file === root || file.startsWith(root + path9.sep);
5159
+ const relative = (file) => path11.relative(root, file).split(path11.sep).join("/");
5160
+ const within = (file) => file === root || file.startsWith(root + path11.sep);
3511
5161
  const add = (item, level, symptom, cause, fix) => {
3512
5162
  checks.push({ app, item, level, symptom, cause, fix });
3513
5163
  };
3514
5164
  const resolveSource = (value, parent = root) => {
3515
5165
  const clean = value.split(/[?#]/)[0];
3516
- const file = /^(?:\/?@\/|~\/)/.test(clean) ? path9.join(root, "src", clean.replace(/^(?:\/?@\/|~\/)/, "")) : path9.resolve(parent, clean);
5166
+ const file = /^(?:\/?@\/|~\/)/.test(clean) ? path11.join(root, "src", clean.replace(/^(?:\/?@\/|~\/)/, "")) : path11.resolve(parent, clean);
3517
5167
  for (const ext of extensions) {
3518
5168
  const candidate = file + ext;
3519
- if (!fs10.existsSync(candidate) || !fs10.statSync(candidate).isFile()) continue;
3520
- const real = fs10.realpathSync(candidate);
5169
+ if (!fs11.existsSync(candidate) || !fs11.statSync(candidate).isFile()) continue;
5170
+ const real = fs11.realpathSync(candidate);
3521
5171
  return real;
3522
5172
  }
3523
5173
  return void 0;
3524
5174
  };
3525
5175
  const required = [relative(loaded.configPath)];
5176
+ const viteFiles = ["vite.config.ts", "vite.config.mts", "vite.config.js", "vite.config.mjs"].filter((file) => fs11.existsSync(path11.join(root, file)));
5177
+ if (viteFiles.length !== 1) add("Vite \u63D2\u4EF6\u63A5\u7EBF", "WARN", "\u672A\u627E\u5230\u552F\u4E00\u5E38\u89C4 Vite \u914D\u7F6E\uFF0C\u65E0\u6CD5\u786E\u8BA4\u63D2\u4EF6\u6CE8\u518C\u3002", "\u53EF\u80FD\u4F7F\u7528\u81EA\u5B9A\u4E49 --config \u6216\u591A\u4EFD\u73AF\u5883\u914D\u7F6E\u3002", "\u5728\u5B9E\u9645 Vite plugins \u4E2D\u6CE8\u518C federation(fulgurjsConfig)\uFF1Binit --plan \u53EF\u9884\u89C8\u53D7\u652F\u6301\u914D\u7F6E\u7684\u63A5\u7EBF\u3002");
5178
+ else {
5179
+ const code = fs11.readFileSync(path11.join(root, viteFiles[0]), "utf8");
5180
+ add(
5181
+ viteFiles[0],
5182
+ "WARN",
5183
+ "Vite \u914D\u7F6E\u5B58\u5728\uFF1B\u63D2\u4EF6\u8C03\u7528\u3001\u52A8\u6001 base \u4E0E\u90E8\u7F72\u5BF9\u5E94\u5173\u7CFB\u4ECD\u9700\u6838\u5BF9\u3002",
5184
+ "\u672C\u5730\u9884\u68C0\u4E0D\u6267\u884C Vite \u914D\u7F6E\uFF1B\u5BFC\u5165\u63D2\u4EF6\u6216\u5199\u4E86\u6CE8\u91CA\u5E76\u4E0D\u80FD\u8BC1\u660E plugins \u5B9E\u9645\u542F\u7528\u3002",
5185
+ code.includes("@fulgurjs/federation") ? "\u8FD0\u884C\u771F\u5B9E dev/build\uFF1B\u786E\u8BA4\u5F53\u524D\u914D\u7F6E\u8C03\u7528 federation\uFF0C\u751F\u4EA7 base/\u8FDC\u7A0B prod \u524D\u7F00\u4E0E\u670D\u52A1\u5668\u6620\u5C04\u4E00\u81F4\u3002" : "\u68C0\u67E5\u63D2\u4EF6\u662F\u5426\u7531\u8F85\u52A9\u51FD\u6570\u6CE8\u518C\uFF1B\u5426\u5219\u7528 init --plan \u9884\u89C8\u63A5\u7EBF\uFF0C\u4E0D\u8981\u4EC5\u521B\u5EFA fulgurjs.config.ts\u3002"
5186
+ );
5187
+ }
5188
+ if (fs11.existsSync(path11.join(root, ".fulgurjs-init-pending.json"))) add("\u63A5\u5165\u5199\u5165\u6062\u590D", "FAIL", "\u5B58\u5728\u88AB\u4E2D\u65AD\u7684 init \u5199\u5165\u8BB0\u5F55\u3002", "\u6B64\u524D\u5199\u5165\u5C1A\u672A\u5B8C\u6210\u6216\u56DE\u9000\u9047\u5230\u624B\u5DE5\u7F16\u8F91\u3002", "\u8FD0\u884C fulgurjs init --rollback\uFF1B\u82E5\u63D0\u793A\u6587\u4EF6\u88AB\u7F16\u8F91\uFF0C\u6309\u6062\u590D\u8BB0\u5F55\u4EBA\u5DE5\u5408\u5E76\u540E\u518D\u6267\u884C\u3002");
3526
5189
  for (const [key, expose] of Object.entries(options.exposes ?? {})) {
3527
5190
  const file = resolveSource(typeof expose === "string" ? expose : expose.import);
3528
5191
  if (file) {
@@ -3548,15 +5211,18 @@ async function runSourceDoctor(configPath) {
3548
5211
  add("setup", "FAIL", "setup \u6E90\u6587\u4EF6\u4E0D\u5B58\u5728\u6216\u65E0\u6CD5\u89E3\u6790\u3002", "\u521D\u59CB\u5316\u5165\u53E3\u4E0D\u80FD\u5728\u52A0\u8F7D\u65F6\u624D\u53D1\u73B0\u7F3A\u5931\u3002", "\u4FEE\u6B63 setup \u8DEF\u5F84\uFF1B\u6CA1\u6709\u521D\u59CB\u5316\u9700\u6C42\u5219\u5220\u9664 setup \u914D\u7F6E\u3002");
3549
5212
  }
3550
5213
  }
3551
- const html = path9.join(root, "index.html");
5214
+ const html = path11.join(root, "index.html");
3552
5215
  let hasEntry = false;
3553
- if (fs10.existsSync(html)) for (const tag of fs10.readFileSync(html, "utf8").matchAll(/<script\b[^>]*>/gi)) {
5216
+ if (fs11.existsSync(html)) for (const tag of fs11.readFileSync(html, "utf8").matchAll(/<script\b[^>]*>/gi)) {
3554
5217
  const entry = tag[0].match(/\bsrc=["']([^"']+)["']/i)?.[1];
3555
5218
  if (!entry || !/\btype=["']module["']/i.test(tag[0]) || /^(?:https?:)?\/\//.test(entry)) continue;
3556
5219
  const file = resolveSource(entry.replace(/^\//, ""));
3557
5220
  if (file) {
3558
5221
  pending.push(file);
3559
5222
  hasEntry = true;
5223
+ } else {
5224
+ complete = false;
5225
+ add("index.html \u5165\u53E3", "FAIL", `\u672C\u5730 module \u5165\u53E3\u4E0D\u5B58\u5728\uFF1A${entry}`, "\u5165\u53E3\u5F15\u7528\u65E0\u6CD5\u89E3\u6790\uFF0C\u4E0D\u80FD\u53EA\u68C0\u67E5 expose \u8DEF\u5F84\u3002", "\u4FEE\u6B63 index.html script src\uFF0C\u6216\u6062\u590D\u5B9E\u9645\u5165\u53E3\uFF1B\u81EA\u5B9A\u4E49\u865A\u62DF\u5165\u53E3\u4F7F\u7528\u5176\u63D2\u4EF6\u6784\u5EFA\u68C0\u67E5\u6838\u5B9E\u3002");
3560
5226
  }
3561
5227
  }
3562
5228
  if (Object.keys(options.remotes ?? {}).length && !hasEntry) complete = false;
@@ -3571,7 +5237,7 @@ async function runSourceDoctor(configPath) {
3571
5237
  if (seen.has(file) || /\.d\.[cm]?ts$/.test(file) || relative(file).includes("fulgurjs/types/")) continue;
3572
5238
  if (!/\.(?:[cm]?js|jsx|ts|tsx|vue)$/.test(file)) continue;
3573
5239
  seen.add(file);
3574
- const raw = fs10.readFileSync(file, "utf8");
5240
+ const raw = fs11.readFileSync(file, "utf8");
3575
5241
  if (file.endsWith(".vue") && /<script\b[^>]*\bsrc\s*=/.test(raw)) complete = false;
3576
5242
  const script = file.endsWith(".vue") ? [...raw.matchAll(/<script\b[^>]*>([\s\S]*?)<\/script>/gi)].map((match) => match[1]).join("\n") : raw;
3577
5243
  try {
@@ -3584,9 +5250,15 @@ async function runSourceDoctor(configPath) {
3584
5250
  continue;
3585
5251
  }
3586
5252
  imports.add(item.n);
5253
+ if (/\.d\.[cm]?ts(?:[?#]|$)/.test(item.n)) {
5254
+ add(relative(file), "FAIL", `\u8FD0\u884C\u65F6\u4EE3\u7801\u5BFC\u5165\u4E86\u7C7B\u578B\u58F0\u660E\uFF1A${item.n}`, "\u751F\u6210\u58F0\u660E\u4E0D\u662F\u53EF\u6267\u884C\u6A21\u5757\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u7EC4\u4EF6/\u5DE5\u5177\u8FD0\u884C\u65F6\u6CE8\u518C\u3002", "\u53EA\u4F7F\u7528 import type\uFF0C\u6216\u5F15\u7528\u771F\u6B63\u7684\u8FDC\u7A0B\u6A21\u5757\uFF1B\u68C0\u67E5 glob \u662F\u5426\u6392\u9664 **/*.d.ts\u3002");
5255
+ }
5256
+ if (item.n.startsWith("@fulgurjs/federation/") && !["@fulgurjs/federation/vue", "@fulgurjs/federation/react", "@fulgurjs/federation/runtime"].includes(item.n)) {
5257
+ add(relative(file), "WARN", `\u5E94\u7528\u4EE3\u7801\u4F7F\u7528\u975E\u63A8\u8350\u5165\u53E3\uFF1A${item.n}`, "\u5185\u90E8\u6A21\u5757\u4E0D\u662F\u5E94\u7528\u63A5\u5165\u8DEF\u5F84\uFF1B\u9759\u6001\u9884\u68C0\u4E0D\u5224\u65AD\u8BE5\u8DEF\u5F84\u662F\u5426\u4ECD\u88AB exports \u5141\u8BB8\u3002", "Vue \u7528 /vue\uFF0CReact \u7528 /react\uFF0C\u6846\u67B6\u65E0\u5173\u6A21\u5757\u7528 /runtime\uFF1B\u7C7B\u578B\u6CE8\u518C\u8868\u7684 import type \u4E0D\u5E94\u6210\u4E3A\u8FD0\u884C\u65F6\u4EE3\u7801\u3002");
5258
+ }
3587
5259
  if (item.n.startsWith(".") || /^(?:\/?@\/|~\/)/.test(item.n)) {
3588
5260
  if (/\.(?:[cm]?js|jsx|ts|tsx|vue)$/.test(item.n.split(/[?#]/)[0]) || !/\.[a-z0-9]+$/i.test(item.n.split(/[?#]/)[0])) {
3589
- const next = resolveSource(item.n, path9.dirname(file));
5261
+ const next = resolveSource(item.n, path11.dirname(file));
3590
5262
  if (next) pending.push(next);
3591
5263
  else {
3592
5264
  complete = false;
@@ -3611,7 +5283,7 @@ async function runSourceDoctor(configPath) {
3611
5283
  "\u5728\u56DE\u8C03\u4E2D\u4F20\u5165\u672C\u5E94\u7528 pinia\uFF0C\u6216\u7528 /vue \u7684 bindStoreToApp \u7ED1\u5B9A\u5B9E\u9645\u5B9E\u4F8B\uFF1B\u7EC4\u4EF6\u5185\u4FDD\u7559\u539F\u751F\u6CE8\u5165\uFF0C\u4E0D\u628A\u5E93\u5355\u4F8B\u5F53\u6210\u4E1A\u52A1 store \u5B9E\u4F8B\u3002"
3612
5284
  );
3613
5285
  }
3614
- if (/defineBridgeApp\s*\(/.test(code) && /createWeb(?:Hash)?History\s*\(/.test(code) && !/createMemoryHistory|defineApplication/.test(code)) {
5286
+ if (/define(?:BridgeApp|Application)\s*\(/.test(code) && /createWeb(?:Hash)?History\s*\(/.test(code) && !/createMemoryHistory/.test(code)) {
3615
5287
  add(
3616
5288
  file,
3617
5289
  "WARN",
@@ -3633,6 +5305,15 @@ async function runSourceDoctor(configPath) {
3633
5305
  }
3634
5306
  }
3635
5307
  const shared = Array.isArray(options.shared) ? options.shared : Object.keys(options.shared ?? {});
5308
+ if (Object.keys(options.remotes ?? {}).length && options.dts !== false) {
5309
+ add(
5310
+ "\u8FDC\u7A0B\u7C7B\u578B\u63A5\u7EBF",
5311
+ "WARN",
5312
+ "\u8FDC\u7A0B\u7C7B\u578B\u542F\u7528\uFF1B\u672C\u5730\u626B\u63CF\u4E0D\u80FD\u8BC1\u660E\u58F0\u660E\u5DF2\u540C\u6B65\u4E14\u88AB IDE \u7684\u6709\u6548 tsconfig \u5305\u542B\u3002",
5313
+ "\u9996\u6B21\u751F\u6210\u3001\u8FDC\u7A0B\u672A\u542F\u52A8\u3001\u81EA\u5B9A\u4E49 include/references \u6216 IDE \u9879\u76EE\u9009\u62E9\u90FD\u4F1A\u5F71\u54CD\u63D0\u793A\u3002",
5314
+ "\u542F\u52A8\u63D0\u4F9B\u65B9\u540E\u8FD0\u884C fulgurjs types\uFF1B\u5728\u5B9E\u9645\u6D88\u8D39\u6587\u4EF6\u9A8C\u8BC1\u6B63\u786E props \u548C\u9519\u8BEF props \u7684\u6B63\u8D1F\u7C7B\u578B\u6837\u4F8B\u3002\u52FF\u7528 any \u6D88\u9664\u8BCA\u65AD\uFF0C\u4E5F\u65E0\u9700\u6E05\u7A7A\u5168\u90E8\u4E1A\u52A1\u5B58\u91CF\u9519\u8BEF\u3002"
5315
+ );
5316
+ }
3636
5317
  const isImported = (key) => [...imports].some((value) => value === key || value.startsWith(key + "/"));
3637
5318
  for (const key of shared) {
3638
5319
  const hint = Array.isArray(options.shared) ? void 0 : options.shared?.[key];
@@ -3696,7 +5377,7 @@ var init_doctor_source = __esm({
3696
5377
  "use strict";
3697
5378
  init_lexer();
3698
5379
  init_app_config();
3699
- requireFromHere = createRequire5(import.meta.url);
5380
+ requireFromHere = createRequire6(import.meta.url);
3700
5381
  esbuildTransform = () => {
3701
5382
  if (!cachedTransform) {
3702
5383
  const esb = requireFromHere("esbuild");
@@ -3721,7 +5402,7 @@ function fetchHeadOrGet(url, method = "GET") {
3721
5402
  const req = mod.request(url, { method, headers: { accept: "*/*" } }, (res) => {
3722
5403
  const chunks = [];
3723
5404
  res.on("data", (c) => {
3724
- if (chunks.reduce((n, b) => n + b.length, 0) < 2 * 1024 * 1024) chunks.push(c);
5405
+ if (chunks.reduce((n2, b) => n2 + b.length, 0) < 2 * 1024 * 1024) chunks.push(c);
3725
5406
  });
3726
5407
  res.on(
3727
5408
  "end",
@@ -4034,6 +5715,13 @@ var HELP = `fulgurjs \u2014 Vite Module Federation CLI (@fulgurjs/federation)
4034
5715
  \u4FDD\u7559\u4F60\u7684\u7248\u672C\uFF08\u7EDD\u4E0D\u6539\u5199\uFF09\uFF1B--json \u65F6 stdout \u4EC5\u8F93\u51FA\u7ED3\u679C
4035
5716
  JSON\uFF0C\u8FDB\u5EA6\u4E0E\u5B89\u88C5\u65E5\u5FD7\u8D70 stderr
4036
5717
  \u5DF2\u6709\u9879\u76EE\uFF08\u5355\u9879\u76EE fulgurjs.config.ts \u5728\u5E94\u7528\u6839\u76EE\u5F55\uFF1B\u547D\u4EE4\u9ED8\u8BA4\u8BFB ./fulgurjs.config.ts\uFF09\uFF1A
5718
+ fulgurjs init --plan [--kind component|app] [--role consumer|provider|dual]
5719
+ [--remote \u540D\u79F0=http://\u5F00\u53D1\u5730\u5740] [--expose ./\u952E=./\u6E90\u6587\u4EF6]
5720
+ [--name \u5BB9\u5668\u540D] [--entry src/main.ts] [--framework vue|react] [--json]
5721
+ \u53EA\u626B\u63CF\u5E76\u9884\u89C8\u5B8C\u6574\u5DEE\u5F02\u4E0E\u4EBA\u5DE5\u5F85\u529E\uFF1B\u53EF\u91CD\u590D remote/expose\u3002
5722
+ --kind \u9ED8\u8BA4 component\uFF1Bapp \u652F\u6301\u7B80\u5355\u5165\u53E3\u63D0\u53D6\u4E0E\u5BBF\u4E3B\u89C6\u56FE\u3002
5723
+ --write \u663E\u5F0F\u5E94\u7528\uFF1B\u963B\u65AD\u9879\u5B58\u5728\u65F6\u6574\u6279\u4E0D\u5199\uFF0C\u4E0D\u8986\u76D6\u5DF2\u6709\u914D\u7F6E\u3002
5724
+ fulgurjs init --rollback \u6062\u590D\u88AB\u4E2D\u65AD\u7684\u8BA1\u5212\u5199\u5165\uFF1B\u6709\u540E\u7EED\u4EBA\u5DE5\u7F16\u8F91\u65F6\u62D2\u7EDD\u8986\u76D6\u3002
4037
5725
  fulgurjs init [--out <\u8DEF\u5F84>] [--framework vue|react] [--role consumer|provider|dual] [--force]
4038
5726
  \u751F\u6210\u5355\u9879\u76EE fulgurjs.config.ts \u8D77\u6B65\u6A21\u677F\uFF08\u6700\u5C0F\u6709\u6548\u914D\u7F6E\uFF09\uFF1A
4039
5727
  \u6846\u67B6\u9ED8\u8BA4\u4ECE package.json \u4F9D\u8D56\u5224\u65AD\uFF08\u5224\u65AD\u4E0D\u4E86\u8981\u6C42\u663E\u5F0F --framework\uFF09\uFF1B
@@ -4104,6 +5792,63 @@ async function main() {
4104
5792
  return out;
4105
5793
  };
4106
5794
  if (cmd === "init") {
5795
+ if (has("--rollback")) {
5796
+ try {
5797
+ if (argv.length !== 2) throw new Error("--rollback \u5FC5\u987B\u72EC\u7ACB\u4F7F\u7528\uFF0C\u4E0D\u4E0E\u5199\u5165\u6216\u9884\u89C8\u53C2\u6570\u6DF7\u7528\u3002");
5798
+ const { rollbackIntegration: rollbackIntegration2 } = await Promise.resolve().then(() => (init_init_plan(), init_plan_exports));
5799
+ rollbackIntegration2(process.cwd());
5800
+ console.log("[fulgurjs:init] \u5DF2\u6062\u590D\u88AB\u4E2D\u65AD\u7684\u5199\u5165\uFF1B\u8BF7\u91CD\u65B0\u751F\u6210\u63A5\u5165\u9884\u89C8\u3002");
5801
+ return 0;
5802
+ } catch (error) {
5803
+ console.error(String(error.message ?? error));
5804
+ return 1;
5805
+ }
5806
+ }
5807
+ if (has("--plan") || has("--write")) {
5808
+ try {
5809
+ if (has("--config") || has("--out") || has("--force")) throw new Error("\u63A5\u5165\u8BA1\u5212\u4E0D\u80FD\u540C\u65F6\u4F7F\u7528 --config/--out/--force\uFF1B\u5DF2\u6709\u914D\u7F6E\u8BF7\u5355\u72EC\u8FD0\u884C doctor --config \u68C0\u67E5\u3002");
5810
+ const values = ["--kind", "--role", "--framework", "--name", "--entry", "--remote", "--expose"];
5811
+ for (let i = 1; i < argv.length; i++) {
5812
+ if (["--plan", "--write", "--json"].includes(argv[i])) continue;
5813
+ if (!values.includes(argv[i])) throw new Error(`\u672A\u77E5\u63A5\u5165\u8BA1\u5212\u53C2\u6570\uFF1A${argv[i]}`);
5814
+ if (!argv[i + 1] || argv[i + 1].startsWith("--")) throw new Error(`${argv[i]} \u7F3A\u5C11\u503C`);
5815
+ i++;
5816
+ }
5817
+ const kind = argOf("--kind") ?? "component";
5818
+ const role = argOf("--role") ?? "dual";
5819
+ const framework2 = argOf("--framework");
5820
+ if (!["component", "app"].includes(kind) || !["consumer", "provider", "dual"].includes(role) || framework2 && !["vue", "react"].includes(framework2)) throw new Error("\u8BF7\u4F7F\u7528 --kind component|app\u3001--role consumer|provider|dual\u3001--framework vue|react\u3002");
5821
+ const pairs = (flag) => {
5822
+ const result2 = {};
5823
+ argv.forEach((value, i) => {
5824
+ if (value !== flag) return;
5825
+ const pair = argv[i + 1], eq = pair?.indexOf("=") ?? -1;
5826
+ if (eq < 1 || !pair.slice(eq + 1) || pair.startsWith("--")) throw new Error(`${flag} \u9700\u8981 \u952E=\u503C\uFF1B\u4E0D\u4F1A\u731C\u8FDC\u7A0B\u5730\u5740\u6216\u4E1A\u52A1\u6587\u4EF6\u3002`);
5827
+ const key = pair.slice(0, eq);
5828
+ if (Object.hasOwn(result2, key)) throw new Error(`${flag} \u91CD\u590D\u952E\uFF1A${key}`);
5829
+ Object.defineProperty(result2, key, { value: pair.slice(eq + 1), enumerable: true, configurable: true });
5830
+ });
5831
+ return result2;
5832
+ };
5833
+ const { planIntegration: planIntegration2, formatIntegrationPlan: formatIntegrationPlan2, applyIntegration: applyIntegration2 } = await Promise.resolve().then(() => (init_init_plan(), init_plan_exports));
5834
+ const plan = await planIntegration2({ cwd: process.cwd(), kind, role, framework: framework2, name: argOf("--name"), entry: argOf("--entry"), remotes: pairs("--remote"), exposes: pairs("--expose") });
5835
+ const blocked = plan.tasks.some((task) => task.blocking);
5836
+ if (has("--write") && !blocked) applyIntegration2(plan);
5837
+ const written = has("--write") && !blocked;
5838
+ if (has("--json")) console.log(JSON.stringify({ ...plan, written }, null, 2));
5839
+ else console.log(formatIntegrationPlan2(plan) + (blocked ? "\n\u5B58\u5728\u963B\u65AD\u9879\uFF0C\u6574\u6279\u672A\u5199\u5165\uFF1B\u5148\u5904\u7406\u6240\u5217\u4E8B\u9879\u518D\u9884\u89C8\u3002" : written ? "\n\u5DF2\u5E94\u7528\u8BA1\u5212\uFF1B\u4EBA\u5DE5\u63A5\u7EBF\u4E0E\u771F\u5B9E\u6D4F\u89C8\u5668\u9A8C\u8BC1\u4ECD\u9700\u5B8C\u6210\u3002" : "\n\u786E\u8BA4\u4EE5\u4E0A\u5DEE\u5F02\u540E\uFF0C\u4F7F\u7528\u76F8\u540C\u53C2\u6570\u8FFD\u52A0 --write \u5E94\u7528\uFF1B\u5DE5\u5177\u4E0D\u81EA\u52A8\u5B89\u88C5\u4F9D\u8D56\u3002"));
5840
+ return blocked ? 1 : 0;
5841
+ } catch (error) {
5842
+ const message = String(error.message ?? error);
5843
+ if (has("--json")) console.log(JSON.stringify({ written: false, error: message }));
5844
+ else console.error(`[fulgurjs:init] ${message}`);
5845
+ return 1;
5846
+ }
5847
+ }
5848
+ if (["--kind", "--remote", "--expose", "--entry", "--name"].some(has)) {
5849
+ console.error("[fulgurjs:init] \u63A5\u5165\u8BA1\u5212\u53C2\u6570\u9700\u8981 --plan\uFF08\u9884\u89C8\uFF09\u6216 --write\uFF08\u663E\u5F0F\u5199\u5165\uFF09\u3002");
5850
+ return 2;
5851
+ }
4107
5852
  const { writeConfigTemplate: writeConfigTemplate2, inspectConfig: inspectConfig2, detectFrameworkFromPackageJson: detectFrameworkFromPackageJson2 } = await Promise.resolve().then(() => (init_init(), init_exports));
4108
5853
  const configPath = argOf("--config");
4109
5854
  if (configPath) {
@@ -4290,7 +6035,7 @@ async function main() {
4290
6035
  if (has("--write")) {
4291
6036
  const written = applyPortChange2(process.cwd(), plan);
4292
6037
  console.log(`[fulgurjs:port] \u5DF2\u5199\u5165 ${written} \u4E2A\u6587\u4EF6\uFF08${app} ${plan.from} \u2192 ${plan.to}\uFF09\u3002\u56DE\u9000\uFF1Agit checkout <file>`);
4293
- for (const n of plan.notes) console.log(` \u6CE8\uFF1A${n}`);
6038
+ for (const n2 of plan.notes) console.log(` \u6CE8\uFF1A${n2}`);
4294
6039
  } else {
4295
6040
  console.log(formatPortPlan2(process.cwd(), plan));
4296
6041
  }