@memberjunction/react-runtime 2.99.0 → 2.100.1

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 +24 -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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/component-manager/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * @fileoverview Type definitions for the unified ComponentManager\n */\n\nimport { ComponentSpec } from '@memberjunction/interactive-component-types';\nimport { UserInfo } from '@memberjunction/core';\nimport { ComponentLibraryEntity } from '@memberjunction/core-entities';\nimport { ComponentObject } from '../types';\n\n/**\n * Resolution mode for specs\n */\nexport type ResolutionMode = 'embed' | 'preserve-metadata';\n\n/**\n * Options for loading a component\n */\nexport interface LoadOptions {\n /**\n * User context for database operations and registry fetching\n */\n contextUser?: UserInfo;\n \n /**\n * Force re-fetch from registry even if cached\n */\n forceRefresh?: boolean;\n \n /**\n * Force recompilation even if compiled version exists\n */\n forceRecompile?: boolean;\n \n /**\n * Whether this is a dependent component (for tracking)\n */\n isDependent?: boolean;\n \n /**\n * What to return from the load operation\n */\n returnType?: 'component' | 'spec' | 'both';\n \n /**\n * Enable registry usage tracking for licensing (default: true)\n */\n trackUsage?: boolean;\n \n /**\n * Namespace to use if not specified in spec\n */\n defaultNamespace?: string;\n \n /**\n * Version to use if not specified in spec\n */\n defaultVersion?: string;\n \n /**\n * How to format resolved specs:\n * - 'preserve-metadata': Keep registry/namespace/name intact (for UI display)\n * - 'embed': Convert to embedded format (for test harness)\n * @default 'preserve-metadata'\n */\n resolutionMode?: ResolutionMode;\n \n /**\n * All available component libraries (for browser context where ComponentMetadataEngine isn't available)\n */\n allLibraries?: ComponentLibraryEntity[];\n}\n\n/**\n * Result of loading a single component\n */\nexport interface LoadResult {\n /**\n * Whether the load operation succeeded\n */\n success: boolean;\n \n /**\n * The compiled component object\n */\n component?: ComponentObject;\n \n /**\n * The fully resolved component specification\n */\n spec?: ComponentSpec;\n \n /**\n * Whether the component was loaded from cache\n */\n fromCache: boolean;\n \n /**\n * Any errors that occurred during loading\n */\n errors?: Array<{\n message: string;\n phase: 'fetch' | 'compile' | 'register' | 'dependency';\n componentName?: string;\n }>;\n \n /**\n * Components that were loaded as dependencies\n */\n dependencies?: Record<string, ComponentObject>;\n}\n\n/**\n * Result of loading a component hierarchy\n */\nexport interface HierarchyResult {\n /**\n * Whether the entire hierarchy loaded successfully\n */\n success: boolean;\n \n /**\n * The root component object\n */\n rootComponent?: ComponentObject;\n \n /**\n * The fully resolved root specification\n */\n resolvedSpec?: ComponentSpec;\n \n /**\n * List of all component names that were loaded\n */\n loadedComponents: string[];\n \n /**\n * Any errors that occurred during loading\n */\n errors: Array<{\n message: string;\n phase: 'fetch' | 'compile' | 'register' | 'dependency';\n componentName?: string;\n }>;\n \n /**\n * Map of all loaded components by name\n */\n components?: Record<string, ComponentObject>;\n \n /**\n * Number of components loaded from cache vs fetched\n */\n stats?: {\n fromCache: number;\n fetched: number;\n compiled: number;\n totalTime: number;\n };\n}\n\n/**\n * Configuration for ComponentManager\n */\nexport interface ComponentManagerConfig {\n /**\n * Enable debug logging\n */\n debug?: boolean;\n \n /**\n * Maximum cache size for fetched specs\n */\n maxCacheSize?: number;\n \n /**\n * Cache TTL in milliseconds (default: 1 hour)\n */\n cacheTTL?: number;\n \n /**\n * Whether to track registry usage for licensing\n */\n enableUsageTracking?: boolean;\n \n /**\n * Batch size for parallel dependency loading\n */\n dependencyBatchSize?: number;\n \n /**\n * Timeout for registry fetch operations (ms)\n */\n fetchTimeout?: number;\n}\n\n/**\n * Internal cache entry for fetched specs\n */\nexport interface CacheEntry {\n spec: ComponentSpec;\n fetchedAt: Date;\n hash?: string;\n usageNotified: boolean;\n}"]}
package/dist/index.d.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  import { ComponentCompiler } from './compiler';
2
2
  import { ComponentRegistry } from './registry';
3
3
  import { ComponentResolver } from './registry';
4
+ import { ComponentManager } from './component-manager';
4
5
  export * from './types';
5
6
  export { ComponentCompiler } from './compiler';
6
7
  export { DEFAULT_PRESETS, DEFAULT_PLUGINS, PRODUCTION_CONFIG, DEVELOPMENT_CONFIG, getBabelConfig, validateBabelPresets, getJSXConfig } from './compiler';
7
8
  export { ComponentRegistry } from './registry';
8
- export { ComponentResolver, ComponentSpec, ResolvedComponents, ComponentRegistryService } from './registry';
9
+ export { ComponentResolver, ComponentSpec, ResolvedComponents, ComponentRegistryService, IComponentRegistryClient } from './registry';
10
+ export { ComponentManager } from './component-manager';
11
+ export type { LoadOptions, LoadResult, HierarchyResult, ComponentManagerConfig } from './component-manager';
9
12
  export { createErrorBoundary, withErrorBoundary, formatComponentError, createErrorLogger } from './runtime';
10
13
  export { buildComponentProps, normalizeCallbacks, normalizeStyles, validateComponentProps, mergeProps, createPropsTransformer, wrapCallbacksWithLogging, extractPropPaths, PropBuilderOptions } from './runtime';
11
14
  export { ComponentHierarchyRegistrar, registerComponentHierarchy, validateComponentSpec, flattenComponentHierarchy, countComponentsInHierarchy, HierarchyRegistrationResult, ComponentRegistrationError, HierarchyRegistrationOptions } from './runtime';
@@ -41,10 +44,12 @@ export declare const DEFAULT_CONFIGS: {
41
44
  export declare function createReactRuntime(babelInstance: any, config?: {
42
45
  compiler?: Partial<import('./types').CompilerConfig>;
43
46
  registry?: Partial<import('./types').RegistryConfig>;
47
+ manager?: Partial<import('./component-manager').ComponentManagerConfig>;
44
48
  }, runtimeContext?: import('./types').RuntimeContext, debug?: boolean): {
45
49
  compiler: ComponentCompiler;
46
50
  registry: ComponentRegistry;
47
51
  resolver: ComponentResolver;
52
+ manager: ComponentManager;
48
53
  version: string;
49
54
  debug: boolean;
50
55
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG/C,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EACL,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,YAAY,EACb,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,UAAU,EACV,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,E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,OAAe;;;;;;;EAwCvB"}
package/dist/index.js CHANGED
@@ -14,11 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.VERSION = exports.unwrapAllComponents = exports.unwrapComponents = exports.unwrapComponent = exports.unwrapAllLibraryComponents = exports.unwrapLibraryComponents = exports.unwrapLibraryComponent = exports.CacheManager = exports.resourceManager = exports.ResourceManager = exports.ComponentErrorAnalyzer = exports.LibraryRegistry = exports.isCoreRuntimeLibrary = exports.getCoreRuntimeLibraries = exports.LibraryLoader = exports.createStandardLibraries = exports.StandardLibraryManager = exports.createDefaultComponentStyles = exports.SetupStyles = exports.reactRootManager = exports.ReactRootManager = exports.countComponentsInHierarchy = exports.flattenComponentHierarchy = exports.validateComponentSpec = exports.registerComponentHierarchy = exports.ComponentHierarchyRegistrar = exports.extractPropPaths = exports.wrapCallbacksWithLogging = exports.createPropsTransformer = exports.mergeProps = exports.validateComponentProps = exports.normalizeStyles = exports.normalizeCallbacks = exports.buildComponentProps = exports.createErrorLogger = exports.formatComponentError = exports.withErrorBoundary = exports.createErrorBoundary = exports.ComponentRegistryService = exports.ComponentSpec = exports.ComponentResolver = exports.ComponentRegistry = exports.getJSXConfig = exports.validateBabelPresets = exports.getBabelConfig = exports.DEVELOPMENT_CONFIG = exports.PRODUCTION_CONFIG = exports.DEFAULT_PLUGINS = exports.DEFAULT_PRESETS = exports.ComponentCompiler = void 0;
18
- exports.createReactRuntime = exports.DEFAULT_CONFIGS = void 0;
17
+ exports.unwrapAllComponents = exports.unwrapComponents = exports.unwrapComponent = exports.unwrapAllLibraryComponents = exports.unwrapLibraryComponents = exports.unwrapLibraryComponent = exports.CacheManager = exports.resourceManager = exports.ResourceManager = exports.ComponentErrorAnalyzer = exports.LibraryRegistry = exports.isCoreRuntimeLibrary = exports.getCoreRuntimeLibraries = exports.LibraryLoader = exports.createStandardLibraries = exports.StandardLibraryManager = exports.createDefaultComponentStyles = exports.SetupStyles = exports.reactRootManager = exports.ReactRootManager = exports.countComponentsInHierarchy = exports.flattenComponentHierarchy = exports.validateComponentSpec = exports.registerComponentHierarchy = exports.ComponentHierarchyRegistrar = exports.extractPropPaths = exports.wrapCallbacksWithLogging = exports.createPropsTransformer = exports.mergeProps = exports.validateComponentProps = exports.normalizeStyles = exports.normalizeCallbacks = exports.buildComponentProps = exports.createErrorLogger = exports.formatComponentError = exports.withErrorBoundary = exports.createErrorBoundary = exports.ComponentManager = exports.ComponentRegistryService = exports.ComponentSpec = exports.ComponentResolver = exports.ComponentRegistry = exports.getJSXConfig = exports.validateBabelPresets = exports.getBabelConfig = exports.DEVELOPMENT_CONFIG = exports.PRODUCTION_CONFIG = exports.DEFAULT_PLUGINS = exports.DEFAULT_PRESETS = exports.ComponentCompiler = void 0;
18
+ exports.createReactRuntime = exports.DEFAULT_CONFIGS = exports.VERSION = void 0;
19
19
  const compiler_1 = require("./compiler");
20
20
  const registry_1 = require("./registry");
21
21
  const registry_2 = require("./registry");
22
+ const component_manager_1 = require("./component-manager");
22
23
  __exportStar(require("./types"), exports);
23
24
  var compiler_2 = require("./compiler");
24
25
  Object.defineProperty(exports, "ComponentCompiler", { enumerable: true, get: function () { return compiler_2.ComponentCompiler; } });
@@ -36,6 +37,8 @@ var registry_4 = require("./registry");
36
37
  Object.defineProperty(exports, "ComponentResolver", { enumerable: true, get: function () { return registry_4.ComponentResolver; } });
37
38
  Object.defineProperty(exports, "ComponentSpec", { enumerable: true, get: function () { return registry_4.ComponentSpec; } });
38
39
  Object.defineProperty(exports, "ComponentRegistryService", { enumerable: true, get: function () { return registry_4.ComponentRegistryService; } });
40
+ var component_manager_2 = require("./component-manager");
41
+ Object.defineProperty(exports, "ComponentManager", { enumerable: true, get: function () { return component_manager_2.ComponentManager; } });
39
42
  var runtime_1 = require("./runtime");
40
43
  Object.defineProperty(exports, "createErrorBoundary", { enumerable: true, get: function () { return runtime_1.createErrorBoundary; } });
41
44
  Object.defineProperty(exports, "withErrorBoundary", { enumerable: true, get: function () { return runtime_1.withErrorBoundary; } });
@@ -114,14 +117,20 @@ function createReactRuntime(babelInstance, config, runtimeContext, debug = false
114
117
  ...config?.registry,
115
118
  debug: config?.registry?.debug ?? debug
116
119
  };
120
+ const managerConfig = {
121
+ ...config?.manager,
122
+ debug: config?.manager?.debug ?? debug
123
+ };
117
124
  const compiler = new compiler_1.ComponentCompiler(compilerConfig);
118
125
  compiler.setBabelInstance(babelInstance);
119
126
  const registry = new registry_1.ComponentRegistry(registryConfig);
120
127
  const resolver = new registry_2.ComponentResolver(registry, compiler, runtimeContext);
128
+ const manager = new component_manager_1.ComponentManager(compiler, registry, runtimeContext || { React: null, ReactDOM: null }, managerConfig);
121
129
  return {
122
130
  compiler,
123
131
  registry,
124
132
  resolver,
133
+ manager,
125
134
  version: exports.VERSION,
126
135
  debug
127
136
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAOA,yCAA+C;AAC/C,yCAA+C;AAC/C,yCAA+C;AAG/C,0CAAwB;AAGxB,uCAA+C;AAAtC,6GAAA,iBAAiB,OAAA;AAC1B,uCAQoB;AAPlB,2GAAA,eAAe,OAAA;AACf,2GAAA,eAAe,OAAA;AACf,6GAAA,iBAAiB,OAAA;AACjB,8GAAA,kBAAkB,OAAA;AAClB,0GAAA,cAAc,OAAA;AACd,gHAAA,oBAAoB,OAAA;AACpB,wGAAA,YAAY,OAAA;AAId,uCAA+C;AAAtC,6GAAA,iBAAiB,OAAA;AAC1B,uCAKoB;AAJlB,6GAAA,iBAAiB,OAAA;AACjB,yGAAA,aAAa,OAAA;AAEb,oHAAA,wBAAwB,OAAA;AAI1B,qCAKmB;AAJjB,8GAAA,mBAAmB,OAAA;AACnB,4GAAA,iB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QACR,KAAK,EAAE;YACL,OAAO,EAAE,CAAC,OAAO,CAAC;YAClB,OAAO,EAAE,EAAE;SACZ;QACD,MAAM,EAAE,KAAK;QACb,UAAU,EAAE,KAAK;QACjB,KAAK,EAAE,IAAI;QACX,YAAY,EAAE,GAAG;KAClB;IACD,QAAQ,EAAE;QACR,aAAa,EAAE,IAAI;QACnB,eAAe,EAAE,KAAK;QACtB,MAAM,EAAE,IAAI;QACZ,gBAAgB,EAAE,IAAI;KACvB;CACF,CAAC;AAUF,SAAgB,kBAAkB,CAChC,aAAkB,EAClB,MAGC,EACD,cAAiD,EACjD,QAAiB,KAAK;IAGtB,MAAM,cAAc,GAAG;QACrB,GAAG,MAAM,EAAE,QAAQ;QACnB,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,IAAI,KAAK;KACxC,CAAC;IAEF,MAAM,cAAc,GAAG;QACrB,GAAG,MAAM,EAAE,QAAQ;QACnB,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,IAAI,KAAK;KACxC,CAAC;IAEF,MAAM,QAAQ,GAAG,IAAI,4BAAiB,CAAC,cAAc,CAAC,CAAC;IACvD,QAAQ,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAEzC,MAAM,QAAQ,GAAG,IAAI,4BAAiB,CAAC,cAAc,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,IAAI,4BAAiB,CAAC,QAAQ,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;IAE3E,OAAO;QACL,QAAQ;QACR,QAAQ;QACR,QAAQ;QACR,OAAO,EAAE,eAAO;QAChB,KAAK;KACN,CAAC;AACJ,CAAC;AAjCD,gDAiCC","sourcesContent":["/**\n * @fileoverview Main entry point for the MemberJunction React Runtime.\n * Exports all public APIs for platform-agnostic React component compilation and execution.\n * @module @memberjunction/react-runtime\n */\n\n// Import necessary classes for createReactRuntime function\nimport { ComponentCompiler } from './compiler';\nimport { ComponentRegistry } from './registry';\nimport { ComponentResolver } from './registry';\n\n// Export all types\nexport * from './types';\n\n// Export compiler APIs\nexport { ComponentCompiler } from './compiler';\nexport { \n DEFAULT_PRESETS,\n DEFAULT_PLUGINS,\n PRODUCTION_CONFIG,\n DEVELOPMENT_CONFIG,\n getBabelConfig,\n validateBabelPresets,\n getJSXConfig\n} from './compiler';\n\n// Export registry APIs\nexport { ComponentRegistry } from './registry';\nexport { \n ComponentResolver,\n ComponentSpec,\n ResolvedComponents,\n ComponentRegistryService\n} from './registry';\n\n// Export runtime APIs\nexport {\n createErrorBoundary,\n withErrorBoundary,\n formatComponentError,\n createErrorLogger\n} from './runtime';\n\n\nexport {\n buildComponentProps,\n normalizeCallbacks,\n normalizeStyles,\n validateComponentProps,\n mergeProps,\n createPropsTransformer,\n wrapCallbacksWithLogging,\n extractPropPaths,\n PropBuilderOptions\n} from './runtime';\n\nexport {\n ComponentHierarchyRegistrar,\n registerComponentHierarchy,\n validateComponentSpec,\n flattenComponentHierarchy,\n countComponentsInHierarchy,\n HierarchyRegistrationResult,\n ComponentRegistrationError,\n HierarchyRegistrationOptions\n} from './runtime';\n\nexport {\n ReactRootManager,\n reactRootManager,\n ManagedReactRoot\n} from './runtime';\n\n// Export utilities\n\nexport { \n SetupStyles,\n createDefaultComponentStyles \n} from './utilities/component-styles';\n\nexport {\n StandardLibraries,\n StandardLibraryManager,\n createStandardLibraries\n} from './utilities/standard-libraries';\n\nexport {\n LibraryLoader,\n LibraryLoadOptions,\n LibraryLoadResult\n} from './utilities/library-loader';\n\nexport {\n getCoreRuntimeLibraries,\n isCoreRuntimeLibrary\n} from './utilities/core-libraries';\n\nexport {\n LibraryRegistry,\n LibraryDefinition\n} from './utilities/library-registry';\n\nexport {\n ComponentErrorAnalyzer,\n FailedComponentInfo\n} from './utilities/component-error-analyzer';\n\nexport {\n ResourceManager,\n resourceManager,\n ManagedResource\n} from './utilities/resource-manager';\n\nexport {\n CacheManager,\n CacheEntry,\n CacheOptions\n} from './utilities/cache-manager';\n\nexport {\n unwrapLibraryComponent,\n unwrapLibraryComponents,\n unwrapAllLibraryComponents,\n // Legacy exports for backward compatibility\n unwrapComponent,\n unwrapComponents,\n unwrapAllComponents\n} from './utilities/component-unwrapper';\n\n// Version information\nexport const VERSION = '2.69.1';\n\n// Default configurations\nexport const DEFAULT_CONFIGS = {\n compiler: {\n babel: {\n presets: ['react'],\n plugins: []\n },\n minify: false,\n sourceMaps: false,\n cache: true,\n maxCacheSize: 100\n },\n registry: {\n maxComponents: 1000,\n cleanupInterval: 60000,\n useLRU: true,\n enableNamespaces: true\n }\n};\n\n/**\n * Creates a complete React runtime instance with all necessary components\n * @param babelInstance - Babel standalone instance for compilation\n * @param config - Optional configuration overrides\n * @param runtimeContext - Optional runtime context for registry-based components\n * @param debug - Enable debug logging (defaults to false)\n * @returns Object containing compiler, registry, and resolver instances\n */\nexport function createReactRuntime(\n babelInstance: any,\n config?: {\n compiler?: Partial<import('./types').CompilerConfig>;\n registry?: Partial<import('./types').RegistryConfig>;\n },\n runtimeContext?: import('./types').RuntimeContext,\n debug: boolean = false\n) {\n // Merge debug flag into configs\n const compilerConfig = {\n ...config?.compiler,\n debug: config?.compiler?.debug ?? debug\n };\n \n const registryConfig = {\n ...config?.registry,\n debug: config?.registry?.debug ?? debug\n };\n \n const compiler = new ComponentCompiler(compilerConfig);\n compiler.setBabelInstance(babelInstance);\n \n const registry = new ComponentRegistry(registryConfig);\n const resolver = new ComponentResolver(registry, compiler, runtimeContext);\n\n return {\n compiler,\n registry,\n resolver,\n version: VERSION,\n debug\n };\n}"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAOA,yCAA+C;AAC/C,yCAA+C;AAC/C,yCAA+C;AAC/C,2DAAuD;AAGvD,0CAAwB;AAGxB,uCAA+C;AAAtC,6GAAA,iBAAiB,OAAA;AAC1B,uCAQoB;AAPlB,2GAAA,eAAe,OAAA;AACf,2GAAA,eAAe,OAAA;AACf,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gB,CAAC,aAAa,CAAC,CAAC;IAEzC,MAAM,QAAQ,GAAG,IAAI,4BAAiB,CAAC,cAAc,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,IAAI,4BAAiB,CAAC,QAAQ,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;IAG3E,MAAM,OAAO,GAAG,IAAI,oCAAgB,CAClC,QAAQ,EACR,QAAQ,EACR,cAAc,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EACjD,aAAa,CACd,CAAC;IAEF,OAAO;QACL,QAAQ;QACR,QAAQ;QACR,QAAQ;QACR,OAAO;QACP,OAAO,EAAE,eAAO;QAChB,KAAK;KACN,CAAC;AACJ,CAAC;AAhDD,gDAgDC","sourcesContent":["/**\n * @fileoverview Main entry point for the MemberJunction React Runtime.\n * Exports all public APIs for platform-agnostic React component compilation and execution.\n * @module @memberjunction/react-runtime\n */\n\n// Import necessary classes for createReactRuntime function\nimport { ComponentCompiler } from './compiler';\nimport { ComponentRegistry } from './registry';\nimport { ComponentResolver } from './registry';\nimport { ComponentManager } from './component-manager';\n\n// Export all types\nexport * from './types';\n\n// Export compiler APIs\nexport { ComponentCompiler } from './compiler';\nexport { \n DEFAULT_PRESETS,\n DEFAULT_PLUGINS,\n PRODUCTION_CONFIG,\n DEVELOPMENT_CONFIG,\n getBabelConfig,\n validateBabelPresets,\n getJSXConfig\n} from './compiler';\n\n// Export registry APIs\nexport { ComponentRegistry } from './registry';\nexport { \n ComponentResolver,\n ComponentSpec,\n ResolvedComponents,\n ComponentRegistryService,\n IComponentRegistryClient\n} from './registry';\n\n// Export unified ComponentManager\nexport { ComponentManager } from './component-manager';\nexport type {\n LoadOptions,\n LoadResult,\n HierarchyResult,\n ComponentManagerConfig\n} from './component-manager';\n\n// Export runtime APIs\nexport {\n createErrorBoundary,\n withErrorBoundary,\n formatComponentError,\n createErrorLogger\n} from './runtime';\n\n\nexport {\n buildComponentProps,\n normalizeCallbacks,\n normalizeStyles,\n validateComponentProps,\n mergeProps,\n createPropsTransformer,\n wrapCallbacksWithLogging,\n extractPropPaths,\n PropBuilderOptions\n} from './runtime';\n\nexport {\n ComponentHierarchyRegistrar,\n registerComponentHierarchy,\n validateComponentSpec,\n flattenComponentHierarchy,\n countComponentsInHierarchy,\n HierarchyRegistrationResult,\n ComponentRegistrationError,\n HierarchyRegistrationOptions\n} from './runtime';\n\nexport {\n ReactRootManager,\n reactRootManager,\n ManagedReactRoot\n} from './runtime';\n\n// Export utilities\n\nexport { \n SetupStyles,\n createDefaultComponentStyles \n} from './utilities/component-styles';\n\nexport {\n StandardLibraries,\n StandardLibraryManager,\n createStandardLibraries\n} from './utilities/standard-libraries';\n\nexport {\n LibraryLoader,\n LibraryLoadOptions,\n LibraryLoadResult\n} from './utilities/library-loader';\n\nexport {\n getCoreRuntimeLibraries,\n isCoreRuntimeLibrary\n} from './utilities/core-libraries';\n\nexport {\n LibraryRegistry,\n LibraryDefinition\n} from './utilities/library-registry';\n\nexport {\n ComponentErrorAnalyzer,\n FailedComponentInfo\n} from './utilities/component-error-analyzer';\n\nexport {\n ResourceManager,\n resourceManager,\n ManagedResource\n} from './utilities/resource-manager';\n\nexport {\n CacheManager,\n CacheEntry,\n CacheOptions\n} from './utilities/cache-manager';\n\nexport {\n unwrapLibraryComponent,\n unwrapLibraryComponents,\n unwrapAllLibraryComponents,\n // Legacy exports for backward compatibility\n unwrapComponent,\n unwrapComponents,\n unwrapAllComponents\n} from './utilities/component-unwrapper';\n\n// Version information\nexport const VERSION = '2.69.1';\n\n// Default configurations\nexport const DEFAULT_CONFIGS = {\n compiler: {\n babel: {\n presets: ['react'],\n plugins: []\n },\n minify: false,\n sourceMaps: false,\n cache: true,\n maxCacheSize: 100\n },\n registry: {\n maxComponents: 1000,\n cleanupInterval: 60000,\n useLRU: true,\n enableNamespaces: true\n }\n};\n\n/**\n * Creates a complete React runtime instance with all necessary components\n * @param babelInstance - Babel standalone instance for compilation\n * @param config - Optional configuration overrides\n * @param runtimeContext - Optional runtime context for registry-based components\n * @param debug - Enable debug logging (defaults to false)\n * @returns Object containing compiler, registry, and resolver instances\n */\nexport function createReactRuntime(\n babelInstance: any,\n config?: {\n compiler?: Partial<import('./types').CompilerConfig>;\n registry?: Partial<import('./types').RegistryConfig>;\n manager?: Partial<import('./component-manager').ComponentManagerConfig>;\n },\n runtimeContext?: import('./types').RuntimeContext,\n debug: boolean = false\n) {\n // Merge debug flag into configs\n const compilerConfig = {\n ...config?.compiler,\n debug: config?.compiler?.debug ?? debug\n };\n \n const registryConfig = {\n ...config?.registry,\n debug: config?.registry?.debug ?? debug\n };\n \n const managerConfig = {\n ...config?.manager,\n debug: config?.manager?.debug ?? debug\n };\n \n const compiler = new ComponentCompiler(compilerConfig);\n compiler.setBabelInstance(babelInstance);\n \n const registry = new ComponentRegistry(registryConfig);\n const resolver = new ComponentResolver(registry, compiler, runtimeContext);\n \n // Create the unified ComponentManager\n const manager = new ComponentManager(\n compiler,\n registry,\n runtimeContext || { React: null, ReactDOM: null },\n managerConfig\n );\n\n return {\n compiler,\n registry,\n resolver,\n manager, // New unified manager\n version: VERSION,\n debug\n };\n}"]}
@@ -3,6 +3,15 @@ import { ComponentCompiler } from '../compiler';
3
3
  import { RuntimeContext } from '../types';
4
4
  import { ComponentDependencyInfo, DependencyTree } from './registry-provider';
5
5
  import { UserInfo } from '@memberjunction/core';
6
+ export interface IComponentRegistryClient {
7
+ GetRegistryComponent(params: {
8
+ registryName: string;
9
+ namespace: string;
10
+ name: string;
11
+ version?: string;
12
+ hash?: string;
13
+ }): Promise<ComponentSpec | null>;
14
+ }
6
15
  export declare class ComponentRegistryService {
7
16
  private static instance;
8
17
  private compiledComponentCache;
@@ -12,10 +21,16 @@ export declare class ComponentRegistryService {
12
21
  private componentEngine;
13
22
  private registryProviders;
14
23
  private debug;
24
+ private graphQLClient?;
15
25
  private constructor();
16
- static getInstance(compiler: ComponentCompiler, context: RuntimeContext, debug?: boolean): ComponentRegistryService;
26
+ static getInstance(compiler: ComponentCompiler, context: RuntimeContext, debug?: boolean, graphQLClient?: IComponentRegistryClient): ComponentRegistryService;
27
+ setGraphQLClient(client: IComponentRegistryClient): void;
28
+ private cachedProviderClient;
29
+ private getGraphQLClient;
17
30
  initialize(contextUser?: UserInfo): Promise<void>;
31
+ private calculateSpecHash;
18
32
  getCompiledComponent(componentId: string, referenceId?: string, contextUser?: UserInfo): Promise<ComponentObject>;
33
+ getCompiledComponentFromRegistry(registryName: string, namespace: string, name: string, version: string, referenceId?: string, contextUser?: UserInfo): Promise<any>;
19
34
  getComponentSpec(componentId: string, contextUser?: UserInfo): Promise<ComponentSpec>;
20
35
  private fetchFromExternalRegistry;
21
36
  private cacheExternalComponent;
@@ -1 +1 @@
1
- {"version":3,"file":"component-registry-service.d.ts","sourceRoot":"","sources":["../../src/registry/component-registry-service.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAGL,uBAAuB,EACvB,cAAc,EAEf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAY,MAAM,sBAAsB,CAAC;AAuB1D,qBAAa,wBAAwB;IACnC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAyC;IAGhE,OAAO,CAAC,sBAAsB,CAA8C;IAC5E,OAAO,CAAC,mBAAmB,CAAkC;IAG7D,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,eAAe,CAAoC;IAC3D,OAAO,CAAC,iBAAiB,CAAuC;IAChE,OAAO,CAAC,KAAK,CAAkB;IAE/B,OAAO;IAaP,MAAM,CAAC,WAAW,CAChB,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,EAAE,cAAc,EACvB,KAAK,GAAE,OAAe,GACrB,wBAAwB;IAUrB,UAAU,CAAC,WAAW,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAQjD,oBAAoB,CACxB,WAAW,EAAE,MAAM,EACnB,WAAW,CAAC,EAAE,MAAM,EACpB,WAAW,CAAC,EAAE,QAAQ,GACrB,OAAO,CAAC,eAAe,CAAC;IAoGrB,gBAAgB,CACpB,WAAW,EAAE,MAAM,EACnB,WAAW,CAAC,EAAE,QAAQ,GACrB,OAAO,CAAC,aAAa,CAAC;YAuDX,yBAAyB;YAkCzB,sBAAsB;IA0F9B,gBAAgB,CACpB,WAAW,EAAE,MAAM,EACnB,WAAW,CAAC,EAAE,QAAQ,GACrB,OAAO,CAAC,uBAAuB,EAAE,CAAC;IAkC/B,qBAAqB,CACzB,WAAW,EAAE,MAAM,EACnB,WAAW,CAAC,EAAE,QAAQ,EACtB,OAAO,cAAoB,GAC1B,OAAO,CAAC,cAAc,CAAC;IAmDpB,mBAAmB,CACvB,eAAe,EAAE,MAAM,EACvB,WAAW,CAAC,EAAE,QAAQ,GACrB,OAAO,CAAC,MAAM,EAAE,CAAC;IAqBpB,OAAO,CAAC,qBAAqB;IAU7B,wBAAwB,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;IAezE,OAAO,CAAC,qBAAqB;IAoB7B,OAAO,CAAC,iBAAiB;IAWzB,aAAa,IAAI;QACf,kBAAkB,EAAE,MAAM,CAAC;QAC3B,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,MAAM,CAAC;KACxB;IAgBD,UAAU,IAAI,IAAI;IAYlB,aAAa,IAAI,IAAI;IAUrB,MAAM,CAAC,KAAK,IAAI,IAAI;IAUpB,OAAO,CAAC,eAAe;CAUxB"}
1
+ {"version":3,"file":"component-registry-service.d.ts","sourceRoot":"","sources":["../../src/registry/component-registry-service.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,eAAe,E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2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.ComponentRegistryService = void 0;
4
27
  const core_1 = require("@memberjunction/core");
5
28
  const core_entities_1 = require("@memberjunction/core-entities");
29
+ let GraphQLComponentRegistryClient;
6
30
  class ComponentRegistryService {
7
- constructor(compiler, runtimeContext, debug = false) {
31
+ constructor(compiler, runtimeContext, debug = false, graphQLClient) {
8
32
  this.compiledComponentCache = new Map();
9
33
  this.componentReferences = new Map();
10
34
  this.componentEngine = core_entities_1.ComponentMetadataEngine.Instance;
11
35
  this.registryProviders = new Map();
12
36
  this.debug = false;
37
+ this.cachedProviderClient = null;
13
38
  this.compiler = compiler;
14
39
  this.runtimeContext = runtimeContext;
15
40
  this.debug = debug;
41
+ this.graphQLClient = graphQLClient;
16
42
  }
17
- static getInstance(compiler, context, debug = false) {
43
+ static getInstance(compiler, context, debug = false, graphQLClient) {
18
44
  if (!ComponentRegistryService.instance) {
19
- ComponentRegistryService.instance = new ComponentRegistryService(compiler, context, debug);
45
+ ComponentRegistryService.instance = new ComponentRegistryService(compiler, context, debug, graphQLClient);
20
46
  }
21
47
  return ComponentRegistryService.instance;
22
48
  }
49
+ setGraphQLClient(client) {
50
+ this.graphQLClient = client;
51
+ if (this.debug) {
52
+ console.log('✅ GraphQL client configured for component registry');
53
+ }
54
+ }
55
+ async getGraphQLClient() {
56
+ if (this.graphQLClient) {
57
+ return this.graphQLClient;
58
+ }
59
+ if (this.cachedProviderClient) {
60
+ return this.cachedProviderClient;
61
+ }
62
+ try {
63
+ const provider = core_1.Metadata?.Provider;
64
+ if (provider && provider.ExecuteGQL !== undefined) {
65
+ if (!GraphQLComponentRegistryClient) {
66
+ try {
67
+ const graphqlModule = await Promise.resolve().then(() => __importStar(require('@memberjunction/graphql-dataprovider')));
68
+ GraphQLComponentRegistryClient = graphqlModule.GraphQLComponentRegistryClient;
69
+ }
70
+ catch (importError) {
71
+ if (this.debug) {
72
+ console.log('⚠️ [ComponentRegistryService] @memberjunction/graphql-dataprovider not available');
73
+ }
74
+ return null;
75
+ }
76
+ }
77
+ if (GraphQLComponentRegistryClient) {
78
+ try {
79
+ const client = new GraphQLComponentRegistryClient(provider);
80
+ this.cachedProviderClient = client;
81
+ if (this.debug) {
82
+ console.log('📡 [ComponentRegistryService] Created GraphQL client from Metadata.Provider');
83
+ }
84
+ return client;
85
+ }
86
+ catch (error) {
87
+ if (this.debug) {
88
+ console.log('⚠️ [ComponentRegistryService] Failed to create GraphQL client:', error);
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }
94
+ catch (error) {
95
+ if (this.debug) {
96
+ console.log('⚠️ [ComponentRegistryService] Could not access Metadata.Provider:', error);
97
+ }
98
+ }
99
+ return null;
100
+ }
23
101
  async initialize(contextUser) {
24
102
  await this.componentEngine.Config(false, contextUser);
25
103
  }
104
+ async calculateSpecHash(spec) {
105
+ if (typeof crypto === 'undefined' || !crypto.subtle) {
106
+ throw new Error('Web Crypto API not available. This typically happens when running in an insecure context. ' +
107
+ 'Please use HTTPS or localhost for development. ' +
108
+ 'Note: crypto.subtle is available in Node.js 15+ and all modern browsers on secure contexts.');
109
+ }
110
+ const specString = JSON.stringify(spec);
111
+ const encoder = new TextEncoder();
112
+ const data = encoder.encode(specString);
113
+ const hashBuffer = await crypto.subtle.digest('SHA-256', data);
114
+ const hashArray = Array.from(new Uint8Array(hashBuffer));
115
+ const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
116
+ return hashHex;
117
+ }
26
118
  async getCompiledComponent(componentId, referenceId, contextUser) {
27
119
  await this.initialize(contextUser);
28
120
  const component = this.componentEngine.Components.find((c) => c.ID === componentId);
@@ -40,7 +132,7 @@ class ComponentRegistryService {
40
132
  if (this.debug) {
41
133
  console.log(`✅ Reusing compiled component from cache: ${key} (use count: ${cached.useCount})`);
42
134
  }
43
- return cached.component;
135
+ return cached.component(this.runtimeContext);
44
136
  }
45
137
  if (this.debug) {
46
138
  console.log(`🔄 Loading and compiling component: ${key}`);
@@ -82,9 +174,9 @@ class ComponentRegistryService {
82
174
  if (!compilationResult.component) {
83
175
  throw new Error(`Component compilation succeeded but no component returned`);
84
176
  }
85
- const compiledComponent = compilationResult.component.factory(this.runtimeContext);
177
+ const compiledComponentFactory = compilationResult.component.factory;
86
178
  this.compiledComponentCache.set(key, {
87
- component: compiledComponent,
179
+ component: compiledComponentFactory,
88
180
  metadata,
89
181
  compiledAt: new Date(),
90
182
  lastUsed: new Date(),
@@ -93,7 +185,102 @@ class ComponentRegistryService {
93
185
  if (referenceId) {
94
186
  this.addComponentReference(key, referenceId);
95
187
  }
96
- return compiledComponent;
188
+ return compiledComponentFactory(this.runtimeContext);
189
+ }
190
+ async getCompiledComponentFromRegistry(registryName, namespace, name, version, referenceId, contextUser) {
191
+ await this.initialize(contextUser);
192
+ if (this.debug) {
193
+ console.log(`🌐 [ComponentRegistryService] Fetching from external registry: ${registryName}/${namespace}/${name}@${version}`);
194
+ }
195
+ const registry = this.componentEngine.ComponentRegistries?.find(r => r.Name === registryName && r.Status === 'Active');
196
+ if (!registry) {
197
+ throw new Error(`Registry not found or inactive: ${registryName}`);
198
+ }
199
+ if (this.debug) {
200
+ console.log(`✅ [ComponentRegistryService] Found registry: ${registry.Name} (ID: ${registry.ID})`);
201
+ }
202
+ const graphQLClient = await this.getGraphQLClient();
203
+ if (!graphQLClient) {
204
+ throw new Error('GraphQL client not available for external registry fetching. No client provided and Metadata.Provider is not a GraphQLDataProvider.');
205
+ }
206
+ const key = `external:${registryName}:${namespace}:${name}:${version}`;
207
+ const cached = this.compiledComponentCache.get(key);
208
+ try {
209
+ const spec = await graphQLClient.GetRegistryComponent({
210
+ registryName: registry.Name,
211
+ namespace,
212
+ name,
213
+ version,
214
+ hash: cached?.specHash
215
+ });
216
+ if (!spec && cached?.specHash) {
217
+ if (this.debug) {
218
+ console.log(`♻️ [ComponentRegistryService] Component not modified, using cached: ${key}`);
219
+ }
220
+ cached.lastUsed = new Date();
221
+ cached.useCount++;
222
+ if (referenceId) {
223
+ this.addComponentReference(key, referenceId);
224
+ }
225
+ return cached.component(this.runtimeContext);
226
+ }
227
+ if (!spec) {
228
+ throw new Error(`Component not found in registry ${registryName}: ${namespace}/${name}@${version}`);
229
+ }
230
+ if (this.debug) {
231
+ console.log(`✅ [ComponentRegistryService] Fetched spec from external registry: ${spec.name}`);
232
+ }
233
+ const specHash = await this.calculateSpecHash(spec);
234
+ if (cached && cached.specHash === specHash) {
235
+ if (this.debug) {
236
+ console.log(`♻️ [ComponentRegistryService] Using cached compilation for: ${key} (hash match)`);
237
+ }
238
+ cached.lastUsed = new Date();
239
+ cached.useCount++;
240
+ if (referenceId) {
241
+ this.addComponentReference(key, referenceId);
242
+ }
243
+ return cached.component(this.runtimeContext);
244
+ }
245
+ if (cached && this.debug) {
246
+ console.log(`🔄 [ComponentRegistryService] Spec changed for: ${key}, recompiling (old hash: ${cached.specHash?.substring(0, 8)}..., new hash: ${specHash.substring(0, 8)}...)`);
247
+ }
248
+ const allLibraries = this.componentEngine.ComponentLibraries || [];
249
+ const compilationResult = await this.compiler.compile({
250
+ componentName: spec.name,
251
+ componentCode: spec.code || '',
252
+ allLibraries: allLibraries
253
+ });
254
+ if (!compilationResult.success || !compilationResult.component) {
255
+ throw new Error(`Failed to compile component: ${compilationResult.error?.message || 'Unknown error'}`);
256
+ }
257
+ this.compiledComponentCache.set(key, {
258
+ component: compilationResult.component.factory,
259
+ metadata: {
260
+ name: spec.name,
261
+ namespace: spec.namespace || '',
262
+ version: spec.version || '1.0.0',
263
+ description: spec.description || '',
264
+ type: spec.type,
265
+ isLocal: false
266
+ },
267
+ compiledAt: new Date(),
268
+ lastUsed: new Date(),
269
+ useCount: 1,
270
+ specHash: specHash
271
+ });
272
+ if (referenceId) {
273
+ this.addComponentReference(key, referenceId);
274
+ }
275
+ if (this.debug) {
276
+ console.log(`🎯 [ComponentRegistryService] Successfully compiled external component: ${spec.name}`);
277
+ }
278
+ return compilationResult.component.factory(this.runtimeContext);
279
+ }
280
+ catch (error) {
281
+ console.error(`❌ [ComponentRegistryService] Failed to fetch from external registry:`, error);
282
+ throw error;
283
+ }
97
284
  }
98
285
  async getComponentSpec(componentId, contextUser) {
99
286
  await this.initialize(contextUser);
@@ -117,10 +304,25 @@ class ComponentRegistryService {
117
304
  if (!registry) {
118
305
  throw new Error(`Registry not found: ${component.SourceRegistryID}`);
119
306
  }
120
- if (!registry) {
121
- throw new Error(`Registry not found: ${component.SourceRegistryID}`);
307
+ let spec;
308
+ if (this.graphQLClient) {
309
+ if (this.debug) {
310
+ console.log(`Fetching from registry via GraphQL: ${component.Name}`);
311
+ }
312
+ const result = await this.graphQLClient.GetRegistryComponent({
313
+ registryName: registry.Name,
314
+ namespace: component.Namespace || '',
315
+ name: component.Name,
316
+ version: component.Version
317
+ });
318
+ if (!result) {
319
+ throw new Error(`Component not found in registry: ${component.Name}`);
320
+ }
321
+ spec = result;
322
+ }
323
+ else {
324
+ spec = await this.fetchFromExternalRegistry(registry.URI || '', component.Name, component.Namespace || '', component.Version, this.getRegistryApiKey(registry.ID));
122
325
  }
123
- const spec = await this.fetchFromExternalRegistry(registry.URI || '', component.Name, component.Namespace || '', component.Version, this.getRegistryApiKey(registry.ID));
124
326
  await this.cacheExternalComponent(componentId, spec, contextUser);
125
327
  return spec;
126
328
  }