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
697
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-20240117093010 to 0.0.0-next-20240117121934

3

dist/helpers.cjs.js

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

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

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

5

dist/helpers.esm.js

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

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';
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';

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

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

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

@@ -179,51 +179,57 @@ 'use strict';

function getInfoWithoutType(target, key) {
return {
value: target[key],
key: key
};
}
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;
}
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;
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
};
}
return;
} else {
throw new Error('key must be string');
}
getGlobalSnapshotInfoByModuleInfo(moduleInfo) {
return this.getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo);
}
const getGlobalSnapshot = ()=>nativeGlobal.__FEDERATION__.moduleInfo;
const getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot)=>{
// Check if the remote is included in the hostSnapshot
const moduleKey = getFMId(moduleInfo);
const getModuleInfo = getInfoWithoutType(snapshot, moduleKey).value;
// The remoteSnapshot might not include a version
if (getModuleInfo && !getModuleInfo.version && 'version' in moduleInfo && moduleInfo['version']) {
getModuleInfo.version = moduleInfo['version'];
}
constructor(loaderHook){
this.loaderHook = loaderHook;
if (getModuleInfo) {
return getModuleInfo;
}
}
const getGlobalSnapshot = ()=>nativeGlobal.__FEDERATION__.moduleInfo;
// 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).value;
if ((getModuleInfoWithoutVersion == null ? void 0 : getModuleInfoWithoutVersion.version) === version) {
return getModuleInfoWithoutVersion;
}
}
return;
};
const getGlobalSnapshotInfoByModuleInfo = (moduleInfo)=>getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo);
const setGlobalSnapshotInfoByModuleInfo = (remoteInfo, moduleDetailInfo)=>{

@@ -788,3 +794,2 @@ const moduleKey = getFMId(remoteInfo);

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

@@ -803,5 +808,8 @@ 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;

@@ -808,0 +816,0 @@ exports.isBrowserEnv = isBrowserEnv;

@@ -177,51 +177,57 @@ function getBuilderId() {

function getInfoWithoutType(target, key) {
return {
value: target[key],
key: key
};
}
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;
}
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;
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
};
}
return;
} else {
throw new Error('key must be string');
}
getGlobalSnapshotInfoByModuleInfo(moduleInfo) {
return this.getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo);
}
const getGlobalSnapshot = ()=>nativeGlobal.__FEDERATION__.moduleInfo;
const getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot)=>{
// Check if the remote is included in the hostSnapshot
const moduleKey = getFMId(moduleInfo);
const getModuleInfo = getInfoWithoutType(snapshot, moduleKey).value;
// The remoteSnapshot might not include a version
if (getModuleInfo && !getModuleInfo.version && 'version' in moduleInfo && moduleInfo['version']) {
getModuleInfo.version = moduleInfo['version'];
}
constructor(loaderHook){
this.loaderHook = loaderHook;
if (getModuleInfo) {
return getModuleInfo;
}
}
const getGlobalSnapshot = ()=>nativeGlobal.__FEDERATION__.moduleInfo;
// 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).value;
if ((getModuleInfoWithoutVersion == null ? void 0 : getModuleInfoWithoutVersion.version) === version) {
return getModuleInfoWithoutVersion;
}
}
return;
};
const getGlobalSnapshotInfoByModuleInfo = (moduleInfo)=>getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo);
const setGlobalSnapshotInfoByModuleInfo = (remoteInfo, moduleDetailInfo)=>{

@@ -784,2 +790,2 @@ const moduleKey = getFMId(remoteInfo);

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 };
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 };

@@ -27,13 +27,9 @@ /// <reference types="node" />

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 function getInfoWithoutType<T extends object>(target: T, key: keyof T): {
value: T[keyof T] | undefined;
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 setGlobalSnapshotInfoByModuleInfo: (remoteInfo: Remote, moduleDetailInfo: GlobalModuleInfo[string]) => GlobalModuleInfo;

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

/// <reference types="node" />
import { resetFederationGlobalInfo, getGlobalFederationInstance, setGlobalFederationInstance, getGlobalFederationConstructor, setGlobalFederationConstructor, getGlobalSnapshot, setGlobalSnapshotInfoByModuleInfo, addGlobalSnapshot, getRemoteEntryExports, registerGlobalPlugins, getGlobalHostPlugins, getPreloaded, setPreloaded, Global } from './global';
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';

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

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

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

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

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

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

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

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

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

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

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