New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@module-federation/runtime

Package Overview
Dependencies
Maintainers
8
Versions
728
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-20240115064607 to 0.0.0-next-20240117093010

3

dist/helpers.cjs.js

@@ -17,6 +17,3 @@ 'use strict';

setGlobalFederationConstructor: share.setGlobalFederationConstructor,
getInfoWithoutType: share.getInfoWithoutType,
getGlobalSnapshot: share.getGlobalSnapshot,
getTargetSnapshotInfoByModuleInfo: share.getTargetSnapshotInfoByModuleInfo,
getGlobalSnapshotInfoByModuleInfo: share.getGlobalSnapshotInfoByModuleInfo,
setGlobalSnapshotInfoByModuleInfo: share.setGlobalSnapshotInfoByModuleInfo,

@@ -23,0 +20,0 @@ addGlobalSnapshot: share.addGlobalSnapshot,

5

dist/helpers.esm.js

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

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, c as getRemoteEntryExports, E as registerGlobalPlugins, g as getGlobalHostPlugins, n as getPreloaded, o as setPreloaded } from './share.esm.js';
import { n 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, q as getGlobalSnapshot, p as setGlobalSnapshotInfoByModuleInfo, o as addGlobalSnapshot, c as getRemoteEntryExports, E as registerGlobalPlugins, g as getGlobalHostPlugins, l as getPreloaded, m as setPreloaded } from './share.esm.js';

@@ -15,6 +15,3 @@ const ShareUtils = {

setGlobalFederationConstructor,
getInfoWithoutType,
getGlobalSnapshot,
getTargetSnapshotInfoByModuleInfo,
getGlobalSnapshotInfoByModuleInfo,
setGlobalSnapshotInfoByModuleInfo,

@@ -21,0 +18,0 @@ addGlobalSnapshot,

@@ -171,4 +171,4 @@ 'use strict';

}
function setGlobalFederationConstructor(FederationConstructor) {
if (isDebugMode()) {
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
if (isDebug) {
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;

@@ -179,39 +179,52 @@ globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.8";

// eslint-disable-next-line @typescript-eslint/ban-types
function getInfoWithoutType(target, key, getModuleInfoHook) {
let res = {
function getInfoWithoutType(target, key) {
return {
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, getModuleInfoHook)=>{
// Check if the remote is included in the hostSnapshot
const moduleKey = getFMId(moduleInfo);
const getModuleInfo = getInfoWithoutType(snapshot, moduleKey, getModuleInfoHook).value;
// The remoteSnapshot might not include a version
if (getModuleInfo && !getModuleInfo.version && 'version' in moduleInfo && moduleInfo['version']) {
getModuleInfo.version = moduleInfo['version'];
class GetSnapshotInfoWithHook {
getInfoWithoutTypeWithHook(target, key) {
let res = getInfoWithoutType(target, key);
const hookRes = this.loaderHook.lifecycle.getModuleInfo.emit({
target,
key
});
if (hookRes && !(hookRes instanceof Promise)) {
res = hookRes || res;
}
return res;
}
if (getModuleInfo) {
return getModuleInfo;
}
// If the remote is not included in the hostSnapshot, deploy a micro app snapshot
if ('version' in moduleInfo && moduleInfo['version']) {
const { version } = moduleInfo, resModuleInfo = _object_without_properties_loose(moduleInfo, [
"version"
]);
const moduleKeyWithoutVersion = getFMId(resModuleInfo);
const getModuleInfoWithoutVersion = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, moduleKeyWithoutVersion, getModuleInfoHook).value;
if ((getModuleInfoWithoutVersion == null ? void 0 : getModuleInfoWithoutVersion.version) === version) {
return getModuleInfoWithoutVersion;
getTargetSnapshotInfoByModuleInfo(moduleInfo, snapshot) {
// Check if the remote is included in the hostSnapshot
const moduleKey = getFMId(moduleInfo);
const getModuleInfo = this.getInfoWithoutTypeWithHook(snapshot, moduleKey).value;
// The remoteSnapshot might not include a version
if (getModuleInfo && !getModuleInfo.version && 'version' in moduleInfo && moduleInfo['version']) {
getModuleInfo.version = moduleInfo['version'];
}
if (getModuleInfo) {
return getModuleInfo;
}
// If the remote is not included in the hostSnapshot, deploy a micro app snapshot
if ('version' in moduleInfo && moduleInfo['version']) {
const { version } = moduleInfo, resModuleInfo = _object_without_properties_loose(moduleInfo, [
"version"
]);
const moduleKeyWithoutVersion = getFMId(resModuleInfo);
const getModuleInfoWithoutVersion = this.getInfoWithoutTypeWithHook(nativeGlobal.__FEDERATION__.moduleInfo, moduleKeyWithoutVersion).value;
if ((getModuleInfoWithoutVersion == null ? void 0 : getModuleInfoWithoutVersion.version) === version) {
return getModuleInfoWithoutVersion;
}
}
return;
}
return;
};
const getGlobalSnapshotInfoByModuleInfo = (moduleInfo, extraOptions)=>getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo, extraOptions == null ? void 0 : extraOptions.getModuleInfoHook);
getGlobalSnapshotInfoByModuleInfo(moduleInfo) {
return this.getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo);
}
constructor(loaderHook){
this.loaderHook = loaderHook;
}
}
const getGlobalSnapshot = ()=>nativeGlobal.__FEDERATION__.moduleInfo;
const setGlobalSnapshotInfoByModuleInfo = (remoteInfo, moduleDetailInfo)=>{

@@ -688,9 +701,6 @@ 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 !isLoaded(versions[prev]) && versionLt(prev, cur);
return !versions[prev].loaded && versionLt(prev, cur);
};

@@ -702,4 +712,4 @@ return findVersion(shareScopeMap, scope, pkgName, callback);

const callback = function(prev, cur) {
if (isLoaded(versions[cur])) {
if (isLoaded(versions[prev])) {
if (versions[cur].loaded) {
if (versions[prev].loaded) {
return Boolean(versionLt(prev, cur));

@@ -710,3 +720,3 @@ } else {

}
if (isLoaded(versions[prev])) {
if (versions[prev].loaded) {
return false;

@@ -782,2 +792,3 @@ }

exports.DEFAULT_SCOPE = DEFAULT_SCOPE;
exports.GetSnapshotInfoWithHook = GetSnapshotInfoWithHook;
exports.Global = Global;

@@ -796,8 +807,5 @@ exports.addGlobalSnapshot = addGlobalSnapshot;

exports.getGlobalSnapshot = getGlobalSnapshot;
exports.getGlobalSnapshotInfoByModuleInfo = getGlobalSnapshotInfoByModuleInfo;
exports.getInfoWithoutType = getInfoWithoutType;
exports.getPreloaded = getPreloaded;
exports.getRegisteredShare = getRegisteredShare;
exports.getRemoteEntryExports = getRemoteEntryExports;
exports.getTargetSnapshotInfoByModuleInfo = getTargetSnapshotInfoByModuleInfo;
exports.globalLoading = globalLoading;

@@ -804,0 +812,0 @@ exports.isBrowserEnv = isBrowserEnv;

@@ -169,4 +169,4 @@ function getBuilderId() {

}
function setGlobalFederationConstructor(FederationConstructor) {
if (isDebugMode()) {
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
if (isDebug) {
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;

@@ -177,39 +177,52 @@ globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.8";

// eslint-disable-next-line @typescript-eslint/ban-types
function getInfoWithoutType(target, key, getModuleInfoHook) {
let res = {
function getInfoWithoutType(target, key) {
return {
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, getModuleInfoHook)=>{
// Check if the remote is included in the hostSnapshot
const moduleKey = getFMId(moduleInfo);
const getModuleInfo = getInfoWithoutType(snapshot, moduleKey, getModuleInfoHook).value;
// The remoteSnapshot might not include a version
if (getModuleInfo && !getModuleInfo.version && 'version' in moduleInfo && moduleInfo['version']) {
getModuleInfo.version = moduleInfo['version'];
class GetSnapshotInfoWithHook {
getInfoWithoutTypeWithHook(target, key) {
let res = getInfoWithoutType(target, key);
const hookRes = this.loaderHook.lifecycle.getModuleInfo.emit({
target,
key
});
if (hookRes && !(hookRes instanceof Promise)) {
res = hookRes || res;
}
return res;
}
if (getModuleInfo) {
return getModuleInfo;
}
// If the remote is not included in the hostSnapshot, deploy a micro app snapshot
if ('version' in moduleInfo && moduleInfo['version']) {
const { version } = moduleInfo, resModuleInfo = _object_without_properties_loose(moduleInfo, [
"version"
]);
const moduleKeyWithoutVersion = getFMId(resModuleInfo);
const getModuleInfoWithoutVersion = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, moduleKeyWithoutVersion, getModuleInfoHook).value;
if ((getModuleInfoWithoutVersion == null ? void 0 : getModuleInfoWithoutVersion.version) === version) {
return getModuleInfoWithoutVersion;
getTargetSnapshotInfoByModuleInfo(moduleInfo, snapshot) {
// Check if the remote is included in the hostSnapshot
const moduleKey = getFMId(moduleInfo);
const getModuleInfo = this.getInfoWithoutTypeWithHook(snapshot, moduleKey).value;
// The remoteSnapshot might not include a version
if (getModuleInfo && !getModuleInfo.version && 'version' in moduleInfo && moduleInfo['version']) {
getModuleInfo.version = moduleInfo['version'];
}
if (getModuleInfo) {
return getModuleInfo;
}
// If the remote is not included in the hostSnapshot, deploy a micro app snapshot
if ('version' in moduleInfo && moduleInfo['version']) {
const { version } = moduleInfo, resModuleInfo = _object_without_properties_loose(moduleInfo, [
"version"
]);
const moduleKeyWithoutVersion = getFMId(resModuleInfo);
const getModuleInfoWithoutVersion = this.getInfoWithoutTypeWithHook(nativeGlobal.__FEDERATION__.moduleInfo, moduleKeyWithoutVersion).value;
if ((getModuleInfoWithoutVersion == null ? void 0 : getModuleInfoWithoutVersion.version) === version) {
return getModuleInfoWithoutVersion;
}
}
return;
}
return;
};
const getGlobalSnapshotInfoByModuleInfo = (moduleInfo, extraOptions)=>getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo, extraOptions == null ? void 0 : extraOptions.getModuleInfoHook);
getGlobalSnapshotInfoByModuleInfo(moduleInfo) {
return this.getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo);
}
constructor(loaderHook){
this.loaderHook = loaderHook;
}
}
const getGlobalSnapshot = ()=>nativeGlobal.__FEDERATION__.moduleInfo;
const setGlobalSnapshotInfoByModuleInfo = (remoteInfo, moduleDetailInfo)=>{

@@ -686,9 +699,6 @@ 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 !isLoaded(versions[prev]) && versionLt(prev, cur);
return !versions[prev].loaded && versionLt(prev, cur);
};

@@ -700,4 +710,4 @@ return findVersion(shareScopeMap, scope, pkgName, callback);

const callback = function(prev, cur) {
if (isLoaded(versions[cur])) {
if (isLoaded(versions[prev])) {
if (versions[cur].loaded) {
if (versions[prev].loaded) {
return Boolean(versionLt(prev, cur));

@@ -708,3 +718,3 @@ } else {

}
if (isLoaded(versions[prev])) {
if (versions[prev].loaded) {
return false;

@@ -778,2 +788,2 @@ }

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, formatShareConfigs as u, isBrowserEnv as v, warn as w, getBuilderId as x, addUniqueItem 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, 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, getPreloaded as l, setPreloaded as m, getRegisteredShare as n, addGlobalSnapshot as o, setGlobalSnapshotInfoByModuleInfo as p, getGlobalSnapshot as q, GetSnapshotInfoWithHook 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,21 +26,14 @@ /// <reference types="node" />

export declare function getGlobalFederationConstructor(): typeof FederationHost | undefined;
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;
key: string;
};
export declare function setGlobalFederationConstructor(FederationConstructor: typeof FederationHost | undefined, isDebug?: boolean): void;
export declare class GetSnapshotInfoWithHook {
loaderHook: FederationHost['loaderHook'];
constructor(loaderHook: FederationHost['loaderHook']);
getInfoWithoutTypeWithHook<T extends object>(target: T, key: keyof T): {
value: T[keyof T] | undefined;
key: string;
};
getTargetSnapshotInfoByModuleInfo(moduleInfo: Optional<Remote, 'alias'>, snapshot: GlobalModuleInfo): import("@module-federation/sdk").PureConsumerModuleInfo | import("@module-federation/sdk").ManifestProvider | undefined;
getGlobalSnapshotInfoByModuleInfo(moduleInfo: Optional<Remote, 'alias'>): import("@module-federation/sdk").PureConsumerModuleInfo | import("@module-federation/sdk").ManifestProvider | undefined;
}
export declare const getGlobalSnapshot: () => GlobalModuleInfo;
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;

@@ -47,0 +40,0 @@ export declare const addGlobalSnapshot: (moduleInfos: GlobalModuleInfo) => (() => void);

/// <reference types="node" />
import { resetFederationGlobalInfo, getGlobalFederationInstance, setGlobalFederationInstance, getGlobalFederationConstructor, setGlobalFederationConstructor, getInfoWithoutType, getGlobalSnapshot, getTargetSnapshotInfoByModuleInfo, getGlobalSnapshotInfoByModuleInfo, setGlobalSnapshotInfoByModuleInfo, addGlobalSnapshot, getRemoteEntryExports, registerGlobalPlugins, getGlobalHostPlugins, getPreloaded, setPreloaded, Global } from './global';
import { resetFederationGlobalInfo, getGlobalFederationInstance, setGlobalFederationInstance, getGlobalFederationConstructor, setGlobalFederationConstructor, getGlobalSnapshot, setGlobalSnapshotInfoByModuleInfo, addGlobalSnapshot, getRemoteEntryExports, registerGlobalPlugins, getGlobalHostPlugins, getPreloaded, setPreloaded, Global } from './global';
import { getRegisteredShare, getGlobalShareScope } from './utils/share';

@@ -16,6 +16,3 @@ interface IShareUtils {

setGlobalFederationConstructor: typeof setGlobalFederationConstructor;
getInfoWithoutType: typeof getInfoWithoutType;
getGlobalSnapshot: typeof getGlobalSnapshot;
getTargetSnapshotInfoByModuleInfo: typeof getTargetSnapshotInfoByModuleInfo;
getGlobalSnapshotInfoByModuleInfo: typeof getGlobalSnapshotInfoByModuleInfo;
setGlobalSnapshotInfoByModuleInfo: typeof setGlobalSnapshotInfoByModuleInfo;

@@ -22,0 +19,0 @@ addGlobalSnapshot: typeof addGlobalSnapshot;

import { GlobalModuleInfo, Manifest, ModuleInfo } from '@module-federation/sdk';
import { Options, Remote } from '../../type';
import { getGlobalSnapshot } from '../../global';
import { getGlobalSnapshot, GetSnapshotInfoWithHook } from '../../global';
import { PluginSystem, AsyncHook, AsyncWaterfallHook } from '../../utils/hooks';

@@ -33,2 +33,3 @@ import { FederationHost } from '../../core';

manifestLoading: Record<string, Promise<ModuleInfo>>;
getSnapshotInfoHandler: GetSnapshotInfoWithHook;
constructor(HostInstance: FederationHost);

@@ -35,0 +36,0 @@ loadSnapshot(moduleInfo: Remote): Promise<{

@@ -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: () => () => Module | Promise<() => Module>;
get: SharedGetter;
}) | (SharedBaseArgs & {
lib: () => Module;
});
export type SharedGetter = () => () => Promise<() => Module> | Module;
export type Shared = {

@@ -49,0 +49,0 @@ version: string;

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

@@ -48,4 +48,4 @@ "main": "./dist/index.cjs",

"dependencies": {
"@module-federation/sdk": "0.0.0-next-20240115064607"
"@module-federation/sdk": "0.0.0-next-20240117093010"
}
}

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