@starknet-io/get-starknet-core
Version:
[](https://www.npmjs.com/package/get-starknet)
1,473 lines (1,468 loc) • 132 kB
JavaScript
var te = Object.defineProperty;
var re = (t, e, r) => e in t ? te(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
var O = (t, e, r) => (re(t, typeof e != "symbol" ? e + "" : e, r), r), X = (t, e, r) => {
if (!e.has(t))
throw TypeError("Cannot " + r);
};
var v = (t, e, r) => (X(t, e, "read from private field"), r ? r.call(t) : e.get(t)), x = (t, e, r) => {
if (e.has(t))
throw TypeError("Cannot add the same private member more than once");
e instanceof WeakSet ? e.add(t) : e.set(t, r);
}, H = (t, e, r, n) => (X(t, e, "write to private field"), n ? n.call(t, r) : e.set(t, r), r);
var j = (t, e, r) => (X(t, e, "access private method"), r);
const generateUID = () => `${Date.now()}-${Math.floor(Math.random() * 8999999999999) + 1e12}`, shuffle = (t) => {
for (let e = t.length - 1; e > 0; e--) {
const r = Math.floor(Math.random() * (e + 1));
[t[e], t[r]] = [t[r], t[e]];
}
return t;
}, pipe$1 = (...t) => (e) => t.reduce((r, n) => r.then(n), Promise.resolve(e));
function ensureKeysArray(t) {
return Object.keys(t);
}
const ssrSafeWindow = typeof window < "u" ? window : null;
function getBuilderId() {
return typeof FEDERATION_BUILD_IDENTIFIER < "u" ? FEDERATION_BUILD_IDENTIFIER : "";
}
function isDebugMode$1() {
return Boolean("");
}
function isBrowserEnv$1() {
return typeof window < "u";
}
const LOG_CATEGORY$1 = "[ Federation Runtime ]";
function assert(t, e) {
t || error(e);
}
function error(t) {
throw t instanceof Error ? (t.message = `${LOG_CATEGORY$1}: ${t.message}`, t) : new Error(`${LOG_CATEGORY$1}: ${t}`);
}
function warn$1(t) {
t instanceof Error ? (t.message = `${LOG_CATEGORY$1}: ${t.message}`, console.warn(t)) : console.warn(`${LOG_CATEGORY$1}: ${t}`);
}
function addUniqueItem(t, e) {
return t.findIndex((r) => r === e) === -1 && t.push(e), t;
}
function getFMId(t) {
return "version" in t && t.version ? `${t.name}:${t.version}` : "entry" in t && t.entry ? `${t.name}:${t.entry}` : `${t.name}`;
}
function isRemoteInfoWithEntry(t) {
return typeof t.entry < "u";
}
function isPureRemoteEntry(t) {
return !t.entry.includes(".json") && t.entry.includes(".js");
}
function safeToString$1(t) {
try {
return JSON.stringify(t, null, 2);
} catch {
return "";
}
}
function isObject(t) {
return t && typeof t == "object";
}
const objectToString = Object.prototype.toString;
function isPlainObject(t) {
return objectToString.call(t) === "[object Object]";
}
function arrayOptions(t) {
return Array.isArray(t) ? t : [
t
];
}
function _extends$1$1() {
return _extends$1$1 = Object.assign || function(t) {
for (var e = 1; e < arguments.length; e++) {
var r = arguments[e];
for (var n in r)
Object.prototype.hasOwnProperty.call(r, n) && (t[n] = r[n]);
}
return t;
}, _extends$1$1.apply(this, arguments);
}
function _object_without_properties_loose$1(t, e) {
if (t == null)
return {};
var r = {}, n = Object.keys(t), o, i;
for (i = 0; i < n.length; i++)
o = n[i], !(e.indexOf(o) >= 0) && (r[o] = t[o]);
return r;
}
const nativeGlobal = (() => {
try {
return new Function("return this")();
} catch {
return globalThis;
}
})(), Global = nativeGlobal;
function definePropertyGlobalVal(t, e, r) {
Object.defineProperty(t, e, {
value: r,
configurable: !1,
writable: !0
});
}
function includeOwnProperty(t, e) {
return Object.hasOwnProperty.call(t, e);
}
includeOwnProperty(globalThis, "__GLOBAL_LOADING_REMOTE_ENTRY__") || definePropertyGlobalVal(globalThis, "__GLOBAL_LOADING_REMOTE_ENTRY__", {});
const globalLoading = globalThis.__GLOBAL_LOADING_REMOTE_ENTRY__;
function setGlobalDefaultVal(t) {
var e, r, n, o, i, s;
includeOwnProperty(t, "__VMOK__") && !includeOwnProperty(t, "__FEDERATION__") && definePropertyGlobalVal(t, "__FEDERATION__", t.__VMOK__), includeOwnProperty(t, "__FEDERATION__") || (definePropertyGlobalVal(t, "__FEDERATION__", {
__GLOBAL_PLUGIN__: [],
__INSTANCES__: [],
moduleInfo: {},
__SHARE__: {},
__MANIFEST_LOADING__: {},
__PRELOADED_MAP__: /* @__PURE__ */ new Map()
}), definePropertyGlobalVal(t, "__VMOK__", t.__FEDERATION__));
var a;
(a = (e = t.__FEDERATION__).__GLOBAL_PLUGIN__) != null || (e.__GLOBAL_PLUGIN__ = []);
var c;
(c = (r = t.__FEDERATION__).__INSTANCES__) != null || (r.__INSTANCES__ = []);
var l;
(l = (n = t.__FEDERATION__).moduleInfo) != null || (n.moduleInfo = {});
var d;
(d = (o = t.__FEDERATION__).__SHARE__) != null || (o.__SHARE__ = {});
var u;
(u = (i = t.__FEDERATION__).__MANIFEST_LOADING__) != null || (i.__MANIFEST_LOADING__ = {});
var h;
(h = (s = t.__FEDERATION__).__PRELOADED_MAP__) != null || (s.__PRELOADED_MAP__ = /* @__PURE__ */ new Map());
}
setGlobalDefaultVal(globalThis);
setGlobalDefaultVal(nativeGlobal);
function getGlobalFederationInstance(t, e) {
const r = getBuilderId();
return globalThis.__FEDERATION__.__INSTANCES__.find((n) => !!(r && n.options.id === getBuilderId() || n.options.name === t && !n.options.version && !e || n.options.name === t && e && n.options.version === e));
}
function setGlobalFederationInstance(t) {
globalThis.__FEDERATION__.__INSTANCES__.push(t);
}
function getGlobalFederationConstructor() {
return globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__;
}
function setGlobalFederationConstructor(t, e = isDebugMode$1()) {
e && (globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = t, globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.1.21");
}
function getInfoWithoutType(t, e) {
if (typeof e == "string") {
if (t[e])
return {
value: t[e],
key: e
};
{
const n = Object.keys(t);
for (const o of n) {
const [i, s] = o.split(":"), a = `${i}:${e}`, c = t[a];
if (c)
return {
value: c,
key: a
};
}
return {
value: void 0,
key: e
};
}
} else
throw new Error("key must be string");
}
const getGlobalSnapshot = () => nativeGlobal.__FEDERATION__.moduleInfo, getTargetSnapshotInfoByModuleInfo = (t, e) => {
const r = getFMId(t), n = getInfoWithoutType(e, r).value;
if (n && !n.version && "version" in t && t.version && (n.version = t.version), n)
return n;
if ("version" in t && t.version) {
const { version: o } = t, i = _object_without_properties_loose$1(t, [
"version"
]), s = getFMId(i), a = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, s).value;
if ((a == null ? void 0 : a.version) === o)
return a;
}
}, getGlobalSnapshotInfoByModuleInfo = (t) => getTargetSnapshotInfoByModuleInfo(t, nativeGlobal.__FEDERATION__.moduleInfo), setGlobalSnapshotInfoByModuleInfo = (t, e) => {
const r = getFMId(t);
return nativeGlobal.__FEDERATION__.moduleInfo[r] = e, nativeGlobal.__FEDERATION__.moduleInfo;
}, addGlobalSnapshot = (t) => (nativeGlobal.__FEDERATION__.moduleInfo = _extends$1$1({}, nativeGlobal.__FEDERATION__.moduleInfo, t), () => {
const e = Object.keys(t);
for (const r of e)
delete nativeGlobal.__FEDERATION__.moduleInfo[r];
}), getRemoteEntryExports = (t, e) => {
const r = e || `__FEDERATION_${t}:custom__`, n = globalThis[r];
return {
remoteEntryKey: r,
entryExports: n
};
}, getGlobalHostPlugins = () => nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__, getPreloaded = (t) => globalThis.__FEDERATION__.__PRELOADED_MAP__.get(t), setPreloaded = (t) => globalThis.__FEDERATION__.__PRELOADED_MAP__.set(t, !0), DEFAULT_SCOPE = "default", DEFAULT_REMOTE_TYPE = "global", buildIdentifier = "[0-9A-Za-z-]+", build = `(?:\\+(${buildIdentifier}(?:\\.${buildIdentifier})*))`, numericIdentifier = "0|[1-9]\\d*", numericIdentifierLoose = "[0-9]+", nonNumericIdentifier = "\\d*[a-zA-Z-][a-zA-Z0-9-]*", preReleaseIdentifierLoose = `(?:${numericIdentifierLoose}|${nonNumericIdentifier})`, preReleaseLoose = `(?:-?(${preReleaseIdentifierLoose}(?:\\.${preReleaseIdentifierLoose})*))`, preReleaseIdentifier = `(?:${numericIdentifier}|${nonNumericIdentifier})`, preRelease = `(?:-(${preReleaseIdentifier}(?:\\.${preReleaseIdentifier})*))`, xRangeIdentifier = `${numericIdentifier}|x|X|\\*`, xRangePlain = `[v=\\s]*(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:${preRelease})?${build}?)?)?`, hyphenRange = `^\\s*(${xRangePlain})\\s+-\\s+(${xRangePlain})\\s*$`, mainVersionLoose = `(${numericIdentifierLoose})\\.(${numericIdentifierLoose})\\.(${numericIdentifierLoose})`, loosePlain = `[v=\\s]*${mainVersionLoose}${preReleaseLoose}?${build}?`, gtlt = "((?:<|>)?=?)", comparatorTrim = `(\\s*)${gtlt}\\s*(${loosePlain}|${xRangePlain})`, loneTilde = "(?:~>?)", tildeTrim = `(\\s*)${loneTilde}\\s+`, loneCaret = "(?:\\^)", caretTrim = `(\\s*)${loneCaret}\\s+`, star = "(<|>)?=?\\s*\\*", caret = `^${loneCaret}${xRangePlain}$`, mainVersion = `(${numericIdentifier})\\.(${numericIdentifier})\\.(${numericIdentifier})`, fullPlain = `v?${mainVersion}${preRelease}?${build}?`, tilde = `^${loneTilde}${xRangePlain}$`, xRange = `^${gtlt}\\s*${xRangePlain}$`, comparator = `^${gtlt}\\s*(${fullPlain})$|^$`, gte0 = "^\\s*>=\\s*0.0.0\\s*$";
function parseRegex(t) {
return new RegExp(t);
}
function isXVersion(t) {
return !t || t.toLowerCase() === "x" || t === "*";
}
function pipe(...t) {
return (e) => t.reduce((r, n) => n(r), e);
}
function extractComparator(t) {
return t.match(parseRegex(comparator));
}
function combineVersion(t, e, r, n) {
const o = `${t}.${e}.${r}`;
return n ? `${o}-${n}` : o;
}
function parseHyphen(t) {
return t.replace(parseRegex(hyphenRange), (e, r, n, o, i, s, a, c, l, d, u, h) => (isXVersion(n) ? r = "" : isXVersion(o) ? r = `>=${n}.0.0` : isXVersion(i) ? r = `>=${n}.${o}.0` : r = `>=${r}`, isXVersion(l) ? c = "" : isXVersion(d) ? c = `<${Number(l) + 1}.0.0-0` : isXVersion(u) ? c = `<${l}.${Number(d) + 1}.0-0` : h ? c = `<=${l}.${d}.${u}-${h}` : c = `<=${c}`, `${r} ${c}`.trim()));
}
function parseComparatorTrim(t) {
return t.replace(parseRegex(comparatorTrim), "$1$2$3");
}
function parseTildeTrim(t) {
return t.replace(parseRegex(tildeTrim), "$1~");
}
function parseCaretTrim(t) {
return t.replace(parseRegex(caretTrim), "$1^");
}
function parseCarets(t) {
return t.trim().split(/\s+/).map((e) => e.replace(parseRegex(caret), (r, n, o, i, s) => isXVersion(n) ? "" : isXVersion(o) ? `>=${n}.0.0 <${Number(n) + 1}.0.0-0` : isXVersion(i) ? n === "0" ? `>=${n}.${o}.0 <${n}.${Number(o) + 1}.0-0` : `>=${n}.${o}.0 <${Number(n) + 1}.0.0-0` : s ? n === "0" ? o === "0" ? `>=${n}.${o}.${i}-${s} <${n}.${o}.${Number(i) + 1}-0` : `>=${n}.${o}.${i}-${s} <${n}.${Number(o) + 1}.0-0` : `>=${n}.${o}.${i}-${s} <${Number(n) + 1}.0.0-0` : n === "0" ? o === "0" ? `>=${n}.${o}.${i} <${n}.${o}.${Number(i) + 1}-0` : `>=${n}.${o}.${i} <${n}.${Number(o) + 1}.0-0` : `>=${n}.${o}.${i} <${Number(n) + 1}.0.0-0`)).join(" ");
}
function parseTildes(t) {
return t.trim().split(/\s+/).map((e) => e.replace(parseRegex(tilde), (r, n, o, i, s) => isXVersion(n) ? "" : isXVersion(o) ? `>=${n}.0.0 <${Number(n) + 1}.0.0-0` : isXVersion(i) ? `>=${n}.${o}.0 <${n}.${Number(o) + 1}.0-0` : s ? `>=${n}.${o}.${i}-${s} <${n}.${Number(o) + 1}.0-0` : `>=${n}.${o}.${i} <${n}.${Number(o) + 1}.0-0`)).join(" ");
}
function parseXRanges(t) {
return t.split(/\s+/).map((e) => e.trim().replace(parseRegex(xRange), (r, n, o, i, s, a) => {
const c = isXVersion(o), l = c || isXVersion(i), d = l || isXVersion(s);
return n === "=" && d && (n = ""), a = "", c ? n === ">" || n === "<" ? "<0.0.0-0" : "*" : n && d ? (l && (i = 0), s = 0, n === ">" ? (n = ">=", l ? (o = Number(o) + 1, i = 0, s = 0) : (i = Number(i) + 1, s = 0)) : n === "<=" && (n = "<", l ? o = Number(o) + 1 : i = Number(i) + 1), n === "<" && (a = "-0"), `${n + o}.${i}.${s}${a}`) : l ? `>=${o}.0.0${a} <${Number(o) + 1}.0.0-0` : d ? `>=${o}.${i}.0${a} <${o}.${Number(i) + 1}.0-0` : r;
})).join(" ");
}
function parseStar(t) {
return t.trim().replace(parseRegex(star), "");
}
function parseGTE0(t) {
return t.trim().replace(parseRegex(gte0), "");
}
function compareAtom(t, e) {
return t = Number(t) || t, e = Number(e) || e, t > e ? 1 : t === e ? 0 : -1;
}
function comparePreRelease(t, e) {
const { preRelease: r } = t, { preRelease: n } = e;
if (r === void 0 && Boolean(n))
return 1;
if (Boolean(r) && n === void 0)
return -1;
if (r === void 0 && n === void 0)
return 0;
for (let o = 0, i = r.length; o <= i; o++) {
const s = r[o], a = n[o];
if (s !== a)
return s === void 0 && a === void 0 ? 0 : s ? a ? compareAtom(s, a) : -1 : 1;
}
return 0;
}
function compareVersion(t, e) {
return compareAtom(t.major, e.major) || compareAtom(t.minor, e.minor) || compareAtom(t.patch, e.patch) || comparePreRelease(t, e);
}
function eq(t, e) {
return t.version === e.version;
}
function compare(t, e) {
switch (t.operator) {
case "":
case "=":
return eq(t, e);
case ">":
return compareVersion(t, e) < 0;
case ">=":
return eq(t, e) || compareVersion(t, e) < 0;
case "<":
return compareVersion(t, e) > 0;
case "<=":
return eq(t, e) || compareVersion(t, e) > 0;
case void 0:
return !0;
default:
return !1;
}
}
function parseComparatorString(t) {
return pipe(
parseCarets,
parseTildes,
parseXRanges,
parseStar
)(t);
}
function parseRange(t) {
return pipe(
parseHyphen,
parseComparatorTrim,
parseTildeTrim,
parseCaretTrim
)(t.trim()).split(/\s+/).join(" ");
}
function satisfy(t, e) {
if (!t)
return !1;
const o = parseRange(e).split(" ").map((h) => parseComparatorString(h)).join(" ").split(/\s+/).map((h) => parseGTE0(h)), i = extractComparator(t);
if (!i)
return !1;
const [, s, , a, c, l, d] = i, u = {
operator: s,
version: combineVersion(a, c, l, d),
major: a,
minor: c,
patch: l,
preRelease: d == null ? void 0 : d.split(".")
};
for (const h of o) {
const M = extractComparator(h);
if (!M)
return !1;
const [, y, , I, g, p, A] = M, m = {
operator: y,
version: combineVersion(I, g, p, A),
major: I,
minor: g,
patch: p,
preRelease: A == null ? void 0 : A.split(".")
};
if (!compare(m, u))
return !1;
}
return !0;
}
function _extends$8() {
return _extends$8 = Object.assign || function(t) {
for (var e = 1; e < arguments.length; e++) {
var r = arguments[e];
for (var n in r)
Object.prototype.hasOwnProperty.call(r, n) && (t[n] = r[n]);
}
return t;
}, _extends$8.apply(this, arguments);
}
function formatShare(t, e, r) {
let n;
"get" in t ? n = t.get : "lib" in t ? n = () => Promise.resolve(t.lib) : n = () => Promise.resolve(() => {
throw new Error(`Can not get shared '${r}'!`);
});
var o, i;
return _extends$8({
deps: [],
useIn: [],
from: e,
loading: null
}, t, {
shareConfig: _extends$8({
requiredVersion: `^${t.version}`,
singleton: !1,
eager: !1,
strictVersion: !1
}, t.shareConfig),
get: n,
loaded: "lib" in t ? !0 : void 0,
version: (o = t.version) != null ? o : "0",
scope: Array.isArray(t.scope) ? t.scope : [
(i = t.scope) != null ? i : "default"
],
strategy: t.strategy || "version-first"
});
}
function formatShareConfigs(t, e) {
const r = e.shared || {}, n = e.name, o = Object.keys(r).reduce((s, a) => {
const c = arrayOptions(r[a]);
return s[a] = s[a] || [], c.forEach((l) => {
s[a].push(formatShare(l, n, a));
}), s;
}, {}), i = _extends$8({}, t.shared);
return Object.keys(o).forEach((s) => {
i[s] ? o[s].forEach((a) => {
i[s].find((l) => l.version === a.version) || i[s].push(a);
}) : i[s] = o[s];
}), {
shared: i,
shareInfos: o
};
}
function versionLt(t, e) {
const r = (n) => {
if (!Number.isNaN(Number(n))) {
const i = n.split(".");
let s = n;
for (let a = 0; a < 3 - i.length; a++)
s += ".0";
return s;
}
return n;
};
return !!satisfy(r(t), `<=${r(e)}`);
}
const findVersion = (t, e) => {
const r = e || function(n, o) {
return versionLt(n, o);
};
return Object.keys(t).reduce((n, o) => !n || r(n, o) || n === "0" ? o : n, 0);
}, isLoaded = (t) => Boolean(t.loaded) || typeof t.lib == "function";
function findSingletonVersionOrderByVersion(t, e, r) {
const n = t[e][r], o = function(i, s) {
return !isLoaded(n[i]) && versionLt(i, s);
};
return findVersion(t[e][r], o);
}
function findSingletonVersionOrderByLoaded(t, e, r) {
const n = t[e][r], o = function(i, s) {
return isLoaded(n[s]) ? isLoaded(n[i]) ? Boolean(versionLt(i, s)) : !0 : isLoaded(n[i]) ? !1 : versionLt(i, s);
};
return findVersion(t[e][r], o);
}
function getFindShareFunction(t) {
return t === "loaded-first" ? findSingletonVersionOrderByLoaded : findSingletonVersionOrderByVersion;
}
function getRegisteredShare(t, e, r, n) {
if (!t)
return;
const { shareConfig: o, scope: i = DEFAULT_SCOPE, strategy: s } = r, a = Array.isArray(i) ? i : [
i
];
for (const c of a)
if (o && t[c] && t[c][e]) {
const { requiredVersion: l } = o, u = getFindShareFunction(s)(t, c, e), h = () => {
if (o.singleton) {
if (typeof l == "string" && !satisfy(u, l)) {
const I = `Version ${u} from ${u && t[c][e][u].from} of shared singleton module ${e} does not satisfy the requirement of ${r.from} which needs ${l})`;
o.strictVersion ? error(I) : warn$1(I);
}
return t[c][e][u];
} else {
if (l === !1 || l === "*" || satisfy(u, l))
return t[c][e][u];
for (const [I, g] of Object.entries(t[c][e]))
if (satisfy(I, l))
return g;
}
}, M = {
shareScopeMap: t,
scope: c,
pkgName: e,
version: u,
GlobalFederation: Global.__FEDERATION__,
resolver: h
};
return (n.emit(M) || M).resolver();
}
}
function getGlobalShareScope() {
return Global.__FEDERATION__.__SHARE__;
}
function getTargetSharedOptions(t) {
const { pkgName: e, extraOptions: r, shareInfos: n } = t, o = (a) => {
if (!a)
return;
const c = {};
a.forEach((u) => {
c[u.version] = u;
});
const d = findVersion(c, function(u, h) {
return !isLoaded(c[u]) && versionLt(u, h);
});
return c[d];
};
var i;
const s = (i = r == null ? void 0 : r.resolver) != null ? i : o;
return Object.assign({}, s(n[e]), r == null ? void 0 : r.customShareInfo);
}
function _define_property$4(t, e, r) {
return e in t ? Object.defineProperty(t, e, {
value: r,
enumerable: !0,
configurable: !0,
writable: !0
}) : t[e] = r, t;
}
var MANIFEST_EXT = ".json", BROWSER_LOG_KEY = "FEDERATION_DEBUG", BROWSER_LOG_VALUE = "1", NameTransformSymbol = {
AT: "@",
HYPHEN: "-",
SLASH: "/"
}, _obj, NameTransformMap = (_obj = {}, _define_property$4(_obj, NameTransformSymbol.AT, "scope_"), _define_property$4(_obj, NameTransformSymbol.HYPHEN, "_"), _define_property$4(_obj, NameTransformSymbol.SLASH, "__"), _obj), _obj1;
_obj1 = {}, _define_property$4(_obj1, NameTransformMap[NameTransformSymbol.AT], NameTransformSymbol.AT), _define_property$4(_obj1, NameTransformMap[NameTransformSymbol.HYPHEN], NameTransformSymbol.HYPHEN), _define_property$4(_obj1, NameTransformMap[NameTransformSymbol.SLASH], NameTransformSymbol.SLASH);
var SEPARATOR = ":";
function isBrowserEnv() {
return typeof window < "u";
}
function isDebugMode() {
return typeof process < "u" && process.env && process.env.FEDERATION_DEBUG ? Boolean(process.env.FEDERATION_DEBUG) : typeof FEDERATION_DEBUG < "u" && Boolean(FEDERATION_DEBUG);
}
function _array_like_to_array$2(t, e) {
(e == null || e > t.length) && (e = t.length);
for (var r = 0, n = new Array(e); r < e; r++)
n[r] = t[r];
return n;
}
function _array_without_holes(t) {
if (Array.isArray(t))
return _array_like_to_array$2(t);
}
function _class_call_check(t, e) {
if (!(t instanceof e))
throw new TypeError("Cannot call a class as a function");
}
function _defineProperties(t, e) {
for (var r = 0; r < e.length; r++) {
var n = e[r];
n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(t, n.key, n);
}
}
function _create_class(t, e, r) {
return e && _defineProperties(t.prototype, e), r && _defineProperties(t, r), t;
}
function _define_property$3(t, e, r) {
return e in t ? Object.defineProperty(t, e, {
value: r,
enumerable: !0,
configurable: !0,
writable: !0
}) : t[e] = r, t;
}
function _iterable_to_array$1(t) {
if (typeof Symbol < "u" && t[Symbol.iterator] != null || t["@@iterator"] != null)
return Array.from(t);
}
function _non_iterable_spread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _to_consumable_array(t) {
return _array_without_holes(t) || _iterable_to_array$1(t) || _unsupported_iterable_to_array$2(t) || _non_iterable_spread();
}
function _unsupported_iterable_to_array$2(t, e) {
if (!!t) {
if (typeof t == "string")
return _array_like_to_array$2(t, e);
var r = Object.prototype.toString.call(t).slice(8, -1);
if (r === "Object" && t.constructor && (r = t.constructor.name), r === "Map" || r === "Set")
return Array.from(r);
if (r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))
return _array_like_to_array$2(t, e);
}
}
function safeToString(t) {
try {
return JSON.stringify(t, null, 2);
} catch {
return "";
}
}
var DEBUG_LOG = "[ FEDERATION DEBUG ]";
function safeGetLocalStorageItem() {
try {
if (typeof window < "u" && window.localStorage)
return localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE;
} catch {
return typeof document < "u";
}
return !1;
}
var Logger = /* @__PURE__ */ function() {
function t(e) {
_class_call_check(this, t), _define_property$3(this, "enable", !1), _define_property$3(this, "identifier", void 0), this.identifier = e || DEBUG_LOG, isBrowserEnv() && safeGetLocalStorageItem() ? this.enable = !0 : isDebugMode() && (this.enable = !0);
}
return _create_class(t, [
{
key: "info",
value: function(e, r) {
if (this.enable) {
var n = safeToString(r) || "";
isBrowserEnv() ? console.info("%c ".concat(this.identifier, ": ").concat(e, " ").concat(n), "color:#3300CC") : console.info("\x1B[34m%s", "".concat(this.identifier, ": ").concat(e, " ").concat(n ? `
`.concat(n) : ""));
}
}
},
{
key: "logOriginalInfo",
value: function() {
for (var r = arguments.length, n = new Array(r), o = 0; o < r; o++)
n[o] = arguments[o];
if (this.enable)
if (isBrowserEnv()) {
var i;
console.info("%c ".concat(this.identifier, ": OriginalInfo"), "color:#3300CC"), (i = console).log.apply(i, _to_consumable_array(n));
} else {
var s;
console.info("%c ".concat(this.identifier, ": OriginalInfo"), "color:#3300CC"), (s = console).log.apply(s, _to_consumable_array(n));
}
}
}
]), t;
}(), LOG_CATEGORY = "[ Federation Runtime ]";
new Logger();
var composeKeyWithSeparator = function() {
for (var e = arguments.length, r = new Array(e), n = 0; n < e; n++)
r[n] = arguments[n];
return r.length ? r.reduce(function(o, i) {
return i ? o ? "".concat(o).concat(SEPARATOR).concat(i) : i : o;
}, "") : "";
}, getResourceUrl = function(t, e) {
if ("getPublicPath" in t) {
var r = new Function(t.getPublicPath)();
return "".concat(r).concat(e);
} else
return "publicPath" in t ? "".concat(t.publicPath).concat(e) : (console.warn("Can not get resource url, if in debug mode, please ignore", t, e), "");
}, warn = function(t) {
console.warn("".concat(LOG_CATEGORY, ": ").concat(t));
};
function _define_property$2(t, e, r) {
return e in t ? Object.defineProperty(t, e, {
value: r,
enumerable: !0,
configurable: !0,
writable: !0
}) : t[e] = r, t;
}
function _object_spread$2(t) {
for (var e = 1; e < arguments.length; e++) {
var r = arguments[e] != null ? arguments[e] : {}, n = Object.keys(r);
typeof Object.getOwnPropertySymbols == "function" && (n = n.concat(Object.getOwnPropertySymbols(r).filter(function(o) {
return Object.getOwnPropertyDescriptor(r, o).enumerable;
}))), n.forEach(function(o) {
_define_property$2(t, o, r[o]);
});
}
return t;
}
function ownKeys(t, e) {
var r = Object.keys(t);
if (Object.getOwnPropertySymbols) {
var n = Object.getOwnPropertySymbols(t);
e && (n = n.filter(function(o) {
return Object.getOwnPropertyDescriptor(t, o).enumerable;
})), r.push.apply(r, n);
}
return r;
}
function _object_spread_props(t, e) {
return e = e != null ? e : {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(e)) : ownKeys(Object(e)).forEach(function(r) {
Object.defineProperty(t, r, Object.getOwnPropertyDescriptor(e, r));
}), t;
}
var simpleJoinRemoteEntry = function(t, e) {
if (!t)
return e;
var r = function(o) {
if (o === ".")
return "";
if (o.startsWith("./"))
return o.replace("./", "");
if (o.startsWith("/")) {
var i = o.slice(1);
return i.endsWith("/") ? i.slice(0, -1) : i;
}
return o;
}, n = r(t);
return n ? n.endsWith("/") ? "".concat(n).concat(e) : "".concat(n, "/").concat(e) : e;
};
function inferAutoPublicPath(t) {
return t.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
}
function generateSnapshotFromManifest(t) {
var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, r, n, o = e.remotes, i = o === void 0 ? {} : o, s = e.overrides, a = s === void 0 ? {} : s, c = e.version, l, d = function() {
return "publicPath" in t.metaData ? t.metaData.publicPath === "auto" && c ? inferAutoPublicPath(c) : t.metaData.publicPath : t.metaData.getPublicPath;
}, u = Object.keys(a), h = {};
if (!Object.keys(i).length) {
var M;
h = ((M = t.remotes) === null || M === void 0 ? void 0 : M.reduce(function(D, G) {
var W, V = G.federationContainerName;
return u.includes(V) ? W = a[V] : "version" in G ? W = G.version : W = G.entry, D[V] = {
matchedVersion: W
}, D;
}, {})) || {};
}
Object.keys(i).forEach(function(D) {
return h[D] = {
matchedVersion: u.includes(D) ? a[D] : i[D]
};
});
var y = t.metaData, I = y.remoteEntry, g = I.path, p = I.name, A = I.type, m = y.types, b = y.buildInfo.buildVersion, _ = y.globalName, w = t.exposes, L = {
version: c || "",
buildVersion: b,
globalName: _,
remoteEntry: simpleJoinRemoteEntry(g, p),
remoteEntryType: A,
remoteTypes: simpleJoinRemoteEntry(m.path, m.name),
remoteTypesZip: m.zip || "",
remoteTypesAPI: m.api || "",
remotesInfo: h,
shared: t == null ? void 0 : t.shared.map(function(D) {
return {
assets: D.assets,
sharedName: D.name,
version: D.version
};
}),
modules: w == null ? void 0 : w.map(function(D) {
return {
moduleName: D.name,
modulePath: D.path,
assets: D.assets
};
})
};
if (!((r = t.metaData) === null || r === void 0) && r.prefetchInterface) {
var z = t.metaData.prefetchInterface;
L = _object_spread_props(_object_spread$2({}, L), {
prefetchInterface: z
});
}
if (!((n = t.metaData) === null || n === void 0) && n.prefetchEntry) {
var E = t.metaData.prefetchEntry, N = E.path, S = E.name, U = E.type;
L = _object_spread_props(_object_spread$2({}, L), {
prefetchEntry: simpleJoinRemoteEntry(N, S),
prefetchEntryType: U
});
}
return "publicPath" in t.metaData ? l = _object_spread_props(_object_spread$2({}, L), {
publicPath: d()
}) : l = _object_spread_props(_object_spread$2({}, L), {
getPublicPath: d()
}), l;
}
function isManifestProvider(t) {
return !!("remoteEntry" in t && t.remoteEntry.includes(MANIFEST_EXT));
}
function asyncGeneratorStep$1(t, e, r, n, o, i, s) {
try {
var a = t[i](s), c = a.value;
} catch (l) {
r(l);
return;
}
a.done ? e(c) : Promise.resolve(c).then(n, o);
}
function _async_to_generator$1(t) {
return function() {
var e = this, r = arguments;
return new Promise(function(n, o) {
var i = t.apply(e, r);
function s(c) {
asyncGeneratorStep$1(i, n, o, s, a, "next", c);
}
function a(c) {
asyncGeneratorStep$1(i, n, o, s, a, "throw", c);
}
s(void 0);
});
};
}
function _define_property$1(t, e, r) {
return e in t ? Object.defineProperty(t, e, {
value: r,
enumerable: !0,
configurable: !0,
writable: !0
}) : t[e] = r, t;
}
function _instanceof(t, e) {
return e != null && typeof Symbol < "u" && e[Symbol.hasInstance] ? !!e[Symbol.hasInstance](t) : t instanceof e;
}
function _object_spread$1(t) {
for (var e = 1; e < arguments.length; e++) {
var r = arguments[e] != null ? arguments[e] : {}, n = Object.keys(r);
typeof Object.getOwnPropertySymbols == "function" && (n = n.concat(Object.getOwnPropertySymbols(r).filter(function(o) {
return Object.getOwnPropertyDescriptor(r, o).enumerable;
}))), n.forEach(function(o) {
_define_property$1(t, o, r[o]);
});
}
return t;
}
function _type_of$2(t) {
return t && typeof Symbol < "u" && t.constructor === Symbol ? "symbol" : typeof t;
}
function _ts_generator$1(t, e) {
var r, n, o, i, s = {
label: 0,
sent: function() {
if (o[0] & 1)
throw o[1];
return o[1];
},
trys: [],
ops: []
};
return i = {
next: a(0),
throw: a(1),
return: a(2)
}, typeof Symbol == "function" && (i[Symbol.iterator] = function() {
return this;
}), i;
function a(l) {
return function(d) {
return c([
l,
d
]);
};
}
function c(l) {
if (r)
throw new TypeError("Generator is already executing.");
for (; s; )
try {
if (r = 1, n && (o = l[0] & 2 ? n.return : l[0] ? n.throw || ((o = n.return) && o.call(n), 0) : n.next) && !(o = o.call(n, l[1])).done)
return o;
switch (n = 0, o && (l = [
l[0] & 2,
o.value
]), l[0]) {
case 0:
case 1:
o = l;
break;
case 4:
return s.label++, {
value: l[1],
done: !1
};
case 5:
s.label++, n = l[1], l = [
0
];
continue;
case 7:
l = s.ops.pop(), s.trys.pop();
continue;
default:
if (o = s.trys, !(o = o.length > 0 && o[o.length - 1]) && (l[0] === 6 || l[0] === 2)) {
s = 0;
continue;
}
if (l[0] === 3 && (!o || l[1] > o[0] && l[1] < o[3])) {
s.label = l[1];
break;
}
if (l[0] === 6 && s.label < o[1]) {
s.label = o[1], o = l;
break;
}
if (o && s.label < o[2]) {
s.label = o[2], s.ops.push(l);
break;
}
o[2] && s.ops.pop(), s.trys.pop();
continue;
}
l = e.call(t, s);
} catch (d) {
l = [
6,
d
], n = 0;
} finally {
r = o = 0;
}
if (l[0] & 5)
throw l[1];
return {
value: l[0] ? l[1] : void 0,
done: !0
};
}
}
function safeWrapper(t, e) {
return _safeWrapper.apply(this, arguments);
}
function _safeWrapper() {
return _safeWrapper = _async_to_generator$1(function(t, e) {
var r, n;
return _ts_generator$1(this, function(o) {
switch (o.label) {
case 0:
return o.trys.push([
0,
2,
,
3
]), [
4,
t()
];
case 1:
return r = o.sent(), [
2,
r
];
case 2:
return n = o.sent(), !e && warn(n), [
2
];
case 3:
return [
2
];
}
});
}), _safeWrapper.apply(this, arguments);
}
function isStaticResourcesEqual(t, e) {
var r = /^(https?:)?\/\//i, n = t.replace(r, "").replace(/\/$/, ""), o = e.replace(r, "").replace(/\/$/, "");
return n === o;
}
function createScript(t) {
for (var e = null, r = !0, n = 2e4, o, i = document.getElementsByTagName("script"), s = 0; s < i.length; s++) {
var a = i[s], c = a.getAttribute("src");
if (c && isStaticResourcesEqual(c, t.url)) {
e = a, r = !1;
break;
}
}
if (!e) {
if (e = document.createElement("script"), e.type = "text/javascript", e.src = t.url, t.createScriptHook) {
var l = t.createScriptHook(t.url);
_instanceof(l, HTMLScriptElement) ? e = l : (typeof l > "u" ? "undefined" : _type_of$2(l)) === "object" && (l.script && (e = l.script), l.timeout && (n = l.timeout));
}
var d = t.attrs;
d && Object.keys(d).forEach(function(h) {
e && (h === "async" || h === "defer" ? e[h] = d[h] : e.getAttribute(h) || e.setAttribute(h, d[h]));
});
}
var u = function(h, M) {
var y;
if (clearTimeout(o), e && (e.onerror = null, e.onload = null, safeWrapper(function() {
var p = t.needDeleteScript, A = p === void 0 ? !0 : p;
A && e != null && e.parentNode && e.parentNode.removeChild(e);
}), h)) {
var I, g = h(M);
return t == null || (I = t.cb) === null || I === void 0 || I.call(t), g;
}
t == null || (y = t.cb) === null || y === void 0 || y.call(t);
};
return e.onerror = u.bind(null, e.onerror), e.onload = u.bind(null, e.onload), o = setTimeout(function() {
u(null, new Error('Remote script "'.concat(t.url, '" time-outed.')));
}, n), {
script: e,
needAttach: r
};
}
function createLink(t) {
for (var e = null, r = !0, n = document.getElementsByTagName("link"), o = 0; o < n.length; o++) {
var i = n[o], s = i.getAttribute("href"), a = i.getAttribute("ref");
if (s && isStaticResourcesEqual(s, t.url) && a === t.attrs.ref) {
e = i, r = !1;
break;
}
}
if (!e) {
if (e = document.createElement("link"), e.setAttribute("href", t.url), t.createLinkHook) {
var c = t.createLinkHook(t.url);
_instanceof(c, HTMLLinkElement) && (e = c);
}
var l = t.attrs;
l && Object.keys(l).forEach(function(u) {
e && !e.getAttribute(u) && e.setAttribute(u, l[u]);
});
}
var d = function(u, h) {
if (e && (e.onerror = null, e.onload = null, safeWrapper(function() {
var y = t.needDeleteLink, I = y === void 0 ? !0 : y;
I && e != null && e.parentNode && e.parentNode.removeChild(e);
}), u)) {
var M = u(h);
return t.cb(), M;
}
t.cb();
};
return e.onerror = d.bind(null, e.onerror), e.onload = d.bind(null, e.onload), {
link: e,
needAttach: r
};
}
function loadScript(t, e) {
var r = e.attrs, n = r === void 0 ? {} : r, o = e.createScriptHook;
return new Promise(function(i, s) {
var a = createScript({
url: t,
cb: i,
attrs: _object_spread$1({
crossorigin: "anonymous",
fetchpriority: "high"
}, n),
createScriptHook: o,
needDeleteScript: !0
}), c = a.script, l = a.needAttach;
l && document.head.appendChild(c);
});
}
function _array_like_to_array(t, e) {
(e == null || e > t.length) && (e = t.length);
for (var r = 0, n = new Array(e); r < e; r++)
n[r] = t[r];
return n;
}
function _array_with_holes(t) {
if (Array.isArray(t))
return t;
}
function asyncGeneratorStep(t, e, r, n, o, i, s) {
try {
var a = t[i](s), c = a.value;
} catch (l) {
r(l);
return;
}
a.done ? e(c) : Promise.resolve(c).then(n, o);
}
function _async_to_generator(t) {
return function() {
var e = this, r = arguments;
return new Promise(function(n, o) {
var i = t.apply(e, r);
function s(c) {
asyncGeneratorStep(i, n, o, s, a, "next", c);
}
function a(c) {
asyncGeneratorStep(i, n, o, s, a, "throw", c);
}
s(void 0);
});
};
}
function _iterable_to_array_limit(t, e) {
var r = t == null ? null : typeof Symbol < "u" && t[Symbol.iterator] || t["@@iterator"];
if (r != null) {
var n = [], o = !0, i = !1, s, a;
try {
for (r = r.call(t); !(o = (s = r.next()).done) && (n.push(s.value), !(e && n.length === e)); o = !0)
;
} catch (c) {
i = !0, a = c;
} finally {
try {
!o && r.return != null && r.return();
} finally {
if (i)
throw a;
}
}
return n;
}
}
function _non_iterable_rest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _sliced_to_array(t, e) {
return _array_with_holes(t) || _iterable_to_array_limit(t, e) || _unsupported_iterable_to_array(t, e) || _non_iterable_rest();
}
function _type_of$1(t) {
return t && typeof Symbol < "u" && t.constructor === Symbol ? "symbol" : typeof t;
}
function _unsupported_iterable_to_array(t, e) {
if (!!t) {
if (typeof t == "string")
return _array_like_to_array(t, e);
var r = Object.prototype.toString.call(t).slice(8, -1);
if (r === "Object" && t.constructor && (r = t.constructor.name), r === "Map" || r === "Set")
return Array.from(r);
if (r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))
return _array_like_to_array(t, e);
}
}
function _ts_generator(t, e) {
var r, n, o, i, s = {
label: 0,
sent: function() {
if (o[0] & 1)
throw o[1];
return o[1];
},
trys: [],
ops: []
};
return i = {
next: a(0),
throw: a(1),
return: a(2)
}, typeof Symbol == "function" && (i[Symbol.iterator] = function() {
return this;
}), i;
function a(l) {
return function(d) {
return c([
l,
d
]);
};
}
function c(l) {
if (r)
throw new TypeError("Generator is already executing.");
for (; s; )
try {
if (r = 1, n && (o = l[0] & 2 ? n.return : l[0] ? n.throw || ((o = n.return) && o.call(n), 0) : n.next) && !(o = o.call(n, l[1])).done)
return o;
switch (n = 0, o && (l = [
l[0] & 2,
o.value
]), l[0]) {
case 0:
case 1:
o = l;
break;
case 4:
return s.label++, {
value: l[1],
done: !1
};
case 5:
s.label++, n = l[1], l = [
0
];
continue;
case 7:
l = s.ops.pop(), s.trys.pop();
continue;
default:
if (o = s.trys, !(o = o.length > 0 && o[o.length - 1]) && (l[0] === 6 || l[0] === 2)) {
s = 0;
continue;
}
if (l[0] === 3 && (!o || l[1] > o[0] && l[1] < o[3])) {
s.label = l[1];
break;
}
if (l[0] === 6 && s.label < o[1]) {
s.label = o[1], o = l;
break;
}
if (o && s.label < o[2]) {
s.label = o[2], s.ops.push(l);
break;
}
o[2] && s.ops.pop(), s.trys.pop();
continue;
}
l = e.call(t, s);
} catch (d) {
l = [
6,
d
], n = 0;
} finally {
r = o = 0;
}
if (l[0] & 5)
throw l[1];
return {
value: l[0] ? l[1] : void 0,
done: !0
};
}
}
function importNodeModule(t) {
if (!t)
throw new Error("import specifier is required");
var e = new Function("name", "return import(name)");
return e(t).then(function(r) {
return r.default;
}).catch(function(r) {
throw console.error("Error importing module ".concat(t, ":"), r), r;
});
}
function createScriptNode(url, cb, attrs, createScriptHook) {
if (createScriptHook) {
var hookResult = createScriptHook(url);
hookResult && (typeof hookResult > "u" ? "undefined" : _type_of$1(hookResult)) === "object" && "url" in hookResult && (url = hookResult.url);
}
var urlObj;
try {
urlObj = new URL(url);
} catch (t) {
console.error("Error constructing URL:", t), cb(new Error("Invalid URL: ".concat(t)));
return;
}
var getFetch = function() {
var t = _async_to_generator(function() {
var e;
return _ts_generator(this, function(r) {
switch (r.label) {
case 0:
return typeof fetch > "u" ? [
4,
importNodeModule("node-fetch")
] : [
3,
2
];
case 1:
return e = r.sent(), [
2,
(e == null ? void 0 : e.default) || e
];
case 2:
return [
2,
fetch
];
case 3:
return [
2
];
}
});
});
return function() {
return t.apply(this, arguments);
};
}();
console.log("fetching", urlObj.href), getFetch().then(function(f) {
f(urlObj.href).then(function(t) {
return t.text();
}).then(function() {
var _ref = _async_to_generator(function(data) {
var _ref, path, vm, scriptContext, urlDirname, filename, script, exportedInterface, container;
return _ts_generator(this, function(_state) {
switch (_state.label) {
case 0:
return [
4,
Promise.all([
importNodeModule("path"),
importNodeModule("vm")
])
];
case 1:
_ref = _sliced_to_array.apply(void 0, [
_state.sent(),
2
]), path = _ref[0], vm = _ref[1], scriptContext = {
exports: {},
module: {
exports: {}
}
}, urlDirname = urlObj.pathname.split("/").slice(0, -1).join("/"), filename = path.basename(urlObj.pathname);
try {
if (script = new vm.Script("(function(exports, module, require, __dirname, __filename) {".concat(data, `
})`), filename), script.runInThisContext()(scriptContext.exports, scriptContext.module, eval("require"), urlDirname, filename), exportedInterface = scriptContext.module.exports || scriptContext.exports, attrs && exportedInterface && attrs.globalName)
return container = exportedInterface[attrs.globalName] || exportedInterface, cb(void 0, container), [
2
];
cb(void 0, exportedInterface);
} catch (t) {
cb(new Error("Script execution error: ".concat(t)));
}
return [
2
];
}
});
});
return function(t) {
return _ref.apply(this, arguments);
};
}()).catch(function(t) {
cb(t);
});
});
}
function loadScriptNode(t, e) {
return new Promise(function(r, n) {
createScriptNode(t, function(o, i) {
if (o)
n(o);
else {
var s, a, c = (e == null || (s = e.attrs) === null || s === void 0 ? void 0 : s.globalName) || "__FEDERATION_".concat(e == null || (a = e.attrs) === null || a === void 0 ? void 0 : a.name, ":custom__"), l = globalThis[c] = i;
r(l);
}
}, e.attrs, e.createScriptHook);
});
}
function matchRemoteWithNameAndExpose(t, e) {
for (const r of t) {
const n = e.startsWith(r.name);
let o = e.replace(r.name, "");
if (n) {
if (o.startsWith("/")) {
const a = r.name;
return o = `.${o}`, {
pkgNameOrAlias: a,
expose: o,
remote: r
};
} else if (o === "")
return {
pkgNameOrAlias: r.name,
expose: ".",
remote: r
};
}
const i = r.alias && e.startsWith(r.alias);
let s = r.alias && e.replace(r.alias, "");
if (r.alias && i) {
if (s && s.startsWith("/")) {
const a = r.alias;
return s = `.${s}`, {
pkgNameOrAlias: a,
expose: s,
remote: r
};
} else if (s === "")
return {
pkgNameOrAlias: r.alias,
expose: ".",
remote: r
};
}
}
}
function matchRemote(t, e) {
for (const r of t)
if (e === r.name || r.alias && e === r.alias)
return r;
}
function registerPlugins$1(t, e) {
const r = getGlobalHostPlugins();
return r.length > 0 && r.forEach((n) => {
t != null && t.find((o) => o.name !== n.name) && t.push(n);
}), t && t.length > 0 && t.forEach((n) => {
e.forEach((o) => {
o.applyPlugin(n);
});
}), t;
}
function _extends$7() {
return _extends$7 = Object.assign || function(t) {
for (var e = 1; e < arguments.length; e++) {
var r = arguments[e];
for (var n in r)
Object.prototype.hasOwnProperty.call(r, n) && (t[n] = r[n]);
}
return t;
}, _extends$7.apply(this, arguments);
}
async function loadEsmEntry({ entry: t, remoteEntryExports: e }) {
return new Promise((r, n) => {
try {
e ? r(e) : new Function("callbacks", `import("${t}").then(callbacks[0]).catch(callbacks[1])`)([
r,
n
]);
} catch (o) {
n(o);
}
});
}
async function loadEntryScript({ name: t, globalName: e, entry: r, createScriptHook: n }) {
const { entryExports: o } = getRemoteEntryExports(t, e);
return o || (typeof document > "u" ? loadScriptNode(r, {
attrs: {
name: t,
globalName: e
},
createScriptHook: n
}).then(() => {
const { remoteEntryKey: i, entryExports: s } = getRemoteEntryExports(t, e);
return assert(s, `
Unable to use the ${t}'s '${r}' URL with ${i}'s globalName to get remoteEntry exports.
Possible reasons could be:
1. '${r}' is not the correct URL, or the remoteEntry resource or name is incorrect.
2. ${i} cannot be used to get remoteEntry exports in the window object.
`), s;
}).catch((i) => {
throw i;
}) : loadScript(r, {
attrs: {},
createScriptHook: n
}).then(() => {
const { remoteEntryKey: i, entryExports: s } = getRemoteEntryExports(t, e);
return assert(s, `
Unable to use the ${t}'s '${r}' URL with ${i}'s globalName to get remoteEntry exports.
Possible reasons could be:
1. '${r}' is not the correct URL, or the remoteEntry resource or name is incorrect.
2. ${i} cannot be used to get remoteEntry exports in the window object.
`), s;
}).catch((i) => {
throw i;
}));
}
function getRemoteEntryUniqueKey(t) {
const { entry: e, name: r } = t;
return composeKeyWithSeparator(r, e);
}
async function getRemoteEntry({ remoteEntryExports: t, remoteInfo: e, createScriptHook: r }) {
const { entry: n, name: o, type: i, entryGlobalName: s } = e, a = getRemoteEntryUniqueKey(e);
return t || (globalLoading[a] || ([
"esm",
"module"
].includes(i) ? globalLoading[a] = loadEsmEntry({
entry: n,
remoteEntryExports: t
}) : globalLoading[a] = loadEntryScript({
name: o,
globalName: s,
entry: n,
createScriptHook: r
})), globalLoading[a]);
}
function getRemoteInfo(t) {
return _extends$7({}, t, {
entry: "entry" in t ? t.entry : "",
type: t.type || DEFAULT_REMOTE_TYPE,
entryGlobalName: t.entryGlobalName || t.name,
shareScope: t.shareScope || DEFAULT_SCOPE
});
}
function _extends$6() {
return _extends$6 = Object.assign || function(t) {
for (var e = 1; e < arguments.length; e++) {
var r = arguments[e];
for (var n in r)
Object.prototype.hasOwnProperty.call(r, n) && (t[n] = r[n]);
}
return t;
}, _extends$6.apply(this, arguments);
}
let Module = class {
async getEntry() {
if (this.remoteEntryExports)
return this.remoteEntryExports;
const e = await getRemoteEntry({
remoteInfo: this.remoteInfo,
remoteEntryExports: this.remoteEntryExports,
createScriptHook: (r) => {
const n = this.host.loaderHook.lifecycle.createScript.emit({
url: r
});
if (!!n && (typeof document > "u" || n instanceof HTMLScriptElement || "script" in n || "timeout" in n))
return n;
}
});
return assert(e, `remoteEntryExports is undefined
${safeToString$1(this.remoteInfo)}`), this.remoteEntryExports = e, this.remoteEntryExports;
}
async get(e, r, n) {
const { loadFactory: o = !0 } = n || {
loadFactory: !0
}, i = await this.getEntry();
if (!this.inited) {
const l = this.host.shareScopeMap, d = this.remoteInfo.shareScope || "default";
l[d] || (l[d] = {});
const u = l[d], h = [], M = {
version: this.remoteInfo.version || ""
};
Object.defineProperty(M, "shareScopeMap", {
value: l,
enumerable: !1
});
const y = await this.host.hooks.lifecycle.beforeInitContainer.emit({
shareScope: u,
remoteEntryInitOptions: M,
initScope: h,
remoteInfo: this.remoteInfo,
origin: this.host
});
await i.init(y.shareScope, y.initScope, y.remoteEntryInitOptions), await this.host.hooks.lifecycle.initContainer.emit(_extends$6({}, y, {
remoteEntryExports: i
}));
}
this.lib = i, this.inited = !0;
const s = await i.get(r);
assert(s, `${getFMId(this.remoteInfo)} remote don't export ${r}.`);