@softarc/native-federation-orchestrator 4.0.0-RC1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +9 -0
- package/README.md +142 -0
- package/fesm2022/@softarc/native-federation-orchestrator.mjs +2539 -0
- package/fesm2022/@softarc/native-federation-orchestrator.mjs.map +7 -0
- package/fesm2022/audit.mjs +67 -0
- package/fesm2022/audit.mjs.map +7 -0
- package/fesm2022/options.mjs +173 -0
- package/fesm2022/options.mjs.map +7 -0
- package/fesm2022/registry.mjs +110 -0
- package/fesm2022/registry.mjs.map +7 -0
- package/fesm2022/sdk.mjs +99 -0
- package/fesm2022/sdk.mjs.map +7 -0
- package/init-registry.mjs +1 -0
- package/package.json +58 -0
- package/quickstart.mjs +18 -0
- package/types/init-registry.d.ts +6 -0
- package/types/lib/1.domain/externals/external.contract.d.ts +14 -0
- package/types/lib/1.domain/externals/version.contract.d.ts +21 -0
- package/types/lib/1.domain/import-map/import-map.contract.d.ts +7 -0
- package/types/lib/1.domain/index.d.ts +7 -0
- package/types/lib/1.domain/registry/event-registry.contract.d.ts +8 -0
- package/types/lib/1.domain/registry/event.contract.d.ts +15 -0
- package/types/lib/1.domain/registry/index.d.ts +3 -0
- package/types/lib/1.domain/registry/registry-options.contract.d.ts +11 -0
- package/types/lib/1.domain/remote/remote-info.contract.d.ts +8 -0
- package/types/lib/1.domain/remote/remote-module.contract.d.ts +4 -0
- package/types/lib/1.domain/remote-entry/manifest.contract.d.ts +3 -0
- package/types/lib/1.domain/remote-entry/remote-entry.contract.d.ts +30 -0
- package/types/lib/2.app/config/config.contract.d.ts +7 -0
- package/types/lib/2.app/config/host.contract.d.ts +14 -0
- package/types/lib/2.app/config/import-map.contract.d.ts +9 -0
- package/types/lib/2.app/config/index.d.ts +6 -0
- package/types/lib/2.app/config/log.contract.d.ts +21 -0
- package/types/lib/2.app/config/mode.contract.d.ts +19 -0
- package/types/lib/2.app/config/registry.contract.d.ts +6 -0
- package/types/lib/2.app/config/storage.contract.d.ts +18 -0
- package/types/lib/2.app/driver-ports/audit/for-auditing-externals.port.d.ts +2 -0
- package/types/lib/2.app/driver-ports/audit/index.d.ts +1 -0
- package/types/lib/2.app/driver-ports/dynamic-init/drivers.contract.d.ts +13 -0
- package/types/lib/2.app/driver-ports/dynamic-init/flow.contract.d.ts +4 -0
- package/types/lib/2.app/driver-ports/dynamic-init/for-converting-to-import-map.d.ts +6 -0
- package/types/lib/2.app/driver-ports/dynamic-init/for-getting-remote-entry.port.d.ts +3 -0
- package/types/lib/2.app/driver-ports/dynamic-init/for-updating-cache.d.ts +5 -0
- package/types/lib/2.app/driver-ports/dynamic-init/index.d.ts +5 -0
- package/types/lib/2.app/driver-ports/flow-factory.contract.d.ts +7 -0
- package/types/lib/2.app/driver-ports/init/drivers.contract.d.ts +17 -0
- package/types/lib/2.app/driver-ports/init/flow.contract.d.ts +6 -0
- package/types/lib/2.app/driver-ports/init/for-committing-changes.port.d.ts +2 -0
- package/types/lib/2.app/driver-ports/init/for-determining-shared-externals.port.d.ts +1 -0
- package/types/lib/2.app/driver-ports/init/for-exposing-module-loader.port.d.ts +2 -0
- package/types/lib/2.app/driver-ports/init/for-generating-import-map.d.ts +2 -0
- package/types/lib/2.app/driver-ports/init/for-getting-remote-entries.port.d.ts +3 -0
- package/types/lib/2.app/driver-ports/init/for-processing-remote-entries.port.d.ts +2 -0
- package/types/lib/2.app/driver-ports/init/index.d.ts +8 -0
- package/types/lib/2.app/driver-ports/registry/for-managing-events.port.d.ts +2 -0
- package/types/lib/2.app/driving-ports/driving.contract.d.ts +16 -0
- package/types/lib/2.app/driving-ports/for-browser-tasks.d.ts +7 -0
- package/types/lib/2.app/driving-ports/for-providing-manifest.port.d.ts +4 -0
- package/types/lib/2.app/driving-ports/for-providing-remote-entries.port.d.ts +4 -0
- package/types/lib/2.app/driving-ports/for-remote-info-storage.port.d.ts +11 -0
- package/types/lib/2.app/driving-ports/for-scoped-externals-storage.port.d.ts +9 -0
- package/types/lib/2.app/driving-ports/for-shared-externals-storage.port.d.ts +13 -0
- package/types/lib/2.app/driving-ports/for-version-checking.port.d.ts +6 -0
- package/types/lib/2.app/driving-ports/index.d.ts +8 -0
- package/types/lib/2.app/flows/audit/externals-audit.d.ts +4 -0
- package/types/lib/2.app/flows/dynamic-init/convert-to-import-map.d.ts +3 -0
- package/types/lib/2.app/flows/dynamic-init/get-remote-entry.d.ts +5 -0
- package/types/lib/2.app/flows/dynamic-init/update-cache.d.ts +5 -0
- package/types/lib/2.app/flows/init/commit-changes.d.ts +4 -0
- package/types/lib/2.app/flows/init/determine-shared-externals.d.ts +5 -0
- package/types/lib/2.app/flows/init/expose-module-loader.d.ts +4 -0
- package/types/lib/2.app/flows/init/generate-import-map.d.ts +5 -0
- package/types/lib/2.app/flows/init/get-remote-entries.d.ts +6 -0
- package/types/lib/2.app/flows/init/process-remote-entries.d.ts +5 -0
- package/types/lib/2.app/flows/registry/setup-registry.d.ts +3 -0
- package/types/lib/3.adapters/browser/browser.d.ts +4 -0
- package/types/lib/3.adapters/checks/version.check.d.ts +3 -0
- package/types/lib/3.adapters/http/manifest-provider.d.ts +3 -0
- package/types/lib/3.adapters/http/remote-entry-provider.d.ts +3 -0
- package/types/lib/3.adapters/storage/remote-info.repository.d.ts +4 -0
- package/types/lib/3.adapters/storage/scoped-externals.repository.d.ts +4 -0
- package/types/lib/3.adapters/storage/shared-externals.repository.d.ts +4 -0
- package/types/lib/4.config/host/host.config.d.ts +2 -0
- package/types/lib/4.config/import-map/import-map.config.d.ts +2 -0
- package/types/lib/4.config/import-map/index.d.ts +3 -0
- package/types/lib/4.config/import-map/replace-in-dom.d.ts +2 -0
- package/types/lib/4.config/import-map/use-default.d.ts +3 -0
- package/types/lib/4.config/import-map/use-import-shim.d.ts +5 -0
- package/types/lib/4.config/logging/console.logger.d.ts +3 -0
- package/types/lib/4.config/logging/index.d.ts +2 -0
- package/types/lib/4.config/logging/log.config.d.ts +2 -0
- package/types/lib/4.config/logging/log.handler.d.ts +3 -0
- package/types/lib/4.config/logging/noop.logger.d.ts +3 -0
- package/types/lib/4.config/mode/caching.profile.d.ts +2 -0
- package/types/lib/4.config/mode/default.profile.d.ts +2 -0
- package/types/lib/4.config/mode/index.d.ts +2 -0
- package/types/lib/4.config/mode/mode.config.d.ts +2 -0
- package/types/lib/4.config/storage/global-this.storage.d.ts +3 -0
- package/types/lib/4.config/storage/index.d.ts +3 -0
- package/types/lib/4.config/storage/local.storage.d.ts +3 -0
- package/types/lib/4.config/storage/session.storage.d.ts +3 -0
- package/types/lib/4.config/storage/storage.config.d.ts +2 -0
- package/types/lib/5.di/config.factory.d.ts +2 -0
- package/types/lib/5.di/driving.factory.d.ts +6 -0
- package/types/lib/5.di/flows/dynamic-init.factory.d.ts +14 -0
- package/types/lib/5.di/flows/init.factory.d.ts +14 -0
- package/types/lib/6.mocks/handlers/log.handler.d.ts +2 -0
- package/types/lib/audit.index.d.ts +2 -0
- package/types/lib/index.d.ts +7 -0
- package/types/lib/init-federation.contract.d.ts +15 -0
- package/types/lib/init-federation.d.ts +4 -0
- package/types/lib/native-federation.error.d.ts +4 -0
- package/types/lib/options.index.d.ts +5 -0
- package/types/lib/registry.index.d.ts +4 -0
- package/types/lib/sdk.index.d.ts +8 -0
- package/types/lib/utils/clone-entry.d.ts +4 -0
- package/types/lib/utils/optional.d.ts +13 -0
- package/types/lib/utils/path.d.ts +3 -0
- package/types/quickstart.d.ts +1 -0
|
@@ -0,0 +1,2539 @@
|
|
|
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.7.3/node_modules/semver/internal/debug.js
|
|
28
|
+
var require_debug = __commonJS({
|
|
29
|
+
"node_modules/.pnpm/semver@7.7.3/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.7.3/node_modules/semver/internal/constants.js
|
|
38
|
+
var require_constants = __commonJS({
|
|
39
|
+
"node_modules/.pnpm/semver@7.7.3/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.7.3/node_modules/semver/internal/re.js
|
|
70
|
+
var require_re = __commonJS({
|
|
71
|
+
"node_modules/.pnpm/semver@7.7.3/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.7.3/node_modules/semver/internal/parse-options.js
|
|
158
|
+
var require_parse_options = __commonJS({
|
|
159
|
+
"node_modules/.pnpm/semver@7.7.3/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.7.3/node_modules/semver/internal/identifiers.js
|
|
177
|
+
var require_identifiers = __commonJS({
|
|
178
|
+
"node_modules/.pnpm/semver@7.7.3/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.7.3/node_modules/semver/classes/semver.js
|
|
202
|
+
var require_semver = __commonJS({
|
|
203
|
+
"node_modules/.pnpm/semver@7.7.3/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.7.3/node_modules/semver/functions/parse.js
|
|
481
|
+
var require_parse = __commonJS({
|
|
482
|
+
"node_modules/.pnpm/semver@7.7.3/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.7.3/node_modules/semver/functions/valid.js
|
|
503
|
+
var require_valid = __commonJS({
|
|
504
|
+
"node_modules/.pnpm/semver@7.7.3/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.7.3/node_modules/semver/internal/lrucache.js
|
|
516
|
+
var require_lrucache = __commonJS({
|
|
517
|
+
"node_modules/.pnpm/semver@7.7.3/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.7.3/node_modules/semver/functions/compare.js
|
|
554
|
+
var require_compare = __commonJS({
|
|
555
|
+
"node_modules/.pnpm/semver@7.7.3/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.7.3/node_modules/semver/functions/eq.js
|
|
564
|
+
var require_eq = __commonJS({
|
|
565
|
+
"node_modules/.pnpm/semver@7.7.3/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.7.3/node_modules/semver/functions/neq.js
|
|
574
|
+
var require_neq = __commonJS({
|
|
575
|
+
"node_modules/.pnpm/semver@7.7.3/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.7.3/node_modules/semver/functions/gt.js
|
|
584
|
+
var require_gt = __commonJS({
|
|
585
|
+
"node_modules/.pnpm/semver@7.7.3/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.7.3/node_modules/semver/functions/gte.js
|
|
594
|
+
var require_gte = __commonJS({
|
|
595
|
+
"node_modules/.pnpm/semver@7.7.3/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.7.3/node_modules/semver/functions/lt.js
|
|
604
|
+
var require_lt = __commonJS({
|
|
605
|
+
"node_modules/.pnpm/semver@7.7.3/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.7.3/node_modules/semver/functions/lte.js
|
|
614
|
+
var require_lte = __commonJS({
|
|
615
|
+
"node_modules/.pnpm/semver@7.7.3/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.7.3/node_modules/semver/functions/cmp.js
|
|
624
|
+
var require_cmp = __commonJS({
|
|
625
|
+
"node_modules/.pnpm/semver@7.7.3/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.7.3/node_modules/semver/classes/comparator.js
|
|
674
|
+
var require_comparator = __commonJS({
|
|
675
|
+
"node_modules/.pnpm/semver@7.7.3/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.7.3/node_modules/semver/classes/range.js
|
|
787
|
+
var require_range = __commonJS({
|
|
788
|
+
"node_modules/.pnpm/semver@7.7.3/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 cached = cache.get(memoKey);
|
|
859
|
+
if (cached) {
|
|
860
|
+
return cached;
|
|
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.7.3/node_modules/semver/functions/satisfies.js
|
|
1164
|
+
var require_satisfies = __commonJS({
|
|
1165
|
+
"node_modules/.pnpm/semver@7.7.3/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.7.3/node_modules/semver/ranges/min-version.js
|
|
1181
|
+
var require_min_version = __commonJS({
|
|
1182
|
+
"node_modules/.pnpm/semver@7.7.3/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.7.3/node_modules/semver/ranges/valid.js
|
|
1240
|
+
var require_valid2 = __commonJS({
|
|
1241
|
+
"node_modules/.pnpm/semver@7.7.3/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/native-federation.error.ts
|
|
1256
|
+
var NFError = class extends Error {
|
|
1257
|
+
constructor(message, cause) {
|
|
1258
|
+
super(message, cause);
|
|
1259
|
+
this.name = "NFError";
|
|
1260
|
+
}
|
|
1261
|
+
};
|
|
1262
|
+
|
|
1263
|
+
// src/lib/utils/path.ts
|
|
1264
|
+
function join(pathA, pathB) {
|
|
1265
|
+
pathA = pathA.endsWith("/") ? pathA.slice(0, -1) : pathA;
|
|
1266
|
+
pathB = pathB.startsWith("/") ? pathB.slice(1) : pathB;
|
|
1267
|
+
return `${pathA}/${pathB}`;
|
|
1268
|
+
}
|
|
1269
|
+
function getScope(path) {
|
|
1270
|
+
if (!path) return "";
|
|
1271
|
+
const parts = path.split("/");
|
|
1272
|
+
if (parts[parts.length - 1] === "" || parts[parts.length - 1].includes(".")) {
|
|
1273
|
+
parts.pop();
|
|
1274
|
+
}
|
|
1275
|
+
if (parts.length < 1) return "";
|
|
1276
|
+
return `${parts.join("/")}/`;
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
// src/lib/2.app/flows/init/get-remote-entries.ts
|
|
1280
|
+
function createGetRemoteEntries(config, ports) {
|
|
1281
|
+
return (remotesOrManifestUrl = {}) => ports.manifestProvider.provide(remotesOrManifestUrl).catch((e) => {
|
|
1282
|
+
config.log.error(1, "Could not fetch manifest.", e);
|
|
1283
|
+
return Promise.reject(new NFError("Failed to fetch manifest"));
|
|
1284
|
+
}).then(addHostRemoteEntry).then(fetchRemoteEntries).then(removeSkippedRemotes);
|
|
1285
|
+
function addHostRemoteEntry(manifest) {
|
|
1286
|
+
if (!config.hostRemoteEntry) return manifest;
|
|
1287
|
+
const { name, url, cacheTag } = config.hostRemoteEntry;
|
|
1288
|
+
const urlWithCache = cacheTag ? `${url}?cacheTag=${cacheTag}` : url;
|
|
1289
|
+
return {
|
|
1290
|
+
...manifest,
|
|
1291
|
+
[name]: urlWithCache
|
|
1292
|
+
};
|
|
1293
|
+
}
|
|
1294
|
+
async function fetchRemoteEntries(manifest) {
|
|
1295
|
+
const fetchPromises = Object.entries(manifest).map(
|
|
1296
|
+
([remoteName, remoteEntryUrl]) => fetchRemoteEntry(remoteName, remoteEntryUrl)
|
|
1297
|
+
);
|
|
1298
|
+
return Promise.all(fetchPromises);
|
|
1299
|
+
}
|
|
1300
|
+
async function fetchRemoteEntry(remoteName, remoteEntryUrl) {
|
|
1301
|
+
let isOverride = false;
|
|
1302
|
+
let skip = false;
|
|
1303
|
+
ports.remoteInfoRepo.tryGet(remoteName).ifPresent((cachedRemoteInfo) => {
|
|
1304
|
+
if (config.profile.overrideCachedRemotes !== "never" && (remoteEntryUrl !== join(cachedRemoteInfo.scopeUrl, "remoteEntry.json") || config.profile.overrideCachedRemotesIfURLMatches)) {
|
|
1305
|
+
config.log.debug(1, `Overriding existing remote '${remoteName}' with '${remoteEntryUrl}'.`);
|
|
1306
|
+
isOverride = true;
|
|
1307
|
+
} else {
|
|
1308
|
+
config.log.debug(1, `Found remote '${remoteName}' in storage, omitting fetch.`);
|
|
1309
|
+
skip = true;
|
|
1310
|
+
}
|
|
1311
|
+
});
|
|
1312
|
+
if (skip) return false;
|
|
1313
|
+
try {
|
|
1314
|
+
const remoteEntry = await ports.remoteEntryProvider.provide(remoteEntryUrl);
|
|
1315
|
+
config.log.debug(
|
|
1316
|
+
1,
|
|
1317
|
+
`Fetched '${remoteEntry.name}' from '${remoteEntry.url}', exposing: ${JSON.stringify(remoteEntry.exposes)}`
|
|
1318
|
+
);
|
|
1319
|
+
return prepareRemoteEntry(remoteEntry, remoteName, isOverride);
|
|
1320
|
+
} catch (error) {
|
|
1321
|
+
if (config.strict.strictRemoteEntry) {
|
|
1322
|
+
config.log.error(1, `Could not fetch remote '${remoteName}'.`, error);
|
|
1323
|
+
return Promise.reject(new NFError(`Could not fetch remote '${remoteName}'`));
|
|
1324
|
+
}
|
|
1325
|
+
config.log.warn(1, `Could not fetch remote '${remoteName}'. skipping init.`, error);
|
|
1326
|
+
return Promise.resolve(false);
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
function prepareRemoteEntry(remoteEntry, expectedRemoteName, isOverride) {
|
|
1330
|
+
if (isOverride) remoteEntry.override = isOverride;
|
|
1331
|
+
if (!!config.hostRemoteEntry && expectedRemoteName === config.hostRemoteEntry.name) {
|
|
1332
|
+
remoteEntry.host = true;
|
|
1333
|
+
remoteEntry.name = config.hostRemoteEntry.name;
|
|
1334
|
+
}
|
|
1335
|
+
if (remoteEntry.name !== expectedRemoteName) {
|
|
1336
|
+
const errorDetails = `Fetched remote '${remoteEntry.name}' does not match requested '${expectedRemoteName}'.`;
|
|
1337
|
+
if (config.strict.strictRemoteEntry) {
|
|
1338
|
+
throw new NFError(errorDetails);
|
|
1339
|
+
}
|
|
1340
|
+
config.log.warn(1, `${errorDetails} Omitting expected name.`);
|
|
1341
|
+
}
|
|
1342
|
+
return remoteEntry;
|
|
1343
|
+
}
|
|
1344
|
+
function removeSkippedRemotes(remoteEntries) {
|
|
1345
|
+
return remoteEntries.filter((entry) => entry !== false);
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
// src/lib/2.app/flows/init/process-remote-entries.ts
|
|
1350
|
+
function createProcessRemoteEntries(config, ports) {
|
|
1351
|
+
return (remoteEntries) => {
|
|
1352
|
+
try {
|
|
1353
|
+
remoteEntries.forEach((remoteEntry) => {
|
|
1354
|
+
if (remoteEntry?.override) removeCachedRemoteEntry(remoteEntry);
|
|
1355
|
+
addRemoteInfoToStorage(remoteEntry);
|
|
1356
|
+
addExternalsToStorage(remoteEntry);
|
|
1357
|
+
});
|
|
1358
|
+
return Promise.resolve(remoteEntries);
|
|
1359
|
+
} catch (e) {
|
|
1360
|
+
return Promise.reject(e);
|
|
1361
|
+
}
|
|
1362
|
+
};
|
|
1363
|
+
function removeCachedRemoteEntry(remoteEntry) {
|
|
1364
|
+
ports.remoteInfoRepo.remove(remoteEntry.name);
|
|
1365
|
+
ports.scopedExternalsRepo.remove(remoteEntry.name);
|
|
1366
|
+
ports.sharedExternalsRepo.removeFromAllScopes(remoteEntry.name);
|
|
1367
|
+
}
|
|
1368
|
+
function addRemoteInfoToStorage({ name, url, exposes }) {
|
|
1369
|
+
ports.remoteInfoRepo.addOrUpdate(name, {
|
|
1370
|
+
scopeUrl: getScope(url),
|
|
1371
|
+
exposes: Object.values(exposes ?? []).map((m) => ({
|
|
1372
|
+
moduleName: m.key,
|
|
1373
|
+
file: m.outFileName
|
|
1374
|
+
}))
|
|
1375
|
+
});
|
|
1376
|
+
}
|
|
1377
|
+
function addExternalsToStorage(remoteEntry) {
|
|
1378
|
+
remoteEntry.shared.forEach((external) => {
|
|
1379
|
+
if (!external.version || !ports.versionCheck.isValidSemver(external.version)) {
|
|
1380
|
+
const errorMsg = `[${remoteEntry.name}][${external.packageName}] Version '${external.version}' is not a valid version.`;
|
|
1381
|
+
if (config.strict.strictExternalVersion) {
|
|
1382
|
+
config.log.error(2, errorMsg);
|
|
1383
|
+
throw new NFError(`Could not process remote '${remoteEntry.name}'`);
|
|
1384
|
+
}
|
|
1385
|
+
config.log.warn(2, errorMsg);
|
|
1386
|
+
}
|
|
1387
|
+
if (external.singleton) {
|
|
1388
|
+
addSharedExternal(remoteEntry.name, external, remoteEntry);
|
|
1389
|
+
} else {
|
|
1390
|
+
addScopedExternal(remoteEntry.name, external);
|
|
1391
|
+
}
|
|
1392
|
+
});
|
|
1393
|
+
}
|
|
1394
|
+
function addSharedExternal(remoteName, sharedInfo, remoteEntry) {
|
|
1395
|
+
let action = "skip";
|
|
1396
|
+
const tag = sharedInfo.version ?? ports.versionCheck.smallestVersion(sharedInfo.requiredVersion);
|
|
1397
|
+
const remote = {
|
|
1398
|
+
file: sharedInfo.outFileName,
|
|
1399
|
+
name: remoteName,
|
|
1400
|
+
strictVersion: sharedInfo.strictVersion,
|
|
1401
|
+
cached: false,
|
|
1402
|
+
requiredVersion: sharedInfo.requiredVersion || tag
|
|
1403
|
+
};
|
|
1404
|
+
const scopeType = ports.sharedExternalsRepo.scopeType(sharedInfo.shareScope);
|
|
1405
|
+
if (scopeType === "strict") {
|
|
1406
|
+
action = "share";
|
|
1407
|
+
remote.requiredVersion = tag;
|
|
1408
|
+
}
|
|
1409
|
+
const cached = ports.sharedExternalsRepo.tryGet(sharedInfo.packageName, sharedInfo.shareScope).orElse({ dirty: false, versions: [] });
|
|
1410
|
+
const matchingVersion = cached.versions.find((version) => version.tag === sharedInfo.version);
|
|
1411
|
+
let dirty = cached.dirty;
|
|
1412
|
+
if (!!matchingVersion) {
|
|
1413
|
+
if (remote.strictVersion && matchingVersion.remotes[0].requiredVersion !== remote.requiredVersion) {
|
|
1414
|
+
const errorMsg = `[${remoteName}][${sharedInfo.packageName}@${sharedInfo.version}] Required version-range '${remote.requiredVersion}' does not match cached version-range '${matchingVersion.remotes[0].requiredVersion}'`;
|
|
1415
|
+
if (config.strict.strictExternalCompatibility) {
|
|
1416
|
+
config.log.error(2, errorMsg);
|
|
1417
|
+
throw new NFError(`Could not process remote '${remoteEntry.name}'`);
|
|
1418
|
+
}
|
|
1419
|
+
config.log.warn(2, errorMsg);
|
|
1420
|
+
}
|
|
1421
|
+
if (!matchingVersion.host && !!remoteEntry?.host) {
|
|
1422
|
+
matchingVersion.host = true;
|
|
1423
|
+
matchingVersion.remotes.unshift(remote);
|
|
1424
|
+
} else matchingVersion.remotes.push(remote);
|
|
1425
|
+
} else {
|
|
1426
|
+
if (scopeType !== "strict") dirty = true;
|
|
1427
|
+
cached.versions.push({ tag, action, host: !!remoteEntry?.host, remotes: [remote] });
|
|
1428
|
+
}
|
|
1429
|
+
ports.sharedExternalsRepo.addOrUpdate(
|
|
1430
|
+
sharedInfo.packageName,
|
|
1431
|
+
{
|
|
1432
|
+
dirty,
|
|
1433
|
+
versions: cached.versions.sort((a, b) => ports.versionCheck.compare(b.tag, a.tag))
|
|
1434
|
+
},
|
|
1435
|
+
sharedInfo.shareScope
|
|
1436
|
+
);
|
|
1437
|
+
}
|
|
1438
|
+
function addScopedExternal(scope, sharedInfo) {
|
|
1439
|
+
ports.scopedExternalsRepo.addExternal(scope, sharedInfo.packageName, {
|
|
1440
|
+
tag: sharedInfo.version ?? ports.versionCheck.smallestVersion(sharedInfo.requiredVersion),
|
|
1441
|
+
file: sharedInfo.outFileName
|
|
1442
|
+
});
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
// src/lib/1.domain/externals/external.contract.ts
|
|
1447
|
+
var GLOBAL_SCOPE = "__GLOBAL__";
|
|
1448
|
+
var STRICT_SCOPE = "strict";
|
|
1449
|
+
|
|
1450
|
+
// src/lib/2.app/flows/init/determine-shared-externals.ts
|
|
1451
|
+
function createDetermineSharedExternals(config, ports) {
|
|
1452
|
+
return () => {
|
|
1453
|
+
for (const shareScope of ports.sharedExternalsRepo.getScopes()) {
|
|
1454
|
+
const sharedExternals = ports.sharedExternalsRepo.getFromScope(shareScope);
|
|
1455
|
+
try {
|
|
1456
|
+
Object.entries(sharedExternals).filter(([_, e]) => e.dirty).forEach(
|
|
1457
|
+
([name, external]) => ports.sharedExternalsRepo.addOrUpdate(
|
|
1458
|
+
name,
|
|
1459
|
+
setVersionActions(name, external),
|
|
1460
|
+
shareScope
|
|
1461
|
+
)
|
|
1462
|
+
);
|
|
1463
|
+
} catch (error) {
|
|
1464
|
+
config.log.error(
|
|
1465
|
+
3,
|
|
1466
|
+
`[${shareScope ?? GLOBAL_SCOPE}] failed to determine shared externals.`,
|
|
1467
|
+
{
|
|
1468
|
+
sharedExternals,
|
|
1469
|
+
error
|
|
1470
|
+
}
|
|
1471
|
+
);
|
|
1472
|
+
return Promise.reject(
|
|
1473
|
+
new NFError(
|
|
1474
|
+
`Could not determine shared externals in scope ${shareScope}.`,
|
|
1475
|
+
error
|
|
1476
|
+
)
|
|
1477
|
+
);
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
return Promise.resolve();
|
|
1481
|
+
};
|
|
1482
|
+
function setVersionActions(externalName, external) {
|
|
1483
|
+
if (external.versions.length === 1) {
|
|
1484
|
+
external.versions[0].action = "share";
|
|
1485
|
+
external.dirty = false;
|
|
1486
|
+
return external;
|
|
1487
|
+
}
|
|
1488
|
+
let sharedVersion = external.versions.find((v) => v.host);
|
|
1489
|
+
if (!sharedVersion && config.profile.latestSharedExternal) {
|
|
1490
|
+
sharedVersion = external.versions[0];
|
|
1491
|
+
}
|
|
1492
|
+
if (!sharedVersion) {
|
|
1493
|
+
let leastExtraDownloads = Number.MAX_VALUE;
|
|
1494
|
+
external.versions.forEach((vA) => {
|
|
1495
|
+
const extraDownloads = external.versions.filter(
|
|
1496
|
+
(vB) => !vB.remotes[0].cached && vB.remotes[0].strictVersion && !ports.versionCheck.isCompatible(vA.tag, vB.remotes[0].requiredVersion)
|
|
1497
|
+
).length;
|
|
1498
|
+
if (extraDownloads < leastExtraDownloads) {
|
|
1499
|
+
leastExtraDownloads = extraDownloads;
|
|
1500
|
+
sharedVersion = vA;
|
|
1501
|
+
}
|
|
1502
|
+
});
|
|
1503
|
+
}
|
|
1504
|
+
if (!sharedVersion) {
|
|
1505
|
+
throw new NFError(`[${externalName}] Could not determine shared version!`);
|
|
1506
|
+
}
|
|
1507
|
+
external.versions.forEach((v) => {
|
|
1508
|
+
if (ports.versionCheck.isCompatible(sharedVersion.tag, v.remotes[0].requiredVersion)) {
|
|
1509
|
+
v.action = "skip";
|
|
1510
|
+
return;
|
|
1511
|
+
}
|
|
1512
|
+
if (config.strict.strictExternalCompatibility && v.remotes[0].strictVersion) {
|
|
1513
|
+
config.log.error(
|
|
1514
|
+
3,
|
|
1515
|
+
`[${v.remotes[0].name}][${externalName}@${v.tag}] Is not compatible with requiredRange '${sharedVersion.remotes[0]?.requiredVersion}' from remote '${sharedVersion.remotes[0].name}'.`
|
|
1516
|
+
);
|
|
1517
|
+
throw new NFError(`External ${externalName}@${v.tag} could not be shared.`);
|
|
1518
|
+
}
|
|
1519
|
+
v.action = v.remotes[0].strictVersion ? "scope" : "skip";
|
|
1520
|
+
});
|
|
1521
|
+
sharedVersion.action = "share";
|
|
1522
|
+
external.dirty = false;
|
|
1523
|
+
return external;
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
// src/lib/2.app/flows/init/generate-import-map.ts
|
|
1528
|
+
function createGenerateImportMap(config, ports) {
|
|
1529
|
+
return () => {
|
|
1530
|
+
const importMap = { imports: {} };
|
|
1531
|
+
try {
|
|
1532
|
+
addScopedExternals(importMap);
|
|
1533
|
+
addshareScopeExternals(importMap);
|
|
1534
|
+
addGlobalSharedExternals(importMap);
|
|
1535
|
+
addRemoteInfos(importMap);
|
|
1536
|
+
return Promise.resolve(importMap);
|
|
1537
|
+
} catch (e) {
|
|
1538
|
+
return Promise.reject(e);
|
|
1539
|
+
}
|
|
1540
|
+
};
|
|
1541
|
+
function addScopedExternals(importMap) {
|
|
1542
|
+
const scopedExternals = ports.scopedExternalsRepo.getAll();
|
|
1543
|
+
for (const [remoteName, externals] of Object.entries(scopedExternals)) {
|
|
1544
|
+
const remote = ports.remoteInfoRepo.tryGet(remoteName).orThrow(() => {
|
|
1545
|
+
config.log.error(4, `[scoped][${remoteName}] Remote name not found in cache.`);
|
|
1546
|
+
return new NFError("Could not create ImportMap.");
|
|
1547
|
+
});
|
|
1548
|
+
addToScope(importMap, remote.scopeUrl, createScopeModules(externals, remote.scopeUrl));
|
|
1549
|
+
}
|
|
1550
|
+
return importMap;
|
|
1551
|
+
}
|
|
1552
|
+
function createScopeModules(externals, scope) {
|
|
1553
|
+
const modules = {};
|
|
1554
|
+
for (const [external, version] of Object.entries(externals)) {
|
|
1555
|
+
modules[external] = join(scope, version.file);
|
|
1556
|
+
}
|
|
1557
|
+
return modules;
|
|
1558
|
+
}
|
|
1559
|
+
function addshareScopeExternals(importMap) {
|
|
1560
|
+
const shareScopes = ports.sharedExternalsRepo.getScopes({ includeGlobal: false });
|
|
1561
|
+
for (const shareScope of shareScopes) {
|
|
1562
|
+
processshareScope(importMap, shareScope);
|
|
1563
|
+
}
|
|
1564
|
+
return importMap;
|
|
1565
|
+
}
|
|
1566
|
+
function processshareScope(importMap, shareScope) {
|
|
1567
|
+
const sharedExternals = ports.sharedExternalsRepo.getFromScope(shareScope);
|
|
1568
|
+
for (const [externalName, external] of Object.entries(sharedExternals)) {
|
|
1569
|
+
let override = void 0;
|
|
1570
|
+
let overrideScope = void 0;
|
|
1571
|
+
for (const version of external.versions) {
|
|
1572
|
+
if (version.action === "scope") {
|
|
1573
|
+
for (const remote of version.remotes) {
|
|
1574
|
+
const remoteScope = getScope2(externalName, shareScope, remote.name);
|
|
1575
|
+
addToScope(importMap, remoteScope, {
|
|
1576
|
+
[externalName]: join(remoteScope, remote.file)
|
|
1577
|
+
});
|
|
1578
|
+
remote.cached = true;
|
|
1579
|
+
}
|
|
1580
|
+
continue;
|
|
1581
|
+
}
|
|
1582
|
+
const scope = getScope2(externalName, shareScope, version.remotes[0].name);
|
|
1583
|
+
let targetFileUrl = join(scope, version.remotes[0].file);
|
|
1584
|
+
version.remotes[0].cached = true;
|
|
1585
|
+
if (version.action === "skip") {
|
|
1586
|
+
if (!override) {
|
|
1587
|
+
override = findOverride(external, shareScope, externalName) ?? "NOT_AVAILABLE";
|
|
1588
|
+
}
|
|
1589
|
+
if (override !== "NOT_AVAILABLE") {
|
|
1590
|
+
if (!overrideScope)
|
|
1591
|
+
overrideScope = getScope2(externalName, shareScope, override.remotes[0].name);
|
|
1592
|
+
targetFileUrl = join(overrideScope, override.remotes[0].file);
|
|
1593
|
+
override.remotes[0].cached = true;
|
|
1594
|
+
version.remotes[0].cached = false;
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
version.remotes.forEach((r) => {
|
|
1598
|
+
const scope2 = getScope2(externalName, shareScope, r.name);
|
|
1599
|
+
addToScope(importMap, scope2, { [externalName]: targetFileUrl });
|
|
1600
|
+
});
|
|
1601
|
+
}
|
|
1602
|
+
ports.sharedExternalsRepo.addOrUpdate(externalName, external, shareScope);
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
function findOverride(external, shareScope, externalName) {
|
|
1606
|
+
const sharedVersions = external.versions.filter((v) => v.action === "share");
|
|
1607
|
+
const scopedExternalName = `${shareScope}.${externalName}`;
|
|
1608
|
+
if (sharedVersions.length > 1) {
|
|
1609
|
+
handleMultipleSharedVersions(scopedExternalName);
|
|
1610
|
+
}
|
|
1611
|
+
if (sharedVersions.length < 1) {
|
|
1612
|
+
if (config.strict.strictImportMap) {
|
|
1613
|
+
config.log.error(4, `[${shareScope}][${externalName}] shareScope has no override version.`);
|
|
1614
|
+
throw new NFError("Could not create ImportMap.");
|
|
1615
|
+
}
|
|
1616
|
+
config.log.debug(
|
|
1617
|
+
4,
|
|
1618
|
+
`[${shareScope}][${externalName}] shareScope has no override version, scoping override versions.`
|
|
1619
|
+
);
|
|
1620
|
+
}
|
|
1621
|
+
return sharedVersions[0];
|
|
1622
|
+
}
|
|
1623
|
+
function handleMultipleSharedVersions(scopedExternalName) {
|
|
1624
|
+
if (config.strict.strictImportMap) {
|
|
1625
|
+
config.log.error(
|
|
1626
|
+
4,
|
|
1627
|
+
`[${scopedExternalName}] ShareScope external has multiple shared versions.`
|
|
1628
|
+
);
|
|
1629
|
+
throw new NFError("Could not create ImportMap.");
|
|
1630
|
+
}
|
|
1631
|
+
config.log.warn(4, `ShareScope external ${scopedExternalName} has multiple shared versions.`);
|
|
1632
|
+
}
|
|
1633
|
+
function addGlobalSharedExternals(importMap) {
|
|
1634
|
+
const sharedExternals = ports.sharedExternalsRepo.getFromScope();
|
|
1635
|
+
for (const [externalName, external] of Object.entries(sharedExternals)) {
|
|
1636
|
+
for (const version of external.versions) {
|
|
1637
|
+
if (version.action === "skip") continue;
|
|
1638
|
+
if (version.action === "scope") {
|
|
1639
|
+
for (const remote of version.remotes) {
|
|
1640
|
+
const remoteScope = getScope2(externalName, GLOBAL_SCOPE, remote.name);
|
|
1641
|
+
addToScope(importMap, remoteScope, {
|
|
1642
|
+
[externalName]: join(remoteScope, remote.file)
|
|
1643
|
+
});
|
|
1644
|
+
remote.cached = true;
|
|
1645
|
+
}
|
|
1646
|
+
continue;
|
|
1647
|
+
}
|
|
1648
|
+
if (importMap.imports[externalName]) {
|
|
1649
|
+
handleDuplicateGlobalExternal(externalName);
|
|
1650
|
+
continue;
|
|
1651
|
+
}
|
|
1652
|
+
const scope = getScope2(externalName, GLOBAL_SCOPE, version.remotes[0].name);
|
|
1653
|
+
addToGlobal(importMap, { [externalName]: join(scope, version.remotes[0].file) });
|
|
1654
|
+
version.remotes[0].cached = true;
|
|
1655
|
+
}
|
|
1656
|
+
ports.sharedExternalsRepo.addOrUpdate(externalName, external);
|
|
1657
|
+
}
|
|
1658
|
+
return importMap;
|
|
1659
|
+
}
|
|
1660
|
+
function handleDuplicateGlobalExternal(externalName) {
|
|
1661
|
+
if (config.strict.strictImportMap) {
|
|
1662
|
+
config.log.error(4, `[${externalName}] Shared external has multiple shared versions.`);
|
|
1663
|
+
throw new NFError("Could not create ImportMap.");
|
|
1664
|
+
}
|
|
1665
|
+
config.log.warn(4, `Singleton external ${externalName} has multiple shared versions.`);
|
|
1666
|
+
}
|
|
1667
|
+
function addToScope(importMap, scope, imports) {
|
|
1668
|
+
if (!importMap.scopes) importMap.scopes = {};
|
|
1669
|
+
if (!importMap.scopes[scope]) importMap.scopes[scope] = {};
|
|
1670
|
+
importMap.scopes[scope] = Object.assign(importMap.scopes[scope], imports);
|
|
1671
|
+
}
|
|
1672
|
+
function addToGlobal(importMap, imports) {
|
|
1673
|
+
importMap.imports = Object.assign(importMap.imports, imports);
|
|
1674
|
+
}
|
|
1675
|
+
function addRemoteInfos(importMap) {
|
|
1676
|
+
const remotes = ports.remoteInfoRepo.getAll();
|
|
1677
|
+
for (const [remoteName, remote] of Object.entries(remotes)) {
|
|
1678
|
+
addRemoteExposedModules(importMap, remoteName, remote);
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
function addRemoteExposedModules(importMap, remoteName, remote) {
|
|
1682
|
+
for (const exposed of remote.exposes) {
|
|
1683
|
+
const moduleName = join(remoteName, exposed.moduleName);
|
|
1684
|
+
const moduleUrl = join(remote.scopeUrl, exposed.file);
|
|
1685
|
+
importMap.imports[moduleName] = moduleUrl;
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
function getScope2(externalName, shareScope, remoteName) {
|
|
1689
|
+
return ports.remoteInfoRepo.tryGet(remoteName).map((remote) => remote.scopeUrl).orThrow(() => {
|
|
1690
|
+
config.log.error(
|
|
1691
|
+
4,
|
|
1692
|
+
`[${shareScope}][${externalName}][${remoteName}] Remote name not found in cache.`
|
|
1693
|
+
);
|
|
1694
|
+
return new NFError("Could not create ImportMap.");
|
|
1695
|
+
});
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
// src/lib/2.app/flows/init/commit-changes.ts
|
|
1700
|
+
function createCommitChanges(config, ports) {
|
|
1701
|
+
return (importMap) => Promise.resolve(importMap).then(addToBrowser).then(persistRepositoryChanges);
|
|
1702
|
+
function addToBrowser(importMap) {
|
|
1703
|
+
ports.browser.setImportMapFn(importMap);
|
|
1704
|
+
config.log.debug(5, "Added import map to browser.", importMap);
|
|
1705
|
+
return importMap;
|
|
1706
|
+
}
|
|
1707
|
+
function persistRepositoryChanges() {
|
|
1708
|
+
ports.remoteInfoRepo.commit();
|
|
1709
|
+
ports.scopedExternalsRepo.commit();
|
|
1710
|
+
ports.sharedExternalsRepo.commit();
|
|
1711
|
+
return;
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
// src/lib/2.app/flows/init/expose-module-loader.ts
|
|
1716
|
+
function createExposeModuleLoader(config, ports) {
|
|
1717
|
+
return () => Promise.resolve(loadRemoteModule);
|
|
1718
|
+
function loadRemoteModule(remoteName, exposedModule) {
|
|
1719
|
+
try {
|
|
1720
|
+
if (!ports.remoteInfoRepo.contains(remoteName)) {
|
|
1721
|
+
throw new NFError(`Remote '${remoteName}' is not initialized.`);
|
|
1722
|
+
}
|
|
1723
|
+
const remoteModuleUrl = ports.remoteInfoRepo.tryGetModule(remoteName, exposedModule).orThrow(
|
|
1724
|
+
new NFError(
|
|
1725
|
+
`Exposed module '${exposedModule}' from remote '${remoteName}' not found in storage.`
|
|
1726
|
+
)
|
|
1727
|
+
);
|
|
1728
|
+
config.log.debug(6, `Loading initialized module '${remoteModuleUrl}'`);
|
|
1729
|
+
return ports.browser.importModule(remoteModuleUrl);
|
|
1730
|
+
} catch (error) {
|
|
1731
|
+
config.log.error(6, `Failed to load module ${join(remoteName, exposedModule)}: `, {
|
|
1732
|
+
error
|
|
1733
|
+
});
|
|
1734
|
+
return Promise.reject(
|
|
1735
|
+
new NFError(`Failed to load module ${join(remoteName, exposedModule)}`)
|
|
1736
|
+
);
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
// src/lib/5.di/flows/init.factory.ts
|
|
1742
|
+
var createInitDrivers = ({
|
|
1743
|
+
config,
|
|
1744
|
+
adapters
|
|
1745
|
+
}) => ({
|
|
1746
|
+
getRemoteEntries: createGetRemoteEntries(config, adapters),
|
|
1747
|
+
processRemoteEntries: createProcessRemoteEntries(config, adapters),
|
|
1748
|
+
determineSharedExternals: createDetermineSharedExternals(config, adapters),
|
|
1749
|
+
generateImportMap: createGenerateImportMap(config, adapters),
|
|
1750
|
+
commitChanges: createCommitChanges(config, adapters),
|
|
1751
|
+
exposeModuleLoader: createExposeModuleLoader(config, adapters)
|
|
1752
|
+
});
|
|
1753
|
+
var INIT_FLOW_FACTORY = ({
|
|
1754
|
+
config,
|
|
1755
|
+
adapters
|
|
1756
|
+
}) => {
|
|
1757
|
+
const flow = createInitDrivers({ config, adapters });
|
|
1758
|
+
return {
|
|
1759
|
+
flow,
|
|
1760
|
+
adapters,
|
|
1761
|
+
config
|
|
1762
|
+
};
|
|
1763
|
+
};
|
|
1764
|
+
var createInitFlow = ({
|
|
1765
|
+
flow,
|
|
1766
|
+
adapters,
|
|
1767
|
+
config
|
|
1768
|
+
}) => {
|
|
1769
|
+
return (remotesOrManifestUrl) => flow.getRemoteEntries(remotesOrManifestUrl).then(flow.processRemoteEntries).then(flow.determineSharedExternals).then(flow.generateImportMap).then(flow.commitChanges).then(flow.exposeModuleLoader).then((loadRemoteModule) => ({
|
|
1770
|
+
config,
|
|
1771
|
+
adapters,
|
|
1772
|
+
loadRemoteModule
|
|
1773
|
+
}));
|
|
1774
|
+
};
|
|
1775
|
+
|
|
1776
|
+
// src/lib/3.adapters/browser/browser.ts
|
|
1777
|
+
var createBrowser = (config) => {
|
|
1778
|
+
return {
|
|
1779
|
+
setImportMapFn: config.setImportMapFn,
|
|
1780
|
+
importModule: config.loadModuleFn
|
|
1781
|
+
};
|
|
1782
|
+
};
|
|
1783
|
+
|
|
1784
|
+
// src/lib/3.adapters/checks/version.check.ts
|
|
1785
|
+
var import_valid = __toESM(require_valid());
|
|
1786
|
+
var import_satisfies = __toESM(require_satisfies());
|
|
1787
|
+
var import_compare = __toESM(require_compare());
|
|
1788
|
+
var import_min_version = __toESM(require_min_version());
|
|
1789
|
+
var import_valid2 = __toESM(require_valid2());
|
|
1790
|
+
var createVersionCheck = () => {
|
|
1791
|
+
return {
|
|
1792
|
+
isValidSemver: function(version) {
|
|
1793
|
+
return (0, import_valid.default)(version) !== null;
|
|
1794
|
+
},
|
|
1795
|
+
isCompatible: function(version, range) {
|
|
1796
|
+
return (0, import_satisfies.default)(version, range);
|
|
1797
|
+
},
|
|
1798
|
+
compare: function(versionA, versionB) {
|
|
1799
|
+
return (0, import_compare.default)(versionA, versionB, true);
|
|
1800
|
+
},
|
|
1801
|
+
smallestVersion: function(versionRange) {
|
|
1802
|
+
if (!(0, import_valid2.default)(versionRange)) return "0.0.0";
|
|
1803
|
+
const minVersion = (0, import_min_version.default)(versionRange);
|
|
1804
|
+
return minVersion?.raw ?? "0.0.0";
|
|
1805
|
+
}
|
|
1806
|
+
};
|
|
1807
|
+
};
|
|
1808
|
+
|
|
1809
|
+
// src/lib/3.adapters/http/manifest-provider.ts
|
|
1810
|
+
var createManifestProvider = () => {
|
|
1811
|
+
const mapToJson = (response) => {
|
|
1812
|
+
if (!response.ok)
|
|
1813
|
+
return Promise.reject(new NFError(`${response.status} - ${response.statusText}`));
|
|
1814
|
+
return response.json();
|
|
1815
|
+
};
|
|
1816
|
+
const formatError = (remoteEntryUrl) => (err) => {
|
|
1817
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1818
|
+
throw new NFError(`Fetch of '${remoteEntryUrl}' returned ${msg}`);
|
|
1819
|
+
};
|
|
1820
|
+
return {
|
|
1821
|
+
provide: async function(remotesOrManifestUrl) {
|
|
1822
|
+
if (typeof remotesOrManifestUrl !== "string") return Promise.resolve(remotesOrManifestUrl);
|
|
1823
|
+
return fetch(remotesOrManifestUrl).then(mapToJson).catch(formatError(remotesOrManifestUrl));
|
|
1824
|
+
}
|
|
1825
|
+
};
|
|
1826
|
+
};
|
|
1827
|
+
|
|
1828
|
+
// src/lib/3.adapters/http/remote-entry-provider.ts
|
|
1829
|
+
var createRemoteEntryProvider = () => {
|
|
1830
|
+
const mapToJson = (response) => {
|
|
1831
|
+
if (!response.ok)
|
|
1832
|
+
return Promise.reject(new Error(`${response.status} - ${response.statusText}`));
|
|
1833
|
+
return response.json();
|
|
1834
|
+
};
|
|
1835
|
+
const fillEmptyFields = (remoteEntryUrl) => (remoteEntry) => {
|
|
1836
|
+
if (!remoteEntry.exposes) remoteEntry.exposes = [];
|
|
1837
|
+
if (!remoteEntry.shared) remoteEntry.shared = [];
|
|
1838
|
+
if (!remoteEntry.url) remoteEntry.url = remoteEntryUrl;
|
|
1839
|
+
return remoteEntry;
|
|
1840
|
+
};
|
|
1841
|
+
const formatError = (remoteEntryUrl) => (err) => {
|
|
1842
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1843
|
+
throw new NFError(`Fetch of '${remoteEntryUrl}' returned ${msg}`);
|
|
1844
|
+
};
|
|
1845
|
+
return {
|
|
1846
|
+
provide: async function(remoteEntryUrl) {
|
|
1847
|
+
return fetch(remoteEntryUrl).then(mapToJson).then(fillEmptyFields(remoteEntryUrl)).catch(formatError(remoteEntryUrl));
|
|
1848
|
+
}
|
|
1849
|
+
};
|
|
1850
|
+
};
|
|
1851
|
+
|
|
1852
|
+
// src/lib/utils/optional.ts
|
|
1853
|
+
var Optional = class _Optional {
|
|
1854
|
+
constructor(item) {
|
|
1855
|
+
this.item = item;
|
|
1856
|
+
}
|
|
1857
|
+
static of(item) {
|
|
1858
|
+
return new _Optional(item);
|
|
1859
|
+
}
|
|
1860
|
+
static empty() {
|
|
1861
|
+
return _Optional.of(void 0);
|
|
1862
|
+
}
|
|
1863
|
+
isPresent() {
|
|
1864
|
+
return typeof this.item !== "undefined" && this.item !== null;
|
|
1865
|
+
}
|
|
1866
|
+
set(other) {
|
|
1867
|
+
return _Optional.of(other);
|
|
1868
|
+
}
|
|
1869
|
+
ifPresent(callback) {
|
|
1870
|
+
if (this.isPresent()) callback(this.item);
|
|
1871
|
+
}
|
|
1872
|
+
map(callback) {
|
|
1873
|
+
if (!this.isPresent()) return _Optional.empty();
|
|
1874
|
+
const result = callback(this.item);
|
|
1875
|
+
return result instanceof _Optional ? result : _Optional.of(result);
|
|
1876
|
+
}
|
|
1877
|
+
orElse(other) {
|
|
1878
|
+
return this.isPresent() ? this.item : other;
|
|
1879
|
+
}
|
|
1880
|
+
orThrow(error) {
|
|
1881
|
+
if (this.isPresent()) return this.item;
|
|
1882
|
+
if (typeof error === "function") throw error();
|
|
1883
|
+
throw typeof error === "string" ? new Error(error) : error;
|
|
1884
|
+
}
|
|
1885
|
+
get() {
|
|
1886
|
+
return this.item;
|
|
1887
|
+
}
|
|
1888
|
+
};
|
|
1889
|
+
|
|
1890
|
+
// src/lib/3.adapters/storage/remote-info.repository.ts
|
|
1891
|
+
var createRemoteInfoRepository = (config) => {
|
|
1892
|
+
const STORAGE = config.storage("remotes", {});
|
|
1893
|
+
if (config.clearStorage) STORAGE.clear();
|
|
1894
|
+
const _cache = STORAGE.get() ?? {};
|
|
1895
|
+
return {
|
|
1896
|
+
contains: function(remoteName) {
|
|
1897
|
+
return !!_cache[remoteName];
|
|
1898
|
+
},
|
|
1899
|
+
remove: function(remoteName) {
|
|
1900
|
+
delete _cache[remoteName];
|
|
1901
|
+
return this;
|
|
1902
|
+
},
|
|
1903
|
+
addOrUpdate: function(remoteName, remote) {
|
|
1904
|
+
_cache[remoteName] = remote;
|
|
1905
|
+
return this;
|
|
1906
|
+
},
|
|
1907
|
+
tryGet: function(remoteName) {
|
|
1908
|
+
return Optional.of(_cache[remoteName]);
|
|
1909
|
+
},
|
|
1910
|
+
tryGetModule: function(remoteName, exposedModule) {
|
|
1911
|
+
return Optional.of(_cache[remoteName]?.exposes.find((m) => m.moduleName === exposedModule)).map(
|
|
1912
|
+
(m) => join(_cache[remoteName].scopeUrl, m.file)
|
|
1913
|
+
);
|
|
1914
|
+
},
|
|
1915
|
+
getAll: function() {
|
|
1916
|
+
return _cache;
|
|
1917
|
+
},
|
|
1918
|
+
commit: function() {
|
|
1919
|
+
STORAGE.set(_cache);
|
|
1920
|
+
return this;
|
|
1921
|
+
}
|
|
1922
|
+
};
|
|
1923
|
+
};
|
|
1924
|
+
|
|
1925
|
+
// src/lib/3.adapters/storage/scoped-externals.repository.ts
|
|
1926
|
+
var createScopedExternalsRepository = (config) => {
|
|
1927
|
+
const STORAGE = config.storage("scoped-externals", {});
|
|
1928
|
+
if (config.clearStorage) STORAGE.clear();
|
|
1929
|
+
const _cache = STORAGE.get() ?? {};
|
|
1930
|
+
return {
|
|
1931
|
+
addExternal: function(remoteName, external, version) {
|
|
1932
|
+
if (!_cache[remoteName]) _cache[remoteName] = {};
|
|
1933
|
+
_cache[remoteName][external] = version;
|
|
1934
|
+
return this;
|
|
1935
|
+
},
|
|
1936
|
+
remove: function(remoteName) {
|
|
1937
|
+
delete _cache[remoteName];
|
|
1938
|
+
return this;
|
|
1939
|
+
},
|
|
1940
|
+
getAll: function() {
|
|
1941
|
+
return _cache;
|
|
1942
|
+
},
|
|
1943
|
+
tryGet: function(remoteName) {
|
|
1944
|
+
return Optional.of(_cache[remoteName]);
|
|
1945
|
+
},
|
|
1946
|
+
commit: function() {
|
|
1947
|
+
STORAGE.set(_cache);
|
|
1948
|
+
return this;
|
|
1949
|
+
}
|
|
1950
|
+
};
|
|
1951
|
+
};
|
|
1952
|
+
|
|
1953
|
+
// src/lib/3.adapters/storage/shared-externals.repository.ts
|
|
1954
|
+
var createSharedExternalsRepository = (config) => {
|
|
1955
|
+
const STORAGE = config.storage(
|
|
1956
|
+
"shared-externals",
|
|
1957
|
+
{ [GLOBAL_SCOPE]: {} }
|
|
1958
|
+
);
|
|
1959
|
+
if (config.clearStorage) STORAGE.clear();
|
|
1960
|
+
const _cache = STORAGE.get();
|
|
1961
|
+
return {
|
|
1962
|
+
getFromScope: function(shareScope) {
|
|
1963
|
+
return { ..._cache[shareScope ?? GLOBAL_SCOPE] };
|
|
1964
|
+
},
|
|
1965
|
+
addOrUpdate: function(externalName, external, shareScope) {
|
|
1966
|
+
if (!_cache[shareScope ?? GLOBAL_SCOPE]) _cache[shareScope ?? GLOBAL_SCOPE] = {};
|
|
1967
|
+
_cache[shareScope ?? GLOBAL_SCOPE][externalName] = external;
|
|
1968
|
+
return this;
|
|
1969
|
+
},
|
|
1970
|
+
getScopes: function(o = { includeGlobal: true }) {
|
|
1971
|
+
if (o.includeGlobal) return Object.keys(_cache);
|
|
1972
|
+
return Object.keys(_cache).filter((s) => s !== GLOBAL_SCOPE);
|
|
1973
|
+
},
|
|
1974
|
+
removeFromAllScopes: function(remoteName) {
|
|
1975
|
+
Object.values(_cache).forEach((scope) => {
|
|
1976
|
+
const removeExternals = [];
|
|
1977
|
+
Object.entries(scope).forEach(([name, external]) => {
|
|
1978
|
+
const removeVersionIdx = [];
|
|
1979
|
+
external.versions.forEach((version, i) => {
|
|
1980
|
+
const versionRemoteIDX = version.remotes.findIndex((r) => r.name === remoteName);
|
|
1981
|
+
if (~versionRemoteIDX) {
|
|
1982
|
+
version.remotes.splice(versionRemoteIDX, 1);
|
|
1983
|
+
}
|
|
1984
|
+
if (version.remotes.length === 0) removeVersionIdx.push(i);
|
|
1985
|
+
});
|
|
1986
|
+
if (removeVersionIdx.length > 0) {
|
|
1987
|
+
for (let i = removeVersionIdx.length - 1; i >= 0; i--) {
|
|
1988
|
+
external.versions.splice(removeVersionIdx[i], 1);
|
|
1989
|
+
}
|
|
1990
|
+
external.dirty = true;
|
|
1991
|
+
if (external.versions.length === 0) removeExternals.push(name);
|
|
1992
|
+
}
|
|
1993
|
+
});
|
|
1994
|
+
removeExternals.forEach((name) => delete scope[name]);
|
|
1995
|
+
});
|
|
1996
|
+
},
|
|
1997
|
+
scopeType: function(shareScope) {
|
|
1998
|
+
switch (shareScope) {
|
|
1999
|
+
case GLOBAL_SCOPE:
|
|
2000
|
+
case null:
|
|
2001
|
+
case void 0:
|
|
2002
|
+
return "global";
|
|
2003
|
+
case STRICT_SCOPE:
|
|
2004
|
+
return "strict";
|
|
2005
|
+
default:
|
|
2006
|
+
return "shareScope";
|
|
2007
|
+
}
|
|
2008
|
+
},
|
|
2009
|
+
tryGet: function(external, shareScope) {
|
|
2010
|
+
return Optional.of(_cache[shareScope ?? GLOBAL_SCOPE]?.[external]);
|
|
2011
|
+
},
|
|
2012
|
+
commit: function() {
|
|
2013
|
+
STORAGE.set(_cache);
|
|
2014
|
+
return this;
|
|
2015
|
+
}
|
|
2016
|
+
};
|
|
2017
|
+
};
|
|
2018
|
+
|
|
2019
|
+
// src/lib/5.di/driving.factory.ts
|
|
2020
|
+
var createDriving = (config) => {
|
|
2021
|
+
const adapters = {
|
|
2022
|
+
versionCheck: createVersionCheck(),
|
|
2023
|
+
manifestProvider: createManifestProvider(),
|
|
2024
|
+
remoteEntryProvider: createRemoteEntryProvider(),
|
|
2025
|
+
remoteInfoRepo: createRemoteInfoRepository(config),
|
|
2026
|
+
scopedExternalsRepo: createScopedExternalsRepository(config),
|
|
2027
|
+
sharedExternalsRepo: createSharedExternalsRepository(config),
|
|
2028
|
+
browser: createBrowser(config)
|
|
2029
|
+
};
|
|
2030
|
+
return { adapters, config };
|
|
2031
|
+
};
|
|
2032
|
+
|
|
2033
|
+
// src/lib/4.config/import-map/replace-in-dom.ts
|
|
2034
|
+
var replaceInDOM = (mapType) => (importMap, opts = {}) => {
|
|
2035
|
+
if (opts?.override) {
|
|
2036
|
+
document.head.querySelectorAll(`script[type="${mapType}"]`).forEach((importMap2) => importMap2.remove());
|
|
2037
|
+
}
|
|
2038
|
+
document.head.appendChild(
|
|
2039
|
+
Object.assign(document.createElement("script"), {
|
|
2040
|
+
type: mapType,
|
|
2041
|
+
innerHTML: JSON.stringify(importMap)
|
|
2042
|
+
})
|
|
2043
|
+
);
|
|
2044
|
+
return Promise.resolve(importMap);
|
|
2045
|
+
};
|
|
2046
|
+
|
|
2047
|
+
// src/lib/4.config/import-map/use-default.ts
|
|
2048
|
+
var useDefaultImportMap = () => ({
|
|
2049
|
+
loadModuleFn: (url) => import(
|
|
2050
|
+
/* @vite-ignore */
|
|
2051
|
+
url
|
|
2052
|
+
),
|
|
2053
|
+
setImportMapFn: replaceInDOM("importmap")
|
|
2054
|
+
});
|
|
2055
|
+
|
|
2056
|
+
// src/lib/4.config/import-map/import-map.config.ts
|
|
2057
|
+
var createImportMapConfig = (o) => {
|
|
2058
|
+
const fallback = useDefaultImportMap();
|
|
2059
|
+
return {
|
|
2060
|
+
setImportMapFn: o.setImportMapFn ?? fallback.setImportMapFn,
|
|
2061
|
+
loadModuleFn: o.loadModuleFn ?? fallback.loadModuleFn
|
|
2062
|
+
};
|
|
2063
|
+
};
|
|
2064
|
+
|
|
2065
|
+
// src/lib/4.config/host/host.config.ts
|
|
2066
|
+
var createHostConfig = (override) => {
|
|
2067
|
+
if (!override?.hostRemoteEntry) {
|
|
2068
|
+
return { hostRemoteEntry: false };
|
|
2069
|
+
}
|
|
2070
|
+
if (typeof override.hostRemoteEntry === "string") {
|
|
2071
|
+
return {
|
|
2072
|
+
hostRemoteEntry: {
|
|
2073
|
+
name: "__NF-HOST__",
|
|
2074
|
+
url: override.hostRemoteEntry
|
|
2075
|
+
}
|
|
2076
|
+
};
|
|
2077
|
+
}
|
|
2078
|
+
return {
|
|
2079
|
+
hostRemoteEntry: {
|
|
2080
|
+
name: "__NF-HOST__",
|
|
2081
|
+
...override.hostRemoteEntry
|
|
2082
|
+
}
|
|
2083
|
+
};
|
|
2084
|
+
};
|
|
2085
|
+
|
|
2086
|
+
// src/lib/4.config/logging/noop.logger.ts
|
|
2087
|
+
var noopLogger = {
|
|
2088
|
+
debug: () => {
|
|
2089
|
+
},
|
|
2090
|
+
error: () => {
|
|
2091
|
+
},
|
|
2092
|
+
warn: () => {
|
|
2093
|
+
}
|
|
2094
|
+
};
|
|
2095
|
+
|
|
2096
|
+
// src/lib/2.app/config/log.contract.ts
|
|
2097
|
+
var LogLevel = {
|
|
2098
|
+
debug: 0,
|
|
2099
|
+
warn: 1,
|
|
2100
|
+
error: 2
|
|
2101
|
+
};
|
|
2102
|
+
|
|
2103
|
+
// src/lib/4.config/logging/log.handler.ts
|
|
2104
|
+
var createLogHandler = (logger, logLevel) => {
|
|
2105
|
+
const logTypes = Object.keys(LogLevel).filter((key) => isNaN(Number(key)));
|
|
2106
|
+
return logTypes.reduce(
|
|
2107
|
+
(acc, logMessageType) => {
|
|
2108
|
+
return {
|
|
2109
|
+
...acc,
|
|
2110
|
+
[logMessageType]: (step, message, details) => {
|
|
2111
|
+
if (LogLevel[logMessageType] >= LogLevel[logLevel]) {
|
|
2112
|
+
logger[logMessageType](step, message, details);
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
};
|
|
2116
|
+
},
|
|
2117
|
+
{ level: logLevel }
|
|
2118
|
+
);
|
|
2119
|
+
};
|
|
2120
|
+
|
|
2121
|
+
// src/lib/4.config/logging/log.config.ts
|
|
2122
|
+
var createLogConfig = ({ logger, logLevel }) => ({
|
|
2123
|
+
log: createLogHandler(logger ?? noopLogger, logLevel ?? "error")
|
|
2124
|
+
});
|
|
2125
|
+
|
|
2126
|
+
// src/lib/utils/clone-entry.ts
|
|
2127
|
+
var cloneEntry = (name, raw) => {
|
|
2128
|
+
try {
|
|
2129
|
+
if (typeof structuredClone === "function") {
|
|
2130
|
+
return structuredClone(raw);
|
|
2131
|
+
}
|
|
2132
|
+
} catch {
|
|
2133
|
+
}
|
|
2134
|
+
try {
|
|
2135
|
+
return JSON.parse(JSON.stringify(raw));
|
|
2136
|
+
} catch {
|
|
2137
|
+
}
|
|
2138
|
+
throw new NFError(`Could not parse storage entry '${String(name)}'`);
|
|
2139
|
+
};
|
|
2140
|
+
|
|
2141
|
+
// src/lib/4.config/storage/global-this.storage.ts
|
|
2142
|
+
var globalThisStorageEntry = (namespace) => (key, initialValue) => {
|
|
2143
|
+
if (!globalThis[namespace]) {
|
|
2144
|
+
globalThis[namespace] = {};
|
|
2145
|
+
}
|
|
2146
|
+
const storage = globalThis[namespace];
|
|
2147
|
+
if (!storage[key]) storage[key] = initialValue;
|
|
2148
|
+
const entry = {
|
|
2149
|
+
get() {
|
|
2150
|
+
return cloneEntry(key, storage[key]);
|
|
2151
|
+
},
|
|
2152
|
+
set(value) {
|
|
2153
|
+
storage[key] = cloneEntry(key, value);
|
|
2154
|
+
return entry;
|
|
2155
|
+
},
|
|
2156
|
+
clear() {
|
|
2157
|
+
storage[key] = cloneEntry(key, initialValue);
|
|
2158
|
+
return this;
|
|
2159
|
+
}
|
|
2160
|
+
};
|
|
2161
|
+
return entry;
|
|
2162
|
+
};
|
|
2163
|
+
|
|
2164
|
+
// src/lib/4.config/storage/storage.config.ts
|
|
2165
|
+
var createStorageConfig = (override) => ({
|
|
2166
|
+
storage: override.storage ? override.storage(override.storageNamespace ?? "__NATIVE_FEDERATION__") : globalThisStorageEntry(override.storageNamespace ?? "__NATIVE_FEDERATION__"),
|
|
2167
|
+
clearStorage: override.clearStorage ?? false
|
|
2168
|
+
});
|
|
2169
|
+
|
|
2170
|
+
// src/lib/4.config/mode/default.profile.ts
|
|
2171
|
+
var defaultProfile = {
|
|
2172
|
+
latestSharedExternal: false,
|
|
2173
|
+
overrideCachedRemotes: "init-only",
|
|
2174
|
+
overrideCachedRemotesIfURLMatches: false
|
|
2175
|
+
};
|
|
2176
|
+
|
|
2177
|
+
// src/lib/4.config/mode/mode.config.ts
|
|
2178
|
+
var createModeConfig = (override) => {
|
|
2179
|
+
const strictnessConfig = typeof override.strict === "boolean" ? {
|
|
2180
|
+
strictRemoteEntry: override.strict,
|
|
2181
|
+
strictExternalCompatibility: override.strict,
|
|
2182
|
+
strictExternalVersion: override.strict,
|
|
2183
|
+
strictImportMap: override.strict
|
|
2184
|
+
} : {
|
|
2185
|
+
strictRemoteEntry: override.strict?.strictRemoteEntry ?? false,
|
|
2186
|
+
strictExternalCompatibility: override.strict?.strictExternalCompatibility ?? false,
|
|
2187
|
+
strictExternalVersion: override.strict?.strictExternalVersion ?? false,
|
|
2188
|
+
strictImportMap: override.strict?.strictImportMap ?? false
|
|
2189
|
+
};
|
|
2190
|
+
return {
|
|
2191
|
+
strict: strictnessConfig,
|
|
2192
|
+
profile: { ...defaultProfile, ...override.profile ?? {} }
|
|
2193
|
+
};
|
|
2194
|
+
};
|
|
2195
|
+
|
|
2196
|
+
// src/lib/5.di/config.factory.ts
|
|
2197
|
+
var createConfigHandlers = (overrides) => ({
|
|
2198
|
+
...createImportMapConfig(overrides),
|
|
2199
|
+
...createHostConfig(overrides),
|
|
2200
|
+
...createLogConfig(overrides),
|
|
2201
|
+
...createStorageConfig(overrides),
|
|
2202
|
+
...createModeConfig(overrides)
|
|
2203
|
+
});
|
|
2204
|
+
|
|
2205
|
+
// src/lib/2.app/flows/dynamic-init/convert-to-import-map.ts
|
|
2206
|
+
function createConvertToImportMap({ log }) {
|
|
2207
|
+
return ({ entry, actions }) => {
|
|
2208
|
+
const importMap = { imports: {} };
|
|
2209
|
+
addExternals(entry, actions, importMap);
|
|
2210
|
+
addRemoteInfos(entry, importMap);
|
|
2211
|
+
log.debug(9, `[${entry.name}] Processed actions:`, actions);
|
|
2212
|
+
return Promise.resolve(importMap);
|
|
2213
|
+
};
|
|
2214
|
+
function addExternals(remoteEntry, actions, importMap) {
|
|
2215
|
+
if (!remoteEntry.shared) {
|
|
2216
|
+
return;
|
|
2217
|
+
}
|
|
2218
|
+
const remoteEntryScope = getScope(remoteEntry.url);
|
|
2219
|
+
remoteEntry.shared.forEach((external) => {
|
|
2220
|
+
if (!external.singleton) {
|
|
2221
|
+
addToScopes(
|
|
2222
|
+
remoteEntryScope,
|
|
2223
|
+
external.packageName,
|
|
2224
|
+
join(remoteEntryScope, external.outFileName),
|
|
2225
|
+
importMap
|
|
2226
|
+
);
|
|
2227
|
+
return;
|
|
2228
|
+
}
|
|
2229
|
+
if (!actions[external.packageName]) {
|
|
2230
|
+
log.warn(
|
|
2231
|
+
9,
|
|
2232
|
+
`[${remoteEntry.name}] No action defined for shared external '${external.packageName}', skipping.`
|
|
2233
|
+
);
|
|
2234
|
+
return;
|
|
2235
|
+
}
|
|
2236
|
+
if (actions[external.packageName].action === "skip") {
|
|
2237
|
+
if (!external.shareScope) return;
|
|
2238
|
+
if (actions[external.packageName].override) {
|
|
2239
|
+
addToScopes(
|
|
2240
|
+
remoteEntryScope,
|
|
2241
|
+
external.packageName,
|
|
2242
|
+
actions[external.packageName].override,
|
|
2243
|
+
importMap
|
|
2244
|
+
);
|
|
2245
|
+
return;
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
if (actions[external.packageName].action === "scope") {
|
|
2249
|
+
addToScopes(
|
|
2250
|
+
remoteEntryScope,
|
|
2251
|
+
external.packageName,
|
|
2252
|
+
join(remoteEntryScope, external.outFileName),
|
|
2253
|
+
importMap
|
|
2254
|
+
);
|
|
2255
|
+
return;
|
|
2256
|
+
}
|
|
2257
|
+
if (external.shareScope) {
|
|
2258
|
+
addToScopes(
|
|
2259
|
+
remoteEntryScope,
|
|
2260
|
+
external.packageName,
|
|
2261
|
+
join(remoteEntryScope, external.outFileName),
|
|
2262
|
+
importMap
|
|
2263
|
+
);
|
|
2264
|
+
return;
|
|
2265
|
+
}
|
|
2266
|
+
importMap.imports[external.packageName] = join(remoteEntryScope, external.outFileName);
|
|
2267
|
+
});
|
|
2268
|
+
}
|
|
2269
|
+
function addToScopes(scope, packageName, url, importMap) {
|
|
2270
|
+
if (!importMap.scopes) importMap.scopes = {};
|
|
2271
|
+
if (!importMap.scopes[scope]) importMap.scopes[scope] = {};
|
|
2272
|
+
importMap.scopes[scope][packageName] = url;
|
|
2273
|
+
}
|
|
2274
|
+
function addRemoteInfos(remoteEntry, importMap) {
|
|
2275
|
+
if (!remoteEntry.exposes) return;
|
|
2276
|
+
const scope = getScope(remoteEntry.url);
|
|
2277
|
+
remoteEntry.exposes.forEach((exposed) => {
|
|
2278
|
+
const moduleName = join(remoteEntry.name, exposed.key);
|
|
2279
|
+
const moduleUrl = join(scope, exposed.outFileName);
|
|
2280
|
+
importMap.imports[moduleName] = moduleUrl;
|
|
2281
|
+
});
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
|
|
2285
|
+
// src/lib/2.app/flows/dynamic-init/get-remote-entry.ts
|
|
2286
|
+
function createGetRemoteEntry(config, ports) {
|
|
2287
|
+
return async (remoteEntryUrl, remoteName) => {
|
|
2288
|
+
if (!!remoteName && shouldSkipCachedRemote(remoteEntryUrl, remoteName)) {
|
|
2289
|
+
config.log.debug(7, `Found remote '${remoteName}' in storage, omitting fetch.`);
|
|
2290
|
+
return Optional.empty();
|
|
2291
|
+
}
|
|
2292
|
+
try {
|
|
2293
|
+
const remoteEntry = await ports.remoteEntryProvider.provide(remoteEntryUrl);
|
|
2294
|
+
config.log.debug(
|
|
2295
|
+
7,
|
|
2296
|
+
`[${remoteEntry.name}] Fetched from '${remoteEntry.url}', exposing: ${JSON.stringify(remoteEntry.exposes)}`
|
|
2297
|
+
);
|
|
2298
|
+
if (!!remoteName && remoteEntry.name !== remoteName) {
|
|
2299
|
+
const errorMsg = `Fetched remote '${remoteEntry.name}' does not match requested '${remoteName}'.`;
|
|
2300
|
+
if (config.strict.strictRemoteEntry) {
|
|
2301
|
+
config.log.error(7, errorMsg);
|
|
2302
|
+
throw new NFError("Could not fetch remote entry");
|
|
2303
|
+
}
|
|
2304
|
+
config.log.warn(7, errorMsg + " Omitting expected name.");
|
|
2305
|
+
}
|
|
2306
|
+
if (ports.remoteInfoRepo.contains(remoteEntry.name)) {
|
|
2307
|
+
remoteEntry.override = true;
|
|
2308
|
+
config.log.debug(7, `Overriding existing remote '${remoteName}' with '${remoteEntryUrl}'.`);
|
|
2309
|
+
}
|
|
2310
|
+
return Optional.of(remoteEntry);
|
|
2311
|
+
} catch (error) {
|
|
2312
|
+
config.log.error(
|
|
2313
|
+
7,
|
|
2314
|
+
`[${remoteName ?? "unknown"}] Could not fetch remoteEntry from ${remoteEntryUrl}.`,
|
|
2315
|
+
error
|
|
2316
|
+
);
|
|
2317
|
+
return Promise.reject(
|
|
2318
|
+
new NFError(`[${remoteName ?? remoteEntryUrl}] Could not fetch remoteEntry.`)
|
|
2319
|
+
);
|
|
2320
|
+
}
|
|
2321
|
+
};
|
|
2322
|
+
function shouldSkipCachedRemote(remoteEntryUrl, remoteName) {
|
|
2323
|
+
return ports.remoteInfoRepo.tryGet(remoteName).map(
|
|
2324
|
+
(cachedRemoteInfo) => config.profile.overrideCachedRemotes !== "always" || !config.profile.overrideCachedRemotesIfURLMatches && remoteEntryUrl === join(cachedRemoteInfo.scopeUrl, "remoteEntry.json")
|
|
2325
|
+
).orElse(false);
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
|
|
2329
|
+
// src/lib/2.app/flows/dynamic-init/update-cache.ts
|
|
2330
|
+
function createUpdateCache(config, ports) {
|
|
2331
|
+
return (remoteEntry) => {
|
|
2332
|
+
try {
|
|
2333
|
+
if (remoteEntry?.override) removeCachedRemoteEntry(remoteEntry);
|
|
2334
|
+
addRemoteInfoToStorage(remoteEntry);
|
|
2335
|
+
const actions = mergeExternalsIntoStorage(remoteEntry);
|
|
2336
|
+
return Promise.resolve({ entry: remoteEntry, actions });
|
|
2337
|
+
} catch (error) {
|
|
2338
|
+
return Promise.reject(error);
|
|
2339
|
+
}
|
|
2340
|
+
};
|
|
2341
|
+
function removeCachedRemoteEntry(remoteEntry) {
|
|
2342
|
+
ports.remoteInfoRepo.remove(remoteEntry.name);
|
|
2343
|
+
ports.scopedExternalsRepo.remove(remoteEntry.name);
|
|
2344
|
+
ports.sharedExternalsRepo.removeFromAllScopes(remoteEntry.name);
|
|
2345
|
+
}
|
|
2346
|
+
function addRemoteInfoToStorage({ name, url, exposes }) {
|
|
2347
|
+
ports.remoteInfoRepo.addOrUpdate(name, {
|
|
2348
|
+
scopeUrl: getScope(url),
|
|
2349
|
+
exposes: Object.values(exposes ?? []).map((m) => ({
|
|
2350
|
+
moduleName: m.key,
|
|
2351
|
+
file: m.outFileName
|
|
2352
|
+
}))
|
|
2353
|
+
});
|
|
2354
|
+
}
|
|
2355
|
+
function mergeExternalsIntoStorage(remoteEntry) {
|
|
2356
|
+
const actions = {};
|
|
2357
|
+
remoteEntry.shared.forEach((external) => {
|
|
2358
|
+
if (!external.version || !ports.versionCheck.isValidSemver(external.version)) {
|
|
2359
|
+
const errorMsg = `[${remoteEntry.name}][${external.packageName}] Version '${external.version}' is not a valid version.`;
|
|
2360
|
+
if (config.strict.strictExternalVersion) {
|
|
2361
|
+
config.log.error(8, errorMsg);
|
|
2362
|
+
throw new NFError(`Could not process remote '${remoteEntry.name}'`);
|
|
2363
|
+
}
|
|
2364
|
+
config.log.warn(8, errorMsg);
|
|
2365
|
+
}
|
|
2366
|
+
if (external.singleton) {
|
|
2367
|
+
const { action, sharedVersion } = addSharedExternal(remoteEntry.name, external);
|
|
2368
|
+
actions[external.packageName] = { action };
|
|
2369
|
+
if (action === "skip" && external.shareScope && sharedVersion?.remotes[0]?.file) {
|
|
2370
|
+
actions[external.packageName].override = ports.remoteInfoRepo.tryGet(sharedVersion.remotes[0].name).map((remote) => join(remote.scopeUrl, sharedVersion.remotes[0].file)).orThrow(() => {
|
|
2371
|
+
config.log.error(
|
|
2372
|
+
8,
|
|
2373
|
+
`[${external.shareScope ?? GLOBAL_SCOPE}][${remoteEntry.name}][${external.packageName}@${external.version}][override] Remote name not found in cache.`
|
|
2374
|
+
);
|
|
2375
|
+
return new NFError(
|
|
2376
|
+
`Could not find override url from remote ${sharedVersion.remotes[0].name}`
|
|
2377
|
+
);
|
|
2378
|
+
});
|
|
2379
|
+
}
|
|
2380
|
+
} else {
|
|
2381
|
+
addScopedExternal(remoteEntry.name, external);
|
|
2382
|
+
}
|
|
2383
|
+
});
|
|
2384
|
+
return actions;
|
|
2385
|
+
}
|
|
2386
|
+
function addSharedExternal(remoteName, sharedInfo) {
|
|
2387
|
+
const cached = ports.sharedExternalsRepo.tryGet(sharedInfo.packageName, sharedInfo.shareScope).orElse({ dirty: false, versions: [] });
|
|
2388
|
+
let action = "skip";
|
|
2389
|
+
const tag = sharedInfo.version ?? ports.versionCheck.smallestVersion(sharedInfo.requiredVersion);
|
|
2390
|
+
const remote = {
|
|
2391
|
+
file: sharedInfo.outFileName,
|
|
2392
|
+
strictVersion: sharedInfo.strictVersion,
|
|
2393
|
+
requiredVersion: sharedInfo.requiredVersion || tag,
|
|
2394
|
+
name: remoteName,
|
|
2395
|
+
cached: false
|
|
2396
|
+
};
|
|
2397
|
+
const scopeType = ports.sharedExternalsRepo.scopeType(sharedInfo.shareScope);
|
|
2398
|
+
if (scopeType === "strict") {
|
|
2399
|
+
remote.requiredVersion = tag;
|
|
2400
|
+
action = "share";
|
|
2401
|
+
}
|
|
2402
|
+
const sharedVersion = cached.versions.find((c) => c.action === "share");
|
|
2403
|
+
const isCompatible = !sharedVersion || ports.versionCheck.isCompatible(sharedVersion.tag, remote.requiredVersion);
|
|
2404
|
+
if (action === "skip" && !isCompatible && remote.strictVersion) {
|
|
2405
|
+
action = "scope";
|
|
2406
|
+
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}'`;
|
|
2407
|
+
if (config.strict.strictExternalCompatibility) {
|
|
2408
|
+
config.log.error(8, errorMsg);
|
|
2409
|
+
throw new NFError(`Could not process remote '${remoteName}'`);
|
|
2410
|
+
}
|
|
2411
|
+
config.log.warn(8, errorMsg);
|
|
2412
|
+
}
|
|
2413
|
+
const matchingVersion = cached.versions.find((cached2) => cached2.tag === tag);
|
|
2414
|
+
if (!!matchingVersion) {
|
|
2415
|
+
if (remote.strictVersion && matchingVersion.remotes[0].requiredVersion !== remote.requiredVersion) {
|
|
2416
|
+
const errorMsg = `[${remoteName}][${sharedInfo.packageName}@${sharedInfo.version}] Required version '${remote.requiredVersion}' does not match existing '${matchingVersion.remotes[0].requiredVersion}'`;
|
|
2417
|
+
if (config.strict.strictExternalCompatibility) {
|
|
2418
|
+
config.log.error(8, errorMsg);
|
|
2419
|
+
throw new NFError(`Could not process remote '${remoteName}'`);
|
|
2420
|
+
}
|
|
2421
|
+
config.log.warn(8, errorMsg);
|
|
2422
|
+
}
|
|
2423
|
+
matchingVersion.remotes.push(remote);
|
|
2424
|
+
} else {
|
|
2425
|
+
if (!sharedVersion) action = "share";
|
|
2426
|
+
remote.cached = action !== "skip";
|
|
2427
|
+
cached.versions.push({ tag, action, host: false, remotes: [remote] });
|
|
2428
|
+
}
|
|
2429
|
+
ports.sharedExternalsRepo.addOrUpdate(
|
|
2430
|
+
sharedInfo.packageName,
|
|
2431
|
+
{
|
|
2432
|
+
dirty: cached.dirty,
|
|
2433
|
+
versions: cached.versions.sort((a, b) => ports.versionCheck.compare(b.tag, a.tag))
|
|
2434
|
+
},
|
|
2435
|
+
sharedInfo.shareScope
|
|
2436
|
+
);
|
|
2437
|
+
return { action, sharedVersion };
|
|
2438
|
+
}
|
|
2439
|
+
function addScopedExternal(remoteName, sharedInfo) {
|
|
2440
|
+
ports.scopedExternalsRepo.addExternal(remoteName, sharedInfo.packageName, {
|
|
2441
|
+
tag: sharedInfo.version ?? ports.versionCheck.smallestVersion(sharedInfo.requiredVersion),
|
|
2442
|
+
file: sharedInfo.outFileName
|
|
2443
|
+
});
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2447
|
+
// src/lib/5.di/flows/dynamic-init.factory.ts
|
|
2448
|
+
var createDynamicInitDrivers = ({
|
|
2449
|
+
config,
|
|
2450
|
+
adapters
|
|
2451
|
+
}) => ({
|
|
2452
|
+
getRemoteEntry: createGetRemoteEntry(config, adapters),
|
|
2453
|
+
updateCache: createUpdateCache(config, adapters),
|
|
2454
|
+
convertToImportMap: createConvertToImportMap(config),
|
|
2455
|
+
commitChanges: createCommitChanges(config, adapters)
|
|
2456
|
+
});
|
|
2457
|
+
var DYNAMIC_INIT_FLOW_FACTORY = ({
|
|
2458
|
+
config,
|
|
2459
|
+
adapters
|
|
2460
|
+
}) => {
|
|
2461
|
+
const flow = createDynamicInitDrivers({ config, adapters });
|
|
2462
|
+
return {
|
|
2463
|
+
flow,
|
|
2464
|
+
adapters,
|
|
2465
|
+
config
|
|
2466
|
+
};
|
|
2467
|
+
};
|
|
2468
|
+
var createDynamicInitFlow = ({
|
|
2469
|
+
flow,
|
|
2470
|
+
adapters,
|
|
2471
|
+
config
|
|
2472
|
+
}) => {
|
|
2473
|
+
const processDynamicRemoteEntry = async (remoteEntry) => {
|
|
2474
|
+
return flow.updateCache(remoteEntry).then(flow.convertToImportMap).then(flow.commitChanges);
|
|
2475
|
+
};
|
|
2476
|
+
const initRemoteEntry = (remoteEntryUrl, remoteName) => flow.getRemoteEntry(remoteEntryUrl, remoteName).then((entry) => entry.map(processDynamicRemoteEntry).orElse(Promise.resolve())).then(() => ({
|
|
2477
|
+
config,
|
|
2478
|
+
adapters,
|
|
2479
|
+
initRemoteEntry
|
|
2480
|
+
}));
|
|
2481
|
+
return initRemoteEntry;
|
|
2482
|
+
};
|
|
2483
|
+
|
|
2484
|
+
// src/lib/init-federation.ts
|
|
2485
|
+
var initFederation = (remotesOrManifestUrl, options = {}) => {
|
|
2486
|
+
const { adapters, config } = createDriving(createConfigHandlers(options));
|
|
2487
|
+
const stateDump = (msg) => config.log.debug(0, msg, {
|
|
2488
|
+
remotes: { ...adapters.remoteInfoRepo.getAll() },
|
|
2489
|
+
"shared-externals": adapters.sharedExternalsRepo.getScopes({ includeGlobal: true }).reduce(
|
|
2490
|
+
(acc, scope) => ({ ...acc, [scope]: adapters.sharedExternalsRepo.getFromScope(scope) }),
|
|
2491
|
+
{}
|
|
2492
|
+
),
|
|
2493
|
+
"scoped-externals": adapters.scopedExternalsRepo.getAll()
|
|
2494
|
+
});
|
|
2495
|
+
const initFlow = createInitFlow(INIT_FLOW_FACTORY({ adapters, config }));
|
|
2496
|
+
const dynamicInitFlow = createDynamicInitFlow(DYNAMIC_INIT_FLOW_FACTORY({ config, adapters }));
|
|
2497
|
+
return initFlow(remotesOrManifestUrl).then(({ loadRemoteModule }) => {
|
|
2498
|
+
const output = {
|
|
2499
|
+
config,
|
|
2500
|
+
adapters,
|
|
2501
|
+
loadRemoteModule,
|
|
2502
|
+
as: () => ({
|
|
2503
|
+
loadRemoteModule
|
|
2504
|
+
}),
|
|
2505
|
+
remote: (remoteName) => ({
|
|
2506
|
+
loadModule: (exposedModule) => loadRemoteModule(remoteName, exposedModule)
|
|
2507
|
+
})
|
|
2508
|
+
};
|
|
2509
|
+
const initRemoteEntry = async (remoteEntryUrl, remoteName) => dynamicInitFlow(remoteEntryUrl, remoteName).catch((e) => {
|
|
2510
|
+
stateDump(`[dynamic-init][${remoteName ?? remoteEntryUrl}] STATE DUMP`);
|
|
2511
|
+
if (config.strict.strictRemoteEntry) return Promise.reject(e);
|
|
2512
|
+
else console.warn("Failed to initialize remote entry, continuing anyway.");
|
|
2513
|
+
return Promise.resolve();
|
|
2514
|
+
}).then(() => ({
|
|
2515
|
+
...output,
|
|
2516
|
+
initRemoteEntry
|
|
2517
|
+
}));
|
|
2518
|
+
return {
|
|
2519
|
+
...output,
|
|
2520
|
+
initRemoteEntry
|
|
2521
|
+
};
|
|
2522
|
+
}).catch((e) => {
|
|
2523
|
+
stateDump(`[init] STATE DUMP`);
|
|
2524
|
+
return Promise.reject(e);
|
|
2525
|
+
});
|
|
2526
|
+
};
|
|
2527
|
+
export {
|
|
2528
|
+
DYNAMIC_INIT_FLOW_FACTORY,
|
|
2529
|
+
INIT_FLOW_FACTORY,
|
|
2530
|
+
NFError,
|
|
2531
|
+
createConfigHandlers,
|
|
2532
|
+
createDriving,
|
|
2533
|
+
createDynamicInitDrivers,
|
|
2534
|
+
createDynamicInitFlow,
|
|
2535
|
+
createInitDrivers,
|
|
2536
|
+
createInitFlow,
|
|
2537
|
+
initFederation
|
|
2538
|
+
};
|
|
2539
|
+
//# sourceMappingURL=native-federation-orchestrator.mjs.map
|