@memberjunction/react-runtime 2.98.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.
- package/.turbo/turbo-build.log +15 -20
- package/CHANGELOG.md +26 -0
- package/README.md +171 -1
- package/dist/compiler/component-compiler.d.ts.map +1 -1
- package/dist/compiler/component-compiler.js +59 -8
- package/dist/compiler/component-compiler.js.map +1 -1
- package/dist/component-manager/component-manager.d.ts +39 -0
- package/dist/component-manager/component-manager.d.ts.map +1 -0
- package/dist/component-manager/component-manager.js +474 -0
- package/dist/component-manager/component-manager.js.map +1 -0
- package/dist/component-manager/index.d.ts +3 -0
- package/dist/component-manager/index.d.ts.map +1 -0
- package/dist/component-manager/index.js +6 -0
- package/dist/component-manager/index.js.map +1 -0
- package/dist/component-manager/types.d.ts +62 -0
- package/dist/component-manager/types.d.ts.map +1 -0
- package/dist/component-manager/types.js +3 -0
- package/dist/component-manager/types.js.map +1 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- package/dist/registry/component-registry-service.d.ts +16 -1
- package/dist/registry/component-registry-service.d.ts.map +1 -1
- package/dist/registry/component-registry-service.js +212 -10
- package/dist/registry/component-registry-service.js.map +1 -1
- package/dist/registry/component-registry.d.ts +1 -1
- package/dist/registry/component-registry.d.ts.map +1 -1
- package/dist/registry/component-registry.js.map +1 -1
- package/dist/registry/component-resolver.d.ts.map +1 -1
- package/dist/registry/component-resolver.js +122 -52
- package/dist/registry/component-resolver.js.map +1 -1
- package/dist/registry/index.d.ts +1 -1
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/index.js.map +1 -1
- package/dist/runtime/component-hierarchy.d.ts +4 -0
- package/dist/runtime/component-hierarchy.d.ts.map +1 -1
- package/dist/runtime/component-hierarchy.js +127 -12
- package/dist/runtime/component-hierarchy.js.map +1 -1
- package/dist/runtime.umd.js +535 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/component-unwrapper.d.ts +7 -0
- package/dist/utilities/component-unwrapper.d.ts.map +1 -0
- package/dist/utilities/component-unwrapper.js +369 -0
- package/dist/utilities/component-unwrapper.js.map +1 -0
- package/dist/utilities/index.d.ts +1 -0
- package/dist/utilities/index.d.ts.map +1 -1
- package/dist/utilities/index.js +1 -0
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/library-loader.d.ts +3 -0
- package/dist/utilities/library-loader.d.ts.map +1 -1
- package/dist/utilities/library-loader.js +101 -17
- package/dist/utilities/library-loader.js.map +1 -1
- package/examples/component-registry-integration.ts +191 -0
- package/package.json +6 -5
- package/src/compiler/component-compiler.ts +101 -23
- package/src/component-manager/component-manager.ts +736 -0
- package/src/component-manager/index.ts +13 -0
- package/src/component-manager/types.ts +204 -0
- package/src/index.ts +37 -1
- package/src/registry/component-registry-service.ts +315 -18
- package/src/registry/component-registry.ts +1 -1
- package/src/registry/component-resolver.ts +159 -67
- package/src/registry/index.ts +1 -1
- package/src/runtime/component-hierarchy.ts +124 -13
- package/src/types/index.ts +2 -0
- package/src/utilities/component-unwrapper.ts +481 -0
- package/src/utilities/index.ts +2 -1
- package/src/utilities/library-loader.ts +155 -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';
|
|
@@ -18,6 +21,7 @@ export { LibraryRegistry, LibraryDefinition } from './utilities/library-registry
|
|
|
18
21
|
export { ComponentErrorAnalyzer, FailedComponentInfo } from './utilities/component-error-analyzer';
|
|
19
22
|
export { ResourceManager, resourceManager, ManagedResource } from './utilities/resource-manager';
|
|
20
23
|
export { CacheManager, CacheEntry, CacheOptions } from './utilities/cache-manager';
|
|
24
|
+
export { unwrapLibraryComponent, unwrapLibraryComponents, unwrapAllLibraryComponents, unwrapComponent, unwrapComponents, unwrapAllComponents } from './utilities/component-unwrapper';
|
|
21
25
|
export declare const VERSION = "2.69.1";
|
|
22
26
|
export declare const DEFAULT_CONFIGS: {
|
|
23
27
|
compiler: {
|
|
@@ -40,10 +44,12 @@ export declare const DEFAULT_CONFIGS: {
|
|
|
40
44
|
export declare function createReactRuntime(babelInstance: any, config?: {
|
|
41
45
|
compiler?: Partial<import('./types').CompilerConfig>;
|
|
42
46
|
registry?: Partial<import('./types').RegistryConfig>;
|
|
47
|
+
manager?: Partial<import('./component-manager').ComponentManagerConfig>;
|
|
43
48
|
}, runtimeContext?: import('./types').RuntimeContext, debug?: boolean): {
|
|
44
49
|
compiler: ComponentCompiler;
|
|
45
50
|
registry: ComponentRegistry;
|
|
46
51
|
resolver: ComponentResolver;
|
|
52
|
+
manager: ComponentManager;
|
|
47
53
|
version: string;
|
|
48
54
|
debug: boolean;
|
|
49
55
|
};
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[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C,OAAO,qBAAqB,EAAE,sBAAsB,CAAC,CAAC;CACzE,EACD,cAAc,CAAC,EAAE,OAAO,SAAS,EAAE,cAAc,EACjD,KAAK,GAAE,OAAe;;;;;;;EAwCvB"}
|
package/dist/index.js
CHANGED
|
@@ -14,10 +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.
|
|
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;
|
|
18
19
|
const compiler_1 = require("./compiler");
|
|
19
20
|
const registry_1 = require("./registry");
|
|
20
21
|
const registry_2 = require("./registry");
|
|
22
|
+
const component_manager_1 = require("./component-manager");
|
|
21
23
|
__exportStar(require("./types"), exports);
|
|
22
24
|
var compiler_2 = require("./compiler");
|
|
23
25
|
Object.defineProperty(exports, "ComponentCompiler", { enumerable: true, get: function () { return compiler_2.ComponentCompiler; } });
|
|
@@ -35,6 +37,8 @@ var registry_4 = require("./registry");
|
|
|
35
37
|
Object.defineProperty(exports, "ComponentResolver", { enumerable: true, get: function () { return registry_4.ComponentResolver; } });
|
|
36
38
|
Object.defineProperty(exports, "ComponentSpec", { enumerable: true, get: function () { return registry_4.ComponentSpec; } });
|
|
37
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; } });
|
|
38
42
|
var runtime_1 = require("./runtime");
|
|
39
43
|
Object.defineProperty(exports, "createErrorBoundary", { enumerable: true, get: function () { return runtime_1.createErrorBoundary; } });
|
|
40
44
|
Object.defineProperty(exports, "withErrorBoundary", { enumerable: true, get: function () { return runtime_1.withErrorBoundary; } });
|
|
@@ -78,6 +82,13 @@ Object.defineProperty(exports, "ResourceManager", { enumerable: true, get: funct
|
|
|
78
82
|
Object.defineProperty(exports, "resourceManager", { enumerable: true, get: function () { return resource_manager_1.resourceManager; } });
|
|
79
83
|
var cache_manager_1 = require("./utilities/cache-manager");
|
|
80
84
|
Object.defineProperty(exports, "CacheManager", { enumerable: true, get: function () { return cache_manager_1.CacheManager; } });
|
|
85
|
+
var component_unwrapper_1 = require("./utilities/component-unwrapper");
|
|
86
|
+
Object.defineProperty(exports, "unwrapLibraryComponent", { enumerable: true, get: function () { return component_unwrapper_1.unwrapLibraryComponent; } });
|
|
87
|
+
Object.defineProperty(exports, "unwrapLibraryComponents", { enumerable: true, get: function () { return component_unwrapper_1.unwrapLibraryComponents; } });
|
|
88
|
+
Object.defineProperty(exports, "unwrapAllLibraryComponents", { enumerable: true, get: function () { return component_unwrapper_1.unwrapAllLibraryComponents; } });
|
|
89
|
+
Object.defineProperty(exports, "unwrapComponent", { enumerable: true, get: function () { return component_unwrapper_1.unwrapComponent; } });
|
|
90
|
+
Object.defineProperty(exports, "unwrapComponents", { enumerable: true, get: function () { return component_unwrapper_1.unwrapComponents; } });
|
|
91
|
+
Object.defineProperty(exports, "unwrapAllComponents", { enumerable: true, get: function () { return component_unwrapper_1.unwrapAllComponents; } });
|
|
81
92
|
exports.VERSION = '2.69.1';
|
|
82
93
|
exports.DEFAULT_CONFIGS = {
|
|
83
94
|
compiler: {
|
|
@@ -106,14 +117,20 @@ function createReactRuntime(babelInstance, config, runtimeContext, debug = false
|
|
|
106
117
|
...config?.registry,
|
|
107
118
|
debug: config?.registry?.debug ?? debug
|
|
108
119
|
};
|
|
120
|
+
const managerConfig = {
|
|
121
|
+
...config?.manager,
|
|
122
|
+
debug: config?.manager?.debug ?? debug
|
|
123
|
+
};
|
|
109
124
|
const compiler = new compiler_1.ComponentCompiler(compilerConfig);
|
|
110
125
|
compiler.setBabelInstance(babelInstance);
|
|
111
126
|
const registry = new registry_1.ComponentRegistry(registryConfig);
|
|
112
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);
|
|
113
129
|
return {
|
|
114
130
|
compiler,
|
|
115
131
|
registry,
|
|
116
132
|
resolver,
|
|
133
|
+
manager,
|
|
117
134
|
version: exports.VERSION,
|
|
118
135
|
debug
|
|
119
136
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index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AAQ,EAAE,KAAK,IAAI,KAAK;KACxC,CAAC;IAEF,MAAM,aAAa,GAAG;QACpB,GAAG,MAAM,EAAE,OAAO;QAClB,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,IAAI,KAAK;KACvC,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;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;
|
|
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;AA+B1D,MAAM,WAAW,wBAAwB;IACvC,oBAAoB,CAAC,MAAM,EAAE;QAC3B,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;CACnC;AAKD,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;IAC/B,OAAO,CAAC,aAAa,CAAC,CAA2B;IAEjD,OAAO;IAeP,MAAM,CAAC,WAAW,CAChB,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,EAAE,cAAc,EACvB,KAAK,GAAE,OAAe,EACtB,aAAa,CAAC,EAAE,w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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,28 +1,120 @@
|
|
|
1
1
|
"use strict";
|
|
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
|
|
177
|
+
const compiledComponentFactory = compilationResult.component.factory;
|
|
86
178
|
this.compiledComponentCache.set(key, {
|
|
87
|
-
component:
|
|
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
|
|
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
|
-
|
|
121
|
-
|
|
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
|
}
|