@softarc/native-federation-orchestrator 4.1.1 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2973 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+
27
+ // node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/debug.js
28
+ var require_debug = __commonJS({
29
+ "node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/debug.js"(exports, module) {
30
+ "use strict";
31
+ var debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {
32
+ };
33
+ module.exports = debug;
34
+ }
35
+ });
36
+
37
+ // node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/constants.js
38
+ var require_constants = __commonJS({
39
+ "node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/constants.js"(exports, module) {
40
+ "use strict";
41
+ var SEMVER_SPEC_VERSION = "2.0.0";
42
+ var MAX_LENGTH = 256;
43
+ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
44
+ 9007199254740991;
45
+ var MAX_SAFE_COMPONENT_LENGTH = 16;
46
+ var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
47
+ var RELEASE_TYPES = [
48
+ "major",
49
+ "premajor",
50
+ "minor",
51
+ "preminor",
52
+ "patch",
53
+ "prepatch",
54
+ "prerelease"
55
+ ];
56
+ module.exports = {
57
+ MAX_LENGTH,
58
+ MAX_SAFE_COMPONENT_LENGTH,
59
+ MAX_SAFE_BUILD_LENGTH,
60
+ MAX_SAFE_INTEGER,
61
+ RELEASE_TYPES,
62
+ SEMVER_SPEC_VERSION,
63
+ FLAG_INCLUDE_PRERELEASE: 1,
64
+ FLAG_LOOSE: 2
65
+ };
66
+ }
67
+ });
68
+
69
+ // node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/re.js
70
+ var require_re = __commonJS({
71
+ "node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/re.js"(exports, module) {
72
+ "use strict";
73
+ var {
74
+ MAX_SAFE_COMPONENT_LENGTH,
75
+ MAX_SAFE_BUILD_LENGTH,
76
+ MAX_LENGTH
77
+ } = require_constants();
78
+ var debug = require_debug();
79
+ exports = module.exports = {};
80
+ var re = exports.re = [];
81
+ var safeRe = exports.safeRe = [];
82
+ var src = exports.src = [];
83
+ var safeSrc = exports.safeSrc = [];
84
+ var t = exports.t = {};
85
+ var R = 0;
86
+ var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
87
+ var safeRegexReplacements = [
88
+ ["\\s", 1],
89
+ ["\\d", MAX_LENGTH],
90
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
91
+ ];
92
+ var makeSafeRegex = (value) => {
93
+ for (const [token, max] of safeRegexReplacements) {
94
+ value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
95
+ }
96
+ return value;
97
+ };
98
+ var createToken = (name, value, isGlobal) => {
99
+ const safe = makeSafeRegex(value);
100
+ const index = R++;
101
+ debug(name, index, value);
102
+ t[name] = index;
103
+ src[index] = value;
104
+ safeSrc[index] = safe;
105
+ re[index] = new RegExp(value, isGlobal ? "g" : void 0);
106
+ safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
107
+ };
108
+ createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
109
+ createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
110
+ createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
111
+ createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
112
+ createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
113
+ createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
114
+ createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
115
+ createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
116
+ createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
117
+ createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
118
+ createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
119
+ createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
120
+ createToken("FULL", `^${src[t.FULLPLAIN]}$`);
121
+ createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
122
+ createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
123
+ createToken("GTLT", "((?:<|>)?=?)");
124
+ createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
125
+ createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
126
+ createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
127
+ createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
128
+ createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
129
+ createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
130
+ createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
131
+ createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
132
+ createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
133
+ createToken("COERCERTL", src[t.COERCE], true);
134
+ createToken("COERCERTLFULL", src[t.COERCEFULL], true);
135
+ createToken("LONETILDE", "(?:~>?)");
136
+ createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
137
+ exports.tildeTrimReplace = "$1~";
138
+ createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
139
+ createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
140
+ createToken("LONECARET", "(?:\\^)");
141
+ createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
142
+ exports.caretTrimReplace = "$1^";
143
+ createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
144
+ createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
145
+ createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
146
+ createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
147
+ createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
148
+ exports.comparatorTrimReplace = "$1$2$3";
149
+ createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
150
+ createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
151
+ createToken("STAR", "(<|>)?=?\\s*\\*");
152
+ createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
153
+ createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
154
+ }
155
+ });
156
+
157
+ // node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/parse-options.js
158
+ var require_parse_options = __commonJS({
159
+ "node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/parse-options.js"(exports, module) {
160
+ "use strict";
161
+ var looseOption = Object.freeze({ loose: true });
162
+ var emptyOpts = Object.freeze({});
163
+ var parseOptions = (options) => {
164
+ if (!options) {
165
+ return emptyOpts;
166
+ }
167
+ if (typeof options !== "object") {
168
+ return looseOption;
169
+ }
170
+ return options;
171
+ };
172
+ module.exports = parseOptions;
173
+ }
174
+ });
175
+
176
+ // node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/identifiers.js
177
+ var require_identifiers = __commonJS({
178
+ "node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/identifiers.js"(exports, module) {
179
+ "use strict";
180
+ var numeric = /^[0-9]+$/;
181
+ var compareIdentifiers = (a, b) => {
182
+ if (typeof a === "number" && typeof b === "number") {
183
+ return a === b ? 0 : a < b ? -1 : 1;
184
+ }
185
+ const anum = numeric.test(a);
186
+ const bnum = numeric.test(b);
187
+ if (anum && bnum) {
188
+ a = +a;
189
+ b = +b;
190
+ }
191
+ return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
192
+ };
193
+ var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
194
+ module.exports = {
195
+ compareIdentifiers,
196
+ rcompareIdentifiers
197
+ };
198
+ }
199
+ });
200
+
201
+ // node_modules/.pnpm/semver@7.8.0/node_modules/semver/classes/semver.js
202
+ var require_semver = __commonJS({
203
+ "node_modules/.pnpm/semver@7.8.0/node_modules/semver/classes/semver.js"(exports, module) {
204
+ "use strict";
205
+ var debug = require_debug();
206
+ var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
207
+ var { safeRe: re, t } = require_re();
208
+ var parseOptions = require_parse_options();
209
+ var { compareIdentifiers } = require_identifiers();
210
+ var SemVer = class _SemVer {
211
+ constructor(version, options) {
212
+ options = parseOptions(options);
213
+ if (version instanceof _SemVer) {
214
+ if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
215
+ return version;
216
+ } else {
217
+ version = version.version;
218
+ }
219
+ } else if (typeof version !== "string") {
220
+ throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
221
+ }
222
+ if (version.length > MAX_LENGTH) {
223
+ throw new TypeError(
224
+ `version is longer than ${MAX_LENGTH} characters`
225
+ );
226
+ }
227
+ debug("SemVer", version, options);
228
+ this.options = options;
229
+ this.loose = !!options.loose;
230
+ this.includePrerelease = !!options.includePrerelease;
231
+ const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
232
+ if (!m) {
233
+ throw new TypeError(`Invalid Version: ${version}`);
234
+ }
235
+ this.raw = version;
236
+ this.major = +m[1];
237
+ this.minor = +m[2];
238
+ this.patch = +m[3];
239
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
240
+ throw new TypeError("Invalid major version");
241
+ }
242
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
243
+ throw new TypeError("Invalid minor version");
244
+ }
245
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
246
+ throw new TypeError("Invalid patch version");
247
+ }
248
+ if (!m[4]) {
249
+ this.prerelease = [];
250
+ } else {
251
+ this.prerelease = m[4].split(".").map((id) => {
252
+ if (/^[0-9]+$/.test(id)) {
253
+ const num = +id;
254
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
255
+ return num;
256
+ }
257
+ }
258
+ return id;
259
+ });
260
+ }
261
+ this.build = m[5] ? m[5].split(".") : [];
262
+ this.format();
263
+ }
264
+ format() {
265
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
266
+ if (this.prerelease.length) {
267
+ this.version += `-${this.prerelease.join(".")}`;
268
+ }
269
+ return this.version;
270
+ }
271
+ toString() {
272
+ return this.version;
273
+ }
274
+ compare(other) {
275
+ debug("SemVer.compare", this.version, this.options, other);
276
+ if (!(other instanceof _SemVer)) {
277
+ if (typeof other === "string" && other === this.version) {
278
+ return 0;
279
+ }
280
+ other = new _SemVer(other, this.options);
281
+ }
282
+ if (other.version === this.version) {
283
+ return 0;
284
+ }
285
+ return this.compareMain(other) || this.comparePre(other);
286
+ }
287
+ compareMain(other) {
288
+ if (!(other instanceof _SemVer)) {
289
+ other = new _SemVer(other, this.options);
290
+ }
291
+ if (this.major < other.major) {
292
+ return -1;
293
+ }
294
+ if (this.major > other.major) {
295
+ return 1;
296
+ }
297
+ if (this.minor < other.minor) {
298
+ return -1;
299
+ }
300
+ if (this.minor > other.minor) {
301
+ return 1;
302
+ }
303
+ if (this.patch < other.patch) {
304
+ return -1;
305
+ }
306
+ if (this.patch > other.patch) {
307
+ return 1;
308
+ }
309
+ return 0;
310
+ }
311
+ comparePre(other) {
312
+ if (!(other instanceof _SemVer)) {
313
+ other = new _SemVer(other, this.options);
314
+ }
315
+ if (this.prerelease.length && !other.prerelease.length) {
316
+ return -1;
317
+ } else if (!this.prerelease.length && other.prerelease.length) {
318
+ return 1;
319
+ } else if (!this.prerelease.length && !other.prerelease.length) {
320
+ return 0;
321
+ }
322
+ let i = 0;
323
+ do {
324
+ const a = this.prerelease[i];
325
+ const b = other.prerelease[i];
326
+ debug("prerelease compare", i, a, b);
327
+ if (a === void 0 && b === void 0) {
328
+ return 0;
329
+ } else if (b === void 0) {
330
+ return 1;
331
+ } else if (a === void 0) {
332
+ return -1;
333
+ } else if (a === b) {
334
+ continue;
335
+ } else {
336
+ return compareIdentifiers(a, b);
337
+ }
338
+ } while (++i);
339
+ }
340
+ compareBuild(other) {
341
+ if (!(other instanceof _SemVer)) {
342
+ other = new _SemVer(other, this.options);
343
+ }
344
+ let i = 0;
345
+ do {
346
+ const a = this.build[i];
347
+ const b = other.build[i];
348
+ debug("build compare", i, a, b);
349
+ if (a === void 0 && b === void 0) {
350
+ return 0;
351
+ } else if (b === void 0) {
352
+ return 1;
353
+ } else if (a === void 0) {
354
+ return -1;
355
+ } else if (a === b) {
356
+ continue;
357
+ } else {
358
+ return compareIdentifiers(a, b);
359
+ }
360
+ } while (++i);
361
+ }
362
+ // preminor will bump the version up to the next minor release, and immediately
363
+ // down to pre-release. premajor and prepatch work the same way.
364
+ inc(release, identifier, identifierBase) {
365
+ if (release.startsWith("pre")) {
366
+ if (!identifier && identifierBase === false) {
367
+ throw new Error("invalid increment argument: identifier is empty");
368
+ }
369
+ if (identifier) {
370
+ const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
371
+ if (!match || match[1] !== identifier) {
372
+ throw new Error(`invalid identifier: ${identifier}`);
373
+ }
374
+ }
375
+ }
376
+ switch (release) {
377
+ case "premajor":
378
+ this.prerelease.length = 0;
379
+ this.patch = 0;
380
+ this.minor = 0;
381
+ this.major++;
382
+ this.inc("pre", identifier, identifierBase);
383
+ break;
384
+ case "preminor":
385
+ this.prerelease.length = 0;
386
+ this.patch = 0;
387
+ this.minor++;
388
+ this.inc("pre", identifier, identifierBase);
389
+ break;
390
+ case "prepatch":
391
+ this.prerelease.length = 0;
392
+ this.inc("patch", identifier, identifierBase);
393
+ this.inc("pre", identifier, identifierBase);
394
+ break;
395
+ // If the input is a non-prerelease version, this acts the same as
396
+ // prepatch.
397
+ case "prerelease":
398
+ if (this.prerelease.length === 0) {
399
+ this.inc("patch", identifier, identifierBase);
400
+ }
401
+ this.inc("pre", identifier, identifierBase);
402
+ break;
403
+ case "release":
404
+ if (this.prerelease.length === 0) {
405
+ throw new Error(`version ${this.raw} is not a prerelease`);
406
+ }
407
+ this.prerelease.length = 0;
408
+ break;
409
+ case "major":
410
+ if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
411
+ this.major++;
412
+ }
413
+ this.minor = 0;
414
+ this.patch = 0;
415
+ this.prerelease = [];
416
+ break;
417
+ case "minor":
418
+ if (this.patch !== 0 || this.prerelease.length === 0) {
419
+ this.minor++;
420
+ }
421
+ this.patch = 0;
422
+ this.prerelease = [];
423
+ break;
424
+ case "patch":
425
+ if (this.prerelease.length === 0) {
426
+ this.patch++;
427
+ }
428
+ this.prerelease = [];
429
+ break;
430
+ // This probably shouldn't be used publicly.
431
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
432
+ case "pre": {
433
+ const base = Number(identifierBase) ? 1 : 0;
434
+ if (this.prerelease.length === 0) {
435
+ this.prerelease = [base];
436
+ } else {
437
+ let i = this.prerelease.length;
438
+ while (--i >= 0) {
439
+ if (typeof this.prerelease[i] === "number") {
440
+ this.prerelease[i]++;
441
+ i = -2;
442
+ }
443
+ }
444
+ if (i === -1) {
445
+ if (identifier === this.prerelease.join(".") && identifierBase === false) {
446
+ throw new Error("invalid increment argument: identifier already exists");
447
+ }
448
+ this.prerelease.push(base);
449
+ }
450
+ }
451
+ if (identifier) {
452
+ let prerelease = [identifier, base];
453
+ if (identifierBase === false) {
454
+ prerelease = [identifier];
455
+ }
456
+ if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
457
+ if (isNaN(this.prerelease[1])) {
458
+ this.prerelease = prerelease;
459
+ }
460
+ } else {
461
+ this.prerelease = prerelease;
462
+ }
463
+ }
464
+ break;
465
+ }
466
+ default:
467
+ throw new Error(`invalid increment argument: ${release}`);
468
+ }
469
+ this.raw = this.format();
470
+ if (this.build.length) {
471
+ this.raw += `+${this.build.join(".")}`;
472
+ }
473
+ return this;
474
+ }
475
+ };
476
+ module.exports = SemVer;
477
+ }
478
+ });
479
+
480
+ // node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/parse.js
481
+ var require_parse = __commonJS({
482
+ "node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/parse.js"(exports, module) {
483
+ "use strict";
484
+ var SemVer = require_semver();
485
+ var parse = (version, options, throwErrors = false) => {
486
+ if (version instanceof SemVer) {
487
+ return version;
488
+ }
489
+ try {
490
+ return new SemVer(version, options);
491
+ } catch (er) {
492
+ if (!throwErrors) {
493
+ return null;
494
+ }
495
+ throw er;
496
+ }
497
+ };
498
+ module.exports = parse;
499
+ }
500
+ });
501
+
502
+ // node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/valid.js
503
+ var require_valid = __commonJS({
504
+ "node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/valid.js"(exports, module) {
505
+ "use strict";
506
+ var parse = require_parse();
507
+ var valid = (version, options) => {
508
+ const v = parse(version, options);
509
+ return v ? v.version : null;
510
+ };
511
+ module.exports = valid;
512
+ }
513
+ });
514
+
515
+ // node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/lrucache.js
516
+ var require_lrucache = __commonJS({
517
+ "node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/lrucache.js"(exports, module) {
518
+ "use strict";
519
+ var LRUCache = class {
520
+ constructor() {
521
+ this.max = 1e3;
522
+ this.map = /* @__PURE__ */ new Map();
523
+ }
524
+ get(key) {
525
+ const value = this.map.get(key);
526
+ if (value === void 0) {
527
+ return void 0;
528
+ } else {
529
+ this.map.delete(key);
530
+ this.map.set(key, value);
531
+ return value;
532
+ }
533
+ }
534
+ delete(key) {
535
+ return this.map.delete(key);
536
+ }
537
+ set(key, value) {
538
+ const deleted = this.delete(key);
539
+ if (!deleted && value !== void 0) {
540
+ if (this.map.size >= this.max) {
541
+ const firstKey = this.map.keys().next().value;
542
+ this.delete(firstKey);
543
+ }
544
+ this.map.set(key, value);
545
+ }
546
+ return this;
547
+ }
548
+ };
549
+ module.exports = LRUCache;
550
+ }
551
+ });
552
+
553
+ // node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/compare.js
554
+ var require_compare = __commonJS({
555
+ "node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/compare.js"(exports, module) {
556
+ "use strict";
557
+ var SemVer = require_semver();
558
+ var compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
559
+ module.exports = compare;
560
+ }
561
+ });
562
+
563
+ // node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/eq.js
564
+ var require_eq = __commonJS({
565
+ "node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/eq.js"(exports, module) {
566
+ "use strict";
567
+ var compare = require_compare();
568
+ var eq = (a, b, loose) => compare(a, b, loose) === 0;
569
+ module.exports = eq;
570
+ }
571
+ });
572
+
573
+ // node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/neq.js
574
+ var require_neq = __commonJS({
575
+ "node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/neq.js"(exports, module) {
576
+ "use strict";
577
+ var compare = require_compare();
578
+ var neq = (a, b, loose) => compare(a, b, loose) !== 0;
579
+ module.exports = neq;
580
+ }
581
+ });
582
+
583
+ // node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/gt.js
584
+ var require_gt = __commonJS({
585
+ "node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/gt.js"(exports, module) {
586
+ "use strict";
587
+ var compare = require_compare();
588
+ var gt = (a, b, loose) => compare(a, b, loose) > 0;
589
+ module.exports = gt;
590
+ }
591
+ });
592
+
593
+ // node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/gte.js
594
+ var require_gte = __commonJS({
595
+ "node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/gte.js"(exports, module) {
596
+ "use strict";
597
+ var compare = require_compare();
598
+ var gte = (a, b, loose) => compare(a, b, loose) >= 0;
599
+ module.exports = gte;
600
+ }
601
+ });
602
+
603
+ // node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/lt.js
604
+ var require_lt = __commonJS({
605
+ "node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/lt.js"(exports, module) {
606
+ "use strict";
607
+ var compare = require_compare();
608
+ var lt = (a, b, loose) => compare(a, b, loose) < 0;
609
+ module.exports = lt;
610
+ }
611
+ });
612
+
613
+ // node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/lte.js
614
+ var require_lte = __commonJS({
615
+ "node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/lte.js"(exports, module) {
616
+ "use strict";
617
+ var compare = require_compare();
618
+ var lte = (a, b, loose) => compare(a, b, loose) <= 0;
619
+ module.exports = lte;
620
+ }
621
+ });
622
+
623
+ // node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/cmp.js
624
+ var require_cmp = __commonJS({
625
+ "node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/cmp.js"(exports, module) {
626
+ "use strict";
627
+ var eq = require_eq();
628
+ var neq = require_neq();
629
+ var gt = require_gt();
630
+ var gte = require_gte();
631
+ var lt = require_lt();
632
+ var lte = require_lte();
633
+ var cmp = (a, op, b, loose) => {
634
+ switch (op) {
635
+ case "===":
636
+ if (typeof a === "object") {
637
+ a = a.version;
638
+ }
639
+ if (typeof b === "object") {
640
+ b = b.version;
641
+ }
642
+ return a === b;
643
+ case "!==":
644
+ if (typeof a === "object") {
645
+ a = a.version;
646
+ }
647
+ if (typeof b === "object") {
648
+ b = b.version;
649
+ }
650
+ return a !== b;
651
+ case "":
652
+ case "=":
653
+ case "==":
654
+ return eq(a, b, loose);
655
+ case "!=":
656
+ return neq(a, b, loose);
657
+ case ">":
658
+ return gt(a, b, loose);
659
+ case ">=":
660
+ return gte(a, b, loose);
661
+ case "<":
662
+ return lt(a, b, loose);
663
+ case "<=":
664
+ return lte(a, b, loose);
665
+ default:
666
+ throw new TypeError(`Invalid operator: ${op}`);
667
+ }
668
+ };
669
+ module.exports = cmp;
670
+ }
671
+ });
672
+
673
+ // node_modules/.pnpm/semver@7.8.0/node_modules/semver/classes/comparator.js
674
+ var require_comparator = __commonJS({
675
+ "node_modules/.pnpm/semver@7.8.0/node_modules/semver/classes/comparator.js"(exports, module) {
676
+ "use strict";
677
+ var ANY = /* @__PURE__ */ Symbol("SemVer ANY");
678
+ var Comparator = class _Comparator {
679
+ static get ANY() {
680
+ return ANY;
681
+ }
682
+ constructor(comp, options) {
683
+ options = parseOptions(options);
684
+ if (comp instanceof _Comparator) {
685
+ if (comp.loose === !!options.loose) {
686
+ return comp;
687
+ } else {
688
+ comp = comp.value;
689
+ }
690
+ }
691
+ comp = comp.trim().split(/\s+/).join(" ");
692
+ debug("comparator", comp, options);
693
+ this.options = options;
694
+ this.loose = !!options.loose;
695
+ this.parse(comp);
696
+ if (this.semver === ANY) {
697
+ this.value = "";
698
+ } else {
699
+ this.value = this.operator + this.semver.version;
700
+ }
701
+ debug("comp", this);
702
+ }
703
+ parse(comp) {
704
+ const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
705
+ const m = comp.match(r);
706
+ if (!m) {
707
+ throw new TypeError(`Invalid comparator: ${comp}`);
708
+ }
709
+ this.operator = m[1] !== void 0 ? m[1] : "";
710
+ if (this.operator === "=") {
711
+ this.operator = "";
712
+ }
713
+ if (!m[2]) {
714
+ this.semver = ANY;
715
+ } else {
716
+ this.semver = new SemVer(m[2], this.options.loose);
717
+ }
718
+ }
719
+ toString() {
720
+ return this.value;
721
+ }
722
+ test(version) {
723
+ debug("Comparator.test", version, this.options.loose);
724
+ if (this.semver === ANY || version === ANY) {
725
+ return true;
726
+ }
727
+ if (typeof version === "string") {
728
+ try {
729
+ version = new SemVer(version, this.options);
730
+ } catch (er) {
731
+ return false;
732
+ }
733
+ }
734
+ return cmp(version, this.operator, this.semver, this.options);
735
+ }
736
+ intersects(comp, options) {
737
+ if (!(comp instanceof _Comparator)) {
738
+ throw new TypeError("a Comparator is required");
739
+ }
740
+ if (this.operator === "") {
741
+ if (this.value === "") {
742
+ return true;
743
+ }
744
+ return new Range(comp.value, options).test(this.value);
745
+ } else if (comp.operator === "") {
746
+ if (comp.value === "") {
747
+ return true;
748
+ }
749
+ return new Range(this.value, options).test(comp.semver);
750
+ }
751
+ options = parseOptions(options);
752
+ if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) {
753
+ return false;
754
+ }
755
+ if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) {
756
+ return false;
757
+ }
758
+ if (this.operator.startsWith(">") && comp.operator.startsWith(">")) {
759
+ return true;
760
+ }
761
+ if (this.operator.startsWith("<") && comp.operator.startsWith("<")) {
762
+ return true;
763
+ }
764
+ if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) {
765
+ return true;
766
+ }
767
+ if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) {
768
+ return true;
769
+ }
770
+ if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) {
771
+ return true;
772
+ }
773
+ return false;
774
+ }
775
+ };
776
+ module.exports = Comparator;
777
+ var parseOptions = require_parse_options();
778
+ var { safeRe: re, t } = require_re();
779
+ var cmp = require_cmp();
780
+ var debug = require_debug();
781
+ var SemVer = require_semver();
782
+ var Range = require_range();
783
+ }
784
+ });
785
+
786
+ // node_modules/.pnpm/semver@7.8.0/node_modules/semver/classes/range.js
787
+ var require_range = __commonJS({
788
+ "node_modules/.pnpm/semver@7.8.0/node_modules/semver/classes/range.js"(exports, module) {
789
+ "use strict";
790
+ var SPACE_CHARACTERS = /\s+/g;
791
+ var Range = class _Range {
792
+ constructor(range, options) {
793
+ options = parseOptions(options);
794
+ if (range instanceof _Range) {
795
+ if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
796
+ return range;
797
+ } else {
798
+ return new _Range(range.raw, options);
799
+ }
800
+ }
801
+ if (range instanceof Comparator) {
802
+ this.raw = range.value;
803
+ this.set = [[range]];
804
+ this.formatted = void 0;
805
+ return this;
806
+ }
807
+ this.options = options;
808
+ this.loose = !!options.loose;
809
+ this.includePrerelease = !!options.includePrerelease;
810
+ this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
811
+ this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
812
+ if (!this.set.length) {
813
+ throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
814
+ }
815
+ if (this.set.length > 1) {
816
+ const first = this.set[0];
817
+ this.set = this.set.filter((c) => !isNullSet(c[0]));
818
+ if (this.set.length === 0) {
819
+ this.set = [first];
820
+ } else if (this.set.length > 1) {
821
+ for (const c of this.set) {
822
+ if (c.length === 1 && isAny(c[0])) {
823
+ this.set = [c];
824
+ break;
825
+ }
826
+ }
827
+ }
828
+ }
829
+ this.formatted = void 0;
830
+ }
831
+ get range() {
832
+ if (this.formatted === void 0) {
833
+ this.formatted = "";
834
+ for (let i = 0; i < this.set.length; i++) {
835
+ if (i > 0) {
836
+ this.formatted += "||";
837
+ }
838
+ const comps = this.set[i];
839
+ for (let k = 0; k < comps.length; k++) {
840
+ if (k > 0) {
841
+ this.formatted += " ";
842
+ }
843
+ this.formatted += comps[k].toString().trim();
844
+ }
845
+ }
846
+ }
847
+ return this.formatted;
848
+ }
849
+ format() {
850
+ return this.range;
851
+ }
852
+ toString() {
853
+ return this.range;
854
+ }
855
+ parseRange(range) {
856
+ const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
857
+ const memoKey = memoOpts + ":" + range;
858
+ const cached2 = cache.get(memoKey);
859
+ if (cached2) {
860
+ return cached2;
861
+ }
862
+ const loose = this.options.loose;
863
+ const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
864
+ range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
865
+ debug("hyphen replace", range);
866
+ range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
867
+ debug("comparator trim", range);
868
+ range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
869
+ debug("tilde trim", range);
870
+ range = range.replace(re[t.CARETTRIM], caretTrimReplace);
871
+ debug("caret trim", range);
872
+ let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
873
+ if (loose) {
874
+ rangeList = rangeList.filter((comp) => {
875
+ debug("loose invalid filter", comp, this.options);
876
+ return !!comp.match(re[t.COMPARATORLOOSE]);
877
+ });
878
+ }
879
+ debug("range list", rangeList);
880
+ const rangeMap = /* @__PURE__ */ new Map();
881
+ const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
882
+ for (const comp of comparators) {
883
+ if (isNullSet(comp)) {
884
+ return [comp];
885
+ }
886
+ rangeMap.set(comp.value, comp);
887
+ }
888
+ if (rangeMap.size > 1 && rangeMap.has("")) {
889
+ rangeMap.delete("");
890
+ }
891
+ const result = [...rangeMap.values()];
892
+ cache.set(memoKey, result);
893
+ return result;
894
+ }
895
+ intersects(range, options) {
896
+ if (!(range instanceof _Range)) {
897
+ throw new TypeError("a Range is required");
898
+ }
899
+ return this.set.some((thisComparators) => {
900
+ return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
901
+ return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
902
+ return rangeComparators.every((rangeComparator) => {
903
+ return thisComparator.intersects(rangeComparator, options);
904
+ });
905
+ });
906
+ });
907
+ });
908
+ }
909
+ // if ANY of the sets match ALL of its comparators, then pass
910
+ test(version) {
911
+ if (!version) {
912
+ return false;
913
+ }
914
+ if (typeof version === "string") {
915
+ try {
916
+ version = new SemVer(version, this.options);
917
+ } catch (er) {
918
+ return false;
919
+ }
920
+ }
921
+ for (let i = 0; i < this.set.length; i++) {
922
+ if (testSet(this.set[i], version, this.options)) {
923
+ return true;
924
+ }
925
+ }
926
+ return false;
927
+ }
928
+ };
929
+ module.exports = Range;
930
+ var LRU = require_lrucache();
931
+ var cache = new LRU();
932
+ var parseOptions = require_parse_options();
933
+ var Comparator = require_comparator();
934
+ var debug = require_debug();
935
+ var SemVer = require_semver();
936
+ var {
937
+ safeRe: re,
938
+ t,
939
+ comparatorTrimReplace,
940
+ tildeTrimReplace,
941
+ caretTrimReplace
942
+ } = require_re();
943
+ var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
944
+ var isNullSet = (c) => c.value === "<0.0.0-0";
945
+ var isAny = (c) => c.value === "";
946
+ var isSatisfiable = (comparators, options) => {
947
+ let result = true;
948
+ const remainingComparators = comparators.slice();
949
+ let testComparator = remainingComparators.pop();
950
+ while (result && remainingComparators.length) {
951
+ result = remainingComparators.every((otherComparator) => {
952
+ return testComparator.intersects(otherComparator, options);
953
+ });
954
+ testComparator = remainingComparators.pop();
955
+ }
956
+ return result;
957
+ };
958
+ var parseComparator = (comp, options) => {
959
+ comp = comp.replace(re[t.BUILD], "");
960
+ debug("comp", comp, options);
961
+ comp = replaceCarets(comp, options);
962
+ debug("caret", comp);
963
+ comp = replaceTildes(comp, options);
964
+ debug("tildes", comp);
965
+ comp = replaceXRanges(comp, options);
966
+ debug("xrange", comp);
967
+ comp = replaceStars(comp, options);
968
+ debug("stars", comp);
969
+ return comp;
970
+ };
971
+ var isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
972
+ var replaceTildes = (comp, options) => {
973
+ return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
974
+ };
975
+ var replaceTilde = (comp, options) => {
976
+ const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
977
+ return comp.replace(r, (_, M, m, p, pr) => {
978
+ debug("tilde", comp, _, M, m, p, pr);
979
+ let ret;
980
+ if (isX(M)) {
981
+ ret = "";
982
+ } else if (isX(m)) {
983
+ ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
984
+ } else if (isX(p)) {
985
+ ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
986
+ } else if (pr) {
987
+ debug("replaceTilde pr", pr);
988
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
989
+ } else {
990
+ ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
991
+ }
992
+ debug("tilde return", ret);
993
+ return ret;
994
+ });
995
+ };
996
+ var replaceCarets = (comp, options) => {
997
+ return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
998
+ };
999
+ var replaceCaret = (comp, options) => {
1000
+ debug("caret", comp, options);
1001
+ const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
1002
+ const z = options.includePrerelease ? "-0" : "";
1003
+ return comp.replace(r, (_, M, m, p, pr) => {
1004
+ debug("caret", comp, _, M, m, p, pr);
1005
+ let ret;
1006
+ if (isX(M)) {
1007
+ ret = "";
1008
+ } else if (isX(m)) {
1009
+ ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
1010
+ } else if (isX(p)) {
1011
+ if (M === "0") {
1012
+ ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
1013
+ } else {
1014
+ ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
1015
+ }
1016
+ } else if (pr) {
1017
+ debug("replaceCaret pr", pr);
1018
+ if (M === "0") {
1019
+ if (m === "0") {
1020
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
1021
+ } else {
1022
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
1023
+ }
1024
+ } else {
1025
+ ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
1026
+ }
1027
+ } else {
1028
+ debug("no pr");
1029
+ if (M === "0") {
1030
+ if (m === "0") {
1031
+ ret = `>=${M}.${m}.${p}${z} <${M}.${m}.${+p + 1}-0`;
1032
+ } else {
1033
+ ret = `>=${M}.${m}.${p}${z} <${M}.${+m + 1}.0-0`;
1034
+ }
1035
+ } else {
1036
+ ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
1037
+ }
1038
+ }
1039
+ debug("caret return", ret);
1040
+ return ret;
1041
+ });
1042
+ };
1043
+ var replaceXRanges = (comp, options) => {
1044
+ debug("replaceXRanges", comp, options);
1045
+ return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
1046
+ };
1047
+ var replaceXRange = (comp, options) => {
1048
+ comp = comp.trim();
1049
+ const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
1050
+ return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
1051
+ debug("xRange", comp, ret, gtlt, M, m, p, pr);
1052
+ const xM = isX(M);
1053
+ const xm = xM || isX(m);
1054
+ const xp = xm || isX(p);
1055
+ const anyX = xp;
1056
+ if (gtlt === "=" && anyX) {
1057
+ gtlt = "";
1058
+ }
1059
+ pr = options.includePrerelease ? "-0" : "";
1060
+ if (xM) {
1061
+ if (gtlt === ">" || gtlt === "<") {
1062
+ ret = "<0.0.0-0";
1063
+ } else {
1064
+ ret = "*";
1065
+ }
1066
+ } else if (gtlt && anyX) {
1067
+ if (xm) {
1068
+ m = 0;
1069
+ }
1070
+ p = 0;
1071
+ if (gtlt === ">") {
1072
+ gtlt = ">=";
1073
+ if (xm) {
1074
+ M = +M + 1;
1075
+ m = 0;
1076
+ p = 0;
1077
+ } else {
1078
+ m = +m + 1;
1079
+ p = 0;
1080
+ }
1081
+ } else if (gtlt === "<=") {
1082
+ gtlt = "<";
1083
+ if (xm) {
1084
+ M = +M + 1;
1085
+ } else {
1086
+ m = +m + 1;
1087
+ }
1088
+ }
1089
+ if (gtlt === "<") {
1090
+ pr = "-0";
1091
+ }
1092
+ ret = `${gtlt + M}.${m}.${p}${pr}`;
1093
+ } else if (xm) {
1094
+ ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
1095
+ } else if (xp) {
1096
+ ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
1097
+ }
1098
+ debug("xRange return", ret);
1099
+ return ret;
1100
+ });
1101
+ };
1102
+ var replaceStars = (comp, options) => {
1103
+ debug("replaceStars", comp, options);
1104
+ return comp.trim().replace(re[t.STAR], "");
1105
+ };
1106
+ var replaceGTE0 = (comp, options) => {
1107
+ debug("replaceGTE0", comp, options);
1108
+ return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
1109
+ };
1110
+ var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
1111
+ if (isX(fM)) {
1112
+ from = "";
1113
+ } else if (isX(fm)) {
1114
+ from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
1115
+ } else if (isX(fp)) {
1116
+ from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
1117
+ } else if (fpr) {
1118
+ from = `>=${from}`;
1119
+ } else {
1120
+ from = `>=${from}${incPr ? "-0" : ""}`;
1121
+ }
1122
+ if (isX(tM)) {
1123
+ to = "";
1124
+ } else if (isX(tm)) {
1125
+ to = `<${+tM + 1}.0.0-0`;
1126
+ } else if (isX(tp)) {
1127
+ to = `<${tM}.${+tm + 1}.0-0`;
1128
+ } else if (tpr) {
1129
+ to = `<=${tM}.${tm}.${tp}-${tpr}`;
1130
+ } else if (incPr) {
1131
+ to = `<${tM}.${tm}.${+tp + 1}-0`;
1132
+ } else {
1133
+ to = `<=${to}`;
1134
+ }
1135
+ return `${from} ${to}`.trim();
1136
+ };
1137
+ var testSet = (set, version, options) => {
1138
+ for (let i = 0; i < set.length; i++) {
1139
+ if (!set[i].test(version)) {
1140
+ return false;
1141
+ }
1142
+ }
1143
+ if (version.prerelease.length && !options.includePrerelease) {
1144
+ for (let i = 0; i < set.length; i++) {
1145
+ debug(set[i].semver);
1146
+ if (set[i].semver === Comparator.ANY) {
1147
+ continue;
1148
+ }
1149
+ if (set[i].semver.prerelease.length > 0) {
1150
+ const allowed = set[i].semver;
1151
+ if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
1152
+ return true;
1153
+ }
1154
+ }
1155
+ }
1156
+ return false;
1157
+ }
1158
+ return true;
1159
+ };
1160
+ }
1161
+ });
1162
+
1163
+ // node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/satisfies.js
1164
+ var require_satisfies = __commonJS({
1165
+ "node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/satisfies.js"(exports, module) {
1166
+ "use strict";
1167
+ var Range = require_range();
1168
+ var satisfies = (version, range, options) => {
1169
+ try {
1170
+ range = new Range(range, options);
1171
+ } catch (er) {
1172
+ return false;
1173
+ }
1174
+ return range.test(version);
1175
+ };
1176
+ module.exports = satisfies;
1177
+ }
1178
+ });
1179
+
1180
+ // node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/min-version.js
1181
+ var require_min_version = __commonJS({
1182
+ "node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/min-version.js"(exports, module) {
1183
+ "use strict";
1184
+ var SemVer = require_semver();
1185
+ var Range = require_range();
1186
+ var gt = require_gt();
1187
+ var minVersion = (range, loose) => {
1188
+ range = new Range(range, loose);
1189
+ let minver = new SemVer("0.0.0");
1190
+ if (range.test(minver)) {
1191
+ return minver;
1192
+ }
1193
+ minver = new SemVer("0.0.0-0");
1194
+ if (range.test(minver)) {
1195
+ return minver;
1196
+ }
1197
+ minver = null;
1198
+ for (let i = 0; i < range.set.length; ++i) {
1199
+ const comparators = range.set[i];
1200
+ let setMin = null;
1201
+ comparators.forEach((comparator) => {
1202
+ const compver = new SemVer(comparator.semver.version);
1203
+ switch (comparator.operator) {
1204
+ case ">":
1205
+ if (compver.prerelease.length === 0) {
1206
+ compver.patch++;
1207
+ } else {
1208
+ compver.prerelease.push(0);
1209
+ }
1210
+ compver.raw = compver.format();
1211
+ /* fallthrough */
1212
+ case "":
1213
+ case ">=":
1214
+ if (!setMin || gt(compver, setMin)) {
1215
+ setMin = compver;
1216
+ }
1217
+ break;
1218
+ case "<":
1219
+ case "<=":
1220
+ break;
1221
+ /* istanbul ignore next */
1222
+ default:
1223
+ throw new Error(`Unexpected operation: ${comparator.operator}`);
1224
+ }
1225
+ });
1226
+ if (setMin && (!minver || gt(minver, setMin))) {
1227
+ minver = setMin;
1228
+ }
1229
+ }
1230
+ if (minver && range.test(minver)) {
1231
+ return minver;
1232
+ }
1233
+ return null;
1234
+ };
1235
+ module.exports = minVersion;
1236
+ }
1237
+ });
1238
+
1239
+ // node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/valid.js
1240
+ var require_valid2 = __commonJS({
1241
+ "node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/valid.js"(exports, module) {
1242
+ "use strict";
1243
+ var Range = require_range();
1244
+ var validRange = (range, options) => {
1245
+ try {
1246
+ return new Range(range, options).range || "*";
1247
+ } catch (er) {
1248
+ return null;
1249
+ }
1250
+ };
1251
+ module.exports = validRange;
1252
+ }
1253
+ });
1254
+
1255
+ // src/lib/3.adapters/browser/browser.ts
1256
+ var createBrowser = (config) => {
1257
+ return {
1258
+ setImportMapFn: config.setImportMapFn,
1259
+ importModule: config.loadModuleFn
1260
+ };
1261
+ };
1262
+
1263
+ // src/lib/3.adapters/checks/version.check.ts
1264
+ var import_valid = __toESM(require_valid());
1265
+ var import_satisfies = __toESM(require_satisfies());
1266
+ var import_compare = __toESM(require_compare());
1267
+ var import_min_version = __toESM(require_min_version());
1268
+ var import_valid2 = __toESM(require_valid2());
1269
+ var createVersionCheck = () => {
1270
+ return {
1271
+ isValidSemver: function(version) {
1272
+ return (0, import_valid.default)(version) !== null;
1273
+ },
1274
+ isCompatible: function(version, range) {
1275
+ return (0, import_satisfies.default)(version, range);
1276
+ },
1277
+ compare: function(versionA, versionB) {
1278
+ return (0, import_compare.default)(versionA, versionB, true);
1279
+ },
1280
+ smallestVersion: function(versionRange) {
1281
+ if (!(0, import_valid2.default)(versionRange)) return "0.0.0";
1282
+ const minVersion = (0, import_min_version.default)(versionRange);
1283
+ return minVersion?.raw ?? "0.0.0";
1284
+ }
1285
+ };
1286
+ };
1287
+
1288
+ // src/lib/native-federation.error.ts
1289
+ var NFError = class extends Error {
1290
+ constructor(message, cause) {
1291
+ super(message, cause);
1292
+ this.name = "NFError";
1293
+ }
1294
+ };
1295
+
1296
+ // src/lib/utils/integrity.ts
1297
+ var SUPPORTED_ALGORITHMS = {
1298
+ "sha256-": "SHA-256",
1299
+ "sha384-": "SHA-384",
1300
+ "sha512-": "SHA-512"
1301
+ };
1302
+ var parseIntegrity = (integrity) => {
1303
+ for (const prefix of Object.keys(SUPPORTED_ALGORITHMS)) {
1304
+ if (integrity.startsWith(prefix)) {
1305
+ return { algorithm: SUPPORTED_ALGORITHMS[prefix], expected: integrity };
1306
+ }
1307
+ }
1308
+ return null;
1309
+ };
1310
+ var toBase64 = (bytes) => {
1311
+ const view = new Uint8Array(bytes);
1312
+ let bin = "";
1313
+ for (let i = 0; i < view.length; i++) bin += String.fromCharCode(view[i]);
1314
+ return btoa(bin);
1315
+ };
1316
+ var verifyIntegrity = async (bytes, integrity) => {
1317
+ const parsed = parseIntegrity(integrity);
1318
+ if (!parsed) {
1319
+ throw new TypeError(
1320
+ `Unsupported integrity prefix in '${integrity}'. Expected sha256-, sha384-, or sha512-.`
1321
+ );
1322
+ }
1323
+ const subtle = typeof crypto !== "undefined" && crypto.subtle ? crypto.subtle : void 0;
1324
+ if (!subtle) {
1325
+ throw new Error("SubtleCrypto is not available in this environment.");
1326
+ }
1327
+ const digest = await subtle.digest(parsed.algorithm, bytes);
1328
+ const actual = integrity.substring(0, integrity.indexOf("-") + 1) + toBase64(digest);
1329
+ if (actual !== parsed.expected) {
1330
+ throw new Error(`Integrity mismatch: expected ${parsed.expected}, got ${actual}`);
1331
+ }
1332
+ };
1333
+
1334
+ // src/lib/utils/node/read-source.ts
1335
+ import * as fs from "node:fs/promises";
1336
+ import { fileURLToPath } from "node:url";
1337
+ var isHttpUrl = (input) => input.startsWith("http://") || input.startsWith("https://");
1338
+ var isFileUrl = (input) => input.startsWith("file://");
1339
+ var readSourceBytes = async (input) => {
1340
+ if (isHttpUrl(input)) {
1341
+ const response = await fetch(input);
1342
+ if (!response.ok) {
1343
+ throw new NFError(`${response.status} - ${response.statusText}`);
1344
+ }
1345
+ return response.arrayBuffer();
1346
+ }
1347
+ const path = isFileUrl(input) ? fileURLToPath(input) : input;
1348
+ const buffer = await fs.readFile(path);
1349
+ return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
1350
+ };
1351
+
1352
+ // src/lib/3.adapters/node/fs-manifest-provider.ts
1353
+ var createFsManifestProvider = () => {
1354
+ const formatError = (manifestUrl) => (err) => {
1355
+ if (err instanceof NFError) throw err;
1356
+ const msg = err instanceof Error ? err.message : String(err);
1357
+ throw new NFError(`Read of '${manifestUrl}' returned ${msg}`);
1358
+ };
1359
+ return {
1360
+ provide: async function(remotesOrManifestUrl, opts = {}) {
1361
+ if (typeof remotesOrManifestUrl !== "string") return remotesOrManifestUrl;
1362
+ try {
1363
+ const bytes = await readSourceBytes(remotesOrManifestUrl);
1364
+ if (opts.integrity) await verifyIntegrity(bytes, opts.integrity);
1365
+ return JSON.parse(new TextDecoder().decode(bytes));
1366
+ } catch (err) {
1367
+ return formatError(remotesOrManifestUrl)(err);
1368
+ }
1369
+ }
1370
+ };
1371
+ };
1372
+
1373
+ // src/lib/3.adapters/node/fs-remote-entry-provider.ts
1374
+ var createFsRemoteEntryProvider = () => {
1375
+ const fillEmptyFields = (remoteEntryUrl) => (remoteEntry) => {
1376
+ if (!remoteEntry.exposes) remoteEntry.exposes = [];
1377
+ if (!remoteEntry.shared) remoteEntry.shared = [];
1378
+ if (!remoteEntry.url) remoteEntry.url = remoteEntryUrl;
1379
+ return remoteEntry;
1380
+ };
1381
+ const formatError = (remoteEntryUrl) => (err) => {
1382
+ if (err instanceof NFError) throw err;
1383
+ const msg = err instanceof Error ? err.message : String(err);
1384
+ throw new NFError(`Read of '${remoteEntryUrl}' returned ${msg}`);
1385
+ };
1386
+ return {
1387
+ provide: async function(remoteEntryUrl, opts = {}) {
1388
+ try {
1389
+ const bytes = await readSourceBytes(remoteEntryUrl);
1390
+ if (opts.integrity) await verifyIntegrity(bytes, opts.integrity);
1391
+ const parsed = JSON.parse(new TextDecoder().decode(bytes));
1392
+ return fillEmptyFields(remoteEntryUrl)(parsed);
1393
+ } catch (err) {
1394
+ return formatError(remoteEntryUrl)(err);
1395
+ }
1396
+ }
1397
+ };
1398
+ };
1399
+
1400
+ // src/lib/3.adapters/node/noop-sse.ts
1401
+ var createNoopSSE = () => ({
1402
+ watchRemoteBuilds: () => {
1403
+ },
1404
+ closeAll: () => {
1405
+ }
1406
+ });
1407
+
1408
+ // src/lib/utils/path.ts
1409
+ function join(pathA, pathB) {
1410
+ pathA = pathA.endsWith("/") ? pathA.slice(0, -1) : pathA;
1411
+ pathB = pathB.startsWith("/") ? pathB.slice(1) : pathB;
1412
+ return `${pathA}/${pathB}`;
1413
+ }
1414
+ function getScope(path) {
1415
+ if (!path) return "";
1416
+ const parts = path.split("/");
1417
+ if (parts[parts.length - 1] === "" || parts[parts.length - 1].includes(".")) {
1418
+ parts.pop();
1419
+ }
1420
+ if (parts.length < 1) return "";
1421
+ return `${parts.join("/")}/`;
1422
+ }
1423
+
1424
+ // src/lib/utils/optional.ts
1425
+ var Optional = class _Optional {
1426
+ constructor(item) {
1427
+ this.item = item;
1428
+ }
1429
+ item;
1430
+ static of(item) {
1431
+ return new _Optional(item);
1432
+ }
1433
+ static empty() {
1434
+ return _Optional.of(void 0);
1435
+ }
1436
+ isPresent() {
1437
+ return typeof this.item !== "undefined" && this.item !== null;
1438
+ }
1439
+ set(other) {
1440
+ return _Optional.of(other);
1441
+ }
1442
+ ifPresent(callback) {
1443
+ if (this.isPresent()) callback(this.item);
1444
+ }
1445
+ map(callback) {
1446
+ if (!this.isPresent()) return _Optional.empty();
1447
+ const result = callback(this.item);
1448
+ return result instanceof _Optional ? result : _Optional.of(result);
1449
+ }
1450
+ orElse(other) {
1451
+ return this.isPresent() ? this.item : other;
1452
+ }
1453
+ orThrow(error) {
1454
+ if (this.isPresent()) return this.item;
1455
+ if (typeof error === "function") throw error();
1456
+ throw typeof error === "string" ? new Error(error) : error;
1457
+ }
1458
+ get() {
1459
+ return this.item;
1460
+ }
1461
+ };
1462
+
1463
+ // src/lib/3.adapters/storage/remote-info.repository.ts
1464
+ var createRemoteInfoRepository = (config) => {
1465
+ const STORAGE = config.storage("remotes", {});
1466
+ if (config.clearStorage) STORAGE.clear();
1467
+ const _cache = STORAGE.get() ?? {};
1468
+ return {
1469
+ contains: function(remoteName) {
1470
+ return !!_cache[remoteName];
1471
+ },
1472
+ remove: function(remoteName) {
1473
+ delete _cache[remoteName];
1474
+ return this;
1475
+ },
1476
+ addOrUpdate: function(remoteName, remote) {
1477
+ _cache[remoteName] = remote;
1478
+ return this;
1479
+ },
1480
+ tryGet: function(remoteName) {
1481
+ return Optional.of(_cache[remoteName]);
1482
+ },
1483
+ tryGetModule: function(remoteName, exposedModule) {
1484
+ return Optional.of(_cache[remoteName]?.exposes.find((m) => m.moduleName === exposedModule)).map(
1485
+ (m) => join(_cache[remoteName].scopeUrl, m.file)
1486
+ );
1487
+ },
1488
+ getAll: function() {
1489
+ return _cache;
1490
+ },
1491
+ commit: function() {
1492
+ STORAGE.set(_cache);
1493
+ return this;
1494
+ }
1495
+ };
1496
+ };
1497
+
1498
+ // src/lib/3.adapters/storage/scoped-externals.repository.ts
1499
+ var createScopedExternalsRepository = (config) => {
1500
+ const STORAGE = config.storage("scoped-externals", {});
1501
+ if (config.clearStorage) STORAGE.clear();
1502
+ const _cache = STORAGE.get() ?? {};
1503
+ return {
1504
+ addExternal: function(remoteName, external, version) {
1505
+ if (!_cache[remoteName]) _cache[remoteName] = {};
1506
+ _cache[remoteName][external] = version;
1507
+ return this;
1508
+ },
1509
+ remove: function(remoteName) {
1510
+ delete _cache[remoteName];
1511
+ return this;
1512
+ },
1513
+ getAll: function() {
1514
+ return _cache;
1515
+ },
1516
+ tryGet: function(remoteName) {
1517
+ return Optional.of(_cache[remoteName]);
1518
+ },
1519
+ commit: function() {
1520
+ STORAGE.set(_cache);
1521
+ return this;
1522
+ }
1523
+ };
1524
+ };
1525
+
1526
+ // src/lib/1.domain/externals/external.contract.ts
1527
+ var GLOBAL_SCOPE = "__GLOBAL__";
1528
+ var STRICT_SCOPE = "strict";
1529
+
1530
+ // src/lib/3.adapters/storage/shared-externals.repository.ts
1531
+ var createSharedExternalsRepository = (config) => {
1532
+ const STORAGE = config.storage(
1533
+ "shared-externals",
1534
+ { [GLOBAL_SCOPE]: {} }
1535
+ );
1536
+ if (config.clearStorage) STORAGE.clear();
1537
+ const _cache = STORAGE.get();
1538
+ return {
1539
+ getFromScope: function(shareScope) {
1540
+ return { ..._cache[shareScope ?? GLOBAL_SCOPE] };
1541
+ },
1542
+ addOrUpdate: function(externalName, external, shareScope) {
1543
+ if (!_cache[shareScope ?? GLOBAL_SCOPE]) _cache[shareScope ?? GLOBAL_SCOPE] = {};
1544
+ _cache[shareScope ?? GLOBAL_SCOPE][externalName] = external;
1545
+ return this;
1546
+ },
1547
+ getScopes: function(o = { includeGlobal: true }) {
1548
+ if (o.includeGlobal) return Object.keys(_cache);
1549
+ return Object.keys(_cache).filter((s) => s !== GLOBAL_SCOPE);
1550
+ },
1551
+ removeFromAllScopes: function(remoteName) {
1552
+ Object.values(_cache).forEach((scope) => {
1553
+ const removeExternals = [];
1554
+ Object.entries(scope).forEach(([name, external]) => {
1555
+ const removeVersionIdx = [];
1556
+ external.versions.forEach((version, i) => {
1557
+ const versionRemoteIDX = version.remotes.findIndex((r) => r.name === remoteName);
1558
+ if (~versionRemoteIDX) {
1559
+ version.remotes.splice(versionRemoteIDX, 1);
1560
+ }
1561
+ if (version.remotes.length === 0) removeVersionIdx.push(i);
1562
+ });
1563
+ if (removeVersionIdx.length > 0) {
1564
+ for (let i = removeVersionIdx.length - 1; i >= 0; i--) {
1565
+ external.versions.splice(removeVersionIdx[i], 1);
1566
+ }
1567
+ external.dirty = true;
1568
+ if (external.versions.length === 0) removeExternals.push(name);
1569
+ }
1570
+ });
1571
+ removeExternals.forEach((name) => delete scope[name]);
1572
+ });
1573
+ },
1574
+ scopeType: function(shareScope) {
1575
+ switch (shareScope) {
1576
+ case GLOBAL_SCOPE:
1577
+ case null:
1578
+ case void 0:
1579
+ return "global";
1580
+ case STRICT_SCOPE:
1581
+ return "strict";
1582
+ default:
1583
+ return "shareScope";
1584
+ }
1585
+ },
1586
+ tryGet: function(external, shareScope) {
1587
+ return Optional.of(_cache[shareScope ?? GLOBAL_SCOPE]?.[external]);
1588
+ },
1589
+ commit: function() {
1590
+ STORAGE.set(_cache);
1591
+ return this;
1592
+ }
1593
+ };
1594
+ };
1595
+
1596
+ // src/lib/utils/clone-entry.ts
1597
+ var cloneEntry = (name, raw) => {
1598
+ try {
1599
+ if (typeof structuredClone === "function") {
1600
+ return structuredClone(raw);
1601
+ }
1602
+ } catch {
1603
+ }
1604
+ try {
1605
+ return JSON.parse(JSON.stringify(raw));
1606
+ } catch {
1607
+ }
1608
+ throw new NFError(`Could not parse storage entry '${String(name)}'`);
1609
+ };
1610
+
1611
+ // src/lib/3.adapters/storage/chunk.repository.ts
1612
+ var createChunkRepository = (config) => {
1613
+ const STORAGE = config.storage("shared-chunks", {});
1614
+ if (config.clearStorage) STORAGE.clear();
1615
+ const _cache = STORAGE.get() ?? {};
1616
+ return {
1617
+ addOrReplace: function(remoteName, bundleName, chunks) {
1618
+ if (!_cache[remoteName]) _cache[remoteName] = {};
1619
+ _cache[remoteName][bundleName] = chunks;
1620
+ return this;
1621
+ },
1622
+ tryGet: function(remoteName, bundleName) {
1623
+ return Optional.of(_cache[remoteName]?.[bundleName]);
1624
+ },
1625
+ commit: function() {
1626
+ STORAGE.set(_cache);
1627
+ return this;
1628
+ }
1629
+ };
1630
+ };
1631
+
1632
+ // src/lib/4.config/import-map/trusted-types.ts
1633
+ var IMPORT_MAP_KEYS = /* @__PURE__ */ new Set(["imports", "scopes", "integrity"]);
1634
+ var validateImportMapJSON = (input) => {
1635
+ let parsed;
1636
+ try {
1637
+ parsed = JSON.parse(input);
1638
+ } catch {
1639
+ throw new TypeError("[nf-orchestrator] trusted-types: import map is not valid JSON");
1640
+ }
1641
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
1642
+ throw new TypeError("[nf-orchestrator] trusted-types: import map must be a plain object");
1643
+ }
1644
+ for (const key of Object.keys(parsed)) {
1645
+ if (!IMPORT_MAP_KEYS.has(key)) {
1646
+ throw new TypeError(`[nf-orchestrator] trusted-types: unexpected key "${key}" in import map`);
1647
+ }
1648
+ }
1649
+ return input;
1650
+ };
1651
+ var validateScriptURL = (input) => {
1652
+ const base = typeof location !== "undefined" ? location.href : "http://localhost/";
1653
+ let url;
1654
+ try {
1655
+ url = new URL(input, base);
1656
+ } catch {
1657
+ throw new TypeError(`[nf-orchestrator] trusted-types: invalid script URL "${input}"`);
1658
+ }
1659
+ if (url.protocol !== "https:" && url.protocol !== "http:") {
1660
+ throw new TypeError(
1661
+ `[nf-orchestrator] trusted-types: disallowed protocol "${url.protocol}" for script URL`
1662
+ );
1663
+ }
1664
+ return input;
1665
+ };
1666
+ var passThroughPolicy = {
1667
+ createScript: (input) => input,
1668
+ createScriptURL: (input) => input
1669
+ };
1670
+ var cachedPolicy = null;
1671
+ var getTrustedTypesPolicy = (name = "nfo") => {
1672
+ if (name === false) return passThroughPolicy;
1673
+ if (cachedPolicy) return cachedPolicy;
1674
+ const factory = globalThis.trustedTypes;
1675
+ if (!factory) {
1676
+ cachedPolicy = passThroughPolicy;
1677
+ return cachedPolicy;
1678
+ }
1679
+ const native = factory.createPolicy(name, {
1680
+ createScript: validateImportMapJSON,
1681
+ createScriptURL: validateScriptURL
1682
+ });
1683
+ cachedPolicy = {
1684
+ createScript: (input) => native.createScript(input),
1685
+ createScriptURL: (input) => native.createScriptURL(input)
1686
+ };
1687
+ return cachedPolicy;
1688
+ };
1689
+
1690
+ // src/lib/4.config/import-map/replace-in-dom.ts
1691
+ var replaceInDOM = (mapType, trustedTypesPolicyName = "nfo") => (importMap, opts = {}) => {
1692
+ if (opts?.override) {
1693
+ document.head.querySelectorAll(`script[type="${mapType}"]`).forEach((importMap2) => importMap2.remove());
1694
+ }
1695
+ const policy = getTrustedTypesPolicy(trustedTypesPolicyName);
1696
+ document.head.appendChild(
1697
+ Object.assign(document.createElement("script"), {
1698
+ type: mapType,
1699
+ text: policy.createScript(JSON.stringify(importMap))
1700
+ })
1701
+ );
1702
+ return Promise.resolve(importMap);
1703
+ };
1704
+
1705
+ // src/lib/4.config/import-map/use-default.ts
1706
+ var useDefaultImportMap = (trustedTypesPolicyName = "nfo") => ({
1707
+ loadModuleFn: (url) => {
1708
+ const trusted = getTrustedTypesPolicy(trustedTypesPolicyName).createScriptURL(url);
1709
+ return import(
1710
+ /* @vite-ignore */
1711
+ trusted
1712
+ );
1713
+ },
1714
+ setImportMapFn: replaceInDOM("importmap", trustedTypesPolicyName),
1715
+ reloadBrowserFn: () => {
1716
+ window.location.reload();
1717
+ }
1718
+ });
1719
+
1720
+ // src/lib/4.config/import-map/import-map.config.ts
1721
+ var createImportMapConfig = (o) => {
1722
+ const fallback = useDefaultImportMap(o.trustedTypesPolicyName);
1723
+ return {
1724
+ setImportMapFn: o.setImportMapFn ?? fallback.setImportMapFn,
1725
+ loadModuleFn: o.loadModuleFn ?? fallback.loadModuleFn,
1726
+ reloadBrowserFn: o.reloadBrowserFn ?? fallback.reloadBrowserFn
1727
+ };
1728
+ };
1729
+
1730
+ // src/lib/4.config/host/host.config.ts
1731
+ var createHostConfig = (override) => {
1732
+ const extras = override?.manifestIntegrity ? { manifestIntegrity: override.manifestIntegrity } : {};
1733
+ if (!override?.hostRemoteEntry) {
1734
+ return { hostRemoteEntry: false, ...extras };
1735
+ }
1736
+ if (typeof override.hostRemoteEntry === "string") {
1737
+ return {
1738
+ hostRemoteEntry: {
1739
+ name: "__NF-HOST__",
1740
+ url: override.hostRemoteEntry
1741
+ },
1742
+ ...extras
1743
+ };
1744
+ }
1745
+ return {
1746
+ hostRemoteEntry: {
1747
+ name: "__NF-HOST__",
1748
+ ...override.hostRemoteEntry
1749
+ },
1750
+ ...extras
1751
+ };
1752
+ };
1753
+
1754
+ // src/lib/4.config/logging/noop.logger.ts
1755
+ var noopLogger = {
1756
+ debug: () => {
1757
+ },
1758
+ error: () => {
1759
+ },
1760
+ warn: () => {
1761
+ }
1762
+ };
1763
+
1764
+ // src/lib/2.app/config/log.contract.ts
1765
+ var LogLevel = {
1766
+ debug: 0,
1767
+ warn: 1,
1768
+ error: 2
1769
+ };
1770
+
1771
+ // src/lib/4.config/logging/log.handler.ts
1772
+ var createLogHandler = (logger, logLevel) => {
1773
+ const logTypes = Object.keys(LogLevel).filter((key) => isNaN(Number(key)));
1774
+ return logTypes.reduce(
1775
+ (acc, logMessageType) => {
1776
+ return {
1777
+ ...acc,
1778
+ [logMessageType]: (step, message, details) => {
1779
+ if (LogLevel[logMessageType] >= LogLevel[logLevel]) {
1780
+ logger[logMessageType](step, message, details);
1781
+ }
1782
+ }
1783
+ };
1784
+ },
1785
+ { level: logLevel }
1786
+ );
1787
+ };
1788
+
1789
+ // src/lib/4.config/logging/log.config.ts
1790
+ var createLogConfig = ({ logger, logLevel, sse }) => ({
1791
+ log: createLogHandler(logger ?? noopLogger, logLevel ?? "error"),
1792
+ sse: !!sse
1793
+ });
1794
+
1795
+ // src/lib/4.config/storage/global-this.storage.ts
1796
+ var globalThisStorageEntry = (namespace) => (key, initialValue) => {
1797
+ if (!globalThis[namespace]) {
1798
+ globalThis[namespace] = {};
1799
+ }
1800
+ const storage = globalThis[namespace];
1801
+ if (!storage[key]) storage[key] = initialValue;
1802
+ const entry = {
1803
+ get() {
1804
+ return cloneEntry(key, storage[key]);
1805
+ },
1806
+ set(value) {
1807
+ storage[key] = cloneEntry(key, value);
1808
+ return entry;
1809
+ },
1810
+ clear() {
1811
+ storage[key] = cloneEntry(key, initialValue);
1812
+ return this;
1813
+ }
1814
+ };
1815
+ return entry;
1816
+ };
1817
+
1818
+ // src/lib/4.config/storage/storage.config.ts
1819
+ var createStorageConfig = (override) => ({
1820
+ storage: override.storage ? override.storage(override.storageNamespace ?? "__NATIVE_FEDERATION__") : globalThisStorageEntry(override.storageNamespace ?? "__NATIVE_FEDERATION__"),
1821
+ clearStorage: override.clearStorage ?? false
1822
+ });
1823
+
1824
+ // src/lib/4.config/mode/default.profile.ts
1825
+ var defaultProfile = {
1826
+ latestSharedExternal: false,
1827
+ overrideCachedRemotes: "init-only",
1828
+ overrideCachedRemotesIfURLMatches: false
1829
+ };
1830
+
1831
+ // src/lib/4.config/mode/mode.config.ts
1832
+ var createModeConfig = (override) => {
1833
+ const strictnessConfig = typeof override.strict === "boolean" ? {
1834
+ strictRemoteEntry: override.strict,
1835
+ strictExternalCompatibility: override.strict,
1836
+ strictExternalSameVersionCompatibility: override.strict,
1837
+ strictExternalVersion: override.strict,
1838
+ strictImportMap: override.strict
1839
+ } : {
1840
+ strictRemoteEntry: override.strict?.strictRemoteEntry ?? false,
1841
+ strictExternalCompatibility: override.strict?.strictExternalCompatibility ?? false,
1842
+ strictExternalSameVersionCompatibility: override.strict?.strictExternalSameVersionCompatibility ?? false,
1843
+ strictExternalVersion: override.strict?.strictExternalVersion ?? false,
1844
+ strictImportMap: override.strict?.strictImportMap ?? false
1845
+ };
1846
+ return {
1847
+ strict: strictnessConfig,
1848
+ profile: { ...defaultProfile, ...override.profile ?? {} }
1849
+ };
1850
+ };
1851
+
1852
+ // src/lib/5.di/config.factory.ts
1853
+ var createConfigHandlers = (overrides) => ({
1854
+ ...createImportMapConfig(overrides),
1855
+ ...createHostConfig(overrides),
1856
+ ...createLogConfig(overrides),
1857
+ ...createStorageConfig(overrides),
1858
+ ...createModeConfig(overrides)
1859
+ });
1860
+
1861
+ // src/lib/2.app/flows/init/get-remote-entries.ts
1862
+ function createGetRemoteEntries(config, ports) {
1863
+ return (remotesOrManifestUrl = {}) => {
1864
+ const manifestPromise = config.manifestIntegrity ? ports.manifestProvider.provide(remotesOrManifestUrl, {
1865
+ integrity: config.manifestIntegrity
1866
+ }) : ports.manifestProvider.provide(remotesOrManifestUrl);
1867
+ return manifestPromise.catch((e) => {
1868
+ config.log.error(1, "Could not fetch manifest.", e);
1869
+ return Promise.reject(new NFError("Failed to fetch manifest"));
1870
+ }).then(addHostRemoteEntry).then(fetchRemoteEntries).then(removeSkippedRemotes).then(checkForSSE);
1871
+ };
1872
+ function addHostRemoteEntry(manifest) {
1873
+ if (!config.hostRemoteEntry) return manifest;
1874
+ const { name, url, cacheTag, integrity } = config.hostRemoteEntry;
1875
+ const urlWithCache = cacheTag ? `${url}?cacheTag=${cacheTag}` : url;
1876
+ return {
1877
+ ...manifest,
1878
+ [name]: integrity ? { url: urlWithCache, integrity } : urlWithCache
1879
+ };
1880
+ }
1881
+ function normalizeEntry(descriptor) {
1882
+ return typeof descriptor === "string" ? { url: descriptor } : descriptor;
1883
+ }
1884
+ async function fetchRemoteEntries(manifest) {
1885
+ const fetchPromises = Object.entries(manifest).map(
1886
+ ([remoteName, descriptor]) => fetchRemoteEntry(remoteName, descriptor)
1887
+ );
1888
+ return Promise.all(fetchPromises);
1889
+ }
1890
+ async function fetchRemoteEntry(remoteName, descriptor) {
1891
+ const { url: remoteEntryUrl, integrity } = normalizeEntry(descriptor);
1892
+ let isOverride = false;
1893
+ let skip = false;
1894
+ ports.remoteInfoRepo.tryGet(remoteName).ifPresent((cachedRemoteInfo) => {
1895
+ if (config.profile.overrideCachedRemotes !== "never" && (remoteEntryUrl !== join(cachedRemoteInfo.scopeUrl, "remoteEntry.json") || config.profile.overrideCachedRemotesIfURLMatches)) {
1896
+ config.log.debug(1, `Overriding existing remote '${remoteName}' with '${remoteEntryUrl}'.`);
1897
+ isOverride = true;
1898
+ } else {
1899
+ config.log.debug(1, `Found remote '${remoteName}' in storage, omitting fetch.`);
1900
+ skip = true;
1901
+ }
1902
+ });
1903
+ if (skip) return false;
1904
+ try {
1905
+ const remoteEntry = integrity ? await ports.remoteEntryProvider.provide(remoteEntryUrl, { integrity }) : await ports.remoteEntryProvider.provide(remoteEntryUrl);
1906
+ config.log.debug(
1907
+ 1,
1908
+ `Fetched '${remoteEntry.name}' from '${remoteEntry.url}', exposing: ${JSON.stringify(remoteEntry.exposes)}`
1909
+ );
1910
+ return prepareRemoteEntry(remoteEntry, remoteName, isOverride);
1911
+ } catch (error) {
1912
+ if (config.strict.strictRemoteEntry) {
1913
+ config.log.error(1, `Could not fetch remote '${remoteName}'.`, error);
1914
+ return Promise.reject(new NFError(`Could not fetch remote '${remoteName}'`));
1915
+ }
1916
+ config.log.warn(1, `Could not fetch remote '${remoteName}'. skipping init.`, error);
1917
+ return Promise.resolve(false);
1918
+ }
1919
+ }
1920
+ function prepareRemoteEntry(remoteEntry, expectedRemoteName, isOverride) {
1921
+ if (isOverride) remoteEntry.override = isOverride;
1922
+ if (!!config.hostRemoteEntry && expectedRemoteName === config.hostRemoteEntry.name) {
1923
+ remoteEntry.host = true;
1924
+ remoteEntry.name = config.hostRemoteEntry.name;
1925
+ }
1926
+ if (remoteEntry.name !== expectedRemoteName) {
1927
+ const errorDetails = `Fetched remote '${remoteEntry.name}' does not match requested '${expectedRemoteName}'.`;
1928
+ if (config.strict.strictRemoteEntry) {
1929
+ throw new NFError(errorDetails);
1930
+ }
1931
+ config.log.warn(1, `${errorDetails} Omitting expected name.`);
1932
+ }
1933
+ return remoteEntry;
1934
+ }
1935
+ function removeSkippedRemotes(remoteEntries) {
1936
+ return remoteEntries.filter((entry) => entry !== false);
1937
+ }
1938
+ function checkForSSE(remoteEntries) {
1939
+ if (config.sse) {
1940
+ remoteEntries.forEach((entry) => {
1941
+ if (entry.buildNotificationsEndpoint) {
1942
+ ports.sse.watchRemoteBuilds(
1943
+ join(getScope(entry.url), entry.buildNotificationsEndpoint)
1944
+ );
1945
+ config.log.debug(1, `Registered SSE endpoint of remote '${entry.name}' `);
1946
+ return;
1947
+ }
1948
+ config.log.debug(1, `Remote ${entry.name} has no defined 'buildNotificationsEndpoint'`);
1949
+ });
1950
+ }
1951
+ return remoteEntries;
1952
+ }
1953
+ }
1954
+
1955
+ // src/lib/2.app/flows/init/process-remote-entries.ts
1956
+ function createProcessRemoteEntries(config, ports) {
1957
+ return (remoteEntries) => {
1958
+ try {
1959
+ remoteEntries.forEach((remoteEntry) => {
1960
+ if (remoteEntry?.override) removeCachedRemoteEntry(remoteEntry);
1961
+ addRemoteInfoToStorage(remoteEntry);
1962
+ addExternalsToStorage(remoteEntry);
1963
+ addSharedChunksToStorage(remoteEntry);
1964
+ });
1965
+ return Promise.resolve(remoteEntries);
1966
+ } catch (e) {
1967
+ return Promise.reject(e);
1968
+ }
1969
+ };
1970
+ function removeCachedRemoteEntry(remoteEntry) {
1971
+ ports.remoteInfoRepo.remove(remoteEntry.name);
1972
+ ports.scopedExternalsRepo.remove(remoteEntry.name);
1973
+ ports.sharedExternalsRepo.removeFromAllScopes(remoteEntry.name);
1974
+ }
1975
+ function addRemoteInfoToStorage({ name, url, exposes, integrity }) {
1976
+ ports.remoteInfoRepo.addOrUpdate(name, {
1977
+ scopeUrl: getScope(url),
1978
+ exposes: Object.values(exposes ?? []).map((m) => ({
1979
+ moduleName: m.key,
1980
+ file: m.outFileName
1981
+ })),
1982
+ ...integrity ? { integrity } : {}
1983
+ });
1984
+ }
1985
+ function addExternalsToStorage(remoteEntry) {
1986
+ remoteEntry.shared.forEach((external) => {
1987
+ if (!external.version || !ports.versionCheck.isValidSemver(external.version)) {
1988
+ const errorMsg = `[${remoteEntry.name}][${external.packageName}] Version '${external.version}' is not a valid version.`;
1989
+ if (config.strict.strictExternalVersion) {
1990
+ config.log.error(2, errorMsg);
1991
+ throw new NFError(`Could not process remote '${remoteEntry.name}'`);
1992
+ }
1993
+ config.log.warn(2, errorMsg);
1994
+ }
1995
+ if (external.singleton) {
1996
+ addSharedExternal(remoteEntry.name, external, remoteEntry);
1997
+ } else {
1998
+ addScopedExternal(remoteEntry.name, external);
1999
+ }
2000
+ });
2001
+ }
2002
+ function addSharedChunksToStorage(remoteEntry) {
2003
+ if (!remoteEntry.chunks) return;
2004
+ config.log.debug(
2005
+ 2,
2006
+ `Adding chunks for remote "${remoteEntry.name}", bundles: [${Object.keys(remoteEntry.chunks).join(", ")}]`
2007
+ );
2008
+ Object.entries(remoteEntry.chunks).forEach(([bundleName, chunks]) => {
2009
+ ports.sharedChunksRepo.addOrReplace(remoteEntry.name, bundleName, chunks);
2010
+ });
2011
+ }
2012
+ function addSharedExternal(remoteName, sharedInfo, remoteEntry) {
2013
+ let action = "skip";
2014
+ const tag = sharedInfo.version ?? ports.versionCheck.smallestVersion(sharedInfo.requiredVersion);
2015
+ const remote = {
2016
+ file: sharedInfo.outFileName,
2017
+ name: remoteName,
2018
+ bundle: sharedInfo.bundle,
2019
+ strictVersion: sharedInfo.strictVersion,
2020
+ cached: false,
2021
+ requiredVersion: sharedInfo.requiredVersion || tag
2022
+ };
2023
+ const scopeType = ports.sharedExternalsRepo.scopeType(sharedInfo.shareScope);
2024
+ if (scopeType === "strict") {
2025
+ action = "share";
2026
+ remote.requiredVersion = tag;
2027
+ }
2028
+ const cached2 = ports.sharedExternalsRepo.tryGet(sharedInfo.packageName, sharedInfo.shareScope).orElse({ dirty: false, versions: [] });
2029
+ const matchingVersion = cached2.versions.find((version) => version.tag === sharedInfo.version);
2030
+ let dirty = cached2.dirty;
2031
+ if (!!matchingVersion) {
2032
+ if (remote.strictVersion && matchingVersion.remotes[0].requiredVersion !== remote.requiredVersion) {
2033
+ const errorMsg = `[${remoteName}][${sharedInfo.packageName}@${sharedInfo.version}] Required version-range '${remote.requiredVersion}' does not match cached version-range '${matchingVersion.remotes[0].requiredVersion}'`;
2034
+ if (config.strict.strictExternalSameVersionCompatibility) {
2035
+ config.log.error(2, errorMsg);
2036
+ throw new NFError(`Could not process remote '${remoteEntry.name}'`);
2037
+ }
2038
+ config.log.warn(2, errorMsg);
2039
+ }
2040
+ if (!matchingVersion.host && !!remoteEntry?.host) {
2041
+ matchingVersion.host = true;
2042
+ matchingVersion.remotes.unshift(remote);
2043
+ } else matchingVersion.remotes.push(remote);
2044
+ } else {
2045
+ if (scopeType !== "strict") dirty = true;
2046
+ cached2.versions.push({ tag, action, host: !!remoteEntry?.host, remotes: [remote] });
2047
+ }
2048
+ ports.sharedExternalsRepo.addOrUpdate(
2049
+ sharedInfo.packageName,
2050
+ {
2051
+ dirty,
2052
+ versions: cached2.versions.sort((a, b) => ports.versionCheck.compare(b.tag, a.tag))
2053
+ },
2054
+ sharedInfo.shareScope
2055
+ );
2056
+ }
2057
+ function addScopedExternal(scope, sharedInfo) {
2058
+ ports.scopedExternalsRepo.addExternal(scope, sharedInfo.packageName, {
2059
+ tag: sharedInfo.version ?? ports.versionCheck.smallestVersion(sharedInfo.requiredVersion),
2060
+ file: sharedInfo.outFileName,
2061
+ bundle: sharedInfo.bundle
2062
+ });
2063
+ }
2064
+ }
2065
+
2066
+ // src/lib/2.app/flows/init/determine-shared-externals.ts
2067
+ function createDetermineSharedExternals(config, ports) {
2068
+ return () => {
2069
+ for (const shareScope of ports.sharedExternalsRepo.getScopes()) {
2070
+ const sharedExternals = ports.sharedExternalsRepo.getFromScope(shareScope);
2071
+ try {
2072
+ Object.entries(sharedExternals).filter(([_, e]) => e.dirty).forEach(
2073
+ ([name, external]) => ports.sharedExternalsRepo.addOrUpdate(
2074
+ name,
2075
+ setVersionActions(name, external),
2076
+ shareScope
2077
+ )
2078
+ );
2079
+ } catch (error) {
2080
+ config.log.error(
2081
+ 3,
2082
+ `[${shareScope ?? GLOBAL_SCOPE}] failed to determine shared externals.`,
2083
+ {
2084
+ sharedExternals,
2085
+ error
2086
+ }
2087
+ );
2088
+ return Promise.reject(
2089
+ new NFError(
2090
+ `Could not determine shared externals in scope ${shareScope}.`,
2091
+ error
2092
+ )
2093
+ );
2094
+ }
2095
+ }
2096
+ return Promise.resolve();
2097
+ };
2098
+ function setVersionActions(externalName, external) {
2099
+ if (external.versions.length === 1) {
2100
+ external.versions[0].action = "share";
2101
+ external.dirty = false;
2102
+ return external;
2103
+ }
2104
+ let sharedVersion = external.versions.find((v) => v.host);
2105
+ if (!sharedVersion && config.profile.latestSharedExternal) {
2106
+ sharedVersion = external.versions[0];
2107
+ }
2108
+ if (!sharedVersion) {
2109
+ let leastExtraDownloads = Number.MAX_VALUE;
2110
+ external.versions.forEach((vA) => {
2111
+ const extraDownloads = external.versions.filter(
2112
+ (vB) => !vB.remotes[0].cached && vB.remotes[0].strictVersion && !ports.versionCheck.isCompatible(vA.tag, vB.remotes[0].requiredVersion)
2113
+ ).length;
2114
+ if (extraDownloads < leastExtraDownloads) {
2115
+ leastExtraDownloads = extraDownloads;
2116
+ sharedVersion = vA;
2117
+ }
2118
+ });
2119
+ }
2120
+ if (!sharedVersion) {
2121
+ throw new NFError(`[${externalName}] Could not determine shared version!`);
2122
+ }
2123
+ external.versions.forEach((v) => {
2124
+ if (ports.versionCheck.isCompatible(sharedVersion.tag, v.remotes[0].requiredVersion)) {
2125
+ v.action = "skip";
2126
+ return;
2127
+ }
2128
+ if (config.strict.strictExternalCompatibility && v.remotes[0].strictVersion) {
2129
+ config.log.error(
2130
+ 3,
2131
+ `[${v.remotes[0].name}][${externalName}@${v.tag}] Is not compatible with requiredRange '${sharedVersion.remotes[0]?.requiredVersion}' from remote '${sharedVersion.remotes[0].name}'.`
2132
+ );
2133
+ throw new NFError(`External ${externalName}@${v.tag} could not be shared.`);
2134
+ }
2135
+ v.action = v.remotes[0].strictVersion ? "scope" : "skip";
2136
+ });
2137
+ sharedVersion.action = "share";
2138
+ external.dirty = false;
2139
+ return external;
2140
+ }
2141
+ }
2142
+
2143
+ // node_modules/.pnpm/@softarc+native-federation@4.1.3_typescript@5.9.3/node_modules/@softarc/native-federation/src/lib/domain/core/build-notification-options.contract.js
2144
+ var BuildNotificationType;
2145
+ (function(BuildNotificationType2) {
2146
+ BuildNotificationType2["COMPLETED"] = "federation-rebuild-complete";
2147
+ BuildNotificationType2["ERROR"] = "federation-rebuild-error";
2148
+ BuildNotificationType2["CANCELLED"] = "federation-rebuild-cancelled";
2149
+ })(BuildNotificationType || (BuildNotificationType = {}));
2150
+
2151
+ // node_modules/.pnpm/@softarc+native-federation@4.1.3_typescript@5.9.3/node_modules/@softarc/native-federation/src/lib/domain/core/chunk.js
2152
+ var CHUNK_PREFIX = "@nf-internal";
2153
+ function toChunkImport(fileName) {
2154
+ if (fileName.startsWith("./")) {
2155
+ fileName = fileName.slice(2);
2156
+ }
2157
+ const packageName = fileName.replace(/.(m|c)?js$/, "");
2158
+ return CHUNK_PREFIX + "/" + packageName;
2159
+ }
2160
+
2161
+ // src/lib/2.app/flows/init/generate-import-map.ts
2162
+ function createGenerateImportMap(config, ports) {
2163
+ return () => {
2164
+ const importMap = { imports: {} };
2165
+ const chunkBundles = {};
2166
+ try {
2167
+ addScopedExternals(importMap, chunkBundles);
2168
+ addshareScopeExternals(importMap, chunkBundles);
2169
+ addGlobalSharedExternals(importMap, chunkBundles);
2170
+ addRemoteInfos(importMap, chunkBundles);
2171
+ addChunkImports(importMap, chunkBundles);
2172
+ return Promise.resolve(importMap);
2173
+ } catch (e) {
2174
+ return Promise.reject(e);
2175
+ }
2176
+ };
2177
+ function addScopedExternals(importMap, chunkBundles) {
2178
+ const scopedExternals = ports.scopedExternalsRepo.getAll();
2179
+ for (const [remoteName, externals] of Object.entries(scopedExternals)) {
2180
+ const remote = ports.remoteInfoRepo.tryGet(remoteName).orThrow(() => {
2181
+ config.log.error(4, `[scoped][${remoteName}] Remote name not found in cache.`);
2182
+ return new NFError("Could not create ImportMap.");
2183
+ });
2184
+ addToScope(importMap, remote.scopeUrl, createScopeModules(externals, remote.scopeUrl));
2185
+ for (const version of Object.values(externals)) {
2186
+ addIntegrity(importMap, join(remote.scopeUrl, version.file), remoteName, version.file);
2187
+ }
2188
+ Object.values(externals).filter((e) => !!e.bundle).forEach((e) => registerBundleChunks(chunkBundles, remoteName, e.bundle));
2189
+ }
2190
+ return importMap;
2191
+ }
2192
+ function createScopeModules(externals, scope) {
2193
+ const modules = {};
2194
+ for (const [external, version] of Object.entries(externals)) {
2195
+ modules[external] = join(scope, version.file);
2196
+ }
2197
+ return modules;
2198
+ }
2199
+ function addshareScopeExternals(importMap, chunkBundles) {
2200
+ const shareScopes = ports.sharedExternalsRepo.getScopes({ includeGlobal: false });
2201
+ for (const shareScope of shareScopes) {
2202
+ processshareScope(importMap, shareScope, chunkBundles);
2203
+ }
2204
+ return importMap;
2205
+ }
2206
+ function processshareScope(importMap, shareScope, chunkBundles) {
2207
+ const sharedExternals = ports.sharedExternalsRepo.getFromScope(shareScope);
2208
+ for (const [externalName, external] of Object.entries(sharedExternals)) {
2209
+ let override = void 0;
2210
+ let overrideScope = void 0;
2211
+ for (const version of external.versions) {
2212
+ if (version.action === "scope") {
2213
+ for (const remote of version.remotes) {
2214
+ const remoteScope = getScope2(shareScope, remote.name, externalName);
2215
+ const url = join(remoteScope, remote.file);
2216
+ addToScope(importMap, remoteScope, {
2217
+ [externalName]: url
2218
+ });
2219
+ addIntegrity(importMap, url, remote.name, remote.file);
2220
+ registerBundleChunks(chunkBundles, remote.name, remote.bundle);
2221
+ remote.cached = true;
2222
+ }
2223
+ continue;
2224
+ }
2225
+ const scope = getScope2(shareScope, version.remotes[0].name, externalName);
2226
+ let targetFileUrl = join(scope, version.remotes[0].file);
2227
+ let targetFileSource = {
2228
+ name: version.remotes[0].name,
2229
+ file: version.remotes[0].file
2230
+ };
2231
+ version.remotes[0].cached = true;
2232
+ if (version.action === "share") {
2233
+ registerBundleChunks(chunkBundles, version.remotes[0].name, version.remotes[0].bundle);
2234
+ }
2235
+ if (version.action === "skip") {
2236
+ if (!override) {
2237
+ override = findOverride(external, shareScope, externalName) ?? "NOT_AVAILABLE";
2238
+ }
2239
+ if (override !== "NOT_AVAILABLE") {
2240
+ if (!overrideScope)
2241
+ overrideScope = getScope2(shareScope, override.remotes[0].name, externalName);
2242
+ targetFileUrl = join(overrideScope, override.remotes[0].file);
2243
+ targetFileSource = {
2244
+ name: override.remotes[0].name,
2245
+ file: override.remotes[0].file
2246
+ };
2247
+ override.remotes[0].cached = true;
2248
+ version.remotes[0].cached = false;
2249
+ }
2250
+ }
2251
+ version.remotes.forEach((r) => {
2252
+ const scope2 = getScope2(shareScope, r.name, externalName);
2253
+ addToScope(importMap, scope2, { [externalName]: targetFileUrl });
2254
+ });
2255
+ addIntegrity(importMap, targetFileUrl, targetFileSource.name, targetFileSource.file);
2256
+ }
2257
+ ports.sharedExternalsRepo.addOrUpdate(externalName, external, shareScope);
2258
+ }
2259
+ }
2260
+ function findOverride(external, shareScope, externalName) {
2261
+ const sharedVersions = external.versions.filter((v) => v.action === "share");
2262
+ const scopedExternalName = `${shareScope}.${externalName}`;
2263
+ if (sharedVersions.length > 1) {
2264
+ handleMultipleSharedVersions(scopedExternalName);
2265
+ }
2266
+ if (sharedVersions.length < 1) {
2267
+ if (config.strict.strictImportMap) {
2268
+ config.log.error(4, `[${shareScope}][${externalName}] shareScope has no override version.`);
2269
+ throw new NFError("Could not create ImportMap.");
2270
+ }
2271
+ config.log.debug(
2272
+ 4,
2273
+ `[${shareScope}][${externalName}] shareScope has no override version, scoping override versions.`
2274
+ );
2275
+ }
2276
+ return sharedVersions[0];
2277
+ }
2278
+ function handleMultipleSharedVersions(scopedExternalName) {
2279
+ if (config.strict.strictImportMap) {
2280
+ config.log.error(
2281
+ 4,
2282
+ `[${scopedExternalName}] ShareScope external has multiple shared versions.`
2283
+ );
2284
+ throw new NFError("Could not create ImportMap.");
2285
+ }
2286
+ config.log.warn(4, `ShareScope external ${scopedExternalName} has multiple shared versions.`);
2287
+ }
2288
+ function addGlobalSharedExternals(importMap, chunkBundles) {
2289
+ const sharedExternals = ports.sharedExternalsRepo.getFromScope();
2290
+ for (const [externalName, external] of Object.entries(sharedExternals)) {
2291
+ for (const version of external.versions) {
2292
+ if (version.action === "skip") continue;
2293
+ if (version.action === "scope") {
2294
+ for (const remote of version.remotes) {
2295
+ const remoteScope = getScope2(GLOBAL_SCOPE, remote.name, externalName);
2296
+ const url2 = join(remoteScope, remote.file);
2297
+ addToScope(importMap, remoteScope, {
2298
+ [externalName]: url2
2299
+ });
2300
+ addIntegrity(importMap, url2, remote.name, remote.file);
2301
+ remote.cached = true;
2302
+ registerBundleChunks(chunkBundles, remote.name, remote.bundle);
2303
+ }
2304
+ continue;
2305
+ }
2306
+ if (importMap.imports[externalName]) {
2307
+ notifyDuplicateGlobalExternal(externalName);
2308
+ continue;
2309
+ }
2310
+ const scope = getScope2(GLOBAL_SCOPE, version.remotes[0].name, externalName);
2311
+ const url = join(scope, version.remotes[0].file);
2312
+ addToGlobal(importMap, { [externalName]: url });
2313
+ addIntegrity(importMap, url, version.remotes[0].name, version.remotes[0].file);
2314
+ registerBundleChunks(chunkBundles, version.remotes[0].name, version.remotes[0].bundle);
2315
+ version.remotes[0].cached = true;
2316
+ }
2317
+ ports.sharedExternalsRepo.addOrUpdate(externalName, external);
2318
+ }
2319
+ return importMap;
2320
+ }
2321
+ function notifyDuplicateGlobalExternal(externalName) {
2322
+ if (config.strict.strictImportMap) {
2323
+ config.log.error(4, `[${externalName}] Shared external has multiple shared versions.`);
2324
+ throw new NFError("Could not create ImportMap.");
2325
+ }
2326
+ config.log.warn(4, `Singleton external ${externalName} has multiple shared versions.`);
2327
+ }
2328
+ function addToScope(importMap, scope, imports) {
2329
+ if (!importMap.scopes) importMap.scopes = {};
2330
+ if (!importMap.scopes[scope]) importMap.scopes[scope] = {};
2331
+ importMap.scopes[scope] = Object.assign(importMap.scopes[scope], imports);
2332
+ }
2333
+ function addToGlobal(importMap, imports) {
2334
+ importMap.imports = Object.assign(importMap.imports, imports);
2335
+ }
2336
+ function addRemoteInfos(importMap, chunkBundles) {
2337
+ const remotes = ports.remoteInfoRepo.getAll();
2338
+ for (const [remoteName, remote] of Object.entries(remotes)) {
2339
+ addRemoteExposedModules(importMap, remoteName, remote);
2340
+ registerBundleChunks(chunkBundles, remoteName, "mapping-or-exposed");
2341
+ }
2342
+ }
2343
+ function addRemoteExposedModules(importMap, remoteName, remote) {
2344
+ for (const exposed of remote.exposes) {
2345
+ const moduleName = join(remoteName, exposed.moduleName);
2346
+ const moduleUrl = join(remote.scopeUrl, exposed.file);
2347
+ importMap.imports[moduleName] = moduleUrl;
2348
+ addIntegrity(importMap, moduleUrl, remoteName, exposed.file);
2349
+ }
2350
+ }
2351
+ function registerBundleChunks(chunkBundles, remoteName, bundleName) {
2352
+ if (!bundleName) return chunkBundles;
2353
+ if (!chunkBundles[remoteName]) chunkBundles[remoteName] = /* @__PURE__ */ new Set();
2354
+ chunkBundles[remoteName].add(bundleName);
2355
+ return chunkBundles;
2356
+ }
2357
+ function addChunkImports(importMap, chunkBundles) {
2358
+ Object.entries(chunkBundles).forEach(([remoteName, bundles]) => {
2359
+ const baseUrl = getScope2("CHUNKS", remoteName);
2360
+ const imports = Array.from(bundles).reduce((_imports, bundleName) => {
2361
+ ports.sharedChunksRepo.tryGet(remoteName, bundleName).ifPresent((files) => {
2362
+ files.forEach((file) => {
2363
+ const url = join(baseUrl, file);
2364
+ _imports[toChunkImport(file)] = url;
2365
+ addIntegrity(importMap, url, remoteName, file);
2366
+ });
2367
+ });
2368
+ return _imports;
2369
+ }, {});
2370
+ if (Object.keys(imports).length > 0) addToScope(importMap, baseUrl, imports);
2371
+ });
2372
+ return importMap;
2373
+ }
2374
+ function addIntegrity(importMap, url, remoteName, file) {
2375
+ const hash = ports.remoteInfoRepo.tryGet(remoteName).get()?.integrity?.[file];
2376
+ if (!hash) return;
2377
+ if (!importMap.integrity) importMap.integrity = {};
2378
+ importMap.integrity[url] = hash;
2379
+ }
2380
+ function getScope2(ctx, remoteName, externalName) {
2381
+ return ports.remoteInfoRepo.tryGet(remoteName).map((remote) => remote.scopeUrl).orThrow(() => {
2382
+ if (externalName) {
2383
+ config.log.error(
2384
+ 4,
2385
+ `[${ctx}][${externalName}][${remoteName}] Remote name not found in cache.`
2386
+ );
2387
+ } else {
2388
+ config.log.error(4, `[${ctx}][${remoteName}] Remote name not found in cache.`);
2389
+ }
2390
+ return new NFError("Could not create ImportMap.");
2391
+ });
2392
+ }
2393
+ }
2394
+
2395
+ // src/lib/2.app/flows/init/commit-changes.ts
2396
+ function createCommitChanges(config, ports) {
2397
+ return (importMap) => Promise.resolve(importMap).then(addToBrowser).then(persistRepositoryChanges);
2398
+ function addToBrowser(importMap) {
2399
+ ports.browser.setImportMapFn(importMap);
2400
+ config.log.debug(5, "Added import map to browser.", importMap);
2401
+ return importMap;
2402
+ }
2403
+ function persistRepositoryChanges() {
2404
+ ports.remoteInfoRepo.commit();
2405
+ ports.scopedExternalsRepo.commit();
2406
+ ports.sharedExternalsRepo.commit();
2407
+ ports.sharedChunksRepo.commit();
2408
+ return;
2409
+ }
2410
+ }
2411
+
2412
+ // src/lib/2.app/flows/init/expose-module-loader.ts
2413
+ function createExposeModuleLoader(config, ports) {
2414
+ const loadRemoteModule = (remoteName, exposedModule) => {
2415
+ try {
2416
+ if (!ports.remoteInfoRepo.contains(remoteName)) {
2417
+ throw new NFError(`Remote '${remoteName}' is not initialized.`);
2418
+ }
2419
+ const remoteModuleUrl = ports.remoteInfoRepo.tryGetModule(remoteName, exposedModule).orThrow(
2420
+ new NFError(
2421
+ `Exposed module '${exposedModule}' from remote '${remoteName}' not found in storage.`
2422
+ )
2423
+ );
2424
+ config.log.debug(6, `Loading initialized module '${remoteModuleUrl}'`);
2425
+ return ports.browser.importModule(remoteModuleUrl);
2426
+ } catch (error) {
2427
+ config.log.error(6, `Failed to load module ${join(remoteName, exposedModule)}: `, {
2428
+ error
2429
+ });
2430
+ return Promise.reject(
2431
+ new NFError(`Failed to load module ${join(remoteName, exposedModule)}`)
2432
+ );
2433
+ }
2434
+ };
2435
+ return () => Promise.resolve(loadRemoteModule);
2436
+ }
2437
+
2438
+ // src/lib/5.di/flows/init.factory.ts
2439
+ var createInitDrivers = ({
2440
+ config,
2441
+ adapters
2442
+ }) => ({
2443
+ getRemoteEntries: createGetRemoteEntries(config, adapters),
2444
+ processRemoteEntries: createProcessRemoteEntries(config, adapters),
2445
+ determineSharedExternals: createDetermineSharedExternals(config, adapters),
2446
+ generateImportMap: createGenerateImportMap(config, adapters),
2447
+ commitChanges: createCommitChanges(config, adapters),
2448
+ exposeModuleLoader: createExposeModuleLoader(config, adapters)
2449
+ });
2450
+ var INIT_FLOW_FACTORY = ({
2451
+ config,
2452
+ adapters
2453
+ }) => {
2454
+ const flow = createInitDrivers({ config, adapters });
2455
+ return {
2456
+ flow,
2457
+ adapters,
2458
+ config
2459
+ };
2460
+ };
2461
+ var createInitFlow = ({
2462
+ flow,
2463
+ adapters,
2464
+ config
2465
+ }) => {
2466
+ return (remotesOrManifestUrl) => flow.getRemoteEntries(remotesOrManifestUrl).then(flow.processRemoteEntries).then(flow.determineSharedExternals).then(flow.generateImportMap).then(flow.commitChanges).then(flow.exposeModuleLoader).then((loadRemoteModule) => ({
2467
+ config,
2468
+ adapters,
2469
+ loadRemoteModule
2470
+ }));
2471
+ };
2472
+
2473
+ // src/lib/2.app/flows/dynamic-init/convert-to-import-map.ts
2474
+ function createConvertToImportMap({ log }, ports) {
2475
+ return ({ entry, actions }) => {
2476
+ const importMap = { imports: {} };
2477
+ addExternals(entry, actions, importMap);
2478
+ addRemoteInfos(entry, importMap);
2479
+ log.debug(9, `[${entry.name}] Processed actions:`, actions);
2480
+ return Promise.resolve(importMap);
2481
+ };
2482
+ function addExternals(remoteEntry, actions, importMap) {
2483
+ if (!remoteEntry.shared) {
2484
+ return;
2485
+ }
2486
+ const remoteEntryScope = getScope(remoteEntry.url);
2487
+ const integrityMap = remoteEntry.integrity;
2488
+ const chunkBundles = /* @__PURE__ */ new Set(["mapping-or-exposed"]);
2489
+ remoteEntry.shared.forEach((external) => {
2490
+ if (!external.singleton) {
2491
+ const url2 = join(remoteEntryScope, external.outFileName);
2492
+ addToScopes(remoteEntryScope, external.packageName, url2, importMap);
2493
+ addIntegrity(importMap, url2, integrityMap, external.outFileName);
2494
+ if (external?.bundle) chunkBundles.add(external?.bundle);
2495
+ return;
2496
+ }
2497
+ if (!actions[external.packageName]) {
2498
+ log.warn(
2499
+ 9,
2500
+ `[${remoteEntry.name}] No action defined for shared external '${external.packageName}', skipping.`
2501
+ );
2502
+ return;
2503
+ }
2504
+ if (actions[external.packageName].action === "skip") {
2505
+ if (!external.shareScope) return;
2506
+ if (actions[external.packageName].override) {
2507
+ addToScopes(
2508
+ remoteEntryScope,
2509
+ external.packageName,
2510
+ actions[external.packageName].override,
2511
+ importMap
2512
+ );
2513
+ return;
2514
+ }
2515
+ }
2516
+ if (external?.bundle) chunkBundles.add(external?.bundle);
2517
+ if (actions[external.packageName].action === "scope") {
2518
+ const url2 = join(remoteEntryScope, external.outFileName);
2519
+ addToScopes(remoteEntryScope, external.packageName, url2, importMap);
2520
+ addIntegrity(importMap, url2, integrityMap, external.outFileName);
2521
+ return;
2522
+ }
2523
+ if (external.shareScope) {
2524
+ const url2 = join(remoteEntryScope, external.outFileName);
2525
+ addToScopes(remoteEntryScope, external.packageName, url2, importMap);
2526
+ addIntegrity(importMap, url2, integrityMap, external.outFileName);
2527
+ return;
2528
+ }
2529
+ const url = join(remoteEntryScope, external.outFileName);
2530
+ importMap.imports[external.packageName] = url;
2531
+ addIntegrity(importMap, url, integrityMap, external.outFileName);
2532
+ });
2533
+ addChunkImports(importMap, remoteEntry, remoteEntryScope, chunkBundles);
2534
+ }
2535
+ function addToScopes(scope, packageName, url, importMap) {
2536
+ if (!importMap.scopes) importMap.scopes = {};
2537
+ if (!importMap.scopes[scope]) importMap.scopes[scope] = {};
2538
+ importMap.scopes[scope][packageName] = url;
2539
+ }
2540
+ function addRemoteInfos(remoteEntry, importMap) {
2541
+ if (!remoteEntry.exposes) return;
2542
+ const scope = getScope(remoteEntry.url);
2543
+ remoteEntry.exposes.forEach((exposed) => {
2544
+ const moduleName = join(remoteEntry.name, exposed.key);
2545
+ const moduleUrl = join(scope, exposed.outFileName);
2546
+ importMap.imports[moduleName] = moduleUrl;
2547
+ addIntegrity(importMap, moduleUrl, remoteEntry.integrity, exposed.outFileName);
2548
+ });
2549
+ }
2550
+ function addChunkImports(importMap, remoteEntry, remoteEntryScope, chunkBundles) {
2551
+ Array.from(chunkBundles).forEach((bundleName) => {
2552
+ ports.sharedChunksRepo.tryGet(remoteEntry.name, bundleName).ifPresent((files) => {
2553
+ files.forEach((file) => {
2554
+ const url = join(remoteEntryScope, file);
2555
+ addToScopes(remoteEntryScope, toChunkImport(file), url, importMap);
2556
+ addIntegrity(importMap, url, remoteEntry.integrity, file);
2557
+ });
2558
+ });
2559
+ });
2560
+ return importMap;
2561
+ }
2562
+ function addIntegrity(importMap, url, integrityMap, file) {
2563
+ const hash = integrityMap?.[file];
2564
+ if (!hash) return;
2565
+ if (!importMap.integrity) importMap.integrity = {};
2566
+ importMap.integrity[url] = hash;
2567
+ }
2568
+ }
2569
+
2570
+ // src/lib/2.app/flows/dynamic-init/get-remote-entry.ts
2571
+ var normalizeRemoteRef = (remote) => {
2572
+ if (!remote) return {};
2573
+ if (typeof remote === "string") return { name: remote };
2574
+ return remote;
2575
+ };
2576
+ function createGetRemoteEntry(config, ports) {
2577
+ return async (remoteEntryUrl, remote) => {
2578
+ const { name: remoteName, integrity } = normalizeRemoteRef(remote);
2579
+ if (!!remoteName && shouldSkipCachedRemote(remoteEntryUrl, remoteName)) {
2580
+ config.log.debug(7, `Found remote '${remoteName}' in storage, omitting fetch.`);
2581
+ return Optional.empty();
2582
+ }
2583
+ try {
2584
+ const remoteEntry = integrity ? await ports.remoteEntryProvider.provide(remoteEntryUrl, { integrity }) : await ports.remoteEntryProvider.provide(remoteEntryUrl);
2585
+ config.log.debug(
2586
+ 7,
2587
+ `[${remoteEntry.name}] Fetched from '${remoteEntry.url}', exposing: ${JSON.stringify(remoteEntry.exposes)}`
2588
+ );
2589
+ if (!!remoteName && remoteEntry.name !== remoteName) {
2590
+ const errorMsg = `Fetched remote '${remoteEntry.name}' does not match requested '${remoteName}'.`;
2591
+ if (config.strict.strictRemoteEntry) {
2592
+ config.log.error(7, errorMsg);
2593
+ throw new NFError("Could not fetch remote entry");
2594
+ }
2595
+ config.log.warn(7, errorMsg + " Omitting expected name.");
2596
+ }
2597
+ if (ports.remoteInfoRepo.contains(remoteEntry.name)) {
2598
+ remoteEntry.override = true;
2599
+ config.log.debug(7, `Overriding existing remote '${remoteName}' with '${remoteEntryUrl}'.`);
2600
+ }
2601
+ return Optional.of(checkForSSE(remoteEntry));
2602
+ } catch (error) {
2603
+ config.log.error(
2604
+ 7,
2605
+ `[${remoteName ?? "unknown"}] Could not fetch remoteEntry from ${remoteEntryUrl}.`,
2606
+ error
2607
+ );
2608
+ return Promise.reject(
2609
+ new NFError(`[${remoteName ?? remoteEntryUrl}] Could not fetch remoteEntry.`)
2610
+ );
2611
+ }
2612
+ };
2613
+ function shouldSkipCachedRemote(remoteEntryUrl, remoteName) {
2614
+ return ports.remoteInfoRepo.tryGet(remoteName).map(
2615
+ (cachedRemoteInfo) => config.profile.overrideCachedRemotes !== "always" || !config.profile.overrideCachedRemotesIfURLMatches && remoteEntryUrl === join(cachedRemoteInfo.scopeUrl, "remoteEntry.json")
2616
+ ).orElse(false);
2617
+ }
2618
+ function checkForSSE(entry) {
2619
+ if (config.sse) {
2620
+ if (entry.buildNotificationsEndpoint) {
2621
+ ports.sse.watchRemoteBuilds(
2622
+ join(getScope(entry.url), entry.buildNotificationsEndpoint)
2623
+ );
2624
+ config.log.debug(7, `Registered SSE endpoint of remote '${entry.name}' `);
2625
+ } else {
2626
+ config.log.debug(7, `Remote ${entry.name} has no defined 'buildNotificationsEndpoint'`);
2627
+ }
2628
+ }
2629
+ return entry;
2630
+ }
2631
+ }
2632
+
2633
+ // src/lib/2.app/flows/dynamic-init/update-cache.ts
2634
+ function createUpdateCache(config, ports) {
2635
+ return (remoteEntry) => {
2636
+ try {
2637
+ if (remoteEntry?.override) removeCachedRemoteEntry(remoteEntry);
2638
+ addRemoteInfoToStorage(remoteEntry);
2639
+ const actions = mergeExternalsIntoStorage(remoteEntry);
2640
+ addSharedChunksToStorage(remoteEntry);
2641
+ return Promise.resolve({ entry: remoteEntry, actions });
2642
+ } catch (error) {
2643
+ return Promise.reject(error);
2644
+ }
2645
+ };
2646
+ function removeCachedRemoteEntry(remoteEntry) {
2647
+ ports.remoteInfoRepo.remove(remoteEntry.name);
2648
+ ports.scopedExternalsRepo.remove(remoteEntry.name);
2649
+ ports.sharedExternalsRepo.removeFromAllScopes(remoteEntry.name);
2650
+ }
2651
+ function addRemoteInfoToStorage({ name, url, exposes }) {
2652
+ ports.remoteInfoRepo.addOrUpdate(name, {
2653
+ scopeUrl: getScope(url),
2654
+ exposes: Object.values(exposes ?? []).map((m) => ({
2655
+ moduleName: m.key,
2656
+ file: m.outFileName
2657
+ }))
2658
+ });
2659
+ }
2660
+ function mergeExternalsIntoStorage(remoteEntry) {
2661
+ const actions = {};
2662
+ remoteEntry.shared.forEach((external) => {
2663
+ if (!external.version || !ports.versionCheck.isValidSemver(external.version)) {
2664
+ const errorMsg = `[${remoteEntry.name}][${external.packageName}] Version '${external.version}' is not a valid version.`;
2665
+ if (config.strict.strictExternalVersion) {
2666
+ config.log.error(8, errorMsg);
2667
+ throw new NFError(`Could not process remote '${remoteEntry.name}'`);
2668
+ }
2669
+ config.log.warn(8, errorMsg);
2670
+ }
2671
+ if (external.singleton) {
2672
+ const { action, sharedVersion } = addSharedExternal(remoteEntry.name, external);
2673
+ actions[external.packageName] = { action };
2674
+ if (action === "skip" && external.shareScope && sharedVersion?.remotes[0]?.file) {
2675
+ actions[external.packageName].override = ports.remoteInfoRepo.tryGet(sharedVersion.remotes[0].name).map((remote) => join(remote.scopeUrl, sharedVersion.remotes[0].file)).orThrow(() => {
2676
+ config.log.error(
2677
+ 8,
2678
+ `[${external.shareScope ?? GLOBAL_SCOPE}][${remoteEntry.name}][${external.packageName}@${external.version}][override] Remote name not found in cache.`
2679
+ );
2680
+ return new NFError(
2681
+ `Could not find override url from remote ${sharedVersion.remotes[0].name}`
2682
+ );
2683
+ });
2684
+ }
2685
+ } else {
2686
+ addScopedExternal(remoteEntry.name, external);
2687
+ }
2688
+ });
2689
+ return actions;
2690
+ }
2691
+ function addSharedChunksToStorage(remoteEntry) {
2692
+ if (!remoteEntry.chunks) return;
2693
+ config.log.debug(
2694
+ 8,
2695
+ `Adding chunks for remote "${remoteEntry.name}", bundles: [${Object.keys(remoteEntry.chunks).join(", ")}]`
2696
+ );
2697
+ Object.entries(remoteEntry.chunks).forEach(([bundleName, chunks]) => {
2698
+ ports.sharedChunksRepo.addOrReplace(remoteEntry.name, bundleName, chunks);
2699
+ });
2700
+ }
2701
+ function addSharedExternal(remoteName, sharedInfo) {
2702
+ const cached2 = ports.sharedExternalsRepo.tryGet(sharedInfo.packageName, sharedInfo.shareScope).orElse({ dirty: false, versions: [] });
2703
+ let action = "skip";
2704
+ const tag = sharedInfo.version ?? ports.versionCheck.smallestVersion(sharedInfo.requiredVersion);
2705
+ const remote = {
2706
+ file: sharedInfo.outFileName,
2707
+ strictVersion: sharedInfo.strictVersion,
2708
+ requiredVersion: sharedInfo.requiredVersion || tag,
2709
+ name: remoteName,
2710
+ bundle: sharedInfo.bundle,
2711
+ cached: false
2712
+ };
2713
+ const scopeType = ports.sharedExternalsRepo.scopeType(sharedInfo.shareScope);
2714
+ if (scopeType === "strict") {
2715
+ remote.requiredVersion = tag;
2716
+ action = "share";
2717
+ }
2718
+ const sharedVersion = cached2.versions.find((c) => c.action === "share");
2719
+ const isCompatible = !sharedVersion || ports.versionCheck.isCompatible(sharedVersion.tag, remote.requiredVersion);
2720
+ if (action === "skip" && !isCompatible && remote.strictVersion) {
2721
+ action = "scope";
2722
+ const errorMsg = `[${sharedInfo.shareScope ?? GLOBAL_SCOPE}][${remoteName}] ${sharedInfo.packageName}@${sharedInfo.version} Is not compatible with existing ${sharedInfo.packageName}@${sharedVersion.tag} requiredRange '${sharedVersion.remotes[0]?.requiredVersion}'`;
2723
+ if (config.strict.strictExternalCompatibility) {
2724
+ config.log.error(8, errorMsg);
2725
+ throw new NFError(`Could not process remote '${remoteName}'`);
2726
+ }
2727
+ config.log.warn(8, errorMsg);
2728
+ }
2729
+ const matchingVersion = cached2.versions.find((cached3) => cached3.tag === tag);
2730
+ if (!!matchingVersion) {
2731
+ if (remote.strictVersion && matchingVersion.remotes[0].requiredVersion !== remote.requiredVersion) {
2732
+ const errorMsg = `[${remoteName}][${sharedInfo.packageName}@${sharedInfo.version}] Required version '${remote.requiredVersion}' does not match existing '${matchingVersion.remotes[0].requiredVersion}'`;
2733
+ if (config.strict.strictExternalCompatibility) {
2734
+ config.log.error(8, errorMsg);
2735
+ throw new NFError(`Could not process remote '${remoteName}'`);
2736
+ }
2737
+ config.log.warn(8, errorMsg);
2738
+ }
2739
+ matchingVersion.remotes.push(remote);
2740
+ } else {
2741
+ if (!sharedVersion) action = "share";
2742
+ remote.cached = action !== "skip";
2743
+ cached2.versions.push({ tag, action, host: false, remotes: [remote] });
2744
+ }
2745
+ ports.sharedExternalsRepo.addOrUpdate(
2746
+ sharedInfo.packageName,
2747
+ {
2748
+ dirty: cached2.dirty,
2749
+ versions: cached2.versions.sort((a, b) => ports.versionCheck.compare(b.tag, a.tag))
2750
+ },
2751
+ sharedInfo.shareScope
2752
+ );
2753
+ return { action, sharedVersion };
2754
+ }
2755
+ function addScopedExternal(remoteName, sharedInfo) {
2756
+ ports.scopedExternalsRepo.addExternal(remoteName, sharedInfo.packageName, {
2757
+ tag: sharedInfo.version ?? ports.versionCheck.smallestVersion(sharedInfo.requiredVersion),
2758
+ file: sharedInfo.outFileName,
2759
+ bundle: sharedInfo.bundle
2760
+ });
2761
+ }
2762
+ }
2763
+
2764
+ // src/lib/5.di/flows/dynamic-init.factory.ts
2765
+ var createDynamicInitDrivers = ({
2766
+ config,
2767
+ adapters
2768
+ }) => ({
2769
+ getRemoteEntry: createGetRemoteEntry(config, adapters),
2770
+ updateCache: createUpdateCache(config, adapters),
2771
+ convertToImportMap: createConvertToImportMap(config, adapters),
2772
+ commitChanges: createCommitChanges(config, adapters)
2773
+ });
2774
+ var DYNAMIC_INIT_FLOW_FACTORY = ({
2775
+ config,
2776
+ adapters
2777
+ }) => {
2778
+ const flow = createDynamicInitDrivers({ config, adapters });
2779
+ return {
2780
+ flow,
2781
+ adapters,
2782
+ config
2783
+ };
2784
+ };
2785
+ var createDynamicInitFlow = ({
2786
+ flow,
2787
+ adapters,
2788
+ config
2789
+ }) => {
2790
+ const processDynamicRemoteEntry = async (remoteEntry) => {
2791
+ return flow.updateCache(remoteEntry).then(flow.convertToImportMap).then(flow.commitChanges);
2792
+ };
2793
+ const initRemoteEntry = (remoteEntryUrl, remote) => flow.getRemoteEntry(remoteEntryUrl, remote).then((entry) => entry.map(processDynamicRemoteEntry).orElse(Promise.resolve())).then(() => ({
2794
+ config,
2795
+ adapters,
2796
+ initRemoteEntry
2797
+ }));
2798
+ return initRemoteEntry;
2799
+ };
2800
+
2801
+ // src/lib/3.adapters/node/node-loader.client.ts
2802
+ import { register } from "node:module";
2803
+ import { MessageChannel } from "node:worker_threads";
2804
+
2805
+ // src/lib/3.adapters/node/loader-url.ts
2806
+ import { createRequire } from "node:module";
2807
+ import { pathToFileURL } from "node:url";
2808
+ var getLoaderUrl = () => {
2809
+ try {
2810
+ const require2 = createRequire(import.meta.url);
2811
+ return pathToFileURL(
2812
+ require2.resolve("@softarc/native-federation-orchestrator/node-loader/loader.mjs")
2813
+ );
2814
+ } catch (err) {
2815
+ const cause = err instanceof Error ? err : new Error(String(err));
2816
+ throw new NFError(
2817
+ `Could not locate the bundled node-loader at '@softarc/native-federation-orchestrator/node-loader/loader.mjs'. Ensure it is installed, and that its 'exports' map exposes this subpath: ${cause.message}`,
2818
+ cause
2819
+ );
2820
+ }
2821
+ };
2822
+
2823
+ // src/lib/3.adapters/node/node-loader.client.ts
2824
+ var NODE_LOADER_CLIENT_ACK_TIMEOUT_MS = 1e4;
2825
+ var cached = null;
2826
+ var createClient = () => {
2827
+ const { port1, port2 } = new MessageChannel();
2828
+ register(getLoaderUrl(), {
2829
+ data: { port: port2 },
2830
+ transferList: [port2]
2831
+ });
2832
+ port1.unref();
2833
+ let pending = Promise.resolve();
2834
+ const postAndAwaitAck = (map) => new Promise((resolve, reject) => {
2835
+ let timer = null;
2836
+ const cleanup = () => {
2837
+ port1.off("message", onMessage);
2838
+ if (timer !== null) clearTimeout(timer);
2839
+ };
2840
+ const onMessage = (msg) => {
2841
+ if (msg?.type === "import-map-applied") {
2842
+ cleanup();
2843
+ resolve();
2844
+ }
2845
+ };
2846
+ port1.on("message", onMessage);
2847
+ timer = setTimeout(() => {
2848
+ cleanup();
2849
+ reject(
2850
+ new Error(
2851
+ `node-loader.client: loader did not acknowledge set-import-map within ${NODE_LOADER_CLIENT_ACK_TIMEOUT_MS}ms`
2852
+ )
2853
+ );
2854
+ }, NODE_LOADER_CLIENT_ACK_TIMEOUT_MS);
2855
+ timer.unref?.();
2856
+ try {
2857
+ const outgoing = { type: "set-import-map", map };
2858
+ port1.postMessage(outgoing);
2859
+ } catch (err) {
2860
+ cleanup();
2861
+ reject(err);
2862
+ }
2863
+ });
2864
+ const setMap = (map) => {
2865
+ const next = pending.catch(() => void 0).then(() => postAndAwaitAck(map));
2866
+ pending = next;
2867
+ return next;
2868
+ };
2869
+ return {
2870
+ setMap,
2871
+ ready: () => pending
2872
+ };
2873
+ };
2874
+ var getNodeLoaderClient = () => {
2875
+ if (!cached) cached = createClient();
2876
+ return cached;
2877
+ };
2878
+
2879
+ // src/lib/4.config/import-map/use-node.ts
2880
+ var useNodeImportMap = () => {
2881
+ const nodeLoader = getNodeLoaderClient();
2882
+ return {
2883
+ nodeLoader,
2884
+ loadModuleFn: (url) => import(
2885
+ /* @vite-ignore */
2886
+ url
2887
+ ),
2888
+ setImportMapFn: (importMap) => nodeLoader.setMap(importMap).then(() => importMap),
2889
+ reloadBrowserFn: () => {
2890
+ }
2891
+ };
2892
+ };
2893
+
2894
+ // src/lib/utils/node/to-url.ts
2895
+ import { pathToFileURL as pathToFileURL2 } from "node:url";
2896
+ var URL_SCHEME = /^[a-z][a-z0-9+\-.]*:/i;
2897
+ var toUrl = (pathOrUrl) => URL_SCHEME.test(pathOrUrl) ? pathOrUrl : pathToFileURL2(pathOrUrl).href;
2898
+ var normalizeHostRemoteEntry = (hostRemoteEntry) => {
2899
+ if (!hostRemoteEntry) return hostRemoteEntry;
2900
+ if (typeof hostRemoteEntry === "string") return toUrl(hostRemoteEntry);
2901
+ return { ...hostRemoteEntry, url: toUrl(hostRemoteEntry.url) };
2902
+ };
2903
+
2904
+ // src/lib/init-federation.node.ts
2905
+ var buildNodeAdapters = (config) => ({
2906
+ versionCheck: createVersionCheck(),
2907
+ manifestProvider: createFsManifestProvider(),
2908
+ remoteEntryProvider: createFsRemoteEntryProvider(),
2909
+ remoteInfoRepo: createRemoteInfoRepository(config),
2910
+ scopedExternalsRepo: createScopedExternalsRepository(config),
2911
+ sharedExternalsRepo: createSharedExternalsRepository(config),
2912
+ sharedChunksRepo: createChunkRepository(config),
2913
+ browser: createBrowser(config),
2914
+ sse: createNoopSSE()
2915
+ });
2916
+ var initNodeFederation = (remotesOrManifestUrl, options = {}) => {
2917
+ const nodeConfig = useNodeImportMap();
2918
+ const config = createConfigHandlers({
2919
+ ...options,
2920
+ hostRemoteEntry: normalizeHostRemoteEntry(options.hostRemoteEntry),
2921
+ loadModuleFn: options.loadModuleFn ?? nodeConfig.loadModuleFn,
2922
+ setImportMapFn: options.setImportMapFn ?? nodeConfig.setImportMapFn,
2923
+ reloadBrowserFn: options.reloadBrowserFn ?? nodeConfig.reloadBrowserFn,
2924
+ sse: false
2925
+ });
2926
+ const adapters = buildNodeAdapters(config);
2927
+ const stateDump = (msg) => config.log.debug(0, msg, {
2928
+ remotes: { ...adapters.remoteInfoRepo.getAll() },
2929
+ "shared-externals": adapters.sharedExternalsRepo.getScopes({ includeGlobal: true }).reduce(
2930
+ (acc, scope) => ({ ...acc, [scope]: adapters.sharedExternalsRepo.getFromScope(scope) }),
2931
+ {}
2932
+ ),
2933
+ "scoped-externals": adapters.scopedExternalsRepo.getAll()
2934
+ });
2935
+ const initFlow = createInitFlow(INIT_FLOW_FACTORY({ adapters, config }));
2936
+ const dynamicInitFlow = createDynamicInitFlow(DYNAMIC_INIT_FLOW_FACTORY({ config, adapters }));
2937
+ return initFlow(remotesOrManifestUrl).then(({ loadRemoteModule }) => nodeConfig.nodeLoader.ready().then(() => loadRemoteModule)).then((loadRemoteModule) => {
2938
+ const output = {
2939
+ config,
2940
+ adapters,
2941
+ loadRemoteModule,
2942
+ as: () => ({
2943
+ loadRemoteModule,
2944
+ load: loadRemoteModule
2945
+ }),
2946
+ load: loadRemoteModule
2947
+ };
2948
+ const initRemoteEntry = async (remoteEntryUrl, remote) => {
2949
+ const remoteName = typeof remote === "string" ? remote : remote?.name;
2950
+ return dynamicInitFlow(remoteEntryUrl, remote).catch((e) => {
2951
+ stateDump(`[dynamic-init][${remoteName ?? remoteEntryUrl}] STATE DUMP`);
2952
+ if (config.strict.strictRemoteEntry) return Promise.reject(e);
2953
+ else console.warn("Failed to initialize remote entry, continuing anyway.");
2954
+ return Promise.resolve();
2955
+ }).then(() => nodeConfig.nodeLoader.ready()).then(() => ({
2956
+ ...output,
2957
+ initRemoteEntry
2958
+ }));
2959
+ };
2960
+ return {
2961
+ ...output,
2962
+ initRemoteEntry
2963
+ };
2964
+ }).catch((e) => {
2965
+ stateDump(`[init] STATE DUMP`);
2966
+ return Promise.reject(e);
2967
+ });
2968
+ };
2969
+ export {
2970
+ NFError,
2971
+ initNodeFederation
2972
+ };
2973
+ //# sourceMappingURL=node.mjs.map