@module-federation/sdk
Advanced tools
Comparing version 0.0.0-next-20241104084202 to 0.0.0-next-20241104091124
'use strict'; | ||
var isomorphicRslog = require('isomorphic-rslog'); | ||
var polyfills = require('./polyfills.cjs.js'); | ||
@@ -61,2 +62,12 @@ | ||
} | ||
function isBrowserDebug() { | ||
try { | ||
if (isBrowserEnv() && window.localStorage) { | ||
return localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE; | ||
} | ||
} catch (error) { | ||
return false; | ||
} | ||
return false; | ||
} | ||
function isDebugMode() { | ||
@@ -66,3 +77,6 @@ if (typeof process !== 'undefined' && process.env && process.env['FEDERATION_DEBUG']) { | ||
} | ||
return typeof FEDERATION_DEBUG !== 'undefined' && Boolean(FEDERATION_DEBUG); | ||
if (typeof FEDERATION_DEBUG !== 'undefined' && Boolean(FEDERATION_DEBUG)) { | ||
return true; | ||
} | ||
return isBrowserDebug(); | ||
} | ||
@@ -73,52 +87,34 @@ const getProcessEnv = function() { | ||
const DEBUG_LOG = '[ FEDERATION DEBUG ]'; | ||
function safeToString$1(info) { | ||
try { | ||
return JSON.stringify(info, null, 2); | ||
} catch (e) { | ||
return ''; | ||
const PREFIX = '[ Module Federation ]'; | ||
function setDebug(loggerInstance) { | ||
if (isDebugMode()) { | ||
loggerInstance.level = 'verbose'; | ||
} | ||
} | ||
function safeGetLocalStorageItem() { | ||
try { | ||
if (typeof window !== 'undefined' && window.localStorage) { | ||
return localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE; | ||
function setPrefix(loggerInstance, prefix) { | ||
loggerInstance.labels = { | ||
warn: `${prefix} Warn`, | ||
error: `${prefix} Error`, | ||
success: `${prefix} Success`, | ||
info: `${prefix} Info`, | ||
ready: `${prefix} Ready`, | ||
debug: `${prefix} Debug` | ||
}; | ||
} | ||
function createLogger(prefix) { | ||
const loggerInstance = isomorphicRslog.createLogger({ | ||
labels: { | ||
warn: `${PREFIX} Warn`, | ||
error: `${PREFIX} Error`, | ||
success: `${PREFIX} Success`, | ||
info: `${PREFIX} Info`, | ||
ready: `${PREFIX} Ready`, | ||
debug: `${PREFIX} Debug` | ||
} | ||
} catch (error) { | ||
return typeof document !== 'undefined'; | ||
} | ||
return false; | ||
}); | ||
setDebug(loggerInstance); | ||
setPrefix(loggerInstance, prefix); | ||
return loggerInstance; | ||
} | ||
let Logger = class Logger { | ||
info(msg, info) { | ||
if (this.enable) { | ||
const argsToString = safeToString$1(info) || ''; | ||
if (isBrowserEnv()) { | ||
console.info(`%c ${this.identifier}: ${msg} ${argsToString}`, 'color:#3300CC'); | ||
} else { | ||
console.info('\x1b[34m%s', `${this.identifier}: ${msg} ${argsToString ? `\n${argsToString}` : ''}`); | ||
} | ||
} | ||
} | ||
logOriginalInfo(...args) { | ||
if (this.enable) { | ||
if (isBrowserEnv()) { | ||
console.info(`%c ${this.identifier}: OriginalInfo`, 'color:#3300CC'); | ||
console.log(...args); | ||
} else { | ||
console.info(`%c ${this.identifier}: OriginalInfo`, 'color:#3300CC'); | ||
console.log(...args); | ||
} | ||
} | ||
} | ||
constructor(identifier){ | ||
this.enable = false; | ||
this.identifier = identifier || DEBUG_LOG; | ||
if (isBrowserEnv() && safeGetLocalStorageItem()) { | ||
this.enable = true; | ||
} else if (isDebugMode()) { | ||
this.enable = true; | ||
} | ||
} | ||
}; | ||
const logger = createLogger(PREFIX); | ||
@@ -172,3 +168,2 @@ const LOG_CATEGORY = '[ Federation Runtime ]'; | ||
}; | ||
const logger = new Logger(); | ||
const composeKeyWithSeparator = function(...args) { | ||
@@ -767,3 +762,2 @@ if (!args.length) { | ||
exports.FederationModuleManifest = FederationModuleManifest; | ||
exports.Logger = Logger; | ||
exports.MANIFEST_EXT = MANIFEST_EXT; | ||
@@ -784,2 +778,3 @@ exports.MFModuleType = MFModuleType; | ||
exports.createLink = createLink; | ||
exports.createLogger = createLogger; | ||
exports.createScript = createScript; | ||
@@ -786,0 +781,0 @@ exports.createScriptNode = createScriptNode; |
@@ -0,1 +1,2 @@ | ||
import { createLogger as createLogger$1 } from 'isomorphic-rslog'; | ||
import { _ as _extends } from './polyfills.esm.js'; | ||
@@ -59,2 +60,12 @@ | ||
} | ||
function isBrowserDebug() { | ||
try { | ||
if (isBrowserEnv() && window.localStorage) { | ||
return localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE; | ||
} | ||
} catch (error) { | ||
return false; | ||
} | ||
return false; | ||
} | ||
function isDebugMode() { | ||
@@ -64,3 +75,6 @@ if (typeof process !== 'undefined' && process.env && process.env['FEDERATION_DEBUG']) { | ||
} | ||
return typeof FEDERATION_DEBUG !== 'undefined' && Boolean(FEDERATION_DEBUG); | ||
if (typeof FEDERATION_DEBUG !== 'undefined' && Boolean(FEDERATION_DEBUG)) { | ||
return true; | ||
} | ||
return isBrowserDebug(); | ||
} | ||
@@ -71,52 +85,34 @@ const getProcessEnv = function() { | ||
const DEBUG_LOG = '[ FEDERATION DEBUG ]'; | ||
function safeToString$1(info) { | ||
try { | ||
return JSON.stringify(info, null, 2); | ||
} catch (e) { | ||
return ''; | ||
const PREFIX = '[ Module Federation ]'; | ||
function setDebug(loggerInstance) { | ||
if (isDebugMode()) { | ||
loggerInstance.level = 'verbose'; | ||
} | ||
} | ||
function safeGetLocalStorageItem() { | ||
try { | ||
if (typeof window !== 'undefined' && window.localStorage) { | ||
return localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE; | ||
function setPrefix(loggerInstance, prefix) { | ||
loggerInstance.labels = { | ||
warn: `${prefix} Warn`, | ||
error: `${prefix} Error`, | ||
success: `${prefix} Success`, | ||
info: `${prefix} Info`, | ||
ready: `${prefix} Ready`, | ||
debug: `${prefix} Debug` | ||
}; | ||
} | ||
function createLogger(prefix) { | ||
const loggerInstance = createLogger$1({ | ||
labels: { | ||
warn: `${PREFIX} Warn`, | ||
error: `${PREFIX} Error`, | ||
success: `${PREFIX} Success`, | ||
info: `${PREFIX} Info`, | ||
ready: `${PREFIX} Ready`, | ||
debug: `${PREFIX} Debug` | ||
} | ||
} catch (error) { | ||
return typeof document !== 'undefined'; | ||
} | ||
return false; | ||
}); | ||
setDebug(loggerInstance); | ||
setPrefix(loggerInstance, prefix); | ||
return loggerInstance; | ||
} | ||
let Logger = class Logger { | ||
info(msg, info) { | ||
if (this.enable) { | ||
const argsToString = safeToString$1(info) || ''; | ||
if (isBrowserEnv()) { | ||
console.info(`%c ${this.identifier}: ${msg} ${argsToString}`, 'color:#3300CC'); | ||
} else { | ||
console.info('\x1b[34m%s', `${this.identifier}: ${msg} ${argsToString ? `\n${argsToString}` : ''}`); | ||
} | ||
} | ||
} | ||
logOriginalInfo(...args) { | ||
if (this.enable) { | ||
if (isBrowserEnv()) { | ||
console.info(`%c ${this.identifier}: OriginalInfo`, 'color:#3300CC'); | ||
console.log(...args); | ||
} else { | ||
console.info(`%c ${this.identifier}: OriginalInfo`, 'color:#3300CC'); | ||
console.log(...args); | ||
} | ||
} | ||
} | ||
constructor(identifier){ | ||
this.enable = false; | ||
this.identifier = identifier || DEBUG_LOG; | ||
if (isBrowserEnv() && safeGetLocalStorageItem()) { | ||
this.enable = true; | ||
} else if (isDebugMode()) { | ||
this.enable = true; | ||
} | ||
} | ||
}; | ||
const logger = createLogger(PREFIX); | ||
@@ -170,3 +166,2 @@ const LOG_CATEGORY = '[ Federation Runtime ]'; | ||
}; | ||
const logger = new Logger(); | ||
const composeKeyWithSeparator = function(...args) { | ||
@@ -760,2 +755,2 @@ if (!args.length) { | ||
export { BROWSER_LOG_KEY, BROWSER_LOG_VALUE, ENCODE_NAME_PREFIX, EncodedNameTransformMap, FederationModuleManifest, Logger, MANIFEST_EXT, MFModuleType, MFPrefetchCommon, MODULE_DEVTOOL_IDENTIFIER, ManifestFileName, NameTransformMap, NameTransformSymbol, SEPARATOR, StatsFileName, TEMP_DIR, assert, composeKeyWithSeparator, ContainerPlugin as containerPlugin, ContainerReferencePlugin as containerReferencePlugin, createLink, createScript, createScriptNode, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, generateSnapshotFromManifest, getProcessEnv, getResourceUrl, inferAutoPublicPath, isBrowserEnv, isDebugMode, isManifestProvider, isRequiredVersion, isStaticResourcesEqual, loadScript, loadScriptNode, logger, ModuleFederationPlugin as moduleFederationPlugin, normalizeOptions, parseEntry, safeToString, safeWrapper, SharePlugin as sharePlugin, simpleJoinRemoteEntry, warn }; | ||
export { BROWSER_LOG_KEY, BROWSER_LOG_VALUE, ENCODE_NAME_PREFIX, EncodedNameTransformMap, FederationModuleManifest, MANIFEST_EXT, MFModuleType, MFPrefetchCommon, MODULE_DEVTOOL_IDENTIFIER, ManifestFileName, NameTransformMap, NameTransformSymbol, SEPARATOR, StatsFileName, TEMP_DIR, assert, composeKeyWithSeparator, ContainerPlugin as containerPlugin, ContainerReferencePlugin as containerReferencePlugin, createLink, createLogger, createScript, createScriptNode, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, generateSnapshotFromManifest, getProcessEnv, getResourceUrl, inferAutoPublicPath, isBrowserEnv, isDebugMode, isManifestProvider, isRequiredVersion, isStaticResourcesEqual, loadScript, loadScriptNode, logger, ModuleFederationPlugin as moduleFederationPlugin, normalizeOptions, parseEntry, safeToString, safeWrapper, SharePlugin as sharePlugin, simpleJoinRemoteEntry, warn }; |
{ | ||
"name": "@module-federation/sdk", | ||
"version": "0.6.11", | ||
"version": "0.6.15", | ||
"license": "MIT", | ||
@@ -43,3 +43,6 @@ "description": "A sdk for support module federation", | ||
} | ||
}, | ||
"dependencies": { | ||
"isomorphic-rslog": "0.0.5" | ||
} | ||
} |
@@ -1,8 +0,5 @@ | ||
declare class Logger { | ||
enable: boolean; | ||
identifier: string; | ||
constructor(identifier?: string); | ||
info(msg: string, info?: any): void; | ||
logOriginalInfo(...args: unknown[]): void; | ||
} | ||
export { Logger }; | ||
import { type Logger } from 'isomorphic-rslog'; | ||
declare function createLogger(prefix: string): Logger; | ||
declare const logger: Logger; | ||
export { logger, createLogger }; | ||
export type { Logger }; |
import { RemoteEntryInfo, ModuleInfo } from './types'; | ||
import { Logger } from './logger'; | ||
import { logger } from './logger'; | ||
declare const parseEntry: (str: string, devVerOrUrl?: string, separator?: string) => RemoteEntryInfo; | ||
@@ -7,3 +7,2 @@ declare global { | ||
} | ||
declare const logger: Logger; | ||
declare const composeKeyWithSeparator: (...args: (string | undefined)[]) => string; | ||
@@ -10,0 +9,0 @@ declare const encodeName: (name: string, prefix?: string, withExt?: boolean) => string; |
{ | ||
"name": "@module-federation/sdk", | ||
"version": "0.0.0-next-20241104084202", | ||
"version": "0.0.0-next-20241104091124", | ||
"license": "MIT", | ||
@@ -43,3 +43,6 @@ "description": "A sdk for support module federation", | ||
} | ||
}, | ||
"dependencies": { | ||
"isomorphic-rslog": "0.0.5" | ||
} | ||
} |
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
104532
1
2618
+ Addedisomorphic-rslog@0.0.5
+ Addedisomorphic-rslog@0.0.5(transitive)