@memberjunction/react-runtime 2.97.0 → 2.99.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +26 -0
- package/dist/compiler/component-compiler.d.ts.map +1 -1
- package/dist/compiler/component-compiler.js +49 -7
- package/dist/compiler/component-compiler.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime.umd.js +1 -1
- package/dist/utilities/component-unwrapper.d.ts +7 -0
- package/dist/utilities/component-unwrapper.d.ts.map +1 -0
- package/dist/utilities/component-unwrapper.js +369 -0
- package/dist/utilities/component-unwrapper.js.map +1 -0
- package/dist/utilities/index.d.ts +1 -0
- package/dist/utilities/index.d.ts.map +1 -1
- package/dist/utilities/index.js +1 -0
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/library-loader.d.ts.map +1 -1
- package/dist/utilities/library-loader.js +16 -0
- package/dist/utilities/library-loader.js.map +1 -1
- package/package.json +5 -5
- package/src/compiler/component-compiler.ts +87 -22
- package/src/index.ts +10 -0
- package/src/utilities/component-unwrapper.ts +481 -0
- package/src/utilities/index.ts +2 -1
- package/src/utilities/library-loader.ts +22 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library-loader.js","sourceRoot":"","sources":["../../src/utilities/library-loader.ts"],"names":[],"mappings":";;;AAMA,6DAG8B;AAE9B,qDAAiF;AACjF,yDAAqD;AAErD,+EAA0E;AAK1E,MAAM,2BAA2B,GAAG,2CAA2C,CAAC;AAsChF,MAAa,aAAa;IAYxB,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC3B,MAA6B,EAC7B,mBAA6C,EAC7C,OAA6B;QAE7B,IAAI,MAAM,EAAE,CAAC;YACX,2CAAsB,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;QAClD,CAAC;QAG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OAAO,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;YACzC,CAAC;YAED,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,CAAC,GAAG,CAAC,aAAa,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC;YAC/D,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAMD,MAAM,CAAC,sBAAsB;QAC3B,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAC3C,CAAC;IAOD,MAAM,CAAC,eAAe,CAAC,WAAmB;QACxC,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACnD,CAAC;IAOD,MAAM,CAAC,uBAAuB,CAAC,WAAmB;QAChD,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC5D,CAAC;;AA9mBH,sCA+mBC;AA9mBgB,6BAAe,GAAG,IAAI,GAAG,EAA0B,CAAC;AACpD,iCAAmB,GAAG,IAAI,GAAG,EAA8B,CAAC;AAC5D,gCAAkB,GAAG,IAAI,uDAAyB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC","sourcesContent":["/**\n * @fileoverview Library loading utilities for React runtime\n * Provides methods to load and manage external JavaScript libraries and CSS\n * @module @memberjunction/react-runtime/utilities\n */\n\nimport { \n StandardLibraries,\n StandardLibraryManager\n} from './standard-libraries';\nimport { LibraryConfiguration, ExternalLibraryConfig, LibraryLoadOptions as ConfigLoadOptions } from '../types/library-config';\nimport { getCoreRuntimeLibraries, isCoreRuntimeLibrary } from './core-libraries';\nimport { resourceManager } from './resource-manager';\nimport { ComponentLibraryEntity } from '@memberjunction/core-entities';\nimport { LibraryDependencyResolver } from './library-dependency-resolver';\nimport { LoadedLibraryState, DependencyResolutionOptions } from '../types/dependency-types';\nimport { LibraryRegistry } from './library-registry';\n\n// Unique component ID for resource tracking\nconst LIBRARY_LOADER_COMPONENT_ID = 'mj-react-runtime-library-loader-singleton';\n\n/**\n * Represents a loaded script or CSS resource\n */\ninterface LoadedResource {\n element: HTMLScriptElement | HTMLLinkElement;\n promise: Promise<any>;\n}\n\n/**\n * Options for loading libraries\n * @deprecated Use LibraryLoadOptions from library-config instead\n */\nexport interface LibraryLoadOptions {\n /** Load core libraries (lodash, d3, Chart.js, dayjs) */\n loadCore?: boolean;\n /** Load UI libraries (antd, React Bootstrap) */\n loadUI?: boolean;\n /** Load CSS files for UI libraries */\n loadCSS?: boolean;\n /** Custom library URLs to load */\n customLibraries?: { url: string; globalName: string }[];\n}\n\n/**\n * Result of loading libraries\n */\nexport interface LibraryLoadResult {\n React: any;\n ReactDOM: any;\n Babel: any;\n libraries: StandardLibraries;\n}\n\n/**\n * Library loader class for managing external script loading\n */\nexport class LibraryLoader {\n private static loadedResources = new Map<string, LoadedResource>();\n private static loadedLibraryStates = new Map<string, LoadedLibraryState>();\n private static dependencyResolver = new LibraryDependencyResolver({ debug: false });\n\n /**\n * Load all standard libraries (core + UI + CSS)\n * This is the main method that should be used by test harness and Angular wrapper\n * @param config Optional full library configuration to replace the default\n * @param additionalLibraries Optional additional libraries to merge with the configuration\n * @param options Optional options including debug mode flag\n */\n static async loadAllLibraries(\n config?: LibraryConfiguration, \n additionalLibraries?: ExternalLibraryConfig[],\n options?: { debug?: boolean }\n ): Promise<LibraryLoadResult> {\n if (config) {\n StandardLibraryManager.setConfiguration(config);\n }\n \n // If additional libraries are provided, merge them with the current configuration\n if (additionalLibraries && additionalLibraries.length > 0) {\n const currentConfig = StandardLibraryManager.getConfiguration();\n const mergedConfig: LibraryConfiguration = {\n libraries: [...currentConfig.libraries, ...additionalLibraries],\n metadata: {\n ...currentConfig.metadata,\n lastUpdated: new Date().toISOString()\n }\n };\n StandardLibraryManager.setConfiguration(mergedConfig);\n }\n \n return this.loadLibrariesFromConfig(undefined, options?.debug);\n }\n\n /**\n * Load libraries based on the current configuration\n */\n static async loadLibrariesFromConfig(options?: ConfigLoadOptions, debug?: boolean): Promise<LibraryLoadResult> {\n // Always load core runtime libraries first\n const coreLibraries = getCoreRuntimeLibraries(debug);\n const corePromises = coreLibraries.map(lib => \n this.loadScript(lib.cdnUrl, lib.globalVariable, debug)\n );\n \n const coreResults = await Promise.all(corePromises);\n const React = coreResults.find((_, i) => coreLibraries[i].globalVariable === 'React');\n const ReactDOM = coreResults.find((_, i) => coreLibraries[i].globalVariable === 'ReactDOM');\n const Babel = coreResults.find((_, i) => coreLibraries[i].globalVariable === 'Babel');\n \n // Expose React and ReactDOM as globals for UMD libraries that expect them\n // Many React component libraries (Recharts, Victory, etc.) expect these as globals\n if (typeof window !== 'undefined') {\n if (React && !(window as any).React) {\n (window as any).React = React;\n console.log('✓ Exposed React as window.React for UMD compatibility');\n }\n if (ReactDOM && !(window as any).ReactDOM) {\n (window as any).ReactDOM = ReactDOM;\n console.log('✓ Exposed ReactDOM as window.ReactDOM for UMD compatibility');\n }\n // Also expose PropTypes as empty object if not present (for older libraries)\n if (!(window as any).PropTypes) {\n (window as any).PropTypes = {};\n console.log('✓ Exposed empty PropTypes as window.PropTypes for UMD compatibility');\n }\n }\n \n // Now load plugin libraries from configuration\n const config = StandardLibraryManager.getConfiguration();\n const enabledLibraries = StandardLibraryManager.getEnabledLibraries();\n \n // Filter out any core runtime libraries from plugin configuration\n let pluginLibraries = enabledLibraries.filter(lib => !isCoreRuntimeLibrary(lib.id));\n \n // Apply options filters if provided\n if (options) {\n if (options.categories) {\n pluginLibraries = pluginLibraries.filter(lib => \n options.categories!.includes(lib.category)\n );\n }\n if (options.excludeRuntimeOnly) {\n pluginLibraries = pluginLibraries.filter(lib => !lib.isRuntimeOnly);\n }\n }\n \n // Load CSS files for plugin libraries (non-blocking)\n pluginLibraries.forEach(lib => {\n if (lib.cdnCssUrl) {\n this.loadCSS(lib.cdnCssUrl);\n }\n });\n \n // Load plugin libraries\n const pluginPromises = pluginLibraries.map(lib => \n this.loadScript(lib.cdnUrl, lib.globalVariable, debug)\n );\n \n const pluginResults = await Promise.all(pluginPromises);\n \n // Build libraries object (only contains plugin libraries)\n const libraries: StandardLibraries = {};\n \n pluginLibraries.forEach((lib, index) => {\n libraries[lib.globalVariable] = pluginResults[index];\n });\n \n return {\n React: React || (window as any).React,\n ReactDOM: ReactDOM || (window as any).ReactDOM,\n Babel: Babel || (window as any).Babel,\n libraries\n };\n }\n\n /**\n * Load libraries with specific options (backward compatibility)\n * @deprecated Use loadLibrariesFromConfig instead\n */\n static async loadLibraries(options: LibraryLoadOptions): Promise<LibraryLoadResult> {\n const {\n loadCore = true,\n loadUI = true,\n loadCSS = true,\n customLibraries = []\n } = options;\n\n // Map old options to new configuration approach\n const categoriesToLoad: Array<ExternalLibraryConfig['category']> = ['runtime'];\n if (loadCore) {\n categoriesToLoad.push('utility', 'charting');\n }\n if (loadUI) {\n categoriesToLoad.push('ui');\n }\n \n const result = await this.loadLibrariesFromConfig({\n categories: categoriesToLoad\n });\n \n // Load custom libraries if provided\n if (customLibraries.length > 0) {\n const customPromises = customLibraries.map(({ url, globalName }) =>\n this.loadScript(url, globalName)\n );\n \n const customResults = await Promise.all(customPromises);\n customLibraries.forEach(({ globalName }, index) => {\n result.libraries[globalName] = customResults[index];\n });\n }\n \n return result;\n }\n\n /**\n * Load a script from URL\n */\n private static async loadScript(url: string, globalName: string, debug: boolean = false): Promise<any> {\n // Check if already loaded\n const existing = this.loadedResources.get(url);\n if (existing) {\n if (debug) {\n console.log(`✅ Library '${globalName}' already loaded (cached)`);\n }\n return existing.promise;\n }\n\n const promise = new Promise((resolve, reject) => {\n // Check if global already exists\n const existingGlobal = (window as any)[globalName];\n if (existingGlobal) {\n if (debug) {\n console.log(`✅ Library '${globalName}' already available globally`);\n }\n resolve(existingGlobal);\n return;\n }\n\n // Check if script tag exists\n const existingScript = document.querySelector(`script[src=\"${url}\"]`);\n if (existingScript) {\n this.waitForScriptLoad(existingScript as HTMLScriptElement, globalName, resolve, reject);\n return;\n }\n\n // Create new script\n const script = document.createElement('script');\n script.src = url;\n script.async = true;\n script.crossOrigin = 'anonymous';\n\n const cleanup = () => {\n script.removeEventListener('load', onLoad);\n script.removeEventListener('error', onError);\n };\n\n const onLoad = () => {\n cleanup();\n const global = (window as any)[globalName];\n if (global) {\n if (debug) {\n console.log(`✅ Library '${globalName}' loaded successfully from ${url}`);\n }\n resolve(global);\n } else {\n // Some libraries may take a moment to initialize\n const timeoutId = resourceManager.setTimeout(\n LIBRARY_LOADER_COMPONENT_ID,\n () => {\n const delayedGlobal = (window as any)[globalName];\n if (delayedGlobal) {\n if (debug) {\n console.log(`✅ Library '${globalName}' loaded successfully (delayed initialization)`);\n }\n resolve(delayedGlobal);\n } else {\n reject(new Error(`${globalName} not found after script load`));\n }\n },\n 100,\n { url, globalName }\n );\n }\n };\n\n const onError = () => {\n cleanup();\n reject(new Error(`Failed to load script: ${url}`));\n };\n\n script.addEventListener('load', onLoad);\n script.addEventListener('error', onError);\n\n if (debug) {\n console.log(`📦 Loading library '${globalName}' from ${url}...`);\n }\n document.head.appendChild(script);\n \n // Register the script element for cleanup\n resourceManager.registerDOMElement(LIBRARY_LOADER_COMPONENT_ID, script);\n });\n\n this.loadedResources.set(url, { \n element: document.querySelector(`script[src=\"${url}\"]`)!, \n promise \n });\n\n return promise;\n }\n\n /**\n * Load CSS from URL\n */\n private static loadCSS(url: string): void {\n if (this.loadedResources.has(url)) {\n return;\n }\n\n const existingLink = document.querySelector(`link[href=\"${url}\"]`);\n if (existingLink) {\n return;\n }\n\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = url;\n document.head.appendChild(link);\n \n // Register the link element for cleanup\n resourceManager.registerDOMElement(LIBRARY_LOADER_COMPONENT_ID, link);\n\n this.loadedResources.set(url, {\n element: link,\n promise: Promise.resolve()\n });\n }\n\n /**\n * Wait for existing script to load\n */\n private static waitForScriptLoad(\n script: HTMLScriptElement,\n globalName: string,\n resolve: (value: any) => void,\n reject: (reason: any) => void\n ): void {\n const checkGlobal = () => {\n const global = (window as any)[globalName];\n if (global) {\n resolve(global);\n } else {\n // Retry after a short delay\n resourceManager.setTimeout(\n LIBRARY_LOADER_COMPONENT_ID,\n () => {\n const delayedGlobal = (window as any)[globalName];\n if (delayedGlobal) {\n resolve(delayedGlobal);\n } else {\n reject(new Error(`${globalName} not found after script load`));\n }\n },\n 100,\n { context: 'waitForScriptLoad', globalName }\n );\n }\n };\n\n // Check if already loaded\n if ((script as any).complete || (script as any).readyState === 'complete') {\n checkGlobal();\n return;\n }\n\n // Wait for load\n const loadHandler = () => {\n checkGlobal();\n };\n resourceManager.addEventListener(\n LIBRARY_LOADER_COMPONENT_ID,\n script,\n 'load',\n loadHandler,\n { once: true }\n );\n }\n\n\n /**\n * Get all loaded resources (for cleanup)\n */\n static getLoadedResources(): Map<string, LoadedResource> {\n return this.loadedResources;\n }\n\n /**\n * Clear loaded resources cache and cleanup DOM elements\n */\n static clearCache(): void {\n // Remove all script and link elements we added\n this.loadedResources.forEach((resource, url) => {\n if (resource.element && resource.element.parentNode) {\n resource.element.parentNode.removeChild(resource.element);\n }\n });\n \n this.loadedResources.clear();\n this.loadedLibraryStates.clear();\n \n // Clean up any resources managed by resource manager\n resourceManager.cleanupComponent(LIBRARY_LOADER_COMPONENT_ID);\n }\n\n /**\n * Load a library with its dependencies\n * @param libraryName - Name of the library to load\n * @param allLibraries - All available libraries for dependency resolution\n * @param requestedBy - Name of the component/library requesting this load\n * @param options - Dependency resolution options\n * @returns Promise resolving to the loaded library global object\n */\n static async loadLibraryWithDependencies(\n libraryName: string,\n allLibraries: ComponentLibraryEntity[],\n requestedBy: string = 'user',\n options?: DependencyResolutionOptions\n ): Promise<any> {\n const debug = options?.debug || false;\n \n if (debug) {\n console.log(`📚 Loading library '${libraryName}' with dependencies`);\n }\n\n // Check if already loaded\n const existingState = this.loadedLibraryStates.get(libraryName);\n if (existingState) {\n if (debug) {\n console.log(`✅ Library '${libraryName}' already loaded (version: ${existingState.version})`);\n }\n // Track who requested it\n if (!existingState.requestedBy.includes(requestedBy)) {\n existingState.requestedBy.push(requestedBy);\n }\n return (window as any)[existingState.globalVariable];\n }\n\n // Get load order including dependencies\n const loadOrderResult = this.dependencyResolver.getLoadOrder(\n [libraryName],\n allLibraries,\n options\n );\n\n if (!loadOrderResult.success) {\n const errors = loadOrderResult.errors?.join(', ') || 'Unknown error';\n throw new Error(`Failed to resolve dependencies for '${libraryName}': ${errors}`);\n }\n\n if (loadOrderResult.warnings && debug) {\n console.warn(`⚠️ Warnings for '${libraryName}':`, loadOrderResult.warnings);\n }\n\n const loadOrder = loadOrderResult.order || [];\n if (debug) {\n console.log(`📋 Load order for '${libraryName}':`, loadOrder.map(lib => `${lib.Name}@${lib.Version}`));\n }\n\n // Load libraries in order\n for (const library of loadOrder) {\n // Skip if already loaded\n if (this.loadedLibraryStates.has(library.Name)) {\n if (debug) {\n console.log(`⏭️ Skipping '${library.Name}' (already loaded)`);\n }\n continue;\n }\n\n if (debug) {\n console.log(`📥 Loading '${library.Name}@${library.Version}'`);\n }\n\n // Load the library\n if (!library.CDNUrl || !library.GlobalVariable) {\n throw new Error(`Library '${library.Name}' missing CDN URL or global variable`);\n }\n\n // Load CSS if available\n if (library.CDNCssUrl) {\n const cssUrls = library.CDNCssUrl.split(',').map(url => url.trim());\n for (const cssUrl of cssUrls) {\n if (cssUrl) {\n this.loadCSS(cssUrl);\n }\n }\n }\n\n // Load the script\n const loadedGlobal = await this.loadScript(library.CDNUrl, library.GlobalVariable, debug);\n\n // Track the loaded state\n const dependencies = Array.from(\n this.dependencyResolver.getDirectDependencies(library).keys()\n );\n\n this.loadedLibraryStates.set(library.Name, {\n name: library.Name,\n version: library.Version || 'unknown',\n globalVariable: library.GlobalVariable,\n loadedAt: new Date(),\n requestedBy: library.Name === libraryName ? [requestedBy] : [],\n dependencies\n });\n\n if (debug) {\n console.log(`✅ Loaded '${library.Name}@${library.Version}'`);\n }\n }\n\n // Return the originally requested library's global\n const targetLibrary = loadOrder.find(lib => lib.Name === libraryName);\n if (!targetLibrary || !targetLibrary.GlobalVariable) {\n throw new Error(`Failed to load library '${libraryName}'`);\n }\n\n return (window as any)[targetLibrary.GlobalVariable];\n }\n\n /**\n * Load multiple libraries with dependency resolution\n * @param libraryNames - Names of libraries to load\n * @param allLibraries - All available libraries for dependency resolution\n * @param requestedBy - Name of the component requesting these libraries\n * @param options - Dependency resolution options\n * @returns Map of library names to their loaded global objects\n */\n static async loadLibrariesWithDependencies(\n libraryNames: string[],\n allLibraries: ComponentLibraryEntity[],\n requestedBy: string = 'user',\n options?: DependencyResolutionOptions\n ): Promise<Map<string, any>> {\n const debug = options?.debug || false;\n const result = new Map<string, any>();\n \n if (debug) {\n console.log(`📚 Loading libraries with dependencies:`, libraryNames);\n console.log(` 📦 Total available libraries: ${allLibraries.length}`);\n console.log(` 📋 Available library list:`, allLibraries.map(l => `${l.Name}@${l.Version}`));\n }\n\n // Get combined load order for all requested libraries\n const loadOrderResult = this.dependencyResolver.getLoadOrder(\n libraryNames,\n allLibraries,\n options\n );\n\n if (!loadOrderResult.success) {\n const errors = loadOrderResult.errors?.join(', ') || 'Unknown error';\n throw new Error(`Failed to resolve dependencies: ${errors}`);\n }\n\n if (debug) {\n console.log(` 📊 Dependency resolution result:`, {\n success: loadOrderResult.success,\n errors: loadOrderResult.errors || [],\n warnings: loadOrderResult.warnings || []\n });\n \n if (loadOrderResult.order) {\n console.log(` 🔄 Resolved dependencies for each library:`);\n loadOrderResult.order.forEach(lib => {\n const deps = this.dependencyResolver.parseDependencies(lib.Dependencies);\n if (deps.size > 0) {\n console.log(` • ${lib.Name}@${lib.Version} requires:`, Array.from(deps.entries()));\n } else {\n console.log(` • ${lib.Name}@${lib.Version} (no dependencies)`);\n }\n });\n }\n }\n\n if (loadOrderResult.warnings && debug) {\n console.warn(` ⚠️ Warnings:`, loadOrderResult.warnings);\n }\n\n const loadOrder = loadOrderResult.order || [];\n if (debug) {\n console.log(` 📋 Final load order:`, loadOrder.map(lib => `${lib.Name}@${lib.Version}`));\n }\n\n // Load all libraries in order\n for (const library of loadOrder) {\n // Skip if already loaded\n if (this.loadedLibraryStates.has(library.Name)) {\n if (debug) {\n console.log(`⏭️ Skipping '${library.Name}' (already loaded)`);\n }\n const state = this.loadedLibraryStates.get(library.Name)!;\n if (libraryNames.includes(library.Name)) {\n result.set(library.Name, (window as any)[state.globalVariable]);\n }\n continue;\n }\n\n if (debug) {\n console.log(`📥 Loading '${library.Name}@${library.Version}'`);\n }\n\n // Load the library\n if (!library.CDNUrl || !library.GlobalVariable) {\n throw new Error(`Library '${library.Name}' missing CDN URL or global variable`);\n }\n\n // Load CSS if available\n if (library.CDNCssUrl) {\n const cssUrls = library.CDNCssUrl.split(',').map(url => url.trim());\n for (const cssUrl of cssUrls) {\n if (cssUrl) {\n this.loadCSS(cssUrl);\n }\n }\n }\n\n // Load the script\n const loadedGlobal = await this.loadScript(library.CDNUrl, library.GlobalVariable, debug);\n\n // Track the loaded state\n const dependencies = Array.from(\n this.dependencyResolver.getDirectDependencies(library).keys()\n );\n\n this.loadedLibraryStates.set(library.Name, {\n name: library.Name,\n version: library.Version || 'unknown',\n globalVariable: library.GlobalVariable,\n loadedAt: new Date(),\n requestedBy: libraryNames.includes(library.Name) ? [requestedBy] : [],\n dependencies\n });\n\n // Add to result if it was directly requested\n if (libraryNames.includes(library.Name)) {\n result.set(library.Name, loadedGlobal);\n }\n\n if (debug) {\n console.log(`✅ Loaded '${library.Name}@${library.Version}'`);\n }\n }\n\n return result;\n }\n\n /**\n * Get information about loaded libraries\n * @returns Map of loaded library states\n */\n static getLoadedLibraryStates(): Map<string, LoadedLibraryState> {\n return new Map(this.loadedLibraryStates);\n }\n\n /**\n * Check if a library is loaded\n * @param libraryName - Name of the library\n * @returns True if the library is loaded\n */\n static isLibraryLoaded(libraryName: string): boolean {\n return this.loadedLibraryStates.has(libraryName);\n }\n\n /**\n * Get the version of a loaded library\n * @param libraryName - Name of the library\n * @returns Version string or undefined if not loaded\n */\n static getLoadedLibraryVersion(libraryName: string): string | undefined {\n return this.loadedLibraryStates.get(libraryName)?.version;\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"library-loader.js","sourceRoot":"","sources":["../../src/utilities/library-loader.ts"],"names":[],"mappings":";;;AAMA,6DAG8B;AAE9B,qDAAiF;AACjF,yDAAqD;AAErD,+EAA0E;AAK1E,MAAM,2BAA2B,GAAG,2CAA2C,CAAC;AAsChF,MAAa,aAAa;IAYxB,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC3B,MAA6B,EAC7B,mBAA6C,EAC7C,OAA6B;QAE7B,IAAI,MAAM,EAAE,CAAC;YACX,2CAAsB,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;QAClD,CAAC;QAGD,IAAI,mBAAmB,IAAI,mBAAmB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1D,MAAM,aAAa,GAAG,2CAAsB,CAAC,gBAAgB,EAAE,CAAC;YAChE,MAAM,YAAY,GAAyB;gBACzC,SAAS,EAAE,CAAC,GAAG,aAAa,CAAC,SAAS,EAAE,GAAG,mBAAmB,CAAC;gBAC/D,QAAQ,EAAE;oBACR,GAAG,aAAa,CAAC,QAAQ;oBACzB,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;iBACtC;aACF,CAAC;YACF,2CAAsB,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;QACxD,CAAC;QAED,OAAO,IAAI,CAAC,uBAAuB,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IACjE,CAAC;IAKD,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,OAA2B,EAAE,KAAe;QAE/E,MAAM,aAAa,GAAG,IAAA,wCAAuB,EAAC,KAAK,CAAC,CAAC;QACrD,MAAM,YAAY,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAC3C,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM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C;YAED,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,CAAC,GAAG,CAAC,aAAa,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC;YAC/D,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAMD,MAAM,CAAC,sBAAsB;QAC3B,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAC3C,CAAC;IAOD,MAAM,CAAC,eAAe,CAAC,WAAmB;QACxC,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACnD,CAAC;IAOD,MAAM,CAAC,uBAAuB,CAAC,WAAmB;QAChD,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC5D,CAAC;;AApoBH,sCAqoBC;AApoBgB,6BAAe,GAAG,IAAI,GAAG,EAA0B,CAAC;AACpD,iCAAmB,GAAG,IAAI,GAAG,EAA8B,CAAC;AAC5D,gCAAkB,GAAG,IAAI,uDAAyB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC","sourcesContent":["/**\n * @fileoverview Library loading utilities for React runtime\n * Provides methods to load and manage external JavaScript libraries and CSS\n * @module @memberjunction/react-runtime/utilities\n */\n\nimport { \n StandardLibraries,\n StandardLibraryManager\n} from './standard-libraries';\nimport { LibraryConfiguration, ExternalLibraryConfig, LibraryLoadOptions as ConfigLoadOptions } from '../types/library-config';\nimport { getCoreRuntimeLibraries, isCoreRuntimeLibrary } from './core-libraries';\nimport { resourceManager } from './resource-manager';\nimport { ComponentLibraryEntity } from '@memberjunction/core-entities';\nimport { LibraryDependencyResolver } from './library-dependency-resolver';\nimport { LoadedLibraryState, DependencyResolutionOptions } from '../types/dependency-types';\nimport { LibraryRegistry } from './library-registry';\n\n// Unique component ID for resource tracking\nconst LIBRARY_LOADER_COMPONENT_ID = 'mj-react-runtime-library-loader-singleton';\n\n/**\n * Represents a loaded script or CSS resource\n */\ninterface LoadedResource {\n element: HTMLScriptElement | HTMLLinkElement;\n promise: Promise<any>;\n}\n\n/**\n * Options for loading libraries\n * @deprecated Use LibraryLoadOptions from library-config instead\n */\nexport interface LibraryLoadOptions {\n /** Load core libraries (lodash, d3, Chart.js, dayjs) */\n loadCore?: boolean;\n /** Load UI libraries (antd, React Bootstrap) */\n loadUI?: boolean;\n /** Load CSS files for UI libraries */\n loadCSS?: boolean;\n /** Custom library URLs to load */\n customLibraries?: { url: string; globalName: string }[];\n}\n\n/**\n * Result of loading libraries\n */\nexport interface LibraryLoadResult {\n React: any;\n ReactDOM: any;\n Babel: any;\n libraries: StandardLibraries;\n}\n\n/**\n * Library loader class for managing external script loading\n */\nexport class LibraryLoader {\n private static loadedResources = new Map<string, LoadedResource>();\n private static loadedLibraryStates = new Map<string, LoadedLibraryState>();\n private static dependencyResolver = new LibraryDependencyResolver({ debug: false });\n\n /**\n * Load all standard libraries (core + UI + CSS)\n * This is the main method that should be used by test harness and Angular wrapper\n * @param config Optional full library configuration to replace the default\n * @param additionalLibraries Optional additional libraries to merge with the configuration\n * @param options Optional options including debug mode flag\n */\n static async loadAllLibraries(\n config?: LibraryConfiguration, \n additionalLibraries?: ExternalLibraryConfig[],\n options?: { debug?: boolean }\n ): Promise<LibraryLoadResult> {\n if (config) {\n StandardLibraryManager.setConfiguration(config);\n }\n \n // If additional libraries are provided, merge them with the current configuration\n if (additionalLibraries && additionalLibraries.length > 0) {\n const currentConfig = StandardLibraryManager.getConfiguration();\n const mergedConfig: LibraryConfiguration = {\n libraries: [...currentConfig.libraries, ...additionalLibraries],\n metadata: {\n ...currentConfig.metadata,\n lastUpdated: new Date().toISOString()\n }\n };\n StandardLibraryManager.setConfiguration(mergedConfig);\n }\n \n return this.loadLibrariesFromConfig(undefined, options?.debug);\n }\n\n /**\n * Load libraries based on the current configuration\n */\n static async loadLibrariesFromConfig(options?: ConfigLoadOptions, debug?: boolean): Promise<LibraryLoadResult> {\n // Always load core runtime libraries first\n const coreLibraries = getCoreRuntimeLibraries(debug);\n const corePromises = coreLibraries.map(lib => \n this.loadScript(lib.cdnUrl, lib.globalVariable, debug)\n );\n \n const coreResults = await Promise.all(corePromises);\n const React = coreResults.find((_, i) => coreLibraries[i].globalVariable === 'React');\n const ReactDOM = coreResults.find((_, i) => coreLibraries[i].globalVariable === 'ReactDOM');\n const Babel = coreResults.find((_, i) => coreLibraries[i].globalVariable === 'Babel');\n \n // Expose React and ReactDOM as globals for UMD libraries that expect them\n // Many React component libraries (Recharts, Victory, etc.) expect these as globals\n if (typeof window !== 'undefined') {\n if (React && !(window as any).React) {\n (window as any).React = React;\n console.log('✓ Exposed React as window.React for UMD compatibility');\n }\n if (ReactDOM && !(window as any).ReactDOM) {\n (window as any).ReactDOM = ReactDOM;\n console.log('✓ Exposed ReactDOM as window.ReactDOM for UMD compatibility');\n }\n // Also expose PropTypes as empty object if not present (for older libraries)\n if (!(window as any).PropTypes) {\n (window as any).PropTypes = {};\n console.log('✓ Exposed empty PropTypes as window.PropTypes for UMD compatibility');\n }\n }\n \n // Now load plugin libraries from configuration\n const config = StandardLibraryManager.getConfiguration();\n const enabledLibraries = StandardLibraryManager.getEnabledLibraries();\n \n // Filter out any core runtime libraries from plugin configuration\n let pluginLibraries = enabledLibraries.filter(lib => !isCoreRuntimeLibrary(lib.id));\n \n // Apply options filters if provided\n if (options) {\n if (options.categories) {\n pluginLibraries = pluginLibraries.filter(lib => \n options.categories!.includes(lib.category)\n );\n }\n if (options.excludeRuntimeOnly) {\n pluginLibraries = pluginLibraries.filter(lib => !lib.isRuntimeOnly);\n }\n }\n \n // Load CSS files for plugin libraries (non-blocking)\n pluginLibraries.forEach(lib => {\n if (lib.cdnCssUrl) {\n this.loadCSS(lib.cdnCssUrl);\n }\n });\n \n // Load plugin libraries\n const pluginPromises = pluginLibraries.map(lib => \n this.loadScript(lib.cdnUrl, lib.globalVariable, debug)\n );\n \n const pluginResults = await Promise.all(pluginPromises);\n \n // Build libraries object (only contains plugin libraries)\n const libraries: StandardLibraries = {};\n \n pluginLibraries.forEach((lib, index) => {\n libraries[lib.globalVariable] = pluginResults[index];\n });\n \n return {\n React: React || (window as any).React,\n ReactDOM: ReactDOM || (window as any).ReactDOM,\n Babel: Babel || (window as any).Babel,\n libraries\n };\n }\n\n /**\n * Load libraries with specific options (backward compatibility)\n * @deprecated Use loadLibrariesFromConfig instead\n */\n static async loadLibraries(options: LibraryLoadOptions): Promise<LibraryLoadResult> {\n const {\n loadCore = true,\n loadUI = true,\n loadCSS = true,\n customLibraries = []\n } = options;\n\n // Map old options to new configuration approach\n const categoriesToLoad: Array<ExternalLibraryConfig['category']> = ['runtime'];\n if (loadCore) {\n categoriesToLoad.push('utility', 'charting');\n }\n if (loadUI) {\n categoriesToLoad.push('ui');\n }\n \n const result = await this.loadLibrariesFromConfig({\n categories: categoriesToLoad\n });\n \n // Load custom libraries if provided\n if (customLibraries.length > 0) {\n const customPromises = customLibraries.map(({ url, globalName }) =>\n this.loadScript(url, globalName)\n );\n \n const customResults = await Promise.all(customPromises);\n customLibraries.forEach(({ globalName }, index) => {\n result.libraries[globalName] = customResults[index];\n });\n }\n \n return result;\n }\n\n /**\n * Load a script from URL\n */\n private static async loadScript(url: string, globalName: string, debug: boolean = false): Promise<any> {\n // Check if already loaded\n const existing = this.loadedResources.get(url);\n if (existing) {\n if (debug) {\n console.log(`✅ Library '${globalName}' already loaded (cached)`);\n }\n return existing.promise;\n }\n\n const promise = new Promise((resolve, reject) => {\n // Check if global already exists\n const existingGlobal = (window as any)[globalName];\n if (existingGlobal) {\n if (debug) {\n console.log(`✅ Library '${globalName}' already available globally`);\n }\n resolve(existingGlobal);\n return;\n }\n\n // Check if script tag exists\n const existingScript = document.querySelector(`script[src=\"${url}\"]`);\n if (existingScript) {\n this.waitForScriptLoad(existingScript as HTMLScriptElement, globalName, resolve, reject);\n return;\n }\n\n // Create new script\n const script = document.createElement('script');\n script.src = url;\n script.async = true;\n script.crossOrigin = 'anonymous';\n\n const cleanup = () => {\n script.removeEventListener('load', onLoad);\n script.removeEventListener('error', onError);\n };\n\n const onLoad = () => {\n cleanup();\n const global = (window as any)[globalName];\n if (global) {\n if (debug) {\n console.log(`✅ Library '${globalName}' loaded successfully from ${url}`);\n }\n resolve(global);\n } else {\n // Some libraries may take a moment to initialize\n const timeoutId = resourceManager.setTimeout(\n LIBRARY_LOADER_COMPONENT_ID,\n () => {\n const delayedGlobal = (window as any)[globalName];\n if (delayedGlobal) {\n if (debug) {\n console.log(`✅ Library '${globalName}' loaded successfully (delayed initialization)`);\n }\n resolve(delayedGlobal);\n } else {\n reject(new Error(`${globalName} not found after script load`));\n }\n },\n 100,\n { url, globalName }\n );\n }\n };\n\n const onError = () => {\n cleanup();\n reject(new Error(`Failed to load script: ${url}`));\n };\n\n script.addEventListener('load', onLoad);\n script.addEventListener('error', onError);\n\n if (debug) {\n console.log(`📦 Loading library '${globalName}' from ${url}...`);\n }\n document.head.appendChild(script);\n \n // Register the script element for cleanup\n resourceManager.registerDOMElement(LIBRARY_LOADER_COMPONENT_ID, script);\n });\n\n this.loadedResources.set(url, { \n element: document.querySelector(`script[src=\"${url}\"]`)!, \n promise \n });\n\n return promise;\n }\n\n /**\n * Load CSS from URL\n */\n private static loadCSS(url: string): void {\n if (this.loadedResources.has(url)) {\n return;\n }\n\n const existingLink = document.querySelector(`link[href=\"${url}\"]`);\n if (existingLink) {\n return;\n }\n\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = url;\n document.head.appendChild(link);\n \n // Register the link element for cleanup\n resourceManager.registerDOMElement(LIBRARY_LOADER_COMPONENT_ID, link);\n\n this.loadedResources.set(url, {\n element: link,\n promise: Promise.resolve()\n });\n }\n\n /**\n * Wait for existing script to load\n */\n private static waitForScriptLoad(\n script: HTMLScriptElement,\n globalName: string,\n resolve: (value: any) => void,\n reject: (reason: any) => void\n ): void {\n const checkGlobal = () => {\n const global = (window as any)[globalName];\n if (global) {\n resolve(global);\n } else {\n // Retry after a short delay\n resourceManager.setTimeout(\n LIBRARY_LOADER_COMPONENT_ID,\n () => {\n const delayedGlobal = (window as any)[globalName];\n if (delayedGlobal) {\n resolve(delayedGlobal);\n } else {\n reject(new Error(`${globalName} not found after script load`));\n }\n },\n 100,\n { context: 'waitForScriptLoad', globalName }\n );\n }\n };\n\n // Check if already loaded\n if ((script as any).complete || (script as any).readyState === 'complete') {\n checkGlobal();\n return;\n }\n\n // Wait for load\n const loadHandler = () => {\n checkGlobal();\n };\n resourceManager.addEventListener(\n LIBRARY_LOADER_COMPONENT_ID,\n script,\n 'load',\n loadHandler,\n { once: true }\n );\n }\n\n\n /**\n * Get all loaded resources (for cleanup)\n */\n static getLoadedResources(): Map<string, LoadedResource> {\n return this.loadedResources;\n }\n\n /**\n * Clear loaded resources cache and cleanup DOM elements\n */\n static clearCache(): void {\n // Remove all script and link elements we added\n this.loadedResources.forEach((resource, url) => {\n if (resource.element && resource.element.parentNode) {\n resource.element.parentNode.removeChild(resource.element);\n }\n });\n \n this.loadedResources.clear();\n this.loadedLibraryStates.clear();\n \n // Clean up any resources managed by resource manager\n resourceManager.cleanupComponent(LIBRARY_LOADER_COMPONENT_ID);\n }\n\n /**\n * Load a library with its dependencies\n * @param libraryName - Name of the library to load\n * @param allLibraries - All available libraries for dependency resolution\n * @param requestedBy - Name of the component/library requesting this load\n * @param options - Dependency resolution options\n * @returns Promise resolving to the loaded library global object\n */\n static async loadLibraryWithDependencies(\n libraryName: string,\n allLibraries: ComponentLibraryEntity[],\n requestedBy: string = 'user',\n options?: DependencyResolutionOptions\n ): Promise<any> {\n const debug = options?.debug || false;\n \n if (debug) {\n console.log(`📚 Loading library '${libraryName}' with dependencies`);\n }\n\n // Check if already loaded\n const existingState = this.loadedLibraryStates.get(libraryName);\n if (existingState) {\n if (debug) {\n console.log(`✅ Library '${libraryName}' already loaded (version: ${existingState.version})`);\n }\n // Track who requested it\n if (!existingState.requestedBy.includes(requestedBy)) {\n existingState.requestedBy.push(requestedBy);\n }\n return (window as any)[existingState.globalVariable];\n }\n\n // Get load order including dependencies\n const loadOrderResult = this.dependencyResolver.getLoadOrder(\n [libraryName],\n allLibraries,\n options\n );\n\n if (!loadOrderResult.success) {\n const errors = loadOrderResult.errors?.join(', ') || 'Unknown error';\n throw new Error(`Failed to resolve dependencies for '${libraryName}': ${errors}`);\n }\n\n if (loadOrderResult.warnings && debug) {\n console.warn(`⚠️ Warnings for '${libraryName}':`, loadOrderResult.warnings);\n }\n\n const loadOrder = loadOrderResult.order || [];\n if (debug) {\n console.log(`📋 Load order for '${libraryName}':`, loadOrder.map(lib => `${lib.Name}@${lib.Version}`));\n }\n\n // Load libraries in order\n for (const library of loadOrder) {\n // Skip if already loaded\n if (this.loadedLibraryStates.has(library.Name)) {\n if (debug) {\n console.log(`⏭️ Skipping '${library.Name}' (already loaded)`);\n }\n continue;\n }\n\n // Check library status\n if (library.Status) {\n if (library.Status === 'Disabled') {\n console.error(`🚫 ERROR: Library '${library.Name}' is DISABLED and should not be used`);\n // Continue loading anyway per requirements\n } else if (library.Status === 'Deprecated') {\n console.warn(`⚠️ WARNING: Library '${library.Name}' is DEPRECATED. Consider using an alternative.`);\n }\n // Active status is fine, no message needed\n }\n\n if (debug) {\n console.log(`📥 Loading '${library.Name}@${library.Version}'`);\n }\n\n // Load the library\n if (!library.CDNUrl || !library.GlobalVariable) {\n throw new Error(`Library '${library.Name}' missing CDN URL or global variable`);\n }\n\n // Load CSS if available\n if (library.CDNCssUrl) {\n const cssUrls = library.CDNCssUrl.split(',').map(url => url.trim());\n for (const cssUrl of cssUrls) {\n if (cssUrl) {\n this.loadCSS(cssUrl);\n }\n }\n }\n\n // Load the script\n const loadedGlobal = await this.loadScript(library.CDNUrl, library.GlobalVariable, debug);\n\n // Track the loaded state\n const dependencies = Array.from(\n this.dependencyResolver.getDirectDependencies(library).keys()\n );\n\n this.loadedLibraryStates.set(library.Name, {\n name: library.Name,\n version: library.Version || 'unknown',\n globalVariable: library.GlobalVariable,\n loadedAt: new Date(),\n requestedBy: library.Name === libraryName ? [requestedBy] : [],\n dependencies\n });\n\n if (debug) {\n console.log(`✅ Loaded '${library.Name}@${library.Version}'`);\n }\n }\n\n // Return the originally requested library's global\n const targetLibrary = loadOrder.find(lib => lib.Name === libraryName);\n if (!targetLibrary || !targetLibrary.GlobalVariable) {\n throw new Error(`Failed to load library '${libraryName}'`);\n }\n\n return (window as any)[targetLibrary.GlobalVariable];\n }\n\n /**\n * Load multiple libraries with dependency resolution\n * @param libraryNames - Names of libraries to load\n * @param allLibraries - All available libraries for dependency resolution\n * @param requestedBy - Name of the component requesting these libraries\n * @param options - Dependency resolution options\n * @returns Map of library names to their loaded global objects\n */\n static async loadLibrariesWithDependencies(\n libraryNames: string[],\n allLibraries: ComponentLibraryEntity[],\n requestedBy: string = 'user',\n options?: DependencyResolutionOptions\n ): Promise<Map<string, any>> {\n const debug = options?.debug || false;\n const result = new Map<string, any>();\n \n if (debug) {\n console.log(`📚 Loading libraries with dependencies:`, libraryNames);\n console.log(` 📦 Total available libraries: ${allLibraries.length}`);\n console.log(` 📋 Available library list:`, allLibraries.map(l => `${l.Name}@${l.Version}`));\n }\n\n // Get combined load order for all requested libraries\n const loadOrderResult = this.dependencyResolver.getLoadOrder(\n libraryNames,\n allLibraries,\n options\n );\n\n if (!loadOrderResult.success) {\n const errors = loadOrderResult.errors?.join(', ') || 'Unknown error';\n throw new Error(`Failed to resolve dependencies: ${errors}`);\n }\n\n if (debug) {\n console.log(` 📊 Dependency resolution result:`, {\n success: loadOrderResult.success,\n errors: loadOrderResult.errors || [],\n warnings: loadOrderResult.warnings || []\n });\n \n if (loadOrderResult.order) {\n console.log(` 🔄 Resolved dependencies for each library:`);\n loadOrderResult.order.forEach(lib => {\n const deps = this.dependencyResolver.parseDependencies(lib.Dependencies);\n if (deps.size > 0) {\n console.log(` • ${lib.Name}@${lib.Version} requires:`, Array.from(deps.entries()));\n } else {\n console.log(` • ${lib.Name}@${lib.Version} (no dependencies)`);\n }\n });\n }\n }\n\n if (loadOrderResult.warnings && debug) {\n console.warn(` ⚠️ Warnings:`, loadOrderResult.warnings);\n }\n\n const loadOrder = loadOrderResult.order || [];\n if (debug) {\n console.log(` 📋 Final load order:`, loadOrder.map(lib => `${lib.Name}@${lib.Version}`));\n }\n\n // Load all libraries in order\n for (const library of loadOrder) {\n // Skip if already loaded\n if (this.loadedLibraryStates.has(library.Name)) {\n if (debug) {\n console.log(`⏭️ Skipping '${library.Name}' (already loaded)`);\n }\n const state = this.loadedLibraryStates.get(library.Name)!;\n if (libraryNames.includes(library.Name)) {\n result.set(library.Name, (window as any)[state.globalVariable]);\n }\n continue;\n }\n\n // Check library status\n if (library.Status) {\n if (library.Status === 'Disabled') {\n console.error(`🚫 ERROR: Library '${library.Name}' is DISABLED and should not be used`);\n // Continue loading anyway per requirements\n } else if (library.Status === 'Deprecated') {\n console.warn(`⚠️ WARNING: Library '${library.Name}' is DEPRECATED. Consider using an alternative.`);\n }\n // Active status is fine, no message needed\n }\n\n if (debug) {\n console.log(`📥 Loading '${library.Name}@${library.Version}'`);\n }\n\n // Load the library\n if (!library.CDNUrl || !library.GlobalVariable) {\n throw new Error(`Library '${library.Name}' missing CDN URL or global variable`);\n }\n\n // Load CSS if available\n if (library.CDNCssUrl) {\n const cssUrls = library.CDNCssUrl.split(',').map(url => url.trim());\n for (const cssUrl of cssUrls) {\n if (cssUrl) {\n this.loadCSS(cssUrl);\n }\n }\n }\n\n // Load the script\n const loadedGlobal = await this.loadScript(library.CDNUrl, library.GlobalVariable, debug);\n\n // Track the loaded state\n const dependencies = Array.from(\n this.dependencyResolver.getDirectDependencies(library).keys()\n );\n\n this.loadedLibraryStates.set(library.Name, {\n name: library.Name,\n version: library.Version || 'unknown',\n globalVariable: library.GlobalVariable,\n loadedAt: new Date(),\n requestedBy: libraryNames.includes(library.Name) ? [requestedBy] : [],\n dependencies\n });\n\n // Add to result if it was directly requested\n if (libraryNames.includes(library.Name)) {\n result.set(library.Name, loadedGlobal);\n }\n\n if (debug) {\n console.log(`✅ Loaded '${library.Name}@${library.Version}'`);\n }\n }\n\n return result;\n }\n\n /**\n * Get information about loaded libraries\n * @returns Map of loaded library states\n */\n static getLoadedLibraryStates(): Map<string, LoadedLibraryState> {\n return new Map(this.loadedLibraryStates);\n }\n\n /**\n * Check if a library is loaded\n * @param libraryName - Name of the library\n * @returns True if the library is loaded\n */\n static isLibraryLoaded(libraryName: string): boolean {\n return this.loadedLibraryStates.has(libraryName);\n }\n\n /**\n * Get the version of a loaded library\n * @param libraryName - Name of the library\n * @returns Version string or undefined if not loaded\n */\n static getLoadedLibraryVersion(libraryName: string): string | undefined {\n return this.loadedLibraryStates.get(libraryName)?.version;\n }\n}"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/react-runtime",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.99.0",
|
|
4
4
|
"description": "Platform-agnostic React component runtime for MemberJunction. Provides core compilation, registry, and execution capabilities for React components in any JavaScript environment.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/MemberJunction/MJ#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@memberjunction/core": "2.
|
|
31
|
-
"@memberjunction/global": "2.
|
|
32
|
-
"@memberjunction/interactive-component-types": "2.
|
|
33
|
-
"@memberjunction/core-entities": "2.
|
|
30
|
+
"@memberjunction/core": "2.99.0",
|
|
31
|
+
"@memberjunction/global": "2.99.0",
|
|
32
|
+
"@memberjunction/interactive-component-types": "2.99.0",
|
|
33
|
+
"@memberjunction/core-entities": "2.99.0",
|
|
34
34
|
"@babel/standalone": "^7.23.5",
|
|
35
35
|
"rxjs": "^7.8.1"
|
|
36
36
|
},
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
import { ComponentStyles, ComponentObject } from '@memberjunction/interactive-component-types';
|
|
17
17
|
import { LibraryRegistry } from '../utilities/library-registry';
|
|
18
18
|
import { LibraryLoader } from '../utilities/library-loader';
|
|
19
|
+
import { unwrapLibraryComponent, unwrapLibraryComponents, unwrapAllLibraryComponents } from '../utilities/component-unwrapper';
|
|
19
20
|
import { ComponentLibraryEntity } from '@memberjunction/core-entities';
|
|
20
21
|
|
|
21
22
|
/**
|
|
@@ -98,7 +99,8 @@ export class ComponentCompiler {
|
|
|
98
99
|
const componentFactory = this.createComponentFactory(
|
|
99
100
|
transpiledCode,
|
|
100
101
|
options.componentName,
|
|
101
|
-
loadedLibraries
|
|
102
|
+
loadedLibraries,
|
|
103
|
+
options
|
|
102
104
|
);
|
|
103
105
|
|
|
104
106
|
// Build the compiled component
|
|
@@ -248,13 +250,19 @@ export class ComponentCompiler {
|
|
|
248
250
|
function createComponent(
|
|
249
251
|
React, ReactDOM,
|
|
250
252
|
useState, useEffect, useCallback, useMemo, useRef, useContext, useReducer, useLayoutEffect,
|
|
251
|
-
libraries, styles, console, components
|
|
253
|
+
libraries, styles, console, components,
|
|
254
|
+
unwrapLibraryComponent, unwrapLibraryComponents, unwrapAllLibraryComponents
|
|
252
255
|
) {
|
|
253
256
|
if (!React)
|
|
254
257
|
console.log('[React-Runtime-JS] React is not defined');
|
|
255
258
|
if (!ReactDOM)
|
|
256
259
|
console.log('[React-Runtime-JS] ReactDOM is not defined');
|
|
257
260
|
|
|
261
|
+
// Make unwrap functions available with legacy names for backward compatibility
|
|
262
|
+
const unwrapComponent = unwrapLibraryComponent;
|
|
263
|
+
const unwrapComponents = unwrapLibraryComponents;
|
|
264
|
+
const unwrapAllComponents = unwrapAllLibraryComponents;
|
|
265
|
+
|
|
258
266
|
// Code for ${componentName}
|
|
259
267
|
${componentCode}
|
|
260
268
|
|
|
@@ -703,19 +711,22 @@ export class ComponentCompiler {
|
|
|
703
711
|
* @param transpiledCode - Transpiled JavaScript code
|
|
704
712
|
* @param componentName - Name of the component
|
|
705
713
|
* @param loadedLibraries - Map of loaded libraries
|
|
714
|
+
* @param options - Compile options containing spec and other metadata
|
|
706
715
|
* @returns Component factory function
|
|
707
716
|
*/
|
|
708
717
|
private createComponentFactory(
|
|
709
718
|
transpiledCode: string,
|
|
710
719
|
componentName: string,
|
|
711
|
-
loadedLibraries: Map<string, any
|
|
720
|
+
loadedLibraries: Map<string, any>,
|
|
721
|
+
options: CompileOptions
|
|
712
722
|
): (context: RuntimeContext, styles?: ComponentStyles) => ComponentObject {
|
|
713
723
|
try {
|
|
714
|
-
// Create the factory function with all React hooks
|
|
724
|
+
// Create the factory function with all React hooks and utility functions
|
|
715
725
|
const factoryCreator = new Function(
|
|
716
726
|
'React', 'ReactDOM',
|
|
717
727
|
'useState', 'useEffect', 'useCallback', 'useMemo', 'useRef', 'useContext', 'useReducer', 'useLayoutEffect',
|
|
718
728
|
'libraries', 'styles', 'console', 'components',
|
|
729
|
+
'unwrapLibraryComponent', 'unwrapLibraryComponents', 'unwrapAllLibraryComponents',
|
|
719
730
|
`${transpiledCode}; return createComponent;`
|
|
720
731
|
);
|
|
721
732
|
|
|
@@ -723,29 +734,80 @@ export class ComponentCompiler {
|
|
|
723
734
|
return (context: RuntimeContext, styles: any = {}, components: Record<string, any> = {}) => {
|
|
724
735
|
const { React, ReactDOM, libraries = {} } = context;
|
|
725
736
|
|
|
737
|
+
// Diagnostic: Check if React is null when creating component
|
|
738
|
+
if (!React) {
|
|
739
|
+
console.error('🔴 CRITICAL: React is NULL in createComponentFactory!');
|
|
740
|
+
console.error('Context provided:', context);
|
|
741
|
+
console.error('Context keys:', Object.keys(context));
|
|
742
|
+
throw new Error('React is null in runtime context when creating component factory');
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
// Additional diagnostic for React hooks
|
|
746
|
+
if (!React.useState || !React.useEffect) {
|
|
747
|
+
console.error('🔴 CRITICAL: React hooks are missing!');
|
|
748
|
+
console.error('React object keys:', React ? Object.keys(React) : 'React is null');
|
|
749
|
+
console.error('useState:', typeof React?.useState);
|
|
750
|
+
console.error('useEffect:', typeof React?.useEffect);
|
|
751
|
+
}
|
|
752
|
+
|
|
726
753
|
// Merge loaded libraries with context libraries
|
|
754
|
+
// IMPORTANT: Only include libraries that are NOT dependency-only
|
|
755
|
+
// We need to filter based on the libraries array from options
|
|
727
756
|
const mergedLibraries = { ...libraries };
|
|
757
|
+
|
|
758
|
+
// Only add libraries that are explicitly requested in the component
|
|
759
|
+
// This prevents dependency-only libraries from being accessible
|
|
760
|
+
const specLibraryNames = new Set(
|
|
761
|
+
(options.libraries || []).map((lib: any) => lib.globalVariable).filter(Boolean)
|
|
762
|
+
);
|
|
763
|
+
|
|
728
764
|
loadedLibraries.forEach((value, key) => {
|
|
729
|
-
|
|
765
|
+
// Only add if this library is in the spec (not just a dependency)
|
|
766
|
+
if (specLibraryNames.has(key)) {
|
|
767
|
+
mergedLibraries[key] = value;
|
|
768
|
+
} else if (this.config.debug) {
|
|
769
|
+
console.log(`⚠️ Filtering out dependency-only library: ${key}`);
|
|
770
|
+
}
|
|
730
771
|
});
|
|
731
772
|
|
|
773
|
+
// Create bound versions of unwrap functions with debug flag
|
|
774
|
+
const boundUnwrapLibraryComponent = (lib: any, name: string) => unwrapLibraryComponent(lib, name, this.config.debug);
|
|
775
|
+
const boundUnwrapLibraryComponents = (lib: any, ...names: string[]) => unwrapLibraryComponents(lib, ...names, this.config.debug as any);
|
|
776
|
+
const boundUnwrapAllLibraryComponents = (lib: any) => unwrapAllLibraryComponents(lib, this.config.debug);
|
|
777
|
+
|
|
732
778
|
// Execute the factory creator to get the createComponent function
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
779
|
+
let createComponentFn;
|
|
780
|
+
try {
|
|
781
|
+
createComponentFn = factoryCreator(
|
|
782
|
+
React,
|
|
783
|
+
ReactDOM,
|
|
784
|
+
React.useState,
|
|
785
|
+
React.useEffect,
|
|
786
|
+
React.useCallback,
|
|
787
|
+
React.useMemo,
|
|
788
|
+
React.useRef,
|
|
789
|
+
React.useContext,
|
|
790
|
+
React.useReducer,
|
|
791
|
+
React.useLayoutEffect,
|
|
792
|
+
mergedLibraries,
|
|
793
|
+
styles,
|
|
794
|
+
console,
|
|
795
|
+
components,
|
|
796
|
+
boundUnwrapLibraryComponent,
|
|
797
|
+
boundUnwrapLibraryComponents,
|
|
798
|
+
boundUnwrapAllLibraryComponents
|
|
799
|
+
);
|
|
800
|
+
} catch (error: any) {
|
|
801
|
+
console.error('🔴 CRITICAL: Error calling factoryCreator with React hooks!');
|
|
802
|
+
console.error('Error:', error?.message || error);
|
|
803
|
+
console.error('React is:', React);
|
|
804
|
+
console.error('React type:', typeof React);
|
|
805
|
+
if (React) {
|
|
806
|
+
console.error('React.useState:', typeof React.useState);
|
|
807
|
+
console.error('React.useEffect:', typeof React.useEffect);
|
|
808
|
+
}
|
|
809
|
+
throw new Error(`Failed to create component factory: ${error?.message || error}`);
|
|
810
|
+
}
|
|
749
811
|
|
|
750
812
|
// Call createComponent to get the actual component
|
|
751
813
|
const Component = createComponentFn(
|
|
@@ -762,7 +824,10 @@ export class ComponentCompiler {
|
|
|
762
824
|
mergedLibraries,
|
|
763
825
|
styles,
|
|
764
826
|
console,
|
|
765
|
-
components
|
|
827
|
+
components,
|
|
828
|
+
boundUnwrapLibraryComponent,
|
|
829
|
+
boundUnwrapLibraryComponents,
|
|
830
|
+
boundUnwrapAllLibraryComponents
|
|
766
831
|
);
|
|
767
832
|
|
|
768
833
|
// Return the component directly
|
package/src/index.ts
CHANGED
|
@@ -117,6 +117,16 @@ export {
|
|
|
117
117
|
CacheOptions
|
|
118
118
|
} from './utilities/cache-manager';
|
|
119
119
|
|
|
120
|
+
export {
|
|
121
|
+
unwrapLibraryComponent,
|
|
122
|
+
unwrapLibraryComponents,
|
|
123
|
+
unwrapAllLibraryComponents,
|
|
124
|
+
// Legacy exports for backward compatibility
|
|
125
|
+
unwrapComponent,
|
|
126
|
+
unwrapComponents,
|
|
127
|
+
unwrapAllComponents
|
|
128
|
+
} from './utilities/component-unwrapper';
|
|
129
|
+
|
|
120
130
|
// Version information
|
|
121
131
|
export const VERSION = '2.69.1';
|
|
122
132
|
|