Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@module-federation/runtime

Package Overview
Dependencies
Maintainers
8
Versions
616
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@module-federation/runtime - npm Package Compare versions

Comparing version 0.0.0-next-20240830062908 to 0.0.0-next-20240830065016

15

dist/helpers.cjs.js
'use strict';
var share = require('./share.cjs.js');
require('@swc/helpers/_/_extends');
require('@swc/helpers/_/_object_without_properties_loose');
require('@module-federation/sdk');
var pluginHelper = /*#__PURE__*/Object.freeze({
__proto__: null,
SyncHook: share.SyncHook,
AsyncHook: share.AsyncHook,
SyncWaterfallHook: share.SyncWaterfallHook,
AsyncWaterfallHook: share.AsyncWaterfallHook,
PluginSystem: share.PluginSystem
});
const ShareUtils = {

@@ -30,3 +37,5 @@ getRegisteredShare: share.getRegisteredShare,

getPreloaded: share.getPreloaded,
setPreloaded: share.setPreloaded
setPreloaded: share.setPreloaded,
registerPlugins: share.registerPlugins,
pluginHelper
};

@@ -33,0 +42,0 @@ var helpers = {

17

dist/helpers.esm.js

@@ -1,6 +0,13 @@

import { o as getRegisteredShare, y as getGlobalShareScope, G as Global, I as nativeGlobal, J as resetFederationGlobalInfo, C as getGlobalFederationInstance, F as setGlobalFederationInstance, E as getGlobalFederationConstructor, B as setGlobalFederationConstructor, m as getInfoWithoutType, u as getGlobalSnapshot, K as getTargetSnapshotInfoByModuleInfo, q as getGlobalSnapshotInfoByModuleInfo, t as setGlobalSnapshotInfoByModuleInfo, r as addGlobalSnapshot, c as getRemoteEntryExports, H as registerGlobalPlugins, g as getGlobalHostPlugins, n as getPreloaded, s as setPreloaded } from './share.esm.js';
import '@swc/helpers/_/_extends';
import '@swc/helpers/_/_object_without_properties_loose';
import { z as SyncHook, A as AsyncHook, S as SyncWaterfallHook, t as AsyncWaterfallHook, P as PluginSystem, n as getRegisteredShare, x as getGlobalShareScope, G as Global, K as nativeGlobal, L as resetFederationGlobalInfo, F as getGlobalFederationInstance, I as setGlobalFederationInstance, H as getGlobalFederationConstructor, E as setGlobalFederationConstructor, k as getInfoWithoutType, u as getGlobalSnapshot, M as getTargetSnapshotInfoByModuleInfo, p as getGlobalSnapshotInfoByModuleInfo, r as setGlobalSnapshotInfoByModuleInfo, q as addGlobalSnapshot, b as getRemoteEntryExports, J as registerGlobalPlugins, N as getGlobalHostPlugins, l as getPreloaded, m as setPreloaded, B as registerPlugins } from './share.esm.js';
import '@module-federation/sdk';
var pluginHelper = /*#__PURE__*/Object.freeze({
__proto__: null,
SyncHook: SyncHook,
AsyncHook: AsyncHook,
SyncWaterfallHook: SyncWaterfallHook,
AsyncWaterfallHook: AsyncWaterfallHook,
PluginSystem: PluginSystem
});
const ShareUtils = {

@@ -28,3 +35,5 @@ getRegisteredShare,

getPreloaded,
setPreloaded
setPreloaded,
registerPlugins,
pluginHelper
};

@@ -31,0 +40,0 @@ var helpers = {

{
"name": "@module-federation/runtime",
"version": "0.6.0",
"version": "0.5.1",
"author": "zhouxiao <codingzx@gmail.com>",

@@ -37,7 +37,2 @@ "main": "./index.cjs.js",

},
"./embedded": {
"types": "./dist/embedded.cjs.d.ts",
"import": "./dist/embedded.esm.js",
"require": "./dist/embedded.cjs.js"
},
"./*": "./*"

@@ -44,0 +39,0 @@ },

'use strict';
var _extends = require('@swc/helpers/_/_extends');
function _extends() {
_extends = Object.assign || function(target) {
for(var i = 1; i < arguments.length; i++){
var source = arguments[i];
for(var key in source){
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
const defaultRetries = 3;

@@ -49,3 +61,3 @@ async function fetchWithRetry({ url, options = {}, retryTimes = defaultRetries, fallbackUrl = '' }) {

url,
options: _extends._({}, options, params == null ? void 0 : params.options),
options: _extends({}, options, params == null ? void 0 : params.options),
retryTimes: params == null ? void 0 : params.retryTimes,

@@ -52,0 +64,0 @@ fallbackUrl: params == null ? void 0 : params.fallbackUrl

@@ -1,3 +0,15 @@

import { _ } from '@swc/helpers/_/_extends';
function _extends() {
_extends = Object.assign || function(target) {
for(var i = 1; i < arguments.length; i++){
var source = arguments[i];
for(var key in source){
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
const defaultRetries = 3;

@@ -47,3 +59,3 @@ async function fetchWithRetry({ url, options = {}, retryTimes = defaultRetries, fallbackUrl = '' }) {

url,
options: _({}, options, params == null ? void 0 : params.options),
options: _extends({}, options, params == null ? void 0 : params.options),
retryTimes: params == null ? void 0 : params.retryTimes,

@@ -50,0 +62,0 @@ fallbackUrl: params == null ? void 0 : params.fallbackUrl

'use strict';
var _extends = require('@swc/helpers/_/_extends');
var _object_without_properties_loose = require('@swc/helpers/_/_object_without_properties_loose');
var sdk = require('@module-federation/sdk');
require('@module-federation/sdk');

@@ -11,2 +9,8 @@ function getBuilderId() {

}
function isDebugMode() {
return Boolean("");
}
function isBrowserEnv() {
return typeof window !== 'undefined';
}

@@ -57,2 +61,10 @@ const LOG_CATEGORY = '[ Federation Runtime ]';

}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
function safeToString(info) {
try {
return JSON.stringify(info, null, 2);
} catch (e) {
return '';
}
}
function isObject(val) {

@@ -77,3 +89,3 @@ return val && typeof val === 'object';

};
if (sdk.isBrowserEnv()) {
if (isBrowserEnv()) {
return 'remoteEntry' in snapshot ? {

@@ -95,2 +107,28 @@ url: snapshot.remoteEntry,

function _extends$1() {
_extends$1 = Object.assign || function(target) {
for(var i = 1; i < arguments.length; i++){
var source = arguments[i];
for(var key in source){
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends$1.apply(this, arguments);
}
function _object_without_properties_loose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for(i = 0; i < sourceKeys.length; i++){
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
const nativeGlobal = (()=>{

@@ -180,6 +218,6 @@ try {

}
function setGlobalFederationConstructor(FederationConstructor, isDebug = sdk.isDebugMode()) {
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
if (isDebug) {
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.0";
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.5.1";
}

@@ -232,3 +270,3 @@ }

if ('version' in moduleInfo && moduleInfo['version']) {
const { version } = moduleInfo, resModuleInfo = _object_without_properties_loose._(moduleInfo, [
const { version } = moduleInfo, resModuleInfo = _object_without_properties_loose(moduleInfo, [
"version"

@@ -251,3 +289,3 @@ ]);

const addGlobalSnapshot = (moduleInfos)=>{
nativeGlobal.__FEDERATION__.moduleInfo = _extends._({}, nativeGlobal.__FEDERATION__.moduleInfo, moduleInfos);
nativeGlobal.__FEDERATION__.moduleInfo = _extends$1({}, nativeGlobal.__FEDERATION__.moduleInfo, moduleInfos);
return ()=>{

@@ -286,5 +324,212 @@ const keys = Object.keys(moduleInfos);

function registerPlugins(plugins, hookInstances) {
const globalPlugins = getGlobalHostPlugins();
// Incorporate global plugins
if (globalPlugins.length > 0) {
globalPlugins.forEach((plugin)=>{
if (plugins == null ? void 0 : plugins.find((item)=>item.name !== plugin.name)) {
plugins.push(plugin);
}
});
}
if (plugins && plugins.length > 0) {
plugins.forEach((plugin)=>{
hookInstances.forEach((hookInstance)=>{
hookInstance.applyPlugin(plugin);
});
});
}
return plugins;
}
const DEFAULT_SCOPE = 'default';
const DEFAULT_REMOTE_TYPE = 'global';
class SyncHook {
on(fn) {
if (typeof fn === 'function') {
this.listeners.add(fn);
}
}
once(fn) {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this;
this.on(function wrapper(...args) {
self.remove(wrapper);
// eslint-disable-next-line prefer-spread
return fn.apply(null, args);
});
}
emit(...data) {
let result;
if (this.listeners.size > 0) {
// eslint-disable-next-line prefer-spread
this.listeners.forEach((fn)=>{
result = fn(...data);
});
}
return result;
}
remove(fn) {
this.listeners.delete(fn);
}
removeAll() {
this.listeners.clear();
}
constructor(type){
this.type = '';
this.listeners = new Set();
if (type) {
this.type = type;
}
}
}
class AsyncHook extends SyncHook {
emit(...data) {
let result;
const ls = Array.from(this.listeners);
if (ls.length > 0) {
let i = 0;
const call = (prev)=>{
if (prev === false) {
return false; // Abort process
} else if (i < ls.length) {
return Promise.resolve(ls[i++].apply(null, data)).then(call);
} else {
return prev;
}
};
result = call();
}
return Promise.resolve(result);
}
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
function checkReturnData(originalData, returnedData) {
if (!isObject(returnedData)) {
return false;
}
if (originalData !== returnedData) {
// eslint-disable-next-line no-restricted-syntax
for(const key in originalData){
if (!(key in returnedData)) {
return false;
}
}
}
return true;
}
class SyncWaterfallHook extends SyncHook {
emit(data) {
if (!isObject(data)) {
error(`The data for the "${this.type}" hook should be an object.`);
}
for (const fn of this.listeners){
try {
const tempData = fn(data);
if (checkReturnData(data, tempData)) {
data = tempData;
} else {
this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);
break;
}
} catch (e) {
warn(e);
this.onerror(e);
}
}
return data;
}
constructor(type){
super();
this.onerror = error;
this.type = type;
}
}
class AsyncWaterfallHook extends SyncHook {
emit(data) {
if (!isObject(data)) {
error(`The response data for the "${this.type}" hook must be an object.`);
}
const ls = Array.from(this.listeners);
if (ls.length > 0) {
let i = 0;
const processError = (e)=>{
warn(e);
this.onerror(e);
return data;
};
const call = (prevData)=>{
if (checkReturnData(data, prevData)) {
data = prevData;
if (i < ls.length) {
try {
return Promise.resolve(ls[i++](data)).then(call, processError);
} catch (e) {
return processError(e);
}
}
} else {
this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);
}
return data;
};
return Promise.resolve(call(data));
}
return Promise.resolve(data);
}
constructor(type){
super();
this.onerror = error;
this.type = type;
}
}
class PluginSystem {
applyPlugin(plugin) {
assert(isPlainObject(plugin), 'Plugin configuration is invalid.');
// The plugin's name is mandatory and must be unique
const pluginName = plugin.name;
assert(pluginName, 'A name must be provided by the plugin.');
if (!this.registerPlugins[pluginName]) {
this.registerPlugins[pluginName] = plugin;
Object.keys(this.lifecycle).forEach((key)=>{
const pluginLife = plugin[key];
if (pluginLife) {
this.lifecycle[key].on(pluginLife);
}
});
}
}
removePlugin(pluginName) {
assert(pluginName, 'A name is required.');
const plugin = this.registerPlugins[pluginName];
assert(plugin, `The plugin "${pluginName}" is not registered.`);
Object.keys(plugin).forEach((key)=>{
if (key !== 'name') {
this.lifecycle[key].remove(plugin[key]);
}
});
}
// eslint-disable-next-line @typescript-eslint/no-shadow
inherit({ lifecycle, registerPlugins }) {
Object.keys(lifecycle).forEach((hookName)=>{
assert(!this.lifecycle[hookName], `The hook "${hookName}" has a conflict and cannot be inherited.`);
this.lifecycle[hookName] = lifecycle[hookName];
});
Object.keys(registerPlugins).forEach((pluginName)=>{
assert(!this.registerPlugins[pluginName], `The plugin "${pluginName}" has a conflict and cannot be inherited.`);
this.applyPlugin(registerPlugins[pluginName]);
});
}
constructor(lifecycle){
this.registerPlugins = {};
this.lifecycle = lifecycle;
this.lifecycleKeys = Object.keys(lifecycle);
}
}
// fork from https://github.com/originjs/vite-plugin-federation/blob/v1.1.12/packages/lib/src/utils/semver/index.ts

@@ -646,2 +891,16 @@ // those constants are based on https://www.rubydoc.info/gems/semantic_range/3.0.0/SemanticRange#BUILDIDENTIFIER-constant

function _extends() {
_extends = Object.assign || function(target) {
for(var i = 1; i < arguments.length; i++){
var source = arguments[i];
for(var key in source){
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function formatShare(shareArgs, from, name, shareStrategy) {

@@ -663,3 +922,3 @@ let get;

var _shareArgs_version, _shareArgs_scope, _shareArgs_strategy;
return _extends._({
return _extends({
deps: [],

@@ -670,3 +929,3 @@ useIn: [],

}, shareArgs, {
shareConfig: _extends._({
shareConfig: _extends({
requiredVersion: `^${shareArgs.version}`,

@@ -697,3 +956,3 @@ singleton: false,

}, {});
const shared = _extends._({}, globalOptions.shared);
const shared = _extends({}, globalOptions.shared);
Object.keys(shareInfos).forEach((shareKey)=>{

@@ -862,5 +1121,10 @@ if (!shared[shareKey]) {

exports.AsyncHook = AsyncHook;
exports.AsyncWaterfallHook = AsyncWaterfallHook;
exports.DEFAULT_REMOTE_TYPE = DEFAULT_REMOTE_TYPE;
exports.DEFAULT_SCOPE = DEFAULT_SCOPE;
exports.Global = Global;
exports.PluginSystem = PluginSystem;
exports.SyncHook = SyncHook;
exports.SyncWaterfallHook = SyncWaterfallHook;
exports.addGlobalSnapshot = addGlobalSnapshot;

@@ -888,4 +1152,3 @@ exports.addUniqueItem = addUniqueItem;

exports.globalLoading = globalLoading;
exports.isObject = isObject;
exports.isPlainObject = isPlainObject;
exports.isBrowserEnv = isBrowserEnv;
exports.isPureRemoteEntry = isPureRemoteEntry;

@@ -895,3 +1158,5 @@ exports.isRemoteInfoWithEntry = isRemoteInfoWithEntry;

exports.registerGlobalPlugins = registerGlobalPlugins;
exports.registerPlugins = registerPlugins;
exports.resetFederationGlobalInfo = resetFederationGlobalInfo;
exports.safeToString = safeToString;
exports.setGlobalFederationConstructor = setGlobalFederationConstructor;

@@ -901,2 +1166,1 @@ exports.setGlobalFederationInstance = setGlobalFederationInstance;

exports.setPreloaded = setPreloaded;
exports.warn = warn;

@@ -1,4 +0,2 @@

import { _ as _$1 } from '@swc/helpers/_/_extends';
import { _ } from '@swc/helpers/_/_object_without_properties_loose';
import { isBrowserEnv, isDebugMode } from '@module-federation/sdk';
import '@module-federation/sdk';

@@ -9,2 +7,8 @@ function getBuilderId() {

}
function isDebugMode() {
return Boolean("");
}
function isBrowserEnv() {
return typeof window !== 'undefined';
}

@@ -55,2 +59,10 @@ const LOG_CATEGORY = '[ Federation Runtime ]';

}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
function safeToString(info) {
try {
return JSON.stringify(info, null, 2);
} catch (e) {
return '';
}
}
function isObject(val) {

@@ -92,2 +104,28 @@ return val && typeof val === 'object';

function _extends$1() {
_extends$1 = Object.assign || function(target) {
for(var i = 1; i < arguments.length; i++){
var source = arguments[i];
for(var key in source){
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends$1.apply(this, arguments);
}
function _object_without_properties_loose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for(i = 0; i < sourceKeys.length; i++){
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
const nativeGlobal = (()=>{

@@ -180,3 +218,3 @@ try {

globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.0";
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.5.1";
}

@@ -229,3 +267,3 @@ }

if ('version' in moduleInfo && moduleInfo['version']) {
const { version } = moduleInfo, resModuleInfo = _(moduleInfo, [
const { version } = moduleInfo, resModuleInfo = _object_without_properties_loose(moduleInfo, [
"version"

@@ -248,3 +286,3 @@ ]);

const addGlobalSnapshot = (moduleInfos)=>{
nativeGlobal.__FEDERATION__.moduleInfo = _$1({}, nativeGlobal.__FEDERATION__.moduleInfo, moduleInfos);
nativeGlobal.__FEDERATION__.moduleInfo = _extends$1({}, nativeGlobal.__FEDERATION__.moduleInfo, moduleInfos);
return ()=>{

@@ -283,5 +321,212 @@ const keys = Object.keys(moduleInfos);

function registerPlugins(plugins, hookInstances) {
const globalPlugins = getGlobalHostPlugins();
// Incorporate global plugins
if (globalPlugins.length > 0) {
globalPlugins.forEach((plugin)=>{
if (plugins == null ? void 0 : plugins.find((item)=>item.name !== plugin.name)) {
plugins.push(plugin);
}
});
}
if (plugins && plugins.length > 0) {
plugins.forEach((plugin)=>{
hookInstances.forEach((hookInstance)=>{
hookInstance.applyPlugin(plugin);
});
});
}
return plugins;
}
const DEFAULT_SCOPE = 'default';
const DEFAULT_REMOTE_TYPE = 'global';
class SyncHook {
on(fn) {
if (typeof fn === 'function') {
this.listeners.add(fn);
}
}
once(fn) {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this;
this.on(function wrapper(...args) {
self.remove(wrapper);
// eslint-disable-next-line prefer-spread
return fn.apply(null, args);
});
}
emit(...data) {
let result;
if (this.listeners.size > 0) {
// eslint-disable-next-line prefer-spread
this.listeners.forEach((fn)=>{
result = fn(...data);
});
}
return result;
}
remove(fn) {
this.listeners.delete(fn);
}
removeAll() {
this.listeners.clear();
}
constructor(type){
this.type = '';
this.listeners = new Set();
if (type) {
this.type = type;
}
}
}
class AsyncHook extends SyncHook {
emit(...data) {
let result;
const ls = Array.from(this.listeners);
if (ls.length > 0) {
let i = 0;
const call = (prev)=>{
if (prev === false) {
return false; // Abort process
} else if (i < ls.length) {
return Promise.resolve(ls[i++].apply(null, data)).then(call);
} else {
return prev;
}
};
result = call();
}
return Promise.resolve(result);
}
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
function checkReturnData(originalData, returnedData) {
if (!isObject(returnedData)) {
return false;
}
if (originalData !== returnedData) {
// eslint-disable-next-line no-restricted-syntax
for(const key in originalData){
if (!(key in returnedData)) {
return false;
}
}
}
return true;
}
class SyncWaterfallHook extends SyncHook {
emit(data) {
if (!isObject(data)) {
error(`The data for the "${this.type}" hook should be an object.`);
}
for (const fn of this.listeners){
try {
const tempData = fn(data);
if (checkReturnData(data, tempData)) {
data = tempData;
} else {
this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);
break;
}
} catch (e) {
warn(e);
this.onerror(e);
}
}
return data;
}
constructor(type){
super();
this.onerror = error;
this.type = type;
}
}
class AsyncWaterfallHook extends SyncHook {
emit(data) {
if (!isObject(data)) {
error(`The response data for the "${this.type}" hook must be an object.`);
}
const ls = Array.from(this.listeners);
if (ls.length > 0) {
let i = 0;
const processError = (e)=>{
warn(e);
this.onerror(e);
return data;
};
const call = (prevData)=>{
if (checkReturnData(data, prevData)) {
data = prevData;
if (i < ls.length) {
try {
return Promise.resolve(ls[i++](data)).then(call, processError);
} catch (e) {
return processError(e);
}
}
} else {
this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);
}
return data;
};
return Promise.resolve(call(data));
}
return Promise.resolve(data);
}
constructor(type){
super();
this.onerror = error;
this.type = type;
}
}
class PluginSystem {
applyPlugin(plugin) {
assert(isPlainObject(plugin), 'Plugin configuration is invalid.');
// The plugin's name is mandatory and must be unique
const pluginName = plugin.name;
assert(pluginName, 'A name must be provided by the plugin.');
if (!this.registerPlugins[pluginName]) {
this.registerPlugins[pluginName] = plugin;
Object.keys(this.lifecycle).forEach((key)=>{
const pluginLife = plugin[key];
if (pluginLife) {
this.lifecycle[key].on(pluginLife);
}
});
}
}
removePlugin(pluginName) {
assert(pluginName, 'A name is required.');
const plugin = this.registerPlugins[pluginName];
assert(plugin, `The plugin "${pluginName}" is not registered.`);
Object.keys(plugin).forEach((key)=>{
if (key !== 'name') {
this.lifecycle[key].remove(plugin[key]);
}
});
}
// eslint-disable-next-line @typescript-eslint/no-shadow
inherit({ lifecycle, registerPlugins }) {
Object.keys(lifecycle).forEach((hookName)=>{
assert(!this.lifecycle[hookName], `The hook "${hookName}" has a conflict and cannot be inherited.`);
this.lifecycle[hookName] = lifecycle[hookName];
});
Object.keys(registerPlugins).forEach((pluginName)=>{
assert(!this.registerPlugins[pluginName], `The plugin "${pluginName}" has a conflict and cannot be inherited.`);
this.applyPlugin(registerPlugins[pluginName]);
});
}
constructor(lifecycle){
this.registerPlugins = {};
this.lifecycle = lifecycle;
this.lifecycleKeys = Object.keys(lifecycle);
}
}
// fork from https://github.com/originjs/vite-plugin-federation/blob/v1.1.12/packages/lib/src/utils/semver/index.ts

@@ -643,2 +888,16 @@ // those constants are based on https://www.rubydoc.info/gems/semantic_range/3.0.0/SemanticRange#BUILDIDENTIFIER-constant

function _extends() {
_extends = Object.assign || function(target) {
for(var i = 1; i < arguments.length; i++){
var source = arguments[i];
for(var key in source){
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function formatShare(shareArgs, from, name, shareStrategy) {

@@ -660,3 +919,3 @@ let get;

var _shareArgs_version, _shareArgs_scope, _shareArgs_strategy;
return _$1({
return _extends({
deps: [],

@@ -667,3 +926,3 @@ useIn: [],

}, shareArgs, {
shareConfig: _$1({
shareConfig: _extends({
requiredVersion: `^${shareArgs.version}`,

@@ -694,3 +953,3 @@ singleton: false,

}, {});
const shared = _$1({}, globalOptions.shared);
const shared = _extends({}, globalOptions.shared);
Object.keys(shareInfos).forEach((shareKey)=>{

@@ -859,2 +1118,2 @@ if (!shared[shareKey]) {

export { getBuilderId as A, setGlobalFederationConstructor as B, getGlobalFederationInstance as C, DEFAULT_REMOTE_TYPE as D, getGlobalFederationConstructor as E, setGlobalFederationInstance as F, Global as G, registerGlobalPlugins as H, nativeGlobal as I, resetFederationGlobalInfo as J, getTargetSnapshotInfoByModuleInfo as K, globalLoading as a, DEFAULT_SCOPE as b, getRemoteEntryExports as c, assert as d, getFMId as e, error as f, getGlobalHostPlugins as g, isPlainObject as h, isObject as i, isRemoteInfoWithEntry as j, isPureRemoteEntry as k, getRemoteEntryInfoFromSnapshot as l, getInfoWithoutType as m, getPreloaded as n, getRegisteredShare as o, arrayOptions as p, getGlobalSnapshotInfoByModuleInfo as q, addGlobalSnapshot as r, setPreloaded as s, setGlobalSnapshotInfoByModuleInfo as t, getGlobalSnapshot as u, formatShareConfigs as v, warn as w, getTargetSharedOptions as x, getGlobalShareScope as y, addUniqueItem as z };
export { AsyncHook as A, registerPlugins as B, getBuilderId as C, DEFAULT_REMOTE_TYPE as D, setGlobalFederationConstructor as E, getGlobalFederationInstance as F, Global as G, getGlobalFederationConstructor as H, setGlobalFederationInstance as I, registerGlobalPlugins as J, nativeGlobal as K, resetFederationGlobalInfo as L, getTargetSnapshotInfoByModuleInfo as M, getGlobalHostPlugins as N, PluginSystem as P, SyncWaterfallHook as S, DEFAULT_SCOPE as a, getRemoteEntryExports as b, assert as c, getFMId as d, isPureRemoteEntry as e, getRemoteEntryInfoFromSnapshot as f, globalLoading as g, error as h, isRemoteInfoWithEntry as i, isBrowserEnv as j, getInfoWithoutType as k, getPreloaded as l, setPreloaded as m, getRegisteredShare as n, arrayOptions as o, getGlobalSnapshotInfoByModuleInfo as p, addGlobalSnapshot as q, setGlobalSnapshotInfoByModuleInfo as r, safeToString as s, AsyncWaterfallHook as t, getGlobalSnapshot as u, formatShareConfigs as v, getTargetSharedOptions as w, getGlobalShareScope as x, addUniqueItem as y, SyncHook as z };
import type { CreateScriptHookReturn } from '@module-federation/sdk';
import { Options, PreloadRemoteArgs, RemoteEntryExports, Remote, Shared, ShareInfos, UserOptions, RemoteInfo, ShareScopeMap, InitScope, RemoteEntryInitOptions, CallFrom } from './type';
import { Options, PreloadRemoteArgs, RemoteEntryExports, Remote, Shared, ShareInfos, UserOptions, RemoteInfo, ShareScopeMap, InitScope, RemoteEntryInitOptions } from './type';
import { Module } from './module';

@@ -72,11 +72,7 @@ import { AsyncHook, AsyncWaterfallHook, PluginSystem, SyncHook, SyncWaterfallHook } from './utils/hooks';

}): () => T | never;
initializeSharing(shareScopeName?: string, extraOptions?: {
initScope?: InitScope;
from?: CallFrom;
strategy?: Shared['strategy'];
}): Array<Promise<void>>;
initializeSharing(shareScopeName?: string, strategy?: Shared['strategy']): Array<Promise<void>>;
initRawContainer(name: string, url: string, container: RemoteEntryExports): Module;
loadRemote<T>(id: string, options?: {
loadFactory?: boolean;
from: CallFrom;
from: 'build' | 'runtime';
}): Promise<T | null>;

@@ -83,0 +79,0 @@ preloadRemote(preloadOptions: Array<PreloadRemoteArgs>): Promise<void>;

import { resetFederationGlobalInfo, getGlobalFederationInstance, setGlobalFederationInstance, getGlobalFederationConstructor, setGlobalFederationConstructor, getInfoWithoutType, getGlobalSnapshot, getTargetSnapshotInfoByModuleInfo, getGlobalSnapshotInfoByModuleInfo, setGlobalSnapshotInfoByModuleInfo, addGlobalSnapshot, getRemoteEntryExports, registerGlobalPlugins, getGlobalHostPlugins, getPreloaded, setPreloaded, Global } from './global';
import { getRegisteredShare, getGlobalShareScope } from './utils/share';
import * as pluginHelper from './utils/hooks';
import { registerPlugins } from './utils';
interface IShareUtils {

@@ -26,2 +28,4 @@ getRegisteredShare: typeof getRegisteredShare;

setPreloaded: typeof setPreloaded;
registerPlugins: typeof registerPlugins;
pluginHelper: typeof pluginHelper;
}

@@ -28,0 +32,0 @@ declare const _default: {

@@ -35,2 +35,7 @@ import { GlobalModuleInfo, Manifest, ModuleInfo } from '@module-federation/sdk';

}>;
afterLoadSnapshot: AsyncWaterfallHook<{
options: Options;
moduleInfo: Remote;
remoteSnapshot: ModuleInfo;
}>;
}>;

@@ -37,0 +42,0 @@ loaderHook: FederationHost['loaderHook'];

@@ -1,3 +0,3 @@

import { ModuleInfo, GlobalModuleInfo } from '@module-federation/sdk';
import { Options, UserOptions, PreloadAssets, PreloadOptions, PreloadRemoteArgs, Remote, RemoteInfo, RemoteEntryExports, CallFrom } from '../type';
import type { ModuleInfo, GlobalModuleInfo } from '@module-federation/sdk';
import { Options, UserOptions, PreloadAssets, PreloadOptions, PreloadRemoteArgs, Remote, RemoteInfo, RemoteEntryExports } from '../type';
import { FederationHost } from '../core';

@@ -59,3 +59,3 @@ import { PluginSystem, AsyncHook, AsyncWaterfallHook, SyncHook, SyncWaterfallHook } from '../utils/hooks';

options?: any;
from: CallFrom;
from: "build" | "runtime";
lifecycle: "onLoad" | "beforeRequest";

@@ -93,3 +93,3 @@ origin: FederationHost;

loadFactory?: boolean;
from: CallFrom;
from: 'build' | 'runtime';
}): Promise<T | null>;

@@ -96,0 +96,0 @@ preloadRemote(preloadOptions: Array<PreloadRemoteArgs>): Promise<void>;

import { Federation } from '../global';
import { Options, ShareScopeMap, ShareInfos, Shared, UserOptions, ShareStrategy, InitScope, InitTokens, CallFrom } from '../type';
import { Options, ShareScopeMap, ShareInfos, Shared, UserOptions, ShareStrategy } from '../type';
import { FederationHost } from '../core';

@@ -34,3 +34,2 @@ import { PluginSystem, AsyncHook, AsyncWaterfallHook, SyncWaterfallHook } from '../utils/hooks';

}>;
initTokens: InitTokens;
constructor(host: FederationHost);

@@ -52,7 +51,3 @@ registerShared(globalOptions: Options, userOptions: UserOptions): {

*/
initializeSharing(shareScopeName?: string, extraOptions?: {
initScope?: InitScope;
from?: CallFrom;
strategy?: ShareStrategy;
}): Array<Promise<void>>;
initializeSharing(shareScopeName?: string, strategy?: ShareStrategy): Array<Promise<void>>;
loadShareSync<T>(pkgName: string, extraOptions?: {

@@ -59,0 +54,0 @@ customShareInfo?: Partial<Shared>;

@@ -105,5 +105,3 @@ import type { RemoteWithEntry, RemoteWithVersion, Module, RemoteEntryType } from '@module-federation/sdk';

};
export type InitTokens = Record<string, Record<string, any>>;
export type InitScope = InitTokens[];
export type CallFrom = 'build' | 'runtime';
export type InitScope = Array<Record<string, never>>;
export type RemoteEntryExports = {

@@ -110,0 +108,0 @@ get: (id: string) => () => Promise<Module>;

@@ -1,3 +0,4 @@

export { isBrowserEnv, isDebugMode } from '@module-federation/sdk';
export declare function isDevelopmentMode(): boolean;
export declare function getBuilderId(): string;
export declare function isDebugMode(): boolean;
export declare function isBrowserEnv(): boolean;
import { FederationHost } from '../core';
import { UserOptions } from '../type';
import { Module } from '../module';
export declare function registerPlugins(plugins: UserOptions['plugins'], hookInstances: Array<FederationHost['hooks'] | FederationHost['snapshotHandler']['hooks'] | FederationHost['sharedHandler']['hooks'] | FederationHost['remoteHandler']['hooks'] | Module['host']['loaderHook']>): import("../type").FederationRuntimePlugin[] | undefined;
import { PluginSystem } from './hooks';
export declare function registerPlugins<Y extends Record<string, any>, T extends PluginSystem<Y>>(plugins: UserOptions['plugins'], hookInstances: Array<T | FederationHost['hooks'] | FederationHost['snapshotHandler']['hooks'] | FederationHost['sharedHandler']['hooks'] | FederationHost['remoteHandler']['hooks'] | Module['host']['loaderHook']>): import("../type").FederationRuntimePlugin[] | undefined;

@@ -1,2 +0,2 @@

import { RemoteWithEntry, ModuleInfo, RemoteEntryType } from '@module-federation/sdk';
import type { RemoteWithEntry, ModuleInfo, RemoteEntryType } from '@module-federation/sdk';
import { Remote, RemoteInfoOptionalVersion } from '../type';

@@ -8,2 +8,3 @@ export declare function addUniqueItem(arr: Array<string>, item: string): Array<string>;

export declare function safeWrapper<T extends (...args: Array<any>) => any>(callback: T, disableWarn?: boolean): Promise<ReturnType<T> | undefined>;
export declare function safeToString(info: any): string;
export declare function isObject(val: any): boolean;

@@ -10,0 +11,0 @@ export declare const objectToString: () => string;

{
"name": "@module-federation/runtime",
"version": "0.0.0-next-20240830062908",
"version": "0.0.0-next-20240830065016",
"author": "zhouxiao <codingzx@gmail.com>",

@@ -37,7 +37,2 @@ "main": "./dist/index.cjs.js",

},
"./embedded": {
"types": "./dist/embedded.cjs.d.ts",
"import": "./dist/embedded.esm.js",
"require": "./dist/embedded.cjs.js"
},
"./*": "./*"

@@ -62,4 +57,4 @@ },

"dependencies": {
"@module-federation/sdk": "0.0.0-next-20240830062908"
"@module-federation/sdk": "0.0.0-next-20240830065016"
}
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc