@module-federation/sdk
Advanced tools
Comparing version 0.0.0-canary-1702522677984 to 0.0.0-feat-node-support-1702694175665
357
index.cjs.js
@@ -46,3 +46,3 @@ 'use strict'; | ||
function _array_like_to_array$1(arr, len) { | ||
function _array_like_to_array$2(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
@@ -53,3 +53,3 @@ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i]; | ||
function _array_without_holes(arr) { | ||
if (Array.isArray(arr)) return _array_like_to_array$1(arr); | ||
if (Array.isArray(arr)) return _array_like_to_array$2(arr); | ||
} | ||
@@ -95,11 +95,11 @@ function _class_call_check(instance, Constructor) { | ||
function _to_consumable_array(arr) { | ||
return _array_without_holes(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$1(arr) || _non_iterable_spread(); | ||
return _array_without_holes(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$2(arr) || _non_iterable_spread(); | ||
} | ||
function _unsupported_iterable_to_array$1(o, minLen) { | ||
function _unsupported_iterable_to_array$2(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _array_like_to_array$1(o, minLen); | ||
if (typeof o === "string") return _array_like_to_array$2(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(n); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen); | ||
} | ||
@@ -163,3 +163,3 @@ function safeToString(info) { | ||
function _array_like_to_array(arr, len) { | ||
function _array_like_to_array$1(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
@@ -169,3 +169,3 @@ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i]; | ||
} | ||
function _array_with_holes(arr) { | ||
function _array_with_holes$1(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
@@ -176,3 +176,3 @@ } | ||
} | ||
function _iterable_to_array_limit(arr, i) { | ||
function _iterable_to_array_limit$1(arr, i) { | ||
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; | ||
@@ -201,18 +201,18 @@ if (_i == null) return; | ||
} | ||
function _non_iterable_rest() { | ||
function _non_iterable_rest$1() { | ||
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(arr, i) { | ||
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest(); | ||
function _sliced_to_array$1(arr, i) { | ||
return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1(); | ||
} | ||
function _to_array(arr) { | ||
return _array_with_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_rest(); | ||
return _array_with_holes$1(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array$1(arr) || _non_iterable_rest$1(); | ||
} | ||
function _unsupported_iterable_to_array(o, minLen) { | ||
function _unsupported_iterable_to_array$1(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _array_like_to_array(o, minLen); | ||
if (typeof o === "string") return _array_like_to_array$1(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(n); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen); | ||
} | ||
@@ -247,3 +247,3 @@ var LOG_CATEGORY = "[ Federation Runtime ]"; | ||
} else if (strSplit.length === 1) { | ||
var _strSplit1 = _sliced_to_array(strSplit, 1), name1 = _strSplit1[0]; | ||
var _strSplit1 = _sliced_to_array$1(strSplit, 1), name1 = _strSplit1[0]; | ||
if (devVersionOrUrl && isEntry(devVersionOrUrl)) { | ||
@@ -524,3 +524,3 @@ return { | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) { | ||
try { | ||
@@ -539,3 +539,3 @@ var info = gen[key](arg); | ||
} | ||
function _async_to_generator(fn) { | ||
function _async_to_generator$1(fn) { | ||
return function() { | ||
@@ -546,6 +546,6 @@ var self = this, args = arguments; | ||
function _next(value) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); | ||
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value); | ||
} | ||
function _throw(err) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); | ||
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err); | ||
} | ||
@@ -563,3 +563,3 @@ _next(undefined); | ||
} | ||
function _ts_generator(thisArg, body) { | ||
function _ts_generator$1(thisArg, body) { | ||
var f, y, t, g, _ = { | ||
@@ -664,5 +664,5 @@ label: 0, | ||
function _safeWrapper() { | ||
_safeWrapper = _async_to_generator(function(callback, disableWarn) { | ||
_safeWrapper = _async_to_generator$1(function(callback, disableWarn) { | ||
var res, e; | ||
return _ts_generator(this, function(_state) { | ||
return _ts_generator$1(this, function(_state) { | ||
switch(_state.label){ | ||
@@ -778,2 +778,309 @@ case 0: | ||
function _array_like_to_array(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _array_with_holes(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
} | ||
function asyncGeneratorStep(gen, resolve1, reject1, _next, _throw, key, arg) { | ||
try { | ||
var info1 = gen[key](arg); | ||
var value = info1.value; | ||
} catch (error1) { | ||
reject1(error1); | ||
return; | ||
} | ||
if (info1.done) { | ||
resolve1(value); | ||
} else { | ||
Promise.resolve(value).then(_next, _throw); | ||
} | ||
} | ||
function _async_to_generator(fn) { | ||
return function() { | ||
var self = this, args = arguments; | ||
return new Promise(function(resolve1, reject1) { | ||
var gen = fn.apply(self, args); | ||
function _next(value) { | ||
asyncGeneratorStep(gen, resolve1, reject1, _next, _throw, "next", value); | ||
} | ||
function _throw(err1) { | ||
asyncGeneratorStep(gen, resolve1, reject1, _next, _throw, "throw", err1); | ||
} | ||
_next(undefined); | ||
}); | ||
}; | ||
} | ||
function _iterable_to_array_limit(arr, i) { | ||
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; | ||
if (_i == null) return; | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _s, _e; | ||
try { | ||
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){ | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err1) { | ||
_d = true; | ||
_e = err1; | ||
} finally{ | ||
try { | ||
if (!_n && _i["return"] != null) _i["return"](); | ||
} finally{ | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
} | ||
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(arr, i) { | ||
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest(); | ||
} | ||
function _unsupported_iterable_to_array(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _array_like_to_array(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(n); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen); | ||
} | ||
function _ts_generator(thisArg, body) { | ||
var f1, y, t, g, _ = { | ||
label: 0, | ||
sent: function() { | ||
if (t[0] & 1) throw t[1]; | ||
return t[1]; | ||
}, | ||
trys: [], | ||
ops: [] | ||
}; | ||
return g = { | ||
next: verb(0), | ||
"throw": verb(1), | ||
"return": verb(2) | ||
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() { | ||
return this; | ||
}), g; | ||
function verb(n) { | ||
return function(v) { | ||
return step([ | ||
n, | ||
v | ||
]); | ||
}; | ||
} | ||
function step(op) { | ||
if (f1) throw new TypeError("Generator is already executing."); | ||
while(_)try { | ||
if (f1 = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [ | ||
op[0] & 2, | ||
t.value | ||
]; | ||
switch(op[0]){ | ||
case 0: | ||
case 1: | ||
t = op; | ||
break; | ||
case 4: | ||
_.label++; | ||
return { | ||
value: op[1], | ||
done: false | ||
}; | ||
case 5: | ||
_.label++; | ||
y = op[1]; | ||
op = [ | ||
0 | ||
]; | ||
continue; | ||
case 7: | ||
op = _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { | ||
_ = 0; | ||
continue; | ||
} | ||
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { | ||
_.label = op[1]; | ||
break; | ||
} | ||
if (op[0] === 6 && _.label < t[1]) { | ||
_.label = t[1]; | ||
t = op; | ||
break; | ||
} | ||
if (t && _.label < t[2]) { | ||
_.label = t[2]; | ||
_.ops.push(op); | ||
break; | ||
} | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e1) { | ||
op = [ | ||
6, | ||
e1 | ||
]; | ||
y = 0; | ||
} finally{ | ||
f1 = t = 0; | ||
} | ||
if (op[0] & 5) throw op[1]; | ||
return { | ||
value: op[0] ? op[1] : void 0, | ||
done: true | ||
}; | ||
} | ||
} | ||
function importNodeModule(name1) { | ||
return new Promise(function(resolve1, reject1) { | ||
new Function("resolve", 'import("'.concat(name1, '").then((res)=>{resolve(res);}, (error)=> reject(error))'))(resolve1); | ||
}); | ||
} | ||
function createScriptNode(url, cb, attrs, createScriptHook) { | ||
if (createScriptHook) { | ||
var hookResult = createScriptHook(url); | ||
if (hookResult && typeof hookResult === "object" && "url" in hookResult) { | ||
url = hookResult.url; | ||
} | ||
} | ||
var urlObj; | ||
try { | ||
urlObj = new URL(url); | ||
} catch (e) { | ||
console.error("Error constructing URL:", e); | ||
cb(new Error("Invalid URL: ".concat(e))); | ||
return; | ||
} | ||
var getFetch = function() { | ||
var _ref = _async_to_generator(function() { | ||
var fetchModule1; | ||
return _ts_generator(this, function(_state) { | ||
switch(_state.label){ | ||
case 0: | ||
if (!(typeof fetch === "undefined")) return [ | ||
3, | ||
2 | ||
]; | ||
return [ | ||
4, | ||
importNodeModule("node-fetch") | ||
]; | ||
case 1: | ||
fetchModule1 = _state.sent(); | ||
//@ts-ignore | ||
return [ | ||
2, | ||
(fetchModule1 === null || fetchModule1 === void 0 ? void 0 : fetchModule1.default) || fetchModule1 | ||
]; | ||
case 2: | ||
return [ | ||
2, | ||
fetch | ||
]; | ||
case 3: | ||
return [ | ||
2 | ||
]; | ||
} | ||
}); | ||
}); | ||
return function getFetch1() { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}(); | ||
console.log("fetching", urlObj.href); | ||
getFetch().then(function(f) { | ||
f(urlObj.href).then(function(res1) { | ||
return res1.text(); | ||
}).then(function() { | ||
var _ref = _async_to_generator(function(data1) { | ||
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 { | ||
script = new vm.Script("(function(exports, module, require, __dirname, __filename) {".concat(data1, "\n})"), { | ||
filename: filename | ||
}); | ||
script.runInThisContext()(scriptContext.exports, scriptContext.module, eval("require"), urlDirname, filename); | ||
exportedInterface = scriptContext.module.exports || scriptContext.exports; | ||
if (attrs && exportedInterface && attrs["globalName"]) { | ||
container = exportedInterface[attrs["globalName"]]; | ||
cb(undefined, container); | ||
return [ | ||
2 | ||
]; | ||
} | ||
cb(undefined, exportedInterface); | ||
} catch (e) { | ||
console.error("Error running script:", e); | ||
cb(new Error("Script execution error: ".concat(e))); | ||
} | ||
return [ | ||
2 | ||
]; | ||
} | ||
}); | ||
}); | ||
return function(data1) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}()).catch(function(err1) { | ||
console.error("Error fetching script:", err1); | ||
cb(err1); | ||
}); | ||
}); | ||
} | ||
function loadScriptNode(url1, info1) { | ||
return new Promise(function(resolve1, reject1) { | ||
createScriptNode(url1, function(error1, scriptContext1) { | ||
if (error1) { | ||
reject1(error1); | ||
} else { | ||
var _info_attrs, _info_attrs1; | ||
// Handle the loaded script context as needed | ||
console.log("Script loaded successfully:", scriptContext1); | ||
var remoteEntryKey1 = (info1 === null || info1 === void 0 ? void 0 : (_info_attrs = info1.attrs) === null || _info_attrs === void 0 ? void 0 : _info_attrs["globalName"]) || "__FEDERATION_".concat(info1 === null || info1 === void 0 ? void 0 : (_info_attrs1 = info1.attrs) === null || _info_attrs1 === void 0 ? void 0 : _info_attrs1["name"], ":custom__"); | ||
var entryExports1 = globalThis[remoteEntryKey1] = scriptContext1; | ||
resolve1(entryExports1); | ||
} | ||
}, info1.attrs, info1.createScriptHook); | ||
}); | ||
} | ||
exports.BROWSER_LOG_KEY = BROWSER_LOG_KEY; | ||
@@ -791,2 +1098,3 @@ exports.BROWSER_LOG_VALUE = BROWSER_LOG_VALUE; | ||
exports.createScript = createScript; | ||
exports.createScriptNode = createScriptNode; | ||
exports.decodeName = decodeName; | ||
@@ -805,2 +1113,3 @@ exports.encodeName = encodeName; | ||
exports.loadScript = loadScript; | ||
exports.loadScriptNode = loadScriptNode; | ||
exports.logger = logger; | ||
@@ -807,0 +1116,0 @@ exports.parseEntry = parseEntry; |
357
index.esm.js
@@ -42,3 +42,3 @@ function _define_property$2(obj, key, value) { | ||
function _array_like_to_array$1(arr, len) { | ||
function _array_like_to_array$2(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
@@ -49,3 +49,3 @@ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i]; | ||
function _array_without_holes(arr) { | ||
if (Array.isArray(arr)) return _array_like_to_array$1(arr); | ||
if (Array.isArray(arr)) return _array_like_to_array$2(arr); | ||
} | ||
@@ -91,11 +91,11 @@ function _class_call_check(instance, Constructor) { | ||
function _to_consumable_array(arr) { | ||
return _array_without_holes(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$1(arr) || _non_iterable_spread(); | ||
return _array_without_holes(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$2(arr) || _non_iterable_spread(); | ||
} | ||
function _unsupported_iterable_to_array$1(o, minLen) { | ||
function _unsupported_iterable_to_array$2(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _array_like_to_array$1(o, minLen); | ||
if (typeof o === "string") return _array_like_to_array$2(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(n); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen); | ||
} | ||
@@ -159,3 +159,3 @@ function safeToString(info) { | ||
function _array_like_to_array(arr, len) { | ||
function _array_like_to_array$1(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
@@ -165,3 +165,3 @@ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i]; | ||
} | ||
function _array_with_holes(arr) { | ||
function _array_with_holes$1(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
@@ -172,3 +172,3 @@ } | ||
} | ||
function _iterable_to_array_limit(arr, i) { | ||
function _iterable_to_array_limit$1(arr, i) { | ||
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; | ||
@@ -197,18 +197,18 @@ if (_i == null) return; | ||
} | ||
function _non_iterable_rest() { | ||
function _non_iterable_rest$1() { | ||
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(arr, i) { | ||
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest(); | ||
function _sliced_to_array$1(arr, i) { | ||
return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1(); | ||
} | ||
function _to_array(arr) { | ||
return _array_with_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_rest(); | ||
return _array_with_holes$1(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array$1(arr) || _non_iterable_rest$1(); | ||
} | ||
function _unsupported_iterable_to_array(o, minLen) { | ||
function _unsupported_iterable_to_array$1(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _array_like_to_array(o, minLen); | ||
if (typeof o === "string") return _array_like_to_array$1(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(n); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen); | ||
} | ||
@@ -243,3 +243,3 @@ var LOG_CATEGORY = "[ Federation Runtime ]"; | ||
} else if (strSplit.length === 1) { | ||
var _strSplit1 = _sliced_to_array(strSplit, 1), name1 = _strSplit1[0]; | ||
var _strSplit1 = _sliced_to_array$1(strSplit, 1), name1 = _strSplit1[0]; | ||
if (devVersionOrUrl && isEntry(devVersionOrUrl)) { | ||
@@ -520,3 +520,3 @@ return { | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) { | ||
try { | ||
@@ -535,3 +535,3 @@ var info = gen[key](arg); | ||
} | ||
function _async_to_generator(fn) { | ||
function _async_to_generator$1(fn) { | ||
return function() { | ||
@@ -542,6 +542,6 @@ var self = this, args = arguments; | ||
function _next(value) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); | ||
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value); | ||
} | ||
function _throw(err) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); | ||
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err); | ||
} | ||
@@ -559,3 +559,3 @@ _next(undefined); | ||
} | ||
function _ts_generator(thisArg, body) { | ||
function _ts_generator$1(thisArg, body) { | ||
var f, y, t, g, _ = { | ||
@@ -660,5 +660,5 @@ label: 0, | ||
function _safeWrapper() { | ||
_safeWrapper = _async_to_generator(function(callback, disableWarn) { | ||
_safeWrapper = _async_to_generator$1(function(callback, disableWarn) { | ||
var res, e; | ||
return _ts_generator(this, function(_state) { | ||
return _ts_generator$1(this, function(_state) { | ||
switch(_state.label){ | ||
@@ -774,2 +774,309 @@ case 0: | ||
export { BROWSER_LOG_KEY, BROWSER_LOG_VALUE, EncodedNameTransformMap, FederationModuleManifest, Logger, MANIFEST_EXT, NameTransformMap, NameTransformSymbol, SEPARATOR, assert, composeKeyWithSeparator, createScript, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, generateSnapshotFromManifest, getProcessEnv, getResourceUrl, isBrowserEnv, isDebugMode, isManifestProvider, isStaticResourcesEqual, loadScript, logger, parseEntry, safeWrapper, warn }; | ||
function _array_like_to_array(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _array_with_holes(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
} | ||
function asyncGeneratorStep(gen, resolve1, reject1, _next, _throw, key, arg) { | ||
try { | ||
var info1 = gen[key](arg); | ||
var value = info1.value; | ||
} catch (error1) { | ||
reject1(error1); | ||
return; | ||
} | ||
if (info1.done) { | ||
resolve1(value); | ||
} else { | ||
Promise.resolve(value).then(_next, _throw); | ||
} | ||
} | ||
function _async_to_generator(fn) { | ||
return function() { | ||
var self = this, args = arguments; | ||
return new Promise(function(resolve1, reject1) { | ||
var gen = fn.apply(self, args); | ||
function _next(value) { | ||
asyncGeneratorStep(gen, resolve1, reject1, _next, _throw, "next", value); | ||
} | ||
function _throw(err1) { | ||
asyncGeneratorStep(gen, resolve1, reject1, _next, _throw, "throw", err1); | ||
} | ||
_next(undefined); | ||
}); | ||
}; | ||
} | ||
function _iterable_to_array_limit(arr, i) { | ||
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; | ||
if (_i == null) return; | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _s, _e; | ||
try { | ||
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){ | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err1) { | ||
_d = true; | ||
_e = err1; | ||
} finally{ | ||
try { | ||
if (!_n && _i["return"] != null) _i["return"](); | ||
} finally{ | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
} | ||
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(arr, i) { | ||
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest(); | ||
} | ||
function _unsupported_iterable_to_array(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _array_like_to_array(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(n); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen); | ||
} | ||
function _ts_generator(thisArg, body) { | ||
var f1, y, t, g, _ = { | ||
label: 0, | ||
sent: function() { | ||
if (t[0] & 1) throw t[1]; | ||
return t[1]; | ||
}, | ||
trys: [], | ||
ops: [] | ||
}; | ||
return g = { | ||
next: verb(0), | ||
"throw": verb(1), | ||
"return": verb(2) | ||
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() { | ||
return this; | ||
}), g; | ||
function verb(n) { | ||
return function(v) { | ||
return step([ | ||
n, | ||
v | ||
]); | ||
}; | ||
} | ||
function step(op) { | ||
if (f1) throw new TypeError("Generator is already executing."); | ||
while(_)try { | ||
if (f1 = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [ | ||
op[0] & 2, | ||
t.value | ||
]; | ||
switch(op[0]){ | ||
case 0: | ||
case 1: | ||
t = op; | ||
break; | ||
case 4: | ||
_.label++; | ||
return { | ||
value: op[1], | ||
done: false | ||
}; | ||
case 5: | ||
_.label++; | ||
y = op[1]; | ||
op = [ | ||
0 | ||
]; | ||
continue; | ||
case 7: | ||
op = _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { | ||
_ = 0; | ||
continue; | ||
} | ||
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { | ||
_.label = op[1]; | ||
break; | ||
} | ||
if (op[0] === 6 && _.label < t[1]) { | ||
_.label = t[1]; | ||
t = op; | ||
break; | ||
} | ||
if (t && _.label < t[2]) { | ||
_.label = t[2]; | ||
_.ops.push(op); | ||
break; | ||
} | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e1) { | ||
op = [ | ||
6, | ||
e1 | ||
]; | ||
y = 0; | ||
} finally{ | ||
f1 = t = 0; | ||
} | ||
if (op[0] & 5) throw op[1]; | ||
return { | ||
value: op[0] ? op[1] : void 0, | ||
done: true | ||
}; | ||
} | ||
} | ||
function importNodeModule(name1) { | ||
return new Promise(function(resolve1, reject1) { | ||
new Function("resolve", 'import("'.concat(name1, '").then((res)=>{resolve(res);}, (error)=> reject(error))'))(resolve1); | ||
}); | ||
} | ||
function createScriptNode(url, cb, attrs, createScriptHook) { | ||
if (createScriptHook) { | ||
var hookResult = createScriptHook(url); | ||
if (hookResult && typeof hookResult === "object" && "url" in hookResult) { | ||
url = hookResult.url; | ||
} | ||
} | ||
var urlObj; | ||
try { | ||
urlObj = new URL(url); | ||
} catch (e) { | ||
console.error("Error constructing URL:", e); | ||
cb(new Error("Invalid URL: ".concat(e))); | ||
return; | ||
} | ||
var getFetch = function() { | ||
var _ref = _async_to_generator(function() { | ||
var fetchModule1; | ||
return _ts_generator(this, function(_state) { | ||
switch(_state.label){ | ||
case 0: | ||
if (!(typeof fetch === "undefined")) return [ | ||
3, | ||
2 | ||
]; | ||
return [ | ||
4, | ||
importNodeModule("node-fetch") | ||
]; | ||
case 1: | ||
fetchModule1 = _state.sent(); | ||
//@ts-ignore | ||
return [ | ||
2, | ||
(fetchModule1 === null || fetchModule1 === void 0 ? void 0 : fetchModule1.default) || fetchModule1 | ||
]; | ||
case 2: | ||
return [ | ||
2, | ||
fetch | ||
]; | ||
case 3: | ||
return [ | ||
2 | ||
]; | ||
} | ||
}); | ||
}); | ||
return function getFetch1() { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}(); | ||
console.log("fetching", urlObj.href); | ||
getFetch().then(function(f) { | ||
f(urlObj.href).then(function(res1) { | ||
return res1.text(); | ||
}).then(function() { | ||
var _ref = _async_to_generator(function(data1) { | ||
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 { | ||
script = new vm.Script("(function(exports, module, require, __dirname, __filename) {".concat(data1, "\n})"), { | ||
filename: filename | ||
}); | ||
script.runInThisContext()(scriptContext.exports, scriptContext.module, eval("require"), urlDirname, filename); | ||
exportedInterface = scriptContext.module.exports || scriptContext.exports; | ||
if (attrs && exportedInterface && attrs["globalName"]) { | ||
container = exportedInterface[attrs["globalName"]]; | ||
cb(undefined, container); | ||
return [ | ||
2 | ||
]; | ||
} | ||
cb(undefined, exportedInterface); | ||
} catch (e) { | ||
console.error("Error running script:", e); | ||
cb(new Error("Script execution error: ".concat(e))); | ||
} | ||
return [ | ||
2 | ||
]; | ||
} | ||
}); | ||
}); | ||
return function(data1) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}()).catch(function(err1) { | ||
console.error("Error fetching script:", err1); | ||
cb(err1); | ||
}); | ||
}); | ||
} | ||
function loadScriptNode(url1, info1) { | ||
return new Promise(function(resolve1, reject1) { | ||
createScriptNode(url1, function(error1, scriptContext1) { | ||
if (error1) { | ||
reject1(error1); | ||
} else { | ||
var _info_attrs, _info_attrs1; | ||
// Handle the loaded script context as needed | ||
console.log("Script loaded successfully:", scriptContext1); | ||
var remoteEntryKey1 = (info1 === null || info1 === void 0 ? void 0 : (_info_attrs = info1.attrs) === null || _info_attrs === void 0 ? void 0 : _info_attrs["globalName"]) || "__FEDERATION_".concat(info1 === null || info1 === void 0 ? void 0 : (_info_attrs1 = info1.attrs) === null || _info_attrs1 === void 0 ? void 0 : _info_attrs1["name"], ":custom__"); | ||
var entryExports1 = globalThis[remoteEntryKey1] = scriptContext1; | ||
resolve1(entryExports1); | ||
} | ||
}, info1.attrs, info1.createScriptHook); | ||
}); | ||
} | ||
export { BROWSER_LOG_KEY, BROWSER_LOG_VALUE, EncodedNameTransformMap, FederationModuleManifest, Logger, MANIFEST_EXT, NameTransformMap, NameTransformSymbol, SEPARATOR, assert, composeKeyWithSeparator, createScript, createScriptNode, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, generateSnapshotFromManifest, getProcessEnv, getResourceUrl, isBrowserEnv, isDebugMode, isManifestProvider, isStaticResourcesEqual, loadScript, loadScriptNode, logger, parseEntry, safeWrapper, warn }; |
{ | ||
"name": "@module-federation/sdk", | ||
"version": "0.0.0-canary-1702522677984", | ||
"version": "0.0.0-feat-node-support-1702694175665", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "A sdk for support module federation", |
@@ -8,1 +8,2 @@ export * from './constant'; | ||
export * from './dom'; | ||
export * from './node'; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
96325
26
2501
4