@module-federation/runtime
Advanced tools
Comparing version 0.0.0-next-20240119073703 to 0.0.0-next-20240119085716
@@ -1,2 +0,2 @@ | ||
import { l as getRegisteredShare, u as getGlobalShareScope, G as Global, H as nativeGlobal, I as resetFederationGlobalInfo, B as getGlobalFederationInstance, E as setGlobalFederationInstance, C as getGlobalFederationConstructor, A as setGlobalFederationConstructor, m as getInfoWithoutType, t as getGlobalSnapshot, J as getTargetSnapshotInfoByModuleInfo, p as getGlobalSnapshotInfoByModuleInfo, r as setGlobalSnapshotInfoByModuleInfo, q as addGlobalSnapshot, c as getRemoteEntryExports, F as registerGlobalPlugins, g as getGlobalHostPlugins, n as getPreloaded, o as setPreloaded } from './share.esm.js'; | ||
import { l as getRegisteredShare, t as getGlobalShareScope, G as Global, 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, b as getRemoteEntryExports, E as registerGlobalPlugins, g as getGlobalHostPlugins, n as getPreloaded, o as setPreloaded } from './share.esm.js'; | ||
@@ -3,0 +3,0 @@ const ShareUtils = { |
{ | ||
"name": "@module-federation/runtime", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"author": "zhouxiao <codingzx@gmail.com>", | ||
@@ -5,0 +5,0 @@ "main": "./index.cjs.js", |
@@ -171,44 +171,25 @@ 'use strict'; | ||
} | ||
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) { | ||
if (isDebug) { | ||
function setGlobalFederationConstructor(FederationConstructor) { | ||
if (isDebugMode()) { | ||
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor; | ||
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.8"; | ||
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.9"; | ||
} | ||
} | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
function getInfoWithoutType(target, key) { | ||
if (typeof key === 'string') { | ||
const keyRes = target[key]; | ||
if (keyRes) { | ||
return { | ||
value: target[key], | ||
key: key | ||
}; | ||
} else { | ||
const targetKeys = Object.keys(target); | ||
for (let targetKey of targetKeys){ | ||
const [targetTypeOrName, _] = targetKey.split(':'); | ||
const nKey = `${targetTypeOrName}:${key}`; | ||
const typeWithKeyRes = target[nKey]; | ||
if (typeWithKeyRes) { | ||
return { | ||
value: typeWithKeyRes, | ||
key: nKey | ||
}; | ||
} | ||
} | ||
return { | ||
value: undefined, | ||
key: key | ||
}; | ||
} | ||
} else { | ||
throw new Error('key must be string'); | ||
function getInfoWithoutType(target, key, getModuleInfoHook) { | ||
let res = { | ||
value: target[key], | ||
key: key | ||
}; | ||
if (getModuleInfoHook) { | ||
const hookRes = getModuleInfoHook(target, key); | ||
res = hookRes || res; | ||
} | ||
return res; | ||
} | ||
const getGlobalSnapshot = ()=>nativeGlobal.__FEDERATION__.moduleInfo; | ||
const getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot)=>{ | ||
const getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot, getModuleInfoHook)=>{ | ||
// Check if the remote is included in the hostSnapshot | ||
const moduleKey = getFMId(moduleInfo); | ||
const getModuleInfo = getInfoWithoutType(snapshot, moduleKey).value; | ||
const getModuleInfo = getInfoWithoutType(snapshot, moduleKey, getModuleInfoHook).value; | ||
// The remoteSnapshot might not include a version | ||
@@ -227,3 +208,3 @@ if (getModuleInfo && !getModuleInfo.version && 'version' in moduleInfo && moduleInfo['version']) { | ||
const moduleKeyWithoutVersion = getFMId(resModuleInfo); | ||
const getModuleInfoWithoutVersion = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, moduleKeyWithoutVersion).value; | ||
const getModuleInfoWithoutVersion = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, moduleKeyWithoutVersion, getModuleInfoHook).value; | ||
if ((getModuleInfoWithoutVersion == null ? void 0 : getModuleInfoWithoutVersion.version) === version) { | ||
@@ -235,3 +216,3 @@ return getModuleInfoWithoutVersion; | ||
}; | ||
const getGlobalSnapshotInfoByModuleInfo = (moduleInfo)=>getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo); | ||
const getGlobalSnapshotInfoByModuleInfo = (moduleInfo, extraOptions)=>getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo, extraOptions == null ? void 0 : extraOptions.getModuleInfoHook); | ||
const setGlobalSnapshotInfoByModuleInfo = (remoteInfo, moduleDetailInfo)=>{ | ||
@@ -708,6 +689,9 @@ const moduleKey = getFMId(remoteInfo); | ||
}; | ||
const isLoaded = (shared)=>{ | ||
return Boolean(shared.loaded) || typeof shared.lib === 'function'; | ||
}; | ||
function findSingletonVersionOrderByVersion(shareScopeMap, scope, pkgName) { | ||
const versions = shareScopeMap[scope][pkgName]; | ||
const callback = function(prev, cur) { | ||
return !versions[prev].loaded && versionLt(prev, cur); | ||
return !isLoaded(versions[prev]) && versionLt(prev, cur); | ||
}; | ||
@@ -719,4 +703,4 @@ return findVersion(shareScopeMap, scope, pkgName, callback); | ||
const callback = function(prev, cur) { | ||
if (versions[cur].loaded) { | ||
if (versions[prev].loaded) { | ||
if (isLoaded(versions[cur])) { | ||
if (isLoaded(versions[prev])) { | ||
return Boolean(versionLt(prev, cur)); | ||
@@ -727,3 +711,3 @@ } else { | ||
} | ||
if (versions[prev].loaded) { | ||
if (isLoaded(versions[prev])) { | ||
return false; | ||
@@ -730,0 +714,0 @@ } |
@@ -169,44 +169,25 @@ function getBuilderId() { | ||
} | ||
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) { | ||
if (isDebug) { | ||
function setGlobalFederationConstructor(FederationConstructor) { | ||
if (isDebugMode()) { | ||
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor; | ||
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.8"; | ||
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.9"; | ||
} | ||
} | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
function getInfoWithoutType(target, key) { | ||
if (typeof key === 'string') { | ||
const keyRes = target[key]; | ||
if (keyRes) { | ||
return { | ||
value: target[key], | ||
key: key | ||
}; | ||
} else { | ||
const targetKeys = Object.keys(target); | ||
for (let targetKey of targetKeys){ | ||
const [targetTypeOrName, _] = targetKey.split(':'); | ||
const nKey = `${targetTypeOrName}:${key}`; | ||
const typeWithKeyRes = target[nKey]; | ||
if (typeWithKeyRes) { | ||
return { | ||
value: typeWithKeyRes, | ||
key: nKey | ||
}; | ||
} | ||
} | ||
return { | ||
value: undefined, | ||
key: key | ||
}; | ||
} | ||
} else { | ||
throw new Error('key must be string'); | ||
function getInfoWithoutType(target, key, getModuleInfoHook) { | ||
let res = { | ||
value: target[key], | ||
key: key | ||
}; | ||
if (getModuleInfoHook) { | ||
const hookRes = getModuleInfoHook(target, key); | ||
res = hookRes || res; | ||
} | ||
return res; | ||
} | ||
const getGlobalSnapshot = ()=>nativeGlobal.__FEDERATION__.moduleInfo; | ||
const getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot)=>{ | ||
const getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot, getModuleInfoHook)=>{ | ||
// Check if the remote is included in the hostSnapshot | ||
const moduleKey = getFMId(moduleInfo); | ||
const getModuleInfo = getInfoWithoutType(snapshot, moduleKey).value; | ||
const getModuleInfo = getInfoWithoutType(snapshot, moduleKey, getModuleInfoHook).value; | ||
// The remoteSnapshot might not include a version | ||
@@ -225,3 +206,3 @@ if (getModuleInfo && !getModuleInfo.version && 'version' in moduleInfo && moduleInfo['version']) { | ||
const moduleKeyWithoutVersion = getFMId(resModuleInfo); | ||
const getModuleInfoWithoutVersion = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, moduleKeyWithoutVersion).value; | ||
const getModuleInfoWithoutVersion = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, moduleKeyWithoutVersion, getModuleInfoHook).value; | ||
if ((getModuleInfoWithoutVersion == null ? void 0 : getModuleInfoWithoutVersion.version) === version) { | ||
@@ -233,3 +214,3 @@ return getModuleInfoWithoutVersion; | ||
}; | ||
const getGlobalSnapshotInfoByModuleInfo = (moduleInfo)=>getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo); | ||
const getGlobalSnapshotInfoByModuleInfo = (moduleInfo, extraOptions)=>getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo, extraOptions == null ? void 0 : extraOptions.getModuleInfoHook); | ||
const setGlobalSnapshotInfoByModuleInfo = (remoteInfo, moduleDetailInfo)=>{ | ||
@@ -706,6 +687,9 @@ const moduleKey = getFMId(remoteInfo); | ||
}; | ||
const isLoaded = (shared)=>{ | ||
return Boolean(shared.loaded) || typeof shared.lib === 'function'; | ||
}; | ||
function findSingletonVersionOrderByVersion(shareScopeMap, scope, pkgName) { | ||
const versions = shareScopeMap[scope][pkgName]; | ||
const callback = function(prev, cur) { | ||
return !versions[prev].loaded && versionLt(prev, cur); | ||
return !isLoaded(versions[prev]) && versionLt(prev, cur); | ||
}; | ||
@@ -717,4 +701,4 @@ return findVersion(shareScopeMap, scope, pkgName, callback); | ||
const callback = function(prev, cur) { | ||
if (versions[cur].loaded) { | ||
if (versions[prev].loaded) { | ||
if (isLoaded(versions[cur])) { | ||
if (isLoaded(versions[prev])) { | ||
return Boolean(versionLt(prev, cur)); | ||
@@ -725,3 +709,3 @@ } else { | ||
} | ||
if (versions[prev].loaded) { | ||
if (isLoaded(versions[prev])) { | ||
return false; | ||
@@ -795,2 +779,2 @@ } | ||
export { setGlobalFederationConstructor as A, getGlobalFederationInstance as B, getGlobalFederationConstructor as C, DEFAULT_REMOTE_TYPE as D, setGlobalFederationInstance as E, registerGlobalPlugins as F, Global as G, nativeGlobal as H, resetFederationGlobalInfo as I, getTargetSnapshotInfoByModuleInfo 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, addGlobalSnapshot as q, setGlobalSnapshotInfoByModuleInfo as r, safeToString as s, getGlobalSnapshot as t, getGlobalShareScope as u, formatShareConfigs as v, warn as w, isBrowserEnv as x, getBuilderId as y, addUniqueItem 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, globalLoading as a, getRemoteEntryExports as b, assert as c, DEFAULT_SCOPE 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, formatShareConfigs as u, isBrowserEnv as v, warn as w, getBuilderId as x, addUniqueItem as y, setGlobalFederationConstructor as z }; |
@@ -26,4 +26,7 @@ /// <reference types="node" /> | ||
export declare function getGlobalFederationConstructor(): typeof FederationHost | undefined; | ||
export declare function setGlobalFederationConstructor(FederationConstructor: typeof FederationHost | undefined, isDebug?: boolean): void; | ||
export declare function getInfoWithoutType<T extends object>(target: T, key: keyof T): { | ||
export declare function setGlobalFederationConstructor(FederationConstructor: typeof FederationHost): void; | ||
export declare function getInfoWithoutType<T extends object>(target: T, key: keyof T, getModuleInfoHook?: (target: any, key: string | number | symbol) => { | ||
value: any | undefined; | ||
key: string; | ||
} | void): { | ||
value: T[keyof T] | undefined; | ||
@@ -33,4 +36,12 @@ key: string; | ||
export declare const getGlobalSnapshot: () => GlobalModuleInfo; | ||
export declare const getTargetSnapshotInfoByModuleInfo: (moduleInfo: Optional<Remote, 'alias'>, snapshot: GlobalModuleInfo) => GlobalModuleInfo[string] | undefined; | ||
export declare const getGlobalSnapshotInfoByModuleInfo: (moduleInfo: Optional<Remote, 'alias'>) => GlobalModuleInfo[string] | undefined; | ||
export declare const getTargetSnapshotInfoByModuleInfo: (moduleInfo: Optional<Remote, 'alias'>, snapshot: GlobalModuleInfo, getModuleInfoHook?: ((target: any, key: string | number | symbol) => void | { | ||
value: any | undefined; | ||
key: string; | ||
}) | undefined) => GlobalModuleInfo[string] | undefined; | ||
export declare const getGlobalSnapshotInfoByModuleInfo: (moduleInfo: Optional<Remote, 'alias'>, extraOptions?: { | ||
getModuleInfoHook?: ((target: any, key: string | number | symbol) => void | { | ||
value: any | undefined; | ||
key: string; | ||
}) | undefined; | ||
} | undefined) => GlobalModuleInfo[string] | undefined; | ||
export declare const setGlobalSnapshotInfoByModuleInfo: (remoteInfo: Remote, moduleDetailInfo: GlobalModuleInfo[string]) => GlobalModuleInfo; | ||
@@ -37,0 +48,0 @@ export declare const addGlobalSnapshot: (moduleInfos: GlobalModuleInfo) => (() => void); |
@@ -5,2 +5,3 @@ import { FederationHost } from './core'; | ||
export { registerGlobalPlugins } from './global'; | ||
export { getRemoteEntry } from './utils'; | ||
export { loadScript } from '@module-federation/sdk'; | ||
@@ -7,0 +8,0 @@ export type { Federation } from './global'; |
@@ -41,8 +41,8 @@ import type { RemoteWithEntry, RemoteWithVersion, Module, RemoteEntryType } from '@module-federation/sdk'; | ||
}; | ||
export type SharedGetter = (() => () => Module) | (() => Promise<() => Module>); | ||
export type ShareArgs = (SharedBaseArgs & { | ||
get: SharedGetter; | ||
get: () => () => Module | Promise<() => Module>; | ||
}) | (SharedBaseArgs & { | ||
lib: () => Module; | ||
}); | ||
export type SharedGetter = () => () => Promise<() => Module> | Module; | ||
export type Shared = { | ||
@@ -49,0 +49,0 @@ version: string; |
@@ -6,1 +6,2 @@ export * from './env'; | ||
export * from './plugin'; | ||
export * from './load'; |
{ | ||
"name": "@module-federation/runtime", | ||
"version": "0.0.0-next-20240119073703", | ||
"version": "0.0.0-next-20240119085716", | ||
"author": "zhouxiao <codingzx@gmail.com>", | ||
@@ -48,4 +48,4 @@ "main": "./dist/index.cjs", | ||
"dependencies": { | ||
"@module-federation/sdk": "0.0.0-next-20240119073703" | ||
"@module-federation/sdk": "0.0.0-next-20240119085716" | ||
} | ||
} |
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
260240
5701
+ Added@module-federation/sdk@0.0.0-next-20240119085716(transitive)
- Removed@module-federation/sdk@0.0.0-next-20240119073703(transitive)