@module-federation/runtime
Advanced tools
Comparing version 0.0.0-canary-1702465394222 to 0.0.0-canary-1702467548140
@@ -6,3 +6,3 @@ 'use strict'; | ||
const ShareUtils = { | ||
getRegisteredShare: share.getRegisteredShare, | ||
getGlobalShare: share.getGlobalShare, | ||
getGlobalShareScope: share.getGlobalShareScope | ||
@@ -9,0 +9,0 @@ }; |
@@ -1,5 +0,5 @@ | ||
import { l as getRegisteredShare, t as getGlobalShareScope, F as nativeGlobal, H as resetFederationGlobalInfo, A as getGlobalFederationInstance, C as setGlobalFederationInstance, B as getGlobalFederationConstructor, z as setGlobalFederationConstructor, m as getInfoWithoutType, r as getGlobalSnapshot, I as getTargetSnapshotInfoByModuleInfo, p as getGlobalSnapshotInfoByModuleInfo, q as setGlobalSnapshotInfoByModuleInfo, J as addGlobalSnapshot, c as getRemoteEntryExports, E as registerGlobalPlugins, g as getGlobalHostPlugins, n as getPreloaded, o as setPreloaded } from './share.esm.js'; | ||
import { l as getGlobalShare, x as getGlobalShareScope, F as nativeGlobal, H as resetFederationGlobalInfo, A as getGlobalFederationInstance, C as setGlobalFederationInstance, B as getGlobalFederationConstructor, z as setGlobalFederationConstructor, m as getInfoWithoutType, r as getGlobalSnapshot, I as getTargetSnapshotInfoByModuleInfo, p as getGlobalSnapshotInfoByModuleInfo, q as setGlobalSnapshotInfoByModuleInfo, J as addGlobalSnapshot, c as getRemoteEntryExports, E as registerGlobalPlugins, g as getGlobalHostPlugins, n as getPreloaded, o as setPreloaded } from './share.esm.js'; | ||
const ShareUtils = { | ||
getRegisteredShare, | ||
getGlobalShare, | ||
getGlobalShareScope | ||
@@ -6,0 +6,0 @@ }; |
{ | ||
"name": "@module-federation/runtime", | ||
"version": "0.0.0-canary-1702465394222", | ||
"version": "0.0.0-canary-1702467548140", | ||
"author": "zhouxiao <codingzx@gmail.com>", | ||
@@ -37,6 +37,5 @@ "main": "./index.cjs.js", | ||
"dependencies": { | ||
"@module-federation/sdk": "0.0.0-canary-1702465394222", | ||
"semver": "7.5.4" | ||
"@module-federation/sdk": "0.0.0-canary-1702467548140" | ||
}, | ||
"peerDependencies": {} | ||
} |
@@ -91,3 +91,3 @@ 'use strict'; | ||
} | ||
var _nativeGlobal___FEDERATION__, _nativeGlobal___FEDERATION__1, _nativeGlobal___FEDERATION__2, _nativeGlobal___FEDERATION__3, _nativeGlobal___FEDERATION__4, _nativeGlobal___FEDERATION__5; | ||
var _nativeGlobal___FEDERATION__, _nativeGlobal___FEDERATION__1, _nativeGlobal___FEDERATION__2, _nativeGlobal___FEDERATION__3, _nativeGlobal___FEDERATION__4, _nativeGlobal___FEDERATION__5, _nativeGlobal___FEDERATION__6; | ||
// export const nativeGlobal: typeof global = new Function('return this')(); | ||
@@ -115,2 +115,3 @@ const nativeGlobal = new Function('return this')(); | ||
__MANIFEST_LOADING__: {}, | ||
__SHARE_SCOPE_LOADING__: {}, | ||
__PRELOADED_MAP__: new Map() | ||
@@ -130,4 +131,6 @@ }; | ||
(___MANIFEST_LOADING__ = (_nativeGlobal___FEDERATION__4 = nativeGlobal.__FEDERATION__).__MANIFEST_LOADING__) != null ? ___MANIFEST_LOADING__ : _nativeGlobal___FEDERATION__4.__MANIFEST_LOADING__ = {}; | ||
var ___SHARE_SCOPE_LOADING__; | ||
(___SHARE_SCOPE_LOADING__ = (_nativeGlobal___FEDERATION__5 = nativeGlobal.__FEDERATION__).__SHARE_SCOPE_LOADING__) != null ? ___SHARE_SCOPE_LOADING__ : _nativeGlobal___FEDERATION__5.__SHARE_SCOPE_LOADING__ = {}; | ||
var ___PRELOADED_MAP__; | ||
(___PRELOADED_MAP__ = (_nativeGlobal___FEDERATION__5 = nativeGlobal.__FEDERATION__).__PRELOADED_MAP__) != null ? ___PRELOADED_MAP__ : _nativeGlobal___FEDERATION__5.__PRELOADED_MAP__ = new Map(); | ||
(___PRELOADED_MAP__ = (_nativeGlobal___FEDERATION__6 = nativeGlobal.__FEDERATION__).__PRELOADED_MAP__) != null ? ___PRELOADED_MAP__ : _nativeGlobal___FEDERATION__6.__PRELOADED_MAP__ = new Map(); | ||
const Global = { | ||
@@ -145,2 +148,3 @@ get __FEDERATION__ () { | ||
nativeGlobal.__FEDERATION__.__MANIFEST_LOADING__ = {}; | ||
nativeGlobal.__FEDERATION__.__SHARE_SCOPE_LOADING__ = {}; | ||
} | ||
@@ -171,3 +175,3 @@ function getGlobalFederationInstance(name, version) { | ||
Global.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor; | ||
Global.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = '1.0.0-canary.5'; | ||
Global.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = '1.0.1-canary.1'; | ||
} | ||
@@ -629,3 +633,2 @@ } | ||
get, | ||
loaded: 'lib' in shareArgs ? true : undefined, | ||
scope: Array.isArray(shareArgs.scope) ? shareArgs.scope : [ | ||
@@ -647,15 +650,3 @@ 'default' | ||
function versionLt(a, b) { | ||
const transformInvalidVersion = (version)=>{ | ||
const isNumberVersion = !Number.isNaN(Number(version)); | ||
if (isNumberVersion) { | ||
const splitArr = version.split('.'); | ||
let validVersion = version; | ||
for(let i = 0; i < 3 - splitArr.length; i++){ | ||
validVersion += '.0'; | ||
} | ||
return validVersion; | ||
} | ||
return version; | ||
}; | ||
if (satisfy(transformInvalidVersion(a), `<=${transformInvalidVersion(b)}`)) { | ||
if (satisfy(a, `<=${b}`)) { | ||
return true; | ||
@@ -666,4 +657,5 @@ } else { | ||
} | ||
const findVersion = (shareScopeMap, scope, pkgName, cb)=>{ | ||
const versions = shareScopeMap[scope][pkgName]; | ||
const findVersion = (scope, pkgName, cb)=>{ | ||
const globalShares = Global.__FEDERATION__.__SHARE__; | ||
const versions = globalShares[scope][pkgName]; | ||
const callback = cb || function(prev, cur) { | ||
@@ -679,18 +671,16 @@ return versionLt(prev, cur); | ||
} | ||
// default version is '0' https://github.com/webpack/webpack/blob/main/lib/sharing/ProvideSharedModule.js#L136 | ||
if (prev === '0') { | ||
return cur; | ||
} | ||
return prev; | ||
}, 0); | ||
}; | ||
function findSingletonVersionOrderByVersion(shareScopeMap, scope, pkgName) { | ||
const versions = shareScopeMap[scope][pkgName]; | ||
function findSingletonVersionOrderByVersion(scope, pkgName) { | ||
const globalShares = Global.__FEDERATION__.__SHARE__; | ||
const versions = globalShares[scope][pkgName]; | ||
const callback = function(prev, cur) { | ||
return !versions[prev].loaded && versionLt(prev, cur); | ||
}; | ||
return findVersion(shareScopeMap, scope, pkgName, callback); | ||
return findVersion(scope, pkgName, callback); | ||
} | ||
function findSingletonVersionOrderByLoaded(shareScopeMap, scope, pkgName) { | ||
const versions = shareScopeMap[scope][pkgName]; | ||
function findSingletonVersionOrderByLoaded(scope, pkgName) { | ||
const globalShares = Global.__FEDERATION__.__SHARE__; | ||
const versions = globalShares[scope][pkgName]; | ||
const callback = function(prev, cur) { | ||
@@ -709,18 +699,8 @@ if (versions[cur].loaded) { | ||
}; | ||
return findVersion(shareScopeMap, scope, pkgName, callback); | ||
return findVersion(scope, pkgName, callback); | ||
} | ||
function getFindShareFunction(strategy) { | ||
if (strategy === 'loaded-first') { | ||
return findSingletonVersionOrderByLoaded; | ||
} | ||
return findSingletonVersionOrderByVersion; | ||
} | ||
// Details about shared resources | ||
// TODO: Implement strictVersion for alignment with module federation. | ||
function getRegisteredShare(instanceName, pkgName, shareInfo) { | ||
function getGlobalShare(pkgName, shareInfo) { | ||
const globalShares = Global.__FEDERATION__.__SHARE__; | ||
const localShareScopeMap = globalShares[instanceName]; | ||
if (!localShareScopeMap) { | ||
return; | ||
} | ||
const { shareConfig, scope = DEFAULT_SCOPE, strategy } = shareInfo; | ||
@@ -731,24 +711,24 @@ const scopes = Array.isArray(scope) ? scope : [ | ||
for (const sc of scopes){ | ||
if (shareConfig && localShareScopeMap[sc] && localShareScopeMap[sc][pkgName]) { | ||
if (shareConfig && globalShares[sc] && globalShares[sc][pkgName]) { | ||
const { requiredVersion } = shareConfig; | ||
// eslint-disable-next-line max-depth | ||
if (shareConfig.singleton) { | ||
const singletonVersion = getFindShareFunction(strategy)(localShareScopeMap, sc, pkgName); | ||
const singletonVersion = strategy === 'loaded-first' ? findSingletonVersionOrderByLoaded(sc, pkgName) : findSingletonVersionOrderByVersion(sc, pkgName); | ||
// eslint-disable-next-line max-depth | ||
if (typeof requiredVersion === 'string' && !satisfy(singletonVersion, requiredVersion)) { | ||
warn(`Version ${singletonVersion} from ${singletonVersion && localShareScopeMap[sc][pkgName][singletonVersion].from} of shared singleton module ${pkgName} does not satisfy the requirement of ${shareInfo.from} which needs ${requiredVersion})`); | ||
warn(`Version ${singletonVersion} from ${singletonVersion && globalShares[sc][pkgName][singletonVersion].from} of shared singleton module ${pkgName} does not satisfy the requirement of ${shareInfo.from} which needs ${requiredVersion})`); | ||
} | ||
return localShareScopeMap[sc][pkgName][singletonVersion]; | ||
return globalShares[sc][pkgName][singletonVersion]; | ||
} else { | ||
const maxVersion = getFindShareFunction(strategy)(localShareScopeMap, sc, pkgName); | ||
const maxVersion = findSingletonVersionOrderByLoaded(sc, pkgName); | ||
// eslint-disable-next-line max-depth | ||
if (requiredVersion === false || requiredVersion === '*') { | ||
return localShareScopeMap[sc][pkgName][maxVersion]; | ||
return globalShares[sc][pkgName][maxVersion]; | ||
} | ||
// eslint-disable-next-line max-depth | ||
if (satisfy(maxVersion, requiredVersion)) { | ||
return localShareScopeMap[sc][pkgName][maxVersion]; | ||
return globalShares[sc][pkgName][maxVersion]; | ||
} | ||
// eslint-disable-next-line max-depth | ||
for (const [versionKey, versionValue] of Object.entries(localShareScopeMap[sc][pkgName])){ | ||
for (const [versionKey, versionValue] of Object.entries(globalShares[sc][pkgName])){ | ||
// eslint-disable-next-line max-depth | ||
@@ -780,2 +760,3 @@ if (satisfy(versionKey, requiredVersion)) { | ||
exports.getGlobalHostPlugins = getGlobalHostPlugins; | ||
exports.getGlobalShare = getGlobalShare; | ||
exports.getGlobalShareScope = getGlobalShareScope; | ||
@@ -786,3 +767,2 @@ exports.getGlobalSnapshot = getGlobalSnapshot; | ||
exports.getPreloaded = getPreloaded; | ||
exports.getRegisteredShare = getRegisteredShare; | ||
exports.getRemoteEntryExports = getRemoteEntryExports; | ||
@@ -789,0 +769,0 @@ exports.getTargetSnapshotInfoByModuleInfo = getTargetSnapshotInfoByModuleInfo; |
@@ -89,3 +89,3 @@ function getBuilderId() { | ||
} | ||
var _nativeGlobal___FEDERATION__, _nativeGlobal___FEDERATION__1, _nativeGlobal___FEDERATION__2, _nativeGlobal___FEDERATION__3, _nativeGlobal___FEDERATION__4, _nativeGlobal___FEDERATION__5; | ||
var _nativeGlobal___FEDERATION__, _nativeGlobal___FEDERATION__1, _nativeGlobal___FEDERATION__2, _nativeGlobal___FEDERATION__3, _nativeGlobal___FEDERATION__4, _nativeGlobal___FEDERATION__5, _nativeGlobal___FEDERATION__6; | ||
// export const nativeGlobal: typeof global = new Function('return this')(); | ||
@@ -113,2 +113,3 @@ const nativeGlobal = new Function('return this')(); | ||
__MANIFEST_LOADING__: {}, | ||
__SHARE_SCOPE_LOADING__: {}, | ||
__PRELOADED_MAP__: new Map() | ||
@@ -128,4 +129,6 @@ }; | ||
(___MANIFEST_LOADING__ = (_nativeGlobal___FEDERATION__4 = nativeGlobal.__FEDERATION__).__MANIFEST_LOADING__) != null ? ___MANIFEST_LOADING__ : _nativeGlobal___FEDERATION__4.__MANIFEST_LOADING__ = {}; | ||
var ___SHARE_SCOPE_LOADING__; | ||
(___SHARE_SCOPE_LOADING__ = (_nativeGlobal___FEDERATION__5 = nativeGlobal.__FEDERATION__).__SHARE_SCOPE_LOADING__) != null ? ___SHARE_SCOPE_LOADING__ : _nativeGlobal___FEDERATION__5.__SHARE_SCOPE_LOADING__ = {}; | ||
var ___PRELOADED_MAP__; | ||
(___PRELOADED_MAP__ = (_nativeGlobal___FEDERATION__5 = nativeGlobal.__FEDERATION__).__PRELOADED_MAP__) != null ? ___PRELOADED_MAP__ : _nativeGlobal___FEDERATION__5.__PRELOADED_MAP__ = new Map(); | ||
(___PRELOADED_MAP__ = (_nativeGlobal___FEDERATION__6 = nativeGlobal.__FEDERATION__).__PRELOADED_MAP__) != null ? ___PRELOADED_MAP__ : _nativeGlobal___FEDERATION__6.__PRELOADED_MAP__ = new Map(); | ||
const Global = { | ||
@@ -143,2 +146,3 @@ get __FEDERATION__ () { | ||
nativeGlobal.__FEDERATION__.__MANIFEST_LOADING__ = {}; | ||
nativeGlobal.__FEDERATION__.__SHARE_SCOPE_LOADING__ = {}; | ||
} | ||
@@ -169,3 +173,3 @@ function getGlobalFederationInstance(name, version) { | ||
Global.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor; | ||
Global.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = '1.0.0-canary.5'; | ||
Global.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = '1.0.1-canary.1'; | ||
} | ||
@@ -627,3 +631,2 @@ } | ||
get, | ||
loaded: 'lib' in shareArgs ? true : undefined, | ||
scope: Array.isArray(shareArgs.scope) ? shareArgs.scope : [ | ||
@@ -645,15 +648,3 @@ 'default' | ||
function versionLt(a, b) { | ||
const transformInvalidVersion = (version)=>{ | ||
const isNumberVersion = !Number.isNaN(Number(version)); | ||
if (isNumberVersion) { | ||
const splitArr = version.split('.'); | ||
let validVersion = version; | ||
for(let i = 0; i < 3 - splitArr.length; i++){ | ||
validVersion += '.0'; | ||
} | ||
return validVersion; | ||
} | ||
return version; | ||
}; | ||
if (satisfy(transformInvalidVersion(a), `<=${transformInvalidVersion(b)}`)) { | ||
if (satisfy(a, `<=${b}`)) { | ||
return true; | ||
@@ -664,4 +655,5 @@ } else { | ||
} | ||
const findVersion = (shareScopeMap, scope, pkgName, cb)=>{ | ||
const versions = shareScopeMap[scope][pkgName]; | ||
const findVersion = (scope, pkgName, cb)=>{ | ||
const globalShares = Global.__FEDERATION__.__SHARE__; | ||
const versions = globalShares[scope][pkgName]; | ||
const callback = cb || function(prev, cur) { | ||
@@ -677,18 +669,16 @@ return versionLt(prev, cur); | ||
} | ||
// default version is '0' https://github.com/webpack/webpack/blob/main/lib/sharing/ProvideSharedModule.js#L136 | ||
if (prev === '0') { | ||
return cur; | ||
} | ||
return prev; | ||
}, 0); | ||
}; | ||
function findSingletonVersionOrderByVersion(shareScopeMap, scope, pkgName) { | ||
const versions = shareScopeMap[scope][pkgName]; | ||
function findSingletonVersionOrderByVersion(scope, pkgName) { | ||
const globalShares = Global.__FEDERATION__.__SHARE__; | ||
const versions = globalShares[scope][pkgName]; | ||
const callback = function(prev, cur) { | ||
return !versions[prev].loaded && versionLt(prev, cur); | ||
}; | ||
return findVersion(shareScopeMap, scope, pkgName, callback); | ||
return findVersion(scope, pkgName, callback); | ||
} | ||
function findSingletonVersionOrderByLoaded(shareScopeMap, scope, pkgName) { | ||
const versions = shareScopeMap[scope][pkgName]; | ||
function findSingletonVersionOrderByLoaded(scope, pkgName) { | ||
const globalShares = Global.__FEDERATION__.__SHARE__; | ||
const versions = globalShares[scope][pkgName]; | ||
const callback = function(prev, cur) { | ||
@@ -707,18 +697,8 @@ if (versions[cur].loaded) { | ||
}; | ||
return findVersion(shareScopeMap, scope, pkgName, callback); | ||
return findVersion(scope, pkgName, callback); | ||
} | ||
function getFindShareFunction(strategy) { | ||
if (strategy === 'loaded-first') { | ||
return findSingletonVersionOrderByLoaded; | ||
} | ||
return findSingletonVersionOrderByVersion; | ||
} | ||
// Details about shared resources | ||
// TODO: Implement strictVersion for alignment with module federation. | ||
function getRegisteredShare(instanceName, pkgName, shareInfo) { | ||
function getGlobalShare(pkgName, shareInfo) { | ||
const globalShares = Global.__FEDERATION__.__SHARE__; | ||
const localShareScopeMap = globalShares[instanceName]; | ||
if (!localShareScopeMap) { | ||
return; | ||
} | ||
const { shareConfig, scope = DEFAULT_SCOPE, strategy } = shareInfo; | ||
@@ -729,24 +709,24 @@ const scopes = Array.isArray(scope) ? scope : [ | ||
for (const sc of scopes){ | ||
if (shareConfig && localShareScopeMap[sc] && localShareScopeMap[sc][pkgName]) { | ||
if (shareConfig && globalShares[sc] && globalShares[sc][pkgName]) { | ||
const { requiredVersion } = shareConfig; | ||
// eslint-disable-next-line max-depth | ||
if (shareConfig.singleton) { | ||
const singletonVersion = getFindShareFunction(strategy)(localShareScopeMap, sc, pkgName); | ||
const singletonVersion = strategy === 'loaded-first' ? findSingletonVersionOrderByLoaded(sc, pkgName) : findSingletonVersionOrderByVersion(sc, pkgName); | ||
// eslint-disable-next-line max-depth | ||
if (typeof requiredVersion === 'string' && !satisfy(singletonVersion, requiredVersion)) { | ||
warn(`Version ${singletonVersion} from ${singletonVersion && localShareScopeMap[sc][pkgName][singletonVersion].from} of shared singleton module ${pkgName} does not satisfy the requirement of ${shareInfo.from} which needs ${requiredVersion})`); | ||
warn(`Version ${singletonVersion} from ${singletonVersion && globalShares[sc][pkgName][singletonVersion].from} of shared singleton module ${pkgName} does not satisfy the requirement of ${shareInfo.from} which needs ${requiredVersion})`); | ||
} | ||
return localShareScopeMap[sc][pkgName][singletonVersion]; | ||
return globalShares[sc][pkgName][singletonVersion]; | ||
} else { | ||
const maxVersion = getFindShareFunction(strategy)(localShareScopeMap, sc, pkgName); | ||
const maxVersion = findSingletonVersionOrderByLoaded(sc, pkgName); | ||
// eslint-disable-next-line max-depth | ||
if (requiredVersion === false || requiredVersion === '*') { | ||
return localShareScopeMap[sc][pkgName][maxVersion]; | ||
return globalShares[sc][pkgName][maxVersion]; | ||
} | ||
// eslint-disable-next-line max-depth | ||
if (satisfy(maxVersion, requiredVersion)) { | ||
return localShareScopeMap[sc][pkgName][maxVersion]; | ||
return globalShares[sc][pkgName][maxVersion]; | ||
} | ||
// eslint-disable-next-line max-depth | ||
for (const [versionKey, versionValue] of Object.entries(localShareScopeMap[sc][pkgName])){ | ||
for (const [versionKey, versionValue] of Object.entries(globalShares[sc][pkgName])){ | ||
// eslint-disable-next-line max-depth | ||
@@ -765,2 +745,2 @@ if (satisfy(versionKey, requiredVersion)) { | ||
export { getGlobalFederationInstance as A, getGlobalFederationConstructor as B, setGlobalFederationInstance as C, DEFAULT_REMOTE_TYPE as D, registerGlobalPlugins as E, nativeGlobal as F, Global as G, resetFederationGlobalInfo as H, getTargetSnapshotInfoByModuleInfo as I, addGlobalSnapshot as J, DEFAULT_SCOPE as a, globalLoading 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, getRegisteredShare as l, getInfoWithoutType as m, getPreloaded as n, setPreloaded as o, getGlobalSnapshotInfoByModuleInfo as p, setGlobalSnapshotInfoByModuleInfo as q, getGlobalSnapshot as r, safeToString as s, getGlobalShareScope as t, addUniqueItem as u, formatShareConfigs as v, warn as w, isBrowserEnv as x, getBuilderId as y, setGlobalFederationConstructor as z }; | ||
export { getGlobalFederationInstance as A, getGlobalFederationConstructor as B, setGlobalFederationInstance as C, DEFAULT_REMOTE_TYPE as D, registerGlobalPlugins as E, nativeGlobal as F, Global as G, resetFederationGlobalInfo as H, getTargetSnapshotInfoByModuleInfo as I, addGlobalSnapshot as J, DEFAULT_SCOPE as a, globalLoading 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, getGlobalShare as l, getInfoWithoutType as m, getPreloaded as n, setPreloaded as o, getGlobalSnapshotInfoByModuleInfo as p, setGlobalSnapshotInfoByModuleInfo as q, getGlobalSnapshot as r, safeToString as s, addUniqueItem as t, formatShareConfigs as u, isBrowserEnv as v, warn as w, getGlobalShareScope as x, getBuilderId as y, setGlobalFederationConstructor as z }; |
import type { ModuleInfo, GlobalModuleInfo } from '@module-federation/sdk'; | ||
import { Options, PreloadAssets, PreloadOptions, PreloadRemoteArgs, Remote, Shared, ShareInfos, UserOptions, RemoteInfo, ShareScopeMap } from './type'; | ||
import { Options, PreloadAssets, PreloadOptions, PreloadRemoteArgs, Remote, Shared, ShareInfos, UserOptions, RemoteInfo } from './type'; | ||
import { Module, ModuleOptions } from './module'; | ||
@@ -29,3 +29,3 @@ import { AsyncHook, AsyncWaterfallHook, PluginSystem, SyncHook, SyncWaterfallHook } from './utils/hooks'; | ||
}], void>; | ||
beforeLoadRemote: AsyncWaterfallHook<{ | ||
beforeRequest: AsyncWaterfallHook<{ | ||
id: string; | ||
@@ -35,4 +35,4 @@ options: Options; | ||
}>; | ||
loadRemoteMatch: AsyncWaterfallHook<LoadRemoteMatch>; | ||
loadRemote: AsyncHook<[{ | ||
afterResolve: AsyncWaterfallHook<LoadRemoteMatch>; | ||
onLoad: AsyncHook<[{ | ||
id: string; | ||
@@ -84,3 +84,2 @@ expose: string; | ||
}>; | ||
releaseNumber: string; | ||
version: string; | ||
@@ -102,5 +101,6 @@ name: string; | ||
}>; | ||
shareScopeMap: ShareScopeMap; | ||
loadingShare: { | ||
[key: string]: Promise<any>; | ||
}; | ||
constructor(userOptions: UserOptions); | ||
private _setGlobalShareScopeMap; | ||
initOptions(userOptions: UserOptions): Options; | ||
@@ -119,4 +119,3 @@ loadShare<T>(pkgName: string, customShareInfo?: Partial<Shared>): Promise<false | (() => T | undefined)>; | ||
*/ | ||
initializeSharing(shareScopeName?: string, strategy?: Shared['strategy']): Array<Promise<void>>; | ||
initShareScopeMap(scopeName: string, shareScope: ShareScopeMap[string]): void; | ||
initializeSharing(shareScopeName?: string): boolean | Promise<boolean>; | ||
private formatOptions; | ||
@@ -123,0 +122,0 @@ private registerPlugins; |
/// <reference types="node" /> | ||
import { FederationHost } from './core'; | ||
import { RemoteEntryExports, GlobalShareScopeMap, Remote, Optional } from './type'; | ||
import { RemoteEntryExports, GlobalShareScope, Remote, Optional } from './type'; | ||
import { GlobalModuleInfo, ModuleInfo } from '@module-federation/sdk'; | ||
@@ -12,4 +12,5 @@ import { FederationRuntimePlugin } from './type/plugin'; | ||
__INSTANCES__: Array<FederationHost>; | ||
__SHARE__: GlobalShareScopeMap; | ||
__SHARE__: GlobalShareScope; | ||
__MANIFEST_LOADING__: Record<string, Promise<ModuleInfo>>; | ||
__SHARE_SCOPE_LOADING__: Record<string, boolean | Promise<boolean>>; | ||
__PRELOADED_MAP__: Map<string, boolean>; | ||
@@ -16,0 +17,0 @@ } |
/// <reference types="node" /> | ||
import { resetFederationGlobalInfo, getGlobalFederationInstance, setGlobalFederationInstance, getGlobalFederationConstructor, setGlobalFederationConstructor, getInfoWithoutType, getGlobalSnapshot, getTargetSnapshotInfoByModuleInfo, getGlobalSnapshotInfoByModuleInfo, setGlobalSnapshotInfoByModuleInfo, addGlobalSnapshot, getRemoteEntryExports, registerGlobalPlugins, getGlobalHostPlugins, getPreloaded, setPreloaded } from './global'; | ||
import { getRegisteredShare, getGlobalShareScope } from './utils/share'; | ||
import { getGlobalShare, getGlobalShareScope } from './utils/share'; | ||
interface IShareUtils { | ||
getRegisteredShare: typeof getRegisteredShare; | ||
getGlobalShare: typeof getGlobalShare; | ||
getGlobalShareScope: typeof getGlobalShareScope; | ||
@@ -7,0 +7,0 @@ } |
@@ -5,3 +5,2 @@ import { FederationHost } from './core'; | ||
export { registerGlobalPlugins } from './global'; | ||
export { loadScript } from '@module-federation/sdk'; | ||
export type { Federation } from './global'; | ||
@@ -8,0 +7,0 @@ export declare function init(options: UserOptions): FederationHost; |
@@ -60,3 +60,3 @@ import type { RemoteWithEntry, RemoteWithVersion, Module, RemoteEntryType } from '@module-federation/sdk'; | ||
}; | ||
export type ShareScopeMap = { | ||
export type GlobalShareScope = { | ||
[scope: string]: { | ||
@@ -68,5 +68,2 @@ [pkgName: string]: { | ||
}; | ||
export type GlobalShareScopeMap = { | ||
[instanceName: string]: ShareScopeMap; | ||
}; | ||
export type ShareInfos = { | ||
@@ -97,4 +94,4 @@ [pkgName: string]: Shared; | ||
get: (id: string) => () => Promise<Module>; | ||
init: (shareScope: ShareScopeMap[string], initScope?: Array<Record<string, any>>, remoteEntryInitOPtions?: RemoteEntryInitOptions) => void; | ||
init: (shareScope: GlobalShareScope[string], initScope?: Array<Record<string, never>>, remoteEntryInitOPtions?: RemoteEntryInitOptions) => void; | ||
}; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
import { GlobalShareScopeMap, Shared, ShareArgs, ShareInfos } from '../type'; | ||
import { GlobalShareScope, Shared, ShareArgs, ShareInfos } from '../type'; | ||
export declare function formatShare(shareArgs: ShareArgs, from: string): Shared; | ||
@@ -6,3 +6,3 @@ export declare function formatShareConfigs(shareArgs: { | ||
}, from: string): ShareInfos; | ||
export declare function getRegisteredShare(instanceName: string, pkgName: string, shareInfo: ShareInfos[keyof ShareInfos]): Shared | void; | ||
export declare function getGlobalShareScope(): GlobalShareScopeMap; | ||
export declare function getGlobalShare(pkgName: string, shareInfo: ShareInfos[keyof ShareInfos]): Shared | void; | ||
export declare function getGlobalShareScope(): GlobalShareScope; |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
1
1
4
224659
5348
+ Added@module-federation/sdk@0.0.0-canary-1702467548140(transitive)
- Removedsemver@7.5.4
- Removed@module-federation/sdk@0.0.0-canary-1702465394222(transitive)
- Removedlru-cache@6.0.0(transitive)
- Removedsemver@7.5.4(transitive)
- Removedyallist@4.0.0(transitive)