@memberjunction/react-runtime 3.4.0 → 4.0.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 +33 -25
- package/CHANGELOG.md +28 -0
- package/dist/324.runtime.umd.js +817 -0
- package/dist/490.runtime.umd.js +1 -0
- package/dist/compiler/babel-config.js +15 -21
- package/dist/compiler/babel-config.js.map +1 -1
- package/dist/compiler/component-compiler.js +13 -17
- package/dist/compiler/component-compiler.js.map +1 -1
- package/dist/compiler/index.js +2 -13
- package/dist/compiler/index.js.map +1 -1
- package/dist/component-manager/component-manager.js +7 -34
- package/dist/component-manager/component-manager.js.map +1 -1
- package/dist/component-manager/index.js +1 -5
- package/dist/component-manager/index.js.map +1 -1
- package/dist/component-manager/types.js +1 -2
- package/dist/index.js +31 -100
- package/dist/index.js.map +1 -1
- package/dist/registry/component-registry-service.js +8 -35
- package/dist/registry/component-registry-service.js.map +1 -1
- package/dist/registry/component-registry.js +5 -9
- package/dist/registry/component-registry.js.map +1 -1
- package/dist/registry/component-resolver.js +5 -9
- package/dist/registry/component-resolver.js.map +1 -1
- package/dist/registry/index.js +4 -11
- package/dist/registry/index.js.map +1 -1
- package/dist/registry/registry-provider.js +1 -2
- package/dist/runtime/component-hierarchy.js +24 -55
- package/dist/runtime/component-hierarchy.js.map +1 -1
- package/dist/runtime/component-wrapper.d.ts +18 -0
- package/dist/runtime/component-wrapper.d.ts.map +1 -0
- package/dist/runtime/component-wrapper.js +108 -0
- package/dist/runtime/error-boundary.js +4 -11
- package/dist/runtime/error-boundary.js.map +1 -1
- package/dist/runtime/index.js +4 -26
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/prop-builder.js +17 -28
- package/dist/runtime/prop-builder.js.map +1 -1
- package/dist/runtime/react-root-manager.js +4 -8
- package/dist/runtime/react-root-manager.js.map +1 -1
- package/dist/runtime.umd.js +1 -801
- package/dist/types/dependency-types.js +1 -2
- package/dist/types/index.js +2 -18
- package/dist/types/index.js.map +1 -1
- package/dist/types/library-config.js +1 -2
- package/dist/utilities/cache-manager.js +1 -5
- package/dist/utilities/cache-manager.js.map +1 -1
- package/dist/utilities/component-error-analyzer.js +53 -57
- package/dist/utilities/component-error-analyzer.js.map +1 -1
- package/dist/utilities/component-styles.js +2 -6
- package/dist/utilities/component-styles.js.map +1 -1
- package/dist/utilities/component-unwrapper.d.ts.map +1 -1
- package/dist/utilities/component-unwrapper.js +6 -13
- package/dist/utilities/component-unwrapper.js.map +1 -1
- package/dist/utilities/core-libraries.js +2 -7
- package/dist/utilities/core-libraries.js.map +1 -1
- package/dist/utilities/index.js +9 -25
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/library-dependency-resolver.js +1 -5
- package/dist/utilities/library-dependency-resolver.js.map +1 -1
- package/dist/utilities/library-loader.js +23 -27
- package/dist/utilities/library-loader.js.map +1 -1
- package/dist/utilities/library-registry.d.ts.map +1 -1
- package/dist/utilities/library-registry.js +3 -7
- package/dist/utilities/library-registry.js.map +1 -1
- package/dist/utilities/resource-manager.d.ts +0 -1
- package/dist/utilities/resource-manager.d.ts.map +1 -1
- package/dist/utilities/resource-manager.js +2 -6
- package/dist/utilities/resource-manager.js.map +1 -1
- package/dist/utilities/runtime-utilities.d.ts +10 -0
- package/dist/utilities/runtime-utilities.d.ts.map +1 -0
- package/dist/utilities/runtime-utilities.js +92 -0
- package/dist/utilities/standard-libraries.js +3 -8
- package/dist/utilities/standard-libraries.js.map +1 -1
- package/package.json +17 -17
- package/tsconfig.json +7 -22
- package/tsconfig.tsbuildinfo +1 -0
package/dist/types/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./library-config"), exports);
|
|
18
|
-
__exportStar(require("./dependency-types"), exports);
|
|
1
|
+
export * from './library-config';
|
|
2
|
+
export * from './dependency-types';
|
|
19
3
|
//# sourceMappingURL=index.js.map
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAkOA,cAAc,kBAAkB,CAAC;AAGjC,cAAc,oBAAoB,CAAC","sourcesContent":["/**\n * @fileoverview Core type definitions for the MemberJunction React Runtime.\n * These types are platform-agnostic and can be used in any JavaScript environment.\n * @module @memberjunction/react-runtime/types\n */\n\nimport { UserInfo } from '@memberjunction/core';\nimport { ComponentLibraryEntity } from '@memberjunction/core-entities';\nimport { ComponentLibraryDependency, ComponentStyles, ComponentObject } from '@memberjunction/interactive-component-types';\n\n/**\n * Represents a compiled React component with its metadata\n */\nexport interface CompiledComponent {\n /** Factory function that creates a ComponentObject when called with context */\n factory: (context: RuntimeContext, styles?: ComponentStyles, components?: Record<string, any>) => ComponentObject;\n /** Unique identifier for the component */\n id: string;\n /** Original component name */\n name: string;\n /** Compilation timestamp */\n compiledAt: Date;\n /** Any compilation warnings */\n warnings?: string[];\n}\n\n/**\n * Options for compiling a React component\n */\nexport interface CompileOptions {\n /** Component name for identification */\n componentName: string;\n /** Raw component code to compile */\n componentCode: string;\n /** Optional styles to inject */\n styles?: ComponentStyles;\n /** Whether to use production mode optimizations */\n production?: boolean;\n /** Custom Babel plugins to use */\n babelPlugins?: string[];\n /** Custom Babel presets to use */\n babelPresets?: string[];\n\n /** Library dependencies that the component requires */\n libraries?: ComponentLibraryDependency[];\n \n /** Child component dependencies that the component requires */\n dependencies?: Array<{ name: string; code?: string }>;\n\n /**\n * Required, metadata for all possible libraries allowed by the system\n */\n allLibraries: ComponentLibraryEntity[];\n}\n\n\n/**\n * Registry entry for a compiled component\n */\nexport interface RegistryEntry {\n /** The compiled component object with all methods */\n component: ComponentObject;\n /** Component metadata */\n metadata: ComponentMetadata;\n /** Last access time for LRU cache */\n lastAccessed: Date;\n /** Reference count for cleanup */\n refCount: number;\n}\n\n/**\n * Metadata about a registered component\n */\nexport interface ComponentMetadata {\n /** Unique component identifier */\n id: string;\n /** Component name */\n name: string;\n /** Component version */\n version: string;\n /** Namespace for organization */\n namespace: string;\n /** Registration timestamp */\n registeredAt: Date;\n /** Optional tags for categorization */\n tags?: string[];\n}\n\n/**\n * Error information from component execution\n */\nexport interface ComponentError {\n /** Error message */\n message: string;\n /** Error stack trace */\n stack?: string;\n /** Component name where error occurred */\n componentName: string;\n /** Error phase (compilation, render, etc.) */\n phase: 'compilation' | 'registration' | 'render' | 'runtime';\n /** Additional error details */\n details?: any;\n}\n\n/**\n * Props passed to React components\n */\nexport interface ComponentProps {\n /** Data object for the component */\n data: any;\n /** User-managed state */\n userState: any;\n /** Utility functions available to the component */\n utilities: any;\n /** Callback functions */\n callbacks: any;\n /** Child components available for use */\n components?: Record<string, any>;\n /** Component styles */\n styles?: ComponentStyles;\n /** Standard state change handler for controlled components */\n onStateChanged?: (stateUpdate: Record<string, any>) => void;\n}\n\n/**\n * Configuration for the component compiler\n */\nexport interface CompilerConfig {\n /** Babel configuration */\n babel: {\n /** Presets to use */\n presets: string[];\n /** Plugins to use */\n plugins: string[];\n };\n /** Whether to minify output */\n minify: boolean;\n /** Source map generation */\n sourceMaps: boolean;\n /** Cache compiled components */\n cache: boolean;\n /** Maximum cache size */\n maxCacheSize: number;\n /** Enable debug logging */\n debug?: boolean;\n}\n\n/**\n * Configuration for the component registry\n */\nexport interface RegistryConfig {\n /** Maximum number of components to keep in memory */\n maxComponents: number;\n /** Time in ms before removing unused components */\n cleanupInterval: number;\n /** Whether to use LRU eviction */\n useLRU: boolean;\n /** Namespace isolation */\n enableNamespaces: boolean;\n /** Enable debug logging */\n debug?: boolean;\n}\n\n/**\n * Result of a compilation operation\n */\nexport interface CompilationResult {\n /** Whether compilation succeeded */\n success: boolean;\n /** The compiled component if successful */\n component?: CompiledComponent;\n /** Error information if failed */\n error?: ComponentError;\n /** Compilation duration in ms */\n duration: number;\n /** Size of compiled code in bytes */\n size?: number;\n /** Libraries loaded during compilation */\n loadedLibraries?: Map<string, any>;\n}\n\n/**\n * Runtime context for component execution\n */\nexport interface RuntimeContext {\n /** React library reference */\n React: any;\n /** ReactDOM library reference */\n ReactDOM?: any;\n /** Additional libraries available */\n libraries?: Record<string, any>;\n /** Global utilities */\n utilities?: Record<string, any>;\n}\n\n/**\n * Component lifecycle events\n */\nexport interface ComponentLifecycle {\n /** Called before component mounts */\n beforeMount?: () => void;\n /** Called after component mounts */\n afterMount?: () => void;\n /** Called before component updates */\n beforeUpdate?: (prevProps: any, nextProps: any) => void;\n /** Called after component updates */\n afterUpdate?: (prevProps: any, currentProps: any) => void;\n /** Called before component unmounts */\n beforeUnmount?: () => void;\n}\n\n/**\n * Options for creating an error boundary\n */\nexport interface ErrorBoundaryOptions {\n /** Custom error handler */\n onError?: (error: Error, errorInfo: any) => void;\n /** Fallback UI to render on error */\n fallback?: any;\n /** Whether to log errors */\n logErrors?: boolean;\n /** Error recovery strategy */\n recovery?: 'retry' | 'reset' | 'none';\n}\n\n// Export library configuration types\nexport * from './library-config';\n\n// Export dependency types\nexport * from './dependency-types';\n\n// Re-export ComponentObject for convenience\nexport { ComponentObject } from '@memberjunction/interactive-component-types';"]}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CacheManager = void 0;
|
|
4
|
-
class CacheManager {
|
|
1
|
+
export class CacheManager {
|
|
5
2
|
constructor(options = {}) {
|
|
6
3
|
this.cache = new Map();
|
|
7
4
|
this.memoryUsage = 0;
|
|
@@ -153,5 +150,4 @@ class CacheManager {
|
|
|
153
150
|
}
|
|
154
151
|
}
|
|
155
152
|
}
|
|
156
|
-
exports.CacheManager = CacheManager;
|
|
157
153
|
//# sourceMappingURL=cache-manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache-manager.js","sourceRoot":"","sources":["../../src/utilities/cache-manager.ts"],"names":[],"mappings":";;;AAsBA,MAAa,YAAY;IAMvB,YAAY,UAAwB,EAAE;QAL9B,UAAK,GAAG,IAAI,GAAG,EAAyB,CAAC;QACzC,gBAAW,GAAG,CAAC,CAAC;QAKtB,IAAI,CAAC,OAAO,GAAG;YACb,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,IAAI;YAChC,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,EAAE,GAAG,IAAI,GAAG,IAAI;YAChD,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI;YAC/C,eAAe,EAAE,OAAO,CAAC,eAAe,IAAI,EAAE,GAAG,IAAI;SACtD,CAAC;QAEF,IAAI,IAAI,CAAC,OAAO,CAAC,eAAe,GAAG,CAAC,EAAE,CAAC;YACrC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC3B,CAAC;IACH,CAAC;IAKD,GAAG,CAAC,GAAW,EAAE,KAAQ,EAAE,GAAY;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACtC,MAAM,KAAK,GAAkB;YAC3B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/utilities\n */\n\nexport interface CacheEntry<T> {\n value: T;\n timestamp: number;\n size?: number;\n}\n\nexport interface CacheOptions {\n maxSize?: number; // Maximum number of entries\n maxMemory?: number; // Maximum memory in bytes (estimated)\n defaultTTL?: number; // Default TTL in milliseconds\n cleanupInterval?: number; // Cleanup interval in milliseconds\n}\n\n/**\n * Cache manager with TTL and size limits.\n * Provides automatic cleanup and memory management.\n */\nexport class CacheManager<T = any> {\n private cache = new Map<string, CacheEntry<T>>();\n private memoryUsage = 0;\n private cleanupTimer?: number;\n private readonly options: Required<CacheOptions>;\n\n constructor(options: CacheOptions = {}) {\n this.options = {\n maxSize: options.maxSize || 1000,\n maxMemory: options.maxMemory || 50 * 1024 * 1024, // 50MB default\n defaultTTL: options.defaultTTL || 5 * 60 * 1000, // 5 minutes default\n cleanupInterval: options.cleanupInterval || 60 * 1000 // 1 minute default\n };\n\n if (this.options.cleanupInterval > 0) {\n this.startCleanupTimer();\n }\n }\n\n /**\n * Set a value in the cache\n */\n set(key: string, value: T, ttl?: number): void {\n const size = this.estimateSize(value);\n const entry: CacheEntry<T> = {\n value,\n timestamp: Date.now(),\n size\n };\n\n // Check if we need to evict entries\n if (this.cache.size >= this.options.maxSize) {\n this.evictLRU();\n }\n\n // Check memory usage\n if (this.memoryUsage + size > this.options.maxMemory) {\n this.evictByMemory(size);\n }\n\n // Remove old entry if exists\n const oldEntry = this.cache.get(key);\n if (oldEntry) {\n this.memoryUsage -= oldEntry.size || 0;\n }\n\n this.cache.set(key, entry);\n this.memoryUsage += size;\n\n // Schedule removal if TTL is set\n if (ttl || this.options.defaultTTL) {\n const timeout = ttl || this.options.defaultTTL;\n setTimeout(() => this.delete(key), timeout);\n }\n }\n\n /**\n * Get a value from the cache\n */\n get(key: string): T | undefined {\n const entry = this.cache.get(key);\n if (!entry) return undefined;\n\n // Check if expired\n if (this.isExpired(entry)) {\n this.delete(key);\n return undefined;\n }\n\n // Update timestamp for LRU\n entry.timestamp = Date.now();\n return entry.value;\n }\n\n /**\n * Check if a key exists and is not expired\n */\n has(key: string): boolean {\n const entry = this.cache.get(key);\n if (!entry) return false;\n\n if (this.isExpired(entry)) {\n this.delete(key);\n return false;\n }\n\n return true;\n }\n\n /**\n * Delete a key from the cache\n */\n delete(key: string): boolean {\n const entry = this.cache.get(key);\n if (entry) {\n this.memoryUsage -= entry.size || 0;\n return this.cache.delete(key);\n }\n return false;\n }\n\n /**\n * Clear all entries\n */\n clear(): void {\n this.cache.clear();\n this.memoryUsage = 0;\n }\n\n /**\n * Get cache statistics\n */\n getStats(): {\n size: number;\n memoryUsage: number;\n maxSize: number;\n maxMemory: number;\n } {\n return {\n size: this.cache.size,\n memoryUsage: this.memoryUsage,\n maxSize: this.options.maxSize,\n maxMemory: this.options.maxMemory\n };\n }\n\n /**\n * Manually trigger cleanup\n */\n cleanup(): number {\n let removed = 0;\n const now = Date.now();\n\n for (const [key, entry] of this.cache) {\n if (this.isExpired(entry, now)) {\n this.delete(key);\n removed++;\n }\n }\n\n return removed;\n }\n\n /**\n * Destroy the cache and stop cleanup timer\n */\n destroy(): void {\n this.stopCleanupTimer();\n this.clear();\n }\n\n /**\n * Check if an entry is expired\n */\n private isExpired(entry: CacheEntry<T>, now?: number): boolean {\n if (!this.options.defaultTTL) return false;\n const currentTime = now || Date.now();\n return currentTime - entry.timestamp > this.options.defaultTTL;\n }\n\n /**\n * Evict least recently used entry\n */\n private evictLRU(): void {\n let lruKey: string | undefined;\n let lruTime = Infinity;\n\n for (const [key, entry] of this.cache) {\n if (entry.timestamp < lruTime) {\n lruTime = entry.timestamp;\n lruKey = key;\n }\n }\n\n if (lruKey) {\n this.delete(lruKey);\n }\n }\n\n /**\n * Evict entries to make room for new memory\n */\n private evictByMemory(requiredSize: number): void {\n const entries = Array.from(this.cache.entries())\n .sort((a, b) => a[1].timestamp - b[1].timestamp);\n\n let freedMemory = 0;\n for (const [key, entry] of entries) {\n if (freedMemory >= requiredSize) break;\n freedMemory += entry.size || 0;\n this.delete(key);\n }\n }\n\n /**\n * Estimate size of a value\n */\n private estimateSize(value: T): number {\n if (typeof value === 'string') {\n return value.length * 2; // 2 bytes per character\n } else if (typeof value === 'object' && value !== null) {\n // Rough estimation for objects\n try {\n return JSON.stringify(value).length * 2;\n } catch {\n return 1024; // Default 1KB for objects that can't be stringified\n }\n } else {\n return 8; // Default for primitives\n }\n }\n\n /**\n * Start the cleanup timer\n */\n private startCleanupTimer(): void {\n this.cleanupTimer = window.setInterval(() => {\n this.cleanup();\n }, this.options.cleanupInterval);\n }\n\n /**\n * Stop the cleanup timer\n */\n private stopCleanupTimer(): void {\n if (this.cleanupTimer) {\n window.clearInterval(this.cleanupTimer);\n this.cleanupTimer = undefined;\n }\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"cache-manager.js","sourceRoot":"","sources":["../../src/utilities/cache-manager.ts"],"names":[],"mappings":"AAsBA,MAAM,OAAO,YAAY;IAMvB,YAAY,UAAwB,EAAE;QAL9B,UAAK,GAAG,IAAI,GAAG,EAAyB,CAAC;QACzC,gBAAW,GAAG,CAAC,CAAC;QAKtB,IAAI,CAAC,OAAO,GAAG;YACb,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,IAAI;YAChC,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,EAAE,GAAG,IAAI,GAAG,IAAI;YAChD,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI;YAC/C,eAAe,EAAE,OAAO,CAAC,eAAe,IAAI,EAAE,GAAG,IAAI;SACtD,CAAC;QAEF,IAAI,IAAI,CAAC,OAAO,CAAC,eAAe,GAAG,CAAC,EAAE,CAAC;YACrC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC3B,CAAC;IACH,CAAC;IAKD,GAAG,CAAC,GAAW,EAAE,KAAQ,EAAE,GAAY;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACtC,MAAM,KAAK,GAAkB;YAC3B,K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AS,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAEnD,IAAI,WAAW,GAAG,CAAC,CAAC;QACpB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,EAAE,CAAC;YACnC,IAAI,WAAW,IAAI,YAAY;gBAAE,MAAM;YACvC,WAAW,IAAI,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC;YAC/B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC;IAKO,YAAY,CAAC,KAAQ;QAC3B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QAC1B,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YAEvD,IAAI,CAAC;gBACH,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;YAC1C,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;IAKO,iBAAiB;QACvB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE;YAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACnC,CAAC;IAKO,gBAAgB;QACtB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACxC,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;QAChC,CAAC;IACH,CAAC;CACF","sourcesContent":["/**\n * @fileoverview Cache management with TTL and size limits\n * @module @memberjunction/react-runtime/utilities\n */\n\nexport interface CacheEntry<T> {\n value: T;\n timestamp: number;\n size?: number;\n}\n\nexport interface CacheOptions {\n maxSize?: number; // Maximum number of entries\n maxMemory?: number; // Maximum memory in bytes (estimated)\n defaultTTL?: number; // Default TTL in milliseconds\n cleanupInterval?: number; // Cleanup interval in milliseconds\n}\n\n/**\n * Cache manager with TTL and size limits.\n * Provides automatic cleanup and memory management.\n */\nexport class CacheManager<T = any> {\n private cache = new Map<string, CacheEntry<T>>();\n private memoryUsage = 0;\n private cleanupTimer?: number;\n private readonly options: Required<CacheOptions>;\n\n constructor(options: CacheOptions = {}) {\n this.options = {\n maxSize: options.maxSize || 1000,\n maxMemory: options.maxMemory || 50 * 1024 * 1024, // 50MB default\n defaultTTL: options.defaultTTL || 5 * 60 * 1000, // 5 minutes default\n cleanupInterval: options.cleanupInterval || 60 * 1000 // 1 minute default\n };\n\n if (this.options.cleanupInterval > 0) {\n this.startCleanupTimer();\n }\n }\n\n /**\n * Set a value in the cache\n */\n set(key: string, value: T, ttl?: number): void {\n const size = this.estimateSize(value);\n const entry: CacheEntry<T> = {\n value,\n timestamp: Date.now(),\n size\n };\n\n // Check if we need to evict entries\n if (this.cache.size >= this.options.maxSize) {\n this.evictLRU();\n }\n\n // Check memory usage\n if (this.memoryUsage + size > this.options.maxMemory) {\n this.evictByMemory(size);\n }\n\n // Remove old entry if exists\n const oldEntry = this.cache.get(key);\n if (oldEntry) {\n this.memoryUsage -= oldEntry.size || 0;\n }\n\n this.cache.set(key, entry);\n this.memoryUsage += size;\n\n // Schedule removal if TTL is set\n if (ttl || this.options.defaultTTL) {\n const timeout = ttl || this.options.defaultTTL;\n setTimeout(() => this.delete(key), timeout);\n }\n }\n\n /**\n * Get a value from the cache\n */\n get(key: string): T | undefined {\n const entry = this.cache.get(key);\n if (!entry) return undefined;\n\n // Check if expired\n if (this.isExpired(entry)) {\n this.delete(key);\n return undefined;\n }\n\n // Update timestamp for LRU\n entry.timestamp = Date.now();\n return entry.value;\n }\n\n /**\n * Check if a key exists and is not expired\n */\n has(key: string): boolean {\n const entry = this.cache.get(key);\n if (!entry) return false;\n\n if (this.isExpired(entry)) {\n this.delete(key);\n return false;\n }\n\n return true;\n }\n\n /**\n * Delete a key from the cache\n */\n delete(key: string): boolean {\n const entry = this.cache.get(key);\n if (entry) {\n this.memoryUsage -= entry.size || 0;\n return this.cache.delete(key);\n }\n return false;\n }\n\n /**\n * Clear all entries\n */\n clear(): void {\n this.cache.clear();\n this.memoryUsage = 0;\n }\n\n /**\n * Get cache statistics\n */\n getStats(): {\n size: number;\n memoryUsage: number;\n maxSize: number;\n maxMemory: number;\n } {\n return {\n size: this.cache.size,\n memoryUsage: this.memoryUsage,\n maxSize: this.options.maxSize,\n maxMemory: this.options.maxMemory\n };\n }\n\n /**\n * Manually trigger cleanup\n */\n cleanup(): number {\n let removed = 0;\n const now = Date.now();\n\n for (const [key, entry] of this.cache) {\n if (this.isExpired(entry, now)) {\n this.delete(key);\n removed++;\n }\n }\n\n return removed;\n }\n\n /**\n * Destroy the cache and stop cleanup timer\n */\n destroy(): void {\n this.stopCleanupTimer();\n this.clear();\n }\n\n /**\n * Check if an entry is expired\n */\n private isExpired(entry: CacheEntry<T>, now?: number): boolean {\n if (!this.options.defaultTTL) return false;\n const currentTime = now || Date.now();\n return currentTime - entry.timestamp > this.options.defaultTTL;\n }\n\n /**\n * Evict least recently used entry\n */\n private evictLRU(): void {\n let lruKey: string | undefined;\n let lruTime = Infinity;\n\n for (const [key, entry] of this.cache) {\n if (entry.timestamp < lruTime) {\n lruTime = entry.timestamp;\n lruKey = key;\n }\n }\n\n if (lruKey) {\n this.delete(lruKey);\n }\n }\n\n /**\n * Evict entries to make room for new memory\n */\n private evictByMemory(requiredSize: number): void {\n const entries = Array.from(this.cache.entries())\n .sort((a, b) => a[1].timestamp - b[1].timestamp);\n\n let freedMemory = 0;\n for (const [key, entry] of entries) {\n if (freedMemory >= requiredSize) break;\n freedMemory += entry.size || 0;\n this.delete(key);\n }\n }\n\n /**\n * Estimate size of a value\n */\n private estimateSize(value: T): number {\n if (typeof value === 'string') {\n return value.length * 2; // 2 bytes per character\n } else if (typeof value === 'object' && value !== null) {\n // Rough estimation for objects\n try {\n return JSON.stringify(value).length * 2;\n } catch {\n return 1024; // Default 1KB for objects that can't be stringified\n }\n } else {\n return 8; // Default for primitives\n }\n }\n\n /**\n * Start the cleanup timer\n */\n private startCleanupTimer(): void {\n this.cleanupTimer = window.setInterval(() => {\n this.cleanup();\n }, this.options.cleanupInterval);\n }\n\n /**\n * Stop the cleanup timer\n */\n private stopCleanupTimer(): void {\n if (this.cleanupTimer) {\n window.clearInterval(this.cleanupTimer);\n this.cleanupTimer = undefined;\n }\n }\n}"]}
|
|
@@ -1,7 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export class ComponentErrorAnalyzer {
|
|
2
|
+
static { this.ERROR_PATTERNS = [
|
|
3
|
+
{
|
|
4
|
+
pattern: /ReferenceError: (\w+) is not defined/,
|
|
5
|
+
errorType: 'not_defined',
|
|
6
|
+
extractComponent: (match) => match[1]
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
pattern: /Cannot read propert(?:y|ies) '(\w+)' of undefined/,
|
|
10
|
+
errorType: 'property_error',
|
|
11
|
+
extractComponent: (match) => match[1]
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
pattern: /(\w+)\(\.\.\.\): Nothing was returned from render/,
|
|
15
|
+
errorType: 'render_error',
|
|
16
|
+
extractComponent: (match) => match[1]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
pattern: /at (\w+Component\w*)/,
|
|
20
|
+
errorType: 'stack_trace',
|
|
21
|
+
extractComponent: (match) => match[1]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
pattern: /Error: Unable to find node on an unmounted component/,
|
|
25
|
+
errorType: 'unmounted_component',
|
|
26
|
+
extractComponent: () => null
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
pattern: /Invalid hook call.*component (\w+)/,
|
|
30
|
+
errorType: 'invalid_hook',
|
|
31
|
+
extractComponent: (match) => match[1]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
pattern: /TypeError:.*in (\w+) \(at/,
|
|
35
|
+
errorType: 'type_error',
|
|
36
|
+
extractComponent: (match) => match[1]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
pattern: /Module not found: Error: Can't resolve '\.\/(\w+)'/,
|
|
40
|
+
errorType: 'missing_import',
|
|
41
|
+
extractComponent: (match) => match[1]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
pattern: /(\w+) is not a function/,
|
|
45
|
+
errorType: 'not_a_function',
|
|
46
|
+
extractComponent: (match) => match[1]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
pattern: /Minified React error.*Visit.*for the full message.*component[: ](\w+)/s,
|
|
50
|
+
errorType: 'react_error',
|
|
51
|
+
extractComponent: (match) => match[1]
|
|
52
|
+
}
|
|
53
|
+
]; }
|
|
5
54
|
static identifyFailedComponents(errors) {
|
|
6
55
|
const failedComponents = new Set();
|
|
7
56
|
for (const error of errors) {
|
|
@@ -149,57 +198,4 @@ class ComponentErrorAnalyzer {
|
|
|
149
198
|
return result;
|
|
150
199
|
}
|
|
151
200
|
}
|
|
152
|
-
exports.ComponentErrorAnalyzer = ComponentErrorAnalyzer;
|
|
153
|
-
ComponentErrorAnalyzer.ERROR_PATTERNS = [
|
|
154
|
-
{
|
|
155
|
-
pattern: /ReferenceError: (\w+) is not defined/,
|
|
156
|
-
errorType: 'not_defined',
|
|
157
|
-
extractComponent: (match) => match[1]
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
pattern: /Cannot read propert(?:y|ies) '(\w+)' of undefined/,
|
|
161
|
-
errorType: 'property_error',
|
|
162
|
-
extractComponent: (match) => match[1]
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
pattern: /(\w+)\(\.\.\.\): Nothing was returned from render/,
|
|
166
|
-
errorType: 'render_error',
|
|
167
|
-
extractComponent: (match) => match[1]
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
pattern: /at (\w+Component\w*)/,
|
|
171
|
-
errorType: 'stack_trace',
|
|
172
|
-
extractComponent: (match) => match[1]
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
pattern: /Error: Unable to find node on an unmounted component/,
|
|
176
|
-
errorType: 'unmounted_component',
|
|
177
|
-
extractComponent: () => null
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
pattern: /Invalid hook call.*component (\w+)/,
|
|
181
|
-
errorType: 'invalid_hook',
|
|
182
|
-
extractComponent: (match) => match[1]
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
pattern: /TypeError:.*in (\w+) \(at/,
|
|
186
|
-
errorType: 'type_error',
|
|
187
|
-
extractComponent: (match) => match[1]
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
pattern: /Module not found: Error: Can't resolve '\.\/(\w+)'/,
|
|
191
|
-
errorType: 'missing_import',
|
|
192
|
-
extractComponent: (match) => match[1]
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
pattern: /(\w+) is not a function/,
|
|
196
|
-
errorType: 'not_a_function',
|
|
197
|
-
extractComponent: (match) => match[1]
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
pattern: /Minified React error.*Visit.*for the full message.*component[: ](\w+)/s,
|
|
201
|
-
errorType: 'react_error',
|
|
202
|
-
extractComponent: (match) => match[1]
|
|
203
|
-
}
|
|
204
|
-
];
|
|
205
201
|
//# sourceMappingURL=component-error-analyzer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-error-analyzer.js","sourceRoot":"","sources":["../../src/utilities/component-error-analyzer.ts"],"names":[],"mappings":";;;AAyBA,MAAa,sBAAsB;IAwEjC,MAAM,CAAC,wBAAwB,CAAC,MAAgB;QAC9C,MAAM,gBAAgB,GA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,EAAE,CAAC,KAAuB,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;KACxD;IACD;QAEE,OAAO,EAAE,sBAAsB;QAC/B,SAAS,EAAE,aAAa;QACxB,gBAAgB,EAAE,CAAC,KAAuB,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;KACxD;IACD;QAEE,OAAO,EAAE,sDAAsD;QAC/D,SAAS,EAAE,qBAAqB;QAChC,gBAAgB,EAAE,GAAG,EAAE,CAAC,IAAI;KAC7B;IACD;QAEE,OAAO,EAAE,oCAAoC;QAC7C,SAAS,EAAE,cAAc;QACzB,gBAAgB,EAAE,CAAC,KAAuB,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;KACxD;IACD;QAEE,OAAO,EAAE,2BAA2B;QACpC,SAAS,EAAE,YAAY;QACvB,gBAAgB,EAAE,CAAC,KAAuB,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;KACxD;IACD;QAEE,OAAO,EAAE,oDAAoD;QAC7D,SAAS,EAAE,gBAAgB;QAC3B,gBAAgB,EAAE,CAAC,KAAuB,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;KACxD;IACD;QAEE,OAAO,EAAE,yBAAyB;QAClC,SAAS,EAAE,gBAAgB;QAC3B,gBAAgB,EAAE,CAAC,KAAuB,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;KACxD;IACD;QAEE,OAAO,EAAE,wEAAwE;QACjF,SAAS,EAAE,aAAa;QACxB,gBAAgB,EAAE,CAAC,KAAuB,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;KACxD;CACF,CAAC","sourcesContent":["/**\n * @fileoverview Component error analysis utilities\n * Provides methods to analyze component errors and identify failed components\n * @module @memberjunction/react-runtime/utilities\n */\n\n/**\n * Information about a failed component\n */\nexport interface FailedComponentInfo {\n /** Component name that failed */\n componentName: string;\n /** Error type (e.g., 'not_defined', 'render_error', 'property_error') */\n errorType: string;\n /** Original error message */\n errorMessage: string;\n /** Line number if available */\n lineNumber?: number;\n /** Additional context */\n context?: string;\n}\n\n/**\n * Analyzes component errors to provide detailed failure information\n */\nexport class ComponentErrorAnalyzer {\n /**\n * Common error patterns for component failures\n */\n private static readonly ERROR_PATTERNS = [\n {\n // Component is not defined\n pattern: /ReferenceError: (\\w+) is not defined/,\n errorType: 'not_defined',\n extractComponent: (match: RegExpMatchArray) => match[1]\n },\n {\n // Cannot read property of undefined (component reference)\n pattern: /Cannot read propert(?:y|ies) '(\\w+)' of undefined/,\n errorType: 'property_error',\n extractComponent: (match: RegExpMatchArray) => match[1]\n },\n {\n // Component render errors\n pattern: /(\\w+)\\(\\.\\.\\.\\): Nothing was returned from render/,\n errorType: 'render_error',\n extractComponent: (match: RegExpMatchArray) => match[1]\n },\n {\n // Component in stack trace\n pattern: /at (\\w+Component\\w*)/,\n errorType: 'stack_trace',\n extractComponent: (match: RegExpMatchArray) => match[1]\n },\n {\n // React component errors\n pattern: /Error: Unable to find node on an unmounted component/,\n errorType: 'unmounted_component',\n extractComponent: () => null // Need to look at stack trace\n },\n {\n // Hook errors\n pattern: /Invalid hook call.*component (\\w+)/,\n errorType: 'invalid_hook',\n extractComponent: (match: RegExpMatchArray) => match[1]\n },\n {\n // Type errors in components\n pattern: /TypeError:.*in (\\w+) \\(at/,\n errorType: 'type_error',\n extractComponent: (match: RegExpMatchArray) => match[1]\n },\n {\n // Missing imports/components\n pattern: /Module not found: Error: Can't resolve '\\.\\/(\\w+)'/,\n errorType: 'missing_import',\n extractComponent: (match: RegExpMatchArray) => match[1]\n },\n {\n // Component is not a function\n pattern: /(\\w+) is not a function/,\n errorType: 'not_a_function',\n extractComponent: (match: RegExpMatchArray) => match[1]\n },\n {\n // Minified React error with component hint\n pattern: /Minified React error.*Visit.*for the full message.*component[: ](\\w+)/s,\n errorType: 'react_error',\n extractComponent: (match: RegExpMatchArray) => match[1]\n }\n ];\n\n /**\n * Analyzes error messages to identify which components failed\n * @param errors Array of error messages\n * @returns Array of failed component names\n */\n static identifyFailedComponents(errors: string[]): string[] {\n const failedComponents = new Set<string>();\n \n for (const error of errors) {\n const components = this.extractComponentsFromError(error);\n components.forEach(comp => failedComponents.add(comp));\n }\n \n return Array.from(failedComponents);\n }\n\n /**\n * Analyzes errors and returns detailed information about failures\n * @param errors Array of error messages\n * @returns Array of detailed failure information\n */\n static analyzeComponentErrors(errors: string[]): FailedComponentInfo[] {\n const failures: FailedComponentInfo[] = [];\n \n for (const error of errors) {\n const failureInfo = this.analyzeError(error);\n failures.push(...failureInfo);\n }\n \n // Remove duplicates based on component name and error type\n const uniqueFailures = new Map<string, FailedComponentInfo>();\n failures.forEach(failure => {\n const key = `${failure.componentName}-${failure.errorType}`;\n if (!uniqueFailures.has(key)) {\n uniqueFailures.set(key, failure);\n }\n });\n \n return Array.from(uniqueFailures.values());\n }\n\n /**\n * Extract component names from a single error message\n */\n private static extractComponentsFromError(error: string): string[] {\n const components: string[] = [];\n \n for (const errorPattern of this.ERROR_PATTERNS) {\n const match = error.match(errorPattern.pattern);\n if (match) {\n const componentName = errorPattern.extractComponent(match);\n if (componentName && this.isLikelyComponentName(componentName)) {\n components.push(componentName);\n }\n }\n }\n \n // Also check for components in stack traces\n const stackComponents = this.extractComponentsFromStackTrace(error);\n components.push(...stackComponents);\n \n return components;\n }\n\n /**\n * Analyze a single error and return detailed information\n */\n private static analyzeError(error: string): FailedComponentInfo[] {\n const failures: FailedComponentInfo[] = [];\n \n for (const errorPattern of this.ERROR_PATTERNS) {\n const match = error.match(errorPattern.pattern);\n if (match) {\n const componentName = errorPattern.extractComponent(match);\n if (componentName && this.isLikelyComponentName(componentName)) {\n failures.push({\n componentName,\n errorType: errorPattern.errorType,\n errorMessage: error,\n lineNumber: this.extractLineNumber(error),\n context: this.extractContext(error)\n });\n }\n }\n }\n \n // If no specific pattern matched, try to extract from stack trace\n if (failures.length === 0) {\n const stackComponents = this.extractComponentsFromStackTrace(error);\n stackComponents.forEach(componentName => {\n failures.push({\n componentName,\n errorType: 'unknown',\n errorMessage: error,\n lineNumber: this.extractLineNumber(error)\n });\n });\n }\n \n return failures;\n }\n\n /**\n * Extract component names from stack trace\n */\n private static extractComponentsFromStackTrace(error: string): string[] {\n const components: string[] = [];\n \n // Look for React component patterns in stack traces\n const stackPatterns = [\n /at (\\w+Component\\w*)/g,\n /at (\\w+)\\s*\\(/g,\n /in (\\w+)\\s*\\(at/g,\n /in (\\w+)\\s*\\(created by/g\n ];\n \n for (const pattern of stackPatterns) {\n let match;\n while ((match = pattern.exec(error)) !== null) {\n const name = match[1];\n if (this.isLikelyComponentName(name)) {\n components.push(name);\n }\n }\n }\n \n return [...new Set(components)]; // Remove duplicates\n }\n\n /**\n * Check if a string is likely to be a React component name\n */\n private static isLikelyComponentName(name: string): boolean {\n // Component names typically:\n // - Start with uppercase letter\n // - Are not JavaScript built-ins\n // - Are not common non-component names\n \n const jsBuiltins = new Set([\n 'Object', 'Array', 'String', 'Number', 'Boolean', 'Function',\n 'Promise', 'Error', 'TypeError', 'ReferenceError', 'SyntaxError',\n 'undefined', 'null', 'console', 'window', 'document'\n ]);\n \n const nonComponents = new Set([\n 'render', 'setState', 'forceUpdate', 'props', 'state', 'context',\n 'componentDidMount', 'componentWillUnmount', 'useEffect', 'useState'\n ]);\n \n return (\n name.length > 0 &&\n /^[A-Z]/.test(name) && // Starts with uppercase\n !jsBuiltins.has(name) &&\n !nonComponents.has(name) &&\n !/^use[A-Z]/.test(name) // Not a hook\n );\n }\n\n /**\n * Extract line number from error message\n */\n private static extractLineNumber(error: string): number | undefined {\n // Look for patterns like \":12:34\" or \"line 12\"\n const patterns = [\n /:(\\d+):\\d+/,\n /line (\\d+)/i,\n /Line (\\d+)/\n ];\n \n for (const pattern of patterns) {\n const match = error.match(pattern);\n if (match) {\n return parseInt(match[1], 10);\n }\n }\n \n return undefined;\n }\n\n /**\n * Extract additional context from error\n */\n private static extractContext(error: string): string | undefined {\n // Extract file names or additional context\n const fileMatch = error.match(/\\(at ([^)]+)\\)/);\n if (fileMatch) {\n return fileMatch[1];\n }\n \n // Extract \"created by\" information\n const createdByMatch = error.match(/created by (\\w+)/);\n if (createdByMatch) {\n return `Created by ${createdByMatch[1]}`;\n }\n \n return undefined;\n }\n\n /**\n * Format error analysis results for logging\n */\n static formatAnalysisResults(failures: FailedComponentInfo[]): string {\n if (failures.length === 0) {\n return 'No component failures detected';\n }\n \n let result = `Detected ${failures.length} component failure(s):\\n`;\n \n failures.forEach((failure, index) => {\n result += `\\n${index + 1}. Component: ${failure.componentName}\\n`;\n result += ` Error Type: ${failure.errorType}\\n`;\n if (failure.lineNumber) {\n result += ` Line: ${failure.lineNumber}\\n`;\n }\n if (failure.context) {\n result += ` Context: ${failure.context}\\n`;\n }\n result += ` Message: ${failure.errorMessage.substring(0, 200)}${failure.errorMessage.length > 200 ? '...' : ''}\\n`;\n });\n \n return result;\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"component-error-analyzer.js","sourceRoot":"","sources":["../../src/utilities/component-error-analyzer.ts"],"names":[],"mappings":"AAyBA,MAAM,OAAO,sBAAsB;aAIT,mBAAc,GAAG;QACvC;YAEE,OAAO,EAAE,sCAAsC;YAC/C,SAAS,EAAE,aAAa;YACxB,gBAAgB,EAAE,CAAC,KAAuB,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;SACxD;QACD;YAEE,OAAO,EAAE,mDAAmD;YAC5D,SAAS,EAAE,gBAAgB;YAC3B,gBAAgB,EAAE,CAAC,KAAuB,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;SACxD;QACD;YAEE,OAAO,EAAE,mDAAmD;YAC5D,SAAS,EAAE,cAAc;YACzB,gBAAgB,EAAE,CAAC,KAAuB,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;SACxD;QACD;YAEE,OAAO,EAAE,sBAAsB;YAC/B,SAAS,EAAE,aAAa;YACxB,gBAAgB,EAAE,CAAC,KAAuB,EAAE,EAAE,CAAC,KAAK,CAA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,kBAAkB,OAAO,CAAC,SAAS,IAAI,CAAC;YAClD,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBACvB,MAAM,IAAI,YAAY,OAAO,CAAC,UAAU,IAAI,CAAC;YAC/C,CAAC;YACD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;gBACpB,MAAM,IAAI,eAAe,OAAO,CAAC,OAAO,IAAI,CAAC;YAC/C,CAAC;YACD,MAAM,IAAI,eAAe,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;QACvH,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC","sourcesContent":["/**\n * @fileoverview Component error analysis utilities\n * Provides methods to analyze component errors and identify failed components\n * @module @memberjunction/react-runtime/utilities\n */\n\n/**\n * Information about a failed component\n */\nexport interface FailedComponentInfo {\n /** Component name that failed */\n componentName: string;\n /** Error type (e.g., 'not_defined', 'render_error', 'property_error') */\n errorType: string;\n /** Original error message */\n errorMessage: string;\n /** Line number if available */\n lineNumber?: number;\n /** Additional context */\n context?: string;\n}\n\n/**\n * Analyzes component errors to provide detailed failure information\n */\nexport class ComponentErrorAnalyzer {\n /**\n * Common error patterns for component failures\n */\n private static readonly ERROR_PATTERNS = [\n {\n // Component is not defined\n pattern: /ReferenceError: (\\w+) is not defined/,\n errorType: 'not_defined',\n extractComponent: (match: RegExpMatchArray) => match[1]\n },\n {\n // Cannot read property of undefined (component reference)\n pattern: /Cannot read propert(?:y|ies) '(\\w+)' of undefined/,\n errorType: 'property_error',\n extractComponent: (match: RegExpMatchArray) => match[1]\n },\n {\n // Component render errors\n pattern: /(\\w+)\\(\\.\\.\\.\\): Nothing was returned from render/,\n errorType: 'render_error',\n extractComponent: (match: RegExpMatchArray) => match[1]\n },\n {\n // Component in stack trace\n pattern: /at (\\w+Component\\w*)/,\n errorType: 'stack_trace',\n extractComponent: (match: RegExpMatchArray) => match[1]\n },\n {\n // React component errors\n pattern: /Error: Unable to find node on an unmounted component/,\n errorType: 'unmounted_component',\n extractComponent: () => null // Need to look at stack trace\n },\n {\n // Hook errors\n pattern: /Invalid hook call.*component (\\w+)/,\n errorType: 'invalid_hook',\n extractComponent: (match: RegExpMatchArray) => match[1]\n },\n {\n // Type errors in components\n pattern: /TypeError:.*in (\\w+) \\(at/,\n errorType: 'type_error',\n extractComponent: (match: RegExpMatchArray) => match[1]\n },\n {\n // Missing imports/components\n pattern: /Module not found: Error: Can't resolve '\\.\\/(\\w+)'/,\n errorType: 'missing_import',\n extractComponent: (match: RegExpMatchArray) => match[1]\n },\n {\n // Component is not a function\n pattern: /(\\w+) is not a function/,\n errorType: 'not_a_function',\n extractComponent: (match: RegExpMatchArray) => match[1]\n },\n {\n // Minified React error with component hint\n pattern: /Minified React error.*Visit.*for the full message.*component[: ](\\w+)/s,\n errorType: 'react_error',\n extractComponent: (match: RegExpMatchArray) => match[1]\n }\n ];\n\n /**\n * Analyzes error messages to identify which components failed\n * @param errors Array of error messages\n * @returns Array of failed component names\n */\n static identifyFailedComponents(errors: string[]): string[] {\n const failedComponents = new Set<string>();\n \n for (const error of errors) {\n const components = this.extractComponentsFromError(error);\n components.forEach(comp => failedComponents.add(comp));\n }\n \n return Array.from(failedComponents);\n }\n\n /**\n * Analyzes errors and returns detailed information about failures\n * @param errors Array of error messages\n * @returns Array of detailed failure information\n */\n static analyzeComponentErrors(errors: string[]): FailedComponentInfo[] {\n const failures: FailedComponentInfo[] = [];\n \n for (const error of errors) {\n const failureInfo = this.analyzeError(error);\n failures.push(...failureInfo);\n }\n \n // Remove duplicates based on component name and error type\n const uniqueFailures = new Map<string, FailedComponentInfo>();\n failures.forEach(failure => {\n const key = `${failure.componentName}-${failure.errorType}`;\n if (!uniqueFailures.has(key)) {\n uniqueFailures.set(key, failure);\n }\n });\n \n return Array.from(uniqueFailures.values());\n }\n\n /**\n * Extract component names from a single error message\n */\n private static extractComponentsFromError(error: string): string[] {\n const components: string[] = [];\n \n for (const errorPattern of this.ERROR_PATTERNS) {\n const match = error.match(errorPattern.pattern);\n if (match) {\n const componentName = errorPattern.extractComponent(match);\n if (componentName && this.isLikelyComponentName(componentName)) {\n components.push(componentName);\n }\n }\n }\n \n // Also check for components in stack traces\n const stackComponents = this.extractComponentsFromStackTrace(error);\n components.push(...stackComponents);\n \n return components;\n }\n\n /**\n * Analyze a single error and return detailed information\n */\n private static analyzeError(error: string): FailedComponentInfo[] {\n const failures: FailedComponentInfo[] = [];\n \n for (const errorPattern of this.ERROR_PATTERNS) {\n const match = error.match(errorPattern.pattern);\n if (match) {\n const componentName = errorPattern.extractComponent(match);\n if (componentName && this.isLikelyComponentName(componentName)) {\n failures.push({\n componentName,\n errorType: errorPattern.errorType,\n errorMessage: error,\n lineNumber: this.extractLineNumber(error),\n context: this.extractContext(error)\n });\n }\n }\n }\n \n // If no specific pattern matched, try to extract from stack trace\n if (failures.length === 0) {\n const stackComponents = this.extractComponentsFromStackTrace(error);\n stackComponents.forEach(componentName => {\n failures.push({\n componentName,\n errorType: 'unknown',\n errorMessage: error,\n lineNumber: this.extractLineNumber(error)\n });\n });\n }\n \n return failures;\n }\n\n /**\n * Extract component names from stack trace\n */\n private static extractComponentsFromStackTrace(error: string): string[] {\n const components: string[] = [];\n \n // Look for React component patterns in stack traces\n const stackPatterns = [\n /at (\\w+Component\\w*)/g,\n /at (\\w+)\\s*\\(/g,\n /in (\\w+)\\s*\\(at/g,\n /in (\\w+)\\s*\\(created by/g\n ];\n \n for (const pattern of stackPatterns) {\n let match;\n while ((match = pattern.exec(error)) !== null) {\n const name = match[1];\n if (this.isLikelyComponentName(name)) {\n components.push(name);\n }\n }\n }\n \n return [...new Set(components)]; // Remove duplicates\n }\n\n /**\n * Check if a string is likely to be a React component name\n */\n private static isLikelyComponentName(name: string): boolean {\n // Component names typically:\n // - Start with uppercase letter\n // - Are not JavaScript built-ins\n // - Are not common non-component names\n \n const jsBuiltins = new Set([\n 'Object', 'Array', 'String', 'Number', 'Boolean', 'Function',\n 'Promise', 'Error', 'TypeError', 'ReferenceError', 'SyntaxError',\n 'undefined', 'null', 'console', 'window', 'document'\n ]);\n \n const nonComponents = new Set([\n 'render', 'setState', 'forceUpdate', 'props', 'state', 'context',\n 'componentDidMount', 'componentWillUnmount', 'useEffect', 'useState'\n ]);\n \n return (\n name.length > 0 &&\n /^[A-Z]/.test(name) && // Starts with uppercase\n !jsBuiltins.has(name) &&\n !nonComponents.has(name) &&\n !/^use[A-Z]/.test(name) // Not a hook\n );\n }\n\n /**\n * Extract line number from error message\n */\n private static extractLineNumber(error: string): number | undefined {\n // Look for patterns like \":12:34\" or \"line 12\"\n const patterns = [\n /:(\\d+):\\d+/,\n /line (\\d+)/i,\n /Line (\\d+)/\n ];\n \n for (const pattern of patterns) {\n const match = error.match(pattern);\n if (match) {\n return parseInt(match[1], 10);\n }\n }\n \n return undefined;\n }\n\n /**\n * Extract additional context from error\n */\n private static extractContext(error: string): string | undefined {\n // Extract file names or additional context\n const fileMatch = error.match(/\\(at ([^)]+)\\)/);\n if (fileMatch) {\n return fileMatch[1];\n }\n \n // Extract \"created by\" information\n const createdByMatch = error.match(/created by (\\w+)/);\n if (createdByMatch) {\n return `Created by ${createdByMatch[1]}`;\n }\n \n return undefined;\n }\n\n /**\n * Format error analysis results for logging\n */\n static formatAnalysisResults(failures: FailedComponentInfo[]): string {\n if (failures.length === 0) {\n return 'No component failures detected';\n }\n \n let result = `Detected ${failures.length} component failure(s):\\n`;\n \n failures.forEach((failure, index) => {\n result += `\\n${index + 1}. Component: ${failure.componentName}\\n`;\n result += ` Error Type: ${failure.errorType}\\n`;\n if (failure.lineNumber) {\n result += ` Line: ${failure.lineNumber}\\n`;\n }\n if (failure.context) {\n result += ` Context: ${failure.context}\\n`;\n }\n result += ` Message: ${failure.errorMessage.substring(0, 200)}${failure.errorMessage.length > 200 ? '...' : ''}\\n`;\n });\n \n return result;\n }\n}"]}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createDefaultComponentStyles = exports.SetupStyles = void 0;
|
|
4
|
-
function SetupStyles() {
|
|
1
|
+
export function SetupStyles() {
|
|
5
2
|
return {
|
|
6
3
|
colors: {
|
|
7
4
|
primary: '#5B4FE9',
|
|
@@ -93,6 +90,5 @@ function SetupStyles() {
|
|
|
93
90
|
overflow: 'auto'
|
|
94
91
|
};
|
|
95
92
|
}
|
|
96
|
-
|
|
97
|
-
exports.createDefaultComponentStyles = SetupStyles;
|
|
93
|
+
export const createDefaultComponentStyles = SetupStyles;
|
|
98
94
|
//# sourceMappingURL=component-styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-styles.js","sourceRoot":"","sources":["../../src/utilities/component-styles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"component-styles.js","sourceRoot":"","sources":["../../src/utilities/component-styles.ts"],"names":[],"mappings":"AAYA,MAAM,UAAU,WAAW;IAEzB,OAAO;QACL,MAAM,EAAE;YAEN,OAAO,EAAE,SAAS;YAClB,YAAY,EAAE,SAAS;YACvB,YAAY,EAAE,SAAS;YAGvB,SAAS,EAAE,SAAS;YACpB,cAAc,EAAE,SAAS;YAGzB,OAAO,EAAE,SAAS;YAClB,YAAY,EAAE,SAAS;YACvB,OAAO,EAAE,SAAS;YAClB,YAAY,EAAE,SAAS;YACvB,KAAK,EAAE,SAAS;YAChB,UAAU,EAAE,SAAS;YACrB,IAAI,EAAE,SAAS;YACf,SAAS,EAAE,SAAS;YAGpB,UAAU,EAAE,SAAS;YACrB,OAAO,EAAE,SAAS;YAClB,YAAY,EAAE,SAAS;YAGvB,IAAI,EAAE,SAAS;YACf,aAAa,EAAE,SAAS;YACxB,YAAY,EAAE,SAAS;YACvB,WAAW,EAAE,SAAS;YAGtB,M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QACD,WAAW,EAAE;YACX,IAAI,EAAE,mBAAmB;YACzB,MAAM,EAAE,mBAAmB;YAC3B,IAAI,EAAE,mBAAmB;SAC1B;QACD,QAAQ,EAAE,MAAM;KACjB,CAAA;AACH,CAAC;AAGD,MAAM,CAAC,MAAM,4BAA4B,GAAG,WAAW,CAAC","sourcesContent":["/**\n * @fileoverview Default component styles for React runtime\n * @module @memberjunction/react-runtime/utilities\n */\n\nimport { ComponentStyles } from '@memberjunction/interactive-component-types';\n\n/**\n * Creates the default component styles for Skip components\n * These provide a modern, contemporary look and feel\n * Copied from skip-chat implementation\n */\nexport function SetupStyles(): ComponentStyles {\n // Return modern, contemporary styles for generated components\n return {\n colors: {\n // Primary colors - modern purple/blue gradient feel\n primary: '#5B4FE9',\n primaryHover: '#4940D4',\n primaryLight: '#E8E6FF',\n \n // Secondary colors - sophisticated gray\n secondary: '#64748B',\n secondaryHover: '#475569',\n \n // Status colors\n success: '#10B981',\n successLight: '#D1FAE5',\n warning: '#F59E0B',\n warningLight: '#FEF3C7',\n error: '#EF4444',\n errorLight: '#FEE2E2',\n info: '#3B82F6',\n infoLight: '#DBEAFE',\n \n // Base colors\n background: '#FFFFFF',\n surface: '#F8FAFC',\n surfaceHover: '#F1F5F9',\n \n // Text colors with better contrast\n text: '#1E293B',\n textSecondary: '#64748B',\n textTertiary: '#94A3B8',\n textInverse: '#FFFFFF',\n \n // Border colors\n border: '#E2E8F0',\n borderLight: '#F1F5F9',\n borderFocus: '#5B4FE9',\n \n // Shadows (as color strings for easy use)\n shadow: 'rgba(0, 0, 0, 0.05)',\n shadowMedium: 'rgba(0, 0, 0, 0.1)',\n shadowLarge: 'rgba(0, 0, 0, 0.15)',\n },\n spacing: {\n xs: '4px',\n sm: '8px',\n md: '16px',\n lg: '24px',\n xl: '32px',\n xxl: '48px',\n xxxl: '64px',\n },\n typography: {\n fontFamily: '-apple-system, BlinkMacSystemFont, \"Inter\", \"Segoe UI\", Roboto, sans-serif',\n fontSize: {\n xs: '11px',\n sm: '12px',\n md: '14px',\n lg: '16px',\n xl: '20px',\n xxl: '24px',\n xxxl: '32px',\n },\n fontWeight: {\n light: '300',\n regular: '400',\n medium: '500',\n semibold: '600',\n bold: '700',\n },\n lineHeight: {\n tight: '1.25',\n normal: '1.5',\n relaxed: '1.75',\n },\n },\n borders: {\n radius: {\n sm: '6px',\n md: '8px',\n lg: '12px',\n xl: '16px',\n full: '9999px',\n },\n width: {\n thin: '1px',\n medium: '2px',\n thick: '3px',\n },\n },\n shadows: {\n sm: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',\n md: '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)',\n lg: '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)',\n xl: '0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)',\n inner: 'inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)',\n },\n transitions: {\n fast: '150ms ease-in-out',\n normal: '250ms ease-in-out',\n slow: '350ms ease-in-out',\n },\n overflow: 'auto' // Default overflow style \n }\n}\n\n// Also export with the original name for backward compatibility\nexport const createDefaultComponentStyles = SetupStyles;"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-unwrapper.d.ts","sourceRoot":"","sources":["../../src/utilities/component-unwrapper.ts"],"names":[],"mappings":"AAwQA,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,GAAE,OAAe,GAAG,GAAG,CASpG;AASD,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,GAAG,EACZ,GAAG,WAAW,EAAE,MAAM,EAAE,GACvB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAqFrB;AASD,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,GAAE,OAAe,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CA8FpG;AAGD,eAAO,MAAM,eAAe,+BAAyB,CAAC;AACtD,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"component-unwrapper.d.ts","sourceRoot":"","sources":["../../src/utilities/component-unwrapper.ts"],"names":[],"mappings":"AAwQA,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,GAAE,OAAe,GAAG,GAAG,CASpG;AASD,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,GAAG,EACZ,GAAG,WAAW,EAAE,MAAM,EAAE,GACvB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAqFrB;AASD,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,GAAE,OAAe,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CA8FpG;AAGD,eAAO,MAAM,eAAe,+BAAyB,CAAC;AACtD,eAAO,MAAM,gBAAgB,GAAI,SAAS,GAAG,EAAE,aAAa,MAAM,EAAE,EAAE,QAAO,OAAe,wBAE3F,CAAC;AACF,eAAO,MAAM,mBAAmB,mCAA6B,CAAC"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.unwrapAllComponents = exports.unwrapComponents = exports.unwrapComponent = exports.unwrapAllLibraryComponents = exports.unwrapLibraryComponents = exports.unwrapLibraryComponent = void 0;
|
|
4
1
|
function coreUnwrapLogic(library, exportName, debug = false) {
|
|
5
2
|
if (library == null) {
|
|
6
3
|
throw new Error(`Cannot unwrap export '${exportName}' from null or undefined library`);
|
|
@@ -195,7 +192,7 @@ function coreUnwrapLogic(library, exportName, debug = false) {
|
|
|
195
192
|
}
|
|
196
193
|
return component;
|
|
197
194
|
}
|
|
198
|
-
function unwrapLibraryComponent(library, exportName, debug = false) {
|
|
195
|
+
export function unwrapLibraryComponent(library, exportName, debug = false) {
|
|
199
196
|
try {
|
|
200
197
|
return coreUnwrapLogic(library, exportName, debug);
|
|
201
198
|
}
|
|
@@ -206,8 +203,7 @@ function unwrapLibraryComponent(library, exportName, debug = false) {
|
|
|
206
203
|
throw error;
|
|
207
204
|
}
|
|
208
205
|
}
|
|
209
|
-
|
|
210
|
-
function unwrapLibraryComponents(library, ...exportNames) {
|
|
206
|
+
export function unwrapLibraryComponents(library, ...exportNames) {
|
|
211
207
|
let debug = false;
|
|
212
208
|
let names = exportNames;
|
|
213
209
|
const lastArg = exportNames[exportNames.length - 1];
|
|
@@ -277,8 +273,7 @@ function unwrapLibraryComponents(library, ...exportNames) {
|
|
|
277
273
|
}
|
|
278
274
|
return components;
|
|
279
275
|
}
|
|
280
|
-
|
|
281
|
-
function unwrapAllLibraryComponents(library, debug = false) {
|
|
276
|
+
export function unwrapAllLibraryComponents(library, debug = false) {
|
|
282
277
|
const components = {};
|
|
283
278
|
const libraryType = typeof library;
|
|
284
279
|
if (library == null ||
|
|
@@ -359,11 +354,9 @@ function unwrapAllLibraryComponents(library, debug = false) {
|
|
|
359
354
|
}
|
|
360
355
|
return components;
|
|
361
356
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
const unwrapComponents = (library, exportNames, debug = false) => {
|
|
357
|
+
export const unwrapComponent = unwrapLibraryComponent;
|
|
358
|
+
export const unwrapComponents = (library, exportNames, debug = false) => {
|
|
365
359
|
return unwrapLibraryComponents(library, ...exportNames, debug);
|
|
366
360
|
};
|
|
367
|
-
|
|
368
|
-
exports.unwrapAllComponents = unwrapAllLibraryComponents;
|
|
361
|
+
export const unwrapAllComponents = unwrapAllLibraryComponents;
|
|
369
362
|
//# sourceMappingURL=component-unwrapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-unwrapper.js","sourceRoot":"","sources":["../../src/utilities/component-unwrapper.ts"],"names":[],"mappings":";;;AAcA,SAAS,eAAe,CAAC,OAAY,EAA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C;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AA9FD,gEA8FC;AAGY,QAAA,eAAe,GAAG,sBAAsB,CAAC;AAC/C,MAAM,gBAAgB,GAAG,CAAC,OAAY,EAAE,WAAqB,EAAE,QAAiB,KAAK,EAAE,EAAE;IAC9F,OAAO,uBAAuB,CAAC,OAAO,EAAE,GAAG,WAAW,EAAE,KAAY,CAAC,CAAC;AACxE,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B;AACW,QAAA,mBAAmB,GAAG,0BAA0B,CAAC","sourcesContent":["/**\n * @fileoverview Utility functions for unwrapping exports (components, utilities, objects) from UMD-bundled libraries\n * Handles various UMD bundle structures and module wrapping patterns\n * Intelligently handles simple functions, complex objects, and nested exports\n * @module @memberjunction/react-runtime/utilities\n */\n\n/**\n * Core unwrapping logic - handles smart detection and various library patterns\n * @param library - The library object (e.g., antd, MaterialUI, XLSX, or a simple function like ApexCharts)\n * @param exportName - Name of the export to unwrap (e.g., 'Button', 'utils', 'DatePicker.RangePicker')\n * @param debug - Whether to log debug information\n * @returns The unwrapped export (component, utility object, function, etc.) or undefined if not found\n */\nfunction coreUnwrapLogic(library: any, exportName: string, debug: boolean = false): any {\n // 1. Handle null/undefined/primitives - THROW EXCEPTION\n if (library == null) {\n throw new Error(`Cannot unwrap export '${exportName}' from null or undefined library`);\n }\n \n const libraryType = typeof library;\n if (libraryType === 'string' || libraryType === 'number' || libraryType === 'boolean' || libraryType === 'symbol' || libraryType === 'bigint') {\n throw new Error(`Cannot unwrap export '${exportName}' from ${libraryType} value. Library must be an object or function.`);\n }\n\n // 2. Handle simple function/class (like ApexCharts or a single exported component)\n if (libraryType === 'function') {\n if (debug) {\n console.log(`📦 Library is a single function/class, returning it for '${exportName}'`);\n console.log(` Function name: ${library.name || 'anonymous'}`);\n \n // Check if it's a class with static methods\n const hasStatics = Object.keys(library).some(key => \n key !== 'prototype' && key !== 'length' && key !== 'name' && key !== 'caller' && key !== 'arguments'\n );\n if (hasStatics) {\n console.log(` Has static properties: ${Object.keys(library).filter(k => \n k !== 'prototype' && k !== 'length' && k !== 'name' && k !== 'caller' && k !== 'arguments'\n ).join(', ')}`);\n }\n }\n return library;\n }\n\n // 3. Handle object with single property (auto-detect pattern)\n if (libraryType === 'object') {\n const objectKeys = Object.keys(library).filter(key => key !== '__esModule' && key !== 'default');\n \n if (objectKeys.length === 1 && typeof library[objectKeys[0]] === 'function') {\n if (debug) {\n console.log(`📦 Library has single exported function '${objectKeys[0]}', using it for '${exportName}'`);\n }\n return library[objectKeys[0]];\n }\n \n // Also check if library.default is the only meaningful export\n if (objectKeys.length === 0 && library.default && typeof library.default === 'function') {\n if (debug) {\n console.log(`📦 Library only has default export (function), using it for '${exportName}'`);\n }\n return library.default;\n }\n }\n\n // 4. Standard unwrapping for complex libraries\n if (debug) {\n console.log(`📦 Library is a complex object, attempting standard unwrapping for '${exportName}'`);\n }\n\n // Check if exportName contains dot notation (e.g., 'DatePicker.RangePicker')\n if (exportName.includes('.')) {\n const parts = exportName.split('.');\n let current = library;\n let pathTaken = 'library';\n \n // Navigate through the path\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n \n if (!current) {\n if (debug) {\n console.log(` ❌ Cannot access '${part}' - parent is null/undefined at path: ${pathTaken}`);\n }\n return undefined;\n }\n \n // For the first part, try various unwrapping strategies\n if (i === 0) {\n // Try different paths for the first component\n if (debug) {\n console.log(` Checking library.${part}...`);\n }\n const firstComponent = current[part];\n \n if (debug) {\n console.log(` Checking library.default.${part}...`);\n }\n const firstDefault = current.default?.[part];\n \n if (firstComponent) {\n current = firstComponent;\n pathTaken = `library.${part}`;\n if (debug) {\n console.log(` ✅ Found via ${pathTaken}`);\n }\n } else if (firstDefault) {\n current = firstDefault;\n pathTaken = `library.default.${part}`;\n if (debug) {\n console.log(` ✅ Found via ${pathTaken}`);\n }\n } else {\n if (debug) {\n console.log(` ❌ Could not find '${part}' in library`);\n }\n return undefined;\n }\n } else {\n // For nested parts, just access directly (they should be properties on the component object)\n if (debug) {\n console.log(` Checking ${pathTaken}.${part}...`);\n }\n if (current[part]) {\n current = current[part];\n pathTaken += `.${part}`;\n if (debug) {\n console.log(` ✅ Found via ${pathTaken}`);\n }\n } else if (current.default?.[part]) {\n // Sometimes nested components are also wrapped in default\n current = current.default[part];\n pathTaken += `.default.${part}`;\n if (debug) {\n console.log(` ✅ Found via ${pathTaken}.default`);\n }\n } else {\n if (debug) {\n console.log(` ❌ Could not find '${part}' at path: ${pathTaken}`);\n }\n return undefined;\n }\n }\n }\n \n // Check if the final result is a valid export (component, utility, object, etc.)\n // We accept anything except null/undefined\n const isValidExport = (obj: any): boolean => {\n return obj != null; // This checks for both null and undefined\n };\n \n if (isValidExport(current)) {\n if (debug) {\n console.log(`✅ Successfully unwrapped '${exportName}' via: ${pathTaken}`);\n const exportType = typeof current === 'function' ? \n (current.prototype?.isReactComponent ? 'React class component' : 'function/component') :\n (typeof current === 'object' ? 'object/utility' : typeof current);\n console.log(` Export type: ${exportType}`);\n }\n return current;\n } else if (current?.default && isValidExport(current.default)) {\n // One more check: the final export might have a default export\n if (debug) {\n console.log(`✅ Successfully unwrapped '${exportName}' via: ${pathTaken}.default`);\n }\n return current.default;\n } else {\n if (debug) {\n console.log(` ❌ '${exportName}' at ${pathTaken} is null/undefined`);\n }\n return undefined;\n }\n }\n\n // Original logic for non-dot notation components\n // Track which path we used for debugging\n let unwrapPath: string = '';\n let component: any;\n\n // Helper to check if something is a valid export (any non-null value)\n // This allows components, utilities, objects, classes, etc.\n const isValidExport = (obj: any): boolean => {\n return obj != null; // Checks for both null and undefined\n };\n\n // Path 1: Direct access (library.Component)\n if (debug) {\n console.log(` Checking library.${exportName}...`);\n }\n const directComponent = library[exportName];\n \n // Path 2: Module with default export (library.Component.default)\n if (debug && directComponent) {\n console.log(` Checking library.${exportName}.default...`);\n }\n const moduleDefault = directComponent?.default;\n \n // Path 3: Library wrapped in default (library.default.Component)\n if (debug && library.default) {\n console.log(` Checking library.default.${exportName}...`);\n }\n const libraryDefault = library.default?.[exportName];\n \n // Path 4: Library wrapped in default with module default (library.default.Component.default)\n if (debug && libraryDefault) {\n console.log(` Checking library.default.${exportName}.default...`);\n }\n const libraryDefaultModule = library.default?.[exportName]?.default;\n\n // Check each path in order of likelihood\n if (isValidExport(directComponent)) {\n component = directComponent;\n unwrapPath = `library.${exportName}`;\n if (debug) {\n console.log(` ✅ Found via ${unwrapPath}`);\n const exportType = typeof directComponent === 'function' ? 'function' : \n typeof directComponent === 'object' ? 'object' : typeof directComponent;\n console.log(` Export type: ${exportType}`);\n }\n } else if (isValidExport(moduleDefault)) {\n component = moduleDefault;\n unwrapPath = `library.${exportName}.default`;\n if (debug) {\n console.log(` ✅ Found via ${unwrapPath}`);\n }\n } else if (isValidExport(libraryDefault)) {\n component = libraryDefault;\n unwrapPath = `library.default.${exportName}`;\n if (debug) {\n console.log(` ✅ Found via ${unwrapPath}`);\n }\n } else if (isValidExport(libraryDefaultModule)) {\n component = libraryDefaultModule;\n unwrapPath = `library.default.${exportName}.default`;\n if (debug) {\n console.log(` ✅ Found via ${unwrapPath}`);\n }\n }\n\n // Debug logging for failure cases\n if (debug && !component) {\n console.log(` ❌ Could not unwrap '${exportName}' from library (all paths were null/undefined)`);\n console.log(' Library structure:');\n console.log(' - Top-level keys:', Object.keys(library).slice(0, 10).join(', '), \n Object.keys(library).length > 10 ? '...' : '');\n \n console.log(` - library.${exportName}:`, directComponent);\n \n if (library.default) {\n console.log(' - library.default exists, keys:', \n Object.keys(library.default).slice(0, 10).join(', '));\n }\n }\n\n return component;\n}\n\n/**\n * Unwraps a single export from a UMD library, handling various bundle structures\n * Works with components, utilities, objects, functions, and any other exports\n * @param library - The library object (e.g., antd, MaterialUI, XLSX)\n * @param exportName - Name of the export to unwrap (e.g., 'Button', 'utils', 'writeFile')\n * @param debug - Whether to log debug information\n * @returns The unwrapped export or undefined if not found\n */\nexport function unwrapLibraryComponent(library: any, exportName: string, debug: boolean = false): any {\n try {\n return coreUnwrapLogic(library, exportName, debug);\n } catch (error: any) {\n if (debug) {\n console.error(`🚫 Error unwrapping export '${exportName}':`, error.message);\n }\n throw error;\n }\n}\n\n/**\n * Unwraps multiple exports from a UMD library using varargs\n * Works with any type of export: components, utilities, objects, functions, etc.\n * @param library - The library object (e.g., antd, XLSX, ApexCharts)\n * @param exportNames - Export names to unwrap (e.g., 'Button', 'utils', 'writeFile')\n * @returns Object with export names as keys and unwrapped values as values\n */\nexport function unwrapLibraryComponents(\n library: any,\n ...exportNames: string[]\n): Record<string, any> {\n // Determine debug mode from the last parameter if it's a boolean\n let debug = false;\n let names = exportNames;\n \n // Check if the last argument is a debug flag (for backward compatibility)\n const lastArg = exportNames[exportNames.length - 1];\n if (typeof lastArg === 'boolean') {\n debug = lastArg;\n names = exportNames.slice(0, -1);\n }\n \n const components: Record<string, any> = {};\n const found: string[] = [];\n const notFound: string[] = [];\n \n // Check if library is a simple function/class that should be returned for all names\n const libraryType = typeof library;\n \n // Handle null/undefined/primitives early\n if (library == null || \n libraryType === 'string' || \n libraryType === 'number' || \n libraryType === 'boolean' ||\n libraryType === 'symbol' ||\n libraryType === 'bigint') {\n // Let the core logic throw the appropriate error\n try {\n coreUnwrapLogic(library, names[0] || 'unknown', debug);\n } catch (error: any) {\n if (debug) {\n console.error(`🚫 ${error.message}`);\n }\n throw error;\n }\n }\n \n // For simple functions/classes, return the same function for all requested names\n if (libraryType === 'function') {\n if (debug) {\n console.log(`📦 Library is a single function/class, returning it for all ${names.length} requested names`);\n }\n for (const name of names) {\n components[name] = library;\n found.push(name);\n }\n } else {\n // For complex objects, use the core unwrap logic for each component\n for (const name of names) {\n try {\n const component = coreUnwrapLogic(library, name, false); // Use false to avoid verbose logging per component\n if (component) {\n components[name] = component;\n \n // Also provide a convenience mapping for the last part of the name\n // e.g., 'DatePicker.RangePicker' also available as 'RangePicker'\n if (name.includes('.')) {\n const lastPart = name.split('.').pop();\n if (lastPart && !components[lastPart]) {\n // Only add the short name if it doesn't conflict with another component\n components[lastPart] = component;\n }\n }\n \n found.push(name);\n } else {\n notFound.push(name);\n }\n } catch (error: any) {\n // If core logic throws an error, it's a critical failure\n throw error;\n }\n }\n }\n \n if (debug) {\n if (found.length > 0) {\n console.log(`📦 Successfully unwrapped ${found.length} components:`, found.join(', '));\n }\n if (notFound.length > 0) {\n console.warn(`⚠️ Could not unwrap ${notFound.length} components:`, notFound.join(', '));\n }\n }\n \n return components;\n}\n\n/**\n * Auto-detects and unwraps all components from a library\n * Uses PascalCase detection to identify likely component exports\n * @param library - The library object\n * @param debug - Whether to log debug information\n * @returns Object with all detected components\n */\nexport function unwrapAllLibraryComponents(library: any, debug: boolean = false): Record<string, any> {\n const components: Record<string, any> = {};\n \n // Handle simple function/class case\n const libraryType = typeof library;\n \n // Handle null/undefined/primitives early\n if (library == null || \n libraryType === 'string' || \n libraryType === 'number' || \n libraryType === 'boolean' ||\n libraryType === 'symbol' ||\n libraryType === 'bigint') {\n try {\n coreUnwrapLogic(library, 'auto-detect', debug);\n } catch (error: any) {\n if (debug) {\n console.error(`🚫 ${error.message}`);\n }\n throw error;\n }\n }\n \n // For simple functions/classes, return it with its name\n if (libraryType === 'function') {\n const functionName = library.name || 'Component';\n if (debug) {\n console.log(`📦 Library is a single function/class '${functionName}', returning it as the only component`);\n }\n components[functionName] = library;\n return components;\n }\n \n // Helper to check if a key looks like a component name (PascalCase)\n const looksLikeComponentName = (key: string): boolean => {\n if (!key || key.length === 0) return false;\n // Must start with uppercase letter\n if (key[0] !== key[0].toUpperCase()) return false;\n // Exclude common non-component exports\n if (['__esModule', 'VERSION', 'version', 'default'].includes(key)) return false;\n // Should have at least one lowercase letter (to distinguish from CONSTANTS)\n return /[a-z]/.test(key);\n };\n \n const checkedKeys = new Set<string>();\n \n // Check direct properties\n for (const key of Object.keys(library)) {\n if (looksLikeComponentName(key)) {\n try {\n const component = coreUnwrapLogic(library, key, false);\n if (component) {\n components[key] = component;\n checkedKeys.add(key);\n }\n } catch (error) {\n // Skip components that can't be unwrapped\n }\n }\n }\n \n // Check library.default properties if it exists\n if (library.default && typeof library.default === 'object') {\n for (const key of Object.keys(library.default)) {\n if (!checkedKeys.has(key) && looksLikeComponentName(key)) {\n try {\n const component = coreUnwrapLogic(library, key, false);\n if (component) {\n components[key] = component;\n checkedKeys.add(key);\n }\n } catch (error) {\n // Skip components that can't be unwrapped\n }\n }\n }\n }\n \n if (debug) {\n const exportNames = Object.keys(components);\n if (exportNames.length > 0) {\n console.log(`🔍 Auto-detected ${exportNames.length} components from library`);\n console.log(' Components:', exportNames.slice(0, 20).join(', '),\n exportNames.length > 20 ? `... and ${exportNames.length - 20} more` : '');\n } else {\n console.warn('⚠️ No components auto-detected from library');\n console.log(' Library type:', typeof library);\n if (library) {\n console.log(' Top-level keys:', Object.keys(library).slice(0, 10).join(', '));\n }\n }\n }\n \n return components;\n}\n\n// Legacy exports for backward compatibility\nexport const unwrapComponent = unwrapLibraryComponent;\nexport const unwrapComponents = (library: any, exportNames: string[], debug: boolean = false) => {\n return unwrapLibraryComponents(library, ...exportNames, debug as any);\n};\nexport const unwrapAllComponents = unwrapAllLibraryComponents;"]}
|
|
1
|
+
{"version":3,"file":"component-unwrapper.js","sourceRoot":"","sources":["../../src/utilities/component-unwrapper.ts"],"names":[],"mappings":"AAcA,SAAS,eAAe,CAAC,OAAY,EAAE,UAAkB,EAAE,QAAiB,KAAK;IAE/E,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,yBAAyB,UAAU,kCAAkC,CAAC,CAAC;IACzF,CAAC;IAED,MAAM,WAAW,GAAG,OAAO,OAAO,CAAC;IACnC,IAAI,WAAW,KAAK,QAAQ,IAAI,WAAW,KAAK,QAAQ,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,QAAQ,IAAI,WAAW,KAAK,QAAQ,EAAE,CAAC;QAC9I,MAAM,IAAI,KAAK,CAAC,yBAAyB,UAAU,UAAU,WAAW,gDAAgD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,CAAC;QACV,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC5C,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,OAAO,CAAC,GAAG,CAAC,oBAAoB,WAAW,CAAC,MAAM,0BAA0B,CAAC,CAAC;YAC9E,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EACrD,WAAW,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,WAAW,WAAW,CAAC,MAAM,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACxF,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;YAC5D,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,OAAO,OAAO,CAAC,CAAC;YAChD,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YAClF,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAGD,MAAM,CAAC,MAAM,eAAe,GAAG,sBAAsB,CAAC;AACtD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAY,EAAE,WAAqB,EAAE,QAAiB,KAAK,EAAE,EAAE;IAC9F,OAAO,uBAAuB,CAAC,OAAO,EAAE,GAAG,WAAW,EAAE,KAAY,CAAC,CAAC;AACxE,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,mBAAmB,GAAG,0BAA0B,CAAC","sourcesContent":["/**\n * @fileoverview Utility functions for unwrapping exports (components, utilities, objects) from UMD-bundled libraries\n * Handles various UMD bundle structures and module wrapping patterns\n * Intelligently handles simple functions, complex objects, and nested exports\n * @module @memberjunction/react-runtime/utilities\n */\n\n/**\n * Core unwrapping logic - handles smart detection and various library patterns\n * @param library - The library object (e.g., antd, MaterialUI, XLSX, or a simple function like ApexCharts)\n * @param exportName - Name of the export to unwrap (e.g., 'Button', 'utils', 'DatePicker.RangePicker')\n * @param debug - Whether to log debug information\n * @returns The unwrapped export (component, utility object, function, etc.) or undefined if not found\n */\nfunction coreUnwrapLogic(library: any, exportName: string, debug: boolean = false): any {\n // 1. Handle null/undefined/primitives - THROW EXCEPTION\n if (library == null) {\n throw new Error(`Cannot unwrap export '${exportName}' from null or undefined library`);\n }\n \n const libraryType = typeof library;\n if (libraryType === 'string' || libraryType === 'number' || libraryType === 'boolean' || libraryType === 'symbol' || libraryType === 'bigint') {\n throw new Error(`Cannot unwrap export '${exportName}' from ${libraryType} value. Library must be an object or function.`);\n }\n\n // 2. Handle simple function/class (like ApexCharts or a single exported component)\n if (libraryType === 'function') {\n if (debug) {\n console.log(`📦 Library is a single function/class, returning it for '${exportName}'`);\n console.log(` Function name: ${library.name || 'anonymous'}`);\n \n // Check if it's a class with static methods\n const hasStatics = Object.keys(library).some(key => \n key !== 'prototype' && key !== 'length' && key !== 'name' && key !== 'caller' && key !== 'arguments'\n );\n if (hasStatics) {\n console.log(` Has static properties: ${Object.keys(library).filter(k => \n k !== 'prototype' && k !== 'length' && k !== 'name' && k !== 'caller' && k !== 'arguments'\n ).join(', ')}`);\n }\n }\n return library;\n }\n\n // 3. Handle object with single property (auto-detect pattern)\n if (libraryType === 'object') {\n const objectKeys = Object.keys(library).filter(key => key !== '__esModule' && key !== 'default');\n \n if (objectKeys.length === 1 && typeof library[objectKeys[0]] === 'function') {\n if (debug) {\n console.log(`📦 Library has single exported function '${objectKeys[0]}', using it for '${exportName}'`);\n }\n return library[objectKeys[0]];\n }\n \n // Also check if library.default is the only meaningful export\n if (objectKeys.length === 0 && library.default && typeof library.default === 'function') {\n if (debug) {\n console.log(`📦 Library only has default export (function), using it for '${exportName}'`);\n }\n return library.default;\n }\n }\n\n // 4. Standard unwrapping for complex libraries\n if (debug) {\n console.log(`📦 Library is a complex object, attempting standard unwrapping for '${exportName}'`);\n }\n\n // Check if exportName contains dot notation (e.g., 'DatePicker.RangePicker')\n if (exportName.includes('.')) {\n const parts = exportName.split('.');\n let current = library;\n let pathTaken = 'library';\n \n // Navigate through the path\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n \n if (!current) {\n if (debug) {\n console.log(` ❌ Cannot access '${part}' - parent is null/undefined at path: ${pathTaken}`);\n }\n return undefined;\n }\n \n // For the first part, try various unwrapping strategies\n if (i === 0) {\n // Try different paths for the first component\n if (debug) {\n console.log(` Checking library.${part}...`);\n }\n const firstComponent = current[part];\n \n if (debug) {\n console.log(` Checking library.default.${part}...`);\n }\n const firstDefault = current.default?.[part];\n \n if (firstComponent) {\n current = firstComponent;\n pathTaken = `library.${part}`;\n if (debug) {\n console.log(` ✅ Found via ${pathTaken}`);\n }\n } else if (firstDefault) {\n current = firstDefault;\n pathTaken = `library.default.${part}`;\n if (debug) {\n console.log(` ✅ Found via ${pathTaken}`);\n }\n } else {\n if (debug) {\n console.log(` ❌ Could not find '${part}' in library`);\n }\n return undefined;\n }\n } else {\n // For nested parts, just access directly (they should be properties on the component object)\n if (debug) {\n console.log(` Checking ${pathTaken}.${part}...`);\n }\n if (current[part]) {\n current = current[part];\n pathTaken += `.${part}`;\n if (debug) {\n console.log(` ✅ Found via ${pathTaken}`);\n }\n } else if (current.default?.[part]) {\n // Sometimes nested components are also wrapped in default\n current = current.default[part];\n pathTaken += `.default.${part}`;\n if (debug) {\n console.log(` ✅ Found via ${pathTaken}.default`);\n }\n } else {\n if (debug) {\n console.log(` ❌ Could not find '${part}' at path: ${pathTaken}`);\n }\n return undefined;\n }\n }\n }\n \n // Check if the final result is a valid export (component, utility, object, etc.)\n // We accept anything except null/undefined\n const isValidExport = (obj: any): boolean => {\n return obj != null; // This checks for both null and undefined\n };\n \n if (isValidExport(current)) {\n if (debug) {\n console.log(`✅ Successfully unwrapped '${exportName}' via: ${pathTaken}`);\n const exportType = typeof current === 'function' ? \n (current.prototype?.isReactComponent ? 'React class component' : 'function/component') :\n (typeof current === 'object' ? 'object/utility' : typeof current);\n console.log(` Export type: ${exportType}`);\n }\n return current;\n } else if (current?.default && isValidExport(current.default)) {\n // One more check: the final export might have a default export\n if (debug) {\n console.log(`✅ Successfully unwrapped '${exportName}' via: ${pathTaken}.default`);\n }\n return current.default;\n } else {\n if (debug) {\n console.log(` ❌ '${exportName}' at ${pathTaken} is null/undefined`);\n }\n return undefined;\n }\n }\n\n // Original logic for non-dot notation components\n // Track which path we used for debugging\n let unwrapPath: string = '';\n let component: any;\n\n // Helper to check if something is a valid export (any non-null value)\n // This allows components, utilities, objects, classes, etc.\n const isValidExport = (obj: any): boolean => {\n return obj != null; // Checks for both null and undefined\n };\n\n // Path 1: Direct access (library.Component)\n if (debug) {\n console.log(` Checking library.${exportName}...`);\n }\n const directComponent = library[exportName];\n \n // Path 2: Module with default export (library.Component.default)\n if (debug && directComponent) {\n console.log(` Checking library.${exportName}.default...`);\n }\n const moduleDefault = directComponent?.default;\n \n // Path 3: Library wrapped in default (library.default.Component)\n if (debug && library.default) {\n console.log(` Checking library.default.${exportName}...`);\n }\n const libraryDefault = library.default?.[exportName];\n \n // Path 4: Library wrapped in default with module default (library.default.Component.default)\n if (debug && libraryDefault) {\n console.log(` Checking library.default.${exportName}.default...`);\n }\n const libraryDefaultModule = library.default?.[exportName]?.default;\n\n // Check each path in order of likelihood\n if (isValidExport(directComponent)) {\n component = directComponent;\n unwrapPath = `library.${exportName}`;\n if (debug) {\n console.log(` ✅ Found via ${unwrapPath}`);\n const exportType = typeof directComponent === 'function' ? 'function' : \n typeof directComponent === 'object' ? 'object' : typeof directComponent;\n console.log(` Export type: ${exportType}`);\n }\n } else if (isValidExport(moduleDefault)) {\n component = moduleDefault;\n unwrapPath = `library.${exportName}.default`;\n if (debug) {\n console.log(` ✅ Found via ${unwrapPath}`);\n }\n } else if (isValidExport(libraryDefault)) {\n component = libraryDefault;\n unwrapPath = `library.default.${exportName}`;\n if (debug) {\n console.log(` ✅ Found via ${unwrapPath}`);\n }\n } else if (isValidExport(libraryDefaultModule)) {\n component = libraryDefaultModule;\n unwrapPath = `library.default.${exportName}.default`;\n if (debug) {\n console.log(` ✅ Found via ${unwrapPath}`);\n }\n }\n\n // Debug logging for failure cases\n if (debug && !component) {\n console.log(` ❌ Could not unwrap '${exportName}' from library (all paths were null/undefined)`);\n console.log(' Library structure:');\n console.log(' - Top-level keys:', Object.keys(library).slice(0, 10).join(', '), \n Object.keys(library).length > 10 ? '...' : '');\n \n console.log(` - library.${exportName}:`, directComponent);\n \n if (library.default) {\n console.log(' - library.default exists, keys:', \n Object.keys(library.default).slice(0, 10).join(', '));\n }\n }\n\n return component;\n}\n\n/**\n * Unwraps a single export from a UMD library, handling various bundle structures\n * Works with components, utilities, objects, functions, and any other exports\n * @param library - The library object (e.g., antd, MaterialUI, XLSX)\n * @param exportName - Name of the export to unwrap (e.g., 'Button', 'utils', 'writeFile')\n * @param debug - Whether to log debug information\n * @returns The unwrapped export or undefined if not found\n */\nexport function unwrapLibraryComponent(library: any, exportName: string, debug: boolean = false): any {\n try {\n return coreUnwrapLogic(library, exportName, debug);\n } catch (error: any) {\n if (debug) {\n console.error(`🚫 Error unwrapping export '${exportName}':`, error.message);\n }\n throw error;\n }\n}\n\n/**\n * Unwraps multiple exports from a UMD library using varargs\n * Works with any type of export: components, utilities, objects, functions, etc.\n * @param library - The library object (e.g., antd, XLSX, ApexCharts)\n * @param exportNames - Export names to unwrap (e.g., 'Button', 'utils', 'writeFile')\n * @returns Object with export names as keys and unwrapped values as values\n */\nexport function unwrapLibraryComponents(\n library: any,\n ...exportNames: string[]\n): Record<string, any> {\n // Determine debug mode from the last parameter if it's a boolean\n let debug = false;\n let names = exportNames;\n \n // Check if the last argument is a debug flag (for backward compatibility)\n const lastArg = exportNames[exportNames.length - 1];\n if (typeof lastArg === 'boolean') {\n debug = lastArg;\n names = exportNames.slice(0, -1);\n }\n \n const components: Record<string, any> = {};\n const found: string[] = [];\n const notFound: string[] = [];\n \n // Check if library is a simple function/class that should be returned for all names\n const libraryType = typeof library;\n \n // Handle null/undefined/primitives early\n if (library == null || \n libraryType === 'string' || \n libraryType === 'number' || \n libraryType === 'boolean' ||\n libraryType === 'symbol' ||\n libraryType === 'bigint') {\n // Let the core logic throw the appropriate error\n try {\n coreUnwrapLogic(library, names[0] || 'unknown', debug);\n } catch (error: any) {\n if (debug) {\n console.error(`🚫 ${error.message}`);\n }\n throw error;\n }\n }\n \n // For simple functions/classes, return the same function for all requested names\n if (libraryType === 'function') {\n if (debug) {\n console.log(`📦 Library is a single function/class, returning it for all ${names.length} requested names`);\n }\n for (const name of names) {\n components[name] = library;\n found.push(name);\n }\n } else {\n // For complex objects, use the core unwrap logic for each component\n for (const name of names) {\n try {\n const component = coreUnwrapLogic(library, name, false); // Use false to avoid verbose logging per component\n if (component) {\n components[name] = component;\n \n // Also provide a convenience mapping for the last part of the name\n // e.g., 'DatePicker.RangePicker' also available as 'RangePicker'\n if (name.includes('.')) {\n const lastPart = name.split('.').pop();\n if (lastPart && !components[lastPart]) {\n // Only add the short name if it doesn't conflict with another component\n components[lastPart] = component;\n }\n }\n \n found.push(name);\n } else {\n notFound.push(name);\n }\n } catch (error: any) {\n // If core logic throws an error, it's a critical failure\n throw error;\n }\n }\n }\n \n if (debug) {\n if (found.length > 0) {\n console.log(`📦 Successfully unwrapped ${found.length} components:`, found.join(', '));\n }\n if (notFound.length > 0) {\n console.warn(`⚠️ Could not unwrap ${notFound.length} components:`, notFound.join(', '));\n }\n }\n \n return components;\n}\n\n/**\n * Auto-detects and unwraps all components from a library\n * Uses PascalCase detection to identify likely component exports\n * @param library - The library object\n * @param debug - Whether to log debug information\n * @returns Object with all detected components\n */\nexport function unwrapAllLibraryComponents(library: any, debug: boolean = false): Record<string, any> {\n const components: Record<string, any> = {};\n \n // Handle simple function/class case\n const libraryType = typeof library;\n \n // Handle null/undefined/primitives early\n if (library == null || \n libraryType === 'string' || \n libraryType === 'number' || \n libraryType === 'boolean' ||\n libraryType === 'symbol' ||\n libraryType === 'bigint') {\n try {\n coreUnwrapLogic(library, 'auto-detect', debug);\n } catch (error: any) {\n if (debug) {\n console.error(`🚫 ${error.message}`);\n }\n throw error;\n }\n }\n \n // For simple functions/classes, return it with its name\n if (libraryType === 'function') {\n const functionName = library.name || 'Component';\n if (debug) {\n console.log(`📦 Library is a single function/class '${functionName}', returning it as the only component`);\n }\n components[functionName] = library;\n return components;\n }\n \n // Helper to check if a key looks like a component name (PascalCase)\n const looksLikeComponentName = (key: string): boolean => {\n if (!key || key.length === 0) return false;\n // Must start with uppercase letter\n if (key[0] !== key[0].toUpperCase()) return false;\n // Exclude common non-component exports\n if (['__esModule', 'VERSION', 'version', 'default'].includes(key)) return false;\n // Should have at least one lowercase letter (to distinguish from CONSTANTS)\n return /[a-z]/.test(key);\n };\n \n const checkedKeys = new Set<string>();\n \n // Check direct properties\n for (const key of Object.keys(library)) {\n if (looksLikeComponentName(key)) {\n try {\n const component = coreUnwrapLogic(library, key, false);\n if (component) {\n components[key] = component;\n checkedKeys.add(key);\n }\n } catch (error) {\n // Skip components that can't be unwrapped\n }\n }\n }\n \n // Check library.default properties if it exists\n if (library.default && typeof library.default === 'object') {\n for (const key of Object.keys(library.default)) {\n if (!checkedKeys.has(key) && looksLikeComponentName(key)) {\n try {\n const component = coreUnwrapLogic(library, key, false);\n if (component) {\n components[key] = component;\n checkedKeys.add(key);\n }\n } catch (error) {\n // Skip components that can't be unwrapped\n }\n }\n }\n }\n \n if (debug) {\n const exportNames = Object.keys(components);\n if (exportNames.length > 0) {\n console.log(`🔍 Auto-detected ${exportNames.length} components from library`);\n console.log(' Components:', exportNames.slice(0, 20).join(', '),\n exportNames.length > 20 ? `... and ${exportNames.length - 20} more` : '');\n } else {\n console.warn('⚠️ No components auto-detected from library');\n console.log(' Library type:', typeof library);\n if (library) {\n console.log(' Top-level keys:', Object.keys(library).slice(0, 10).join(', '));\n }\n }\n }\n \n return components;\n}\n\n// Legacy exports for backward compatibility\nexport const unwrapComponent = unwrapLibraryComponent;\nexport const unwrapComponents = (library: any, exportNames: string[], debug: boolean = false) => {\n return unwrapLibraryComponents(library, ...exportNames, debug as any);\n};\nexport const unwrapAllComponents = unwrapAllLibraryComponents;"]}
|