@memberjunction/react-runtime 2.99.0 → 2.100.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.
Files changed (61) hide show
  1. package/.turbo/turbo-build.log +15 -20
  2. package/CHANGELOG.md +14 -0
  3. package/README.md +171 -1
  4. package/dist/compiler/component-compiler.d.ts.map +1 -1
  5. package/dist/compiler/component-compiler.js +10 -1
  6. package/dist/compiler/component-compiler.js.map +1 -1
  7. package/dist/component-manager/component-manager.d.ts +39 -0
  8. package/dist/component-manager/component-manager.d.ts.map +1 -0
  9. package/dist/component-manager/component-manager.js +474 -0
  10. package/dist/component-manager/component-manager.js.map +1 -0
  11. package/dist/component-manager/index.d.ts +3 -0
  12. package/dist/component-manager/index.d.ts.map +1 -0
  13. package/dist/component-manager/index.js +6 -0
  14. package/dist/component-manager/index.js.map +1 -0
  15. package/dist/component-manager/types.d.ts +62 -0
  16. package/dist/component-manager/types.d.ts.map +1 -0
  17. package/dist/component-manager/types.js +3 -0
  18. package/dist/component-manager/types.js.map +1 -0
  19. package/dist/index.d.ts +6 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +11 -2
  22. package/dist/index.js.map +1 -1
  23. package/dist/registry/component-registry-service.d.ts +16 -1
  24. package/dist/registry/component-registry-service.d.ts.map +1 -1
  25. package/dist/registry/component-registry-service.js +212 -10
  26. package/dist/registry/component-registry-service.js.map +1 -1
  27. package/dist/registry/component-registry.d.ts +1 -1
  28. package/dist/registry/component-registry.d.ts.map +1 -1
  29. package/dist/registry/component-registry.js.map +1 -1
  30. package/dist/registry/component-resolver.d.ts.map +1 -1
  31. package/dist/registry/component-resolver.js +122 -52
  32. package/dist/registry/component-resolver.js.map +1 -1
  33. package/dist/registry/index.d.ts +1 -1
  34. package/dist/registry/index.d.ts.map +1 -1
  35. package/dist/registry/index.js.map +1 -1
  36. package/dist/runtime/component-hierarchy.d.ts +4 -0
  37. package/dist/runtime/component-hierarchy.d.ts.map +1 -1
  38. package/dist/runtime/component-hierarchy.js +127 -12
  39. package/dist/runtime/component-hierarchy.js.map +1 -1
  40. package/dist/runtime.umd.js +535 -1
  41. package/dist/types/index.d.ts +1 -0
  42. package/dist/types/index.d.ts.map +1 -1
  43. package/dist/types/index.js.map +1 -1
  44. package/dist/utilities/library-loader.d.ts +3 -0
  45. package/dist/utilities/library-loader.d.ts.map +1 -1
  46. package/dist/utilities/library-loader.js +85 -17
  47. package/dist/utilities/library-loader.js.map +1 -1
  48. package/examples/component-registry-integration.ts +191 -0
  49. package/package.json +6 -5
  50. package/src/compiler/component-compiler.ts +14 -1
  51. package/src/component-manager/component-manager.ts +736 -0
  52. package/src/component-manager/index.ts +13 -0
  53. package/src/component-manager/types.ts +204 -0
  54. package/src/index.ts +27 -1
  55. package/src/registry/component-registry-service.ts +315 -18
  56. package/src/registry/component-registry.ts +1 -1
  57. package/src/registry/component-resolver.ts +159 -67
  58. package/src/registry/index.ts +1 -1
  59. package/src/runtime/component-hierarchy.ts +124 -13
  60. package/src/types/index.ts +2 -0
  61. package/src/utilities/library-loader.ts +133 -22
@@ -75,6 +75,7 @@ export interface CompilationResult {
75
75
  error?: ComponentError;
76
76
  duration: number;
77
77
  size?: number;
78
+ loadedLibraries?: Map<string, any>;
78
79
  }
79
80
  export interface RuntimeContext {
80
81
  React: any;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAK3H,MAAM,WAAW,iBAAiB;IAEhC,OAAO,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,eAAe,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,eAAe,CAAC;IAElH,EAAE,E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M,WAAW,kBAAkB;IAEjC,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IAEzB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IAExB,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,KAAK,IAAI,CAAC;IAExD,WAAW,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,KAAK,IAAI,CAAC;IAE1D,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAKD,MAAM,WAAW,oBAAoB;IAEnC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,KAAK,IAAI,CAAC;IAEjD,QAAQ,CAAC,EAAE,GAAG,CAAC;IAEf,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;CACvC;AAGD,cAAc,kBAAkB,CAAC;AAGjC,cAAc,oBAAoB,CAAC;AAGnC,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAgOA,mDAAiC;AAGjC,qDAAmC","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}\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
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAkOA,mDAAiC;AAGjC,qDAAmC","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';"]}
@@ -25,12 +25,15 @@ export declare class LibraryLoader {
25
25
  private static loadedResources;
26
26
  private static loadedLibraryStates;
27
27
  private static dependencyResolver;
28
+ static enableProgressiveDelay: boolean;
28
29
  static loadAllLibraries(config?: LibraryConfiguration, additionalLibraries?: ExternalLibraryConfig[], options?: {
29
30
  debug?: boolean;
30
31
  }): Promise<LibraryLoadResult>;
31
32
  static loadLibrariesFromConfig(options?: ConfigLoadOptions, debug?: boolean): Promise<LibraryLoadResult>;
32
33
  static loadLibraries(options: LibraryLoadOptions): Promise<LibraryLoadResult>;
33
34
  private static loadScript;
35
+ private static isLibraryReady;
36
+ private static waitForGlobalVariable;
34
37
  private static loadCSS;
35
38
  private static waitForScriptLoad;
36
39
  static getLoadedResources(): Map<string, LoadedResource>;
@@ -1 +1 @@
1
- {"version":3,"file":"library-loader.d.ts","sourceRoot":"","sources":["../../src/utilities/library-loader.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,iBAAiB,EAElB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,kBAAkB,IAAI,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG/H,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAS5F,UAAU,cAAc;IACtB,OAAO,EAAE,iBAAiB,GAAG,eAAe,CAAC;IAC7C,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;CACvB;AAMD,MAAM,WAAW,kBAAkB;IAEjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,eAAe,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACzD;AAKD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,GAAG,CAAC;IACX,QAAQ,EAAE,GAAG,CAAC;IACd,KAAK,EAAE,GAAG,CAAC;IACX,SAAS,EAAE,iBAAiB,CAAC;CAC9B;AAKD,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,eAAe,CAAqC;IACnE,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAAyC;IAC3E,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAmD;WASvE,gBAAgB,CAC3B,MAAM,CAAC,EAAE,oBAAoB,EAC7B,mBAAmB,CAAC,EAAE,qBAAqB,EAAE,EAC7C,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAC5B,OAAO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MAAM,CAAC,cAAc;mBAgCR,qBAAqB;IA6D1C,OAAO,CAAC,MAAM,CAAC,OAAO;IA2BtB,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAmDhC,MAAM,CAAC,kBAAkB,IAAI,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC;IAOxD,MAAM,CAAC,UAAU,IAAI,IAAI;WAuBZ,2BAA2B,CACtC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,sBAAsB,EAAE,EACtC,WAAW,GAAE,MAAe,EAC5B,OAAO,CAAC,EAAE,2BAA2B,GACpC,OAAO,CAAC,GAAG,CAAC;WAwHF,6BAA6B,CACxC,YAAY,EAAE,MAAM,EAAE,EACtB,YAAY,EAAE,sBAAsB,EAAE,EACtC,WAAW,GAAE,MAAe,EAC5B,OAAO,CAAC,EAAE,2BAA2B,GACpC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAiI5B,MAAM,CAAC,sBAAsB,IAAI,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC;IAShE,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IASpD,MAAM,CAAC,uBAAuB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAGxE"}
@@ -125,28 +125,39 @@ class LibraryLoader {
125
125
  script.removeEventListener('load', onLoad);
126
126
  script.removeEventListener('error', onError);
127
127
  };
128
- const onLoad = () => {
128
+ const onLoad = async () => {
129
129
  cleanup();
130
- const global = window[globalName];
131
- if (global) {
132
- if (debug) {
133
- console.log(`✅ Library '${globalName}' loaded successfully from ${url}`);
130
+ if (LibraryLoader.enableProgressiveDelay) {
131
+ try {
132
+ const global = await LibraryLoader.waitForGlobalVariable(globalName, url, debug);
133
+ resolve(global);
134
+ }
135
+ catch (error) {
136
+ reject(error);
134
137
  }
135
- resolve(global);
136
138
  }
137
139
  else {
138
- const timeoutId = resource_manager_1.resourceManager.setTimeout(LIBRARY_LOADER_COMPONENT_ID, () => {
139
- const delayedGlobal = window[globalName];
140
- if (delayedGlobal) {
141
- if (debug) {
142
- console.log(`✅ Library '${globalName}' loaded successfully (delayed initialization)`);
143
- }
144
- resolve(delayedGlobal);
145
- }
146
- else {
147
- reject(new Error(`${globalName} not found after script load`));
140
+ const global = window[globalName];
141
+ if (global) {
142
+ if (debug) {
143
+ console.log(`✅ Library '${globalName}' loaded successfully from ${url}`);
148
144
  }
149
- }, 100, { url, globalName });
145
+ resolve(global);
146
+ }
147
+ else {
148
+ const timeoutId = resource_manager_1.resourceManager.setTimeout(LIBRARY_LOADER_COMPONENT_ID, () => {
149
+ const delayedGlobal = window[globalName];
150
+ if (delayedGlobal) {
151
+ if (debug) {
152
+ console.log(`✅ Library '${globalName}' loaded successfully (delayed initialization)`);
153
+ }
154
+ resolve(delayedGlobal);
155
+ }
156
+ else {
157
+ reject(new Error(`${globalName} not found after script load`));
158
+ }
159
+ }, 100, { url, globalName });
160
+ }
150
161
  }
151
162
  };
152
163
  const onError = () => {
@@ -167,6 +178,62 @@ class LibraryLoader {
167
178
  });
168
179
  return promise;
169
180
  }
181
+ static isLibraryReady(globalVariable) {
182
+ if (!globalVariable) {
183
+ return false;
184
+ }
185
+ if (typeof globalVariable === 'function') {
186
+ return true;
187
+ }
188
+ if (typeof globalVariable === 'object') {
189
+ const keys = Object.keys(globalVariable);
190
+ return keys.length > 0 ||
191
+ Object.getOwnPropertyNames(globalVariable).length > 1 ||
192
+ globalVariable.constructor !== Object;
193
+ }
194
+ return true;
195
+ }
196
+ static async waitForGlobalVariable(globalName, url, debug = false) {
197
+ const delays = [0, 100, 200, 300, 400];
198
+ const maxAttempts = delays.length;
199
+ let totalDelay = 0;
200
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
201
+ if (attempt > 0) {
202
+ const delay = delays[attempt];
203
+ if (debug) {
204
+ console.log(`⏳ Waiting ${delay}ms for ${globalName} to initialize (attempt ${attempt + 1}/${maxAttempts})...`);
205
+ }
206
+ await new Promise(resolve => {
207
+ resource_manager_1.resourceManager.setTimeout(LIBRARY_LOADER_COMPONENT_ID, () => resolve(undefined), delay, { globalName, attempt });
208
+ });
209
+ totalDelay += delay;
210
+ }
211
+ const global = window[globalName];
212
+ if (global) {
213
+ const isReady = this.isLibraryReady(global);
214
+ if (isReady) {
215
+ if (debug) {
216
+ if (totalDelay > 0) {
217
+ console.log(`✅ ${globalName} ready after ${totalDelay}ms delay`);
218
+ }
219
+ else {
220
+ console.log(`✅ Library '${globalName}' loaded successfully from ${url}`);
221
+ }
222
+ }
223
+ return global;
224
+ }
225
+ else if (debug && attempt < maxAttempts - 1) {
226
+ console.log(`🔄 ${globalName} exists but not fully initialized, will retry...`);
227
+ }
228
+ }
229
+ }
230
+ const finalGlobal = window[globalName];
231
+ if (finalGlobal) {
232
+ console.warn(`⚠️ ${globalName} loaded but may not be fully initialized after ${totalDelay}ms`);
233
+ return finalGlobal;
234
+ }
235
+ throw new Error(`${globalName} not found after script load and ${totalDelay}ms delay`);
236
+ }
170
237
  static loadCSS(url) {
171
238
  if (this.loadedResources.has(url)) {
172
239
  return;
@@ -406,4 +473,5 @@ exports.LibraryLoader = LibraryLoader;
406
473
  LibraryLoader.loadedResources = new Map();
407
474
  LibraryLoader.loadedLibraryStates = new Map();
408
475
  LibraryLoader.dependencyResolver = new library_dependency_resolver_1.LibraryDependencyResolver({ debug: false });
476
+ LibraryLoader.enableProgressiveDelay = false;
409
477
  //# sourceMappingURL=library-loader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"library-loader.js","sourceRoot":"","sources":["../../src/utilities/library-loader.ts"],"names":[],"mappings":";;;AAMA,6DAG8B;AAE9B,qDAAiF;AACjF,yDAAqD;AAErD,+EAA0E;AAK1E,MAAM,2BAA2B,GAAG,2CAA2C,CAAC;AAsChF,MAAa,aAAa;IAYxB,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC3B,MAA6B,EAC7B,mBAA6C,EAC7C,OAA6B;QAE7B,IAAI,MAA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nD,CAAC;IAOD,MAAM,CAAC,uBAAuB,CAAC,WAAmB;QAChD,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC5D,CAAC;;AApoBH,sCAqoBC;AApoBgB,6BAAe,GAAG,IAAI,GAAG,EAA0B,CAAC;AACpD,iCAAmB,GAAG,IAAI,GAAG,EAA8B,CAAC;AAC5D,gCAAkB,GAAG,IAAI,uDAAyB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC","sourcesContent":["/**\n * @fileoverview Library loading utilities for React runtime\n * Provides methods to load and manage external JavaScript libraries and CSS\n * @module @memberjunction/react-runtime/utilities\n */\n\nimport { \n StandardLibraries,\n StandardLibraryManager\n} from './standard-libraries';\nimport { LibraryConfiguration, ExternalLibraryConfig, LibraryLoadOptions as ConfigLoadOptions } from '../types/library-config';\nimport { getCoreRuntimeLibraries, isCoreRuntimeLibrary } from './core-libraries';\nimport { resourceManager } from './resource-manager';\nimport { ComponentLibraryEntity } from '@memberjunction/core-entities';\nimport { LibraryDependencyResolver } from './library-dependency-resolver';\nimport { LoadedLibraryState, DependencyResolutionOptions } from '../types/dependency-types';\nimport { LibraryRegistry } from './library-registry';\n\n// Unique component ID for resource tracking\nconst LIBRARY_LOADER_COMPONENT_ID = 'mj-react-runtime-library-loader-singleton';\n\n/**\n * Represents a loaded script or CSS resource\n */\ninterface LoadedResource {\n element: HTMLScriptElement | HTMLLinkElement;\n promise: Promise<any>;\n}\n\n/**\n * Options for loading libraries\n * @deprecated Use LibraryLoadOptions from library-config instead\n */\nexport interface LibraryLoadOptions {\n /** Load core libraries (lodash, d3, Chart.js, dayjs) */\n loadCore?: boolean;\n /** Load UI libraries (antd, React Bootstrap) */\n loadUI?: boolean;\n /** Load CSS files for UI libraries */\n loadCSS?: boolean;\n /** Custom library URLs to load */\n customLibraries?: { url: string; globalName: string }[];\n}\n\n/**\n * Result of loading libraries\n */\nexport interface LibraryLoadResult {\n React: any;\n ReactDOM: any;\n Babel: any;\n libraries: StandardLibraries;\n}\n\n/**\n * Library loader class for managing external script loading\n */\nexport class LibraryLoader {\n private static loadedResources = new Map<string, LoadedResource>();\n private static loadedLibraryStates = new Map<string, LoadedLibraryState>();\n private static dependencyResolver = new LibraryDependencyResolver({ debug: false });\n\n /**\n * Load all standard libraries (core + UI + CSS)\n * This is the main method that should be used by test harness and Angular wrapper\n * @param config Optional full library configuration to replace the default\n * @param additionalLibraries Optional additional libraries to merge with the configuration\n * @param options Optional options including debug mode flag\n */\n static async loadAllLibraries(\n config?: LibraryConfiguration, \n additionalLibraries?: ExternalLibraryConfig[],\n options?: { debug?: boolean }\n ): Promise<LibraryLoadResult> {\n if (config) {\n StandardLibraryManager.setConfiguration(config);\n }\n \n // If additional libraries are provided, merge them with the current configuration\n if (additionalLibraries && additionalLibraries.length > 0) {\n const currentConfig = StandardLibraryManager.getConfiguration();\n const mergedConfig: LibraryConfiguration = {\n libraries: [...currentConfig.libraries, ...additionalLibraries],\n metadata: {\n ...currentConfig.metadata,\n lastUpdated: new Date().toISOString()\n }\n };\n StandardLibraryManager.setConfiguration(mergedConfig);\n }\n \n return this.loadLibrariesFromConfig(undefined, options?.debug);\n }\n\n /**\n * Load libraries based on the current configuration\n */\n static async loadLibrariesFromConfig(options?: ConfigLoadOptions, debug?: boolean): Promise<LibraryLoadResult> {\n // Always load core runtime libraries first\n const coreLibraries = getCoreRuntimeLibraries(debug);\n const corePromises = coreLibraries.map(lib => \n this.loadScript(lib.cdnUrl, lib.globalVariable, debug)\n );\n \n const coreResults = await Promise.all(corePromises);\n const React = coreResults.find((_, i) => coreLibraries[i].globalVariable === 'React');\n const ReactDOM = coreResults.find((_, i) => coreLibraries[i].globalVariable === 'ReactDOM');\n const Babel = coreResults.find((_, i) => coreLibraries[i].globalVariable === 'Babel');\n \n // Expose React and ReactDOM as globals for UMD libraries that expect them\n // Many React component libraries (Recharts, Victory, etc.) expect these as globals\n if (typeof window !== 'undefined') {\n if (React && !(window as any).React) {\n (window as any).React = React;\n console.log('✓ Exposed React as window.React for UMD compatibility');\n }\n if (ReactDOM && !(window as any).ReactDOM) {\n (window as any).ReactDOM = ReactDOM;\n console.log('✓ Exposed ReactDOM as window.ReactDOM for UMD compatibility');\n }\n // Also expose PropTypes as empty object if not present (for older libraries)\n if (!(window as any).PropTypes) {\n (window as any).PropTypes = {};\n console.log('✓ Exposed empty PropTypes as window.PropTypes for UMD compatibility');\n }\n }\n \n // Now load plugin libraries from configuration\n const config = StandardLibraryManager.getConfiguration();\n const enabledLibraries = StandardLibraryManager.getEnabledLibraries();\n \n // Filter out any core runtime libraries from plugin configuration\n let pluginLibraries = enabledLibraries.filter(lib => !isCoreRuntimeLibrary(lib.id));\n \n // Apply options filters if provided\n if (options) {\n if (options.categories) {\n pluginLibraries = pluginLibraries.filter(lib => \n options.categories!.includes(lib.category)\n );\n }\n if (options.excludeRuntimeOnly) {\n pluginLibraries = pluginLibraries.filter(lib => !lib.isRuntimeOnly);\n }\n }\n \n // Load CSS files for plugin libraries (non-blocking)\n pluginLibraries.forEach(lib => {\n if (lib.cdnCssUrl) {\n this.loadCSS(lib.cdnCssUrl);\n }\n });\n \n // Load plugin libraries\n const pluginPromises = pluginLibraries.map(lib => \n this.loadScript(lib.cdnUrl, lib.globalVariable, debug)\n );\n \n const pluginResults = await Promise.all(pluginPromises);\n \n // Build libraries object (only contains plugin libraries)\n const libraries: StandardLibraries = {};\n \n pluginLibraries.forEach((lib, index) => {\n libraries[lib.globalVariable] = pluginResults[index];\n });\n \n return {\n React: React || (window as any).React,\n ReactDOM: ReactDOM || (window as any).ReactDOM,\n Babel: Babel || (window as any).Babel,\n libraries\n };\n }\n\n /**\n * Load libraries with specific options (backward compatibility)\n * @deprecated Use loadLibrariesFromConfig instead\n */\n static async loadLibraries(options: LibraryLoadOptions): Promise<LibraryLoadResult> {\n const {\n loadCore = true,\n loadUI = true,\n loadCSS = true,\n customLibraries = []\n } = options;\n\n // Map old options to new configuration approach\n const categoriesToLoad: Array<ExternalLibraryConfig['category']> = ['runtime'];\n if (loadCore) {\n categoriesToLoad.push('utility', 'charting');\n }\n if (loadUI) {\n categoriesToLoad.push('ui');\n }\n \n const result = await this.loadLibrariesFromConfig({\n categories: categoriesToLoad\n });\n \n // Load custom libraries if provided\n if (customLibraries.length > 0) {\n const customPromises = customLibraries.map(({ url, globalName }) =>\n this.loadScript(url, globalName)\n );\n \n const customResults = await Promise.all(customPromises);\n customLibraries.forEach(({ globalName }, index) => {\n result.libraries[globalName] = customResults[index];\n });\n }\n \n return result;\n }\n\n /**\n * Load a script from URL\n */\n private static async loadScript(url: string, globalName: string, debug: boolean = false): Promise<any> {\n // Check if already loaded\n const existing = this.loadedResources.get(url);\n if (existing) {\n if (debug) {\n console.log(`✅ Library '${globalName}' already loaded (cached)`);\n }\n return existing.promise;\n }\n\n const promise = new Promise((resolve, reject) => {\n // Check if global already exists\n const existingGlobal = (window as any)[globalName];\n if (existingGlobal) {\n if (debug) {\n console.log(`✅ Library '${globalName}' already available globally`);\n }\n resolve(existingGlobal);\n return;\n }\n\n // Check if script tag exists\n const existingScript = document.querySelector(`script[src=\"${url}\"]`);\n if (existingScript) {\n this.waitForScriptLoad(existingScript as HTMLScriptElement, globalName, resolve, reject);\n return;\n }\n\n // Create new script\n const script = document.createElement('script');\n script.src = url;\n script.async = true;\n script.crossOrigin = 'anonymous';\n\n const cleanup = () => {\n script.removeEventListener('load', onLoad);\n script.removeEventListener('error', onError);\n };\n\n const onLoad = () => {\n cleanup();\n const global = (window as any)[globalName];\n if (global) {\n if (debug) {\n console.log(`✅ Library '${globalName}' loaded successfully from ${url}`);\n }\n resolve(global);\n } else {\n // Some libraries may take a moment to initialize\n const timeoutId = resourceManager.setTimeout(\n LIBRARY_LOADER_COMPONENT_ID,\n () => {\n const delayedGlobal = (window as any)[globalName];\n if (delayedGlobal) {\n if (debug) {\n console.log(`✅ Library '${globalName}' loaded successfully (delayed initialization)`);\n }\n resolve(delayedGlobal);\n } else {\n reject(new Error(`${globalName} not found after script load`));\n }\n },\n 100,\n { url, globalName }\n );\n }\n };\n\n const onError = () => {\n cleanup();\n reject(new Error(`Failed to load script: ${url}`));\n };\n\n script.addEventListener('load', onLoad);\n script.addEventListener('error', onError);\n\n if (debug) {\n console.log(`📦 Loading library '${globalName}' from ${url}...`);\n }\n document.head.appendChild(script);\n \n // Register the script element for cleanup\n resourceManager.registerDOMElement(LIBRARY_LOADER_COMPONENT_ID, script);\n });\n\n this.loadedResources.set(url, { \n element: document.querySelector(`script[src=\"${url}\"]`)!, \n promise \n });\n\n return promise;\n }\n\n /**\n * Load CSS from URL\n */\n private static loadCSS(url: string): void {\n if (this.loadedResources.has(url)) {\n return;\n }\n\n const existingLink = document.querySelector(`link[href=\"${url}\"]`);\n if (existingLink) {\n return;\n }\n\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = url;\n document.head.appendChild(link);\n \n // Register the link element for cleanup\n resourceManager.registerDOMElement(LIBRARY_LOADER_COMPONENT_ID, link);\n\n this.loadedResources.set(url, {\n element: link,\n promise: Promise.resolve()\n });\n }\n\n /**\n * Wait for existing script to load\n */\n private static waitForScriptLoad(\n script: HTMLScriptElement,\n globalName: string,\n resolve: (value: any) => void,\n reject: (reason: any) => void\n ): void {\n const checkGlobal = () => {\n const global = (window as any)[globalName];\n if (global) {\n resolve(global);\n } else {\n // Retry after a short delay\n resourceManager.setTimeout(\n LIBRARY_LOADER_COMPONENT_ID,\n () => {\n const delayedGlobal = (window as any)[globalName];\n if (delayedGlobal) {\n resolve(delayedGlobal);\n } else {\n reject(new Error(`${globalName} not found after script load`));\n }\n },\n 100,\n { context: 'waitForScriptLoad', globalName }\n );\n }\n };\n\n // Check if already loaded\n if ((script as any).complete || (script as any).readyState === 'complete') {\n checkGlobal();\n return;\n }\n\n // Wait for load\n const loadHandler = () => {\n checkGlobal();\n };\n resourceManager.addEventListener(\n LIBRARY_LOADER_COMPONENT_ID,\n script,\n 'load',\n loadHandler,\n { once: true }\n );\n }\n\n\n /**\n * Get all loaded resources (for cleanup)\n */\n static getLoadedResources(): Map<string, LoadedResource> {\n return this.loadedResources;\n }\n\n /**\n * Clear loaded resources cache and cleanup DOM elements\n */\n static clearCache(): void {\n // Remove all script and link elements we added\n this.loadedResources.forEach((resource, url) => {\n if (resource.element && resource.element.parentNode) {\n resource.element.parentNode.removeChild(resource.element);\n }\n });\n \n this.loadedResources.clear();\n this.loadedLibraryStates.clear();\n \n // Clean up any resources managed by resource manager\n resourceManager.cleanupComponent(LIBRARY_LOADER_COMPONENT_ID);\n }\n\n /**\n * Load a library with its dependencies\n * @param libraryName - Name of the library to load\n * @param allLibraries - All available libraries for dependency resolution\n * @param requestedBy - Name of the component/library requesting this load\n * @param options - Dependency resolution options\n * @returns Promise resolving to the loaded library global object\n */\n static async loadLibraryWithDependencies(\n libraryName: string,\n allLibraries: ComponentLibraryEntity[],\n requestedBy: string = 'user',\n options?: DependencyResolutionOptions\n ): Promise<any> {\n const debug = options?.debug || false;\n \n if (debug) {\n console.log(`📚 Loading library '${libraryName}' with dependencies`);\n }\n\n // Check if already loaded\n const existingState = this.loadedLibraryStates.get(libraryName);\n if (existingState) {\n if (debug) {\n console.log(`✅ Library '${libraryName}' already loaded (version: ${existingState.version})`);\n }\n // Track who requested it\n if (!existingState.requestedBy.includes(requestedBy)) {\n existingState.requestedBy.push(requestedBy);\n }\n return (window as any)[existingState.globalVariable];\n }\n\n // Get load order including dependencies\n const loadOrderResult = this.dependencyResolver.getLoadOrder(\n [libraryName],\n allLibraries,\n options\n );\n\n if (!loadOrderResult.success) {\n const errors = loadOrderResult.errors?.join(', ') || 'Unknown error';\n throw new Error(`Failed to resolve dependencies for '${libraryName}': ${errors}`);\n }\n\n if (loadOrderResult.warnings && debug) {\n console.warn(`⚠️ Warnings for '${libraryName}':`, loadOrderResult.warnings);\n }\n\n const loadOrder = loadOrderResult.order || [];\n if (debug) {\n console.log(`📋 Load order for '${libraryName}':`, loadOrder.map(lib => `${lib.Name}@${lib.Version}`));\n }\n\n // Load libraries in order\n for (const library of loadOrder) {\n // Skip if already loaded\n if (this.loadedLibraryStates.has(library.Name)) {\n if (debug) {\n console.log(`⏭️ Skipping '${library.Name}' (already loaded)`);\n }\n continue;\n }\n\n // Check library status\n if (library.Status) {\n if (library.Status === 'Disabled') {\n console.error(`🚫 ERROR: Library '${library.Name}' is DISABLED and should not be used`);\n // Continue loading anyway per requirements\n } else if (library.Status === 'Deprecated') {\n console.warn(`⚠️ WARNING: Library '${library.Name}' is DEPRECATED. Consider using an alternative.`);\n }\n // Active status is fine, no message needed\n }\n\n if (debug) {\n console.log(`📥 Loading '${library.Name}@${library.Version}'`);\n }\n\n // Load the library\n if (!library.CDNUrl || !library.GlobalVariable) {\n throw new Error(`Library '${library.Name}' missing CDN URL or global variable`);\n }\n\n // Load CSS if available\n if (library.CDNCssUrl) {\n const cssUrls = library.CDNCssUrl.split(',').map(url => url.trim());\n for (const cssUrl of cssUrls) {\n if (cssUrl) {\n this.loadCSS(cssUrl);\n }\n }\n }\n\n // Load the script\n const loadedGlobal = await this.loadScript(library.CDNUrl, library.GlobalVariable, debug);\n\n // Track the loaded state\n const dependencies = Array.from(\n this.dependencyResolver.getDirectDependencies(library).keys()\n );\n\n this.loadedLibraryStates.set(library.Name, {\n name: library.Name,\n version: library.Version || 'unknown',\n globalVariable: library.GlobalVariable,\n loadedAt: new Date(),\n requestedBy: library.Name === libraryName ? [requestedBy] : [],\n dependencies\n });\n\n if (debug) {\n console.log(`✅ Loaded '${library.Name}@${library.Version}'`);\n }\n }\n\n // Return the originally requested library's global\n const targetLibrary = loadOrder.find(lib => lib.Name === libraryName);\n if (!targetLibrary || !targetLibrary.GlobalVariable) {\n throw new Error(`Failed to load library '${libraryName}'`);\n }\n\n return (window as any)[targetLibrary.GlobalVariable];\n }\n\n /**\n * Load multiple libraries with dependency resolution\n * @param libraryNames - Names of libraries to load\n * @param allLibraries - All available libraries for dependency resolution\n * @param requestedBy - Name of the component requesting these libraries\n * @param options - Dependency resolution options\n * @returns Map of library names to their loaded global objects\n */\n static async loadLibrariesWithDependencies(\n libraryNames: string[],\n allLibraries: ComponentLibraryEntity[],\n requestedBy: string = 'user',\n options?: DependencyResolutionOptions\n ): Promise<Map<string, any>> {\n const debug = options?.debug || false;\n const result = new Map<string, any>();\n \n if (debug) {\n console.log(`📚 Loading libraries with dependencies:`, libraryNames);\n console.log(` 📦 Total available libraries: ${allLibraries.length}`);\n console.log(` 📋 Available library list:`, allLibraries.map(l => `${l.Name}@${l.Version}`));\n }\n\n // Get combined load order for all requested libraries\n const loadOrderResult = this.dependencyResolver.getLoadOrder(\n libraryNames,\n allLibraries,\n options\n );\n\n if (!loadOrderResult.success) {\n const errors = loadOrderResult.errors?.join(', ') || 'Unknown error';\n throw new Error(`Failed to resolve dependencies: ${errors}`);\n }\n\n if (debug) {\n console.log(` 📊 Dependency resolution result:`, {\n success: loadOrderResult.success,\n errors: loadOrderResult.errors || [],\n warnings: loadOrderResult.warnings || []\n });\n \n if (loadOrderResult.order) {\n console.log(` 🔄 Resolved dependencies for each library:`);\n loadOrderResult.order.forEach(lib => {\n const deps = this.dependencyResolver.parseDependencies(lib.Dependencies);\n if (deps.size > 0) {\n console.log(` • ${lib.Name}@${lib.Version} requires:`, Array.from(deps.entries()));\n } else {\n console.log(` • ${lib.Name}@${lib.Version} (no dependencies)`);\n }\n });\n }\n }\n\n if (loadOrderResult.warnings && debug) {\n console.warn(` ⚠️ Warnings:`, loadOrderResult.warnings);\n }\n\n const loadOrder = loadOrderResult.order || [];\n if (debug) {\n console.log(` 📋 Final load order:`, loadOrder.map(lib => `${lib.Name}@${lib.Version}`));\n }\n\n // Load all libraries in order\n for (const library of loadOrder) {\n // Skip if already loaded\n if (this.loadedLibraryStates.has(library.Name)) {\n if (debug) {\n console.log(`⏭️ Skipping '${library.Name}' (already loaded)`);\n }\n const state = this.loadedLibraryStates.get(library.Name)!;\n if (libraryNames.includes(library.Name)) {\n result.set(library.Name, (window as any)[state.globalVariable]);\n }\n continue;\n }\n\n // Check library status\n if (library.Status) {\n if (library.Status === 'Disabled') {\n console.error(`🚫 ERROR: Library '${library.Name}' is DISABLED and should not be used`);\n // Continue loading anyway per requirements\n } else if (library.Status === 'Deprecated') {\n console.warn(`⚠️ WARNING: Library '${library.Name}' is DEPRECATED. Consider using an alternative.`);\n }\n // Active status is fine, no message needed\n }\n\n if (debug) {\n console.log(`📥 Loading '${library.Name}@${library.Version}'`);\n }\n\n // Load the library\n if (!library.CDNUrl || !library.GlobalVariable) {\n throw new Error(`Library '${library.Name}' missing CDN URL or global variable`);\n }\n\n // Load CSS if available\n if (library.CDNCssUrl) {\n const cssUrls = library.CDNCssUrl.split(',').map(url => url.trim());\n for (const cssUrl of cssUrls) {\n if (cssUrl) {\n this.loadCSS(cssUrl);\n }\n }\n }\n\n // Load the script\n const loadedGlobal = await this.loadScript(library.CDNUrl, library.GlobalVariable, debug);\n\n // Track the loaded state\n const dependencies = Array.from(\n this.dependencyResolver.getDirectDependencies(library).keys()\n );\n\n this.loadedLibraryStates.set(library.Name, {\n name: library.Name,\n version: library.Version || 'unknown',\n globalVariable: library.GlobalVariable,\n loadedAt: new Date(),\n requestedBy: libraryNames.includes(library.Name) ? [requestedBy] : [],\n dependencies\n });\n\n // Add to result if it was directly requested\n if (libraryNames.includes(library.Name)) {\n result.set(library.Name, loadedGlobal);\n }\n\n if (debug) {\n console.log(`✅ Loaded '${library.Name}@${library.Version}'`);\n }\n }\n\n return result;\n }\n\n /**\n * Get information about loaded libraries\n * @returns Map of loaded library states\n */\n static getLoadedLibraryStates(): Map<string, LoadedLibraryState> {\n return new Map(this.loadedLibraryStates);\n }\n\n /**\n * Check if a library is loaded\n * @param libraryName - Name of the library\n * @returns True if the library is loaded\n */\n static isLibraryLoaded(libraryName: string): boolean {\n return this.loadedLibraryStates.has(libraryName);\n }\n\n /**\n * Get the version of a loaded library\n * @param libraryName - Name of the library\n * @returns Version string or undefined if not loaded\n */\n static getLoadedLibraryVersion(libraryName: string): string | undefined {\n return this.loadedLibraryStates.get(libraryName)?.version;\n }\n}"]}
1
+ {"version":3,"file":"library-loader.js","sourceRoot":"","sources":["../../src/utilities/library-loader.ts"],"names":[],"mappings":";;;AAMA,6DAG8B;AAE9B,qDAAiF;AACjF,yDAAqD;AAErD,+EAA0E;AAK1E,MAAM,2BAA2B,GAAG,2CAA2C,CAAC;AAsChF,MAAa,aAAa;IAiBxB,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC3B,MAA6B,EAC7B,mBAA6C,EAC7C,OAA6B;QAE7B,IAAI,MAAM,EAAE,CAAC;YACX,2CAAsB,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;QAClD,CAAC;QAGD,IAAI,mBAAmB,IAAI,mBAAmB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1D,MAAM,aAAa,GAAG,2CAAsB,CAAC,gBAAgB,EAAE,CAAC;YAChE,MAAM,YAAY,GAAyB;gBACzC,SAAS,EAAE,CAAC,GAAG,aAAa,CAAC,SAAS,EAAE,GAAG,mBAAmB,CAAC;gBAC/D,QAAQ,EAAE;oBACR,GAAG,aAAa,CAAC,QAAQ;oBACzB,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;iBACtC;aACF,CAAC;YACF,2CAAsB,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;QACxD,CAAC;QAED,OAAO,IAAI,CAAC,uBAAuB,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IACjE,CAAC;IAKD,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,OAA2B,EAAE,KAAe;QAE/E,MAAM,aAAa,GAAG,IAAA,wCAAuB,EAAC,KAAK,CAAC,CAAC;QACrD,MAAM,YAAY,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAC3C,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,cAAc,EAAE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,YAAY;aACb,CAAC,CAAC;YAGH,IAAI,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;gBACxC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;YACzC,CAAC;YAED,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,CAAC,GAAG,CAAC,aAAa,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC;YAC/D,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAMD,MAAM,CAAC,sBAAsB;QAC3B,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAC3C,CAAC;IAOD,MAAM,CAAC,eAAe,CAAC,WAAmB;QACxC,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACnD,CAAC;IAOD,MAAM,CAAC,uBAAuB,CAAC,WAAmB;QAChD,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC5D,CAAC;;AAnvBH,sCAovBC;AAnvBgB,6BAAe,GAAG,IAAI,GAAG,EAA0B,CAAC;AACpD,iCAAmB,GAAG,IAAI,GAAG,EAA8B,CAAC;AAC5D,gCAAkB,GAAG,IAAI,uDAAyB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AAKtE,oCAAsB,GAAY,KAAK,CAAC","sourcesContent":["/**\n * @fileoverview Library loading utilities for React runtime\n * Provides methods to load and manage external JavaScript libraries and CSS\n * @module @memberjunction/react-runtime/utilities\n */\n\nimport { \n StandardLibraries,\n StandardLibraryManager\n} from './standard-libraries';\nimport { LibraryConfiguration, ExternalLibraryConfig, LibraryLoadOptions as ConfigLoadOptions } from '../types/library-config';\nimport { getCoreRuntimeLibraries, isCoreRuntimeLibrary } from './core-libraries';\nimport { resourceManager } from './resource-manager';\nimport { ComponentLibraryEntity } from '@memberjunction/core-entities';\nimport { LibraryDependencyResolver } from './library-dependency-resolver';\nimport { LoadedLibraryState, DependencyResolutionOptions } from '../types/dependency-types';\nimport { LibraryRegistry } from './library-registry';\n\n// Unique component ID for resource tracking\nconst LIBRARY_LOADER_COMPONENT_ID = 'mj-react-runtime-library-loader-singleton';\n\n/**\n * Represents a loaded script or CSS resource\n */\ninterface LoadedResource {\n element: HTMLScriptElement | HTMLLinkElement;\n promise: Promise<any>;\n}\n\n/**\n * Options for loading libraries\n * @deprecated Use LibraryLoadOptions from library-config instead\n */\nexport interface LibraryLoadOptions {\n /** Load core libraries (lodash, d3, Chart.js, dayjs) */\n loadCore?: boolean;\n /** Load UI libraries (antd, React Bootstrap) */\n loadUI?: boolean;\n /** Load CSS files for UI libraries */\n loadCSS?: boolean;\n /** Custom library URLs to load */\n customLibraries?: { url: string; globalName: string }[];\n}\n\n/**\n * Result of loading libraries\n */\nexport interface LibraryLoadResult {\n React: any;\n ReactDOM: any;\n Babel: any;\n libraries: StandardLibraries;\n}\n\n/**\n * Library loader class for managing external script loading\n */\nexport class LibraryLoader {\n private static loadedResources = new Map<string, LoadedResource>();\n private static loadedLibraryStates = new Map<string, LoadedLibraryState>();\n private static dependencyResolver = new LibraryDependencyResolver({ debug: false });\n \n /**\n * Enable progressive delay for library initialization (useful for test harness)\n */\n public static enableProgressiveDelay: boolean = false;\n\n /**\n * Load all standard libraries (core + UI + CSS)\n * This is the main method that should be used by test harness and Angular wrapper\n * @param config Optional full library configuration to replace the default\n * @param additionalLibraries Optional additional libraries to merge with the configuration\n * @param options Optional options including debug mode flag\n */\n static async loadAllLibraries(\n config?: LibraryConfiguration, \n additionalLibraries?: ExternalLibraryConfig[],\n options?: { debug?: boolean }\n ): Promise<LibraryLoadResult> {\n if (config) {\n StandardLibraryManager.setConfiguration(config);\n }\n \n // If additional libraries are provided, merge them with the current configuration\n if (additionalLibraries && additionalLibraries.length > 0) {\n const currentConfig = StandardLibraryManager.getConfiguration();\n const mergedConfig: LibraryConfiguration = {\n libraries: [...currentConfig.libraries, ...additionalLibraries],\n metadata: {\n ...currentConfig.metadata,\n lastUpdated: new Date().toISOString()\n }\n };\n StandardLibraryManager.setConfiguration(mergedConfig);\n }\n \n return this.loadLibrariesFromConfig(undefined, options?.debug);\n }\n\n /**\n * Load libraries based on the current configuration\n */\n static async loadLibrariesFromConfig(options?: ConfigLoadOptions, debug?: boolean): Promise<LibraryLoadResult> {\n // Always load core runtime libraries first\n const coreLibraries = getCoreRuntimeLibraries(debug);\n const corePromises = coreLibraries.map(lib => \n this.loadScript(lib.cdnUrl, lib.globalVariable, debug)\n );\n \n const coreResults = await Promise.all(corePromises);\n const React = coreResults.find((_, i) => coreLibraries[i].globalVariable === 'React');\n const ReactDOM = coreResults.find((_, i) => coreLibraries[i].globalVariable === 'ReactDOM');\n const Babel = coreResults.find((_, i) => coreLibraries[i].globalVariable === 'Babel');\n \n // Expose React and ReactDOM as globals for UMD libraries that expect them\n // Many React component libraries (Recharts, Victory, etc.) expect these as globals\n if (typeof window !== 'undefined') {\n if (React && !(window as any).React) {\n (window as any).React = React;\n console.log('✓ Exposed React as window.React for UMD compatibility');\n }\n if (ReactDOM && !(window as any).ReactDOM) {\n (window as any).ReactDOM = ReactDOM;\n console.log('✓ Exposed ReactDOM as window.ReactDOM for UMD compatibility');\n }\n // Also expose PropTypes as empty object if not present (for older libraries)\n if (!(window as any).PropTypes) {\n (window as any).PropTypes = {};\n console.log('✓ Exposed empty PropTypes as window.PropTypes for UMD compatibility');\n }\n }\n \n // Now load plugin libraries from configuration\n const config = StandardLibraryManager.getConfiguration();\n const enabledLibraries = StandardLibraryManager.getEnabledLibraries();\n \n // Filter out any core runtime libraries from plugin configuration\n let pluginLibraries = enabledLibraries.filter(lib => !isCoreRuntimeLibrary(lib.id));\n \n // Apply options filters if provided\n if (options) {\n if (options.categories) {\n pluginLibraries = pluginLibraries.filter(lib => \n options.categories!.includes(lib.category)\n );\n }\n if (options.excludeRuntimeOnly) {\n pluginLibraries = pluginLibraries.filter(lib => !lib.isRuntimeOnly);\n }\n }\n \n // Load CSS files for plugin libraries (non-blocking)\n pluginLibraries.forEach(lib => {\n if (lib.cdnCssUrl) {\n this.loadCSS(lib.cdnCssUrl);\n }\n });\n \n // Load plugin libraries\n const pluginPromises = pluginLibraries.map(lib => \n this.loadScript(lib.cdnUrl, lib.globalVariable, debug)\n );\n \n const pluginResults = await Promise.all(pluginPromises);\n \n // Build libraries object (only contains plugin libraries)\n const libraries: StandardLibraries = {};\n \n pluginLibraries.forEach((lib, index) => {\n libraries[lib.globalVariable] = pluginResults[index];\n });\n \n return {\n React: React || (window as any).React,\n ReactDOM: ReactDOM || (window as any).ReactDOM,\n Babel: Babel || (window as any).Babel,\n libraries\n };\n }\n\n /**\n * Load libraries with specific options (backward compatibility)\n * @deprecated Use loadLibrariesFromConfig instead\n */\n static async loadLibraries(options: LibraryLoadOptions): Promise<LibraryLoadResult> {\n const {\n loadCore = true,\n loadUI = true,\n loadCSS = true,\n customLibraries = []\n } = options;\n\n // Map old options to new configuration approach\n const categoriesToLoad: Array<ExternalLibraryConfig['category']> = ['runtime'];\n if (loadCore) {\n categoriesToLoad.push('utility', 'charting');\n }\n if (loadUI) {\n categoriesToLoad.push('ui');\n }\n \n const result = await this.loadLibrariesFromConfig({\n categories: categoriesToLoad\n });\n \n // Load custom libraries if provided\n if (customLibraries.length > 0) {\n const customPromises = customLibraries.map(({ url, globalName }) =>\n this.loadScript(url, globalName)\n );\n \n const customResults = await Promise.all(customPromises);\n customLibraries.forEach(({ globalName }, index) => {\n result.libraries[globalName] = customResults[index];\n });\n }\n \n return result;\n }\n\n /**\n * Load a script from URL\n */\n private static async loadScript(url: string, globalName: string, debug: boolean = false): Promise<any> {\n // Check if already loaded\n const existing = this.loadedResources.get(url);\n if (existing) {\n if (debug) {\n console.log(`✅ Library '${globalName}' already loaded (cached)`);\n }\n return existing.promise;\n }\n\n const promise = new Promise((resolve, reject) => {\n // Check if global already exists\n const existingGlobal = (window as any)[globalName];\n if (existingGlobal) {\n if (debug) {\n console.log(`✅ Library '${globalName}' already available globally`);\n }\n resolve(existingGlobal);\n return;\n }\n\n // Check if script tag exists\n const existingScript = document.querySelector(`script[src=\"${url}\"]`);\n if (existingScript) {\n this.waitForScriptLoad(existingScript as HTMLScriptElement, globalName, resolve, reject);\n return;\n }\n\n // Create new script\n const script = document.createElement('script');\n script.src = url;\n script.async = true;\n script.crossOrigin = 'anonymous';\n\n const cleanup = () => {\n script.removeEventListener('load', onLoad);\n script.removeEventListener('error', onError);\n };\n\n const onLoad = async () => {\n cleanup();\n \n // Use progressive delay if enabled, otherwise use original behavior\n if (LibraryLoader.enableProgressiveDelay) {\n try {\n const global = await LibraryLoader.waitForGlobalVariable(globalName, url, debug);\n resolve(global);\n } catch (error) {\n reject(error);\n }\n } else {\n // Original behavior\n const global = (window as any)[globalName];\n if (global) {\n if (debug) {\n console.log(`✅ Library '${globalName}' loaded successfully from ${url}`);\n }\n resolve(global);\n } else {\n // Some libraries may take a moment to initialize\n const timeoutId = resourceManager.setTimeout(\n LIBRARY_LOADER_COMPONENT_ID,\n () => {\n const delayedGlobal = (window as any)[globalName];\n if (delayedGlobal) {\n if (debug) {\n console.log(`✅ Library '${globalName}' loaded successfully (delayed initialization)`);\n }\n resolve(delayedGlobal);\n } else {\n reject(new Error(`${globalName} not found after script load`));\n }\n },\n 100,\n { url, globalName }\n );\n }\n }\n };\n\n const onError = () => {\n cleanup();\n reject(new Error(`Failed to load script: ${url}`));\n };\n\n script.addEventListener('load', onLoad);\n script.addEventListener('error', onError);\n\n if (debug) {\n console.log(`📦 Loading library '${globalName}' from ${url}...`);\n }\n document.head.appendChild(script);\n \n // Register the script element for cleanup\n resourceManager.registerDOMElement(LIBRARY_LOADER_COMPONENT_ID, script);\n });\n\n this.loadedResources.set(url, { \n element: document.querySelector(`script[src=\"${url}\"]`)!, \n promise \n });\n\n return promise;\n }\n\n /**\n * Check if a library global variable is properly initialized\n * Generic check that works for any library\n */\n private static isLibraryReady(globalVariable: any): boolean {\n if (!globalVariable) {\n return false;\n }\n \n // For functions, they're ready immediately\n if (typeof globalVariable === 'function') {\n return true;\n }\n \n // For objects, check if they have properties (not an empty object)\n if (typeof globalVariable === 'object') {\n // Check for non-empty object with enumerable properties\n const keys = Object.keys(globalVariable);\n // Some libraries might have only non-enumerable properties, \n // so also check for common indicators of initialization\n return keys.length > 0 || \n Object.getOwnPropertyNames(globalVariable).length > 1 || // > 1 to exclude just constructor\n globalVariable.constructor !== Object; // Has a custom constructor\n }\n \n // For other types (string, number, etc.), consider them ready\n return true;\n }\n\n /**\n * Wait for a global variable to be available with progressive delays\n * @param globalName The name of the global variable to wait for\n * @param url The URL of the script (for debugging)\n * @param debug Whether to log debug information\n * @returns The global variable once it's available\n */\n private static async waitForGlobalVariable(\n globalName: string, \n url: string, \n debug: boolean = false\n ): Promise<any> {\n const delays = [0, 100, 200, 300, 400]; // Total: 1000ms max delay\n const maxAttempts = delays.length;\n let totalDelay = 0;\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n // Wait for the specified delay (0ms on first attempt)\n if (attempt > 0) {\n const delay = delays[attempt];\n if (debug) {\n console.log(`⏳ Waiting ${delay}ms for ${globalName} to initialize (attempt ${attempt + 1}/${maxAttempts})...`);\n }\n await new Promise(resolve => {\n resourceManager.setTimeout(\n LIBRARY_LOADER_COMPONENT_ID,\n () => resolve(undefined),\n delay,\n { globalName, attempt }\n );\n });\n totalDelay += delay;\n }\n\n // Check if the global variable exists\n const global = (window as any)[globalName];\n if (global) {\n // Use generic library readiness check\n const isReady = this.isLibraryReady(global);\n\n if (isReady) {\n if (debug) {\n if (totalDelay > 0) {\n console.log(`✅ ${globalName} ready after ${totalDelay}ms delay`);\n } else {\n console.log(`✅ Library '${globalName}' loaded successfully from ${url}`);\n }\n }\n return global;\n } else if (debug && attempt < maxAttempts - 1) {\n console.log(`🔄 ${globalName} exists but not fully initialized, will retry...`);\n }\n }\n }\n\n // Final check after all attempts\n const finalGlobal = (window as any)[globalName];\n if (finalGlobal) {\n console.warn(`⚠️ ${globalName} loaded but may not be fully initialized after ${totalDelay}ms`);\n return finalGlobal;\n }\n\n throw new Error(`${globalName} not found after script load and ${totalDelay}ms delay`);\n }\n\n /**\n * Load CSS from URL\n */\n private static loadCSS(url: string): void {\n if (this.loadedResources.has(url)) {\n return;\n }\n\n const existingLink = document.querySelector(`link[href=\"${url}\"]`);\n if (existingLink) {\n return;\n }\n\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = url;\n document.head.appendChild(link);\n \n // Register the link element for cleanup\n resourceManager.registerDOMElement(LIBRARY_LOADER_COMPONENT_ID, link);\n\n this.loadedResources.set(url, {\n element: link,\n promise: Promise.resolve()\n });\n }\n\n /**\n * Wait for existing script to load\n */\n private static waitForScriptLoad(\n script: HTMLScriptElement,\n globalName: string,\n resolve: (value: any) => void,\n reject: (reason: any) => void\n ): void {\n const checkGlobal = () => {\n const global = (window as any)[globalName];\n if (global) {\n resolve(global);\n } else {\n // Retry after a short delay\n resourceManager.setTimeout(\n LIBRARY_LOADER_COMPONENT_ID,\n () => {\n const delayedGlobal = (window as any)[globalName];\n if (delayedGlobal) {\n resolve(delayedGlobal);\n } else {\n reject(new Error(`${globalName} not found after script load`));\n }\n },\n 100,\n { context: 'waitForScriptLoad', globalName }\n );\n }\n };\n\n // Check if already loaded\n if ((script as any).complete || (script as any).readyState === 'complete') {\n checkGlobal();\n return;\n }\n\n // Wait for load\n const loadHandler = () => {\n checkGlobal();\n };\n resourceManager.addEventListener(\n LIBRARY_LOADER_COMPONENT_ID,\n script,\n 'load',\n loadHandler,\n { once: true }\n );\n }\n\n\n /**\n * Get all loaded resources (for cleanup)\n */\n static getLoadedResources(): Map<string, LoadedResource> {\n return this.loadedResources;\n }\n\n /**\n * Clear loaded resources cache and cleanup DOM elements\n */\n static clearCache(): void {\n // Remove all script and link elements we added\n this.loadedResources.forEach((resource, url) => {\n if (resource.element && resource.element.parentNode) {\n resource.element.parentNode.removeChild(resource.element);\n }\n });\n \n this.loadedResources.clear();\n this.loadedLibraryStates.clear();\n \n // Clean up any resources managed by resource manager\n resourceManager.cleanupComponent(LIBRARY_LOADER_COMPONENT_ID);\n }\n\n /**\n * Load a library with its dependencies\n * @param libraryName - Name of the library to load\n * @param allLibraries - All available libraries for dependency resolution\n * @param requestedBy - Name of the component/library requesting this load\n * @param options - Dependency resolution options\n * @returns Promise resolving to the loaded library global object\n */\n static async loadLibraryWithDependencies(\n libraryName: string,\n allLibraries: ComponentLibraryEntity[],\n requestedBy: string = 'user',\n options?: DependencyResolutionOptions\n ): Promise<any> {\n const debug = options?.debug || false;\n \n if (debug) {\n console.log(`📚 Loading library '${libraryName}' with dependencies`);\n }\n\n // Check if already loaded\n const existingState = this.loadedLibraryStates.get(libraryName);\n if (existingState) {\n if (debug) {\n console.log(`✅ Library '${libraryName}' already loaded (version: ${existingState.version})`);\n }\n // Track who requested it\n if (!existingState.requestedBy.includes(requestedBy)) {\n existingState.requestedBy.push(requestedBy);\n }\n return (window as any)[existingState.globalVariable];\n }\n\n // Get load order including dependencies\n const loadOrderResult = this.dependencyResolver.getLoadOrder(\n [libraryName],\n allLibraries,\n options\n );\n\n if (!loadOrderResult.success) {\n const errors = loadOrderResult.errors?.join(', ') || 'Unknown error';\n throw new Error(`Failed to resolve dependencies for '${libraryName}': ${errors}`);\n }\n\n if (loadOrderResult.warnings && debug) {\n console.warn(`⚠️ Warnings for '${libraryName}':`, loadOrderResult.warnings);\n }\n\n const loadOrder = loadOrderResult.order || [];\n if (debug) {\n console.log(`📋 Load order for '${libraryName}':`, loadOrder.map(lib => `${lib.Name}@${lib.Version}`));\n }\n\n // Load libraries in order\n for (const library of loadOrder) {\n // Skip if already loaded\n if (this.loadedLibraryStates.has(library.Name)) {\n if (debug) {\n console.log(`⏭️ Skipping '${library.Name}' (already loaded)`);\n }\n continue;\n }\n\n // Check library status\n if (library.Status) {\n if (library.Status === 'Disabled') {\n console.error(`🚫 ERROR: Library '${library.Name}' is DISABLED and should not be used`);\n // Continue loading anyway per requirements\n } else if (library.Status === 'Deprecated') {\n console.warn(`⚠️ WARNING: Library '${library.Name}' is DEPRECATED. Consider using an alternative.`);\n }\n // Active status is fine, no message needed\n }\n\n if (debug) {\n console.log(`📥 Loading '${library.Name}@${library.Version}'`);\n }\n\n // Load the library\n if (!library.CDNUrl || !library.GlobalVariable) {\n throw new Error(`Library '${library.Name}' missing CDN URL or global variable`);\n }\n\n // Load CSS if available\n if (library.CDNCssUrl) {\n const cssUrls = library.CDNCssUrl.split(',').map(url => url.trim());\n for (const cssUrl of cssUrls) {\n if (cssUrl) {\n this.loadCSS(cssUrl);\n }\n }\n }\n\n // Load the script\n const loadedGlobal = await this.loadScript(library.CDNUrl, library.GlobalVariable, debug);\n\n // Track the loaded state\n const dependencies = Array.from(\n this.dependencyResolver.getDirectDependencies(library).keys()\n );\n\n this.loadedLibraryStates.set(library.Name, {\n name: library.Name,\n version: library.Version || 'unknown',\n globalVariable: library.GlobalVariable,\n loadedAt: new Date(),\n requestedBy: library.Name === libraryName ? [requestedBy] : [],\n dependencies\n });\n\n if (debug) {\n console.log(`✅ Loaded '${library.Name}@${library.Version}'`);\n }\n }\n\n // Return the originally requested library's global\n const targetLibrary = loadOrder.find(lib => lib.Name === libraryName);\n if (!targetLibrary || !targetLibrary.GlobalVariable) {\n throw new Error(`Failed to load library '${libraryName}'`);\n }\n\n return (window as any)[targetLibrary.GlobalVariable];\n }\n\n /**\n * Load multiple libraries with dependency resolution\n * @param libraryNames - Names of libraries to load\n * @param allLibraries - All available libraries for dependency resolution\n * @param requestedBy - Name of the component requesting these libraries\n * @param options - Dependency resolution options\n * @returns Map of library names to their loaded global objects\n */\n static async loadLibrariesWithDependencies(\n libraryNames: string[],\n allLibraries: ComponentLibraryEntity[],\n requestedBy: string = 'user',\n options?: DependencyResolutionOptions\n ): Promise<Map<string, any>> {\n const debug = options?.debug || false;\n const result = new Map<string, any>();\n \n if (debug) {\n console.log(`📚 Loading libraries with dependencies:`, libraryNames);\n console.log(` 📦 Total available libraries: ${allLibraries.length}`);\n console.log(` 📋 Available library list:`, allLibraries.map(l => `${l.Name}@${l.Version}`));\n }\n\n // Get combined load order for all requested libraries\n const loadOrderResult = this.dependencyResolver.getLoadOrder(\n libraryNames,\n allLibraries,\n options\n );\n\n if (!loadOrderResult.success) {\n const errors = loadOrderResult.errors?.join(', ') || 'Unknown error';\n throw new Error(`Failed to resolve dependencies: ${errors}`);\n }\n\n if (debug) {\n console.log(` 📊 Dependency resolution result:`, {\n success: loadOrderResult.success,\n errors: loadOrderResult.errors || [],\n warnings: loadOrderResult.warnings || []\n });\n \n if (loadOrderResult.order) {\n console.log(` 🔄 Resolved dependencies for each library:`);\n loadOrderResult.order.forEach(lib => {\n const deps = this.dependencyResolver.parseDependencies(lib.Dependencies);\n if (deps.size > 0) {\n console.log(` • ${lib.Name}@${lib.Version} requires:`, Array.from(deps.entries()));\n } else {\n console.log(` • ${lib.Name}@${lib.Version} (no dependencies)`);\n }\n });\n }\n }\n\n if (loadOrderResult.warnings && debug) {\n console.warn(` ⚠️ Warnings:`, loadOrderResult.warnings);\n }\n\n const loadOrder = loadOrderResult.order || [];\n if (debug) {\n console.log(` 📋 Final load order:`, loadOrder.map(lib => `${lib.Name}@${lib.Version}`));\n }\n\n // Load all libraries in order\n for (const library of loadOrder) {\n // Skip if already loaded\n if (this.loadedLibraryStates.has(library.Name)) {\n if (debug) {\n console.log(`⏭️ Skipping '${library.Name}' (already loaded)`);\n }\n const state = this.loadedLibraryStates.get(library.Name)!;\n if (libraryNames.includes(library.Name)) {\n result.set(library.Name, (window as any)[state.globalVariable]);\n }\n continue;\n }\n\n // Check library status\n if (library.Status) {\n if (library.Status === 'Disabled') {\n console.error(`🚫 ERROR: Library '${library.Name}' is DISABLED and should not be used`);\n // Continue loading anyway per requirements\n } else if (library.Status === 'Deprecated') {\n console.warn(`⚠️ WARNING: Library '${library.Name}' is DEPRECATED. Consider using an alternative.`);\n }\n // Active status is fine, no message needed\n }\n\n if (debug) {\n console.log(`📥 Loading '${library.Name}@${library.Version}'`);\n }\n\n // Load the library\n if (!library.CDNUrl || !library.GlobalVariable) {\n throw new Error(`Library '${library.Name}' missing CDN URL or global variable`);\n }\n\n // Load CSS if available\n if (library.CDNCssUrl) {\n const cssUrls = library.CDNCssUrl.split(',').map(url => url.trim());\n for (const cssUrl of cssUrls) {\n if (cssUrl) {\n this.loadCSS(cssUrl);\n }\n }\n }\n\n // Load the script\n const loadedGlobal = await this.loadScript(library.CDNUrl, library.GlobalVariable, debug);\n\n // Track the loaded state\n const dependencies = Array.from(\n this.dependencyResolver.getDirectDependencies(library).keys()\n );\n\n this.loadedLibraryStates.set(library.Name, {\n name: library.Name,\n version: library.Version || 'unknown',\n globalVariable: library.GlobalVariable,\n loadedAt: new Date(),\n requestedBy: libraryNames.includes(library.Name) ? [requestedBy] : [],\n dependencies\n });\n\n // Add to result if it was directly requested\n if (libraryNames.includes(library.Name)) {\n result.set(library.Name, loadedGlobal);\n }\n\n if (debug) {\n console.log(`✅ Loaded '${library.Name}@${library.Version}'`);\n }\n }\n\n return result;\n }\n\n /**\n * Get information about loaded libraries\n * @returns Map of loaded library states\n */\n static getLoadedLibraryStates(): Map<string, LoadedLibraryState> {\n return new Map(this.loadedLibraryStates);\n }\n\n /**\n * Check if a library is loaded\n * @param libraryName - Name of the library\n * @returns True if the library is loaded\n */\n static isLibraryLoaded(libraryName: string): boolean {\n return this.loadedLibraryStates.has(libraryName);\n }\n\n /**\n * Get the version of a loaded library\n * @param libraryName - Name of the library\n * @returns Version string or undefined if not loaded\n */\n static getLoadedLibraryVersion(libraryName: string): string | undefined {\n return this.loadedLibraryStates.get(libraryName)?.version;\n }\n}"]}
@@ -0,0 +1,191 @@
1
+ /**
2
+ * Example demonstrating Component Registry integration
3
+ * This shows how to use the new GraphQL-based Component Registry client
4
+ * with the React runtime's ComponentRegistryService
5
+ */
6
+
7
+ import { ComponentRegistryService, IComponentRegistryClient } from '@memberjunction/react-runtime';
8
+ import { GraphQLComponentRegistryClient, GraphQLDataProvider } from '@memberjunction/graphql-dataprovider';
9
+ import { ComponentCompiler } from '@memberjunction/react-runtime';
10
+
11
+ /**
12
+ * Example 1: Using the GraphQL Component Registry Client directly
13
+ */
14
+ async function exampleDirectUsage() {
15
+ // Initialize GraphQL data provider (typically done once at app startup)
16
+ const graphQLProvider = new GraphQLDataProvider({
17
+ endpoint: 'http://localhost:4000/graphql',
18
+ headers: {
19
+ 'Authorization': 'Bearer YOUR_TOKEN'
20
+ }
21
+ });
22
+
23
+ // Create the Component Registry client
24
+ const registryClient = new GraphQLComponentRegistryClient(graphQLProvider);
25
+
26
+ // Get a component from a registry
27
+ const component = await registryClient.GetRegistryComponent({
28
+ registryId: 'mj-central',
29
+ namespace: 'core/ui',
30
+ name: 'DataGrid',
31
+ version: '1.0.0'
32
+ });
33
+
34
+ if (component) {
35
+ console.log('Component loaded:', component.name);
36
+ console.log('Description:', component.description);
37
+ console.log('Code length:', component.code.length);
38
+ }
39
+
40
+ // Search for components
41
+ const searchResult = await registryClient.SearchRegistryComponents({
42
+ query: 'dashboard',
43
+ type: 'dashboard',
44
+ limit: 10
45
+ });
46
+
47
+ console.log(`Found ${searchResult.total} components`);
48
+ searchResult.components.forEach(comp => {
49
+ console.log(`- ${comp.name}: ${comp.description}`);
50
+ });
51
+ }
52
+
53
+ /**
54
+ * Example 2: Integrating with React Runtime's ComponentRegistryService
55
+ */
56
+ async function exampleRuntimeIntegration() {
57
+ // Create GraphQL client
58
+ const graphQLProvider = new GraphQLDataProvider({
59
+ endpoint: 'http://localhost:4000/graphql',
60
+ headers: {
61
+ 'Authorization': 'Bearer YOUR_TOKEN'
62
+ }
63
+ });
64
+
65
+ const registryClient = new GraphQLComponentRegistryClient(graphQLProvider);
66
+
67
+ // Create compiler and runtime context
68
+ const compiler = new ComponentCompiler({ debug: true });
69
+ const runtimeContext = {
70
+ // Your runtime context (React, libraries, etc.)
71
+ };
72
+
73
+ // Get or create the ComponentRegistryService with GraphQL client
74
+ const registryService = ComponentRegistryService.getInstance(
75
+ compiler,
76
+ runtimeContext,
77
+ true, // debug
78
+ registryClient // Pass the GraphQL client
79
+ );
80
+
81
+ // Alternative: Set the GraphQL client after creation
82
+ // registryService.setGraphQLClient(registryClient);
83
+
84
+ // Now the service will use GraphQL for registry operations
85
+ const compiledComponent = await registryService.getCompiledComponent(
86
+ 'component-id-123',
87
+ 'reference-id',
88
+ undefined // contextUser (optional)
89
+ );
90
+
91
+ console.log('Component compiled and cached');
92
+ }
93
+
94
+ /**
95
+ * Example 3: Creating a custom adapter for the IComponentRegistryClient interface
96
+ */
97
+ class CustomRegistryAdapter implements IComponentRegistryClient {
98
+ private graphQLClient: GraphQLComponentRegistryClient;
99
+
100
+ constructor(graphQLClient: GraphQLComponentRegistryClient) {
101
+ this.graphQLClient = graphQLClient;
102
+ }
103
+
104
+ async GetRegistryComponent(params: {
105
+ registryId: string;
106
+ namespace: string;
107
+ name: string;
108
+ version?: string;
109
+ }) {
110
+ // Add custom logic here (logging, caching, transformation, etc.)
111
+ console.log(`Fetching component: ${params.namespace}/${params.name}`);
112
+
113
+ const result = await this.graphQLClient.GetRegistryComponent(params);
114
+
115
+ // Custom post-processing if needed
116
+ if (result) {
117
+ console.log(`Successfully loaded component v${result.version}`);
118
+ }
119
+
120
+ return result;
121
+ }
122
+ }
123
+
124
+ /**
125
+ * Example 4: Fallback pattern - GraphQL with HTTP fallback
126
+ */
127
+ async function exampleWithFallback() {
128
+ const compiler = new ComponentCompiler({ debug: true });
129
+ const runtimeContext = {};
130
+
131
+ let registryService: ComponentRegistryService;
132
+
133
+ try {
134
+ // Try to use GraphQL client
135
+ const graphQLProvider = new GraphQLDataProvider({
136
+ endpoint: 'http://localhost:4000/graphql',
137
+ headers: {
138
+ 'Authorization': 'Bearer YOUR_TOKEN'
139
+ }
140
+ });
141
+
142
+ const registryClient = new GraphQLComponentRegistryClient(graphQLProvider);
143
+
144
+ registryService = ComponentRegistryService.getInstance(
145
+ compiler,
146
+ runtimeContext,
147
+ true,
148
+ registryClient
149
+ );
150
+
151
+ console.log('Using GraphQL client for registry operations');
152
+ } catch (error) {
153
+ // Fallback to direct HTTP (service handles this internally)
154
+ console.log('GraphQL not available, falling back to direct HTTP');
155
+
156
+ registryService = ComponentRegistryService.getInstance(
157
+ compiler,
158
+ runtimeContext,
159
+ true
160
+ // No GraphQL client - will use direct HTTP
161
+ );
162
+ }
163
+
164
+ // Service will use the appropriate method based on configuration
165
+ const component = await registryService.getCompiledComponent(
166
+ 'component-id',
167
+ 'ref-id'
168
+ );
169
+ }
170
+
171
+ // Run examples
172
+ (async () => {
173
+ console.log('=== Component Registry Integration Examples ===\n');
174
+
175
+ try {
176
+ console.log('1. Direct GraphQL Client Usage:');
177
+ await exampleDirectUsage();
178
+
179
+ console.log('\n2. Runtime Integration:');
180
+ await exampleRuntimeIntegration();
181
+
182
+ console.log('\n3. Custom Adapter Pattern:');
183
+ // Demonstrate custom adapter
184
+
185
+ console.log('\n4. Fallback Pattern:');
186
+ await exampleWithFallback();
187
+
188
+ } catch (error) {
189
+ console.error('Error in examples:', error);
190
+ }
191
+ })();