@module-federation/runtime
Advanced tools
Comparing version 0.0.0-next-20241015065721 to 0.0.0-next-20241016062654
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
function getRuntime() { | ||
@@ -6,0 +4,0 @@ // @ts-ignore |
'use strict'; | ||
var share = require('./share.cjs.js'); | ||
require('./polyfills.cjs.js'); | ||
require('@module-federation/sdk'); | ||
require('./polyfills.cjs.js'); | ||
var pluginHelper = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
SyncHook: share.SyncHook, | ||
AsyncHook: share.AsyncHook, | ||
SyncWaterfallHook: share.SyncWaterfallHook, | ||
AsyncWaterfallHook: share.AsyncWaterfallHook, | ||
PluginSystem: share.PluginSystem | ||
}); | ||
const ShareUtils = { | ||
@@ -38,5 +29,3 @@ getRegisteredShare: share.getRegisteredShare, | ||
getPreloaded: share.getPreloaded, | ||
setPreloaded: share.setPreloaded, | ||
registerPlugins: share.registerPlugins, | ||
pluginHelper | ||
setPreloaded: share.setPreloaded | ||
}; | ||
@@ -43,0 +32,0 @@ var helpers = { |
@@ -1,14 +0,5 @@ | ||
import { y as SyncHook, A as AsyncHook, S as SyncWaterfallHook, r as AsyncWaterfallHook, P as PluginSystem, l as getRegisteredShare, w as getGlobalShareScope, G as Global, J as nativeGlobal, K as resetFederationGlobalInfo, E as getGlobalFederationInstance, H as setGlobalFederationInstance, F as getGlobalFederationConstructor, C as setGlobalFederationConstructor, j as getInfoWithoutType, t as getGlobalSnapshot, L as getTargetSnapshotInfoByModuleInfo, n as getGlobalSnapshotInfoByModuleInfo, q as setGlobalSnapshotInfoByModuleInfo, o as addGlobalSnapshot, b as getRemoteEntryExports, I as registerGlobalPlugins, M as getGlobalHostPlugins, k as getPreloaded, s as setPreloaded, z as registerPlugins } from './share.esm.js'; | ||
import { g as getRegisteredShare, a as getGlobalShareScope, G as Global, n as nativeGlobal, r as resetFederationGlobalInfo, b as getGlobalFederationInstance, s as setGlobalFederationInstance, c as getGlobalFederationConstructor, d as setGlobalFederationConstructor, e as getInfoWithoutType, f as getGlobalSnapshot, h as getTargetSnapshotInfoByModuleInfo, i as getGlobalSnapshotInfoByModuleInfo, j as setGlobalSnapshotInfoByModuleInfo, k as addGlobalSnapshot, l as getRemoteEntryExports, m as registerGlobalPlugins, o as getGlobalHostPlugins, p as getPreloaded, q as setPreloaded } from './share.esm.js'; | ||
import './polyfills.esm.js'; | ||
import '@module-federation/sdk'; | ||
import './polyfills.esm.js'; | ||
var pluginHelper = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
SyncHook: SyncHook, | ||
AsyncHook: AsyncHook, | ||
SyncWaterfallHook: SyncWaterfallHook, | ||
AsyncWaterfallHook: AsyncWaterfallHook, | ||
PluginSystem: PluginSystem | ||
}); | ||
const ShareUtils = { | ||
@@ -36,5 +27,3 @@ getRegisteredShare, | ||
getPreloaded, | ||
setPreloaded, | ||
registerPlugins, | ||
pluginHelper | ||
setPreloaded | ||
}; | ||
@@ -41,0 +30,0 @@ var helpers = { |
{ | ||
"name": "@module-federation/runtime", | ||
"version": "0.6.6", | ||
"version": "0.6.10", | ||
"author": "zhouxiao <codingzx@gmail.com>", | ||
@@ -55,2 +55,2 @@ "main": "./index.cjs.js", | ||
} | ||
} | ||
} |
@@ -25,2 +25,2 @@ function _extends() { | ||
export { _extends as _, _object_without_properties_loose as a }; | ||
export { _object_without_properties_loose as _, _extends as a }; |
'use strict'; | ||
var polyfills = require('./polyfills.cjs.js'); | ||
var sdk = require('@module-federation/sdk'); | ||
var polyfills = require('./polyfills.cjs.js'); | ||
@@ -90,16 +90,2 @@ function getBuilderId() { | ||
} | ||
const processModuleAlias = (name, subPath)=>{ | ||
// @host/ ./button -> @host/button | ||
let moduleName; | ||
if (name.endsWith('/')) { | ||
moduleName = name.slice(0, -1); | ||
} else { | ||
moduleName = name; | ||
} | ||
if (subPath.startsWith('.')) { | ||
subPath = subPath.slice(1); | ||
} | ||
moduleName = moduleName + subPath; | ||
return moduleName; | ||
}; | ||
@@ -193,3 +179,3 @@ const nativeGlobal = (()=>{ | ||
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor; | ||
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.6"; | ||
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.10"; | ||
} | ||
@@ -294,212 +280,5 @@ } | ||
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 | ||
@@ -545,2 +324,9 @@ // those constants are based on https://www.rubydoc.info/gems/semantic_range/3.0.0/SemanticRange#BUILDIDENTIFIER-constant | ||
// fork from https://github.com/originjs/vite-plugin-federation/blob/v1.1.12/packages/lib/src/utils/semver/index.ts | ||
// Copyright (c) | ||
// vite-plugin-federation is licensed under Mulan PSL v2. | ||
// You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
// You may obtain a copy of Mulan PSL v2 at: | ||
// http://license.coscl.org.cn/MulanPSL2 | ||
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
// See the Mulan PSL v2 for more details. | ||
function parseRegex(source) { | ||
@@ -567,2 +353,9 @@ return new RegExp(source); | ||
// fork from https://github.com/originjs/vite-plugin-federation/blob/v1.1.12/packages/lib/src/utils/semver/index.ts | ||
// Copyright (c) | ||
// vite-plugin-federation is licensed under Mulan PSL v2. | ||
// You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
// You may obtain a copy of Mulan PSL v2 at: | ||
// http://license.coscl.org.cn/MulanPSL2 | ||
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
// See the Mulan PSL v2 for more details. | ||
function parseHyphen(range) { | ||
@@ -794,2 +587,9 @@ return range.replace(parseRegex(hyphenRange), (_range, from, fromMajor, fromMinor, fromPatch, _fromPreRelease, _fromBuild, to, toMajor, toMinor, toPatch, toPreRelease)=>{ | ||
// fork from https://github.com/originjs/vite-plugin-federation/blob/v1.1.12/packages/lib/src/utils/semver/index.ts | ||
// Copyright (c) | ||
// vite-plugin-federation is licensed under Mulan PSL v2. | ||
// You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
// You may obtain a copy of Mulan PSL v2 at: | ||
// http://license.coscl.org.cn/MulanPSL2 | ||
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
// See the Mulan PSL v2 for more details. | ||
function parseComparatorString(range) { | ||
@@ -1076,10 +876,5 @@ return pipe(// handle caret | ||
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; | ||
@@ -1107,8 +902,8 @@ exports.addUniqueItem = addUniqueItem; | ||
exports.globalLoading = globalLoading; | ||
exports.isObject = isObject; | ||
exports.isPlainObject = isPlainObject; | ||
exports.isPureRemoteEntry = isPureRemoteEntry; | ||
exports.isRemoteInfoWithEntry = isRemoteInfoWithEntry; | ||
exports.nativeGlobal = nativeGlobal; | ||
exports.processModuleAlias = processModuleAlias; | ||
exports.registerGlobalPlugins = registerGlobalPlugins; | ||
exports.registerPlugins = registerPlugins; | ||
exports.resetFederationGlobalInfo = resetFederationGlobalInfo; | ||
@@ -1119,1 +914,2 @@ exports.setGlobalFederationConstructor = setGlobalFederationConstructor; | ||
exports.setPreloaded = setPreloaded; | ||
exports.warn = warn; |
@@ -0,3 +1,3 @@ | ||
import { _ as _object_without_properties_loose, a as _extends } from './polyfills.esm.js'; | ||
import { isBrowserEnv, isDebugMode } from '@module-federation/sdk'; | ||
import { a as _object_without_properties_loose, _ as _extends } from './polyfills.esm.js'; | ||
@@ -88,16 +88,2 @@ function getBuilderId() { | ||
} | ||
const processModuleAlias = (name, subPath)=>{ | ||
// @host/ ./button -> @host/button | ||
let moduleName; | ||
if (name.endsWith('/')) { | ||
moduleName = name.slice(0, -1); | ||
} else { | ||
moduleName = name; | ||
} | ||
if (subPath.startsWith('.')) { | ||
subPath = subPath.slice(1); | ||
} | ||
moduleName = moduleName + subPath; | ||
return moduleName; | ||
}; | ||
@@ -191,3 +177,3 @@ const nativeGlobal = (()=>{ | ||
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor; | ||
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.6"; | ||
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.10"; | ||
} | ||
@@ -292,212 +278,5 @@ } | ||
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 | ||
@@ -543,2 +322,9 @@ // those constants are based on https://www.rubydoc.info/gems/semantic_range/3.0.0/SemanticRange#BUILDIDENTIFIER-constant | ||
// fork from https://github.com/originjs/vite-plugin-federation/blob/v1.1.12/packages/lib/src/utils/semver/index.ts | ||
// Copyright (c) | ||
// vite-plugin-federation is licensed under Mulan PSL v2. | ||
// You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
// You may obtain a copy of Mulan PSL v2 at: | ||
// http://license.coscl.org.cn/MulanPSL2 | ||
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
// See the Mulan PSL v2 for more details. | ||
function parseRegex(source) { | ||
@@ -565,2 +351,9 @@ return new RegExp(source); | ||
// fork from https://github.com/originjs/vite-plugin-federation/blob/v1.1.12/packages/lib/src/utils/semver/index.ts | ||
// Copyright (c) | ||
// vite-plugin-federation is licensed under Mulan PSL v2. | ||
// You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
// You may obtain a copy of Mulan PSL v2 at: | ||
// http://license.coscl.org.cn/MulanPSL2 | ||
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
// See the Mulan PSL v2 for more details. | ||
function parseHyphen(range) { | ||
@@ -792,2 +585,9 @@ return range.replace(parseRegex(hyphenRange), (_range, from, fromMajor, fromMinor, fromPatch, _fromPreRelease, _fromBuild, to, toMajor, toMinor, toPatch, toPreRelease)=>{ | ||
// fork from https://github.com/originjs/vite-plugin-federation/blob/v1.1.12/packages/lib/src/utils/semver/index.ts | ||
// Copyright (c) | ||
// vite-plugin-federation is licensed under Mulan PSL v2. | ||
// You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
// You may obtain a copy of Mulan PSL v2 at: | ||
// http://license.coscl.org.cn/MulanPSL2 | ||
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
// See the Mulan PSL v2 for more details. | ||
function parseComparatorString(range) { | ||
@@ -1074,2 +874,2 @@ return pipe(// handle caret | ||
export { AsyncHook as A, getBuilderId as B, setGlobalFederationConstructor as C, DEFAULT_REMOTE_TYPE as D, getGlobalFederationInstance as E, getGlobalFederationConstructor as F, Global as G, setGlobalFederationInstance as H, registerGlobalPlugins as I, nativeGlobal as J, resetFederationGlobalInfo as K, getTargetSnapshotInfoByModuleInfo as L, getGlobalHostPlugins as M, 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, getInfoWithoutType as j, getPreloaded as k, getRegisteredShare as l, arrayOptions as m, getGlobalSnapshotInfoByModuleInfo as n, addGlobalSnapshot as o, processModuleAlias as p, setGlobalSnapshotInfoByModuleInfo as q, AsyncWaterfallHook as r, setPreloaded as s, getGlobalSnapshot as t, formatShareConfigs as u, getTargetSharedOptions as v, getGlobalShareScope as w, addUniqueItem as x, SyncHook as y, registerPlugins as z }; | ||
export { isPlainObject as A, isRemoteInfoWithEntry as B, isPureRemoteEntry as C, DEFAULT_REMOTE_TYPE as D, getRemoteEntryInfoFromSnapshot as E, arrayOptions as F, Global as G, formatShareConfigs as H, getTargetSharedOptions as I, addUniqueItem as J, getBuilderId as K, getGlobalShareScope as a, getGlobalFederationInstance as b, getGlobalFederationConstructor as c, setGlobalFederationConstructor as d, getInfoWithoutType as e, getGlobalSnapshot as f, getRegisteredShare as g, getTargetSnapshotInfoByModuleInfo as h, getGlobalSnapshotInfoByModuleInfo as i, setGlobalSnapshotInfoByModuleInfo as j, addGlobalSnapshot as k, getRemoteEntryExports as l, registerGlobalPlugins as m, nativeGlobal as n, getGlobalHostPlugins as o, getPreloaded as p, setPreloaded as q, resetFederationGlobalInfo as r, setGlobalFederationInstance as s, globalLoading as t, DEFAULT_SCOPE as u, assert as v, getFMId as w, isObject as x, error as y, warn as z }; |
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 { | ||
@@ -28,4 +26,2 @@ getRegisteredShare: typeof getRegisteredShare; | ||
setPreloaded: typeof setPreloaded; | ||
registerPlugins: typeof registerPlugins; | ||
pluginHelper: typeof pluginHelper; | ||
} | ||
@@ -32,0 +28,0 @@ declare const _default: { |
@@ -35,7 +35,2 @@ import { GlobalModuleInfo, Manifest, ModuleInfo } from '@module-federation/sdk'; | ||
}>; | ||
afterLoadSnapshot: AsyncWaterfallHook<{ | ||
options: Options; | ||
moduleInfo: Remote; | ||
remoteSnapshot: ModuleInfo; | ||
}>; | ||
}>; | ||
@@ -42,0 +37,0 @@ loaderHook: FederationHost['loaderHook']; |
@@ -60,3 +60,3 @@ import { ModuleInfo, GlobalModuleInfo } from '@module-federation/sdk'; | ||
from: CallFrom; | ||
lifecycle: "onLoad" | "beforeRequest"; | ||
lifecycle: "onLoad" | "beforeRequest" | "beforeLoadShare"; | ||
origin: FederationHost; | ||
@@ -63,0 +63,0 @@ }], unknown>; |
@@ -7,3 +7,3 @@ import type { RemoteWithEntry, RemoteWithVersion, Module, RemoteEntryType } from '@module-federation/sdk'; | ||
}; | ||
export interface RemoteInfoCommon { | ||
interface RemoteInfoCommon { | ||
alias?: string; | ||
@@ -10,0 +10,0 @@ shareScope?: string; |
@@ -26,7 +26,6 @@ import { FederationHost } from '../core'; | ||
}>; | ||
type LifeCycle = CoreLifeCyclePartial & SnapshotLifeCycleCyclePartial & SharedLifeCycleCyclePartial & RemoteLifeCycleCyclePartial & ModuleLifeCycleCyclePartial & { | ||
export type FederationRuntimePlugin = CoreLifeCyclePartial & SnapshotLifeCycleCyclePartial & SharedLifeCycleCyclePartial & RemoteLifeCycleCyclePartial & ModuleLifeCycleCyclePartial & { | ||
name: string; | ||
version?: string; | ||
}; | ||
export type FederationRuntimePlugin<T = LifeCycle> = LifeCycle & T; | ||
export {}; |
import { FederationHost } from '../core'; | ||
import { UserOptions } from '../type'; | ||
import { Module } from '../module'; | ||
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; | ||
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; |
@@ -18,2 +18,1 @@ import { RemoteWithEntry, ModuleInfo, RemoteEntryType } from '@module-federation/sdk'; | ||
}; | ||
export declare const processModuleAlias: (name: string, subPath: string) => string; |
{ | ||
"name": "@module-federation/runtime", | ||
"version": "0.0.0-next-20241015065721", | ||
"version": "0.0.0-next-20241016062654", | ||
"author": "zhouxiao <codingzx@gmail.com>", | ||
@@ -53,4 +53,4 @@ "main": "./dist/index.cjs.js", | ||
"dependencies": { | ||
"@module-federation/sdk": "0.0.0-next-20241015065721" | ||
"@module-federation/sdk": "0.0.0-next-20241016062654" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
323825
62
6
7504
+ Added@module-federation/sdk@0.0.0-next-20241016062654(transitive)
- Removed@module-federation/sdk@0.0.0-next-20241015065721(transitive)