@memberjunction/react-runtime 4.4.0 → 5.1.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 +28 -17
- package/CHANGELOG.md +28 -0
- package/dist/324.runtime.umd.js +17 -17
- package/dist/compiler/component-compiler.js.map +1 -1
- package/dist/component-manager/component-manager.js.map +1 -1
- package/dist/component-manager/types.d.ts +2 -2
- package/dist/component-manager/types.d.ts.map +1 -1
- package/dist/component-manager/types.js.map +1 -1
- package/dist/registry/component-registry-service.js.map +1 -1
- package/dist/runtime/component-hierarchy.d.ts +3 -3
- package/dist/runtime/component-hierarchy.d.ts.map +1 -1
- package/dist/runtime/component-hierarchy.js.map +1 -1
- package/dist/runtime.umd.js +1 -1
- package/dist/types/dependency-types.d.ts +3 -3
- package/dist/types/dependency-types.d.ts.map +1 -1
- package/dist/types/dependency-types.js.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/library-dependency-resolver.d.ts +7 -7
- package/dist/utilities/library-dependency-resolver.d.ts.map +1 -1
- package/dist/utilities/library-dependency-resolver.js.map +1 -1
- package/dist/utilities/library-loader.d.ts +3 -3
- package/dist/utilities/library-loader.d.ts.map +1 -1
- package/dist/utilities/library-loader.js.map +1 -1
- package/dist/utilities/library-registry.d.ts +2 -2
- package/dist/utilities/library-registry.d.ts.map +1 -1
- package/dist/utilities/library-registry.js.map +1 -1
- package/package.json +6 -6
- package/src/compiler/component-compiler.ts +2 -2
- package/src/component-manager/component-manager.ts +1 -1
- package/src/component-manager/types.ts +2 -2
- package/src/registry/component-registry-service.ts +10 -10
- package/src/runtime/component-hierarchy.ts +3 -3
- package/src/types/dependency-types.ts +3 -3
- package/src/types/index.ts +2 -2
- package/src/utilities/library-dependency-resolver.ts +11 -11
- package/src/utilities/library-loader.ts +3 -3
- package/src/utilities/library-registry.ts +4 -4
|
@@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,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;IACjD,CAAC;IAOO,cAAc,CAAC,SAA4B,EAAE,IAAY;QAE/D,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YAE3D,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;YAC3D,IAAI,QAAQ;gBACV,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC3C,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC3D,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IACjD,CAAC;IAQO,sBAAsB,CAAC,KAAU,EAAE,aAAqB;QAC9D,OAAO;YACL,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,2BAA2B;YACrD,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,aAAa;YACb,KAAK,EAAE,aAAa;YACpB,OAAO,EAAE,KAAK;SACf,CAAC;IACJ,CAAC;IAKD,UAAU;QACR,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;IAMD,YAAY;QACV,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC;IACpC,CAAC;IAMD,YAAY,CAAC,MAA+B;QAC1C,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IAC9C,CAAC;CACF","sourcesContent":["/**\n * @fileoverview Platform-agnostic React component compiler.\n * Compiles React component source code into executable components using Babel.\n * @module @memberjunction/react-runtime/compiler\n */\n\nimport { UserInfo } from '@memberjunction/core';\nimport { \n CompileOptions, \n CompiledComponent, \n CompilationResult,\n CompilerConfig,\n ComponentError,\n RuntimeContext\n} from '../types';\nimport { ComponentStyles, ComponentObject } from '@memberjunction/interactive-component-types';\nimport { LibraryRegistry } from '../utilities/library-registry';\nimport { LibraryLoader } from '../utilities/library-loader';\nimport { unwrapLibraryComponent, unwrapLibraryComponents, unwrapAllLibraryComponents } from '../utilities/component-unwrapper';\nimport { ComponentLibraryEntity } from '@memberjunction/core-entities';\n\n/**\n * Default compiler configuration\n */\nconst DEFAULT_COMPILER_CONFIG: CompilerConfig = {\n babel: {\n presets: ['react'],\n plugins: []\n },\n minify: false,\n sourceMaps: false,\n cache: true,\n maxCacheSize: 100,\n debug: false\n};\n\n/**\n * Platform-agnostic React component compiler.\n * Transforms JSX/React component source code into executable JavaScript.\n */\nexport class ComponentCompiler {\n private config: CompilerConfig;\n private compilationCache: Map<string, CompiledComponent>;\n private cacheAccessOrder: string[]; // Track access order for LRU\n private babelInstance: any;\n\n /**\n * Creates a new ComponentCompiler instance\n * @param config - Optional compiler configuration\n */\n constructor(config?: Partial<CompilerConfig>) {\n this.config = { ...DEFAULT_COMPILER_CONFIG, ...config };\n this.compilationCache = new Map();\n }\n\n /**\n * Sets the Babel instance to use for compilation\n * @param babel - The Babel standalone instance\n */\n setBabelInstance(babel: any): void {\n this.babelInstance = babel;\n }\n\n /**\n * Compiles a React component from source code\n * @param options - Compilation options\n * @returns Promise resolving to compilation result\n */\n async compile(options: CompileOptions): Promise<CompilationResult> {\n const startTime = Date.now();\n\n try {\n // Check cache first if enabled\n if (this.config.cache) {\n const cached = this.getCachedComponent(options.componentName, options.componentCode);\n if (cached) {\n return {\n success: true,\n component: cached,\n duration: Date.now() - startTime\n };\n }\n }\n\n // Validate inputs\n this.validateCompileOptions(options);\n\n // Load required libraries if specified\n const loadedLibraries = await this.loadRequiredLibraries(options.libraries!, options.allLibraries);\n\n // Transpile the component code\n const transpiledCode = this.transpileComponent(\n options.componentCode,\n options.componentName,\n options\n );\n\n // Create the component factory with loaded libraries\n const componentFactory = this.createComponentFactory(\n transpiledCode,\n options.componentName,\n loadedLibraries,\n options\n );\n\n // Build the compiled component\n const compiledComponent: CompiledComponent = {\n factory: componentFactory,\n id: this.generateComponentId(options.componentName),\n name: options.componentName,\n compiledAt: new Date(),\n warnings: []\n };\n\n // Cache if enabled\n if (this.config.cache) {\n this.cacheComponent(compiledComponent, options.componentCode);\n }\n\n return {\n success: true,\n component: compiledComponent,\n duration: Date.now() - startTime,\n size: transpiledCode.length,\n loadedLibraries: loadedLibraries\n };\n\n } catch (error) {\n return {\n success: false,\n error: this.createCompilationError(error, options.componentName),\n duration: Date.now() - startTime\n };\n }\n }\n\n /**\n * Transpiles JSX/React code to JavaScript\n * @param code - Source code to transpile\n * @param componentName - Name of the component\n * @param options - Compilation options\n * @returns Transpiled JavaScript code\n */\n private transpileComponent(\n code: string,\n componentName: string,\n options: CompileOptions\n ): string {\n if (!this.babelInstance) {\n throw new Error('Babel instance not set. Call setBabelInstance() first.');\n }\n\n const wrappedCode = this.wrapComponentCode(code, componentName, options.libraries, options.dependencies);\n\n try {\n const result = this.babelInstance.transform(wrappedCode, {\n presets: options.babelPresets || this.config.babel.presets,\n plugins: options.babelPlugins || this.config.babel.plugins,\n filename: `${componentName}.jsx`,\n sourceMaps: this.config.sourceMaps,\n minified: this.config.minify\n });\n\n return result.code;\n } catch (error: any) {\n throw new Error(`Transpilation failed: ${error.message}`);\n }\n }\n\n /**\n * Wraps component code in a factory function for execution\n * @param componentCode - Raw component code\n * @param componentName - Name of the component\n * @param libraries - Optional library dependencies\n * @param dependencies - Optional child component dependencies\n * @returns Wrapped component code\n */\n // Core libraries that are passed as parameters to createComponent and should not be destructured\n private readonly CORE_LIBRARIES = new Set(['React', 'ReactDOM']);\n\n private wrapComponentCode(componentCode: string, componentName: string, libraries?: any[], dependencies?: Array<{ name: string }>): string {\n const debug = this.config.debug;\n // Generate library declarations if libraries are provided\n // Skip core libraries as they're passed as parameters to createComponent\n const libraryDeclarations = libraries && libraries.length > 0\n ? libraries\n .filter(lib => lib.globalVariable && !this.CORE_LIBRARIES.has(lib.globalVariable)) // Skip core libraries\n .map(lib => `const ${lib.globalVariable} = libraries['${lib.globalVariable}'];`)\n .join('\\n ')\n : '';\n const libraryLogChecks = libraries && libraries.length > 0 \n ? libraries\n .filter(lib => lib.globalVariable && !this.CORE_LIBRARIES.has(lib.globalVariable)) // Skip core libraries\n .map(lib => `\\nif (!${lib.globalVariable}) { console.error('[React-Runtime-JS] Library \"${lib.globalVariable}\" is not defined'); } else { ${debug ? `console.log('[React-Runtime-JS] Library \"${lib.globalVariable}\" is defined');` : ''} }`)\n .join('\\n ')\n : '';\n\n // Generate component declarations if dependencies are provided\n // Filter out the component being compiled to avoid naming conflicts\n // Also detect and warn about duplicates\n const seenDependencies = new Set<string>();\n const uniqueDependencies: Array<{ name: string; code?: string }> = [];\n const duplicates: string[] = [];\n \n if (dependencies && dependencies.length > 0) {\n for (const dep of dependencies) {\n if (dep.name === componentName) {\n // Skip the component being compiled itself\n continue;\n }\n if (seenDependencies.has(dep.name)) {\n duplicates.push(dep.name);\n } else {\n seenDependencies.add(dep.name);\n uniqueDependencies.push(dep);\n }\n }\n }\n \n // Generate warning for duplicates\n const duplicateWarnings = duplicates.length > 0\n ? duplicates\n .map(name => `console.warn('[React-Runtime-JS] WARNING: Component \"${name}\" is registered multiple times as a dependency. Using first occurrence only.');`)\n .join('\\n ')\n : '';\n \n const componentDeclarations = uniqueDependencies.length > 0\n ? uniqueDependencies\n .map(dep => `const ${dep.name}Raw = componentsOuter['${dep.name}'];\n ${debug ? `console.log('[React-Runtime-JS] Extracting ${dep.name}:');\n console.log(' - Raw value type:', typeof ${dep.name}Raw);\n console.log(' - Raw value:', ${dep.name}Raw);\n if (${dep.name}Raw && typeof ${dep.name}Raw === 'object') {\n console.log(' - Has .component property:', 'component' in ${dep.name}Raw);\n console.log(' - .component type:', typeof ${dep.name}Raw.component);\n }` : ''}\n const ${dep.name} = ${dep.name}Raw?.component || ${dep.name}Raw;\n ${debug ? `console.log(' - Final ${dep.name} type:', typeof ${dep.name});\n console.log(' - Final ${dep.name} is function:', typeof ${dep.name} === 'function');` : ''}`)\n .join('\\n ')\n : '';\n \n const componentLogChecks = uniqueDependencies.length > 0\n ? uniqueDependencies\n .map(dep => `if (!${dep.name}) { console.error('[React-Runtime-JS] Dependency \"${dep.name}\" is not defined'); } else { ${debug ? `console.log('[React-Runtime-JS] Dependency \"${dep.name}\" is defined');` : ''} }`)\n .join('\\n ')\n : '';\n \n\n const wrappedCode = `\n function createComponent(\n React, ReactDOM, \n useState, useEffect, useCallback, useMemo, useRef, useContext, useReducer, useLayoutEffect,\n libraries, styles, console, components,\n unwrapLibraryComponent, unwrapLibraryComponents, unwrapAllLibraryComponents\n ) {\n if (!React)\n console.log('[React-Runtime-JS] React is not defined');\n if (!ReactDOM)\n console.log('[React-Runtime-JS] ReactDOM is not defined');\n\n // Make unwrap functions available with legacy names for backward compatibility\n const unwrapComponent = unwrapLibraryComponent;\n const unwrapComponents = unwrapLibraryComponents;\n const unwrapAllComponents = unwrapAllLibraryComponents;\n \n // Code for ${componentName}\n ${componentCode}\n \n // Ensure the component exists\n if (typeof ${componentName} === 'undefined') {\n throw new Error('Component \"${componentName}\" is not defined in the provided code');\n }\n else {\n ${debug ? `console.log('[React-Runtime-JS] Component \"${componentName}\" is defined');` : ''}\n }\n \n // Store the component in a variable so we don't lose it\n const UserComponent = ${componentName};\n\n // Check if the component is already a ComponentObject (has a .component property)\n // If so, extract the actual React component\n const ActualComponent = (typeof UserComponent === 'object' && UserComponent !== null && 'component' in UserComponent)\n ? UserComponent.component\n : UserComponent;\n \n // Debug logging to understand what we're getting\n ${debug ? `\n console.log('[React-Runtime-JS]Component ${componentName} type:', typeof UserComponent);\n if (typeof UserComponent === 'object' && UserComponent !== null) {\n console.log('[React-Runtime-JS]Component ${componentName} keys:', Object.keys(UserComponent));\n console.log('[React-Runtime-JS]Component ${componentName} has .component:', 'component' in UserComponent);\n if ('component' in UserComponent) {\n console.log('[React-Runtime-JS]Component ${componentName}.component type:', typeof UserComponent.component);\n }\n }` : ''}\n \n // Validate that we have a function (React component)\n if (typeof ActualComponent !== 'function') {\n console.error('[React-Runtime-JS] Invalid component type for ${componentName}:', typeof ActualComponent);\n console.error('[React-Runtime-JS] ActualComponent value:', ActualComponent);\n console.error('[React-Runtime-JS] Original UserComponent value:', UserComponent);\n throw new Error('[React-Runtime-JS] Component \"${componentName}\" must be a function (React component) or an object with a .component property that is a function. Got: ' + typeof ActualComponent);\n }\n\n let componentsOuter = null, utilitiesOuter = null;\n const DestructureWrapperUserComponent = (props) => {\n if (!componentsOuter) {\n componentsOuter = props?.components || components;\n }\n if (!utilitiesOuter) {\n utilitiesOuter = props?.utilities;\n }\n ${debug ? `\n console.log('[React-Runtime-JS] DestructureWrapperUserComponent for ${componentName}:');\n console.log(' - Props:', props);\n console.log(' - componentsOuter type:', typeof componentsOuter);\n console.log(' - componentsOuter:', componentsOuter);\n if (componentsOuter && typeof componentsOuter === 'object') {\n console.log(' - componentsOuter keys:', Object.keys(componentsOuter));\n for (const key of Object.keys(componentsOuter)) {\n const comp = componentsOuter[key];\n console.log(\\` - componentsOuter[\\${key}] type:\\`, typeof comp);\n if (comp && typeof comp === 'object') {\n console.log(\\` - Has .component: \\${'component' in comp}\\`);\n console.log(\\` - .component type: \\${typeof comp.component}\\`);\n }\n }\n }\n console.log(' - styles:', styles);\n console.log(' - utilities:', utilitiesOuter);\n console.log(' - libraries:', libraries);` : ''}\n ${duplicateWarnings ? '// Duplicate dependency warnings\\n ' + duplicateWarnings + '\\n ' : ''}\n ${libraryDeclarations ? '// Destructure Libraries\\n' + libraryDeclarations + '\\n ' : ''}\n ${componentDeclarations ? '// Destructure Dependencies\\n' + componentDeclarations + '\\n ' : ''}\n ${libraryLogChecks}\n ${componentLogChecks} \n\n const newProps = {\n ...props,\n components: componentsOuter,\n utilities: utilitiesOuter \n }\n return ActualComponent(newProps);\n };\n \n // Create a fresh method registry for each factory call\n const methodRegistry = new Map();\n \n // Create a wrapper component that provides RegisterMethod in callbacks\n const ComponentWithMethodRegistry = (props) => {\n // Register methods on mount\n React.useEffect(() => {\n // Clear previous methods\n methodRegistry.clear();\n \n // Provide RegisterMethod callback if callbacks exist\n if (props.callbacks && typeof props.callbacks.RegisterMethod === 'function') {\n // Component can now register its methods\n // This will be called from within the component\n }\n }, [props.callbacks]);\n \n // Create enhanced callbacks with RegisterMethod\n const enhancedCallbacks = React.useMemo(() => {\n if (!props.callbacks) return {};\n \n return {\n ...props.callbacks,\n RegisterMethod: (methodName, handler) => {\n if (methodName && handler) {\n methodRegistry.set(methodName, handler);\n }\n }\n };\n }, [props.callbacks]);\n \n // Render the original component with enhanced callbacks\n return React.createElement(DestructureWrapperUserComponent, {\n ...props,\n callbacks: enhancedCallbacks\n });\n };\n \n ComponentWithMethodRegistry.displayName = '${componentName}WithMethods';\n \n // Return the component object with method access\n return {\n component: ComponentWithMethodRegistry,\n \n print: function() { \n const printMethod = methodRegistry.get('print');\n if (printMethod) {\n printMethod();\n } else if (typeof window !== 'undefined' && window.print) {\n window.print(); \n }\n },\n refresh: function(data) { \n const refreshMethod = methodRegistry.get('refresh');\n if (refreshMethod) {\n refreshMethod(data);\n }\n // Refresh functionality is handled by the host environment\n },\n \n // Standard method accessors with type safety\n getCurrentDataState: function() {\n const method = methodRegistry.get('getCurrentDataState');\n return method ? method() : undefined;\n },\n getDataStateHistory: function() {\n const method = methodRegistry.get('getDataStateHistory');\n return method ? method() : [];\n },\n validate: function() {\n const method = methodRegistry.get('validate');\n return method ? method() : true;\n },\n isDirty: function() {\n const method = methodRegistry.get('isDirty');\n return method ? method() : false;\n },\n reset: function() {\n const method = methodRegistry.get('reset');\n if (method) method();\n },\n scrollTo: function(target) {\n const method = methodRegistry.get('scrollTo');\n if (method) method(target);\n },\n focus: function(target) {\n const method = methodRegistry.get('focus');\n if (method) method(target);\n },\n \n // Generic method invoker for custom methods\n invokeMethod: function(methodName, ...args) {\n const method = methodRegistry.get(methodName);\n if (method) {\n return method(...args);\n }\n console.warn(\\`[React-Runtime-JS] Method '\\${methodName}' is not registered on component ${componentName}\\`);\n return undefined;\n },\n \n // Check if a method exists\n hasMethod: function(methodName) {\n return methodRegistry.has(methodName);\n }\n };\n }\n `;\n\n return wrappedCode;\n }\n\n /**\n * Load required libraries from the registry with dependency resolution\n * @param libraries - Array of library dependencies\n * @param componentLibraries - All available component libraries for dependency resolution\n * @returns Map of loaded libraries\n */\n private async loadRequiredLibraries(libraries: any[], componentLibraries: ComponentLibraryEntity[]): Promise<Map<string, any>> {\n const loadedLibraries = new Map<string, any>();\n \n if (this.config.debug) {\n console.log('🔍 loadRequiredLibraries called with:', {\n librariesCount: libraries?.length || 0,\n libraries: libraries?.map(l => ({ name: l.name, version: l.version, globalVariable: l.globalVariable }))\n });\n }\n \n if (!libraries || libraries.length === 0) {\n if (this.config.debug) {\n console.log('📚 No libraries to load, returning empty map');\n }\n return loadedLibraries;\n }\n\n // Only works in browser environment\n if (typeof window === 'undefined') {\n console.warn('Library loading is only supported in browser environments');\n return loadedLibraries;\n }\n\n // Initialize LibraryRegistry with componentLibraries if provided\n if (componentLibraries) {\n await LibraryRegistry.Config(false, componentLibraries);\n } else {\n console.warn('⚠️ No componentLibraries provided for LibraryRegistry initialization');\n }\n\n // Filter out React, ReactDOM, and invalid library entries\n const filteredLibraries = libraries.filter(lib => {\n // Check if library object is valid\n if (!lib || typeof lib !== 'object' || !lib.name) {\n console.warn(`⚠️ Invalid library entry detected (missing name):`, lib);\n return false;\n }\n \n // Filter out entries with 'unknown' name or missing globalVariable\n if (lib.name === 'unknown' || lib.name === 'null' || lib.name === 'undefined') {\n console.warn(`⚠️ Filtering out invalid library with name '${lib.name}':`, lib);\n return false;\n }\n \n // Check for missing or invalid globalVariable\n if (!lib.globalVariable || lib.globalVariable === 'undefined' || lib.globalVariable === 'null') {\n console.warn(`⚠️ Filtering out library '${lib.name}' with invalid globalVariable:`, lib.globalVariable);\n return false;\n }\n \n const libNameLower = lib.name.toLowerCase();\n if (libNameLower === 'react' || libNameLower === 'reactdom') {\n console.warn(`⚠️ Library '${lib.name}' is automatically loaded by the React runtime and should not be requested separately`);\n return false;\n }\n return true;\n });\n \n // Extract library names from the filtered libraries (with extra safety)\n const libraryNames = filteredLibraries\n .map(lib => lib.name)\n .filter(name => name && typeof name === 'string');\n \n if (this.config.debug) {\n console.log('📦 Using dependency-aware loading for libraries:', libraryNames);\n }\n \n // If all libraries were filtered out, return empty map\n if (filteredLibraries.length === 0) {\n if (this.config.debug) {\n console.log('📚 All requested libraries were filtered out (React/ReactDOM), returning empty map');\n }\n return loadedLibraries;\n }\n\n try {\n // Use the new dependency-aware loading\n const loadedLibraryMap = await LibraryLoader.loadLibrariesWithDependencies(\n libraryNames,\n componentLibraries,\n 'component-compiler',\n { debug: this.config.debug }\n );\n\n // Map the results to match the expected format\n // We need to map from library name to global variable\n for (const lib of filteredLibraries) {\n // Check if library is approved first\n const isApproved = LibraryRegistry.isApproved(lib.name);\n if (!isApproved) {\n console.error(`❌ Library '${lib.name}' is not approved`);\n throw new Error(`Library '${lib.name}' is not approved. Only approved libraries can be used.`);\n }\n\n // Get the loaded library from the map\n const loadedValue = loadedLibraryMap.get(lib.name);\n \n if (loadedValue) {\n // Store by global variable name for component access\n loadedLibraries.set(lib.globalVariable, loadedValue);\n if (this.config.debug) {\n console.log(`✅ Mapped ${lib.name} to global variable ${lib.globalVariable}`);\n }\n } else {\n // Fallback: check if it's already globally available (might be a dependency)\n const globalValue = (window as any)[lib.globalVariable];\n if (globalValue) {\n loadedLibraries.set(lib.globalVariable, globalValue);\n if (this.config.debug) {\n console.log(`✅ Found ${lib.name} already loaded as ${lib.globalVariable}`);\n }\n } else {\n console.error(`❌ Library '${lib.name}' failed to load`);\n throw new Error(`Library '${lib.name}' failed to load or did not expose '${lib.globalVariable}'`);\n }\n }\n }\n } catch (error: any) {\n console.error('Failed to load libraries with dependencies:', error);\n \n // Fallback to old loading method if dependency resolution fails\n if (this.config.debug) {\n console.warn('⚠️ Falling back to non-dependency-aware loading due to error');\n }\n \n // Load each library independently (old method)\n for (const lib of libraries) {\n if ((window as any)[lib.globalVariable]) {\n loadedLibraries.set(lib.globalVariable, (window as any)[lib.globalVariable]);\n } else {\n // Try to load using LibraryRegistry\n const libraryDef = LibraryRegistry.getLibrary(lib.name);\n if (libraryDef) {\n const resolvedVersion = LibraryRegistry.resolveVersion(lib.name, lib.version);\n const cdnUrl = LibraryRegistry.getCdnUrl(lib.name, resolvedVersion);\n \n if (cdnUrl) {\n await this.loadScript(cdnUrl, lib.globalVariable);\n const libraryValue = (window as any)[lib.globalVariable];\n if (libraryValue) {\n loadedLibraries.set(lib.globalVariable, libraryValue);\n }\n }\n }\n }\n }\n }\n \n if (this.config.debug) {\n console.log(`✅ All libraries loaded successfully. Total: ${loadedLibraries.size}`);\n console.log('📚 Loaded libraries map:', Array.from(loadedLibraries.keys()));\n }\n \n return loadedLibraries;\n }\n\n /**\n * Load CSS stylesheets dynamically\n * @param urls - Array of CSS URLs to load\n * @returns Promise that resolves when all stylesheets are loaded\n */\n private async loadStyles(urls: string[]): Promise<void> {\n const loadPromises = urls.map(url => {\n return new Promise<void>((resolve) => {\n // Check if stylesheet already exists\n const existingLink = document.querySelector(`link[href=\"${url}\"]`);\n if (existingLink) {\n resolve();\n return;\n }\n\n // Create new link element\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = url;\n \n // CSS load events are not reliable cross-browser, so resolve immediately\n // The CSS will load asynchronously but won't block component rendering\n document.head.appendChild(link);\n resolve();\n });\n });\n\n await Promise.all(loadPromises);\n }\n\n /**\n * Load a script dynamically\n * @param url - Script URL\n * @param globalName - Expected global variable name\n * @returns Promise that resolves when script is loaded\n */\n private loadScript(url: string, globalName: string): Promise<void> {\n return new Promise((resolve, reject) => {\n // Check if script already exists\n const existingScript = document.querySelector(`script[src=\"${url}\"]`);\n if (existingScript) {\n // Wait for it to finish loading with exponential backoff\n let attempts = 0;\n const maxAttempts = 50; // 5 seconds total with 100ms intervals\n const checkLoaded = () => {\n if ((window as any)[globalName]) {\n resolve();\n } else if (attempts >= maxAttempts) {\n reject(new Error(`${globalName} not found after ${maxAttempts * 100}ms waiting for existing script`));\n } else {\n attempts++;\n setTimeout(checkLoaded, 100);\n }\n };\n checkLoaded();\n return;\n }\n\n // Create new script element\n const script = document.createElement('script');\n script.src = url;\n script.async = true;\n \n script.onload = () => {\n // More robust checking with multiple attempts\n let attempts = 0;\n const maxAttempts = 20; // 2 seconds total\n const checkInterval = 100; // Check every 100ms\n \n const checkGlobal = () => {\n if ((window as any)[globalName]) {\n if (this.config.debug) {\n console.log(` ✓ Global variable ${globalName} found after ${attempts * checkInterval}ms`);\n }\n resolve();\n } else if (attempts >= maxAttempts) {\n // Final check - some libraries might use a different global name pattern\n if (this.config.debug) {\n console.error(` ❌ ${globalName} not found after ${attempts * checkInterval}ms`);\n // Only log matching property names, not the entire window object\n const matchingKeys = Object.keys(window).filter(k => k.toLowerCase().includes(globalName.toLowerCase()));\n console.log(` ℹ️ Matching window properties: ${matchingKeys.join(', ') || 'none'}`);\n }\n reject(new Error(`${globalName} not found after loading script from ${url}`));\n } else {\n attempts++;\n setTimeout(checkGlobal, checkInterval);\n }\n };\n \n // Start checking immediately (don't wait 100ms first)\n checkGlobal();\n };\n \n script.onerror = () => {\n reject(new Error(`Failed to load script: ${url}`));\n };\n \n document.head.appendChild(script);\n });\n }\n\n /**\n * Creates a component factory function from transpiled code\n * @param transpiledCode - Transpiled JavaScript code\n * @param componentName - Name of the component\n * @param loadedLibraries - Map of loaded libraries\n * @param options - Compile options containing spec and other metadata\n * @returns Component factory function\n */\n private createComponentFactory(\n transpiledCode: string, \n componentName: string,\n loadedLibraries: Map<string, any>,\n options: CompileOptions\n ): (context: RuntimeContext, styles?: ComponentStyles) => ComponentObject {\n try {\n // Create the factory function with all React hooks and utility functions\n const factoryCreator = new Function(\n 'React', 'ReactDOM',\n 'useState', 'useEffect', 'useCallback', 'useMemo', 'useRef', 'useContext', 'useReducer', 'useLayoutEffect',\n 'libraries', 'styles', 'console', 'components',\n 'unwrapLibraryComponent', 'unwrapLibraryComponents', 'unwrapAllLibraryComponents',\n `${transpiledCode}; return createComponent;`\n );\n\n // Return a function that executes the factory with runtime context\n return (context: RuntimeContext, styles: any = {}, components: Record<string, any> = {}) => {\n const { React, ReactDOM, libraries = {} } = context;\n \n // Diagnostic: Check if React is null when creating component\n if (!React) {\n console.error('🔴 CRITICAL: React is NULL in createComponentFactory!');\n console.error('Context provided:', context);\n console.error('Context keys:', Object.keys(context));\n throw new Error('React is null in runtime context when creating component factory');\n }\n \n // Additional diagnostic for React hooks\n if (!React.useState || !React.useEffect) {\n console.error('🔴 CRITICAL: React hooks are missing!');\n console.error('React object keys:', React ? Object.keys(React) : 'React is null');\n console.error('useState:', typeof React?.useState);\n console.error('useEffect:', typeof React?.useEffect);\n }\n \n // Merge loaded libraries with context libraries\n // IMPORTANT: Only include libraries that are NOT dependency-only\n // We need to filter based on the libraries array from options\n const mergedLibraries = { ...libraries };\n \n // Only add libraries that are explicitly requested in the component\n // This prevents dependency-only libraries from being accessible\n const specLibraryNames = new Set(\n (options.libraries || []).map((lib: any) => lib.globalVariable).filter(Boolean)\n );\n \n loadedLibraries.forEach((value, key) => {\n // Only add if this library is in the spec (not just a dependency)\n if (specLibraryNames.has(key)) {\n mergedLibraries[key] = value;\n } else if (this.config.debug) {\n console.log(`⚠️ Filtering out dependency-only library: ${key}`);\n }\n });\n\n // Create bound versions of unwrap functions with debug flag\n const boundUnwrapLibraryComponent = (lib: any, name: string) => unwrapLibraryComponent(lib, name, this.config.debug);\n const boundUnwrapLibraryComponents = (lib: any, ...names: string[]) => unwrapLibraryComponents(lib, ...names, this.config.debug as any);\n const boundUnwrapAllLibraryComponents = (lib: any) => unwrapAllLibraryComponents(lib, this.config.debug);\n\n // Execute the factory creator to get the createComponent function\n let createComponentFn;\n try {\n createComponentFn = factoryCreator(\n React,\n ReactDOM,\n React.useState,\n React.useEffect,\n React.useCallback,\n React.useMemo,\n React.useRef,\n React.useContext,\n React.useReducer,\n React.useLayoutEffect,\n mergedLibraries,\n styles,\n console,\n components,\n boundUnwrapLibraryComponent,\n boundUnwrapLibraryComponents,\n boundUnwrapAllLibraryComponents\n );\n } catch (error: any) {\n console.error('🔴 CRITICAL: Error calling factoryCreator with React hooks!');\n console.error('Error:', error?.message || error);\n console.error('React is:', React);\n console.error('React type:', typeof React);\n if (React) {\n console.error('React.useState:', typeof React.useState);\n console.error('React.useEffect:', typeof React.useEffect);\n }\n throw new Error(`Failed to create component factory: ${error?.message || error}`);\n }\n\n // Call createComponent to get the actual component\n const Component = createComponentFn(\n React,\n ReactDOM,\n React.useState,\n React.useEffect,\n React.useCallback,\n React.useMemo,\n React.useRef,\n React.useContext,\n React.useReducer,\n React.useLayoutEffect,\n mergedLibraries,\n styles,\n console,\n components,\n boundUnwrapLibraryComponent,\n boundUnwrapLibraryComponents,\n boundUnwrapAllLibraryComponents\n );\n\n // Return the component directly\n return Component;\n };\n } catch (error: any) {\n throw new Error(`Failed to create component factory: ${error.message}`);\n }\n }\n\n\n /**\n * Validates compilation options\n * @param options - Options to validate\n * @throws Error if validation fails\n */\n private validateCompileOptions(options: CompileOptions): void {\n // Check if options object exists\n if (!options) {\n throw new Error(\n 'Component compilation failed: No options provided.\\n' +\n 'Expected an object with componentName and componentCode properties.\\n' +\n 'Example: { componentName: \"MyComponent\", componentCode: \"function MyComponent() { ... }\" }'\n );\n }\n\n // Check component name\n if (!options.componentName) {\n const providedKeys = Object.keys(options).join(', ');\n throw new Error(\n 'Component compilation failed: Component name is required.\\n' +\n `Received options with keys: [${providedKeys}]\\n` +\n 'Please ensure your component spec includes a \"name\" property.\\n' +\n 'Example: { name: \"MyComponent\", code: \"...\" }'\n );\n }\n\n // Check component code\n if (!options.componentCode) {\n throw new Error(\n `Component compilation failed: Component code is required for \"${options.componentName}\".\\n` +\n 'Please ensure your component spec includes a \"code\" property with the component source code.\\n' +\n 'Example: { name: \"MyComponent\", code: \"function MyComponent() { return <div>Hello</div>; }\" }'\n );\n }\n\n // Check code type\n if (typeof options.componentCode !== 'string') {\n const actualType = typeof options.componentCode;\n throw new Error(\n `Component compilation failed: Component code must be a string for \"${options.componentName}\".\\n` +\n `Received type: ${actualType}\\n` +\n `Received value: ${JSON.stringify(options.componentCode).substring(0, 100)}...\\n` +\n 'Please ensure the code property contains a string of JavaScript/JSX code.'\n );\n }\n\n // Check if code is empty or whitespace only\n if (options.componentCode.trim().length === 0) {\n throw new Error(\n `Component compilation failed: Component code is empty for \"${options.componentName}\".\\n` +\n 'The code property must contain valid JavaScript/JSX code defining a React component.'\n );\n }\n\n // Basic syntax check\n if (!options.componentCode.includes(options.componentName)) {\n throw new Error(\n `Component compilation failed: Component code must define a component named \"${options.componentName}\".\\n` +\n 'The function/component name in the code must match the componentName property.\\n' +\n `Expected to find: function ${options.componentName}(...) or const ${options.componentName} = ...\\n` +\n 'Code preview: ' + options.componentCode.substring(0, 200) + '...'\n );\n }\n }\n\n /**\n * Generates a unique component ID\n * @param componentName - Name of the component\n * @returns Unique component ID\n */\n private generateComponentId(componentName: string): string {\n return `${componentName}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;\n }\n\n /**\n * Gets a cached component if available\n * @param componentName - Name of the component\n * @param code - Component source code\n * @returns Cached component or undefined\n */\n private getCachedComponent(componentName: string, code: string): CompiledComponent | undefined {\n // Create cache key based on name AND content hash\n const cacheKey = this.createCacheKey(componentName, code);\n return this.compilationCache.get(cacheKey);\n }\n\n /**\n * Creates a cache key based on component name and code content\n * @param componentName - Name of the component\n * @param code - Component source code\n * @returns Cache key\n */\n private createCacheKey(componentName: string, code: string): string {\n // Simple hash function for code content\n let hash = 0;\n for (let i = 0; i < code.length; i++) {\n const char = code.charCodeAt(i);\n hash = ((hash << 5) - hash) + char;\n hash = hash & hash; // Convert to 32-bit integer\n }\n return `${componentName}_${hash.toString(36)}`;\n }\n\n /**\n * Caches a compiled component\n * @param component - Component to cache\n * @param code - Original source code\n */\n private cacheComponent(component: CompiledComponent, code: string): void {\n // Enforce cache size limit\n if (this.compilationCache.size >= this.config.maxCacheSize) {\n // Remove oldest entry (first in map)\n const firstKey = this.compilationCache.keys().next().value;\n if (firstKey)\n this.compilationCache.delete(firstKey);\n }\n\n const cacheKey = this.createCacheKey(component.name, code);\n this.compilationCache.set(cacheKey, component);\n }\n\n /**\n * Creates a standardized compilation error\n * @param error - Original error\n * @param componentName - Name of the component\n * @returns Formatted component error\n */\n private createCompilationError(error: any, componentName: string): ComponentError {\n return {\n message: error.message || 'Unknown compilation error',\n stack: error.stack,\n componentName,\n phase: 'compilation',\n details: error\n };\n }\n\n /**\n * Clears the compilation cache\n */\n clearCache(): void {\n this.compilationCache.clear();\n }\n\n /**\n * Gets current cache size\n * @returns Number of cached components\n */\n getCacheSize(): number {\n return this.compilationCache.size;\n }\n\n /**\n * Updates compiler configuration\n * @param config - New configuration options\n */\n updateConfig(config: Partial<CompilerConfig>): void {\n this.config = { ...this.config, ...config };\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"component-compiler.js","sourceRoot":"","sources":["../../src/compiler/component-compiler.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAM/H,MAAM,uBAAuB,GAAmB;IAC9C,KAAK,EAAE;QACL,OAAO,EAAE,CAAC,OAAO,CAAC;QAClB,OAAO,EAAE,EAAE;KACZ;IACD,MAAM,EAAE,KAAK;IACb,UAAU,EAAE,KAAK;IACjB,KAAK,EAAE,IAAI;IACX,YAAY,EAAE,GAAG;IACjB,KAAK,EAAE,KAAK;CACb,CAAC;AAMF,MAAM,OAAO,iBAAiB;IAU5B,YAAY,MAAgC;QAgI3B,mBAAc,GAAG,IAAI,GAAG,CA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OAAO;YACL,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,2BAA2B;YACrD,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,aAAa;YACb,KAAK,EAAE,aAAa;YACpB,OAAO,EAAE,KAAK;SACf,CAAC;IACJ,CAAC;IAKD,UAAU;QACR,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;IAMD,YAAY;QACV,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC;IACpC,CAAC;IAMD,YAAY,CAAC,MAA+B;QAC1C,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IAC9C,CAAC;CACF","sourcesContent":["/**\n * @fileoverview Platform-agnostic React component compiler.\n * Compiles React component source code into executable components using Babel.\n * @module @memberjunction/react-runtime/compiler\n */\n\nimport { UserInfo } from '@memberjunction/core';\nimport { \n CompileOptions, \n CompiledComponent, \n CompilationResult,\n CompilerConfig,\n ComponentError,\n RuntimeContext\n} from '../types';\nimport { ComponentStyles, ComponentObject } from '@memberjunction/interactive-component-types';\nimport { LibraryRegistry } from '../utilities/library-registry';\nimport { LibraryLoader } from '../utilities/library-loader';\nimport { unwrapLibraryComponent, unwrapLibraryComponents, unwrapAllLibraryComponents } from '../utilities/component-unwrapper';\nimport { MJComponentLibraryEntity } from '@memberjunction/core-entities';\n\n/**\n * Default compiler configuration\n */\nconst DEFAULT_COMPILER_CONFIG: CompilerConfig = {\n babel: {\n presets: ['react'],\n plugins: []\n },\n minify: false,\n sourceMaps: false,\n cache: true,\n maxCacheSize: 100,\n debug: false\n};\n\n/**\n * Platform-agnostic React component compiler.\n * Transforms JSX/React component source code into executable JavaScript.\n */\nexport class ComponentCompiler {\n private config: CompilerConfig;\n private compilationCache: Map<string, CompiledComponent>;\n private cacheAccessOrder: string[]; // Track access order for LRU\n private babelInstance: any;\n\n /**\n * Creates a new ComponentCompiler instance\n * @param config - Optional compiler configuration\n */\n constructor(config?: Partial<CompilerConfig>) {\n this.config = { ...DEFAULT_COMPILER_CONFIG, ...config };\n this.compilationCache = new Map();\n }\n\n /**\n * Sets the Babel instance to use for compilation\n * @param babel - The Babel standalone instance\n */\n setBabelInstance(babel: any): void {\n this.babelInstance = babel;\n }\n\n /**\n * Compiles a React component from source code\n * @param options - Compilation options\n * @returns Promise resolving to compilation result\n */\n async compile(options: CompileOptions): Promise<CompilationResult> {\n const startTime = Date.now();\n\n try {\n // Check cache first if enabled\n if (this.config.cache) {\n const cached = this.getCachedComponent(options.componentName, options.componentCode);\n if (cached) {\n return {\n success: true,\n component: cached,\n duration: Date.now() - startTime\n };\n }\n }\n\n // Validate inputs\n this.validateCompileOptions(options);\n\n // Load required libraries if specified\n const loadedLibraries = await this.loadRequiredLibraries(options.libraries!, options.allLibraries);\n\n // Transpile the component code\n const transpiledCode = this.transpileComponent(\n options.componentCode,\n options.componentName,\n options\n );\n\n // Create the component factory with loaded libraries\n const componentFactory = this.createComponentFactory(\n transpiledCode,\n options.componentName,\n loadedLibraries,\n options\n );\n\n // Build the compiled component\n const compiledComponent: CompiledComponent = {\n factory: componentFactory,\n id: this.generateComponentId(options.componentName),\n name: options.componentName,\n compiledAt: new Date(),\n warnings: []\n };\n\n // Cache if enabled\n if (this.config.cache) {\n this.cacheComponent(compiledComponent, options.componentCode);\n }\n\n return {\n success: true,\n component: compiledComponent,\n duration: Date.now() - startTime,\n size: transpiledCode.length,\n loadedLibraries: loadedLibraries\n };\n\n } catch (error) {\n return {\n success: false,\n error: this.createCompilationError(error, options.componentName),\n duration: Date.now() - startTime\n };\n }\n }\n\n /**\n * Transpiles JSX/React code to JavaScript\n * @param code - Source code to transpile\n * @param componentName - Name of the component\n * @param options - Compilation options\n * @returns Transpiled JavaScript code\n */\n private transpileComponent(\n code: string,\n componentName: string,\n options: CompileOptions\n ): string {\n if (!this.babelInstance) {\n throw new Error('Babel instance not set. Call setBabelInstance() first.');\n }\n\n const wrappedCode = this.wrapComponentCode(code, componentName, options.libraries, options.dependencies);\n\n try {\n const result = this.babelInstance.transform(wrappedCode, {\n presets: options.babelPresets || this.config.babel.presets,\n plugins: options.babelPlugins || this.config.babel.plugins,\n filename: `${componentName}.jsx`,\n sourceMaps: this.config.sourceMaps,\n minified: this.config.minify\n });\n\n return result.code;\n } catch (error: any) {\n throw new Error(`Transpilation failed: ${error.message}`);\n }\n }\n\n /**\n * Wraps component code in a factory function for execution\n * @param componentCode - Raw component code\n * @param componentName - Name of the component\n * @param libraries - Optional library dependencies\n * @param dependencies - Optional child component dependencies\n * @returns Wrapped component code\n */\n // Core libraries that are passed as parameters to createComponent and should not be destructured\n private readonly CORE_LIBRARIES = new Set(['React', 'ReactDOM']);\n\n private wrapComponentCode(componentCode: string, componentName: string, libraries?: any[], dependencies?: Array<{ name: string }>): string {\n const debug = this.config.debug;\n // Generate library declarations if libraries are provided\n // Skip core libraries as they're passed as parameters to createComponent\n const libraryDeclarations = libraries && libraries.length > 0\n ? libraries\n .filter(lib => lib.globalVariable && !this.CORE_LIBRARIES.has(lib.globalVariable)) // Skip core libraries\n .map(lib => `const ${lib.globalVariable} = libraries['${lib.globalVariable}'];`)\n .join('\\n ')\n : '';\n const libraryLogChecks = libraries && libraries.length > 0 \n ? libraries\n .filter(lib => lib.globalVariable && !this.CORE_LIBRARIES.has(lib.globalVariable)) // Skip core libraries\n .map(lib => `\\nif (!${lib.globalVariable}) { console.error('[React-Runtime-JS] Library \"${lib.globalVariable}\" is not defined'); } else { ${debug ? `console.log('[React-Runtime-JS] Library \"${lib.globalVariable}\" is defined');` : ''} }`)\n .join('\\n ')\n : '';\n\n // Generate component declarations if dependencies are provided\n // Filter out the component being compiled to avoid naming conflicts\n // Also detect and warn about duplicates\n const seenDependencies = new Set<string>();\n const uniqueDependencies: Array<{ name: string; code?: string }> = [];\n const duplicates: string[] = [];\n \n if (dependencies && dependencies.length > 0) {\n for (const dep of dependencies) {\n if (dep.name === componentName) {\n // Skip the component being compiled itself\n continue;\n }\n if (seenDependencies.has(dep.name)) {\n duplicates.push(dep.name);\n } else {\n seenDependencies.add(dep.name);\n uniqueDependencies.push(dep);\n }\n }\n }\n \n // Generate warning for duplicates\n const duplicateWarnings = duplicates.length > 0\n ? duplicates\n .map(name => `console.warn('[React-Runtime-JS] WARNING: Component \"${name}\" is registered multiple times as a dependency. Using first occurrence only.');`)\n .join('\\n ')\n : '';\n \n const componentDeclarations = uniqueDependencies.length > 0\n ? uniqueDependencies\n .map(dep => `const ${dep.name}Raw = componentsOuter['${dep.name}'];\n ${debug ? `console.log('[React-Runtime-JS] Extracting ${dep.name}:');\n console.log(' - Raw value type:', typeof ${dep.name}Raw);\n console.log(' - Raw value:', ${dep.name}Raw);\n if (${dep.name}Raw && typeof ${dep.name}Raw === 'object') {\n console.log(' - Has .component property:', 'component' in ${dep.name}Raw);\n console.log(' - .component type:', typeof ${dep.name}Raw.component);\n }` : ''}\n const ${dep.name} = ${dep.name}Raw?.component || ${dep.name}Raw;\n ${debug ? `console.log(' - Final ${dep.name} type:', typeof ${dep.name});\n console.log(' - Final ${dep.name} is function:', typeof ${dep.name} === 'function');` : ''}`)\n .join('\\n ')\n : '';\n \n const componentLogChecks = uniqueDependencies.length > 0\n ? uniqueDependencies\n .map(dep => `if (!${dep.name}) { console.error('[React-Runtime-JS] Dependency \"${dep.name}\" is not defined'); } else { ${debug ? `console.log('[React-Runtime-JS] Dependency \"${dep.name}\" is defined');` : ''} }`)\n .join('\\n ')\n : '';\n \n\n const wrappedCode = `\n function createComponent(\n React, ReactDOM, \n useState, useEffect, useCallback, useMemo, useRef, useContext, useReducer, useLayoutEffect,\n libraries, styles, console, components,\n unwrapLibraryComponent, unwrapLibraryComponents, unwrapAllLibraryComponents\n ) {\n if (!React)\n console.log('[React-Runtime-JS] React is not defined');\n if (!ReactDOM)\n console.log('[React-Runtime-JS] ReactDOM is not defined');\n\n // Make unwrap functions available with legacy names for backward compatibility\n const unwrapComponent = unwrapLibraryComponent;\n const unwrapComponents = unwrapLibraryComponents;\n const unwrapAllComponents = unwrapAllLibraryComponents;\n \n // Code for ${componentName}\n ${componentCode}\n \n // Ensure the component exists\n if (typeof ${componentName} === 'undefined') {\n throw new Error('Component \"${componentName}\" is not defined in the provided code');\n }\n else {\n ${debug ? `console.log('[React-Runtime-JS] Component \"${componentName}\" is defined');` : ''}\n }\n \n // Store the component in a variable so we don't lose it\n const UserComponent = ${componentName};\n\n // Check if the component is already a ComponentObject (has a .component property)\n // If so, extract the actual React component\n const ActualComponent = (typeof UserComponent === 'object' && UserComponent !== null && 'component' in UserComponent)\n ? UserComponent.component\n : UserComponent;\n \n // Debug logging to understand what we're getting\n ${debug ? `\n console.log('[React-Runtime-JS]Component ${componentName} type:', typeof UserComponent);\n if (typeof UserComponent === 'object' && UserComponent !== null) {\n console.log('[React-Runtime-JS]Component ${componentName} keys:', Object.keys(UserComponent));\n console.log('[React-Runtime-JS]Component ${componentName} has .component:', 'component' in UserComponent);\n if ('component' in UserComponent) {\n console.log('[React-Runtime-JS]Component ${componentName}.component type:', typeof UserComponent.component);\n }\n }` : ''}\n \n // Validate that we have a function (React component)\n if (typeof ActualComponent !== 'function') {\n console.error('[React-Runtime-JS] Invalid component type for ${componentName}:', typeof ActualComponent);\n console.error('[React-Runtime-JS] ActualComponent value:', ActualComponent);\n console.error('[React-Runtime-JS] Original UserComponent value:', UserComponent);\n throw new Error('[React-Runtime-JS] Component \"${componentName}\" must be a function (React component) or an object with a .component property that is a function. Got: ' + typeof ActualComponent);\n }\n\n let componentsOuter = null, utilitiesOuter = null;\n const DestructureWrapperUserComponent = (props) => {\n if (!componentsOuter) {\n componentsOuter = props?.components || components;\n }\n if (!utilitiesOuter) {\n utilitiesOuter = props?.utilities;\n }\n ${debug ? `\n console.log('[React-Runtime-JS] DestructureWrapperUserComponent for ${componentName}:');\n console.log(' - Props:', props);\n console.log(' - componentsOuter type:', typeof componentsOuter);\n console.log(' - componentsOuter:', componentsOuter);\n if (componentsOuter && typeof componentsOuter === 'object') {\n console.log(' - componentsOuter keys:', Object.keys(componentsOuter));\n for (const key of Object.keys(componentsOuter)) {\n const comp = componentsOuter[key];\n console.log(\\` - componentsOuter[\\${key}] type:\\`, typeof comp);\n if (comp && typeof comp === 'object') {\n console.log(\\` - Has .component: \\${'component' in comp}\\`);\n console.log(\\` - .component type: \\${typeof comp.component}\\`);\n }\n }\n }\n console.log(' - styles:', styles);\n console.log(' - utilities:', utilitiesOuter);\n console.log(' - libraries:', libraries);` : ''}\n ${duplicateWarnings ? '// Duplicate dependency warnings\\n ' + duplicateWarnings + '\\n ' : ''}\n ${libraryDeclarations ? '// Destructure Libraries\\n' + libraryDeclarations + '\\n ' : ''}\n ${componentDeclarations ? '// Destructure Dependencies\\n' + componentDeclarations + '\\n ' : ''}\n ${libraryLogChecks}\n ${componentLogChecks} \n\n const newProps = {\n ...props,\n components: componentsOuter,\n utilities: utilitiesOuter \n }\n return ActualComponent(newProps);\n };\n \n // Create a fresh method registry for each factory call\n const methodRegistry = new Map();\n \n // Create a wrapper component that provides RegisterMethod in callbacks\n const ComponentWithMethodRegistry = (props) => {\n // Register methods on mount\n React.useEffect(() => {\n // Clear previous methods\n methodRegistry.clear();\n \n // Provide RegisterMethod callback if callbacks exist\n if (props.callbacks && typeof props.callbacks.RegisterMethod === 'function') {\n // Component can now register its methods\n // This will be called from within the component\n }\n }, [props.callbacks]);\n \n // Create enhanced callbacks with RegisterMethod\n const enhancedCallbacks = React.useMemo(() => {\n if (!props.callbacks) return {};\n \n return {\n ...props.callbacks,\n RegisterMethod: (methodName, handler) => {\n if (methodName && handler) {\n methodRegistry.set(methodName, handler);\n }\n }\n };\n }, [props.callbacks]);\n \n // Render the original component with enhanced callbacks\n return React.createElement(DestructureWrapperUserComponent, {\n ...props,\n callbacks: enhancedCallbacks\n });\n };\n \n ComponentWithMethodRegistry.displayName = '${componentName}WithMethods';\n \n // Return the component object with method access\n return {\n component: ComponentWithMethodRegistry,\n \n print: function() { \n const printMethod = methodRegistry.get('print');\n if (printMethod) {\n printMethod();\n } else if (typeof window !== 'undefined' && window.print) {\n window.print(); \n }\n },\n refresh: function(data) { \n const refreshMethod = methodRegistry.get('refresh');\n if (refreshMethod) {\n refreshMethod(data);\n }\n // Refresh functionality is handled by the host environment\n },\n \n // Standard method accessors with type safety\n getCurrentDataState: function() {\n const method = methodRegistry.get('getCurrentDataState');\n return method ? method() : undefined;\n },\n getDataStateHistory: function() {\n const method = methodRegistry.get('getDataStateHistory');\n return method ? method() : [];\n },\n validate: function() {\n const method = methodRegistry.get('validate');\n return method ? method() : true;\n },\n isDirty: function() {\n const method = methodRegistry.get('isDirty');\n return method ? method() : false;\n },\n reset: function() {\n const method = methodRegistry.get('reset');\n if (method) method();\n },\n scrollTo: function(target) {\n const method = methodRegistry.get('scrollTo');\n if (method) method(target);\n },\n focus: function(target) {\n const method = methodRegistry.get('focus');\n if (method) method(target);\n },\n \n // Generic method invoker for custom methods\n invokeMethod: function(methodName, ...args) {\n const method = methodRegistry.get(methodName);\n if (method) {\n return method(...args);\n }\n console.warn(\\`[React-Runtime-JS] Method '\\${methodName}' is not registered on component ${componentName}\\`);\n return undefined;\n },\n \n // Check if a method exists\n hasMethod: function(methodName) {\n return methodRegistry.has(methodName);\n }\n };\n }\n `;\n\n return wrappedCode;\n }\n\n /**\n * Load required libraries from the registry with dependency resolution\n * @param libraries - Array of library dependencies\n * @param componentLibraries - All available component libraries for dependency resolution\n * @returns Map of loaded libraries\n */\n private async loadRequiredLibraries(libraries: any[], componentLibraries: MJComponentLibraryEntity[]): Promise<Map<string, any>> {\n const loadedLibraries = new Map<string, any>();\n \n if (this.config.debug) {\n console.log('🔍 loadRequiredLibraries called with:', {\n librariesCount: libraries?.length || 0,\n libraries: libraries?.map(l => ({ name: l.name, version: l.version, globalVariable: l.globalVariable }))\n });\n }\n \n if (!libraries || libraries.length === 0) {\n if (this.config.debug) {\n console.log('📚 No libraries to load, returning empty map');\n }\n return loadedLibraries;\n }\n\n // Only works in browser environment\n if (typeof window === 'undefined') {\n console.warn('Library loading is only supported in browser environments');\n return loadedLibraries;\n }\n\n // Initialize LibraryRegistry with componentLibraries if provided\n if (componentLibraries) {\n await LibraryRegistry.Config(false, componentLibraries);\n } else {\n console.warn('⚠️ No componentLibraries provided for LibraryRegistry initialization');\n }\n\n // Filter out React, ReactDOM, and invalid library entries\n const filteredLibraries = libraries.filter(lib => {\n // Check if library object is valid\n if (!lib || typeof lib !== 'object' || !lib.name) {\n console.warn(`⚠️ Invalid library entry detected (missing name):`, lib);\n return false;\n }\n \n // Filter out entries with 'unknown' name or missing globalVariable\n if (lib.name === 'unknown' || lib.name === 'null' || lib.name === 'undefined') {\n console.warn(`⚠️ Filtering out invalid library with name '${lib.name}':`, lib);\n return false;\n }\n \n // Check for missing or invalid globalVariable\n if (!lib.globalVariable || lib.globalVariable === 'undefined' || lib.globalVariable === 'null') {\n console.warn(`⚠️ Filtering out library '${lib.name}' with invalid globalVariable:`, lib.globalVariable);\n return false;\n }\n \n const libNameLower = lib.name.toLowerCase();\n if (libNameLower === 'react' || libNameLower === 'reactdom') {\n console.warn(`⚠️ Library '${lib.name}' is automatically loaded by the React runtime and should not be requested separately`);\n return false;\n }\n return true;\n });\n \n // Extract library names from the filtered libraries (with extra safety)\n const libraryNames = filteredLibraries\n .map(lib => lib.name)\n .filter(name => name && typeof name === 'string');\n \n if (this.config.debug) {\n console.log('📦 Using dependency-aware loading for libraries:', libraryNames);\n }\n \n // If all libraries were filtered out, return empty map\n if (filteredLibraries.length === 0) {\n if (this.config.debug) {\n console.log('📚 All requested libraries were filtered out (React/ReactDOM), returning empty map');\n }\n return loadedLibraries;\n }\n\n try {\n // Use the new dependency-aware loading\n const loadedLibraryMap = await LibraryLoader.loadLibrariesWithDependencies(\n libraryNames,\n componentLibraries,\n 'component-compiler',\n { debug: this.config.debug }\n );\n\n // Map the results to match the expected format\n // We need to map from library name to global variable\n for (const lib of filteredLibraries) {\n // Check if library is approved first\n const isApproved = LibraryRegistry.isApproved(lib.name);\n if (!isApproved) {\n console.error(`❌ Library '${lib.name}' is not approved`);\n throw new Error(`Library '${lib.name}' is not approved. Only approved libraries can be used.`);\n }\n\n // Get the loaded library from the map\n const loadedValue = loadedLibraryMap.get(lib.name);\n \n if (loadedValue) {\n // Store by global variable name for component access\n loadedLibraries.set(lib.globalVariable, loadedValue);\n if (this.config.debug) {\n console.log(`✅ Mapped ${lib.name} to global variable ${lib.globalVariable}`);\n }\n } else {\n // Fallback: check if it's already globally available (might be a dependency)\n const globalValue = (window as any)[lib.globalVariable];\n if (globalValue) {\n loadedLibraries.set(lib.globalVariable, globalValue);\n if (this.config.debug) {\n console.log(`✅ Found ${lib.name} already loaded as ${lib.globalVariable}`);\n }\n } else {\n console.error(`❌ Library '${lib.name}' failed to load`);\n throw new Error(`Library '${lib.name}' failed to load or did not expose '${lib.globalVariable}'`);\n }\n }\n }\n } catch (error: any) {\n console.error('Failed to load libraries with dependencies:', error);\n \n // Fallback to old loading method if dependency resolution fails\n if (this.config.debug) {\n console.warn('⚠️ Falling back to non-dependency-aware loading due to error');\n }\n \n // Load each library independently (old method)\n for (const lib of libraries) {\n if ((window as any)[lib.globalVariable]) {\n loadedLibraries.set(lib.globalVariable, (window as any)[lib.globalVariable]);\n } else {\n // Try to load using LibraryRegistry\n const libraryDef = LibraryRegistry.getLibrary(lib.name);\n if (libraryDef) {\n const resolvedVersion = LibraryRegistry.resolveVersion(lib.name, lib.version);\n const cdnUrl = LibraryRegistry.getCdnUrl(lib.name, resolvedVersion);\n \n if (cdnUrl) {\n await this.loadScript(cdnUrl, lib.globalVariable);\n const libraryValue = (window as any)[lib.globalVariable];\n if (libraryValue) {\n loadedLibraries.set(lib.globalVariable, libraryValue);\n }\n }\n }\n }\n }\n }\n \n if (this.config.debug) {\n console.log(`✅ All libraries loaded successfully. Total: ${loadedLibraries.size}`);\n console.log('📚 Loaded libraries map:', Array.from(loadedLibraries.keys()));\n }\n \n return loadedLibraries;\n }\n\n /**\n * Load CSS stylesheets dynamically\n * @param urls - Array of CSS URLs to load\n * @returns Promise that resolves when all stylesheets are loaded\n */\n private async loadStyles(urls: string[]): Promise<void> {\n const loadPromises = urls.map(url => {\n return new Promise<void>((resolve) => {\n // Check if stylesheet already exists\n const existingLink = document.querySelector(`link[href=\"${url}\"]`);\n if (existingLink) {\n resolve();\n return;\n }\n\n // Create new link element\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = url;\n \n // CSS load events are not reliable cross-browser, so resolve immediately\n // The CSS will load asynchronously but won't block component rendering\n document.head.appendChild(link);\n resolve();\n });\n });\n\n await Promise.all(loadPromises);\n }\n\n /**\n * Load a script dynamically\n * @param url - Script URL\n * @param globalName - Expected global variable name\n * @returns Promise that resolves when script is loaded\n */\n private loadScript(url: string, globalName: string): Promise<void> {\n return new Promise((resolve, reject) => {\n // Check if script already exists\n const existingScript = document.querySelector(`script[src=\"${url}\"]`);\n if (existingScript) {\n // Wait for it to finish loading with exponential backoff\n let attempts = 0;\n const maxAttempts = 50; // 5 seconds total with 100ms intervals\n const checkLoaded = () => {\n if ((window as any)[globalName]) {\n resolve();\n } else if (attempts >= maxAttempts) {\n reject(new Error(`${globalName} not found after ${maxAttempts * 100}ms waiting for existing script`));\n } else {\n attempts++;\n setTimeout(checkLoaded, 100);\n }\n };\n checkLoaded();\n return;\n }\n\n // Create new script element\n const script = document.createElement('script');\n script.src = url;\n script.async = true;\n \n script.onload = () => {\n // More robust checking with multiple attempts\n let attempts = 0;\n const maxAttempts = 20; // 2 seconds total\n const checkInterval = 100; // Check every 100ms\n \n const checkGlobal = () => {\n if ((window as any)[globalName]) {\n if (this.config.debug) {\n console.log(` ✓ Global variable ${globalName} found after ${attempts * checkInterval}ms`);\n }\n resolve();\n } else if (attempts >= maxAttempts) {\n // Final check - some libraries might use a different global name pattern\n if (this.config.debug) {\n console.error(` ❌ ${globalName} not found after ${attempts * checkInterval}ms`);\n // Only log matching property names, not the entire window object\n const matchingKeys = Object.keys(window).filter(k => k.toLowerCase().includes(globalName.toLowerCase()));\n console.log(` ℹ️ Matching window properties: ${matchingKeys.join(', ') || 'none'}`);\n }\n reject(new Error(`${globalName} not found after loading script from ${url}`));\n } else {\n attempts++;\n setTimeout(checkGlobal, checkInterval);\n }\n };\n \n // Start checking immediately (don't wait 100ms first)\n checkGlobal();\n };\n \n script.onerror = () => {\n reject(new Error(`Failed to load script: ${url}`));\n };\n \n document.head.appendChild(script);\n });\n }\n\n /**\n * Creates a component factory function from transpiled code\n * @param transpiledCode - Transpiled JavaScript code\n * @param componentName - Name of the component\n * @param loadedLibraries - Map of loaded libraries\n * @param options - Compile options containing spec and other metadata\n * @returns Component factory function\n */\n private createComponentFactory(\n transpiledCode: string, \n componentName: string,\n loadedLibraries: Map<string, any>,\n options: CompileOptions\n ): (context: RuntimeContext, styles?: ComponentStyles) => ComponentObject {\n try {\n // Create the factory function with all React hooks and utility functions\n const factoryCreator = new Function(\n 'React', 'ReactDOM',\n 'useState', 'useEffect', 'useCallback', 'useMemo', 'useRef', 'useContext', 'useReducer', 'useLayoutEffect',\n 'libraries', 'styles', 'console', 'components',\n 'unwrapLibraryComponent', 'unwrapLibraryComponents', 'unwrapAllLibraryComponents',\n `${transpiledCode}; return createComponent;`\n );\n\n // Return a function that executes the factory with runtime context\n return (context: RuntimeContext, styles: any = {}, components: Record<string, any> = {}) => {\n const { React, ReactDOM, libraries = {} } = context;\n \n // Diagnostic: Check if React is null when creating component\n if (!React) {\n console.error('🔴 CRITICAL: React is NULL in createComponentFactory!');\n console.error('Context provided:', context);\n console.error('Context keys:', Object.keys(context));\n throw new Error('React is null in runtime context when creating component factory');\n }\n \n // Additional diagnostic for React hooks\n if (!React.useState || !React.useEffect) {\n console.error('🔴 CRITICAL: React hooks are missing!');\n console.error('React object keys:', React ? Object.keys(React) : 'React is null');\n console.error('useState:', typeof React?.useState);\n console.error('useEffect:', typeof React?.useEffect);\n }\n \n // Merge loaded libraries with context libraries\n // IMPORTANT: Only include libraries that are NOT dependency-only\n // We need to filter based on the libraries array from options\n const mergedLibraries = { ...libraries };\n \n // Only add libraries that are explicitly requested in the component\n // This prevents dependency-only libraries from being accessible\n const specLibraryNames = new Set(\n (options.libraries || []).map((lib: any) => lib.globalVariable).filter(Boolean)\n );\n \n loadedLibraries.forEach((value, key) => {\n // Only add if this library is in the spec (not just a dependency)\n if (specLibraryNames.has(key)) {\n mergedLibraries[key] = value;\n } else if (this.config.debug) {\n console.log(`⚠️ Filtering out dependency-only library: ${key}`);\n }\n });\n\n // Create bound versions of unwrap functions with debug flag\n const boundUnwrapLibraryComponent = (lib: any, name: string) => unwrapLibraryComponent(lib, name, this.config.debug);\n const boundUnwrapLibraryComponents = (lib: any, ...names: string[]) => unwrapLibraryComponents(lib, ...names, this.config.debug as any);\n const boundUnwrapAllLibraryComponents = (lib: any) => unwrapAllLibraryComponents(lib, this.config.debug);\n\n // Execute the factory creator to get the createComponent function\n let createComponentFn;\n try {\n createComponentFn = factoryCreator(\n React,\n ReactDOM,\n React.useState,\n React.useEffect,\n React.useCallback,\n React.useMemo,\n React.useRef,\n React.useContext,\n React.useReducer,\n React.useLayoutEffect,\n mergedLibraries,\n styles,\n console,\n components,\n boundUnwrapLibraryComponent,\n boundUnwrapLibraryComponents,\n boundUnwrapAllLibraryComponents\n );\n } catch (error: any) {\n console.error('🔴 CRITICAL: Error calling factoryCreator with React hooks!');\n console.error('Error:', error?.message || error);\n console.error('React is:', React);\n console.error('React type:', typeof React);\n if (React) {\n console.error('React.useState:', typeof React.useState);\n console.error('React.useEffect:', typeof React.useEffect);\n }\n throw new Error(`Failed to create component factory: ${error?.message || error}`);\n }\n\n // Call createComponent to get the actual component\n const Component = createComponentFn(\n React,\n ReactDOM,\n React.useState,\n React.useEffect,\n React.useCallback,\n React.useMemo,\n React.useRef,\n React.useContext,\n React.useReducer,\n React.useLayoutEffect,\n mergedLibraries,\n styles,\n console,\n components,\n boundUnwrapLibraryComponent,\n boundUnwrapLibraryComponents,\n boundUnwrapAllLibraryComponents\n );\n\n // Return the component directly\n return Component;\n };\n } catch (error: any) {\n throw new Error(`Failed to create component factory: ${error.message}`);\n }\n }\n\n\n /**\n * Validates compilation options\n * @param options - Options to validate\n * @throws Error if validation fails\n */\n private validateCompileOptions(options: CompileOptions): void {\n // Check if options object exists\n if (!options) {\n throw new Error(\n 'Component compilation failed: No options provided.\\n' +\n 'Expected an object with componentName and componentCode properties.\\n' +\n 'Example: { componentName: \"MyComponent\", componentCode: \"function MyComponent() { ... }\" }'\n );\n }\n\n // Check component name\n if (!options.componentName) {\n const providedKeys = Object.keys(options).join(', ');\n throw new Error(\n 'Component compilation failed: Component name is required.\\n' +\n `Received options with keys: [${providedKeys}]\\n` +\n 'Please ensure your component spec includes a \"name\" property.\\n' +\n 'Example: { name: \"MyComponent\", code: \"...\" }'\n );\n }\n\n // Check component code\n if (!options.componentCode) {\n throw new Error(\n `Component compilation failed: Component code is required for \"${options.componentName}\".\\n` +\n 'Please ensure your component spec includes a \"code\" property with the component source code.\\n' +\n 'Example: { name: \"MyComponent\", code: \"function MyComponent() { return <div>Hello</div>; }\" }'\n );\n }\n\n // Check code type\n if (typeof options.componentCode !== 'string') {\n const actualType = typeof options.componentCode;\n throw new Error(\n `Component compilation failed: Component code must be a string for \"${options.componentName}\".\\n` +\n `Received type: ${actualType}\\n` +\n `Received value: ${JSON.stringify(options.componentCode).substring(0, 100)}...\\n` +\n 'Please ensure the code property contains a string of JavaScript/JSX code.'\n );\n }\n\n // Check if code is empty or whitespace only\n if (options.componentCode.trim().length === 0) {\n throw new Error(\n `Component compilation failed: Component code is empty for \"${options.componentName}\".\\n` +\n 'The code property must contain valid JavaScript/JSX code defining a React component.'\n );\n }\n\n // Basic syntax check\n if (!options.componentCode.includes(options.componentName)) {\n throw new Error(\n `Component compilation failed: Component code must define a component named \"${options.componentName}\".\\n` +\n 'The function/component name in the code must match the componentName property.\\n' +\n `Expected to find: function ${options.componentName}(...) or const ${options.componentName} = ...\\n` +\n 'Code preview: ' + options.componentCode.substring(0, 200) + '...'\n );\n }\n }\n\n /**\n * Generates a unique component ID\n * @param componentName - Name of the component\n * @returns Unique component ID\n */\n private generateComponentId(componentName: string): string {\n return `${componentName}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;\n }\n\n /**\n * Gets a cached component if available\n * @param componentName - Name of the component\n * @param code - Component source code\n * @returns Cached component or undefined\n */\n private getCachedComponent(componentName: string, code: string): CompiledComponent | undefined {\n // Create cache key based on name AND content hash\n const cacheKey = this.createCacheKey(componentName, code);\n return this.compilationCache.get(cacheKey);\n }\n\n /**\n * Creates a cache key based on component name and code content\n * @param componentName - Name of the component\n * @param code - Component source code\n * @returns Cache key\n */\n private createCacheKey(componentName: string, code: string): string {\n // Simple hash function for code content\n let hash = 0;\n for (let i = 0; i < code.length; i++) {\n const char = code.charCodeAt(i);\n hash = ((hash << 5) - hash) + char;\n hash = hash & hash; // Convert to 32-bit integer\n }\n return `${componentName}_${hash.toString(36)}`;\n }\n\n /**\n * Caches a compiled component\n * @param component - Component to cache\n * @param code - Original source code\n */\n private cacheComponent(component: CompiledComponent, code: string): void {\n // Enforce cache size limit\n if (this.compilationCache.size >= this.config.maxCacheSize) {\n // Remove oldest entry (first in map)\n const firstKey = this.compilationCache.keys().next().value;\n if (firstKey)\n this.compilationCache.delete(firstKey);\n }\n\n const cacheKey = this.createCacheKey(component.name, code);\n this.compilationCache.set(cacheKey, component);\n }\n\n /**\n * Creates a standardized compilation error\n * @param error - Original error\n * @param componentName - Name of the component\n * @returns Formatted component error\n */\n private createCompilationError(error: any, componentName: string): ComponentError {\n return {\n message: error.message || 'Unknown compilation error',\n stack: error.stack,\n componentName,\n phase: 'compilation',\n details: error\n };\n }\n\n /**\n * Clears the compilation cache\n */\n clearCache(): void {\n this.compilationCache.clear();\n }\n\n /**\n * Gets current cache size\n * @returns Number of cached components\n */\n getCacheSize(): number {\n return this.compilationCache.size;\n }\n\n /**\n * Updates compiler configuration\n * @param config - New configuration options\n */\n updateConfig(config: Partial<CompilerConfig>): void {\n this.config = { ...this.config, ...config };\n }\n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-manager.js","sourceRoot":"","sources":["../../src/component-manager/component-manager.ts"],"names":[],"mappings":"AAMA,OAAO,EAAY,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAmD,MAAM,+BAA+B,CAAC;AAkBzH,MAAM,OAAO,gBAAgB;IAe3B,YACE,QAA2B,EAC3B,QAA2B,EAC3B,cAA8B,EAC9B,SAAiC,EAAE;QAZ7B,eAAU,GAA4B,IAAI,GAAG,EAAE,CAAC;QAChD,0BAAqB,GAAgB,IAAI,GAAG,EAAE,CAAC;QAC/C,oBAAe,GAAqC,IAAI,GAAG,EAAE,CAAC;QAG9D,oBAAe,GAAG,uBAAuB,CAAC,QAAQ,CAAC;QACnD,kBAAa,GAAQ,IAAI,CAAC;QAQhC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG;YACZ,KAAK,EAAE,KAAK;YACZ,YAAY,EAAE,GAAG;YACjB,QAAQ,EAAE,OAAO;YACjB,mBAAmB,EAAE,IAAI;YACzB,mBAAmB,EAAE,CAAC;YACtB,YAAY,EAAE,KAAK;YACnB,GAAG,MAAM;SACV,CAAC;QAEF,IAAI,CAAC,GAAG,CAAC,8BAA8B,EAAE;YACvC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;YACxB,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;YAC9B,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,mBAAmB;SAC/C,CAAC,CAAC;IACL,CAAC;IAKD,KAAK,CAAC,aAAa,CACjB,IAAmB,EACnB,UAAuB,EAAE;QAEzB,MAAM,SAAS,GAAG,IAAI,CAA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AAE,IAAI,IAAI,EAAE,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;CACF","sourcesContent":["/**\n * @fileoverview Unified Component Manager implementation\n * Handles all component operations efficiently with proper caching and registry tracking\n */\n\nimport { ComponentSpec, ComponentLibraryDependency } from '@memberjunction/interactive-component-types';\nimport { UserInfo, Metadata, LogError } from '@memberjunction/core';\nimport { ComponentMetadataEngine, ComponentLibraryEntity, ComponentEntityExtended } from '@memberjunction/core-entities';\n\nimport { ComponentCompiler } from '../compiler';\nimport { ComponentRegistry } from '../registry';\nimport { RuntimeContext, ComponentObject } from '../types';\nimport {\n LoadOptions,\n LoadResult,\n HierarchyResult,\n ComponentManagerConfig,\n CacheEntry,\n ResolutionMode\n} from './types';\n\n/**\n * Unified component management system that handles all component operations\n * efficiently with proper caching and registry tracking.\n */\nexport class ComponentManager {\n private compiler: ComponentCompiler;\n private registry: ComponentRegistry;\n private runtimeContext: RuntimeContext;\n private config: ComponentManagerConfig;\n \n // Caching\n private fetchCache: Map<string, CacheEntry> = new Map();\n private registryNotifications: Set<string> = new Set();\n private loadingPromises: Map<string, Promise<LoadResult>> = new Map();\n \n // Metadata engine\n private componentEngine = ComponentMetadataEngine.Instance;\n private graphQLClient: any = null;\n \n constructor(\n compiler: ComponentCompiler,\n registry: ComponentRegistry,\n runtimeContext: RuntimeContext,\n config: ComponentManagerConfig = {}\n ) {\n this.compiler = compiler;\n this.registry = registry;\n this.runtimeContext = runtimeContext;\n this.config = {\n debug: false,\n maxCacheSize: 100,\n cacheTTL: 3600000, // 1 hour\n enableUsageTracking: true,\n dependencyBatchSize: 5,\n fetchTimeout: 30000,\n ...config\n };\n \n this.log('ComponentManager initialized', {\n debug: this.config.debug,\n cacheTTL: this.config.cacheTTL,\n usageTracking: this.config.enableUsageTracking\n });\n }\n \n /**\n * Main entry point - intelligently handles all component operations\n */\n async loadComponent(\n spec: ComponentSpec,\n options: LoadOptions = {}\n ): Promise<LoadResult> {\n const startTime = Date.now();\n const componentKey = this.getComponentKey(spec, options);\n \n this.log(`Loading component: ${spec.name}`, { \n key: componentKey, \n location: spec.location,\n registry: spec.registry,\n forceRefresh: options.forceRefresh \n });\n \n // Check if already loading to prevent duplicate work\n const existingPromise = this.loadingPromises.get(componentKey);\n if (existingPromise && !options.forceRefresh) {\n this.log(`Component already loading: ${spec.name}, waiting...`);\n return existingPromise;\n }\n \n // Create loading promise\n const loadPromise = this.doLoadComponent(spec, options, componentKey, startTime);\n this.loadingPromises.set(componentKey, loadPromise);\n \n try {\n const result = await loadPromise;\n return result;\n } finally {\n this.loadingPromises.delete(componentKey);\n }\n }\n \n /**\n * Internal method that does the actual loading\n */\n private async doLoadComponent(\n spec: ComponentSpec,\n options: LoadOptions,\n componentKey: string,\n startTime: number\n ): Promise<LoadResult> {\n const errors: LoadResult['errors'] = [];\n \n try {\n // STEP 1: Check if already loaded in ComponentRegistry\n const namespace = spec.namespace || options.defaultNamespace || 'Global';\n const version = spec.version || options.defaultVersion || 'latest';\n \n const existing = this.registry.get(spec.name, namespace, version);\n if (existing && !options.forceRefresh && !options.forceRecompile) {\n this.log(`Component found in registry: ${spec.name}`);\n \n // Still need to notify registry for usage tracking\n if (options.trackUsage !== false) {\n await this.notifyRegistryUsageIfNeeded(spec, componentKey);\n }\n \n // Get cached spec if available\n const cachedEntry = this.fetchCache.get(componentKey);\n \n return {\n success: true,\n component: existing,\n spec: cachedEntry?.spec || spec,\n fromCache: true\n };\n }\n \n // STEP 2: Fetch full spec if needed\n let fullSpec = spec;\n if (this.needsFetch(spec)) {\n this.log(`Fetching component spec: ${spec.name}`);\n try {\n fullSpec = await this.fetchComponentSpec(spec, options.contextUser, {\n resolutionMode: options.resolutionMode\n });\n\n // Cache the fetched spec\n this.fetchCache.set(componentKey, {\n spec: fullSpec,\n fetchedAt: new Date(),\n hash: await this.calculateHash(fullSpec),\n usageNotified: false\n });\n } catch (error) {\n errors.push({\n message: `Failed to fetch component: ${error instanceof Error ? error.message : String(error)}`,\n phase: 'fetch',\n componentName: spec.name\n });\n throw error;\n }\n } else {\n // Log when we skip fetching because code is already provided\n if (spec.location === 'registry' && spec.code) {\n this.log(`Skipping fetch for registry component: ${spec.name} (code already provided)`, {\n location: spec.location,\n registry: spec.registry\n });\n }\n // Also cache the spec if it has code to avoid re-fetching\n if (spec.code && !this.fetchCache.has(componentKey)) {\n this.fetchCache.set(componentKey, {\n spec: fullSpec,\n fetchedAt: new Date(),\n hash: await this.calculateHash(fullSpec),\n usageNotified: false\n });\n }\n }\n \n // STEP 3: Notify registry of usage (exactly once per session)\n if (options.trackUsage !== false) {\n await this.notifyRegistryUsageIfNeeded(fullSpec, componentKey);\n }\n \n // STEP 4: Compile if needed\n let compiledComponent = existing;\n if (!compiledComponent || options.forceRecompile) {\n this.log(`Compiling component: ${spec.name}`);\n try {\n compiledComponent = await this.compileComponent(fullSpec, options);\n } catch (error) {\n errors.push({\n message: `Failed to compile component: ${error instanceof Error ? error.message : String(error)}`,\n phase: 'compile',\n componentName: spec.name\n });\n throw error;\n }\n }\n \n // STEP 5: Register in ComponentRegistry\n if (!existing || options.forceRefresh || options.forceRecompile) {\n this.log(`Registering component: ${spec.name}`);\n this.registry.register(\n fullSpec.name,\n compiledComponent,\n namespace,\n version\n );\n }\n \n // STEP 6: Process dependencies recursively\n const dependencies: Record<string, ComponentObject> = {};\n if (fullSpec.dependencies && fullSpec.dependencies.length > 0) {\n this.log(`Loading ${fullSpec.dependencies.length} dependencies for ${spec.name}`);\n \n // Load dependencies in batches for efficiency\n const depResults = await this.loadDependenciesBatched(\n fullSpec.dependencies,\n { ...options, isDependent: true }\n );\n \n for (const result of depResults) {\n if (result.success && result.component) {\n const depSpec = fullSpec.dependencies.find(d => \n d.name === (result.spec?.name || '')\n );\n if (depSpec) {\n dependencies[depSpec.name] = result.component;\n }\n } else if (result.errors) {\n errors.push(...result.errors);\n }\n }\n }\n \n const elapsed = Date.now() - startTime;\n this.log(`Component loaded successfully: ${spec.name} (${elapsed}ms)`, {\n fromCache: false,\n dependencyCount: Object.keys(dependencies).length\n });\n \n return {\n success: errors.length === 0,\n component: compiledComponent,\n spec: fullSpec,\n fromCache: false,\n dependencies,\n errors: errors.length > 0 ? errors : undefined\n };\n \n } catch (error) {\n const elapsed = Date.now() - startTime;\n this.log(`Failed to load component: ${spec.name} (${elapsed}ms)`, error);\n \n return {\n success: false,\n fromCache: false,\n errors: errors.length > 0 ? errors : [{\n message: error instanceof Error ? error.message : String(error),\n phase: 'fetch',\n componentName: spec.name\n }]\n };\n }\n }\n \n /**\n * Load a complete hierarchy efficiently\n */\n async loadHierarchy(\n rootSpec: ComponentSpec,\n options: LoadOptions = {}\n ): Promise<HierarchyResult> {\n const startTime = Date.now();\n const loaded: string[] = [];\n const errors: HierarchyResult['errors'] = [];\n const components: Record<string, ComponentObject> = {};\n const stats = {\n fromCache: 0,\n fetched: 0,\n compiled: 0,\n totalTime: 0\n };\n \n this.log(`Loading component hierarchy: ${rootSpec.name}`, {\n location: rootSpec.location,\n registry: rootSpec.registry\n });\n \n try {\n // Initialize component engine if needed (skip in browser context where it doesn't exist)\n if (this.componentEngine && typeof this.componentEngine.Config === 'function') {\n await this.componentEngine.Config(false, options.contextUser);\n }\n \n // Load the root component and all its dependencies\n const result = await this.loadComponentRecursive(\n rootSpec,\n options,\n loaded,\n errors,\n components,\n stats,\n new Set()\n );\n \n stats.totalTime = Date.now() - startTime;\n \n this.log(`Hierarchy loaded: ${rootSpec.name}`, {\n success: errors.length === 0,\n loadedCount: loaded.length,\n errors: errors.length,\n ...stats\n });\n \n // Unwrap components before returning\n // Components are ComponentObject wrappers, but consumers expect just the React components\n const unwrappedComponents: Record<string, ComponentObject> = {};\n for (const [name, componentObject] of Object.entries(components)) {\n if (componentObject && typeof componentObject === 'object' && 'component' in componentObject) {\n // Extract the actual React component function\n unwrappedComponents[name] = (componentObject as any).component;\n } else {\n // Already a function or something else - use as-is\n unwrappedComponents[name] = componentObject;\n }\n }\n \n return {\n success: errors.length === 0,\n rootComponent: result.component,\n resolvedSpec: result.spec,\n loadedComponents: loaded,\n errors,\n components: unwrappedComponents,\n stats\n };\n \n } catch (error) {\n stats.totalTime = Date.now() - startTime;\n \n this.log(`Failed to load hierarchy: ${rootSpec.name}`, error);\n \n return {\n success: false,\n loadedComponents: loaded,\n errors: [...errors, {\n message: error instanceof Error ? error.message : String(error),\n phase: 'fetch',\n componentName: rootSpec.name\n }],\n stats\n };\n }\n }\n \n /**\n * Recursively load a component and its dependencies\n */\n private async loadComponentRecursive(\n spec: ComponentSpec,\n options: LoadOptions,\n loaded: string[],\n errors: HierarchyResult['errors'],\n components: Record<string, ComponentObject>,\n stats: HierarchyResult['stats'],\n visited: Set<string>\n ): Promise<LoadResult> {\n const componentKey = this.getComponentKey(spec, options);\n \n // Prevent circular dependencies\n if (visited.has(componentKey)) {\n this.log(`Circular dependency detected: ${spec.name}`);\n return {\n success: true,\n component: components[spec.name],\n spec,\n fromCache: true\n };\n }\n visited.add(componentKey);\n \n // Load this component\n const result = await this.loadComponent(spec, options);\n \n if (result.success && result.component) {\n loaded.push(spec.name);\n components[spec.name] = result.component;\n \n // Update stats\n if (stats) {\n if (result.fromCache) stats.fromCache++;\n else {\n stats.fetched++;\n stats.compiled++;\n }\n }\n \n // Load dependencies\n if (result.spec?.dependencies) {\n for (const dep of result.spec.dependencies) {\n // Normalize dependency spec for local registry lookup\n const depSpec = { ...dep };\n // OPTIMIZATION: If the dependency already has code (from registry population),\n // we can skip fetching and go straight to compilation\n if (depSpec.code) {\n this.log(`Dependency ${depSpec.name} already has code (from registry population), optimizing load`);\n }\n\n // If location is \"registry\" with undefined registry, ensure it's treated as local\n // This follows the convention that registry components with undefined registry\n // should be looked up in the local ComponentMetadataEngine\n if (depSpec.location === 'registry' && !depSpec.registry) {\n // Explicitly set to undefined for clarity (it may already be undefined)\n depSpec.registry = undefined;\n\n // Log for debugging\n this.log(`Dependency ${depSpec.name} is a local registry component (registry=undefined)`);\n }\n\n await this.loadComponentRecursive(\n depSpec,\n { ...options, isDependent: true },\n loaded,\n errors,\n components,\n stats,\n visited\n );\n }\n }\n } else if (result.errors) {\n errors.push(...result.errors);\n }\n \n return result;\n }\n \n /**\n * Load dependencies in batches for efficiency\n */\n private async loadDependenciesBatched(\n dependencies: ComponentSpec[],\n options: LoadOptions\n ): Promise<LoadResult[]> {\n const batchSize = this.config.dependencyBatchSize || 5;\n const results: LoadResult[] = [];\n \n for (let i = 0; i < dependencies.length; i += batchSize) {\n const batch = dependencies.slice(i, i + batchSize);\n const batchPromises = batch.map(dep => this.loadComponent(dep, options));\n const batchResults = await Promise.all(batchPromises);\n results.push(...batchResults);\n }\n \n return results;\n }\n \n /**\n * Check if a component needs to be fetched from a registry\n */\n private needsFetch(spec: ComponentSpec): boolean {\n // Need to fetch if:\n // 1. It's a registry component without code\n // 2. It's missing required fields\n return spec.location === 'registry' && !spec.code;\n }\n \n /**\n * Fetch a component specification from a registry (local or external)\n * \n * Convention: When location === 'registry' and registry === undefined,\n * the component is looked up in the local ComponentMetadataEngine.\n * This allows components to reference local registry components without\n * having to know if they're embedded or registry-based.\n */\n private async fetchComponentSpec(\n spec: ComponentSpec,\n contextUser?: UserInfo,\n options?: { resolutionMode?: ResolutionMode }\n ): Promise<ComponentSpec> {\n // Check cache first\n const cacheKey = this.getComponentKey(spec, {});\n const cached = this.fetchCache.get(cacheKey);\n \n if (cached && this.isCacheValid(cached)) {\n this.log(`Using cached spec for: ${spec.name}`);\n return cached.spec;\n }\n \n // Handle LOCAL registry components (registry is null/undefined)\n if (!spec.registry) {\n this.log(`Fetching from local registry: ${spec.name}`);\n \n // Find component in local ComponentMetadataEngine\n const localComponent = this.componentEngine.Components?.find(\n (c: ComponentEntityExtended) => {\n // Match by name (case-insensitive for better compatibility)\n const nameMatch = c.Name?.toLowerCase() === spec.name?.toLowerCase();\n \n // Match by namespace if provided (handle different formats)\n const namespaceMatch = !spec.namespace || c.Namespace?.toLowerCase() === spec.namespace?.toLowerCase();\n\n if (nameMatch && !namespaceMatch) {\n }\n \n return nameMatch && namespaceMatch;\n }\n );\n \n if (!localComponent) {\n throw new Error(`Local component not found: ${spec.name}`);\n }\n \n // Parse specification from local component\n if (!localComponent.Specification) {\n throw new Error(`Local component ${spec.name} has no specification`);\n }\n \n const fullSpec = JSON.parse(localComponent.Specification);\n \n // Cache it\n this.fetchCache.set(cacheKey, {\n spec: fullSpec,\n fetchedAt: new Date(),\n usageNotified: false\n });\n \n return fullSpec;\n }\n \n // Handle EXTERNAL registry components (registry has a name)\n // Initialize GraphQL client if needed\n if (!this.graphQLClient) {\n await this.initializeGraphQLClient();\n }\n \n if (!this.graphQLClient) {\n throw new Error('GraphQL client not available for registry fetching');\n }\n \n // Fetch from external registry\n this.log(`Fetching from external registry: ${spec.registry}/${spec.name}`);\n \n const fullSpec = await this.graphQLClient.GetRegistryComponent({\n registryName: spec.registry,\n namespace: spec.namespace || 'Global',\n name: spec.name,\n version: spec.version || 'latest'\n });\n \n if (!fullSpec) {\n throw new Error(`Component not found in registry: ${spec.registry}/${spec.name}`);\n }\n \n // Apply resolution mode if specified\n const processedSpec = this.applyResolutionMode(fullSpec, spec, options?.resolutionMode);\n \n // Cache it\n this.fetchCache.set(cacheKey, {\n spec: processedSpec,\n fetchedAt: new Date(),\n usageNotified: false\n });\n \n return processedSpec;\n }\n \n /**\n * Apply resolution mode to a fetched spec (recursively including dependencies)\n */\n private applyResolutionMode(\n fullSpec: ComponentSpec,\n originalSpec: ComponentSpec,\n resolutionMode?: ResolutionMode\n ): ComponentSpec {\n let processedSpec: ComponentSpec;\n \n if (resolutionMode === 'embed') {\n // Convert to embedded format for test harness\n processedSpec = {\n ...fullSpec,\n location: 'embedded',\n registry: undefined,\n // namespace and name can stay for identification\n };\n } else {\n // Default: preserve-metadata mode\n // Keep original registry metadata but include fetched code\n processedSpec = {\n ...fullSpec,\n location: originalSpec.location,\n registry: originalSpec.registry,\n namespace: originalSpec.namespace || fullSpec.namespace,\n name: originalSpec.name || fullSpec.name\n };\n }\n \n // Recursively apply resolution mode to dependencies\n if (processedSpec.dependencies && processedSpec.dependencies.length > 0) {\n processedSpec.dependencies = processedSpec.dependencies.map(dep => {\n // For dependencies, use the dep itself as both full and original spec\n // since they've already been fetched and processed\n return this.applyResolutionMode(dep, dep, resolutionMode);\n });\n }\n \n return processedSpec;\n }\n\n /**\n * Compile a component specification\n */\n private async compileComponent(\n spec: ComponentSpec,\n options: LoadOptions\n ): Promise<ComponentObject> {\n // Get all available libraries - use passed libraries or fall back to ComponentMetadataEngine\n const allLibraries = options.allLibraries || this.componentEngine.ComponentLibraries || [];\n \n // Filter valid libraries\n const validLibraries = spec.libraries?.filter(lib => \n lib && lib.name && lib.globalVariable && \n lib.name !== 'unknown' && lib.globalVariable !== 'undefined'\n );\n \n // Compile the component\n const result = await this.compiler.compile({\n componentName: spec.name,\n componentCode: spec.code || '',\n libraries: validLibraries,\n dependencies: spec.dependencies,\n allLibraries\n });\n \n if (!result.success || !result.component) {\n throw new Error(result.error?.message || 'Compilation failed');\n }\n \n // Add loaded libraries to runtime context\n if (result.loadedLibraries && result.loadedLibraries.size > 0) {\n if (!this.runtimeContext.libraries) {\n this.runtimeContext.libraries = {};\n }\n result.loadedLibraries.forEach((value, key) => {\n this.runtimeContext.libraries![key] = value;\n });\n }\n \n // Get the component object from the factory\n const componentObject = result.component.factory(\n this.runtimeContext,\n undefined, // styles\n {} // components - will be injected by parent\n );\n \n return componentObject;\n }\n \n /**\n * Notify registry of component usage for licensing\n * Only happens once per component per session\n */\n private async notifyRegistryUsageIfNeeded(\n spec: ComponentSpec,\n componentKey: string\n ): Promise<void> {\n if (!spec.registry || !this.config.enableUsageTracking) {\n return; // Only for external registry components with tracking enabled\n }\n \n const notificationKey = `${spec.registry}:${componentKey}`;\n if (this.registryNotifications.has(notificationKey)) {\n this.log(`Usage already notified for: ${spec.name}`);\n return; // Already notified this session\n }\n \n try {\n // In the future, make lightweight usage notification call to registry\n // For now, the fetch itself serves as the notification\n this.log(`Notifying registry usage for: ${spec.name}`);\n this.registryNotifications.add(notificationKey);\n \n // Update cache entry\n const cached = this.fetchCache.get(componentKey);\n if (cached) {\n cached.usageNotified = true;\n }\n } catch (error) {\n // Log but don't fail - usage tracking shouldn't break component loading\n console.warn(`Failed to notify registry usage for ${componentKey}:`, error);\n }\n }\n \n /**\n * Initialize GraphQL client for registry operations\n */\n private async initializeGraphQLClient(): Promise<void> {\n try {\n const provider = Metadata?.Provider;\n if (provider && (provider as any).ExecuteGQL) {\n const { GraphQLComponentRegistryClient } = await import('@memberjunction/graphql-dataprovider');\n this.graphQLClient = new GraphQLComponentRegistryClient(provider as any);\n this.log('GraphQL client initialized');\n }\n } catch (error) {\n LogError(`Failed to initialize GraphQL client: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n \n /**\n * Check if a cache entry is still valid\n */\n private isCacheValid(entry: CacheEntry): boolean {\n const age = Date.now() - entry.fetchedAt.getTime();\n return age < (this.config.cacheTTL || 3600000);\n }\n \n /**\n * Calculate a hash for a component spec (for cache validation)\n */\n private async calculateHash(spec: ComponentSpec): Promise<string> {\n // Simple hash based on spec content\n const content = JSON.stringify({\n name: spec.name,\n version: spec.version,\n code: spec.code,\n libraries: spec.libraries\n });\n \n // Simple hash function (in production, use crypto)\n let hash = 0;\n for (let i = 0; i < content.length; i++) {\n const char = content.charCodeAt(i);\n hash = ((hash << 5) - hash) + char;\n hash = hash & hash; // Convert to 32bit integer\n }\n return hash.toString(16);\n }\n \n /**\n * Generate a unique key for a component\n */\n private getComponentKey(spec: ComponentSpec, options: LoadOptions): string {\n const registry = spec.registry || 'local';\n const namespace = spec.namespace || options.defaultNamespace || 'Global';\n const version = spec.version || options.defaultVersion || 'latest';\n return `${registry}:${namespace}:${spec.name}:${version}`;\n }\n \n /**\n * Clear all caches\n */\n clearCache(): void {\n this.fetchCache.clear();\n this.registryNotifications.clear();\n this.loadingPromises.clear();\n this.log('All caches cleared');\n }\n \n /**\n * Get cache statistics\n */\n getCacheStats(): {\n fetchCacheSize: number;\n notificationsCount: number;\n loadingCount: number;\n } {\n return {\n fetchCacheSize: this.fetchCache.size,\n notificationsCount: this.registryNotifications.size,\n loadingCount: this.loadingPromises.size\n };\n }\n \n /**\n * Log a message if debug is enabled\n */\n private log(message: string, data?: any): void {\n if (this.config.debug) {\n console.log(`🎯 [ComponentManager] ${message}`, data || '');\n }\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"component-manager.js","sourceRoot":"","sources":["../../src/component-manager/component-manager.ts"],"names":[],"mappings":"AAMA,OAAO,EAAY,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAqD,MAAM,+BAA+B,CAAC;AAkB3H,MAAM,OAAO,gBAAgB;IAe3B,YACE,QAA2B,EAC3B,QAA2B,EAC3B,cAA8B,EAC9B,SAAiC,EAAE;QAZ7B,eAAU,GAA4B,IAAI,GAAG,EAAE,CAAC;QAChD,0BAAqB,GAAgB,IAAI,GAAG,EAAE,CAAC;QAC/C,oBAAe,GAAqC,IAAI,GAAG,EAAE,CAAC;QAG9D,oBAAe,GAAG,uBAAuB,CAAC,QAAQ,CAAC;QACnD,kBAAa,GAAQ,IAAI,CAAC;QAQhC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG;YACZ,KAAK,EAAE,KAAK;YACZ,YAAY,EAAE,GAAG;YACjB,QAAQ,EAAE,OAAO;YACjB,mBAAmB,EAAE,IAAI;YACzB,mBAAmB,EAAE,CAAC;YACtB,YAAY,EAAE,KAAK;YACnB,GAAG,MAAM;SACV,CAAC;QAEF,IAAI,CAAC,GAAG,CAAC,8BAA8B,EAAE;YACvC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;YACxB,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;YAC9B,aAAa,EA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AC;IACJ,CAAC;IAKO,GAAG,CAAC,OAAe,EAAE,IAAU;QACrC,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACtB,OAAO,CAAC,GAAG,CAAC,yBAAyB,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;CACF","sourcesContent":["/**\n * @fileoverview Unified Component Manager implementation\n * Handles all component operations efficiently with proper caching and registry tracking\n */\n\nimport { ComponentSpec, ComponentLibraryDependency } from '@memberjunction/interactive-component-types';\nimport { UserInfo, Metadata, LogError } from '@memberjunction/core';\nimport { ComponentMetadataEngine, MJComponentLibraryEntity, ComponentEntityExtended } from '@memberjunction/core-entities';\n\nimport { ComponentCompiler } from '../compiler';\nimport { ComponentRegistry } from '../registry';\nimport { RuntimeContext, ComponentObject } from '../types';\nimport {\n LoadOptions,\n LoadResult,\n HierarchyResult,\n ComponentManagerConfig,\n CacheEntry,\n ResolutionMode\n} from './types';\n\n/**\n * Unified component management system that handles all component operations\n * efficiently with proper caching and registry tracking.\n */\nexport class ComponentManager {\n private compiler: ComponentCompiler;\n private registry: ComponentRegistry;\n private runtimeContext: RuntimeContext;\n private config: ComponentManagerConfig;\n \n // Caching\n private fetchCache: Map<string, CacheEntry> = new Map();\n private registryNotifications: Set<string> = new Set();\n private loadingPromises: Map<string, Promise<LoadResult>> = new Map();\n \n // Metadata engine\n private componentEngine = ComponentMetadataEngine.Instance;\n private graphQLClient: any = null;\n \n constructor(\n compiler: ComponentCompiler,\n registry: ComponentRegistry,\n runtimeContext: RuntimeContext,\n config: ComponentManagerConfig = {}\n ) {\n this.compiler = compiler;\n this.registry = registry;\n this.runtimeContext = runtimeContext;\n this.config = {\n debug: false,\n maxCacheSize: 100,\n cacheTTL: 3600000, // 1 hour\n enableUsageTracking: true,\n dependencyBatchSize: 5,\n fetchTimeout: 30000,\n ...config\n };\n \n this.log('ComponentManager initialized', {\n debug: this.config.debug,\n cacheTTL: this.config.cacheTTL,\n usageTracking: this.config.enableUsageTracking\n });\n }\n \n /**\n * Main entry point - intelligently handles all component operations\n */\n async loadComponent(\n spec: ComponentSpec,\n options: LoadOptions = {}\n ): Promise<LoadResult> {\n const startTime = Date.now();\n const componentKey = this.getComponentKey(spec, options);\n \n this.log(`Loading component: ${spec.name}`, { \n key: componentKey, \n location: spec.location,\n registry: spec.registry,\n forceRefresh: options.forceRefresh \n });\n \n // Check if already loading to prevent duplicate work\n const existingPromise = this.loadingPromises.get(componentKey);\n if (existingPromise && !options.forceRefresh) {\n this.log(`Component already loading: ${spec.name}, waiting...`);\n return existingPromise;\n }\n \n // Create loading promise\n const loadPromise = this.doLoadComponent(spec, options, componentKey, startTime);\n this.loadingPromises.set(componentKey, loadPromise);\n \n try {\n const result = await loadPromise;\n return result;\n } finally {\n this.loadingPromises.delete(componentKey);\n }\n }\n \n /**\n * Internal method that does the actual loading\n */\n private async doLoadComponent(\n spec: ComponentSpec,\n options: LoadOptions,\n componentKey: string,\n startTime: number\n ): Promise<LoadResult> {\n const errors: LoadResult['errors'] = [];\n \n try {\n // STEP 1: Check if already loaded in ComponentRegistry\n const namespace = spec.namespace || options.defaultNamespace || 'Global';\n const version = spec.version || options.defaultVersion || 'latest';\n \n const existing = this.registry.get(spec.name, namespace, version);\n if (existing && !options.forceRefresh && !options.forceRecompile) {\n this.log(`Component found in registry: ${spec.name}`);\n \n // Still need to notify registry for usage tracking\n if (options.trackUsage !== false) {\n await this.notifyRegistryUsageIfNeeded(spec, componentKey);\n }\n \n // Get cached spec if available\n const cachedEntry = this.fetchCache.get(componentKey);\n \n return {\n success: true,\n component: existing,\n spec: cachedEntry?.spec || spec,\n fromCache: true\n };\n }\n \n // STEP 2: Fetch full spec if needed\n let fullSpec = spec;\n if (this.needsFetch(spec)) {\n this.log(`Fetching component spec: ${spec.name}`);\n try {\n fullSpec = await this.fetchComponentSpec(spec, options.contextUser, {\n resolutionMode: options.resolutionMode\n });\n\n // Cache the fetched spec\n this.fetchCache.set(componentKey, {\n spec: fullSpec,\n fetchedAt: new Date(),\n hash: await this.calculateHash(fullSpec),\n usageNotified: false\n });\n } catch (error) {\n errors.push({\n message: `Failed to fetch component: ${error instanceof Error ? error.message : String(error)}`,\n phase: 'fetch',\n componentName: spec.name\n });\n throw error;\n }\n } else {\n // Log when we skip fetching because code is already provided\n if (spec.location === 'registry' && spec.code) {\n this.log(`Skipping fetch for registry component: ${spec.name} (code already provided)`, {\n location: spec.location,\n registry: spec.registry\n });\n }\n // Also cache the spec if it has code to avoid re-fetching\n if (spec.code && !this.fetchCache.has(componentKey)) {\n this.fetchCache.set(componentKey, {\n spec: fullSpec,\n fetchedAt: new Date(),\n hash: await this.calculateHash(fullSpec),\n usageNotified: false\n });\n }\n }\n \n // STEP 3: Notify registry of usage (exactly once per session)\n if (options.trackUsage !== false) {\n await this.notifyRegistryUsageIfNeeded(fullSpec, componentKey);\n }\n \n // STEP 4: Compile if needed\n let compiledComponent = existing;\n if (!compiledComponent || options.forceRecompile) {\n this.log(`Compiling component: ${spec.name}`);\n try {\n compiledComponent = await this.compileComponent(fullSpec, options);\n } catch (error) {\n errors.push({\n message: `Failed to compile component: ${error instanceof Error ? error.message : String(error)}`,\n phase: 'compile',\n componentName: spec.name\n });\n throw error;\n }\n }\n \n // STEP 5: Register in ComponentRegistry\n if (!existing || options.forceRefresh || options.forceRecompile) {\n this.log(`Registering component: ${spec.name}`);\n this.registry.register(\n fullSpec.name,\n compiledComponent,\n namespace,\n version\n );\n }\n \n // STEP 6: Process dependencies recursively\n const dependencies: Record<string, ComponentObject> = {};\n if (fullSpec.dependencies && fullSpec.dependencies.length > 0) {\n this.log(`Loading ${fullSpec.dependencies.length} dependencies for ${spec.name}`);\n \n // Load dependencies in batches for efficiency\n const depResults = await this.loadDependenciesBatched(\n fullSpec.dependencies,\n { ...options, isDependent: true }\n );\n \n for (const result of depResults) {\n if (result.success && result.component) {\n const depSpec = fullSpec.dependencies.find(d => \n d.name === (result.spec?.name || '')\n );\n if (depSpec) {\n dependencies[depSpec.name] = result.component;\n }\n } else if (result.errors) {\n errors.push(...result.errors);\n }\n }\n }\n \n const elapsed = Date.now() - startTime;\n this.log(`Component loaded successfully: ${spec.name} (${elapsed}ms)`, {\n fromCache: false,\n dependencyCount: Object.keys(dependencies).length\n });\n \n return {\n success: errors.length === 0,\n component: compiledComponent,\n spec: fullSpec,\n fromCache: false,\n dependencies,\n errors: errors.length > 0 ? errors : undefined\n };\n \n } catch (error) {\n const elapsed = Date.now() - startTime;\n this.log(`Failed to load component: ${spec.name} (${elapsed}ms)`, error);\n \n return {\n success: false,\n fromCache: false,\n errors: errors.length > 0 ? errors : [{\n message: error instanceof Error ? error.message : String(error),\n phase: 'fetch',\n componentName: spec.name\n }]\n };\n }\n }\n \n /**\n * Load a complete hierarchy efficiently\n */\n async loadHierarchy(\n rootSpec: ComponentSpec,\n options: LoadOptions = {}\n ): Promise<HierarchyResult> {\n const startTime = Date.now();\n const loaded: string[] = [];\n const errors: HierarchyResult['errors'] = [];\n const components: Record<string, ComponentObject> = {};\n const stats = {\n fromCache: 0,\n fetched: 0,\n compiled: 0,\n totalTime: 0\n };\n \n this.log(`Loading component hierarchy: ${rootSpec.name}`, {\n location: rootSpec.location,\n registry: rootSpec.registry\n });\n \n try {\n // Initialize component engine if needed (skip in browser context where it doesn't exist)\n if (this.componentEngine && typeof this.componentEngine.Config === 'function') {\n await this.componentEngine.Config(false, options.contextUser);\n }\n \n // Load the root component and all its dependencies\n const result = await this.loadComponentRecursive(\n rootSpec,\n options,\n loaded,\n errors,\n components,\n stats,\n new Set()\n );\n \n stats.totalTime = Date.now() - startTime;\n \n this.log(`Hierarchy loaded: ${rootSpec.name}`, {\n success: errors.length === 0,\n loadedCount: loaded.length,\n errors: errors.length,\n ...stats\n });\n \n // Unwrap components before returning\n // Components are ComponentObject wrappers, but consumers expect just the React components\n const unwrappedComponents: Record<string, ComponentObject> = {};\n for (const [name, componentObject] of Object.entries(components)) {\n if (componentObject && typeof componentObject === 'object' && 'component' in componentObject) {\n // Extract the actual React component function\n unwrappedComponents[name] = (componentObject as any).component;\n } else {\n // Already a function or something else - use as-is\n unwrappedComponents[name] = componentObject;\n }\n }\n \n return {\n success: errors.length === 0,\n rootComponent: result.component,\n resolvedSpec: result.spec,\n loadedComponents: loaded,\n errors,\n components: unwrappedComponents,\n stats\n };\n \n } catch (error) {\n stats.totalTime = Date.now() - startTime;\n \n this.log(`Failed to load hierarchy: ${rootSpec.name}`, error);\n \n return {\n success: false,\n loadedComponents: loaded,\n errors: [...errors, {\n message: error instanceof Error ? error.message : String(error),\n phase: 'fetch',\n componentName: rootSpec.name\n }],\n stats\n };\n }\n }\n \n /**\n * Recursively load a component and its dependencies\n */\n private async loadComponentRecursive(\n spec: ComponentSpec,\n options: LoadOptions,\n loaded: string[],\n errors: HierarchyResult['errors'],\n components: Record<string, ComponentObject>,\n stats: HierarchyResult['stats'],\n visited: Set<string>\n ): Promise<LoadResult> {\n const componentKey = this.getComponentKey(spec, options);\n \n // Prevent circular dependencies\n if (visited.has(componentKey)) {\n this.log(`Circular dependency detected: ${spec.name}`);\n return {\n success: true,\n component: components[spec.name],\n spec,\n fromCache: true\n };\n }\n visited.add(componentKey);\n \n // Load this component\n const result = await this.loadComponent(spec, options);\n \n if (result.success && result.component) {\n loaded.push(spec.name);\n components[spec.name] = result.component;\n \n // Update stats\n if (stats) {\n if (result.fromCache) stats.fromCache++;\n else {\n stats.fetched++;\n stats.compiled++;\n }\n }\n \n // Load dependencies\n if (result.spec?.dependencies) {\n for (const dep of result.spec.dependencies) {\n // Normalize dependency spec for local registry lookup\n const depSpec = { ...dep };\n // OPTIMIZATION: If the dependency already has code (from registry population),\n // we can skip fetching and go straight to compilation\n if (depSpec.code) {\n this.log(`Dependency ${depSpec.name} already has code (from registry population), optimizing load`);\n }\n\n // If location is \"registry\" with undefined registry, ensure it's treated as local\n // This follows the convention that registry components with undefined registry\n // should be looked up in the local ComponentMetadataEngine\n if (depSpec.location === 'registry' && !depSpec.registry) {\n // Explicitly set to undefined for clarity (it may already be undefined)\n depSpec.registry = undefined;\n\n // Log for debugging\n this.log(`Dependency ${depSpec.name} is a local registry component (registry=undefined)`);\n }\n\n await this.loadComponentRecursive(\n depSpec,\n { ...options, isDependent: true },\n loaded,\n errors,\n components,\n stats,\n visited\n );\n }\n }\n } else if (result.errors) {\n errors.push(...result.errors);\n }\n \n return result;\n }\n \n /**\n * Load dependencies in batches for efficiency\n */\n private async loadDependenciesBatched(\n dependencies: ComponentSpec[],\n options: LoadOptions\n ): Promise<LoadResult[]> {\n const batchSize = this.config.dependencyBatchSize || 5;\n const results: LoadResult[] = [];\n \n for (let i = 0; i < dependencies.length; i += batchSize) {\n const batch = dependencies.slice(i, i + batchSize);\n const batchPromises = batch.map(dep => this.loadComponent(dep, options));\n const batchResults = await Promise.all(batchPromises);\n results.push(...batchResults);\n }\n \n return results;\n }\n \n /**\n * Check if a component needs to be fetched from a registry\n */\n private needsFetch(spec: ComponentSpec): boolean {\n // Need to fetch if:\n // 1. It's a registry component without code\n // 2. It's missing required fields\n return spec.location === 'registry' && !spec.code;\n }\n \n /**\n * Fetch a component specification from a registry (local or external)\n * \n * Convention: When location === 'registry' and registry === undefined,\n * the component is looked up in the local ComponentMetadataEngine.\n * This allows components to reference local registry components without\n * having to know if they're embedded or registry-based.\n */\n private async fetchComponentSpec(\n spec: ComponentSpec,\n contextUser?: UserInfo,\n options?: { resolutionMode?: ResolutionMode }\n ): Promise<ComponentSpec> {\n // Check cache first\n const cacheKey = this.getComponentKey(spec, {});\n const cached = this.fetchCache.get(cacheKey);\n \n if (cached && this.isCacheValid(cached)) {\n this.log(`Using cached spec for: ${spec.name}`);\n return cached.spec;\n }\n \n // Handle LOCAL registry components (registry is null/undefined)\n if (!spec.registry) {\n this.log(`Fetching from local registry: ${spec.name}`);\n \n // Find component in local ComponentMetadataEngine\n const localComponent = this.componentEngine.Components?.find(\n (c: ComponentEntityExtended) => {\n // Match by name (case-insensitive for better compatibility)\n const nameMatch = c.Name?.toLowerCase() === spec.name?.toLowerCase();\n \n // Match by namespace if provided (handle different formats)\n const namespaceMatch = !spec.namespace || c.Namespace?.toLowerCase() === spec.namespace?.toLowerCase();\n\n if (nameMatch && !namespaceMatch) {\n }\n \n return nameMatch && namespaceMatch;\n }\n );\n \n if (!localComponent) {\n throw new Error(`Local component not found: ${spec.name}`);\n }\n \n // Parse specification from local component\n if (!localComponent.Specification) {\n throw new Error(`Local component ${spec.name} has no specification`);\n }\n \n const fullSpec = JSON.parse(localComponent.Specification);\n \n // Cache it\n this.fetchCache.set(cacheKey, {\n spec: fullSpec,\n fetchedAt: new Date(),\n usageNotified: false\n });\n \n return fullSpec;\n }\n \n // Handle EXTERNAL registry components (registry has a name)\n // Initialize GraphQL client if needed\n if (!this.graphQLClient) {\n await this.initializeGraphQLClient();\n }\n \n if (!this.graphQLClient) {\n throw new Error('GraphQL client not available for registry fetching');\n }\n \n // Fetch from external registry\n this.log(`Fetching from external registry: ${spec.registry}/${spec.name}`);\n \n const fullSpec = await this.graphQLClient.GetRegistryComponent({\n registryName: spec.registry,\n namespace: spec.namespace || 'Global',\n name: spec.name,\n version: spec.version || 'latest'\n });\n \n if (!fullSpec) {\n throw new Error(`Component not found in registry: ${spec.registry}/${spec.name}`);\n }\n \n // Apply resolution mode if specified\n const processedSpec = this.applyResolutionMode(fullSpec, spec, options?.resolutionMode);\n \n // Cache it\n this.fetchCache.set(cacheKey, {\n spec: processedSpec,\n fetchedAt: new Date(),\n usageNotified: false\n });\n \n return processedSpec;\n }\n \n /**\n * Apply resolution mode to a fetched spec (recursively including dependencies)\n */\n private applyResolutionMode(\n fullSpec: ComponentSpec,\n originalSpec: ComponentSpec,\n resolutionMode?: ResolutionMode\n ): ComponentSpec {\n let processedSpec: ComponentSpec;\n \n if (resolutionMode === 'embed') {\n // Convert to embedded format for test harness\n processedSpec = {\n ...fullSpec,\n location: 'embedded',\n registry: undefined,\n // namespace and name can stay for identification\n };\n } else {\n // Default: preserve-metadata mode\n // Keep original registry metadata but include fetched code\n processedSpec = {\n ...fullSpec,\n location: originalSpec.location,\n registry: originalSpec.registry,\n namespace: originalSpec.namespace || fullSpec.namespace,\n name: originalSpec.name || fullSpec.name\n };\n }\n \n // Recursively apply resolution mode to dependencies\n if (processedSpec.dependencies && processedSpec.dependencies.length > 0) {\n processedSpec.dependencies = processedSpec.dependencies.map(dep => {\n // For dependencies, use the dep itself as both full and original spec\n // since they've already been fetched and processed\n return this.applyResolutionMode(dep, dep, resolutionMode);\n });\n }\n \n return processedSpec;\n }\n\n /**\n * Compile a component specification\n */\n private async compileComponent(\n spec: ComponentSpec,\n options: LoadOptions\n ): Promise<ComponentObject> {\n // Get all available libraries - use passed libraries or fall back to ComponentMetadataEngine\n const allLibraries = options.allLibraries || this.componentEngine.ComponentLibraries || [];\n \n // Filter valid libraries\n const validLibraries = spec.libraries?.filter(lib => \n lib && lib.name && lib.globalVariable && \n lib.name !== 'unknown' && lib.globalVariable !== 'undefined'\n );\n \n // Compile the component\n const result = await this.compiler.compile({\n componentName: spec.name,\n componentCode: spec.code || '',\n libraries: validLibraries,\n dependencies: spec.dependencies,\n allLibraries\n });\n \n if (!result.success || !result.component) {\n throw new Error(result.error?.message || 'Compilation failed');\n }\n \n // Add loaded libraries to runtime context\n if (result.loadedLibraries && result.loadedLibraries.size > 0) {\n if (!this.runtimeContext.libraries) {\n this.runtimeContext.libraries = {};\n }\n result.loadedLibraries.forEach((value, key) => {\n this.runtimeContext.libraries![key] = value;\n });\n }\n \n // Get the component object from the factory\n const componentObject = result.component.factory(\n this.runtimeContext,\n undefined, // styles\n {} // components - will be injected by parent\n );\n \n return componentObject;\n }\n \n /**\n * Notify registry of component usage for licensing\n * Only happens once per component per session\n */\n private async notifyRegistryUsageIfNeeded(\n spec: ComponentSpec,\n componentKey: string\n ): Promise<void> {\n if (!spec.registry || !this.config.enableUsageTracking) {\n return; // Only for external registry components with tracking enabled\n }\n \n const notificationKey = `${spec.registry}:${componentKey}`;\n if (this.registryNotifications.has(notificationKey)) {\n this.log(`Usage already notified for: ${spec.name}`);\n return; // Already notified this session\n }\n \n try {\n // In the future, make lightweight usage notification call to registry\n // For now, the fetch itself serves as the notification\n this.log(`Notifying registry usage for: ${spec.name}`);\n this.registryNotifications.add(notificationKey);\n \n // Update cache entry\n const cached = this.fetchCache.get(componentKey);\n if (cached) {\n cached.usageNotified = true;\n }\n } catch (error) {\n // Log but don't fail - usage tracking shouldn't break component loading\n console.warn(`Failed to notify registry usage for ${componentKey}:`, error);\n }\n }\n \n /**\n * Initialize GraphQL client for registry operations\n */\n private async initializeGraphQLClient(): Promise<void> {\n try {\n const provider = Metadata?.Provider;\n if (provider && (provider as any).ExecuteGQL) {\n const { GraphQLComponentRegistryClient } = await import('@memberjunction/graphql-dataprovider');\n this.graphQLClient = new GraphQLComponentRegistryClient(provider as any);\n this.log('GraphQL client initialized');\n }\n } catch (error) {\n LogError(`Failed to initialize GraphQL client: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n \n /**\n * Check if a cache entry is still valid\n */\n private isCacheValid(entry: CacheEntry): boolean {\n const age = Date.now() - entry.fetchedAt.getTime();\n return age < (this.config.cacheTTL || 3600000);\n }\n \n /**\n * Calculate a hash for a component spec (for cache validation)\n */\n private async calculateHash(spec: ComponentSpec): Promise<string> {\n // Simple hash based on spec content\n const content = JSON.stringify({\n name: spec.name,\n version: spec.version,\n code: spec.code,\n libraries: spec.libraries\n });\n \n // Simple hash function (in production, use crypto)\n let hash = 0;\n for (let i = 0; i < content.length; i++) {\n const char = content.charCodeAt(i);\n hash = ((hash << 5) - hash) + char;\n hash = hash & hash; // Convert to 32bit integer\n }\n return hash.toString(16);\n }\n \n /**\n * Generate a unique key for a component\n */\n private getComponentKey(spec: ComponentSpec, options: LoadOptions): string {\n const registry = spec.registry || 'local';\n const namespace = spec.namespace || options.defaultNamespace || 'Global';\n const version = spec.version || options.defaultVersion || 'latest';\n return `${registry}:${namespace}:${spec.name}:${version}`;\n }\n \n /**\n * Clear all caches\n */\n clearCache(): void {\n this.fetchCache.clear();\n this.registryNotifications.clear();\n this.loadingPromises.clear();\n this.log('All caches cleared');\n }\n \n /**\n * Get cache statistics\n */\n getCacheStats(): {\n fetchCacheSize: number;\n notificationsCount: number;\n loadingCount: number;\n } {\n return {\n fetchCacheSize: this.fetchCache.size,\n notificationsCount: this.registryNotifications.size,\n loadingCount: this.loadingPromises.size\n };\n }\n \n /**\n * Log a message if debug is enabled\n */\n private log(message: string, data?: any): void {\n if (this.config.debug) {\n console.log(`🎯 [ComponentManager] ${message}`, data || '');\n }\n }\n}"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentSpec } from '@memberjunction/interactive-component-types';
|
|
2
2
|
import { UserInfo } from '@memberjunction/core';
|
|
3
|
-
import {
|
|
3
|
+
import { MJComponentLibraryEntity } from '@memberjunction/core-entities';
|
|
4
4
|
import { ComponentObject } from '../types';
|
|
5
5
|
export type ResolutionMode = 'embed' | 'preserve-metadata';
|
|
6
6
|
export interface LoadOptions {
|
|
@@ -13,7 +13,7 @@ export interface LoadOptions {
|
|
|
13
13
|
defaultNamespace?: string;
|
|
14
14
|
defaultVersion?: string;
|
|
15
15
|
resolutionMode?: ResolutionMode;
|
|
16
|
-
allLibraries?:
|
|
16
|
+
allLibraries?: MJComponentLibraryEntity[];
|
|
17
17
|
}
|
|
18
18
|
export interface LoadResult {
|
|
19
19
|
success: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/component-manager/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/component-manager/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA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E,MAAM,EAAE,CAAC;IAK3B,MAAM,EAAE,KAAK,CAAC;QACZ,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,UAAU,GAAG,YAAY,CAAC;QACvD,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC,CAAC;IAKH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAK7C,KAAK,CAAC,EAAE;QACN,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAKD,MAAM,WAAW,sBAAsB;IAIrC,KAAK,CAAC,EAAE,OAAO,CAAC;IAKhB,YAAY,CAAC,EAAE,MAAM,CAAC;IAKtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAKlB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAK9B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAK7B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAKD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,aAAa,CAAC;IACpB,SAAS,EAAE,IAAI,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,OAAO,CAAC;CACxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/component-manager/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * @fileoverview Type definitions for the unified ComponentManager\n */\n\nimport { ComponentSpec } from '@memberjunction/interactive-component-types';\nimport { UserInfo } from '@memberjunction/core';\nimport {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/component-manager/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * @fileoverview Type definitions for the unified ComponentManager\n */\n\nimport { ComponentSpec } from '@memberjunction/interactive-component-types';\nimport { UserInfo } from '@memberjunction/core';\nimport { MJComponentLibraryEntity } from '@memberjunction/core-entities';\nimport { ComponentObject } from '../types';\n\n/**\n * Resolution mode for specs\n */\nexport type ResolutionMode = 'embed' | 'preserve-metadata';\n\n/**\n * Options for loading a component\n */\nexport interface LoadOptions {\n /**\n * User context for database operations and registry fetching\n */\n contextUser?: UserInfo;\n \n /**\n * Force re-fetch from registry even if cached\n */\n forceRefresh?: boolean;\n \n /**\n * Force recompilation even if compiled version exists\n */\n forceRecompile?: boolean;\n \n /**\n * Whether this is a dependent component (for tracking)\n */\n isDependent?: boolean;\n \n /**\n * What to return from the load operation\n */\n returnType?: 'component' | 'spec' | 'both';\n \n /**\n * Enable registry usage tracking for licensing (default: true)\n */\n trackUsage?: boolean;\n \n /**\n * Namespace to use if not specified in spec\n */\n defaultNamespace?: string;\n \n /**\n * Version to use if not specified in spec\n */\n defaultVersion?: string;\n \n /**\n * How to format resolved specs:\n * - 'preserve-metadata': Keep registry/namespace/name intact (for UI display)\n * - 'embed': Convert to embedded format (for test harness)\n * @default 'preserve-metadata'\n */\n resolutionMode?: ResolutionMode;\n \n /**\n * All available component libraries (for browser context where ComponentMetadataEngine isn't available)\n */\n allLibraries?: MJComponentLibraryEntity[];\n}\n\n/**\n * Result of loading a single component\n */\nexport interface LoadResult {\n /**\n * Whether the load operation succeeded\n */\n success: boolean;\n \n /**\n * The compiled component object\n */\n component?: ComponentObject;\n \n /**\n * The fully resolved component specification\n */\n spec?: ComponentSpec;\n \n /**\n * Whether the component was loaded from cache\n */\n fromCache: boolean;\n \n /**\n * Any errors that occurred during loading\n */\n errors?: Array<{\n message: string;\n phase: 'fetch' | 'compile' | 'register' | 'dependency';\n componentName?: string;\n }>;\n \n /**\n * Components that were loaded as dependencies\n */\n dependencies?: Record<string, ComponentObject>;\n}\n\n/**\n * Result of loading a component hierarchy\n */\nexport interface HierarchyResult {\n /**\n * Whether the entire hierarchy loaded successfully\n */\n success: boolean;\n \n /**\n * The root component object\n */\n rootComponent?: ComponentObject;\n \n /**\n * The fully resolved root specification\n */\n resolvedSpec?: ComponentSpec;\n \n /**\n * List of all component names that were loaded\n */\n loadedComponents: string[];\n \n /**\n * Any errors that occurred during loading\n */\n errors: Array<{\n message: string;\n phase: 'fetch' | 'compile' | 'register' | 'dependency';\n componentName?: string;\n }>;\n \n /**\n * Map of all loaded components by name\n */\n components?: Record<string, ComponentObject>;\n \n /**\n * Number of components loaded from cache vs fetched\n */\n stats?: {\n fromCache: number;\n fetched: number;\n compiled: number;\n totalTime: number;\n };\n}\n\n/**\n * Configuration for ComponentManager\n */\nexport interface ComponentManagerConfig {\n /**\n * Enable debug logging\n */\n debug?: boolean;\n \n /**\n * Maximum cache size for fetched specs\n */\n maxCacheSize?: number;\n \n /**\n * Cache TTL in milliseconds (default: 1 hour)\n */\n cacheTTL?: number;\n \n /**\n * Whether to track registry usage for licensing\n */\n enableUsageTracking?: boolean;\n \n /**\n * Batch size for parallel dependency loading\n */\n dependencyBatchSize?: number;\n \n /**\n * Timeout for registry fetch operations (ms)\n */\n fetchTimeout?: number;\n}\n\n/**\n * Internal cache entry for fetched specs\n */\nexport interface CacheEntry {\n spec: ComponentSpec;\n fetchedAt: Date;\n hash?: string;\n usageNotified: boolean;\n}"]}
|