@meethive/vite 0.0.3 → 0.0.4

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.
package/dist/index.js CHANGED
@@ -1,10 +1,13 @@
1
- "use strict";
2
1
  var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
5
  var __getProtoOf = Object.getPrototypeOf;
7
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
8
11
  var __copyProps = (to, from, except, desc) => {
9
12
  if (from && typeof from === "object" || typeof from === "function") {
10
13
  for (let key of __getOwnPropNames(from))
@@ -21,30 +24,1264 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
25
  mod
23
26
  ));
24
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
25
- const virtual = require("@rollup/plugin-virtual");
26
- const path = require("path");
27
- const estreeWalker = require("estree-walker");
28
- const MagicString = require("magic-string");
29
- const path$1 = require("node:path");
30
- const fs = require("fs");
31
- require("crypto");
32
- require("./dynamic-remote.js");
33
- const esbuild = require("esbuild");
34
- const EXPOSES_MAP = /* @__PURE__ */ new Map();
35
- const EXPOSES_KEY_MAP = /* @__PURE__ */ new Map();
36
- const SHARED = "shared";
37
- const DYNAMIC_LOADING_CSS = "dynamicLoadingCss";
38
- const DYNAMIC_LOADING_CSS_PREFIX = "__v__css__";
39
- const DEFAULT_ENTRY_FILENAME = "remoteEntry.js";
40
- const builderInfo = {
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // index.ts
30
+ var index_exports = {};
31
+ __export(index_exports, {
32
+ federation: () => federation,
33
+ monacoEditorPlugin: () => monacoEditorPlugin,
34
+ sharpOptimize: () => sharpOptimize
35
+ });
36
+ module.exports = __toCommonJS(index_exports);
37
+
38
+ // node_modules/.pnpm/@rollup+plugin-virtual@3.0.2_rollup@4.48.1/node_modules/@rollup/plugin-virtual/dist/es/index.js
39
+ var path = __toESM(require("path"), 1);
40
+ var PREFIX = `\0virtual:`;
41
+ function virtual(modules) {
42
+ const resolvedIds = /* @__PURE__ */ new Map();
43
+ Object.keys(modules).forEach((id) => {
44
+ resolvedIds.set(path.resolve(id), modules[id]);
45
+ });
46
+ return {
47
+ name: "virtual",
48
+ resolveId(id, importer) {
49
+ if (id in modules)
50
+ return PREFIX + id;
51
+ if (importer) {
52
+ const importerNoPrefix = importer.startsWith(PREFIX) ? importer.slice(PREFIX.length) : importer;
53
+ const resolved = path.resolve(path.dirname(importerNoPrefix), id);
54
+ if (resolvedIds.has(resolved))
55
+ return PREFIX + resolved;
56
+ }
57
+ return null;
58
+ },
59
+ load(id) {
60
+ if (id.startsWith(PREFIX)) {
61
+ const idNoPrefix = id.slice(PREFIX.length);
62
+ return idNoPrefix in modules ? modules[idNoPrefix] : resolvedIds.get(idNoPrefix);
63
+ }
64
+ return null;
65
+ }
66
+ };
67
+ }
68
+
69
+ // src/federation/src/index.ts
70
+ var import_path5 = require("path");
71
+
72
+ // node_modules/.pnpm/estree-walker@3.0.2/node_modules/estree-walker/src/walker.js
73
+ var WalkerBase = class {
74
+ constructor() {
75
+ this.should_skip = false;
76
+ this.should_remove = false;
77
+ this.replacement = null;
78
+ this.context = {
79
+ skip: () => this.should_skip = true,
80
+ remove: () => this.should_remove = true,
81
+ replace: (node) => this.replacement = node
82
+ };
83
+ }
84
+ /**
85
+ *
86
+ * @param {any} parent
87
+ * @param {string} prop
88
+ * @param {number} index
89
+ * @param {BaseNode} node
90
+ */
91
+ replace(parent, prop, index, node) {
92
+ if (parent) {
93
+ if (index !== null) {
94
+ parent[prop][index] = node;
95
+ } else {
96
+ parent[prop] = node;
97
+ }
98
+ }
99
+ }
100
+ /**
101
+ *
102
+ * @param {any} parent
103
+ * @param {string} prop
104
+ * @param {number} index
105
+ */
106
+ remove(parent, prop, index) {
107
+ if (parent) {
108
+ if (index !== null) {
109
+ parent[prop].splice(index, 1);
110
+ } else {
111
+ delete parent[prop];
112
+ }
113
+ }
114
+ }
115
+ };
116
+
117
+ // node_modules/.pnpm/estree-walker@3.0.2/node_modules/estree-walker/src/sync.js
118
+ var SyncWalker = class extends WalkerBase {
119
+ /**
120
+ *
121
+ * @param {SyncHandler} enter
122
+ * @param {SyncHandler} leave
123
+ */
124
+ constructor(enter, leave) {
125
+ super();
126
+ this.enter = enter;
127
+ this.leave = leave;
128
+ }
129
+ /**
130
+ *
131
+ * @param {BaseNode} node
132
+ * @param {BaseNode} parent
133
+ * @param {string} [prop]
134
+ * @param {number} [index]
135
+ * @returns {BaseNode}
136
+ */
137
+ visit(node, parent, prop, index) {
138
+ if (node) {
139
+ if (this.enter) {
140
+ const _should_skip = this.should_skip;
141
+ const _should_remove = this.should_remove;
142
+ const _replacement = this.replacement;
143
+ this.should_skip = false;
144
+ this.should_remove = false;
145
+ this.replacement = null;
146
+ this.enter.call(this.context, node, parent, prop, index);
147
+ if (this.replacement) {
148
+ node = this.replacement;
149
+ this.replace(parent, prop, index, node);
150
+ }
151
+ if (this.should_remove) {
152
+ this.remove(parent, prop, index);
153
+ }
154
+ const skipped = this.should_skip;
155
+ const removed = this.should_remove;
156
+ this.should_skip = _should_skip;
157
+ this.should_remove = _should_remove;
158
+ this.replacement = _replacement;
159
+ if (skipped) return node;
160
+ if (removed) return null;
161
+ }
162
+ for (const key in node) {
163
+ const value = node[key];
164
+ if (typeof value !== "object") {
165
+ continue;
166
+ } else if (Array.isArray(value)) {
167
+ for (let i = 0; i < value.length; i += 1) {
168
+ if (value[i] !== null && typeof value[i].type === "string") {
169
+ if (!this.visit(value[i], node, key, i)) {
170
+ i--;
171
+ }
172
+ }
173
+ }
174
+ } else if (value !== null && typeof value.type === "string") {
175
+ this.visit(value, node, key, null);
176
+ }
177
+ }
178
+ if (this.leave) {
179
+ const _replacement = this.replacement;
180
+ const _should_remove = this.should_remove;
181
+ this.replacement = null;
182
+ this.should_remove = false;
183
+ this.leave.call(this.context, node, parent, prop, index);
184
+ if (this.replacement) {
185
+ node = this.replacement;
186
+ this.replace(parent, prop, index, node);
187
+ }
188
+ if (this.should_remove) {
189
+ this.remove(parent, prop, index);
190
+ }
191
+ const removed = this.should_remove;
192
+ this.replacement = _replacement;
193
+ this.should_remove = _should_remove;
194
+ if (removed) return null;
195
+ }
196
+ }
197
+ return node;
198
+ }
199
+ };
200
+
201
+ // node_modules/.pnpm/estree-walker@3.0.2/node_modules/estree-walker/src/index.js
202
+ function walk(ast, { enter, leave }) {
203
+ const instance = new SyncWalker(enter, leave);
204
+ return instance.visit(ast, null);
205
+ }
206
+
207
+ // node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
208
+ var comma = ",".charCodeAt(0);
209
+ var semicolon = ";".charCodeAt(0);
210
+ var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
211
+ var intToChar = new Uint8Array(64);
212
+ var charToInt = new Uint8Array(128);
213
+ for (let i = 0; i < chars.length; i++) {
214
+ const c = chars.charCodeAt(i);
215
+ intToChar[i] = c;
216
+ charToInt[c] = i;
217
+ }
218
+ function encodeInteger(builder, num, relative3) {
219
+ let delta = num - relative3;
220
+ delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
221
+ do {
222
+ let clamped = delta & 31;
223
+ delta >>>= 5;
224
+ if (delta > 0) clamped |= 32;
225
+ builder.write(intToChar[clamped]);
226
+ } while (delta > 0);
227
+ return num;
228
+ }
229
+ var bufLength = 1024 * 16;
230
+ var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? {
231
+ decode(buf) {
232
+ const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
233
+ return out.toString();
234
+ }
235
+ } : {
236
+ decode(buf) {
237
+ let out = "";
238
+ for (let i = 0; i < buf.length; i++) {
239
+ out += String.fromCharCode(buf[i]);
240
+ }
241
+ return out;
242
+ }
243
+ };
244
+ var StringWriter = class {
245
+ constructor() {
246
+ this.pos = 0;
247
+ this.out = "";
248
+ this.buffer = new Uint8Array(bufLength);
249
+ }
250
+ write(v) {
251
+ const { buffer } = this;
252
+ buffer[this.pos++] = v;
253
+ if (this.pos === bufLength) {
254
+ this.out += td.decode(buffer);
255
+ this.pos = 0;
256
+ }
257
+ }
258
+ flush() {
259
+ const { buffer, out, pos } = this;
260
+ return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
261
+ }
262
+ };
263
+ function encode(decoded) {
264
+ const writer = new StringWriter();
265
+ let sourcesIndex = 0;
266
+ let sourceLine = 0;
267
+ let sourceColumn = 0;
268
+ let namesIndex = 0;
269
+ for (let i = 0; i < decoded.length; i++) {
270
+ const line = decoded[i];
271
+ if (i > 0) writer.write(semicolon);
272
+ if (line.length === 0) continue;
273
+ let genColumn = 0;
274
+ for (let j = 0; j < line.length; j++) {
275
+ const segment = line[j];
276
+ if (j > 0) writer.write(comma);
277
+ genColumn = encodeInteger(writer, segment[0], genColumn);
278
+ if (segment.length === 1) continue;
279
+ sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
280
+ sourceLine = encodeInteger(writer, segment[2], sourceLine);
281
+ sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
282
+ if (segment.length === 4) continue;
283
+ namesIndex = encodeInteger(writer, segment[4], namesIndex);
284
+ }
285
+ }
286
+ return writer.flush();
287
+ }
288
+
289
+ // node_modules/.pnpm/magic-string@0.30.17/node_modules/magic-string/dist/magic-string.es.mjs
290
+ var BitSet = class _BitSet {
291
+ constructor(arg) {
292
+ this.bits = arg instanceof _BitSet ? arg.bits.slice() : [];
293
+ }
294
+ add(n2) {
295
+ this.bits[n2 >> 5] |= 1 << (n2 & 31);
296
+ }
297
+ has(n2) {
298
+ return !!(this.bits[n2 >> 5] & 1 << (n2 & 31));
299
+ }
300
+ };
301
+ var Chunk = class _Chunk {
302
+ constructor(start, end, content) {
303
+ this.start = start;
304
+ this.end = end;
305
+ this.original = content;
306
+ this.intro = "";
307
+ this.outro = "";
308
+ this.content = content;
309
+ this.storeName = false;
310
+ this.edited = false;
311
+ {
312
+ this.previous = null;
313
+ this.next = null;
314
+ }
315
+ }
316
+ appendLeft(content) {
317
+ this.outro += content;
318
+ }
319
+ appendRight(content) {
320
+ this.intro = this.intro + content;
321
+ }
322
+ clone() {
323
+ const chunk = new _Chunk(this.start, this.end, this.original);
324
+ chunk.intro = this.intro;
325
+ chunk.outro = this.outro;
326
+ chunk.content = this.content;
327
+ chunk.storeName = this.storeName;
328
+ chunk.edited = this.edited;
329
+ return chunk;
330
+ }
331
+ contains(index) {
332
+ return this.start < index && index < this.end;
333
+ }
334
+ eachNext(fn) {
335
+ let chunk = this;
336
+ while (chunk) {
337
+ fn(chunk);
338
+ chunk = chunk.next;
339
+ }
340
+ }
341
+ eachPrevious(fn) {
342
+ let chunk = this;
343
+ while (chunk) {
344
+ fn(chunk);
345
+ chunk = chunk.previous;
346
+ }
347
+ }
348
+ edit(content, storeName, contentOnly) {
349
+ this.content = content;
350
+ if (!contentOnly) {
351
+ this.intro = "";
352
+ this.outro = "";
353
+ }
354
+ this.storeName = storeName;
355
+ this.edited = true;
356
+ return this;
357
+ }
358
+ prependLeft(content) {
359
+ this.outro = content + this.outro;
360
+ }
361
+ prependRight(content) {
362
+ this.intro = content + this.intro;
363
+ }
364
+ reset() {
365
+ this.intro = "";
366
+ this.outro = "";
367
+ if (this.edited) {
368
+ this.content = this.original;
369
+ this.storeName = false;
370
+ this.edited = false;
371
+ }
372
+ }
373
+ split(index) {
374
+ const sliceIndex = index - this.start;
375
+ const originalBefore = this.original.slice(0, sliceIndex);
376
+ const originalAfter = this.original.slice(sliceIndex);
377
+ this.original = originalBefore;
378
+ const newChunk = new _Chunk(index, this.end, originalAfter);
379
+ newChunk.outro = this.outro;
380
+ this.outro = "";
381
+ this.end = index;
382
+ if (this.edited) {
383
+ newChunk.edit("", false);
384
+ this.content = "";
385
+ } else {
386
+ this.content = originalBefore;
387
+ }
388
+ newChunk.next = this.next;
389
+ if (newChunk.next) newChunk.next.previous = newChunk;
390
+ newChunk.previous = this;
391
+ this.next = newChunk;
392
+ return newChunk;
393
+ }
394
+ toString() {
395
+ return this.intro + this.content + this.outro;
396
+ }
397
+ trimEnd(rx) {
398
+ this.outro = this.outro.replace(rx, "");
399
+ if (this.outro.length) return true;
400
+ const trimmed = this.content.replace(rx, "");
401
+ if (trimmed.length) {
402
+ if (trimmed !== this.content) {
403
+ this.split(this.start + trimmed.length).edit("", void 0, true);
404
+ if (this.edited) {
405
+ this.edit(trimmed, this.storeName, true);
406
+ }
407
+ }
408
+ return true;
409
+ } else {
410
+ this.edit("", void 0, true);
411
+ this.intro = this.intro.replace(rx, "");
412
+ if (this.intro.length) return true;
413
+ }
414
+ }
415
+ trimStart(rx) {
416
+ this.intro = this.intro.replace(rx, "");
417
+ if (this.intro.length) return true;
418
+ const trimmed = this.content.replace(rx, "");
419
+ if (trimmed.length) {
420
+ if (trimmed !== this.content) {
421
+ const newChunk = this.split(this.end - trimmed.length);
422
+ if (this.edited) {
423
+ newChunk.edit(trimmed, this.storeName, true);
424
+ }
425
+ this.edit("", void 0, true);
426
+ }
427
+ return true;
428
+ } else {
429
+ this.edit("", void 0, true);
430
+ this.outro = this.outro.replace(rx, "");
431
+ if (this.outro.length) return true;
432
+ }
433
+ }
434
+ };
435
+ function getBtoa() {
436
+ if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") {
437
+ return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
438
+ } else if (typeof Buffer === "function") {
439
+ return (str) => Buffer.from(str, "utf-8").toString("base64");
440
+ } else {
441
+ return () => {
442
+ throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
443
+ };
444
+ }
445
+ }
446
+ var btoa = /* @__PURE__ */ getBtoa();
447
+ var SourceMap = class {
448
+ constructor(properties) {
449
+ this.version = 3;
450
+ this.file = properties.file;
451
+ this.sources = properties.sources;
452
+ this.sourcesContent = properties.sourcesContent;
453
+ this.names = properties.names;
454
+ this.mappings = encode(properties.mappings);
455
+ if (typeof properties.x_google_ignoreList !== "undefined") {
456
+ this.x_google_ignoreList = properties.x_google_ignoreList;
457
+ }
458
+ if (typeof properties.debugId !== "undefined") {
459
+ this.debugId = properties.debugId;
460
+ }
461
+ }
462
+ toString() {
463
+ return JSON.stringify(this);
464
+ }
465
+ toUrl() {
466
+ return "data:application/json;charset=utf-8;base64," + btoa(this.toString());
467
+ }
468
+ };
469
+ function guessIndent(code) {
470
+ const lines = code.split("\n");
471
+ const tabbed = lines.filter((line) => /^\t+/.test(line));
472
+ const spaced = lines.filter((line) => /^ {2,}/.test(line));
473
+ if (tabbed.length === 0 && spaced.length === 0) {
474
+ return null;
475
+ }
476
+ if (tabbed.length >= spaced.length) {
477
+ return " ";
478
+ }
479
+ const min = spaced.reduce((previous, current) => {
480
+ const numSpaces = /^ +/.exec(current)[0].length;
481
+ return Math.min(numSpaces, previous);
482
+ }, Infinity);
483
+ return new Array(min + 1).join(" ");
484
+ }
485
+ function getRelativePath(from, to) {
486
+ const fromParts = from.split(/[/\\]/);
487
+ const toParts = to.split(/[/\\]/);
488
+ fromParts.pop();
489
+ while (fromParts[0] === toParts[0]) {
490
+ fromParts.shift();
491
+ toParts.shift();
492
+ }
493
+ if (fromParts.length) {
494
+ let i = fromParts.length;
495
+ while (i--) fromParts[i] = "..";
496
+ }
497
+ return fromParts.concat(toParts).join("/");
498
+ }
499
+ var toString = Object.prototype.toString;
500
+ function isObject(thing) {
501
+ return toString.call(thing) === "[object Object]";
502
+ }
503
+ function getLocator(source) {
504
+ const originalLines = source.split("\n");
505
+ const lineOffsets = [];
506
+ for (let i = 0, pos = 0; i < originalLines.length; i++) {
507
+ lineOffsets.push(pos);
508
+ pos += originalLines[i].length + 1;
509
+ }
510
+ return function locate(index) {
511
+ let i = 0;
512
+ let j = lineOffsets.length;
513
+ while (i < j) {
514
+ const m = i + j >> 1;
515
+ if (index < lineOffsets[m]) {
516
+ j = m;
517
+ } else {
518
+ i = m + 1;
519
+ }
520
+ }
521
+ const line = i - 1;
522
+ const column = index - lineOffsets[line];
523
+ return { line, column };
524
+ };
525
+ }
526
+ var wordRegex = /\w/;
527
+ var Mappings = class {
528
+ constructor(hires) {
529
+ this.hires = hires;
530
+ this.generatedCodeLine = 0;
531
+ this.generatedCodeColumn = 0;
532
+ this.raw = [];
533
+ this.rawSegments = this.raw[this.generatedCodeLine] = [];
534
+ this.pending = null;
535
+ }
536
+ addEdit(sourceIndex, content, loc, nameIndex) {
537
+ if (content.length) {
538
+ const contentLengthMinusOne = content.length - 1;
539
+ let contentLineEnd = content.indexOf("\n", 0);
540
+ let previousContentLineEnd = -1;
541
+ while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
542
+ const segment2 = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
543
+ if (nameIndex >= 0) {
544
+ segment2.push(nameIndex);
545
+ }
546
+ this.rawSegments.push(segment2);
547
+ this.generatedCodeLine += 1;
548
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
549
+ this.generatedCodeColumn = 0;
550
+ previousContentLineEnd = contentLineEnd;
551
+ contentLineEnd = content.indexOf("\n", contentLineEnd + 1);
552
+ }
553
+ const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
554
+ if (nameIndex >= 0) {
555
+ segment.push(nameIndex);
556
+ }
557
+ this.rawSegments.push(segment);
558
+ this.advance(content.slice(previousContentLineEnd + 1));
559
+ } else if (this.pending) {
560
+ this.rawSegments.push(this.pending);
561
+ this.advance(content);
562
+ }
563
+ this.pending = null;
564
+ }
565
+ addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
566
+ let originalCharIndex = chunk.start;
567
+ let first = true;
568
+ let charInHiresBoundary = false;
569
+ while (originalCharIndex < chunk.end) {
570
+ if (original[originalCharIndex] === "\n") {
571
+ loc.line += 1;
572
+ loc.column = 0;
573
+ this.generatedCodeLine += 1;
574
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
575
+ this.generatedCodeColumn = 0;
576
+ first = true;
577
+ charInHiresBoundary = false;
578
+ } else {
579
+ if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
580
+ const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
581
+ if (this.hires === "boundary") {
582
+ if (wordRegex.test(original[originalCharIndex])) {
583
+ if (!charInHiresBoundary) {
584
+ this.rawSegments.push(segment);
585
+ charInHiresBoundary = true;
586
+ }
587
+ } else {
588
+ this.rawSegments.push(segment);
589
+ charInHiresBoundary = false;
590
+ }
591
+ } else {
592
+ this.rawSegments.push(segment);
593
+ }
594
+ }
595
+ loc.column += 1;
596
+ this.generatedCodeColumn += 1;
597
+ first = false;
598
+ }
599
+ originalCharIndex += 1;
600
+ }
601
+ this.pending = null;
602
+ }
603
+ advance(str) {
604
+ if (!str) return;
605
+ const lines = str.split("\n");
606
+ if (lines.length > 1) {
607
+ for (let i = 0; i < lines.length - 1; i++) {
608
+ this.generatedCodeLine++;
609
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
610
+ }
611
+ this.generatedCodeColumn = 0;
612
+ }
613
+ this.generatedCodeColumn += lines[lines.length - 1].length;
614
+ }
615
+ };
616
+ var n = "\n";
617
+ var warned = {
618
+ insertLeft: false,
619
+ insertRight: false,
620
+ storeName: false
621
+ };
622
+ var MagicString = class _MagicString {
623
+ constructor(string, options = {}) {
624
+ const chunk = new Chunk(0, string.length, string);
625
+ Object.defineProperties(this, {
626
+ original: { writable: true, value: string },
627
+ outro: { writable: true, value: "" },
628
+ intro: { writable: true, value: "" },
629
+ firstChunk: { writable: true, value: chunk },
630
+ lastChunk: { writable: true, value: chunk },
631
+ lastSearchedChunk: { writable: true, value: chunk },
632
+ byStart: { writable: true, value: {} },
633
+ byEnd: { writable: true, value: {} },
634
+ filename: { writable: true, value: options.filename },
635
+ indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
636
+ sourcemapLocations: { writable: true, value: new BitSet() },
637
+ storedNames: { writable: true, value: {} },
638
+ indentStr: { writable: true, value: void 0 },
639
+ ignoreList: { writable: true, value: options.ignoreList },
640
+ offset: { writable: true, value: options.offset || 0 }
641
+ });
642
+ this.byStart[0] = chunk;
643
+ this.byEnd[string.length] = chunk;
644
+ }
645
+ addSourcemapLocation(char) {
646
+ this.sourcemapLocations.add(char);
647
+ }
648
+ append(content) {
649
+ if (typeof content !== "string") throw new TypeError("outro content must be a string");
650
+ this.outro += content;
651
+ return this;
652
+ }
653
+ appendLeft(index, content) {
654
+ index = index + this.offset;
655
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
656
+ this._split(index);
657
+ const chunk = this.byEnd[index];
658
+ if (chunk) {
659
+ chunk.appendLeft(content);
660
+ } else {
661
+ this.intro += content;
662
+ }
663
+ return this;
664
+ }
665
+ appendRight(index, content) {
666
+ index = index + this.offset;
667
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
668
+ this._split(index);
669
+ const chunk = this.byStart[index];
670
+ if (chunk) {
671
+ chunk.appendRight(content);
672
+ } else {
673
+ this.outro += content;
674
+ }
675
+ return this;
676
+ }
677
+ clone() {
678
+ const cloned = new _MagicString(this.original, { filename: this.filename, offset: this.offset });
679
+ let originalChunk = this.firstChunk;
680
+ let clonedChunk = cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone();
681
+ while (originalChunk) {
682
+ cloned.byStart[clonedChunk.start] = clonedChunk;
683
+ cloned.byEnd[clonedChunk.end] = clonedChunk;
684
+ const nextOriginalChunk = originalChunk.next;
685
+ const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
686
+ if (nextClonedChunk) {
687
+ clonedChunk.next = nextClonedChunk;
688
+ nextClonedChunk.previous = clonedChunk;
689
+ clonedChunk = nextClonedChunk;
690
+ }
691
+ originalChunk = nextOriginalChunk;
692
+ }
693
+ cloned.lastChunk = clonedChunk;
694
+ if (this.indentExclusionRanges) {
695
+ cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
696
+ }
697
+ cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
698
+ cloned.intro = this.intro;
699
+ cloned.outro = this.outro;
700
+ return cloned;
701
+ }
702
+ generateDecodedMap(options) {
703
+ options = options || {};
704
+ const sourceIndex = 0;
705
+ const names = Object.keys(this.storedNames);
706
+ const mappings = new Mappings(options.hires);
707
+ const locate = getLocator(this.original);
708
+ if (this.intro) {
709
+ mappings.advance(this.intro);
710
+ }
711
+ this.firstChunk.eachNext((chunk) => {
712
+ const loc = locate(chunk.start);
713
+ if (chunk.intro.length) mappings.advance(chunk.intro);
714
+ if (chunk.edited) {
715
+ mappings.addEdit(
716
+ sourceIndex,
717
+ chunk.content,
718
+ loc,
719
+ chunk.storeName ? names.indexOf(chunk.original) : -1
720
+ );
721
+ } else {
722
+ mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
723
+ }
724
+ if (chunk.outro.length) mappings.advance(chunk.outro);
725
+ });
726
+ return {
727
+ file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
728
+ sources: [
729
+ options.source ? getRelativePath(options.file || "", options.source) : options.file || ""
730
+ ],
731
+ sourcesContent: options.includeContent ? [this.original] : void 0,
732
+ names,
733
+ mappings: mappings.raw,
734
+ x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0
735
+ };
736
+ }
737
+ generateMap(options) {
738
+ return new SourceMap(this.generateDecodedMap(options));
739
+ }
740
+ _ensureindentStr() {
741
+ if (this.indentStr === void 0) {
742
+ this.indentStr = guessIndent(this.original);
743
+ }
744
+ }
745
+ _getRawIndentString() {
746
+ this._ensureindentStr();
747
+ return this.indentStr;
748
+ }
749
+ getIndentString() {
750
+ this._ensureindentStr();
751
+ return this.indentStr === null ? " " : this.indentStr;
752
+ }
753
+ indent(indentStr, options) {
754
+ const pattern = /^[^\r\n]/gm;
755
+ if (isObject(indentStr)) {
756
+ options = indentStr;
757
+ indentStr = void 0;
758
+ }
759
+ if (indentStr === void 0) {
760
+ this._ensureindentStr();
761
+ indentStr = this.indentStr || " ";
762
+ }
763
+ if (indentStr === "") return this;
764
+ options = options || {};
765
+ const isExcluded = {};
766
+ if (options.exclude) {
767
+ const exclusions = typeof options.exclude[0] === "number" ? [options.exclude] : options.exclude;
768
+ exclusions.forEach((exclusion) => {
769
+ for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
770
+ isExcluded[i] = true;
771
+ }
772
+ });
773
+ }
774
+ let shouldIndentNextCharacter = options.indentStart !== false;
775
+ const replacer = (match) => {
776
+ if (shouldIndentNextCharacter) return `${indentStr}${match}`;
777
+ shouldIndentNextCharacter = true;
778
+ return match;
779
+ };
780
+ this.intro = this.intro.replace(pattern, replacer);
781
+ let charIndex = 0;
782
+ let chunk = this.firstChunk;
783
+ while (chunk) {
784
+ const end = chunk.end;
785
+ if (chunk.edited) {
786
+ if (!isExcluded[charIndex]) {
787
+ chunk.content = chunk.content.replace(pattern, replacer);
788
+ if (chunk.content.length) {
789
+ shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === "\n";
790
+ }
791
+ }
792
+ } else {
793
+ charIndex = chunk.start;
794
+ while (charIndex < end) {
795
+ if (!isExcluded[charIndex]) {
796
+ const char = this.original[charIndex];
797
+ if (char === "\n") {
798
+ shouldIndentNextCharacter = true;
799
+ } else if (char !== "\r" && shouldIndentNextCharacter) {
800
+ shouldIndentNextCharacter = false;
801
+ if (charIndex === chunk.start) {
802
+ chunk.prependRight(indentStr);
803
+ } else {
804
+ this._splitChunk(chunk, charIndex);
805
+ chunk = chunk.next;
806
+ chunk.prependRight(indentStr);
807
+ }
808
+ }
809
+ }
810
+ charIndex += 1;
811
+ }
812
+ }
813
+ charIndex = chunk.end;
814
+ chunk = chunk.next;
815
+ }
816
+ this.outro = this.outro.replace(pattern, replacer);
817
+ return this;
818
+ }
819
+ insert() {
820
+ throw new Error(
821
+ "magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)"
822
+ );
823
+ }
824
+ insertLeft(index, content) {
825
+ if (!warned.insertLeft) {
826
+ console.warn(
827
+ "magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"
828
+ );
829
+ warned.insertLeft = true;
830
+ }
831
+ return this.appendLeft(index, content);
832
+ }
833
+ insertRight(index, content) {
834
+ if (!warned.insertRight) {
835
+ console.warn(
836
+ "magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"
837
+ );
838
+ warned.insertRight = true;
839
+ }
840
+ return this.prependRight(index, content);
841
+ }
842
+ move(start, end, index) {
843
+ start = start + this.offset;
844
+ end = end + this.offset;
845
+ index = index + this.offset;
846
+ if (index >= start && index <= end) throw new Error("Cannot move a selection inside itself");
847
+ this._split(start);
848
+ this._split(end);
849
+ this._split(index);
850
+ const first = this.byStart[start];
851
+ const last = this.byEnd[end];
852
+ const oldLeft = first.previous;
853
+ const oldRight = last.next;
854
+ const newRight = this.byStart[index];
855
+ if (!newRight && last === this.lastChunk) return this;
856
+ const newLeft = newRight ? newRight.previous : this.lastChunk;
857
+ if (oldLeft) oldLeft.next = oldRight;
858
+ if (oldRight) oldRight.previous = oldLeft;
859
+ if (newLeft) newLeft.next = first;
860
+ if (newRight) newRight.previous = last;
861
+ if (!first.previous) this.firstChunk = last.next;
862
+ if (!last.next) {
863
+ this.lastChunk = first.previous;
864
+ this.lastChunk.next = null;
865
+ }
866
+ first.previous = newLeft;
867
+ last.next = newRight || null;
868
+ if (!newLeft) this.firstChunk = first;
869
+ if (!newRight) this.lastChunk = last;
870
+ return this;
871
+ }
872
+ overwrite(start, end, content, options) {
873
+ options = options || {};
874
+ return this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
875
+ }
876
+ update(start, end, content, options) {
877
+ start = start + this.offset;
878
+ end = end + this.offset;
879
+ if (typeof content !== "string") throw new TypeError("replacement content must be a string");
880
+ if (this.original.length !== 0) {
881
+ while (start < 0) start += this.original.length;
882
+ while (end < 0) end += this.original.length;
883
+ }
884
+ if (end > this.original.length) throw new Error("end is out of bounds");
885
+ if (start === end)
886
+ throw new Error(
887
+ "Cannot overwrite a zero-length range \u2013 use appendLeft or prependRight instead"
888
+ );
889
+ this._split(start);
890
+ this._split(end);
891
+ if (options === true) {
892
+ if (!warned.storeName) {
893
+ console.warn(
894
+ "The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"
895
+ );
896
+ warned.storeName = true;
897
+ }
898
+ options = { storeName: true };
899
+ }
900
+ const storeName = options !== void 0 ? options.storeName : false;
901
+ const overwrite = options !== void 0 ? options.overwrite : false;
902
+ if (storeName) {
903
+ const original = this.original.slice(start, end);
904
+ Object.defineProperty(this.storedNames, original, {
905
+ writable: true,
906
+ value: true,
907
+ enumerable: true
908
+ });
909
+ }
910
+ const first = this.byStart[start];
911
+ const last = this.byEnd[end];
912
+ if (first) {
913
+ let chunk = first;
914
+ while (chunk !== last) {
915
+ if (chunk.next !== this.byStart[chunk.end]) {
916
+ throw new Error("Cannot overwrite across a split point");
917
+ }
918
+ chunk = chunk.next;
919
+ chunk.edit("", false);
920
+ }
921
+ first.edit(content, storeName, !overwrite);
922
+ } else {
923
+ const newChunk = new Chunk(start, end, "").edit(content, storeName);
924
+ last.next = newChunk;
925
+ newChunk.previous = last;
926
+ }
927
+ return this;
928
+ }
929
+ prepend(content) {
930
+ if (typeof content !== "string") throw new TypeError("outro content must be a string");
931
+ this.intro = content + this.intro;
932
+ return this;
933
+ }
934
+ prependLeft(index, content) {
935
+ index = index + this.offset;
936
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
937
+ this._split(index);
938
+ const chunk = this.byEnd[index];
939
+ if (chunk) {
940
+ chunk.prependLeft(content);
941
+ } else {
942
+ this.intro = content + this.intro;
943
+ }
944
+ return this;
945
+ }
946
+ prependRight(index, content) {
947
+ index = index + this.offset;
948
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
949
+ this._split(index);
950
+ const chunk = this.byStart[index];
951
+ if (chunk) {
952
+ chunk.prependRight(content);
953
+ } else {
954
+ this.outro = content + this.outro;
955
+ }
956
+ return this;
957
+ }
958
+ remove(start, end) {
959
+ start = start + this.offset;
960
+ end = end + this.offset;
961
+ if (this.original.length !== 0) {
962
+ while (start < 0) start += this.original.length;
963
+ while (end < 0) end += this.original.length;
964
+ }
965
+ if (start === end) return this;
966
+ if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
967
+ if (start > end) throw new Error("end must be greater than start");
968
+ this._split(start);
969
+ this._split(end);
970
+ let chunk = this.byStart[start];
971
+ while (chunk) {
972
+ chunk.intro = "";
973
+ chunk.outro = "";
974
+ chunk.edit("");
975
+ chunk = end > chunk.end ? this.byStart[chunk.end] : null;
976
+ }
977
+ return this;
978
+ }
979
+ reset(start, end) {
980
+ start = start + this.offset;
981
+ end = end + this.offset;
982
+ if (this.original.length !== 0) {
983
+ while (start < 0) start += this.original.length;
984
+ while (end < 0) end += this.original.length;
985
+ }
986
+ if (start === end) return this;
987
+ if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
988
+ if (start > end) throw new Error("end must be greater than start");
989
+ this._split(start);
990
+ this._split(end);
991
+ let chunk = this.byStart[start];
992
+ while (chunk) {
993
+ chunk.reset();
994
+ chunk = end > chunk.end ? this.byStart[chunk.end] : null;
995
+ }
996
+ return this;
997
+ }
998
+ lastChar() {
999
+ if (this.outro.length) return this.outro[this.outro.length - 1];
1000
+ let chunk = this.lastChunk;
1001
+ do {
1002
+ if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
1003
+ if (chunk.content.length) return chunk.content[chunk.content.length - 1];
1004
+ if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
1005
+ } while (chunk = chunk.previous);
1006
+ if (this.intro.length) return this.intro[this.intro.length - 1];
1007
+ return "";
1008
+ }
1009
+ lastLine() {
1010
+ let lineIndex = this.outro.lastIndexOf(n);
1011
+ if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
1012
+ let lineStr = this.outro;
1013
+ let chunk = this.lastChunk;
1014
+ do {
1015
+ if (chunk.outro.length > 0) {
1016
+ lineIndex = chunk.outro.lastIndexOf(n);
1017
+ if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
1018
+ lineStr = chunk.outro + lineStr;
1019
+ }
1020
+ if (chunk.content.length > 0) {
1021
+ lineIndex = chunk.content.lastIndexOf(n);
1022
+ if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
1023
+ lineStr = chunk.content + lineStr;
1024
+ }
1025
+ if (chunk.intro.length > 0) {
1026
+ lineIndex = chunk.intro.lastIndexOf(n);
1027
+ if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
1028
+ lineStr = chunk.intro + lineStr;
1029
+ }
1030
+ } while (chunk = chunk.previous);
1031
+ lineIndex = this.intro.lastIndexOf(n);
1032
+ if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
1033
+ return this.intro + lineStr;
1034
+ }
1035
+ slice(start = 0, end = this.original.length - this.offset) {
1036
+ start = start + this.offset;
1037
+ end = end + this.offset;
1038
+ if (this.original.length !== 0) {
1039
+ while (start < 0) start += this.original.length;
1040
+ while (end < 0) end += this.original.length;
1041
+ }
1042
+ let result = "";
1043
+ let chunk = this.firstChunk;
1044
+ while (chunk && (chunk.start > start || chunk.end <= start)) {
1045
+ if (chunk.start < end && chunk.end >= end) {
1046
+ return result;
1047
+ }
1048
+ chunk = chunk.next;
1049
+ }
1050
+ if (chunk && chunk.edited && chunk.start !== start)
1051
+ throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
1052
+ const startChunk = chunk;
1053
+ while (chunk) {
1054
+ if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
1055
+ result += chunk.intro;
1056
+ }
1057
+ const containsEnd = chunk.start < end && chunk.end >= end;
1058
+ if (containsEnd && chunk.edited && chunk.end !== end)
1059
+ throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
1060
+ const sliceStart = startChunk === chunk ? start - chunk.start : 0;
1061
+ const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
1062
+ result += chunk.content.slice(sliceStart, sliceEnd);
1063
+ if (chunk.outro && (!containsEnd || chunk.end === end)) {
1064
+ result += chunk.outro;
1065
+ }
1066
+ if (containsEnd) {
1067
+ break;
1068
+ }
1069
+ chunk = chunk.next;
1070
+ }
1071
+ return result;
1072
+ }
1073
+ // TODO deprecate this? not really very useful
1074
+ snip(start, end) {
1075
+ const clone = this.clone();
1076
+ clone.remove(0, start);
1077
+ clone.remove(end, clone.original.length);
1078
+ return clone;
1079
+ }
1080
+ _split(index) {
1081
+ if (this.byStart[index] || this.byEnd[index]) return;
1082
+ let chunk = this.lastSearchedChunk;
1083
+ const searchForward = index > chunk.end;
1084
+ while (chunk) {
1085
+ if (chunk.contains(index)) return this._splitChunk(chunk, index);
1086
+ chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
1087
+ }
1088
+ }
1089
+ _splitChunk(chunk, index) {
1090
+ if (chunk.edited && chunk.content.length) {
1091
+ const loc = getLocator(this.original)(index);
1092
+ throw new Error(
1093
+ `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} \u2013 "${chunk.original}")`
1094
+ );
1095
+ }
1096
+ const newChunk = chunk.split(index);
1097
+ this.byEnd[index] = chunk;
1098
+ this.byStart[index] = newChunk;
1099
+ this.byEnd[newChunk.end] = newChunk;
1100
+ if (chunk === this.lastChunk) this.lastChunk = newChunk;
1101
+ this.lastSearchedChunk = chunk;
1102
+ return true;
1103
+ }
1104
+ toString() {
1105
+ let str = this.intro;
1106
+ let chunk = this.firstChunk;
1107
+ while (chunk) {
1108
+ str += chunk.toString();
1109
+ chunk = chunk.next;
1110
+ }
1111
+ return str + this.outro;
1112
+ }
1113
+ isEmpty() {
1114
+ let chunk = this.firstChunk;
1115
+ do {
1116
+ if (chunk.intro.length && chunk.intro.trim() || chunk.content.length && chunk.content.trim() || chunk.outro.length && chunk.outro.trim())
1117
+ return false;
1118
+ } while (chunk = chunk.next);
1119
+ return true;
1120
+ }
1121
+ length() {
1122
+ let chunk = this.firstChunk;
1123
+ let length = 0;
1124
+ do {
1125
+ length += chunk.intro.length + chunk.content.length + chunk.outro.length;
1126
+ } while (chunk = chunk.next);
1127
+ return length;
1128
+ }
1129
+ trimLines() {
1130
+ return this.trim("[\\r\\n]");
1131
+ }
1132
+ trim(charType) {
1133
+ return this.trimStart(charType).trimEnd(charType);
1134
+ }
1135
+ trimEndAborted(charType) {
1136
+ const rx = new RegExp((charType || "\\s") + "+$");
1137
+ this.outro = this.outro.replace(rx, "");
1138
+ if (this.outro.length) return true;
1139
+ let chunk = this.lastChunk;
1140
+ do {
1141
+ const end = chunk.end;
1142
+ const aborted = chunk.trimEnd(rx);
1143
+ if (chunk.end !== end) {
1144
+ if (this.lastChunk === chunk) {
1145
+ this.lastChunk = chunk.next;
1146
+ }
1147
+ this.byEnd[chunk.end] = chunk;
1148
+ this.byStart[chunk.next.start] = chunk.next;
1149
+ this.byEnd[chunk.next.end] = chunk.next;
1150
+ }
1151
+ if (aborted) return true;
1152
+ chunk = chunk.previous;
1153
+ } while (chunk);
1154
+ return false;
1155
+ }
1156
+ trimEnd(charType) {
1157
+ this.trimEndAborted(charType);
1158
+ return this;
1159
+ }
1160
+ trimStartAborted(charType) {
1161
+ const rx = new RegExp("^" + (charType || "\\s") + "+");
1162
+ this.intro = this.intro.replace(rx, "");
1163
+ if (this.intro.length) return true;
1164
+ let chunk = this.firstChunk;
1165
+ do {
1166
+ const end = chunk.end;
1167
+ const aborted = chunk.trimStart(rx);
1168
+ if (chunk.end !== end) {
1169
+ if (chunk === this.lastChunk) this.lastChunk = chunk.next;
1170
+ this.byEnd[chunk.end] = chunk;
1171
+ this.byStart[chunk.next.start] = chunk.next;
1172
+ this.byEnd[chunk.next.end] = chunk.next;
1173
+ }
1174
+ if (aborted) return true;
1175
+ chunk = chunk.next;
1176
+ } while (chunk);
1177
+ return false;
1178
+ }
1179
+ trimStart(charType) {
1180
+ this.trimStartAborted(charType);
1181
+ return this;
1182
+ }
1183
+ hasChanged() {
1184
+ return this.original !== this.toString();
1185
+ }
1186
+ _replaceRegexp(searchValue, replacement) {
1187
+ function getReplacement(match, str) {
1188
+ if (typeof replacement === "string") {
1189
+ return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
1190
+ if (i === "$") return "$";
1191
+ if (i === "&") return match[0];
1192
+ const num = +i;
1193
+ if (num < match.length) return match[+i];
1194
+ return `$${i}`;
1195
+ });
1196
+ } else {
1197
+ return replacement(...match, match.index, str, match.groups);
1198
+ }
1199
+ }
1200
+ function matchAll(re, str) {
1201
+ let match;
1202
+ const matches2 = [];
1203
+ while (match = re.exec(str)) {
1204
+ matches2.push(match);
1205
+ }
1206
+ return matches2;
1207
+ }
1208
+ if (searchValue.global) {
1209
+ const matches2 = matchAll(searchValue, this.original);
1210
+ matches2.forEach((match) => {
1211
+ if (match.index != null) {
1212
+ const replacement2 = getReplacement(match, this.original);
1213
+ if (replacement2 !== match[0]) {
1214
+ this.overwrite(match.index, match.index + match[0].length, replacement2);
1215
+ }
1216
+ }
1217
+ });
1218
+ } else {
1219
+ const match = this.original.match(searchValue);
1220
+ if (match && match.index != null) {
1221
+ const replacement2 = getReplacement(match, this.original);
1222
+ if (replacement2 !== match[0]) {
1223
+ this.overwrite(match.index, match.index + match[0].length, replacement2);
1224
+ }
1225
+ }
1226
+ }
1227
+ return this;
1228
+ }
1229
+ _replaceString(string, replacement) {
1230
+ const { original } = this;
1231
+ const index = original.indexOf(string);
1232
+ if (index !== -1) {
1233
+ this.overwrite(index, index + string.length, replacement);
1234
+ }
1235
+ return this;
1236
+ }
1237
+ replace(searchValue, replacement) {
1238
+ if (typeof searchValue === "string") {
1239
+ return this._replaceString(searchValue, replacement);
1240
+ }
1241
+ return this._replaceRegexp(searchValue, replacement);
1242
+ }
1243
+ _replaceAllString(string, replacement) {
1244
+ const { original } = this;
1245
+ const stringLength = string.length;
1246
+ for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
1247
+ const previous = original.slice(index, index + stringLength);
1248
+ if (previous !== replacement) this.overwrite(index, index + stringLength, replacement);
1249
+ }
1250
+ return this;
1251
+ }
1252
+ replaceAll(searchValue, replacement) {
1253
+ if (typeof searchValue === "string") {
1254
+ return this._replaceAllString(searchValue, replacement);
1255
+ }
1256
+ if (!searchValue.global) {
1257
+ throw new TypeError(
1258
+ "MagicString.prototype.replaceAll called with a non-global RegExp argument"
1259
+ );
1260
+ }
1261
+ return this._replaceRegexp(searchValue, replacement);
1262
+ }
1263
+ };
1264
+
1265
+ // src/federation/src/prod/remote-production.ts
1266
+ var import_node_path = __toESM(require("path"));
1267
+
1268
+ // src/federation/src/public.ts
1269
+ var EXPOSES_MAP = /* @__PURE__ */ new Map();
1270
+ var EXPOSES_KEY_MAP = /* @__PURE__ */ new Map();
1271
+ var SHARED = "shared";
1272
+ var DYNAMIC_LOADING_CSS = "dynamicLoadingCss";
1273
+ var DYNAMIC_LOADING_CSS_PREFIX = "__v__css__";
1274
+ var DEFAULT_ENTRY_FILENAME = "remoteEntry.js";
1275
+ var EXTERNALS = [];
1276
+ var builderInfo = {
41
1277
  builder: "rollup",
1278
+ version: "",
42
1279
  assetsDir: "",
43
1280
  isHost: false,
44
1281
  isRemote: false,
45
1282
  isShared: false
46
1283
  };
47
- const parsedOptions = {
1284
+ var parsedOptions = {
48
1285
  prodExpose: [],
49
1286
  prodRemote: [],
50
1287
  prodShared: [],
@@ -52,12 +1289,17 @@ const parsedOptions = {
52
1289
  devExpose: [],
53
1290
  devRemote: []
54
1291
  };
55
- const devRemotes = [];
56
- const prodRemotes = [];
57
- const viteConfigResolved = {
1292
+ var devRemotes = [];
1293
+ var prodRemotes = [];
1294
+ var viteConfigResolved = {
58
1295
  config: void 0
59
1296
  };
60
- const unaryTags = /* @__PURE__ */ new Set(["link", "meta", "base"]);
1297
+
1298
+ // src/federation/src/utils/index.ts
1299
+ var import_path = __toESM(require("path"));
1300
+
1301
+ // src/federation/src/utils/html.ts
1302
+ var unaryTags = /* @__PURE__ */ new Set(["link", "meta", "base"]);
61
1303
  function serializeTag({ tag, attrs, children }, indent = "") {
62
1304
  if (unaryTags.has(tag)) {
63
1305
  return `<${tag}${serializeAttrs(attrs)}>`;
@@ -91,7 +1333,7 @@ function serializeAttrs(attrs) {
91
1333
  function incrementIndent(indent = "") {
92
1334
  return `${indent}${indent[0] === " " ? " " : " "}`;
93
1335
  }
94
- const matchHtmlRegExp = /["'&<>]/;
1336
+ var matchHtmlRegExp = /["'&<>]/;
95
1337
  function escapeHtml(string) {
96
1338
  const str = "" + string;
97
1339
  const match = matchHtmlRegExp.exec(str);
@@ -130,12 +1372,12 @@ function escapeHtml(string) {
130
1372
  }
131
1373
  return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
132
1374
  }
133
- const headInjectRE = /([ \t]*)<\/head>/i;
134
- const headPrependInjectRE = /([ \t]*)<head[^>]*>/i;
135
- const htmlPrependInjectRE = /([ \t]*)<html[^>]*>/i;
136
- const bodyPrependInjectRE = /([ \t]*)<body[^>]*>/i;
137
- const doctypePrependInjectRE = /<!doctype html>/i;
138
- const toPreloadTag = (href) => ({
1375
+ var headInjectRE = /([ \t]*)<\/head>/i;
1376
+ var headPrependInjectRE = /([ \t]*)<head[^>]*>/i;
1377
+ var htmlPrependInjectRE = /([ \t]*)<html[^>]*>/i;
1378
+ var bodyPrependInjectRE = /([ \t]*)<body[^>]*>/i;
1379
+ var doctypePrependInjectRE = /<!doctype html>/i;
1380
+ var toPreloadTag = (href) => ({
139
1381
  tag: "link",
140
1382
  attrs: {
141
1383
  rel: "modulepreload",
@@ -181,6 +1423,8 @@ ${serializeTags(tags)}`);
181
1423
  }
182
1424
  return serializeTags(tags) + html;
183
1425
  }
1426
+
1427
+ // src/federation/src/utils/index.ts
184
1428
  function parseSharedOptions(options) {
185
1429
  return parseOptions(
186
1430
  options.shared || {},
@@ -274,7 +1518,7 @@ function parseOptions(options, normalizeSimple, normalizeOptions) {
274
1518
  }
275
1519
  return list;
276
1520
  }
277
- const letterReg = new RegExp("[0-9a-zA-Z]+");
1521
+ var letterReg = new RegExp("[0-9a-zA-Z]+");
278
1522
  function removeNonRegLetter(str, reg = letterReg) {
279
1523
  let needUpperCase = false;
280
1524
  let ret = "";
@@ -292,7 +1536,7 @@ function getModuleMarker(value, type) {
292
1536
  return type ? `__rf_${type}__${value}` : `__rf_placeholder__${value}`;
293
1537
  }
294
1538
  function normalizePath(id) {
295
- return path.posix.normalize(id.replace(/\\/g, "/"));
1539
+ return import_path.posix.normalize(id.replace(/\\/g, "/"));
296
1540
  }
297
1541
  function createRemotesMap(remotes) {
298
1542
  const createUrl = (remote) => {
@@ -314,10 +1558,12 @@ function getFileExtname(url) {
314
1558
  const fileNameAndParamArr = normalizePath(url).split("/");
315
1559
  const fileNameAndParam = fileNameAndParamArr[fileNameAndParamArr.length - 1];
316
1560
  const fileName = fileNameAndParam.split("?")[0];
317
- return path.extname(fileName);
1561
+ return import_path.default.extname(fileName);
318
1562
  }
319
- const REMOTE_FROM_PARAMETER = "remoteFrom";
320
- const NAME_CHAR_REG = new RegExp("[0-9a-zA-Z@_-]+");
1563
+ var REMOTE_FROM_PARAMETER = "remoteFrom";
1564
+ var NAME_CHAR_REG = new RegExp("[0-9a-zA-Z@_-]+");
1565
+
1566
+ // src/federation/src/prod/remote-production.ts
321
1567
  function joinUrlSegments(a, b) {
322
1568
  if (!a || !b) {
323
1569
  return a || b || "";
@@ -332,7 +1578,7 @@ function joinUrlSegments(a, b) {
332
1578
  }
333
1579
  function toOutputFilePathWithoutRuntime(filename, type, hostId, hostType, config, toRelative) {
334
1580
  const { renderBuiltUrl } = config.experimental;
335
- let relative = config.base === "" || config.base === "./";
1581
+ let relative3 = config.base === "" || config.base === "./";
336
1582
  if (renderBuiltUrl) {
337
1583
  const result = renderBuiltUrl(filename, {
338
1584
  hostId,
@@ -347,13 +1593,13 @@ function toOutputFilePathWithoutRuntime(filename, type, hostId, hostType, config
347
1593
  );
348
1594
  }
349
1595
  if (typeof result.relative === "boolean") {
350
- relative = result.relative;
1596
+ relative3 = result.relative;
351
1597
  }
352
1598
  } else if (result) {
353
1599
  return result;
354
1600
  }
355
1601
  }
356
- if (relative && !config.build.ssr) {
1602
+ if (relative3 && !config.build.ssr) {
357
1603
  return toRelative(filename, hostId);
358
1604
  } else {
359
1605
  return joinUrlSegments(config.base, filename);
@@ -578,8 +1824,9 @@ function prodRemotePlugin(options) {
578
1824
  let hasImportShared = false;
579
1825
  let modify = false;
580
1826
  let manualRequired = null;
581
- estreeWalker.walk(ast, {
1827
+ walk(ast, {
582
1828
  enter(node) {
1829
+ var _a, _b, _c, _d, _e;
583
1830
  if (node.type === "ImportDeclaration") {
584
1831
  const moduleName = node.source.value;
585
1832
  if (parsedOptions.prodShared.some(
@@ -587,12 +1834,13 @@ function prodRemotePlugin(options) {
587
1834
  )) {
588
1835
  const namedImportDeclaration = [];
589
1836
  let defaultImportDeclaration = null;
590
- if (!node.specifiers?.length) {
1837
+ if (!((_a = node.specifiers) == null ? void 0 : _a.length)) {
591
1838
  magicString.remove(node.start, node.end);
592
1839
  modify = true;
593
1840
  } else {
594
1841
  node.specifiers.forEach((specify) => {
595
- if (specify.imported?.name) {
1842
+ var _a2;
1843
+ if ((_a2 = specify.imported) == null ? void 0 : _a2.name) {
596
1844
  namedImportDeclaration.push(
597
1845
  `${specify.imported.name === specify.local.name ? specify.imported.name : `${specify.imported.name}:${specify.local.name}`}`
598
1846
  );
@@ -627,13 +1875,13 @@ const {${imports}} = ${defaultImportDeclaration};
627
1875
  }
628
1876
  }
629
1877
  }
630
- if (node.type === "ImportDeclaration" && node.source?.value === "virtual:__federation__") {
1878
+ if (node.type === "ImportDeclaration" && ((_b = node.source) == null ? void 0 : _b.value) === "virtual:__federation__") {
631
1879
  manualRequired = node;
632
1880
  }
633
- if ((node.type === "ImportExpression" || node.type === "ImportDeclaration" || node.type === "ExportNamedDeclaration") && node.source?.value?.indexOf("/") > -1) {
1881
+ if ((node.type === "ImportExpression" || node.type === "ImportDeclaration" || node.type === "ExportNamedDeclaration") && ((_d = (_c = node.source) == null ? void 0 : _c.value) == null ? void 0 : _d.indexOf("/")) > -1) {
634
1882
  const moduleId = node.source.value;
635
1883
  const remote = prodRemotes.find((r) => r.regexp.test(moduleId));
636
- const needWrap = remote?.config.from === "vite";
1884
+ const needWrap = (remote == null ? void 0 : remote.config.from) === "vite";
637
1885
  if (remote) {
638
1886
  requiresRuntime = true;
639
1887
  const modName = `.${moduleId.slice(remote.id.length)}`;
@@ -651,7 +1899,7 @@ const {${imports}} = ${defaultImportDeclaration};
651
1899
  break;
652
1900
  }
653
1901
  case "ImportDeclaration": {
654
- if (node.specifiers?.length) {
1902
+ if ((_e = node.specifiers) == null ? void 0 : _e.length) {
655
1903
  const afterImportName = `__federation_var_${moduleId.replace(
656
1904
  /[@/\\.-]/g,
657
1905
  ""
@@ -815,8 +2063,8 @@ const {${imports}} = ${defaultImportDeclaration};
815
2063
  Object.keys(entryChunk).forEach((fileName) => {
816
2064
  let html = entryChunk[fileName].source;
817
2065
  const htmlPath = entryChunk[fileName].fileName;
818
- const basePath = resolvedConfig.base === "./" || resolvedConfig.base === "" ? path$1.posix.join(
819
- path$1.posix.relative(entryChunk[fileName].fileName, "").slice(0, -2),
2066
+ const basePath = resolvedConfig.base === "./" || resolvedConfig.base === "" ? import_node_path.default.posix.join(
2067
+ import_node_path.default.posix.relative(entryChunk[fileName].fileName, "").slice(0, -2),
820
2068
  "./"
821
2069
  ) : resolvedConfig.base;
822
2070
  const toOutputFilePath = (filename) => toOutputFilePathWithoutRuntime(
@@ -848,8 +2096,16 @@ const {${imports}} = ${defaultImportDeclaration};
848
2096
  }
849
2097
  };
850
2098
  }
851
- const federation_fn_import = "import { satisfy } from '__federation_fn_satisfy'\r\n\r\nconst currentImports = {}\r\n\r\n// eslint-disable-next-line no-undef\r\nconst moduleMap = __rf_var__moduleMap\r\nconst moduleCache = Object.create(null)\r\nasync function importShared(name, shareScope = 'default') {\r\n return moduleCache[name]\r\n ? new Promise((r) => r(moduleCache[name]))\r\n : (await getSharedFromRuntime(name, shareScope)) || getSharedFromLocal(name)\r\n}\r\n// eslint-disable-next-line\r\nasync function __federation_import(name) {\r\n currentImports[name] ??= import(name)\r\n return currentImports[name]\r\n}\r\nasync function getSharedFromRuntime(name, shareScope) {\r\n let module = null\r\n if (globalThis?.__federation_shared__?.[shareScope]?.[name]) {\r\n const versionObj = globalThis.__federation_shared__[shareScope][name]\r\n const requiredVersion = moduleMap[name]?.requiredVersion\r\n const hasRequiredVersion = !!requiredVersion\r\n if (hasRequiredVersion) {\r\n const versionKey = Object.keys(versionObj).find((version) =>\r\n satisfy(version, requiredVersion)\r\n )\r\n if (versionKey) {\r\n const versionValue = versionObj[versionKey]\r\n module = await (await versionValue.get())()\r\n } else {\r\n console.log(\r\n `provider support ${name}(${versionKey}) is not satisfied requiredVersion(\\${moduleMap[name].requiredVersion})`\r\n )\r\n }\r\n } else {\r\n const versionKey = Object.keys(versionObj)[0]\r\n const versionValue = versionObj[versionKey]\r\n module = await (await versionValue.get())()\r\n }\r\n }\r\n if (module) {\r\n return flattenModule(module, name)\r\n }\r\n}\r\nasync function getSharedFromLocal(name) {\r\n if (moduleMap[name]?.import) {\r\n let module = await (await moduleMap[name].get())()\r\n return flattenModule(module, name)\r\n } else {\r\n console.error(\r\n `consumer config import=false,so cant use callback shared module`\r\n )\r\n }\r\n}\r\nfunction flattenModule(module, name) {\r\n // use a shared module which export default a function will getting error 'TypeError: xxx is not a function'\r\n if (typeof module.default === 'function') {\r\n Object.keys(module).forEach((key) => {\r\n if (key !== 'default') {\r\n module.default[key] = module[key]\r\n }\r\n })\r\n moduleCache[name] = module.default\r\n return module.default\r\n }\r\n if (module.default) module = Object.assign({}, module.default, module)\r\n moduleCache[name] = module\r\n return module\r\n}\r\nexport {\r\n importShared,\r\n getSharedFromRuntime as importSharedRuntime,\r\n getSharedFromLocal as importSharedLocal\r\n}\r\n";
852
- const sharedFilePathReg = /__federation_shared_(.+)-.{8}\.js$/;
2099
+
2100
+ // src/federation/src/prod/shared-production.ts
2101
+ var import_path2 = require("path");
2102
+ var import_fs = require("fs");
2103
+
2104
+ // raw:E:\meet-hive\meethive\packages\vite\src\federation\src\prod\federation_fn_import.js
2105
+ var federation_fn_import_default = "import { satisfy } from '__federation_fn_satisfy'\r\n\r\nconst currentImports = {}\r\n\r\n// eslint-disable-next-line no-undef\r\nconst moduleMap = __rf_var__moduleMap\r\nconst moduleCache = Object.create(null)\r\nasync function importShared(name, shareScope = 'default') {\r\n return moduleCache[name]\r\n ? new Promise((r) => r(moduleCache[name]))\r\n : (await getSharedFromRuntime(name, shareScope)) || getSharedFromLocal(name)\r\n}\r\n// eslint-disable-next-line\r\nasync function __federation_import(name) {\r\n currentImports[name] ??= import(name)\r\n return currentImports[name]\r\n}\r\nasync function getSharedFromRuntime(name, shareScope) {\r\n let module = null\r\n if (globalThis?.__federation_shared__?.[shareScope]?.[name]) {\r\n const versionObj = globalThis.__federation_shared__[shareScope][name]\r\n const requiredVersion = moduleMap[name]?.requiredVersion\r\n const hasRequiredVersion = !!requiredVersion\r\n if (hasRequiredVersion) {\r\n const versionKey = Object.keys(versionObj).find((version) =>\r\n satisfy(version, requiredVersion)\r\n )\r\n if (versionKey) {\r\n const versionValue = versionObj[versionKey]\r\n module = await (await versionValue.get())()\r\n } else {\r\n console.log(\r\n `provider support ${name}(${versionKey}) is not satisfied requiredVersion(\\${moduleMap[name].requiredVersion})`\r\n )\r\n }\r\n } else {\r\n const versionKey = Object.keys(versionObj)[0]\r\n const versionValue = versionObj[versionKey]\r\n module = await (await versionValue.get())()\r\n }\r\n }\r\n if (module) {\r\n return flattenModule(module, name)\r\n }\r\n}\r\nasync function getSharedFromLocal(name) {\r\n if (moduleMap[name]?.import) {\r\n let module = await (await moduleMap[name].get())()\r\n return flattenModule(module, name)\r\n } else {\r\n console.error(\r\n `consumer config import=false,so cant use callback shared module`\r\n )\r\n }\r\n}\r\nfunction flattenModule(module, name) {\r\n // use a shared module which export default a function will getting error 'TypeError: xxx is not a function'\r\n if (typeof module.default === 'function') {\r\n Object.keys(module).forEach((key) => {\r\n if (key !== 'default') {\r\n module.default[key] = module[key]\r\n }\r\n })\r\n moduleCache[name] = module.default\r\n return module.default\r\n }\r\n if (module.default) module = Object.assign({}, module.default, module)\r\n moduleCache[name] = module\r\n return module\r\n}\r\nexport {\r\n importShared,\r\n getSharedFromRuntime as importSharedRuntime,\r\n getSharedFromLocal as importSharedLocal\r\n}\r\n";
2106
+
2107
+ // src/federation/src/prod/shared-production.ts
2108
+ var sharedFilePathReg = /__federation_shared_(.+)-.{8}\.js$/;
853
2109
  function prodSharedPlugin(options) {
854
2110
  parsedOptions.prodShared = parseSharedOptions(options);
855
2111
  const shareName2Prop = /* @__PURE__ */ new Map();
@@ -875,7 +2131,7 @@ function prodSharedPlugin(options) {
875
2131
  }
876
2132
  if (conflictModules.size > 0) {
877
2133
  console.info(
878
- `[Federation] 检测到模块 [${Array.from(conflictModules).join(", ")}] 同时配置在 shared manualChunks 中,启用协商共存模式`
2134
+ `[Federation] \u68C0\u6D4B\u5230\u6A21\u5757 [${Array.from(conflictModules).join(", ")}] \u540C\u65F6\u914D\u7F6E\u5728 shared \u548C manualChunks \u4E2D\uFF0C\u542F\u7528\u534F\u5546\u5171\u5B58\u6A21\u5F0F`
879
2135
  );
880
2136
  adaptSharedToManualChunks(conflictModules);
881
2137
  }
@@ -888,7 +2144,7 @@ function prodSharedPlugin(options) {
888
2144
  config.manualChunkCompat = true;
889
2145
  config.chunkLoading = "defer";
890
2146
  console.info(
891
- `[Federation] 模块 "${moduleName}" 设置为兼容模式:manualChunks 负责分块,federation 负责运行时共享`
2147
+ `[Federation] \u6A21\u5757 "${moduleName}" \u8BBE\u7F6E\u4E3A\u517C\u5BB9\u6A21\u5F0F\uFF1AmanualChunks \u8D1F\u8D23\u5206\u5757\uFF0Cfederation \u8D1F\u8D23\u8FD0\u884C\u65F6\u5171\u4EAB`
892
2148
  );
893
2149
  }
894
2150
  });
@@ -896,13 +2152,14 @@ function prodSharedPlugin(options) {
896
2152
  return {
897
2153
  name: "originjs:shared-production",
898
2154
  virtualFile: {
899
- __federation_fn_import: federation_fn_import
2155
+ __federation_fn_import: federation_fn_import_default
900
2156
  },
901
2157
  options(inputOptions) {
2158
+ var _a;
902
2159
  isRemote = !!parsedOptions.prodExpose.length;
903
2160
  isHost = options.isHost;
904
2161
  if (shareName2Prop.size) {
905
- inputOptions.external = inputOptions.external?.filter((item) => {
2162
+ inputOptions.external = (_a = inputOptions.external) == null ? void 0 : _a.filter((item) => {
906
2163
  if (item instanceof RegExp)
907
2164
  return ![...shareName2Prop.keys()].some((key) => item.test(key));
908
2165
  return !shareName2Prop.has(removeNonRegLetter(item, NAME_CHAR_REG));
@@ -912,6 +2169,7 @@ function prodSharedPlugin(options) {
912
2169
  return inputOptions;
913
2170
  },
914
2171
  async buildStart() {
2172
+ var _a;
915
2173
  if (parsedOptions.prodShared.length && isRemote) {
916
2174
  this.emitFile({
917
2175
  name: "__federation_fn_import",
@@ -921,10 +2179,10 @@ function prodSharedPlugin(options) {
921
2179
  });
922
2180
  }
923
2181
  const collectDirFn = (filePath, collect) => {
924
- const files = fs.readdirSync(filePath);
2182
+ const files = (0, import_fs.readdirSync)(filePath);
925
2183
  files.forEach((name) => {
926
- const tempPath = path.join(filePath, name);
927
- const isDir = fs.statSync(tempPath).isDirectory();
2184
+ const tempPath = (0, import_path2.join)(filePath, name);
2185
+ const isDir = (0, import_fs.statSync)(tempPath).isDirectory();
928
2186
  if (isDir) {
929
2187
  collect.push(tempPath);
930
2188
  collectDirFn(tempPath, collect);
@@ -933,19 +2191,19 @@ function prodSharedPlugin(options) {
933
2191
  };
934
2192
  const monoRepos = [];
935
2193
  const dirPaths = [];
936
- const currentDir = path.resolve();
2194
+ const currentDir = (0, import_path2.resolve)();
937
2195
  for (const arr of parsedOptions.prodShared) {
938
2196
  if (isHost && !arr[1].version && !arr[1].manuallyPackagePathSetting) {
939
- const packageJsonPath = (await this.resolve(`${arr[1].packagePath}/package.json`))?.id;
2197
+ const packageJsonPath = (_a = await this.resolve(`${arr[1].packagePath}/package.json`)) == null ? void 0 : _a.id;
940
2198
  if (packageJsonPath) {
941
2199
  const packageJson = JSON.parse(
942
- fs.readFileSync(packageJsonPath, { encoding: "utf-8" })
2200
+ (0, import_fs.readFileSync)(packageJsonPath, { encoding: "utf-8" })
943
2201
  );
944
2202
  arr[1].version = packageJson.version;
945
2203
  } else {
946
2204
  arr[1].removed = true;
947
- const dir = path.join(currentDir, "node_modules", arr[0]);
948
- const dirStat = fs.statSync(dir);
2205
+ const dir = (0, import_path2.join)(currentDir, "node_modules", arr[0]);
2206
+ const dirStat = (0, import_fs.statSync)(dir);
949
2207
  if (dirStat.isDirectory()) {
950
2208
  collectDirFn(dir, dirPaths);
951
2209
  } else {
@@ -970,11 +2228,11 @@ function prodSharedPlugin(options) {
970
2228
  for (const id of monoRepo.arr) {
971
2229
  try {
972
2230
  const idResolve = await this.resolve(id);
973
- if (idResolve?.id) {
2231
+ if (idResolve == null ? void 0 : idResolve.id) {
974
2232
  parsedOptions.prodShared.push([
975
- `${monoRepo.root[0]}/${path.basename(id)}`,
2233
+ `${monoRepo.root[0]}/${(0, import_path2.basename)(id)}`,
976
2234
  {
977
- id: idResolve?.id,
2235
+ id: idResolve == null ? void 0 : idResolve.id,
978
2236
  import: monoRepo.root[1].import,
979
2237
  shareScope: monoRepo.root[1].shareScope,
980
2238
  root: monoRepo.root
@@ -996,7 +2254,10 @@ function prodSharedPlugin(options) {
996
2254
  outputOption.hoistTransitiveImports = false;
997
2255
  const manualChunkFunc = (id) => {
998
2256
  const find = parsedOptions.prodShared.find(
999
- (arr) => arr[1].dependencies?.has(id)
2257
+ (arr) => {
2258
+ var _a;
2259
+ return (_a = arr[1].dependencies) == null ? void 0 : _a.has(id);
2260
+ }
1000
2261
  );
1001
2262
  return find ? find[0] : void 0;
1002
2263
  };
@@ -1014,6 +2275,7 @@ function prodSharedPlugin(options) {
1014
2275
  return outputOption;
1015
2276
  },
1016
2277
  generateBundle(options2, bundle) {
2278
+ var _a;
1017
2279
  if (!isRemote) {
1018
2280
  return;
1019
2281
  }
@@ -1023,7 +2285,7 @@ function prodSharedPlugin(options) {
1023
2285
  if (chunk.type === "chunk") {
1024
2286
  if (!isHost) {
1025
2287
  const regRst = sharedFilePathReg.exec(chunk.fileName);
1026
- if (regRst && shareName2Prop.get(removeNonRegLetter(regRst[1], NAME_CHAR_REG))?.generate === false) {
2288
+ if (regRst && ((_a = shareName2Prop.get(removeNonRegLetter(regRst[1], NAME_CHAR_REG))) == null ? void 0 : _a.generate) === false) {
1027
2289
  needRemoveShared.add(key);
1028
2290
  }
1029
2291
  }
@@ -1037,10 +2299,14 @@ function prodSharedPlugin(options) {
1037
2299
  }
1038
2300
  };
1039
2301
  }
2302
+
2303
+ // src/federation/src/prod/expose-production.ts
2304
+ var import_path3 = require("path");
1040
2305
  function prodExposePlugin(options) {
1041
2306
  let moduleMap = "";
1042
2307
  const hasOptions = parsedOptions.prodExpose.some((expose) => {
1043
- return expose[0] === parseExposeOptions(options)[0]?.[0];
2308
+ var _a;
2309
+ return expose[0] === ((_a = parseExposeOptions(options)[0]) == null ? void 0 : _a[0]);
1044
2310
  });
1045
2311
  if (!hasOptions) {
1046
2312
  parsedOptions.prodExpose = Array.prototype.concat(
@@ -1049,8 +2315,9 @@ function prodExposePlugin(options) {
1049
2315
  );
1050
2316
  }
1051
2317
  for (const item of parseExposeOptions(options)) {
1052
- getModuleMarker(`\${${item[0]}}`, SHARED);
1053
- const exposeFilepath = normalizePath(path.resolve(item[1].import));
2318
+ const moduleName = getModuleMarker(`\${${item[0]}}`, SHARED);
2319
+ EXTERNALS.push(moduleName);
2320
+ const exposeFilepath = normalizePath((0, import_path3.resolve)(item[1].import));
1054
2321
  EXPOSES_MAP.set(item[0], exposeFilepath);
1055
2322
  EXPOSES_KEY_MAP.set(
1056
2323
  item[0],
@@ -1100,11 +2367,11 @@ function prodExposePlugin(options) {
1100
2367
  if (isAbsoluteUrl(baseUrl)) {
1101
2368
  href = [cleanBaseUrl, cleanAssetsDir, cleanCssPath].filter(Boolean).join('/');
1102
2369
  } else {
1103
- // 当remoteEntry.js和CSS都在assets目录下时,使用相对路径
2370
+ // \u5F53remoteEntry.js\u548CCSS\u90FD\u5728assets\u76EE\u5F55\u4E0B\u65F6\uFF0C\u4F7F\u7528\u76F8\u5BF9\u8DEF\u5F84
1104
2371
  const remoteEntryInAssets = cleanCurUrl.endsWith('/assets/') || cleanCurUrl.endsWith('/assets');
1105
2372
 
1106
2373
  if (remoteEntryInAssets) {
1107
- // 都在assets目录下,直接使用CSS文件名
2374
+ // \u90FD\u5728assets\u76EE\u5F55\u4E0B\uFF0C\u76F4\u63A5\u4F7F\u7528CSS\u6587\u4EF6\u540D
1108
2375
  href = [cleanCurUrl, cleanCssPath].filter(Boolean).join('/');
1109
2376
  } else if (cleanCurUrl.includes(cleanBaseUrl)) {
1110
2377
  href = [cleanCurUrl, cleanAssetsDir, cleanCssPath].filter(Boolean).join('/');
@@ -1169,10 +2436,11 @@ function prodExposePlugin(options) {
1169
2436
  }
1170
2437
  },
1171
2438
  generateBundle(_options, bundle) {
2439
+ var _a, _b, _c;
1172
2440
  let remoteEntryChunk;
1173
2441
  for (const file in bundle) {
1174
2442
  const chunk = bundle[file];
1175
- if (chunk?.facadeModuleId === `\0virtual:__remoteEntryHelper__${options.filename}`) {
2443
+ if ((chunk == null ? void 0 : chunk.facadeModuleId) === `\0virtual:__remoteEntryHelper__${options.filename}`) {
1176
2444
  remoteEntryChunk = chunk;
1177
2445
  break;
1178
2446
  }
@@ -1180,14 +2448,14 @@ function prodExposePlugin(options) {
1180
2448
  if (remoteEntryChunk) {
1181
2449
  remoteEntryChunk.code = remoteEntryChunk.code.replace(
1182
2450
  "__VITE_BASE_PLACEHOLDER__",
1183
- `'${viteConfigResolved.config?.base || ""}'`
2451
+ `'${((_a = viteConfigResolved.config) == null ? void 0 : _a.base) || ""}'`
1184
2452
  ).replace(
1185
2453
  "__VITE_ASSETS_DIR_PLACEHOLDER__",
1186
2454
  `'${builderInfo.assetsDir || ""}'`
1187
2455
  );
1188
2456
  const filepathMap = /* @__PURE__ */ new Map();
1189
- const getFilename = (name) => path.parse(path.parse(name).name).name;
1190
- const cssBundlesMap = Object.keys(bundle).filter((name) => path.extname(name) === ".css").reduce((res, name) => {
2457
+ const getFilename = (name) => (0, import_path3.parse)((0, import_path3.parse)(name).name).name;
2458
+ const cssBundlesMap = Object.keys(bundle).filter((name) => (0, import_path3.extname)(name) === ".css").reduce((res, name) => {
1191
2459
  const filename = getFilename(name);
1192
2460
  res.set(filename, bundle[name]);
1193
2461
  return res;
@@ -1198,7 +2466,7 @@ function prodExposePlugin(options) {
1198
2466
  if (viteConfigResolved.config && !viteConfigResolved.config.build.cssCodeSplit) {
1199
2467
  if (cssBundlesMap.size) {
1200
2468
  return `[${[...cssBundlesMap.values()].map(
1201
- (cssBundle) => JSON.stringify(path.basename(cssBundle.fileName))
2469
+ (cssBundle) => JSON.stringify((0, import_path3.basename)(cssBundle.fileName))
1202
2470
  ).join(",")}]`;
1203
2471
  } else {
1204
2472
  return "[]";
@@ -1233,24 +2501,24 @@ function prodExposePlugin(options) {
1233
2501
  }
1234
2502
  };
1235
2503
  [fileBundle.fileName, ...fileBundle.imports].forEach(addDepCss);
1236
- return `[${[...depCssFiles].map((d) => JSON.stringify(path.basename(d))).join(",")}]`;
2504
+ return `[${[...depCssFiles].map((d) => JSON.stringify((0, import_path3.basename)(d))).join(",")}]`;
1237
2505
  }
1238
2506
  );
1239
2507
  for (const expose of parseExposeOptions(options)) {
1240
- const module2 = Object.keys(bundle).find((module22) => {
1241
- const chunk = bundle[module22];
2508
+ const module2 = Object.keys(bundle).find((module3) => {
2509
+ const chunk = bundle[module3];
1242
2510
  return chunk.name === EXPOSES_KEY_MAP.get(expose[0]);
1243
2511
  });
1244
2512
  if (module2) {
1245
2513
  const chunk = bundle[module2];
1246
- const fileRelativePath = path.relative(
1247
- path.dirname(remoteEntryChunk.fileName),
2514
+ const fileRelativePath = (0, import_path3.relative)(
2515
+ (0, import_path3.dirname)(remoteEntryChunk.fileName),
1248
2516
  chunk.fileName
1249
2517
  );
1250
2518
  const slashPath = fileRelativePath.replace(/\\/g, "/");
1251
2519
  remoteEntryChunk.code = remoteEntryChunk.code.replace(
1252
2520
  `\${__federation_expose_${expose[0]}}`,
1253
- viteConfigResolved.config?.base?.replace(/\/+$/, "") ? [
2521
+ ((_c = (_b = viteConfigResolved.config) == null ? void 0 : _b.base) == null ? void 0 : _c.replace(/\/+$/, "")) ? [
1254
2522
  viteConfigResolved.config.base.replace(/\/+$/, ""),
1255
2523
  slashPath
1256
2524
  ].filter(Boolean).join("/") : `./${slashPath}`
@@ -1267,11 +2535,12 @@ function prodExposePlugin(options) {
1267
2535
  return;
1268
2536
  }
1269
2537
  const magicString = new MagicString(remoteEntryChunk.code);
1270
- estreeWalker.walk(ast, {
2538
+ walk(ast, {
1271
2539
  enter(node) {
1272
- if (node && node.type === "CallExpression" && typeof node.arguments[0]?.value === "string" && node.arguments[0]?.value.indexOf(
2540
+ var _a2, _b2;
2541
+ if (node && node.type === "CallExpression" && typeof ((_a2 = node.arguments[0]) == null ? void 0 : _a2.value) === "string" && ((_b2 = node.arguments[0]) == null ? void 0 : _b2.value.indexOf(
1273
2542
  `${DYNAMIC_LOADING_CSS_PREFIX}`
1274
- ) > -1) {
2543
+ )) > -1) {
1275
2544
  magicString.remove(node.start, node.end + 1);
1276
2545
  }
1277
2546
  }
@@ -1281,12 +2550,18 @@ function prodExposePlugin(options) {
1281
2550
  }
1282
2551
  };
1283
2552
  }
2553
+
2554
+ // src/federation/src/dev/shared-development.ts
1284
2555
  function devSharedPlugin(options) {
1285
2556
  parsedOptions.devShared = parseSharedOptions(options);
1286
2557
  return {
1287
2558
  name: "originjs:shared-development"
1288
2559
  };
1289
2560
  }
2561
+
2562
+ // src/federation/src/dev/remote-development.ts
2563
+ var import_fs2 = require("fs");
2564
+ var import_path4 = require("path");
1290
2565
  function devRemotePlugin(options) {
1291
2566
  parsedOptions.devRemote = parseRemoteOptions(options);
1292
2567
  for (const item of parsedOptions.devRemote) {
@@ -1436,17 +2711,18 @@ export {__federation_method_ensure, __federation_method_getRemote , __federation
1436
2711
  viteDevServer = server;
1437
2712
  },
1438
2713
  async transform(code, id) {
2714
+ var _a;
1439
2715
  if (builderInfo.isHost && !builderInfo.isRemote) {
1440
2716
  for (const arr of parsedOptions.devShared) {
1441
2717
  if (!arr[1].version && !arr[1].manuallyPackagePathSetting) {
1442
- const packageJsonPath = (await this.resolve(`${arr[0]}/package.json`))?.id;
2718
+ const packageJsonPath = (_a = await this.resolve(`${arr[0]}/package.json`)) == null ? void 0 : _a.id;
1443
2719
  if (!packageJsonPath) {
1444
2720
  this.error(
1445
2721
  `No description file or no version in description file (usually package.json) of ${arr[0]}(${packageJsonPath}). Add version to description file, or manually specify version in shared config.`
1446
2722
  );
1447
2723
  } else {
1448
2724
  const json = JSON.parse(
1449
- fs.readFileSync(packageJsonPath, { encoding: "utf-8" })
2725
+ (0, import_fs2.readFileSync)(packageJsonPath, { encoding: "utf-8" })
1450
2726
  );
1451
2727
  arr[1].version = json.version;
1452
2728
  }
@@ -1477,15 +2753,16 @@ export {__federation_method_ensure, __federation_method_getRemote , __federation
1477
2753
  const hasStaticImported = /* @__PURE__ */ new Map();
1478
2754
  let requiresRuntime = false;
1479
2755
  let manualRequired = null;
1480
- estreeWalker.walk(ast, {
2756
+ walk(ast, {
1481
2757
  enter(node) {
1482
- if (node.type === "ImportDeclaration" && node.source?.value === "virtual:__federation__") {
2758
+ var _a2, _b, _c, _d;
2759
+ if (node.type === "ImportDeclaration" && ((_a2 = node.source) == null ? void 0 : _a2.value) === "virtual:__federation__") {
1483
2760
  manualRequired = node;
1484
2761
  }
1485
- if ((node.type === "ImportExpression" || node.type === "ImportDeclaration" || node.type === "ExportNamedDeclaration") && node.source?.value?.indexOf("/") > -1) {
2762
+ if ((node.type === "ImportExpression" || node.type === "ImportDeclaration" || node.type === "ExportNamedDeclaration") && ((_c = (_b = node.source) == null ? void 0 : _b.value) == null ? void 0 : _c.indexOf("/")) > -1) {
1486
2763
  const moduleId = node.source.value;
1487
2764
  const remote = devRemotes.find((r) => r.regexp.test(moduleId));
1488
- const needWrap = remote?.config.from === "vite";
2765
+ const needWrap = (remote == null ? void 0 : remote.config.from) === "vite";
1489
2766
  if (remote) {
1490
2767
  requiresRuntime = true;
1491
2768
  const modName = `.${moduleId.slice(remote.id.length)}`;
@@ -1503,7 +2780,7 @@ export {__federation_method_ensure, __federation_method_getRemote , __federation
1503
2780
  break;
1504
2781
  }
1505
2782
  case "ImportDeclaration": {
1506
- if (node.specifiers?.length) {
2783
+ if ((_d = node.specifiers) == null ? void 0 : _d.length) {
1507
2784
  const afterImportName = `__federation_var_${moduleId.replace(
1508
2785
  /[@/\\.-]/g,
1509
2786
  ""
@@ -1631,7 +2908,7 @@ export {__federation_method_ensure, __federation_method_getRemote , __federation
1631
2908
  if (!moduleInfo) continue;
1632
2909
  const moduleFilePath = normalizePath(moduleInfo.id);
1633
2910
  const idx = moduleFilePath.indexOf(cwdPath);
1634
- const relativePath = idx === 0 ? path.posix.join(base, moduleFilePath.slice(cwdPath.length)) : null;
2911
+ const relativePath = idx === 0 ? import_path4.posix.join(base, moduleFilePath.slice(cwdPath.length)) : null;
1635
2912
  const sharedName = item[0];
1636
2913
  const obj = item[1];
1637
2914
  let str = "";
@@ -1647,19 +2924,150 @@ export {__federation_method_ensure, __federation_method_getRemote , __federation
1647
2924
  return res;
1648
2925
  }
1649
2926
  }
2927
+
2928
+ // src/federation/src/dev/expose-development.ts
1650
2929
  function devExposePlugin(options) {
1651
2930
  parsedOptions.devExpose = parseExposeOptions(options);
1652
2931
  return {
1653
2932
  name: "originjs:expose-development"
1654
2933
  };
1655
2934
  }
1656
- const normalizeAssetsDir = (config) => {
1657
- const configured = config?.build?.assetsDir ?? "assets";
2935
+
2936
+ // src/federation/src/runtime/dynamic-remote.ts
2937
+ var DynamicRemoteManager = class {
2938
+ remoteCache = /* @__PURE__ */ new Map();
2939
+ loadingPromises = /* @__PURE__ */ new Map();
2940
+ /**
2941
+ * Add a remote dynamically at runtime
2942
+ * @param name Remote name
2943
+ * @param config Remote configuration
2944
+ */
2945
+ async addRemote(name, config) {
2946
+ try {
2947
+ const federationModule = await import("virtual:__federation__");
2948
+ const { __federation_method_add_origin_setRemote } = federationModule;
2949
+ await __federation_method_add_origin_setRemote(name, config.url, {
2950
+ format: config.format || "esm",
2951
+ from: config.from || "vite",
2952
+ shareScope: config.shareScope || "default",
2953
+ external: config.external,
2954
+ externalType: config.externalType || "url"
2955
+ });
2956
+ } catch (error) {
2957
+ throw new Error(`Failed to add dynamic remote '${name}': ${error.message}. Make sure to enable dynamic remotes in your plugin configuration with 'enableDynamicRemotes: true'.`);
2958
+ }
2959
+ }
2960
+ /**
2961
+ * Load a remote component dynamically
2962
+ * @param remoteName Remote name
2963
+ * @param componentName Component name to load from remote
2964
+ * @returns Promise of the loaded component
2965
+ */
2966
+ async loadRemoteComponent(remoteName, componentName) {
2967
+ const cacheKey = `${remoteName}/${componentName}`;
2968
+ if (this.remoteCache.has(cacheKey)) {
2969
+ return this.remoteCache.get(cacheKey);
2970
+ }
2971
+ if (this.loadingPromises.has(cacheKey)) {
2972
+ return this.loadingPromises.get(cacheKey);
2973
+ }
2974
+ const loadingPromise = this.doLoadRemoteComponent(remoteName, componentName);
2975
+ this.loadingPromises.set(cacheKey, loadingPromise);
2976
+ try {
2977
+ const component = await loadingPromise;
2978
+ this.remoteCache.set(cacheKey, component);
2979
+ return component;
2980
+ } finally {
2981
+ this.loadingPromises.delete(cacheKey);
2982
+ }
2983
+ }
2984
+ async doLoadRemoteComponent(remoteName, componentName) {
2985
+ try {
2986
+ const federationModule = await import("virtual:__federation__");
2987
+ const { __federation_method_getRemote } = federationModule;
2988
+ return __federation_method_getRemote(remoteName, componentName);
2989
+ } catch (error) {
2990
+ throw new Error(`Failed to load remote component '${remoteName}/${componentName}': ${error.message}. Make sure to enable dynamic remotes in your plugin configuration with 'enableDynamicRemotes: true'.`);
2991
+ }
2992
+ }
2993
+ /**
2994
+ * Preload a remote component
2995
+ * @param remoteName Remote name
2996
+ * @param componentName Component name
2997
+ */
2998
+ async preloadRemoteComponent(remoteName, componentName) {
2999
+ try {
3000
+ await this.loadRemoteComponent(remoteName, componentName);
3001
+ } catch (error) {
3002
+ console.warn(`Failed to preload remote component ${remoteName}/${componentName}:`, error);
3003
+ }
3004
+ }
3005
+ /**
3006
+ * Remove a remote component from cache
3007
+ * @param remoteName Remote name
3008
+ * @param componentName Component name
3009
+ */
3010
+ clearRemoteComponentCache(remoteName, componentName) {
3011
+ if (componentName) {
3012
+ const cacheKey = `${remoteName}/${componentName}`;
3013
+ this.remoteCache.delete(cacheKey);
3014
+ } else {
3015
+ for (const key of this.remoteCache.keys()) {
3016
+ if (key.startsWith(`${remoteName}/`)) {
3017
+ this.remoteCache.delete(key);
3018
+ }
3019
+ }
3020
+ }
3021
+ }
3022
+ /**
3023
+ * Get all cached remote components
3024
+ */
3025
+ getCachedRemotes() {
3026
+ return Array.from(this.remoteCache.keys());
3027
+ }
3028
+ /**
3029
+ * Check if a remote component is cached
3030
+ * @param remoteName Remote name
3031
+ * @param componentName Component name
3032
+ */
3033
+ isRemoteComponentCached(remoteName, componentName) {
3034
+ const cacheKey = `${remoteName}/${componentName}`;
3035
+ return this.remoteCache.has(cacheKey);
3036
+ }
3037
+ };
3038
+ var dynamicRemoteManager = new DynamicRemoteManager();
3039
+ function isVueAvailable() {
3040
+ try {
3041
+ return typeof ref !== "undefined" && typeof onMounted !== "undefined";
3042
+ } catch {
3043
+ return false;
3044
+ }
3045
+ }
3046
+ var ref;
3047
+ var onMounted;
3048
+ var readonly;
3049
+ if (isVueAvailable()) {
3050
+ try {
3051
+ import("vue").then((vue) => {
3052
+ ref = vue.ref;
3053
+ onMounted = vue.onMounted;
3054
+ readonly = vue.readonly;
3055
+ }).catch(() => {
3056
+ console.warn("Vue not available for dynamic import");
3057
+ });
3058
+ } catch {
3059
+ }
3060
+ }
3061
+
3062
+ // src/federation/src/index.ts
3063
+ var normalizeAssetsDir = (config) => {
3064
+ var _a, _b;
3065
+ const configured = ((_a = config == null ? void 0 : config.build) == null ? void 0 : _a.assetsDir) ?? "assets";
1658
3066
  if (!configured) return "";
1659
- if (!path.isAbsolute(configured)) return configured;
1660
- const root = config?.root ? path.resolve(config.root) : process.cwd();
1661
- const resolvedOutDir = config?.build?.outDir ? path.isAbsolute(config.build.outDir) ? config.build.outDir : path.resolve(root, config.build.outDir) : path.resolve(root, "dist");
1662
- const normalized = path.relative(resolvedOutDir, configured).replace(/\\/g, "/");
3067
+ if (!(0, import_path5.isAbsolute)(configured)) return configured;
3068
+ const root = (config == null ? void 0 : config.root) ? (0, import_path5.resolve)(config.root) : process.cwd();
3069
+ const resolvedOutDir = ((_b = config == null ? void 0 : config.build) == null ? void 0 : _b.outDir) ? (0, import_path5.isAbsolute)(config.build.outDir) ? config.build.outDir : (0, import_path5.resolve)(root, config.build.outDir) : (0, import_path5.resolve)(root, "dist");
3070
+ const normalized = (0, import_path5.relative)(resolvedOutDir, configured).replace(/\\/g, "/");
1663
3071
  return normalized.startsWith("..") ? "" : normalized || "assets";
1664
3072
  };
1665
3073
  function federation(options) {
@@ -1702,6 +3110,7 @@ function federation(options) {
1702
3110
  enforce: "post",
1703
3111
  // apply:'build',
1704
3112
  options(_options) {
3113
+ var _a;
1705
3114
  if (!registerCount++) {
1706
3115
  registerPlugins(options.mode = options.mode ?? "production", "");
1707
3116
  }
@@ -1713,36 +3122,41 @@ function federation(options) {
1713
3122
  _options.external = [_options.external];
1714
3123
  }
1715
3124
  for (const pluginHook of pluginList) {
1716
- pluginHook.options?.call(this, _options);
3125
+ (_a = pluginHook.options) == null ? void 0 : _a.call(this, _options);
1717
3126
  }
1718
3127
  return _options;
1719
3128
  },
1720
3129
  config(config, env) {
3130
+ var _a;
1721
3131
  options.mode = options.mode ?? env.mode;
1722
3132
  registerPlugins(options.mode, env.command);
1723
3133
  registerCount++;
1724
3134
  for (const pluginHook of pluginList) {
1725
- pluginHook.config?.call(this, config, env);
3135
+ (_a = pluginHook.config) == null ? void 0 : _a.call(this, config, env);
1726
3136
  }
1727
3137
  builderInfo.builder = "vite";
1728
3138
  builderInfo.assetsDir = normalizeAssetsDir(config) ?? "assets";
1729
3139
  },
1730
3140
  configureServer(server) {
3141
+ var _a;
1731
3142
  for (const pluginHook of pluginList) {
1732
- pluginHook.configureServer?.call(this, server);
3143
+ (_a = pluginHook.configureServer) == null ? void 0 : _a.call(this, server);
1733
3144
  }
1734
3145
  },
1735
3146
  configResolved(config) {
3147
+ var _a;
1736
3148
  for (const pluginHook of pluginList) {
1737
- pluginHook.configResolved?.call(this, config);
3149
+ (_a = pluginHook.configResolved) == null ? void 0 : _a.call(this, config);
1738
3150
  }
1739
3151
  },
1740
3152
  buildStart(inputOptions) {
3153
+ var _a;
1741
3154
  for (const pluginHook of pluginList) {
1742
- pluginHook.buildStart?.call(this, inputOptions);
3155
+ (_a = pluginHook.buildStart) == null ? void 0 : _a.call(this, inputOptions);
1743
3156
  }
1744
3157
  },
1745
3158
  async resolveId(...args) {
3159
+ var _a;
1746
3160
  const v = virtualMod.resolveId.call(this, ...args);
1747
3161
  if (v) {
1748
3162
  return v;
@@ -1754,9 +3168,9 @@ function federation(options) {
1754
3168
  };
1755
3169
  }
1756
3170
  if (args[0] === "__federation_fn_satisfy") {
1757
- const federationId = (await this.resolve("@meethive/vite"))?.id;
3171
+ const federationId = (_a = await this.resolve("@meethive/vite")) == null ? void 0 : _a.id;
1758
3172
  if (federationId) {
1759
- return await this.resolve(`${path.dirname(federationId)}/satisfy.mjs`);
3173
+ return await this.resolve(`${(0, import_path5.dirname)(federationId)}/satisfy.mjs`);
1760
3174
  }
1761
3175
  return null;
1762
3176
  }
@@ -1776,8 +3190,9 @@ function federation(options) {
1776
3190
  return null;
1777
3191
  },
1778
3192
  transform(code, id) {
3193
+ var _a;
1779
3194
  for (const pluginHook of pluginList) {
1780
- const result = pluginHook.transform?.call(this, code, id);
3195
+ const result = (_a = pluginHook.transform) == null ? void 0 : _a.call(this, code, id);
1781
3196
  if (result) {
1782
3197
  return result;
1783
3198
  }
@@ -1785,19 +3200,22 @@ function federation(options) {
1785
3200
  return code;
1786
3201
  },
1787
3202
  moduleParsed(moduleInfo) {
3203
+ var _a;
1788
3204
  for (const pluginHook of pluginList) {
1789
- pluginHook.moduleParsed?.call(this, moduleInfo);
3205
+ (_a = pluginHook.moduleParsed) == null ? void 0 : _a.call(this, moduleInfo);
1790
3206
  }
1791
3207
  },
1792
3208
  outputOptions(outputOptions) {
3209
+ var _a;
1793
3210
  for (const pluginHook of pluginList) {
1794
- pluginHook.outputOptions?.call(this, outputOptions);
3211
+ (_a = pluginHook.outputOptions) == null ? void 0 : _a.call(this, outputOptions);
1795
3212
  }
1796
3213
  return outputOptions;
1797
3214
  },
1798
3215
  renderChunk(code, chunkInfo, _options) {
3216
+ var _a;
1799
3217
  for (const pluginHook of pluginList) {
1800
- const result = pluginHook.renderChunk?.call(
3218
+ const result = (_a = pluginHook.renderChunk) == null ? void 0 : _a.call(
1801
3219
  this,
1802
3220
  code,
1803
3221
  chunkInfo,
@@ -1810,13 +3228,20 @@ function federation(options) {
1810
3228
  return null;
1811
3229
  },
1812
3230
  generateBundle: function(_options, bundle, isWrite) {
3231
+ var _a;
1813
3232
  for (const pluginHook of pluginList) {
1814
- pluginHook.generateBundle?.call(this, _options, bundle, isWrite);
3233
+ (_a = pluginHook.generateBundle) == null ? void 0 : _a.call(this, _options, bundle, isWrite);
1815
3234
  }
1816
3235
  }
1817
3236
  };
1818
3237
  }
1819
- const languageWorkAttr = [
3238
+
3239
+ // src/monaco-editor/index.ts
3240
+ var import_path7 = require("path");
3241
+ var import_esbuild2 = require("esbuild");
3242
+
3243
+ // src/monaco-editor/languageWork.ts
3244
+ var languageWorkAttr = [
1820
3245
  {
1821
3246
  label: "editorWorkerService",
1822
3247
  entry: "monaco-editor/esm/vs/editor/editor.worker"
@@ -1838,15 +3263,20 @@ const languageWorkAttr = [
1838
3263
  entry: "monaco-editor/esm/vs/language/typescript/ts.worker"
1839
3264
  }
1840
3265
  ];
1841
- const languageWorksByLabel = {};
3266
+ var languageWorksByLabel = {};
1842
3267
  languageWorkAttr.forEach(
1843
3268
  (languageWork) => languageWorksByLabel[languageWork.label] = languageWork
1844
3269
  );
3270
+
3271
+ // src/monaco-editor/workerMiddleware.ts
3272
+ var import_esbuild = require("esbuild");
3273
+ var import_fs3 = require("fs");
3274
+ var import_path6 = require("path");
1845
3275
  function getFilenameByEntry(entry) {
1846
- entry = path.basename(entry, "js");
3276
+ entry = (0, import_path6.basename)(entry, "js");
1847
3277
  return entry + ".bundle.js";
1848
3278
  }
1849
- const cacheDir = "node_modules/.monaco/";
3279
+ var cacheDir = "node_modules/.monaco/";
1850
3280
  function getWorkPath(works, options, config) {
1851
3281
  const workerPaths = {};
1852
3282
  for (const work of works) {
@@ -1871,32 +3301,34 @@ function getWorkPath(works, options, config) {
1871
3301
  }
1872
3302
  function workerMiddleware(middlewares, config, options) {
1873
3303
  const works = getWorks(options);
1874
- if (fs.existsSync(cacheDir)) {
1875
- fs.rmSync(cacheDir, { recursive: true, force: true });
3304
+ if ((0, import_fs3.existsSync)(cacheDir)) {
3305
+ (0, import_fs3.rmSync)(cacheDir, { recursive: true, force: true });
1876
3306
  }
1877
3307
  for (const work of works) {
1878
3308
  middlewares.use(
1879
3309
  config.base + options.publicPath + "/" + getFilenameByEntry(work.entry),
1880
3310
  function(req, res, next) {
1881
- if (!fs.existsSync(cacheDir + getFilenameByEntry(work.entry))) {
1882
- esbuild.buildSync({
3311
+ if (!(0, import_fs3.existsSync)(cacheDir + getFilenameByEntry(work.entry))) {
3312
+ (0, import_esbuild.buildSync)({
1883
3313
  entryPoints: [resolveMonacoPath(work.entry)],
1884
3314
  bundle: true,
1885
3315
  outfile: cacheDir + getFilenameByEntry(work.entry)
1886
3316
  });
1887
3317
  }
1888
- const contentBuffer = fs.readFileSync(cacheDir + getFilenameByEntry(work.entry));
3318
+ const contentBuffer = (0, import_fs3.readFileSync)(cacheDir + getFilenameByEntry(work.entry));
1889
3319
  res.setHeader("Content-Type", "text/javascript");
1890
3320
  res.end(contentBuffer);
1891
3321
  }
1892
3322
  );
1893
3323
  }
1894
3324
  }
3325
+
3326
+ // src/monaco-editor/index.ts
1895
3327
  function resolveMonacoPath(filePath) {
1896
3328
  try {
1897
- return path.resolve(path.join(process.cwd(), "node_modules", filePath));
3329
+ return (0, import_path7.resolve)((0, import_path7.join)(process.cwd(), "node_modules", filePath));
1898
3330
  } catch (err) {
1899
- return path.resolve(filePath);
3331
+ return (0, import_path7.resolve)(filePath);
1900
3332
  }
1901
3333
  }
1902
3334
  function getWorks(options) {
@@ -1906,14 +3338,15 @@ function getWorks(options) {
1906
3338
  works.push(...options.customWorkers);
1907
3339
  return works;
1908
3340
  }
1909
- const getFS = async () => {
1910
- if (typeof process !== "undefined" && process.versions?.node) {
1911
- const fs2 = await import("fs");
3341
+ var getFS = async () => {
3342
+ var _a;
3343
+ if (typeof process !== "undefined" && ((_a = process.versions) == null ? void 0 : _a.node)) {
3344
+ const fs = await import("fs");
1912
3345
  return {
1913
- existsSync: fs2.existsSync,
1914
- mkdirSync: fs2.mkdirSync,
1915
- readFileSync: fs2.readFileSync,
1916
- writeFileSync: fs2.writeFileSync
3346
+ existsSync: fs.existsSync,
3347
+ mkdirSync: fs.mkdirSync,
3348
+ readFileSync: fs.readFileSync,
3349
+ writeFileSync: fs.writeFileSync
1917
3350
  };
1918
3351
  }
1919
3352
  return null;
@@ -1987,8 +3420,8 @@ function monacoEditorPlugin(options) {
1987
3420
  if (isCDN(publicPath) && !forceBuildCDN) {
1988
3421
  return;
1989
3422
  }
1990
- const fs2 = await getFS();
1991
- if (!fs2) {
3423
+ const fs = await getFS();
3424
+ if (!fs) {
1992
3425
  this.warn("File system operations not available in this environment");
1993
3426
  return;
1994
3427
  }
@@ -1997,28 +3430,28 @@ function monacoEditorPlugin(options) {
1997
3430
  resolvedConfig.root,
1998
3431
  resolvedConfig.build.outDir,
1999
3432
  resolvedConfig.base
2000
- ) : path.join(
3433
+ ) : (0, import_path7.join)(
2001
3434
  resolvedConfig.root,
2002
3435
  resolvedConfig.build.outDir,
2003
3436
  resolvedConfig.base,
2004
3437
  options.publicPath
2005
3438
  );
2006
- if (!fs2.existsSync(distPath)) {
2007
- fs2.mkdirSync(distPath, {
3439
+ if (!fs.existsSync(distPath)) {
3440
+ fs.mkdirSync(distPath, {
2008
3441
  recursive: true
2009
3442
  });
2010
3443
  }
2011
3444
  for (const work of works) {
2012
- if (!fs2.existsSync(cacheDir + getFilenameByEntry(work.entry))) {
2013
- esbuild.buildSync({
3445
+ if (!fs.existsSync(cacheDir + getFilenameByEntry(work.entry))) {
3446
+ (0, import_esbuild2.buildSync)({
2014
3447
  entryPoints: [resolveMonacoPath(work.entry)],
2015
3448
  bundle: true,
2016
3449
  outfile: cacheDir + getFilenameByEntry(work.entry)
2017
3450
  });
2018
3451
  }
2019
- const contentBuffer = fs2.readFileSync(cacheDir + getFilenameByEntry(work.entry));
2020
- const workDistPath = path.resolve(distPath, getFilenameByEntry(work.entry));
2021
- fs2.writeFileSync(workDistPath, contentBuffer);
3452
+ const contentBuffer = fs.readFileSync(cacheDir + getFilenameByEntry(work.entry));
3453
+ const workDistPath = (0, import_path7.resolve)(distPath, getFilenameByEntry(work.entry));
3454
+ fs.writeFileSync(workDistPath, contentBuffer);
2022
3455
  }
2023
3456
  }
2024
3457
  };
@@ -2029,6 +3462,9 @@ function isCDN(publicPath) {
2029
3462
  }
2030
3463
  return false;
2031
3464
  }
3465
+
3466
+ // src/sharp/index.ts
3467
+ var import_node_path2 = __toESM(require("path"));
2032
3468
  function matches(filename, patterns) {
2033
3469
  if (!patterns || patterns.length === 0) return true;
2034
3470
  return patterns.some(
@@ -2060,7 +3496,7 @@ function sharpOptimize(options = {}) {
2060
3496
  async generateBundle(_opts, bundle) {
2061
3497
  for (const [fileName, asset] of Object.entries(bundle)) {
2062
3498
  if (asset.type !== "asset") continue;
2063
- const ext = path$1.extname(fileName).toLowerCase();
3499
+ const ext = import_node_path2.default.extname(fileName).toLowerCase();
2064
3500
  if (!imageExts.has(ext)) continue;
2065
3501
  if (exclude && matches(fileName, exclude)) continue;
2066
3502
  if (include && !matches(fileName, include)) continue;
@@ -2094,6 +3530,9 @@ function sharpOptimize(options = {}) {
2094
3530
  }
2095
3531
  };
2096
3532
  }
2097
- exports.federation = federation;
2098
- exports.monacoEditorPlugin = monacoEditorPlugin;
2099
- exports.sharpOptimize = sharpOptimize;
3533
+ // Annotate the CommonJS export names for ESM import in node:
3534
+ 0 && (module.exports = {
3535
+ federation,
3536
+ monacoEditorPlugin,
3537
+ sharpOptimize
3538
+ });