@memberjunction/react-runtime 2.93.0 → 2.95.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 +6 -6
- package/CHANGELOG.md +28 -0
- package/README.md +180 -2
- package/dist/compiler/component-compiler.d.ts +1 -0
- package/dist/compiler/component-compiler.d.ts.map +1 -1
- package/dist/compiler/component-compiler.js +253 -61
- package/dist/compiler/component-compiler.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/dist/registry/component-registry-service.d.ts +6 -3
- package/dist/registry/component-registry-service.d.ts.map +1 -1
- package/dist/registry/component-registry-service.js +38 -11
- package/dist/registry/component-registry-service.js.map +1 -1
- package/dist/registry/component-registry.d.ts +6 -3
- package/dist/registry/component-registry.d.ts.map +1 -1
- package/dist/registry/component-registry.js +17 -0
- package/dist/registry/component-registry.js.map +1 -1
- package/dist/registry/component-resolver.d.ts +2 -1
- package/dist/registry/component-resolver.d.ts.map +1 -1
- package/dist/registry/component-resolver.js +101 -14
- package/dist/registry/component-resolver.js.map +1 -1
- package/dist/runtime/component-hierarchy.d.ts.map +1 -1
- package/dist/runtime/component-hierarchy.js +75 -13
- package/dist/runtime/component-hierarchy.js.map +1 -1
- package/dist/runtime/prop-builder.d.ts +2 -2
- package/dist/runtime/prop-builder.d.ts.map +1 -1
- package/dist/runtime/prop-builder.js +32 -14
- package/dist/runtime/prop-builder.js.map +1 -1
- package/dist/runtime.umd.js +1 -1
- package/dist/types/dependency-types.d.ts +62 -0
- package/dist/types/dependency-types.d.ts.map +1 -0
- package/dist/types/dependency-types.js +3 -0
- package/dist/types/dependency-types.js.map +1 -0
- package/dist/types/index.d.ts +8 -10
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- 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-dependency-resolver.d.ts +19 -0
- package/dist/utilities/library-dependency-resolver.d.ts.map +1 -0
- package/dist/utilities/library-dependency-resolver.js +419 -0
- package/dist/utilities/library-dependency-resolver.js.map +1 -0
- package/dist/utilities/library-loader.d.ts +9 -0
- package/dist/utilities/library-loader.d.ts.map +1 -1
- package/dist/utilities/library-loader.js +164 -0
- package/dist/utilities/library-loader.js.map +1 -1
- package/package.json +5 -5
- package/src/compiler/component-compiler.ts +280 -82
- package/src/index.ts +20 -5
- package/src/registry/component-registry-service.ts +53 -14
- package/src/registry/component-registry.ts +36 -7
- package/src/registry/component-resolver.ts +130 -16
- package/src/runtime/component-hierarchy.ts +101 -27
- package/src/runtime/prop-builder.ts +38 -18
- package/src/types/dependency-types.ts +110 -0
- package/src/types/index.ts +17 -21
- package/src/utilities/index.ts +1 -0
- package/src/utilities/library-dependency-resolver.ts +613 -0
- package/src/utilities/library-loader.ts +274 -0
|
@@ -4,77 +4,164 @@ exports.ComponentResolver = void 0;
|
|
|
4
4
|
const component_registry_service_1 = require("./component-registry-service");
|
|
5
5
|
const core_entities_1 = require("@memberjunction/core-entities");
|
|
6
6
|
class ComponentResolver {
|
|
7
|
-
constructor(registry, compiler, runtimeContext) {
|
|
7
|
+
constructor(registry, compiler, runtimeContext, debug = false) {
|
|
8
8
|
this.registryService = null;
|
|
9
9
|
this.compiler = null;
|
|
10
10
|
this.runtimeContext = null;
|
|
11
11
|
this.componentEngine = core_entities_1.ComponentMetadataEngine.Instance;
|
|
12
|
+
this.debug = false;
|
|
12
13
|
this.registry = registry;
|
|
13
14
|
this.resolverInstanceId = `resolver-${Date.now()}-${Math.random()}`;
|
|
15
|
+
this.debug = debug;
|
|
14
16
|
if (compiler && runtimeContext) {
|
|
15
17
|
this.compiler = compiler;
|
|
16
18
|
this.runtimeContext = runtimeContext;
|
|
17
|
-
this.registryService = component_registry_service_1.ComponentRegistryService.getInstance(compiler, runtimeContext);
|
|
19
|
+
this.registryService = component_registry_service_1.ComponentRegistryService.getInstance(compiler, runtimeContext, debug);
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
async resolveComponents(spec, namespace = 'Global', contextUser) {
|
|
23
|
+
console.log(`🚀 [ComponentResolver] Starting component resolution for: ${spec.name}`);
|
|
24
|
+
console.log(`📋 [ComponentResolver] Dependencies to resolve:`, (spec.dependencies || []).map(d => ({
|
|
25
|
+
name: d.name,
|
|
26
|
+
location: d.location,
|
|
27
|
+
namespace: d.namespace
|
|
28
|
+
})));
|
|
21
29
|
const resolved = {};
|
|
22
30
|
if (this.registryService) {
|
|
31
|
+
console.log(`🔄 [ComponentResolver] Initializing component engine...`);
|
|
23
32
|
await this.componentEngine.Config(false, contextUser);
|
|
33
|
+
console.log(`✅ [ComponentResolver] Component engine initialized with ${this.componentEngine.Components?.length || 0} components`);
|
|
24
34
|
}
|
|
25
35
|
await this.resolveComponentHierarchy(spec, resolved, namespace, new Set(), contextUser);
|
|
26
|
-
|
|
36
|
+
console.log(`📊 [ComponentResolver] Resolved components before unwrapping:`, Object.keys(resolved));
|
|
37
|
+
const unwrapped = {};
|
|
38
|
+
for (const [name, value] of Object.entries(resolved)) {
|
|
39
|
+
if (value && typeof value === 'object' && 'component' in value) {
|
|
40
|
+
if (typeof value.component === 'function') {
|
|
41
|
+
unwrapped[name] = value.component;
|
|
42
|
+
console.log(`✅ [ComponentResolver] Unwrapped component: ${name} (was object with .component)`);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
console.error(`❌ [ComponentResolver] Component ${name} has invalid component property:`, typeof value.component, value);
|
|
46
|
+
unwrapped[name] = value;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else if (typeof value === 'function') {
|
|
50
|
+
unwrapped[name] = value;
|
|
51
|
+
console.log(`✅ [ComponentResolver] Component already a function: ${name}`);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
console.warn(`⚠️ [ComponentResolver] Component ${name} is not a function or wrapped component:`, typeof value, value);
|
|
55
|
+
unwrapped[name] = value;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
console.log(`🎯 [ComponentResolver] Final resolved components:`, Object.keys(unwrapped).map(name => ({
|
|
59
|
+
name,
|
|
60
|
+
type: typeof unwrapped[name],
|
|
61
|
+
isUndefined: unwrapped[name] === undefined
|
|
62
|
+
})));
|
|
63
|
+
return unwrapped;
|
|
27
64
|
}
|
|
28
65
|
async resolveComponentHierarchy(spec, resolved, namespace, visited = new Set(), contextUser) {
|
|
29
66
|
const componentId = `${spec.namespace || namespace}/${spec.name}@${spec.version || 'latest'}`;
|
|
67
|
+
if (resolved[spec.name]) {
|
|
68
|
+
console.log(`⏭️ [ComponentResolver] Component already resolved: ${spec.name}`);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
30
71
|
if (visited.has(componentId)) {
|
|
31
|
-
|
|
72
|
+
if (this.debug) {
|
|
73
|
+
console.warn(`Circular dependency detected for component: ${componentId}`);
|
|
74
|
+
}
|
|
32
75
|
return;
|
|
33
76
|
}
|
|
34
77
|
visited.add(componentId);
|
|
78
|
+
console.log(`🔄 [ComponentResolver] Resolving dependencies for ${spec.name} BEFORE resolving itself`);
|
|
79
|
+
const children = spec.dependencies || [];
|
|
80
|
+
for (const child of children) {
|
|
81
|
+
console.log(` ↳ [ComponentResolver] Resolving dependency: ${child.name} for parent ${spec.name}`);
|
|
82
|
+
await this.resolveComponentHierarchy(child, resolved, namespace, visited, contextUser);
|
|
83
|
+
}
|
|
84
|
+
if (children.length > 0) {
|
|
85
|
+
console.log(`✅ [ComponentResolver] All ${children.length} dependencies resolved for ${spec.name}, now resolving itself`);
|
|
86
|
+
}
|
|
35
87
|
if (spec.location === 'registry' && this.registryService) {
|
|
88
|
+
console.log(`🔍 [ComponentResolver] Looking for registry component: ${spec.name} in namespace: ${spec.namespace || namespace}`);
|
|
36
89
|
try {
|
|
90
|
+
const allComponents = this.componentEngine.Components || [];
|
|
91
|
+
console.log(`📊 [ComponentResolver] Total components in engine: ${allComponents.length}`);
|
|
92
|
+
const matchingNames = allComponents.filter((c) => c.Name === spec.name);
|
|
93
|
+
if (matchingNames.length > 0) {
|
|
94
|
+
console.log(`🔎 [ComponentResolver] Found ${matchingNames.length} components with name "${spec.name}":`, matchingNames.map((c) => ({
|
|
95
|
+
ID: c.ID,
|
|
96
|
+
Name: c.Name,
|
|
97
|
+
Namespace: c.Namespace,
|
|
98
|
+
Version: c.Version,
|
|
99
|
+
Status: c.Status
|
|
100
|
+
})));
|
|
101
|
+
}
|
|
37
102
|
const component = this.componentEngine.Components?.find((c) => c.Name === spec.name &&
|
|
38
103
|
c.Namespace === (spec.namespace || namespace));
|
|
39
104
|
if (component) {
|
|
105
|
+
console.log(`✅ [ComponentResolver] Found component in DB:`, {
|
|
106
|
+
ID: component.ID,
|
|
107
|
+
Name: component.Name,
|
|
108
|
+
Namespace: component.Namespace,
|
|
109
|
+
Version: component.Version
|
|
110
|
+
});
|
|
40
111
|
const compiledComponent = await this.registryService.getCompiledComponent(component.ID, this.resolverInstanceId, contextUser);
|
|
41
112
|
resolved[spec.name] = compiledComponent;
|
|
42
|
-
console.log(`📦
|
|
113
|
+
console.log(`📦 [ComponentResolver] Successfully compiled and resolved: ${spec.name}, type: ${typeof compiledComponent}`);
|
|
114
|
+
if (this.debug) {
|
|
115
|
+
console.log(`📦 Resolved registry component: ${spec.name} from ${componentId}`);
|
|
116
|
+
}
|
|
43
117
|
}
|
|
44
118
|
else {
|
|
45
|
-
console.
|
|
119
|
+
console.error(`❌❌❌❌❌ [ComponentResolver] Registry component NOT found in database: ${spec.name} with namespace: ${spec.namespace || namespace} ❌❌❌❌`);
|
|
120
|
+
if (this.debug) {
|
|
121
|
+
console.warn(`Registry component not found in database: ${spec.name}`);
|
|
122
|
+
}
|
|
46
123
|
}
|
|
47
124
|
}
|
|
48
125
|
catch (error) {
|
|
49
|
-
|
|
126
|
+
if (this.debug) {
|
|
127
|
+
console.error(`Failed to load registry component ${spec.name}:`, error);
|
|
128
|
+
}
|
|
50
129
|
}
|
|
51
130
|
}
|
|
52
131
|
else {
|
|
53
132
|
const componentNamespace = spec.namespace || namespace;
|
|
133
|
+
console.log(`🔍 [ComponentResolver] Looking for embedded component: ${spec.name} in namespace: ${componentNamespace}`);
|
|
54
134
|
const component = this.registry.get(spec.name, componentNamespace);
|
|
55
135
|
if (component) {
|
|
56
136
|
resolved[spec.name] = component;
|
|
57
|
-
console.log(
|
|
137
|
+
console.log(`✅ [ComponentResolver] Found embedded component: ${spec.name}, type: ${typeof component}`);
|
|
138
|
+
if (this.debug) {
|
|
139
|
+
console.log(`📄 Resolved embedded component: ${spec.name} from namespace ${componentNamespace}, type:`, typeof component);
|
|
140
|
+
}
|
|
58
141
|
}
|
|
59
142
|
else {
|
|
143
|
+
console.log(`⚠️ [ComponentResolver] Not found in namespace ${componentNamespace}, trying fallback namespace: ${namespace}`);
|
|
60
144
|
const fallbackComponent = this.registry.get(spec.name, namespace);
|
|
61
145
|
if (fallbackComponent) {
|
|
62
146
|
resolved[spec.name] = fallbackComponent;
|
|
63
|
-
console.log(
|
|
147
|
+
console.log(`✅ [ComponentResolver] Found embedded component in fallback namespace: ${spec.name}, type: ${typeof fallbackComponent}`);
|
|
148
|
+
if (this.debug) {
|
|
149
|
+
console.log(`📄 Resolved embedded component: ${spec.name} from fallback namespace ${namespace}, type:`, typeof fallbackComponent);
|
|
150
|
+
}
|
|
64
151
|
}
|
|
65
152
|
else {
|
|
153
|
+
console.error(`❌ [ComponentResolver] Could not resolve embedded component: ${spec.name} in namespace ${componentNamespace} or ${namespace}`);
|
|
66
154
|
console.warn(`⚠️ Could not resolve embedded component: ${spec.name} in namespace ${componentNamespace} or ${namespace}`);
|
|
155
|
+
resolved[spec.name] = undefined;
|
|
67
156
|
}
|
|
68
157
|
}
|
|
69
158
|
}
|
|
70
|
-
const children = spec.dependencies || [];
|
|
71
|
-
for (const child of children) {
|
|
72
|
-
await this.resolveComponentHierarchy(child, resolved, namespace, visited, contextUser);
|
|
73
|
-
}
|
|
74
159
|
}
|
|
75
160
|
cleanup() {
|
|
76
161
|
if (this.registryService) {
|
|
77
|
-
|
|
162
|
+
if (this.debug) {
|
|
163
|
+
console.log(`Cleaning up resolver: ${this.resolverInstanceId}`);
|
|
164
|
+
}
|
|
78
165
|
}
|
|
79
166
|
}
|
|
80
167
|
validateDependencies(spec, namespace = 'Global') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-resolver.js","sourceRoot":"","sources":["../../src/registry/component-resolver.ts"],"names":[],"mappings":";;;AAOA,6EAAwE;AAKxE,iEAAwE;AAaxE,MAAa,iBAAiB;IAc5B,YACE,QAA2B,EAC3B,QAA4B,EAC5B,cAA+B;QAfzB,oBAAe,GAAoC,IAAI,CAAC;QAExD,aAAQ,GAA6B,IAAI,CAAC;QAC1C,mBAAc,GAA0B,IAAI,CAAC;QAC7C,oBAAe,GAAG,uCAAuB,CAAC,QAAQ,CAAC;QAazD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,kBAAkB,GAAG,YAAY,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;QAEpE,IAAI,QAAQ,IAAI,cAAc,EAAE,CAAC;YAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;YACzB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;YACrC,IAAI,CAAC,eAAe,GAAG,qDAAwB,CAAC,WAAW,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;QACxF,CAAC;IACH,CAAC;IASD,KAAK,CAAC,iBAAiB,CACrB,IAAmB,EACnB,YAAoB,QAAQ,EAC5B,WAAsB;QAEtB,MAAM,QAAQ,GAAuB,EAAE,CAAC;QAGxC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACzB,MAAM,IAAI,CAAC,eAAe,CAA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AmB,EACnB,SAA0B,EAC1B,OAAoB;QAEpB,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,OAAO;QACnC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEvB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAErB,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC;QACzC,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC7B,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;CACF;AAzUD,8CAyUC","sourcesContent":["/**\n * @fileoverview Component dependency resolver for managing component relationships.\n * Handles resolution of child components and dependency graphs.\n * @module @memberjunction/react-runtime/registry\n */\n\nimport { ComponentRegistry } from './component-registry';\nimport { ComponentRegistryService } from './component-registry-service';\nimport { ComponentSpec } from '@memberjunction/interactive-component-types';\nimport { ComponentCompiler } from '../compiler';\nimport { RuntimeContext } from '../types';\nimport { UserInfo } from '@memberjunction/core';\nimport { ComponentMetadataEngine } from '@memberjunction/core-entities';\n\n/**\n * Resolved component map for passing to React components\n */\nexport interface ResolvedComponents {\n [componentName: string]: any;\n}\n\n/**\n * Component dependency resolver.\n * Resolves component hierarchies and manages dependencies between components.\n */\nexport class ComponentResolver {\n private registry: ComponentRegistry;\n private registryService: ComponentRegistryService | null = null;\n private resolverInstanceId: string;\n private compiler: ComponentCompiler | null = null;\n private runtimeContext: RuntimeContext | null = null;\n private componentEngine = ComponentMetadataEngine.Instance;\n\n /**\n * Creates a new ComponentResolver instance\n * @param registry - Component registry to use for resolution\n * @param compiler - Optional compiler for registry-based components\n * @param runtimeContext - Optional runtime context for registry-based components\n */\n constructor(\n registry: ComponentRegistry,\n compiler?: ComponentCompiler,\n runtimeContext?: RuntimeContext\n ) {\n this.registry = registry;\n this.resolverInstanceId = `resolver-${Date.now()}-${Math.random()}`;\n \n if (compiler && runtimeContext) {\n this.compiler = compiler;\n this.runtimeContext = runtimeContext;\n this.registryService = ComponentRegistryService.getInstance(compiler, runtimeContext);\n }\n }\n\n /**\n * Resolves all components for a given component specification\n * @param spec - Root component specification\n * @param namespace - Namespace for component resolution\n * @param contextUser - Optional user context for database operations\n * @returns Map of component names to resolved components\n */\n async resolveComponents(\n spec: ComponentSpec, \n namespace: string = 'Global',\n contextUser?: UserInfo\n ): Promise<ResolvedComponents> {\n const resolved: ResolvedComponents = {};\n \n // Initialize component engine if we have registry service\n if (this.registryService) {\n await this.componentEngine.Config(false, contextUser);\n }\n \n // Resolve the component hierarchy\n await this.resolveComponentHierarchy(spec, resolved, namespace, new Set(), contextUser);\n \n return resolved;\n }\n\n /**\n * Recursively resolves a component hierarchy\n * @param spec - Component specification\n * @param resolved - Map to store resolved components\n * @param namespace - Namespace for resolution\n * @param visited - Set of visited component names to prevent cycles\n * @param contextUser - Optional user context for database operations\n */\n private async resolveComponentHierarchy(\n spec: ComponentSpec,\n resolved: ResolvedComponents,\n namespace: string,\n visited: Set<string> = new Set(),\n contextUser?: UserInfo\n ): Promise<void> {\n // Create a unique identifier for this component\n const componentId = `${spec.namespace || namespace}/${spec.name}@${spec.version || 'latest'}`;\n \n // Prevent circular dependencies\n if (visited.has(componentId)) {\n console.warn(`Circular dependency detected for component: ${componentId}`);\n return;\n }\n visited.add(componentId);\n\n // Handle based on location\n if (spec.location === 'registry' && this.registryService) {\n // Registry component - need to load from database or external source\n try {\n // First, try to find the component in the metadata engine\n const component = this.componentEngine.Components?.find(\n (c: any) => c.Name === spec.name && \n c.Namespace === (spec.namespace || namespace)\n );\n \n if (component) {\n // Get compiled component from registry service\n const compiledComponent = await this.registryService.getCompiledComponent(\n component.ID,\n this.resolverInstanceId,\n contextUser\n );\n resolved[spec.name] = compiledComponent;\n console.log(`📦 Resolved registry component: ${spec.name} from ${componentId}`);\n } else {\n console.warn(`Registry component not found in database: ${spec.name}`);\n }\n } catch (error) {\n console.error(`Failed to load registry component ${spec.name}:`, error);\n }\n } else {\n // Embedded component - get from local registry\n // Use the component's specified namespace if it has one, otherwise use parent's namespace\n const componentNamespace = spec.namespace || namespace;\n const component = this.registry.get(spec.name, componentNamespace);\n if (component) {\n resolved[spec.name] = component;\n console.log(`📄 Resolved embedded component: ${spec.name} from namespace ${componentNamespace}`);\n } else {\n // If not found with specified namespace, try the parent namespace as fallback\n const fallbackComponent = this.registry.get(spec.name, namespace);\n if (fallbackComponent) {\n resolved[spec.name] = fallbackComponent;\n console.log(`📄 Resolved embedded component: ${spec.name} from fallback namespace ${namespace}`);\n } else {\n console.warn(`⚠️ Could not resolve embedded component: ${spec.name} in namespace ${componentNamespace} or ${namespace}`);\n }\n }\n }\n\n // Process child components recursively\n const children = spec.dependencies || [];\n for (const child of children) {\n await this.resolveComponentHierarchy(child, resolved, namespace, visited, contextUser);\n }\n }\n\n /**\n * Cleanup resolver resources\n */\n cleanup(): void {\n // Remove our references when resolver is destroyed\n if (this.registryService) {\n // This would allow the registry service to clean up unused components\n // Implementation would track which components this resolver referenced\n console.log(`Cleaning up resolver: ${this.resolverInstanceId}`);\n }\n }\n\n /**\n * Validates that all required components are available\n * @param spec - Component specification to validate\n * @param namespace - Namespace for validation\n * @returns Array of missing component names\n */\n validateDependencies(spec: ComponentSpec, namespace: string = 'Global'): string[] {\n const missing: string[] = [];\n const checked = new Set<string>();\n \n this.checkDependencies(spec, namespace, missing, checked);\n \n return missing;\n }\n\n /**\n * Recursively checks for missing dependencies\n * @param spec - Component specification\n * @param namespace - Namespace for checking\n * @param missing - Array to collect missing components\n * @param checked - Set of already checked components\n */\n private checkDependencies(\n spec: ComponentSpec,\n namespace: string,\n missing: string[],\n checked: Set<string>\n ): void {\n if (checked.has(spec.name)) return;\n checked.add(spec.name);\n\n // Check if component exists in registry\n if (!this.registry.has(spec.name, namespace)) {\n missing.push(spec.name);\n }\n\n // Check children\n const children = spec.dependencies || [];\n for (const child of children) {\n this.checkDependencies(child, namespace, missing, checked);\n }\n }\n\n /**\n * Gets the dependency graph for a component specification\n * @param spec - Component specification\n * @returns Dependency graph as adjacency list\n */\n getDependencyGraph(spec: ComponentSpec): Map<string, string[]> {\n const graph = new Map<string, string[]>();\n const visited = new Set<string>();\n \n this.buildDependencyGraph(spec, graph, visited);\n \n return graph;\n }\n\n /**\n * Recursively builds the dependency graph\n * @param spec - Component specification\n * @param graph - Graph to build\n * @param visited - Set of visited components\n */\n private buildDependencyGraph(\n spec: ComponentSpec,\n graph: Map<string, string[]>,\n visited: Set<string>\n ): void {\n if (visited.has(spec.name)) return;\n visited.add(spec.name);\n\n const children = spec.dependencies || [];\n const dependencies = children.map(child => child.name);\n \n graph.set(spec.name, dependencies);\n\n // Recursively process children\n for (const child of children) {\n this.buildDependencyGraph(child, graph, visited);\n }\n }\n\n /**\n * Performs topological sort on component dependencies\n * @param spec - Root component specification\n * @returns Array of component names in dependency order\n */\n getLoadOrder(spec: ComponentSpec): string[] {\n const graph = this.getDependencyGraph(spec);\n const visited = new Set<string>();\n const stack: string[] = [];\n\n // Perform DFS on all nodes\n for (const node of graph.keys()) {\n if (!visited.has(node)) {\n this.topologicalSortDFS(node, graph, visited, stack);\n }\n }\n\n // Reverse to get correct load order\n return stack.reverse();\n }\n\n /**\n * DFS helper for topological sort\n * @param node - Current node\n * @param graph - Dependency graph\n * @param visited - Set of visited nodes\n * @param stack - Result stack\n */\n private topologicalSortDFS(\n node: string,\n graph: Map<string, string[]>,\n visited: Set<string>,\n stack: string[]\n ): void {\n visited.add(node);\n\n const dependencies = graph.get(node) || [];\n for (const dep of dependencies) {\n if (!visited.has(dep)) {\n this.topologicalSortDFS(dep, graph, visited, stack);\n }\n }\n\n stack.push(node);\n }\n\n /**\n * Resolves components in the correct dependency order\n * @param spec - Root component specification\n * @param namespace - Namespace for resolution\n * @returns Ordered array of resolved components\n */\n resolveInOrder(spec: ComponentSpec, namespace: string = 'Global'): Array<{\n name: string;\n component: any;\n }> {\n const loadOrder = this.getLoadOrder(spec);\n const resolved: Array<{ name: string; component: any }> = [];\n\n for (const name of loadOrder) {\n const component = this.registry.get(name, namespace);\n if (component) {\n resolved.push({ name, component });\n }\n }\n\n return resolved;\n }\n\n /**\n * Creates a flattened list of all component specifications\n * @param spec - Root component specification\n * @returns Array of all component specs in the hierarchy\n */\n flattenComponentSpecs(spec: ComponentSpec): ComponentSpec[] {\n const flattened: ComponentSpec[] = [];\n const visited = new Set<string>();\n\n this.collectComponentSpecs(spec, flattened, visited);\n\n return flattened;\n }\n\n /**\n * Recursively collects component specifications\n * @param spec - Current component specification\n * @param collected - Array to collect specs\n * @param visited - Set of visited component names\n */\n private collectComponentSpecs(\n spec: ComponentSpec,\n collected: ComponentSpec[],\n visited: Set<string>\n ): void {\n if (visited.has(spec.name)) return;\n visited.add(spec.name);\n\n collected.push(spec);\n\n const children = spec.dependencies || [];\n for (const child of children) {\n this.collectComponentSpecs(child, collected, visited);\n }\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"component-resolver.js","sourceRoot":"","sources":["../../src/registry/component-resolver.ts"],"names":[],"mappings":";;;AAOA,6EAAwE;AAKxE,iEAAwE;AAaxE,MAAa,iBAAiB;IAgB5B,YACE,QAA2B,EAC3B,QAA4B,EAC5B,cAA+B,EAC/B,QAAiB,KAAK;QAlBhB,oBAAe,GAAoC,IAAI,CAAC;QAExD,aAAQ,GAA6B,IAAI,CAAC;QAC1C,mBAAc,GAA0B,IAAI,CAAC;QAC7C,oBAAe,GAAG,uCAAuB,CAAC,QAAQ,CAAC;QACnD,UAAK,GAAY,KAAK,CAAC;QAe7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,kBAAkB,GAAG,YAAY,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;QACpE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAEnB,IAAI,QAAQ,IAAI,cAAc,EAAE,CAAC;YA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C,CAAC;QAErD,OAAO,SAAS,CAAC;IACnB,CAAC;IAQO,qBAAqB,CAC3B,IAAmB,EACnB,SAA0B,EAC1B,OAAoB;QAEpB,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,OAAO;QACnC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEvB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAErB,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC;QACzC,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC7B,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;CACF;AA3bD,8CA2bC","sourcesContent":["/**\n * @fileoverview Component dependency resolver for managing component relationships.\n * Handles resolution of child components and dependency graphs.\n * @module @memberjunction/react-runtime/registry\n */\n\nimport { ComponentRegistry } from './component-registry';\nimport { ComponentRegistryService } from './component-registry-service';\nimport { ComponentSpec } from '@memberjunction/interactive-component-types';\nimport { ComponentCompiler } from '../compiler';\nimport { RuntimeContext } from '../types';\nimport { UserInfo } from '@memberjunction/core';\nimport { ComponentMetadataEngine } from '@memberjunction/core-entities';\n\n/**\n * Resolved component map for passing to React components\n */\nexport interface ResolvedComponents {\n [componentName: string]: any;\n}\n\n/**\n * Component dependency resolver.\n * Resolves component hierarchies and manages dependencies between components.\n */\nexport class ComponentResolver {\n private registry: ComponentRegistry;\n private registryService: ComponentRegistryService | null = null;\n private resolverInstanceId: string;\n private compiler: ComponentCompiler | null = null;\n private runtimeContext: RuntimeContext | null = null;\n private componentEngine = ComponentMetadataEngine.Instance;\n private debug: boolean = false;\n\n /**\n * Creates a new ComponentResolver instance\n * @param registry - Component registry to use for resolution\n * @param compiler - Optional compiler for registry-based components\n * @param runtimeContext - Optional runtime context for registry-based components\n * @param debug - Enable debug logging (defaults to false)\n */\n constructor(\n registry: ComponentRegistry,\n compiler?: ComponentCompiler,\n runtimeContext?: RuntimeContext,\n debug: boolean = false\n ) {\n this.registry = registry;\n this.resolverInstanceId = `resolver-${Date.now()}-${Math.random()}`;\n this.debug = debug;\n \n if (compiler && runtimeContext) {\n this.compiler = compiler;\n this.runtimeContext = runtimeContext;\n this.registryService = ComponentRegistryService.getInstance(compiler, runtimeContext, debug);\n }\n }\n\n /**\n * Resolves all components for a given component specification\n * @param spec - Root component specification\n * @param namespace - Namespace for component resolution\n * @param contextUser - Optional user context for database operations\n * @returns Map of component names to resolved components\n */\n async resolveComponents(\n spec: ComponentSpec, \n namespace: string = 'Global',\n contextUser?: UserInfo\n ): Promise<ResolvedComponents> {\n console.log(`🚀 [ComponentResolver] Starting component resolution for: ${spec.name}`);\n console.log(`📋 [ComponentResolver] Dependencies to resolve:`, (spec.dependencies || []).map(d => ({\n name: d.name,\n location: d.location,\n namespace: d.namespace\n })));\n \n const resolved: ResolvedComponents = {};\n \n // Initialize component engine if we have registry service\n if (this.registryService) {\n console.log(`🔄 [ComponentResolver] Initializing component engine...`);\n await this.componentEngine.Config(false, contextUser);\n console.log(`✅ [ComponentResolver] Component engine initialized with ${this.componentEngine.Components?.length || 0} components`);\n }\n \n // Resolve the component hierarchy\n await this.resolveComponentHierarchy(spec, resolved, namespace, new Set(), contextUser);\n \n console.log(`📊 [ComponentResolver] Resolved components before unwrapping:`, Object.keys(resolved));\n \n // Unwrap component wrappers before returning\n // Components from the registry come as objects with component/print/refresh properties\n // We need to extract just the component function for use in child components\n const unwrapped: ResolvedComponents = {};\n for (const [name, value] of Object.entries(resolved)) {\n if (value && typeof value === 'object' && 'component' in value) {\n if (typeof value.component === 'function') {\n // This is a wrapped component - extract the actual React component function\n unwrapped[name] = value.component;\n console.log(`✅ [ComponentResolver] Unwrapped component: ${name} (was object with .component)`);\n } else {\n // ComponentObject has a component property but it's not a function\n console.error(`❌ [ComponentResolver] Component ${name} has invalid component property:`, typeof value.component, value);\n unwrapped[name] = value; // Pass through the problematic value so we can see the error\n }\n } else if (typeof value === 'function') {\n // Already a function - use as is\n unwrapped[name] = value;\n console.log(`✅ [ComponentResolver] Component already a function: ${name}`);\n } else {\n // Something else - could be undefined or an error\n console.warn(`⚠️ [ComponentResolver] Component ${name} is not a function or wrapped component:`, typeof value, value);\n unwrapped[name] = value; // Pass through for debugging\n }\n }\n \n console.log(`🎯 [ComponentResolver] Final resolved components:`, Object.keys(unwrapped).map(name => ({\n name,\n type: typeof unwrapped[name],\n isUndefined: unwrapped[name] === undefined\n })));\n \n return unwrapped;\n }\n\n /**\n * Recursively resolves a component hierarchy\n * @param spec - Component specification\n * @param resolved - Map to store resolved components\n * @param namespace - Namespace for resolution\n * @param visited - Set of visited component names to prevent cycles\n * @param contextUser - Optional user context for database operations\n */\n private async resolveComponentHierarchy(\n spec: ComponentSpec,\n resolved: ResolvedComponents,\n namespace: string,\n visited: Set<string> = new Set(),\n contextUser?: UserInfo\n ): Promise<void> {\n // Create a unique identifier for this component\n const componentId = `${spec.namespace || namespace}/${spec.name}@${spec.version || 'latest'}`;\n \n // Check if already resolved (not just visited)\n if (resolved[spec.name]) {\n console.log(`⏭️ [ComponentResolver] Component already resolved: ${spec.name}`);\n return;\n }\n \n // Prevent circular dependencies\n if (visited.has(componentId)) {\n if (this.debug) {\n console.warn(`Circular dependency detected for component: ${componentId}`);\n }\n return;\n }\n visited.add(componentId);\n\n // *** CRITICAL: Process child components FIRST (depth-first, post-order) ***\n console.log(`🔄 [ComponentResolver] Resolving dependencies for ${spec.name} BEFORE resolving itself`);\n const children = spec.dependencies || [];\n for (const child of children) {\n console.log(` ↳ [ComponentResolver] Resolving dependency: ${child.name} for parent ${spec.name}`);\n await this.resolveComponentHierarchy(child, resolved, namespace, visited, contextUser);\n }\n if (children.length > 0) {\n console.log(`✅ [ComponentResolver] All ${children.length} dependencies resolved for ${spec.name}, now resolving itself`);\n }\n\n // NOW resolve the current component (it can access its dependencies)\n // Handle based on location\n if (spec.location === 'registry' && this.registryService) {\n // Registry component - need to load from database or external source\n console.log(`🔍 [ComponentResolver] Looking for registry component: ${spec.name} in namespace: ${spec.namespace || namespace}`);\n \n try {\n // First, try to find the component in the metadata engine\n const allComponents = this.componentEngine.Components || [];\n console.log(`📊 [ComponentResolver] Total components in engine: ${allComponents.length}`);\n \n // Log all matching names to see duplicates\n const matchingNames = allComponents.filter((c: any) => c.Name === spec.name);\n if (matchingNames.length > 0) {\n console.log(`🔎 [ComponentResolver] Found ${matchingNames.length} components with name \"${spec.name}\":`, \n matchingNames.map((c: any) => ({\n ID: c.ID,\n Name: c.Name,\n Namespace: c.Namespace,\n Version: c.Version,\n Status: c.Status\n }))\n );\n }\n \n const component = this.componentEngine.Components?.find(\n (c: any) => c.Name === spec.name && \n c.Namespace === (spec.namespace || namespace)\n );\n \n if (component) {\n console.log(`✅ [ComponentResolver] Found component in DB:`, {\n ID: component.ID,\n Name: component.Name,\n Namespace: component.Namespace,\n Version: component.Version\n });\n \n // Get compiled component from registry service\n const compiledComponent = await this.registryService.getCompiledComponent(\n component.ID,\n this.resolverInstanceId,\n contextUser\n );\n resolved[spec.name] = compiledComponent;\n console.log(`📦 [ComponentResolver] Successfully compiled and resolved: ${spec.name}, type: ${typeof compiledComponent}`);\n \n if (this.debug) {\n console.log(`📦 Resolved registry component: ${spec.name} from ${componentId}`);\n }\n } else {\n console.error(`❌❌❌❌❌ [ComponentResolver] Registry component NOT found in database: ${spec.name} with namespace: ${spec.namespace || namespace} ❌❌❌❌`);\n if (this.debug) {\n console.warn(`Registry component not found in database: ${spec.name}`);\n }\n }\n } catch (error) {\n if (this.debug) {\n console.error(`Failed to load registry component ${spec.name}:`, error);\n }\n }\n } else {\n // Embedded component - get from local registry\n // Use the component's specified namespace if it has one, otherwise use parent's namespace\n const componentNamespace = spec.namespace || namespace;\n console.log(`🔍 [ComponentResolver] Looking for embedded component: ${spec.name} in namespace: ${componentNamespace}`);\n \n const component = this.registry.get(spec.name, componentNamespace);\n if (component) {\n resolved[spec.name] = component;\n console.log(`✅ [ComponentResolver] Found embedded component: ${spec.name}, type: ${typeof component}`);\n if (this.debug) {\n console.log(`📄 Resolved embedded component: ${spec.name} from namespace ${componentNamespace}, type:`, typeof component);\n }\n } else {\n // If not found with specified namespace, try the parent namespace as fallback\n console.log(`⚠️ [ComponentResolver] Not found in namespace ${componentNamespace}, trying fallback namespace: ${namespace}`);\n const fallbackComponent = this.registry.get(spec.name, namespace);\n if (fallbackComponent) {\n resolved[spec.name] = fallbackComponent;\n console.log(`✅ [ComponentResolver] Found embedded component in fallback namespace: ${spec.name}, type: ${typeof fallbackComponent}`);\n if (this.debug) {\n console.log(`📄 Resolved embedded component: ${spec.name} from fallback namespace ${namespace}, type:`, typeof fallbackComponent);\n }\n } else {\n // Component not found - this might cause issues later\n console.error(`❌ [ComponentResolver] Could not resolve embedded component: ${spec.name} in namespace ${componentNamespace} or ${namespace}`);\n console.warn(`⚠️ Could not resolve embedded component: ${spec.name} in namespace ${componentNamespace} or ${namespace}`);\n // Store undefined explicitly so we know it failed to resolve\n resolved[spec.name] = undefined;\n }\n }\n }\n \n // Child components have already been processed at the beginning of this method\n // No need to process them again - we're using depth-first, post-order traversal\n }\n\n /**\n * Cleanup resolver resources\n */\n cleanup(): void {\n // Remove our references when resolver is destroyed\n if (this.registryService) {\n // This would allow the registry service to clean up unused components\n // Implementation would track which components this resolver referenced\n if (this.debug) {\n console.log(`Cleaning up resolver: ${this.resolverInstanceId}`);\n }\n }\n }\n\n /**\n * Validates that all required components are available\n * @param spec - Component specification to validate\n * @param namespace - Namespace for validation\n * @returns Array of missing component names\n */\n validateDependencies(spec: ComponentSpec, namespace: string = 'Global'): string[] {\n const missing: string[] = [];\n const checked = new Set<string>();\n \n this.checkDependencies(spec, namespace, missing, checked);\n \n return missing;\n }\n\n /**\n * Recursively checks for missing dependencies\n * @param spec - Component specification\n * @param namespace - Namespace for checking\n * @param missing - Array to collect missing components\n * @param checked - Set of already checked components\n */\n private checkDependencies(\n spec: ComponentSpec,\n namespace: string,\n missing: string[],\n checked: Set<string>\n ): void {\n if (checked.has(spec.name)) return;\n checked.add(spec.name);\n\n // Check if component exists in registry\n if (!this.registry.has(spec.name, namespace)) {\n missing.push(spec.name);\n }\n\n // Check children\n const children = spec.dependencies || [];\n for (const child of children) {\n this.checkDependencies(child, namespace, missing, checked);\n }\n }\n\n /**\n * Gets the dependency graph for a component specification\n * @param spec - Component specification\n * @returns Dependency graph as adjacency list\n */\n getDependencyGraph(spec: ComponentSpec): Map<string, string[]> {\n const graph = new Map<string, string[]>();\n const visited = new Set<string>();\n \n this.buildDependencyGraph(spec, graph, visited);\n \n return graph;\n }\n\n /**\n * Recursively builds the dependency graph\n * @param spec - Component specification\n * @param graph - Graph to build\n * @param visited - Set of visited components\n */\n private buildDependencyGraph(\n spec: ComponentSpec,\n graph: Map<string, string[]>,\n visited: Set<string>\n ): void {\n if (visited.has(spec.name)) return;\n visited.add(spec.name);\n\n const children = spec.dependencies || [];\n const dependencies = children.map(child => child.name);\n \n graph.set(spec.name, dependencies);\n\n // Recursively process children\n for (const child of children) {\n this.buildDependencyGraph(child, graph, visited);\n }\n }\n\n /**\n * Performs topological sort on component dependencies\n * @param spec - Root component specification\n * @returns Array of component names in dependency order\n */\n getLoadOrder(spec: ComponentSpec): string[] {\n const graph = this.getDependencyGraph(spec);\n const visited = new Set<string>();\n const stack: string[] = [];\n\n // Perform DFS on all nodes\n for (const node of graph.keys()) {\n if (!visited.has(node)) {\n this.topologicalSortDFS(node, graph, visited, stack);\n }\n }\n\n // Reverse to get correct load order\n return stack.reverse();\n }\n\n /**\n * DFS helper for topological sort\n * @param node - Current node\n * @param graph - Dependency graph\n * @param visited - Set of visited nodes\n * @param stack - Result stack\n */\n private topologicalSortDFS(\n node: string,\n graph: Map<string, string[]>,\n visited: Set<string>,\n stack: string[]\n ): void {\n visited.add(node);\n\n const dependencies = graph.get(node) || [];\n for (const dep of dependencies) {\n if (!visited.has(dep)) {\n this.topologicalSortDFS(dep, graph, visited, stack);\n }\n }\n\n stack.push(node);\n }\n\n /**\n * Resolves components in the correct dependency order\n * @param spec - Root component specification\n * @param namespace - Namespace for resolution\n * @returns Ordered array of resolved components\n */\n resolveInOrder(spec: ComponentSpec, namespace: string = 'Global'): Array<{\n name: string;\n component: any;\n }> {\n const loadOrder = this.getLoadOrder(spec);\n const resolved: Array<{ name: string; component: any }> = [];\n\n for (const name of loadOrder) {\n const component = this.registry.get(name, namespace);\n if (component) {\n resolved.push({ name, component });\n }\n }\n\n return resolved;\n }\n\n /**\n * Creates a flattened list of all component specifications\n * @param spec - Root component specification\n * @returns Array of all component specs in the hierarchy\n */\n flattenComponentSpecs(spec: ComponentSpec): ComponentSpec[] {\n const flattened: ComponentSpec[] = [];\n const visited = new Set<string>();\n\n this.collectComponentSpecs(spec, flattened, visited);\n\n return flattened;\n }\n\n /**\n * Recursively collects component specifications\n * @param spec - Current component specification\n * @param collected - Array to collect specs\n * @param visited - Set of visited component names\n */\n private collectComponentSpecs(\n spec: ComponentSpec,\n collected: ComponentSpec[],\n visited: Set<string>\n ): void {\n if (visited.has(spec.name)) return;\n visited.add(spec.name);\n\n collected.push(spec);\n\n const children = spec.dependencies || [];\n for (const child of children) {\n this.collectComponentSpecs(child, collected, visited);\n }\n }\n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-hierarchy.d.ts","sourceRoot":"","sources":["../../src/runtime/component-hierarchy.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,cAAc,
|
|
1
|
+
{"version":3,"file":"component-hierarchy.d.ts","sourceRoot":"","sources":["../../src/runtime/component-hierarchy.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,cAAc,EAEf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MA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AAC,KAAK,CAAC,EAAE,0BAA0B,CAAA;KAAE,CAAC;YA6FtD,uBAAuB;CAyCtC;AAWD,wBAAsB,0BAA0B,CAC9C,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,iBAAiB,EAC3B,QAAQ,EAAE,iBAAiB,EAC3B,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,2BAA2B,CAAC,CAGtC;AAOD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,EAAE,CA2BnE;AAOD,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,aAAa,GAAG,aAAa,EAAE,CASlF;AAQD,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,aAAa,EACvB,YAAY,GAAE,OAAe,GAC5B,MAAM,CAaR"}
|
|
@@ -18,19 +18,76 @@ class ComponentHierarchyRegistrar {
|
|
|
18
18
|
const registeredComponents = [];
|
|
19
19
|
const errors = [];
|
|
20
20
|
const warnings = [];
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
const compiledMap = new Map();
|
|
22
|
+
const specMap = new Map();
|
|
23
|
+
const compileOnly = async (spec) => {
|
|
24
|
+
if (!spec.code)
|
|
25
|
+
return { success: true };
|
|
26
|
+
try {
|
|
27
|
+
const compileOptions = {
|
|
28
|
+
componentName: spec.name,
|
|
29
|
+
componentCode: spec.code,
|
|
30
|
+
styles,
|
|
31
|
+
libraries: spec.libraries,
|
|
32
|
+
dependencies: spec.dependencies,
|
|
33
|
+
allLibraries: options.allLibraries
|
|
34
|
+
};
|
|
35
|
+
const result = await this.compiler.compile(compileOptions);
|
|
36
|
+
if (result.success && result.component) {
|
|
37
|
+
compiledMap.set(spec.name, result.component);
|
|
38
|
+
specMap.set(spec.name, spec);
|
|
39
|
+
return { success: true };
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
return {
|
|
43
|
+
success: false,
|
|
44
|
+
error: {
|
|
45
|
+
componentName: spec.name,
|
|
46
|
+
error: result.error?.message || 'Unknown compilation error',
|
|
47
|
+
phase: 'compilation'
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
return {
|
|
54
|
+
success: false,
|
|
55
|
+
error: {
|
|
56
|
+
componentName: spec.name,
|
|
57
|
+
error: error instanceof Error ? error.message : String(error),
|
|
58
|
+
phase: 'compilation'
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const compileQueue = [rootSpec];
|
|
64
|
+
const visited = new Set();
|
|
65
|
+
while (compileQueue.length > 0) {
|
|
66
|
+
const spec = compileQueue.shift();
|
|
67
|
+
if (visited.has(spec.name))
|
|
68
|
+
continue;
|
|
69
|
+
visited.add(spec.name);
|
|
70
|
+
const result = await compileOnly(spec);
|
|
71
|
+
if (!result.success) {
|
|
72
|
+
errors.push(result.error);
|
|
73
|
+
if (!continueOnError) {
|
|
74
|
+
return { success: false, registeredComponents, errors, warnings };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (spec.dependencies) {
|
|
78
|
+
compileQueue.push(...spec.dependencies);
|
|
29
79
|
}
|
|
30
80
|
}
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
const
|
|
81
|
+
for (const [name, compiled] of compiledMap) {
|
|
82
|
+
const spec = specMap.get(name);
|
|
83
|
+
const components = {};
|
|
84
|
+
for (const [depName, depCompiled] of compiledMap) {
|
|
85
|
+
const depObject = depCompiled.factory(this.runtimeContext, styles);
|
|
86
|
+
components[depName] = depObject.component;
|
|
87
|
+
}
|
|
88
|
+
const componentObject = compiled.factory(this.runtimeContext, styles, components);
|
|
89
|
+
this.registry.register(spec.name, componentObject, spec.namespace || namespace, version);
|
|
90
|
+
registeredComponents.push(spec.name);
|
|
34
91
|
}
|
|
35
92
|
return {
|
|
36
93
|
success: errors.length === 0,
|
|
@@ -82,8 +139,13 @@ class ComponentHierarchyRegistrar {
|
|
|
82
139
|
}
|
|
83
140
|
};
|
|
84
141
|
}
|
|
85
|
-
|
|
86
|
-
|
|
142
|
+
console.log(`🏭 Calling factory for ${spec.name} with runtime context:`, {
|
|
143
|
+
hasReact: !!this.runtimeContext.React,
|
|
144
|
+
hasReactDOM: !!this.runtimeContext.ReactDOM,
|
|
145
|
+
libraryKeys: Object.keys(this.runtimeContext.libraries || {})
|
|
146
|
+
});
|
|
147
|
+
const componentObject = compilationResult.component.factory(this.runtimeContext, styles);
|
|
148
|
+
this.registry.register(spec.name, componentObject, spec.namespace || namespace, version);
|
|
87
149
|
return { success: true };
|
|
88
150
|
}
|
|
89
151
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-hierarchy.js","sourceRoot":"","sources":["../../src/runtime/component-hierarchy.ts"],"names":[],"mappings":";;;AA4DA,MAAa,2BAA2B;IACtC,YACU,QAA2B,EAC3B,QAA2B,EAC3B,cAA8B;QAF9B,aAAQ,GAAR,QAAQ,CAAmB;QAC3B,aAAQ,GAAR,QAAQ,CAAmB;QAC3B,mBAAc,GAAd,cAAc,CAAgB;IACrC,CAAC;IAQJ,KAAK,CAAC,iBAAiB,CACrB,QAAuB,EACvB,OAAqC;QAErC,MAAM,EACJ,MAAM,EACN,SAAS,GAAG,QAAQ,EACpB,OAAO,GAAG,IAAI,EACd,eAAe,GAAG,IAAI,EACtB,aAAa,GAAG,IAAI,EACrB,GAAG,OAAO,CAAC;QAEZ,OAAO,CAAC,GAAG,CAAC,mDAAmD,EAAE;YAC/D,aAAa,EAAE,QAAQ,CAAC,IAAI;YAC5B,YAAY,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,IAAI,QAAQ,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;YACrE,YAAY,EAAE,QAAQ,CAAC,SAAS,EAAE,M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AAwB,KAAK;IAE7B,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,IAAI,YAAY,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;QAClC,KAAK,GAAG,CAAC,CAAC;IACZ,CAAC;IAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,IAAI,EAAE,CAAC;IAC7C,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACvB,KAAK,IAAI,0BAA0B,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC;AAhBD,gEAgBC","sourcesContent":["/**\n * @fileoverview Component hierarchy registration utilities for MemberJunction React Runtime.\n * Provides functionality to register a hierarchy of components from Skip component specifications.\n * @module @memberjunction/react-runtime/hierarchy\n */\n\nimport { \n CompilationResult,\n CompileOptions,\n RuntimeContext\n} from '../types';\nimport { ComponentCompiler } from '../compiler';\nimport { ComponentRegistry } from '../registry';\n\nimport { ComponentSpec, ComponentStyles } from '@memberjunction/interactive-component-types';\nimport { UserInfo } from '@memberjunction/core';\nimport { ComponentLibraryEntity } from '@memberjunction/core-entities';\n\n/**\n * Result of a hierarchy registration operation\n */\nexport interface HierarchyRegistrationResult {\n success: boolean;\n registeredComponents: string[];\n errors: ComponentRegistrationError[];\n warnings: string[];\n}\n\n/**\n * Error information for component registration\n */\nexport interface ComponentRegistrationError {\n componentName: string;\n error: string;\n phase: 'compilation' | 'registration' | 'validation';\n}\n\n/**\n * Options for hierarchy registration\n */\nexport interface HierarchyRegistrationOptions {\n /** Component styles to apply to all components */\n styles?: ComponentStyles;\n /** Namespace for component registration */\n namespace?: string;\n /** Version for component registration */\n version?: string;\n /** Whether to continue on errors */\n continueOnError?: boolean;\n /** Whether to override existing components */\n allowOverride?: boolean;\n /**\n * Required, metadata for all possible libraries allowed by the system\n */\n allLibraries: ComponentLibraryEntity[];\n}\n\n/**\n * Utility class for registering component hierarchies\n */\nexport class ComponentHierarchyRegistrar {\n constructor(\n private compiler: ComponentCompiler,\n private registry: ComponentRegistry,\n private runtimeContext: RuntimeContext\n ) {}\n\n /**\n * Registers a complete component hierarchy from a root specification\n * @param rootSpec - The root component specification\n * @param options - Registration options\n * @returns Registration result with details about success/failures\n */\n async registerHierarchy(\n rootSpec: ComponentSpec,\n options: HierarchyRegistrationOptions\n ): Promise<HierarchyRegistrationResult> {\n const {\n styles,\n namespace = 'Global',\n version = 'v1',\n continueOnError = true,\n allowOverride = true\n } = options;\n\n console.log('🌳 ComponentHierarchyRegistrar.registerHierarchy:', {\n rootComponent: rootSpec.name,\n hasLibraries: !!(rootSpec.libraries && rootSpec.libraries.length > 0),\n libraryCount: rootSpec.libraries?.length || 0,\n libraries: rootSpec.libraries?.map(l => l.name)\n });\n\n const registeredComponents: string[] = [];\n const errors: ComponentRegistrationError[] = [];\n const warnings: string[] = [];\n\n // Register the root component\n const rootResult = await this.registerSingleComponent(\n rootSpec,\n { styles, namespace, version, allowOverride, allLibraries: options.allLibraries }\n );\n\n if (rootResult.success) {\n registeredComponents.push(rootSpec.name);\n } else {\n errors.push(rootResult.error!);\n if (!continueOnError) {\n return { success: false, registeredComponents, errors, warnings };\n }\n }\n\n // Register child components recursively\n const childComponents = rootSpec.dependencies || [];\n if (childComponents.length > 0) {\n const childResult = await this.registerChildComponents(\n childComponents,\n { styles, namespace, version, continueOnError, allowOverride, allLibraries: options.allLibraries },\n registeredComponents,\n errors,\n warnings\n );\n }\n\n return {\n success: errors.length === 0,\n registeredComponents,\n errors,\n warnings\n };\n }\n\n /**\n * Registers a single component from a specification\n * @param spec - Component specification\n * @param options - Registration options\n * @returns Registration result for this component\n */\n async registerSingleComponent(\n spec: ComponentSpec,\n options: {\n styles?: ComponentStyles;\n namespace?: string;\n version?: string;\n allowOverride?: boolean;\n allLibraries: ComponentLibraryEntity[];\n }\n ): Promise<{ success: boolean; error?: ComponentRegistrationError }> {\n const { styles, namespace = 'Global', version = 'v1', allowOverride = true } = options;\n\n try {\n // Skip if no component code\n if (!spec.code) {\n return {\n success: true,\n error: undefined\n };\n }\n\n // Check if component already exists\n const existingComponent = this.registry.get(spec.name, namespace, version);\n if (existingComponent && !allowOverride) {\n return {\n success: false,\n error: {\n componentName: spec.name,\n error: `Component already registered in ${namespace}/${version}`,\n phase: 'registration'\n }\n };\n }\n\n // Compile the component\n const compileOptions: CompileOptions = {\n componentName: spec.name,\n componentCode: spec.code,\n styles,\n libraries: spec.libraries, // Pass along library dependencies from the spec\n dependencies: spec.dependencies, // Pass along child component dependencies\n allLibraries: options.allLibraries\n };\n\n console.log(`🔧 Compiling component ${spec.name} with libraries:`, {\n libraryCount: spec.libraries?.length || 0,\n libraries: spec.libraries?.map(l => ({ name: l.name, globalVariable: l.globalVariable }))\n });\n\n const compilationResult = await this.compiler.compile(compileOptions);\n\n if (!compilationResult.success) {\n return {\n success: false,\n error: {\n componentName: spec.name,\n error: compilationResult.error?.message || 'Unknown compilation error',\n phase: 'compilation'\n }\n };\n }\n\n // Create component factory\n const componentFactory = compilationResult.component!.component(this.runtimeContext, styles);\n\n // Register the component\n this.registry.register(\n spec.name,\n componentFactory.component,\n spec.namespace || namespace,\n version\n );\n\n return { success: true };\n\n } catch (error) {\n return {\n success: false,\n error: {\n componentName: spec.name,\n error: error instanceof Error ? error.message : String(error),\n phase: 'registration'\n }\n };\n }\n }\n\n /**\n * Recursively registers child components\n * @param children - Array of child component specifications\n * @param options - Registration options\n * @param registeredComponents - Array to track registered components\n * @param errors - Array to collect errors\n * @param warnings - Array to collect warnings\n */\n private async registerChildComponents(\n children: ComponentSpec[],\n options: HierarchyRegistrationOptions,\n registeredComponents: string[],\n errors: ComponentRegistrationError[],\n warnings: string[]\n ): Promise<void> {\n for (const child of children) {\n // Register this child\n const childResult = await this.registerSingleComponent(child, {\n styles: options.styles,\n namespace: options.namespace,\n version: options.version,\n allowOverride: options.allowOverride,\n allLibraries: options.allLibraries\n });\n\n if (childResult.success) {\n if (child.code) {\n registeredComponents.push(child.name);\n }\n } else {\n errors.push(childResult.error!);\n if (!options.continueOnError) {\n return;\n }\n }\n\n // Register nested children recursively\n const nestedChildren = child.dependencies || [];\n if (nestedChildren.length > 0) {\n await this.registerChildComponents(\n nestedChildren,\n options,\n registeredComponents,\n errors,\n warnings\n );\n }\n }\n }\n}\n\n/**\n * Convenience function to register a component hierarchy\n * @param rootSpec - The root component specification\n * @param compiler - Component compiler instance\n * @param registry - Component registry instance\n * @param runtimeContext - Runtime context with React and other libraries\n * @param options - Registration options\n * @returns Registration result\n */\nexport async function registerComponentHierarchy(\n rootSpec: ComponentSpec,\n compiler: ComponentCompiler,\n registry: ComponentRegistry,\n runtimeContext: RuntimeContext,\n options: HierarchyRegistrationOptions\n): Promise<HierarchyRegistrationResult> {\n const registrar = new ComponentHierarchyRegistrar(compiler, registry, runtimeContext);\n return registrar.registerHierarchy(rootSpec, options);\n}\n\n/**\n * Validates a component specification before registration\n * @param spec - Component specification to validate\n * @returns Array of validation errors (empty if valid)\n */\nexport function validateComponentSpec(spec: ComponentSpec): string[] {\n const errors: string[] = [];\n\n if (!spec.name) {\n errors.push('Component specification must have a name');\n }\n\n // If componentCode is provided, do basic validation\n if (spec.code) {\n if (typeof spec.code !== 'string') {\n errors.push(`Component code for ${spec.name} must be a string`);\n }\n if (spec.code.trim().length === 0) {\n errors.push(`Component code for ${spec.name} cannot be empty`);\n }\n }\n\n // Validate child components recursively\n const children = spec.dependencies || [];\n children.forEach((child, index) => {\n const childErrors = validateComponentSpec(child);\n childErrors.forEach(error => {\n errors.push(`Child ${index} (${child.name || 'unnamed'}): ${error}`);\n });\n });\n\n return errors;\n}\n\n/**\n * Flattens a component hierarchy into a list of all components\n * @param rootSpec - The root component specification\n * @returns Array of all component specifications in the hierarchy\n */\nexport function flattenComponentHierarchy(rootSpec: ComponentSpec): ComponentSpec[] {\n const components: ComponentSpec[] = [rootSpec];\n \n const children = rootSpec.dependencies || [];\n children.forEach(child => {\n components.push(...flattenComponentHierarchy(child));\n });\n\n return components;\n}\n\n/**\n * Counts the total number of components in a hierarchy\n * @param rootSpec - The root component specification\n * @param includeEmpty - Whether to include components without code\n * @returns Total component count\n */\nexport function countComponentsInHierarchy(\n rootSpec: ComponentSpec,\n includeEmpty: boolean = false\n): number {\n let count = 0;\n \n if (includeEmpty || rootSpec.code) {\n count = 1;\n }\n\n const children = rootSpec.dependencies || [];\n children.forEach(child => {\n count += countComponentsInHierarchy(child, includeEmpty);\n });\n\n return count;\n}"]}
|
|
1
|
+
{"version":3,"file":"component-hierarchy.js","sourceRoot":"","sources":["../../src/runtime/component-hierarchy.ts"],"names":[],"mappings":";;;AA6DA,MAAa,2BAA2B;IACtC,YACU,QAA2B,EAC3B,QAA2B,EAC3B,cAA8B;QAF9B,aAAQ,GAAR,QAAQ,CAAmB;QAC3B,aAAQ,GAAR,QAAQ,CAAmB;QAC3B,mBAAc,GAAd,cAAc,CAAgB;IACrC,CAAC;IAQJ,KAAK,CAAC,iBAAiB,CACrB,QAAuB,EACvB,OAAqC;QAErC,MAAM,EACJ,MAAM,EACN,SAAS,GAAG,QAAQ,EACpB,OAAO,GAAG,IAAI,EACd,eAAe,GAAG,IAAI,EACtB,aAAa,GAAG,IAAI,EACrB,GAAG,OAAO,CAAC;QAEZ,OAAO,CAAC,GAAG,CAAC,mDAAmD,EAAE;YAC/D,aAAa,EAAE,QAAQ,CAAC,IAAI;YAC5B,YAAY,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,IAAI,QAAQ,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;YACrE,YAAY,EAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,IAAI,CAAC;YAC7C,SAAS,EAAE,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;SAChD,CAAC,CAAC;QAEH,MAAM,oBAAoB,GAAa,EAAE,CAAC;QAC1C,MAAM,MAAM,GAAiC,EAAE,CAAC;QA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EAAE,YAAY,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC;AAhBD,gEAgBC","sourcesContent":["/**\n * @fileoverview Component hierarchy registration utilities for MemberJunction React Runtime.\n * Provides functionality to register a hierarchy of components from Skip component specifications.\n * @module @memberjunction/react-runtime/hierarchy\n */\n\nimport { \n CompilationResult,\n CompileOptions,\n RuntimeContext,\n CompiledComponent\n} from '../types';\nimport { ComponentCompiler } from '../compiler';\nimport { ComponentRegistry } from '../registry';\n\nimport { ComponentSpec, ComponentStyles } from '@memberjunction/interactive-component-types';\nimport { UserInfo } from '@memberjunction/core';\nimport { ComponentLibraryEntity } from '@memberjunction/core-entities';\n\n/**\n * Result of a hierarchy registration operation\n */\nexport interface HierarchyRegistrationResult {\n success: boolean;\n registeredComponents: string[];\n errors: ComponentRegistrationError[];\n warnings: string[];\n}\n\n/**\n * Error information for component registration\n */\nexport interface ComponentRegistrationError {\n componentName: string;\n error: string;\n phase: 'compilation' | 'registration' | 'validation';\n}\n\n/**\n * Options for hierarchy registration\n */\nexport interface HierarchyRegistrationOptions {\n /** Component styles to apply to all components */\n styles?: ComponentStyles;\n /** Namespace for component registration */\n namespace?: string;\n /** Version for component registration */\n version?: string;\n /** Whether to continue on errors */\n continueOnError?: boolean;\n /** Whether to override existing components */\n allowOverride?: boolean;\n /**\n * Required, metadata for all possible libraries allowed by the system\n */\n allLibraries: ComponentLibraryEntity[];\n}\n\n/**\n * Utility class for registering component hierarchies\n */\nexport class ComponentHierarchyRegistrar {\n constructor(\n private compiler: ComponentCompiler,\n private registry: ComponentRegistry,\n private runtimeContext: RuntimeContext\n ) {}\n\n /**\n * Registers a complete component hierarchy from a root specification\n * @param rootSpec - The root component specification\n * @param options - Registration options\n * @returns Registration result with details about success/failures\n */\n async registerHierarchy(\n rootSpec: ComponentSpec,\n options: HierarchyRegistrationOptions\n ): Promise<HierarchyRegistrationResult> {\n const {\n styles,\n namespace = 'Global',\n version = 'v1',\n continueOnError = true,\n allowOverride = true\n } = options;\n\n console.log('🌳 ComponentHierarchyRegistrar.registerHierarchy:', {\n rootComponent: rootSpec.name,\n hasLibraries: !!(rootSpec.libraries && rootSpec.libraries.length > 0),\n libraryCount: rootSpec.libraries?.length || 0,\n libraries: rootSpec.libraries?.map(l => l.name)\n });\n\n const registeredComponents: string[] = [];\n const errors: ComponentRegistrationError[] = [];\n const warnings: string[] = [];\n\n // PHASE 1: Compile all components first (but defer factory execution)\n const compiledMap = new Map<string, CompiledComponent>();\n const specMap = new Map<string, ComponentSpec>();\n \n // Helper to compile a component without calling its factory\n const compileOnly = async (spec: ComponentSpec): Promise<{ success: boolean; error?: ComponentRegistrationError }> => {\n if (!spec.code) return { success: true };\n \n try {\n const compileOptions: CompileOptions = {\n componentName: spec.name,\n componentCode: spec.code,\n styles,\n libraries: spec.libraries,\n dependencies: spec.dependencies,\n allLibraries: options.allLibraries\n };\n \n const result = await this.compiler.compile(compileOptions);\n if (result.success && result.component) {\n compiledMap.set(spec.name, result.component);\n specMap.set(spec.name, spec);\n return { success: true };\n } else {\n return {\n success: false,\n error: {\n componentName: spec.name,\n error: result.error?.message || 'Unknown compilation error',\n phase: 'compilation'\n }\n };\n }\n } catch (error) {\n return {\n success: false,\n error: {\n componentName: spec.name,\n error: error instanceof Error ? error.message : String(error),\n phase: 'compilation'\n }\n };\n }\n };\n \n // Compile all components in hierarchy\n const compileQueue = [rootSpec];\n const visited = new Set<string>();\n \n while (compileQueue.length > 0) {\n const spec = compileQueue.shift()!;\n if (visited.has(spec.name)) continue;\n visited.add(spec.name);\n \n const result = await compileOnly(spec);\n if (!result.success) {\n errors.push(result.error!);\n if (!continueOnError) {\n return { success: false, registeredComponents, errors, warnings };\n }\n }\n \n if (spec.dependencies) {\n compileQueue.push(...spec.dependencies);\n }\n }\n \n // PHASE 2: Execute all factories with components available\n for (const [name, compiled] of compiledMap) {\n const spec = specMap.get(name)!;\n \n // Build components object from all registered components\n const components: Record<string, any> = {};\n for (const [depName, depCompiled] of compiledMap) {\n // Call factory to get ComponentObject, then extract React component\n const depObject = depCompiled.factory(this.runtimeContext, styles);\n components[depName] = depObject.component;\n }\n \n // Now call factory with components available\n const componentObject = compiled.factory(this.runtimeContext, styles, components);\n \n // Register in registry\n this.registry.register(\n spec.name,\n componentObject,\n spec.namespace || namespace,\n version\n );\n \n registeredComponents.push(spec.name);\n }\n\n return {\n success: errors.length === 0,\n registeredComponents,\n errors,\n warnings\n };\n }\n\n /**\n * Registers a single component from a specification\n * @param spec - Component specification\n * @param options - Registration options\n * @returns Registration result for this component\n */\n async registerSingleComponent(\n spec: ComponentSpec,\n options: {\n styles?: ComponentStyles;\n namespace?: string;\n version?: string;\n allowOverride?: boolean;\n allLibraries: ComponentLibraryEntity[];\n }\n ): Promise<{ success: boolean; error?: ComponentRegistrationError }> {\n const { styles, namespace = 'Global', version = 'v1', allowOverride = true } = options;\n\n try {\n // Skip if no component code\n if (!spec.code) {\n return {\n success: true,\n error: undefined\n };\n }\n\n // Check if component already exists\n const existingComponent = this.registry.get(spec.name, namespace, version);\n if (existingComponent && !allowOverride) {\n return {\n success: false,\n error: {\n componentName: spec.name,\n error: `Component already registered in ${namespace}/${version}`,\n phase: 'registration'\n }\n };\n }\n\n // Compile the component\n const compileOptions: CompileOptions = {\n componentName: spec.name,\n componentCode: spec.code,\n styles,\n libraries: spec.libraries, // Pass along library dependencies from the spec\n dependencies: spec.dependencies, // Pass along child component dependencies\n allLibraries: options.allLibraries\n };\n\n console.log(`🔧 Compiling component ${spec.name} with libraries:`, {\n libraryCount: spec.libraries?.length || 0,\n libraries: spec.libraries?.map(l => ({ name: l.name, globalVariable: l.globalVariable }))\n });\n\n const compilationResult = await this.compiler.compile(compileOptions);\n\n if (!compilationResult.success) {\n return {\n success: false,\n error: {\n componentName: spec.name,\n error: compilationResult.error?.message || 'Unknown compilation error',\n phase: 'compilation'\n }\n };\n }\n\n // Call the factory to create the ComponentObject\n // IMPORTANT: We don't pass components here because child components may not be registered yet\n // Components are resolved later when the component is actually rendered\n console.log(`🏭 Calling factory for ${spec.name} with runtime context:`, {\n hasReact: !!this.runtimeContext.React,\n hasReactDOM: !!this.runtimeContext.ReactDOM,\n libraryKeys: Object.keys(this.runtimeContext.libraries || {})\n });\n const componentObject = compilationResult.component!.factory(this.runtimeContext, styles);\n\n // Register the full ComponentObject (not just the React component)\n this.registry.register(\n spec.name,\n componentObject,\n spec.namespace || namespace,\n version\n );\n\n return { success: true };\n\n } catch (error) {\n return {\n success: false,\n error: {\n componentName: spec.name,\n error: error instanceof Error ? error.message : String(error),\n phase: 'registration'\n }\n };\n }\n }\n\n /**\n * Recursively registers child components\n * @param children - Array of child component specifications\n * @param options - Registration options\n * @param registeredComponents - Array to track registered components\n * @param errors - Array to collect errors\n * @param warnings - Array to collect warnings\n */\n private async registerChildComponents(\n children: ComponentSpec[],\n options: HierarchyRegistrationOptions,\n registeredComponents: string[],\n errors: ComponentRegistrationError[],\n warnings: string[]\n ): Promise<void> {\n for (const child of children) {\n // Register this child\n const childResult = await this.registerSingleComponent(child, {\n styles: options.styles,\n namespace: options.namespace,\n version: options.version,\n allowOverride: options.allowOverride,\n allLibraries: options.allLibraries\n });\n\n if (childResult.success) {\n if (child.code) {\n registeredComponents.push(child.name);\n }\n } else {\n errors.push(childResult.error!);\n if (!options.continueOnError) {\n return;\n }\n }\n\n // Register nested children recursively\n const nestedChildren = child.dependencies || [];\n if (nestedChildren.length > 0) {\n await this.registerChildComponents(\n nestedChildren,\n options,\n registeredComponents,\n errors,\n warnings\n );\n }\n }\n }\n}\n\n/**\n * Convenience function to register a component hierarchy\n * @param rootSpec - The root component specification\n * @param compiler - Component compiler instance\n * @param registry - Component registry instance\n * @param runtimeContext - Runtime context with React and other libraries\n * @param options - Registration options\n * @returns Registration result\n */\nexport async function registerComponentHierarchy(\n rootSpec: ComponentSpec,\n compiler: ComponentCompiler,\n registry: ComponentRegistry,\n runtimeContext: RuntimeContext,\n options: HierarchyRegistrationOptions\n): Promise<HierarchyRegistrationResult> {\n const registrar = new ComponentHierarchyRegistrar(compiler, registry, runtimeContext);\n return registrar.registerHierarchy(rootSpec, options);\n}\n\n/**\n * Validates a component specification before registration\n * @param spec - Component specification to validate\n * @returns Array of validation errors (empty if valid)\n */\nexport function validateComponentSpec(spec: ComponentSpec): string[] {\n const errors: string[] = [];\n\n if (!spec.name) {\n errors.push('Component specification must have a name');\n }\n\n // If componentCode is provided, do basic validation\n if (spec.code) {\n if (typeof spec.code !== 'string') {\n errors.push(`Component code for ${spec.name} must be a string`);\n }\n if (spec.code.trim().length === 0) {\n errors.push(`Component code for ${spec.name} cannot be empty`);\n }\n }\n\n // Validate child components recursively\n const children = spec.dependencies || [];\n children.forEach((child, index) => {\n const childErrors = validateComponentSpec(child);\n childErrors.forEach(error => {\n errors.push(`Child ${index} (${child.name || 'unnamed'}): ${error}`);\n });\n });\n\n return errors;\n}\n\n/**\n * Flattens a component hierarchy into a list of all components\n * @param rootSpec - The root component specification\n * @returns Array of all component specifications in the hierarchy\n */\nexport function flattenComponentHierarchy(rootSpec: ComponentSpec): ComponentSpec[] {\n const components: ComponentSpec[] = [rootSpec];\n \n const children = rootSpec.dependencies || [];\n children.forEach(child => {\n components.push(...flattenComponentHierarchy(child));\n });\n\n return components;\n}\n\n/**\n * Counts the total number of components in a hierarchy\n * @param rootSpec - The root component specification\n * @param includeEmpty - Whether to include components without code\n * @returns Total component count\n */\nexport function countComponentsInHierarchy(\n rootSpec: ComponentSpec,\n includeEmpty: boolean = false\n): number {\n let count = 0;\n \n if (includeEmpty || rootSpec.code) {\n count = 1;\n }\n\n const children = rootSpec.dependencies || [];\n children.forEach(child => {\n count += countComponentsInHierarchy(child, includeEmpty);\n });\n\n return count;\n}"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ComponentStyles } from '@memberjunction/interactive-component-types';
|
|
2
|
-
import { ComponentProps
|
|
1
|
+
import { ComponentStyles, ComponentCallbacks } from '@memberjunction/interactive-component-types';
|
|
2
|
+
import { ComponentProps } from '../types';
|
|
3
3
|
export interface PropBuilderOptions {
|
|
4
4
|
validate?: boolean;
|
|
5
5
|
merge?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prop-builder.d.ts","sourceRoot":"","sources":["../../src/runtime/prop-builder.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"prop-builder.d.ts","sourceRoot":"","sources":["../../src/runtime/prop-builder.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAClG,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAM1C,MAAM,WAAW,kBAAkB;IAEjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,GAAG,CAAC;IAEnC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;IAErC,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAaD,wBAAgB,mBAAmB,CACjC,IAAI,GAAE,GAAQ,EACd,SAAS,GAAE,GAAQ,EACnB,SAAS,GAAE,GAAQ,EACnB,SAAS,GAAE,kBAGV,EACD,UAAU,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EACpC,MAAM,CAAC,EAAE,eAAe,EACxB,OAAO,GAAE,kBAAuB,EAChC,cAAc,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,GAC1D,cAAc,CA6BhB;AA0CD,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,GAAG,EAAE,UAAU,GAAE,MAAa,GAAG,kBAAkB,CAiBhG;AAOD,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,GAAG,GAAG,GAAG,CAKjD;AAOD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CA2BlE;AAOD,wBAAgB,UAAU,CAAC,GAAG,SAAS,EAAE,OAAO,CAAC,cAAc,CAAC,EAAE,GAAG,cAAc,CAqClF;AAOD,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC,GACnD,CAAC,KAAK,EAAE,cAAc,KAAK,cAAc,CAyB3C;AAQD,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,kBAAkB,EAC7B,aAAa,EAAE,MAAM,GACpB,kBAAkB,CA+BpB;AAOD,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,CAmBhE"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extractPropPaths = exports.wrapCallbacksWithLogging = exports.createPropsTransformer = exports.mergeProps = exports.validateComponentProps = exports.normalizeStyles = exports.normalizeCallbacks = exports.buildComponentProps = void 0;
|
|
4
|
-
function buildComponentProps(data = {}, userState = {}, utilities = {}, callbacks = {
|
|
4
|
+
function buildComponentProps(data = {}, userState = {}, utilities = {}, callbacks = {
|
|
5
|
+
OpenEntityRecord: () => { },
|
|
6
|
+
RegisterMethod: () => { }
|
|
7
|
+
}, components = {}, styles, options = {}, onStateChanged) {
|
|
5
8
|
const { validate = true, transformData, transformState, debounceUpdateUserState = 3000 } = options;
|
|
6
9
|
const transformedData = transformData ? transformData(data) : data;
|
|
7
10
|
const transformedState = transformState ? transformState(userState) : userState;
|
|
@@ -43,12 +46,16 @@ function deepEqual(obj1, obj2) {
|
|
|
43
46
|
return true;
|
|
44
47
|
}
|
|
45
48
|
function normalizeCallbacks(callbacks, debounceMs = 3000) {
|
|
46
|
-
const normalized = {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
if (callbacks
|
|
51
|
-
|
|
49
|
+
const normalized = {
|
|
50
|
+
OpenEntityRecord: callbacks?.OpenEntityRecord || (() => { }),
|
|
51
|
+
RegisterMethod: callbacks?.RegisterMethod || (() => { })
|
|
52
|
+
};
|
|
53
|
+
if (callbacks) {
|
|
54
|
+
Object.keys(callbacks).forEach(key => {
|
|
55
|
+
if (typeof callbacks[key] === 'function' && !normalized.hasOwnProperty(key)) {
|
|
56
|
+
normalized[key] = callbacks[key];
|
|
57
|
+
}
|
|
58
|
+
});
|
|
52
59
|
}
|
|
53
60
|
return normalized;
|
|
54
61
|
}
|
|
@@ -131,19 +138,30 @@ function createPropsTransformer(transformations) {
|
|
|
131
138
|
}
|
|
132
139
|
exports.createPropsTransformer = createPropsTransformer;
|
|
133
140
|
function wrapCallbacksWithLogging(callbacks, componentName) {
|
|
134
|
-
const wrapped = {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
+
const wrapped = {
|
|
142
|
+
OpenEntityRecord: callbacks?.OpenEntityRecord || (() => { }),
|
|
143
|
+
RegisterMethod: callbacks?.RegisterMethod || (() => { })
|
|
144
|
+
};
|
|
145
|
+
Object.keys(callbacks).forEach(key => {
|
|
146
|
+
if (key !== 'OpenEntityRecord' && key !== 'RegisterMethod' && typeof callbacks[key] === 'function') {
|
|
147
|
+
wrapped[key] = (...args) => {
|
|
148
|
+
console.log(`[${componentName}] ${key} called with args:`, args);
|
|
149
|
+
return callbacks[key](...args);
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
});
|
|
141
153
|
if (callbacks.OpenEntityRecord) {
|
|
142
154
|
wrapped.OpenEntityRecord = (entityName, key) => {
|
|
143
155
|
console.log(`[${componentName}] OpenEntityRecord called:`, { entityName, key });
|
|
144
156
|
callbacks.OpenEntityRecord(entityName, key);
|
|
145
157
|
};
|
|
146
158
|
}
|
|
159
|
+
if (callbacks.RegisterMethod) {
|
|
160
|
+
wrapped.RegisterMethod = (methodName, handler) => {
|
|
161
|
+
console.log(`[${componentName}] RegisterMethod called for:`, methodName);
|
|
162
|
+
callbacks.RegisterMethod(methodName, handler);
|
|
163
|
+
};
|
|
164
|
+
}
|
|
147
165
|
return wrapped;
|
|
148
166
|
}
|
|
149
167
|
exports.wrapCallbacksWithLogging = wrapCallbacksWithLogging;
|