@memberjunction/react-runtime 2.111.0 → 2.112.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 +10 -11
- package/CHANGELOG.md +6 -6
- package/dist/compiler/component-compiler.d.ts.map +1 -1
- package/dist/compiler/component-compiler.js +66 -56
- package/dist/compiler/component-compiler.js.map +1 -1
- package/dist/component-manager/component-manager.d.ts.map +1 -1
- package/dist/component-manager/component-manager.js +48 -42
- package/dist/component-manager/component-manager.js.map +1 -1
- package/dist/component-manager/types.d.ts +1 -1
- package/dist/component-manager/types.d.ts.map +1 -1
- package/dist/component-manager/types.js.map +1 -1
- package/dist/registry/component-registry-service.d.ts +1 -1
- package/dist/registry/component-registry-service.d.ts.map +1 -1
- package/dist/registry/component-registry-service.js +34 -34
- package/dist/registry/component-registry-service.js.map +1 -1
- package/dist/registry/component-resolver.d.ts +1 -1
- package/dist/registry/component-resolver.d.ts.map +1 -1
- package/dist/registry/component-resolver.js +10 -11
- package/dist/registry/component-resolver.js.map +1 -1
- package/dist/runtime/component-hierarchy.d.ts +1 -1
- package/dist/runtime/component-hierarchy.d.ts.map +1 -1
- package/dist/runtime/component-hierarchy.js +43 -43
- package/dist/runtime/component-hierarchy.js.map +1 -1
- package/dist/runtime/prop-builder.d.ts.map +1 -1
- package/dist/runtime/prop-builder.js +22 -24
- package/dist/runtime/prop-builder.js.map +1 -1
- package/dist/runtime.umd.js +494 -511
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/library-registry.d.ts +1 -1
- package/dist/utilities/library-registry.d.ts.map +1 -1
- package/dist/utilities/library-registry.js +10 -10
- package/dist/utilities/library-registry.js.map +1 -1
- package/package.json +5 -6
- package/src/compiler/component-compiler.ts +186 -164
- package/src/component-manager/component-manager.ts +162 -216
- package/src/component-manager/types.ts +27 -27
- package/src/registry/component-registry-service.ts +190 -218
- package/src/registry/component-resolver.ts +87 -98
- package/src/runtime/component-hierarchy.ts +57 -94
- package/src/runtime/prop-builder.ts +28 -33
- package/src/types/index.ts +3 -4
- package/src/utilities/library-registry.ts +14 -19
|
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.countComponentsInHierarchy = exports.flattenComponentHierarchy = exports.validateComponentSpec = exports.registerComponentHierarchy = exports.ComponentHierarchyRegistrar = void 0;
|
|
27
|
-
const
|
|
27
|
+
const global_1 = require("@memberjunction/global");
|
|
28
28
|
class ComponentHierarchyRegistrar {
|
|
29
29
|
constructor(compiler, registry, runtimeContext) {
|
|
30
30
|
this.compiler = compiler;
|
|
@@ -33,7 +33,7 @@ class ComponentHierarchyRegistrar {
|
|
|
33
33
|
}
|
|
34
34
|
async fetchExternalComponent(spec, contextUser) {
|
|
35
35
|
try {
|
|
36
|
-
const provider =
|
|
36
|
+
const provider = global_1.Metadata?.Provider;
|
|
37
37
|
if (!provider || !provider.ExecuteGQL) {
|
|
38
38
|
console.warn('⚠️ [ComponentHierarchyRegistrar] No GraphQL provider available for external registry fetch');
|
|
39
39
|
return null;
|
|
@@ -44,11 +44,11 @@ class ComponentHierarchyRegistrar {
|
|
|
44
44
|
registryName: spec.registry,
|
|
45
45
|
namespace: spec.namespace || 'Global',
|
|
46
46
|
name: spec.name,
|
|
47
|
-
version: spec.version || 'latest'
|
|
47
|
+
version: spec.version || 'latest',
|
|
48
48
|
});
|
|
49
49
|
if (fullSpec && fullSpec.code) {
|
|
50
|
-
if (!(0,
|
|
51
|
-
(0,
|
|
50
|
+
if (!(0, global_1.GetProductionStatus)()) {
|
|
51
|
+
(0, global_1.LogStatus)(`✅ [ComponentHierarchyRegistrar] Fetched external component ${spec.name} with code (${fullSpec.code.length} chars)`);
|
|
52
52
|
}
|
|
53
53
|
return fullSpec;
|
|
54
54
|
}
|
|
@@ -65,20 +65,20 @@ class ComponentHierarchyRegistrar {
|
|
|
65
65
|
async registerHierarchy(rootSpec, options) {
|
|
66
66
|
let resolvedRootSpec = rootSpec;
|
|
67
67
|
if (rootSpec.location === 'registry' && rootSpec.registry && !rootSpec.code) {
|
|
68
|
-
if (!(0,
|
|
69
|
-
(0,
|
|
68
|
+
if (!(0, global_1.GetProductionStatus)()) {
|
|
69
|
+
(0, global_1.LogStatus)(`🌐 [ComponentHierarchyRegistrar] Fetching external registry component: ${rootSpec.registry}/${rootSpec.name}`);
|
|
70
70
|
}
|
|
71
|
-
resolvedRootSpec = await this.fetchExternalComponent(rootSpec, options.contextUser) || rootSpec;
|
|
71
|
+
resolvedRootSpec = (await this.fetchExternalComponent(rootSpec, options.contextUser)) || rootSpec;
|
|
72
72
|
}
|
|
73
73
|
const { styles, namespace = 'Global', version = 'v1', continueOnError = true, allowOverride = true } = options;
|
|
74
74
|
const registeredComponents = [];
|
|
75
75
|
const errors = [];
|
|
76
76
|
const warnings = [];
|
|
77
|
-
if (!(0,
|
|
78
|
-
(0,
|
|
77
|
+
if (!(0, global_1.GetProductionStatus)()) {
|
|
78
|
+
(0, global_1.LogStatus)('🌳 ComponentHierarchyRegistrar.registerHierarchy:', undefined, {
|
|
79
79
|
rootComponent: resolvedRootSpec.name,
|
|
80
80
|
hasLibraries: !!(resolvedRootSpec.libraries && resolvedRootSpec.libraries.length > 0),
|
|
81
|
-
libraryCount: resolvedRootSpec.libraries?.length || 0
|
|
81
|
+
libraryCount: resolvedRootSpec.libraries?.length || 0,
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
const compiledMap = new Map();
|
|
@@ -88,7 +88,7 @@ class ComponentHierarchyRegistrar {
|
|
|
88
88
|
if (!spec.code)
|
|
89
89
|
return { success: true };
|
|
90
90
|
try {
|
|
91
|
-
const validLibraries = spec.libraries?.filter(lib => {
|
|
91
|
+
const validLibraries = spec.libraries?.filter((lib) => {
|
|
92
92
|
if (!lib || typeof lib !== 'object')
|
|
93
93
|
return false;
|
|
94
94
|
if (!lib.name || lib.name === 'unknown' || lib.name === 'null' || lib.name === 'undefined')
|
|
@@ -103,7 +103,7 @@ class ComponentHierarchyRegistrar {
|
|
|
103
103
|
styles,
|
|
104
104
|
libraries: validLibraries,
|
|
105
105
|
dependencies: spec.dependencies,
|
|
106
|
-
allLibraries: options.allLibraries
|
|
106
|
+
allLibraries: options.allLibraries,
|
|
107
107
|
};
|
|
108
108
|
const result = await this.compiler.compile(compileOptions);
|
|
109
109
|
if (result.success && result.component) {
|
|
@@ -113,8 +113,8 @@ class ComponentHierarchyRegistrar {
|
|
|
113
113
|
result.loadedLibraries.forEach((value, key) => {
|
|
114
114
|
if (!allLoadedLibraries.has(key)) {
|
|
115
115
|
allLoadedLibraries.set(key, value);
|
|
116
|
-
if (!(0,
|
|
117
|
-
(0,
|
|
116
|
+
if (!(0, global_1.GetProductionStatus)()) {
|
|
117
|
+
(0, global_1.LogStatus)(`📚 [registerHierarchy] Added library ${key} to accumulated libraries`);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
});
|
|
@@ -127,8 +127,8 @@ class ComponentHierarchyRegistrar {
|
|
|
127
127
|
error: {
|
|
128
128
|
componentName: spec.name,
|
|
129
129
|
error: result.error?.message || 'Unknown compilation error',
|
|
130
|
-
phase: 'compilation'
|
|
131
|
-
}
|
|
130
|
+
phase: 'compilation',
|
|
131
|
+
},
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
134
|
}
|
|
@@ -138,8 +138,8 @@ class ComponentHierarchyRegistrar {
|
|
|
138
138
|
error: {
|
|
139
139
|
componentName: spec.name,
|
|
140
140
|
error: error instanceof Error ? error.message : String(error),
|
|
141
|
-
phase: 'compilation'
|
|
142
|
-
}
|
|
141
|
+
phase: 'compilation',
|
|
142
|
+
},
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
145
|
};
|
|
@@ -177,8 +177,8 @@ class ComponentHierarchyRegistrar {
|
|
|
177
177
|
}
|
|
178
178
|
allLoadedLibraries.forEach((value, key) => {
|
|
179
179
|
this.runtimeContext.libraries[key] = value;
|
|
180
|
-
if (!(0,
|
|
181
|
-
(0,
|
|
180
|
+
if (!(0, global_1.GetProductionStatus)()) {
|
|
181
|
+
(0, global_1.LogStatus)(`✅ [registerHierarchy] Added ${key} to runtime context libraries`);
|
|
182
182
|
}
|
|
183
183
|
});
|
|
184
184
|
}
|
|
@@ -198,7 +198,7 @@ class ComponentHierarchyRegistrar {
|
|
|
198
198
|
registeredComponents,
|
|
199
199
|
errors,
|
|
200
200
|
warnings,
|
|
201
|
-
resolvedSpec: resolvedRootSpec
|
|
201
|
+
resolvedSpec: resolvedRootSpec,
|
|
202
202
|
};
|
|
203
203
|
}
|
|
204
204
|
async registerSingleComponent(spec, options) {
|
|
@@ -207,7 +207,7 @@ class ComponentHierarchyRegistrar {
|
|
|
207
207
|
if (!spec.code) {
|
|
208
208
|
return {
|
|
209
209
|
success: true,
|
|
210
|
-
error: undefined
|
|
210
|
+
error: undefined,
|
|
211
211
|
};
|
|
212
212
|
}
|
|
213
213
|
const existingComponent = this.registry.get(spec.name, namespace, version);
|
|
@@ -217,11 +217,11 @@ class ComponentHierarchyRegistrar {
|
|
|
217
217
|
error: {
|
|
218
218
|
componentName: spec.name,
|
|
219
219
|
error: `Component already registered in ${namespace}/${version}`,
|
|
220
|
-
phase: 'registration'
|
|
221
|
-
}
|
|
220
|
+
phase: 'registration',
|
|
221
|
+
},
|
|
222
222
|
};
|
|
223
223
|
}
|
|
224
|
-
const validLibraries = spec.libraries?.filter(lib => {
|
|
224
|
+
const validLibraries = spec.libraries?.filter((lib) => {
|
|
225
225
|
if (!lib || typeof lib !== 'object')
|
|
226
226
|
return false;
|
|
227
227
|
if (!lib.name || lib.name === 'unknown' || lib.name === 'null' || lib.name === 'undefined')
|
|
@@ -230,11 +230,11 @@ class ComponentHierarchyRegistrar {
|
|
|
230
230
|
return false;
|
|
231
231
|
return true;
|
|
232
232
|
});
|
|
233
|
-
if (!(0,
|
|
234
|
-
(0,
|
|
233
|
+
if (!(0, global_1.GetProductionStatus)()) {
|
|
234
|
+
(0, global_1.LogStatus)(`🔧 Compiling component ${spec.name} with libraries:`, undefined, {
|
|
235
235
|
originalCount: spec.libraries?.length || 0,
|
|
236
236
|
filteredCount: validLibraries?.length || 0,
|
|
237
|
-
libraries: validLibraries?.map(l => l.name) || []
|
|
237
|
+
libraries: validLibraries?.map((l) => l.name) || [],
|
|
238
238
|
});
|
|
239
239
|
}
|
|
240
240
|
const compileOptions = {
|
|
@@ -243,7 +243,7 @@ class ComponentHierarchyRegistrar {
|
|
|
243
243
|
styles,
|
|
244
244
|
libraries: validLibraries,
|
|
245
245
|
dependencies: spec.dependencies,
|
|
246
|
-
allLibraries: options.allLibraries
|
|
246
|
+
allLibraries: options.allLibraries,
|
|
247
247
|
};
|
|
248
248
|
const compilationResult = await this.compiler.compile(compileOptions);
|
|
249
249
|
if (!compilationResult.success) {
|
|
@@ -252,8 +252,8 @@ class ComponentHierarchyRegistrar {
|
|
|
252
252
|
error: {
|
|
253
253
|
componentName: spec.name,
|
|
254
254
|
error: compilationResult.error?.message || 'Unknown compilation error',
|
|
255
|
-
phase: 'compilation'
|
|
256
|
-
}
|
|
255
|
+
phase: 'compilation',
|
|
256
|
+
},
|
|
257
257
|
};
|
|
258
258
|
}
|
|
259
259
|
if (compilationResult.loadedLibraries && compilationResult.loadedLibraries.size > 0) {
|
|
@@ -262,16 +262,16 @@ class ComponentHierarchyRegistrar {
|
|
|
262
262
|
}
|
|
263
263
|
compilationResult.loadedLibraries.forEach((value, key) => {
|
|
264
264
|
this.runtimeContext.libraries[key] = value;
|
|
265
|
-
if (!(0,
|
|
266
|
-
(0,
|
|
265
|
+
if (!(0, global_1.GetProductionStatus)()) {
|
|
266
|
+
(0, global_1.LogStatus)(`✅ [registerSingleComponent] Added ${key} to runtime context libraries`);
|
|
267
267
|
}
|
|
268
268
|
});
|
|
269
269
|
}
|
|
270
|
-
if (!(0,
|
|
271
|
-
(0,
|
|
270
|
+
if (!(0, global_1.GetProductionStatus)()) {
|
|
271
|
+
(0, global_1.LogStatus)(`🏭 Calling factory for ${spec.name} with runtime context:`, undefined, {
|
|
272
272
|
hasReact: !!this.runtimeContext.React,
|
|
273
273
|
hasReactDOM: !!this.runtimeContext.ReactDOM,
|
|
274
|
-
libraryCount: Object.keys(this.runtimeContext.libraries || {}).length
|
|
274
|
+
libraryCount: Object.keys(this.runtimeContext.libraries || {}).length,
|
|
275
275
|
});
|
|
276
276
|
}
|
|
277
277
|
const componentObject = compilationResult.component.factory(this.runtimeContext, styles);
|
|
@@ -284,8 +284,8 @@ class ComponentHierarchyRegistrar {
|
|
|
284
284
|
error: {
|
|
285
285
|
componentName: spec.name,
|
|
286
286
|
error: error instanceof Error ? error.message : String(error),
|
|
287
|
-
phase: 'registration'
|
|
288
|
-
}
|
|
287
|
+
phase: 'registration',
|
|
288
|
+
},
|
|
289
289
|
};
|
|
290
290
|
}
|
|
291
291
|
}
|
|
@@ -296,7 +296,7 @@ class ComponentHierarchyRegistrar {
|
|
|
296
296
|
namespace: options.namespace,
|
|
297
297
|
version: options.version,
|
|
298
298
|
allowOverride: options.allowOverride,
|
|
299
|
-
allLibraries: options.allLibraries
|
|
299
|
+
allLibraries: options.allLibraries,
|
|
300
300
|
});
|
|
301
301
|
if (childResult.success) {
|
|
302
302
|
if (child.code) {
|
|
@@ -338,7 +338,7 @@ function validateComponentSpec(spec) {
|
|
|
338
338
|
const children = spec.dependencies || [];
|
|
339
339
|
children.forEach((child, index) => {
|
|
340
340
|
const childErrors = validateComponentSpec(child);
|
|
341
|
-
childErrors.forEach(error => {
|
|
341
|
+
childErrors.forEach((error) => {
|
|
342
342
|
errors.push(`Child ${index} (${child.name || 'unnamed'}): ${error}`);
|
|
343
343
|
});
|
|
344
344
|
});
|
|
@@ -348,7 +348,7 @@ exports.validateComponentSpec = validateComponentSpec;
|
|
|
348
348
|
function flattenComponentHierarchy(rootSpec) {
|
|
349
349
|
const components = [rootSpec];
|
|
350
350
|
const children = rootSpec.dependencies || [];
|
|
351
|
-
children.forEach(child => {
|
|
351
|
+
children.forEach((child) => {
|
|
352
352
|
components.push(...flattenComponentHierarchy(child));
|
|
353
353
|
});
|
|
354
354
|
return components;
|
|
@@ -360,7 +360,7 @@ function countComponentsInHierarchy(rootSpec, includeEmpty = false) {
|
|
|
360
360
|
count = 1;
|
|
361
361
|
}
|
|
362
362
|
const children = rootSpec.dependencies || [];
|
|
363
|
-
children.forEach(child => {
|
|
363
|
+
children.forEach((child) => {
|
|
364
364
|
count += countComponentsInHierarchy(child, includeEmpty);
|
|
365
365
|
});
|
|
366
366
|
return count;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-hierarchy.js","sourceRoot":"","sources":["../../src/runtime/component-hierarchy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,+CAA0F;AAkD1F,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;IAKI,KAAK,CAAC,sBAAsB,CAClC,IAAmB,EACnB,WAAsB;QAEtB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,eAAQ,EAAE,QAAQ,CAAC;YACpC,IAAI,CAAC,QAAQ,IAAI,CAAE,QAAgB,CAAC,UAAU,EAAE,CAAC;gBAC/C,OAAO,CAAC,IAAI,CAAC,4FAA4F,CAAC,CAAC;gBAC3G,OAAO,IAAI,CAAC;YACd,CAAC;YAGD,MAAM,EAAE,8BAA8B,EAAE,GAAG,wDAAa,sCAAsC,GAAC,CAAC;YAChG,MAAM,aAAa,GAAG,IAAI,8BAA8B,CAAC,QAAe,CAAC,CAAC;YAE1E,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,oBAAoB,CAAC;gBACxD,YAAY,EAAE,IAAI,CAAC,Q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AY,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, Metadata, LogStatus, GetProductionStatus } 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 /** The fully resolved component specification with all dependencies and libraries */\n resolvedSpec?: ComponentSpec;\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 debug?: boolean;\n /** Optional user context for fetching from external registries */\n contextUser?: UserInfo;\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 * Fetches a component specification from an external registry\n */\n private async fetchExternalComponent(\n spec: ComponentSpec,\n contextUser?: UserInfo\n ): Promise<ComponentSpec | null> {\n try {\n const provider = Metadata?.Provider;\n if (!provider || !(provider as any).ExecuteGQL) {\n console.warn('⚠️ [ComponentHierarchyRegistrar] No GraphQL provider available for external registry fetch');\n return null;\n }\n \n // Dynamically import the GraphQL client to avoid circular dependencies\n const { GraphQLComponentRegistryClient } = await import('@memberjunction/graphql-dataprovider');\n const graphQLClient = new GraphQLComponentRegistryClient(provider as any);\n \n const fullSpec = await graphQLClient.GetRegistryComponent({\n registryName: spec.registry!,\n namespace: spec.namespace || 'Global',\n name: spec.name,\n version: spec.version || 'latest'\n });\n\n if (fullSpec && fullSpec.code) {\n if (!GetProductionStatus()) {\n LogStatus(`✅ [ComponentHierarchyRegistrar] Fetched external component ${spec.name} with code (${fullSpec.code.length} chars)`);\n }\n return fullSpec;\n } else {\n console.warn(`⚠️ [ComponentHierarchyRegistrar] Failed to fetch external component ${spec.name} or no code`);\n return null;\n }\n } catch (error) {\n console.error(`❌ [ComponentHierarchyRegistrar] Error fetching external component ${spec.name}:`, error);\n return null;\n }\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 // If this is an external registry component without code, fetch it first\n let resolvedRootSpec = rootSpec;\n if (rootSpec.location === 'registry' && rootSpec.registry && !rootSpec.code) {\n if (!GetProductionStatus()) {\n LogStatus(`🌐 [ComponentHierarchyRegistrar] Fetching external registry component: ${rootSpec.registry}/${rootSpec.name}`);\n }\n resolvedRootSpec = await this.fetchExternalComponent(rootSpec, options.contextUser) || rootSpec;\n }\n const {\n styles,\n namespace = 'Global',\n version = 'v1',\n continueOnError = true,\n allowOverride = true\n } = options;\n\n const registeredComponents: string[] = [];\n const errors: ComponentRegistrationError[] = [];\n const warnings: string[] = [];\n\n if (!GetProductionStatus()) {\n LogStatus('🌳 ComponentHierarchyRegistrar.registerHierarchy:', undefined, {\n rootComponent: resolvedRootSpec.name,\n hasLibraries: !!(resolvedRootSpec.libraries && resolvedRootSpec.libraries.length > 0),\n libraryCount: resolvedRootSpec.libraries?.length || 0\n });\n }\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 const allLoadedLibraries = new Map<string, any>(); // Track all loaded libraries\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 // Filter out invalid library entries before compilation\n const validLibraries = spec.libraries?.filter(lib => {\n if (!lib || typeof lib !== 'object') return false;\n if (!lib.name || lib.name === 'unknown' || lib.name === 'null' || lib.name === 'undefined') return false;\n if (!lib.globalVariable || lib.globalVariable === 'undefined' || lib.globalVariable === 'null') return false;\n return true;\n });\n \n const compileOptions: CompileOptions = {\n componentName: spec.name,\n componentCode: spec.code,\n styles,\n libraries: validLibraries,\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 \n // Extract and accumulate loaded libraries from the compilation\n if (result.loadedLibraries) {\n result.loadedLibraries.forEach((value, key) => {\n if (!allLoadedLibraries.has(key)) {\n allLoadedLibraries.set(key, value);\n if (!GetProductionStatus()) {\n LogStatus(`📚 [registerHierarchy] Added library ${key} to accumulated libraries`);\n }\n }\n });\n }\n \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 = [resolvedRootSpec];\n const visited = new Set<string>();\n \n while (compileQueue.length > 0) {\n let spec = compileQueue.shift()!;\n if (visited.has(spec.name)) continue;\n visited.add(spec.name);\n \n // If this is an external registry component without code, fetch it first\n if (spec.location === 'registry' && spec.registry && !spec.code) {\n const fetched = await this.fetchExternalComponent(spec, options.contextUser);\n if (fetched) {\n spec = fetched;\n } else {\n console.warn(`⚠️ [ComponentHierarchyRegistrar] Could not fetch external component ${spec.name}, skipping`);\n continue;\n }\n }\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, resolvedSpec: resolvedRootSpec };\n }\n }\n \n if (spec.dependencies) {\n compileQueue.push(...spec.dependencies);\n }\n }\n \n // Add all accumulated libraries to runtime context\n if (allLoadedLibraries.size > 0) {\n if (!this.runtimeContext.libraries) {\n this.runtimeContext.libraries = {};\n }\n allLoadedLibraries.forEach((value, key) => {\n this.runtimeContext.libraries![key] = value;\n if (!GetProductionStatus()) {\n LogStatus(`✅ [registerHierarchy] Added ${key} to runtime context libraries`);\n }\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 resolvedSpec: resolvedRootSpec\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 // Filter out invalid library entries before compilation\n const validLibraries = spec.libraries?.filter(lib => {\n if (!lib || typeof lib !== 'object') return false;\n if (!lib.name || lib.name === 'unknown' || lib.name === 'null' || lib.name === 'undefined') return false;\n if (!lib.globalVariable || lib.globalVariable === 'undefined' || lib.globalVariable === 'null') return false;\n return true;\n });\n\n if (!GetProductionStatus()) {\n LogStatus(`🔧 Compiling component ${spec.name} with libraries:`, undefined, {\n originalCount: spec.libraries?.length || 0,\n filteredCount: validLibraries?.length || 0,\n libraries: validLibraries?.map(l => l.name) || []\n });\n }\n\n // Compile the component\n const compileOptions: CompileOptions = {\n componentName: spec.name,\n componentCode: spec.code,\n styles,\n libraries: validLibraries, // Pass along filtered library dependencies\n dependencies: spec.dependencies, // Pass along child component dependencies\n allLibraries: options.allLibraries\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 // Add loaded libraries to runtime context\n if (compilationResult.loadedLibraries && compilationResult.loadedLibraries.size > 0) {\n if (!this.runtimeContext.libraries) {\n this.runtimeContext.libraries = {};\n }\n compilationResult.loadedLibraries.forEach((value, key) => {\n this.runtimeContext.libraries![key] = value;\n if (!GetProductionStatus()) {\n LogStatus(`✅ [registerSingleComponent] Added ${key} to runtime context libraries`);\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 if (!GetProductionStatus()) {\n LogStatus(`🏭 Calling factory for ${spec.name} with runtime context:`, undefined, {\n hasReact: !!this.runtimeContext.React,\n hasReactDOM: !!this.runtimeContext.ReactDOM,\n libraryCount: Object.keys(this.runtimeContext.libraries || {}).length\n });\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
|
+
{"version":3,"file":"component-hierarchy.js","sourceRoot":"","sources":["../../src/runtime/component-hierarchy.ts"],"names":[],"mappings":";;;;;;;;;;;;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;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AA3BD,sDA2BC;AAOD,SAAgB,yBAAyB,CAAC,QAAuB;IAC/D,MAAM,UAAU,GAAoB,CAAC,QAAQ,CAAC,CAAC;IAE/C,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,IAAI,EAAE,CAAC;IAC7C,QAAQ,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACzB,UAAU,CAAC,IAAI,CAAC,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACpB,CAAC;AATD,8DASC;AAQD,SAAgB,0BAA0B,CAAC,QAAuB,EAAE,eAAwB,KAAK;IAC/F,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,CAAC,KAAK,EAAE,EAAE;QACzB,KAAK,IAAI,0BAA0B,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC;AAbD,gEAaC","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 { CompilationResult, CompileOptions, RuntimeContext, CompiledComponent } from '../types';\nimport { ComponentCompiler } from '../compiler';\nimport { ComponentRegistry } from '../registry';\n\nimport { ComponentSpec, ComponentStyles } from '@memberjunction/interactive-component-types';\nimport { UserInfo, Metadata, LogStatus, GetProductionStatus } from '@memberjunction/global';\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 /** The fully resolved component specification with all dependencies and libraries */\n resolvedSpec?: ComponentSpec;\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 debug?: boolean;\n /** Optional user context for fetching from external registries */\n contextUser?: UserInfo;\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 * Fetches a component specification from an external registry\n */\n private async fetchExternalComponent(spec: ComponentSpec, contextUser?: UserInfo): Promise<ComponentSpec | null> {\n try {\n const provider = Metadata?.Provider;\n if (!provider || !(provider as any).ExecuteGQL) {\n console.warn('⚠️ [ComponentHierarchyRegistrar] No GraphQL provider available for external registry fetch');\n return null;\n }\n\n // Dynamically import the GraphQL client to avoid circular dependencies\n const { GraphQLComponentRegistryClient } = await import('@memberjunction/graphql-dataprovider');\n const graphQLClient = new GraphQLComponentRegistryClient(provider as any);\n\n const fullSpec = await graphQLClient.GetRegistryComponent({\n registryName: spec.registry!,\n namespace: spec.namespace || 'Global',\n name: spec.name,\n version: spec.version || 'latest',\n });\n\n if (fullSpec && fullSpec.code) {\n if (!GetProductionStatus()) {\n LogStatus(`✅ [ComponentHierarchyRegistrar] Fetched external component ${spec.name} with code (${fullSpec.code.length} chars)`);\n }\n return fullSpec;\n } else {\n console.warn(`⚠️ [ComponentHierarchyRegistrar] Failed to fetch external component ${spec.name} or no code`);\n return null;\n }\n } catch (error) {\n console.error(`❌ [ComponentHierarchyRegistrar] Error fetching external component ${spec.name}:`, error);\n return null;\n }\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(rootSpec: ComponentSpec, options: HierarchyRegistrationOptions): Promise<HierarchyRegistrationResult> {\n // If this is an external registry component without code, fetch it first\n let resolvedRootSpec = rootSpec;\n if (rootSpec.location === 'registry' && rootSpec.registry && !rootSpec.code) {\n if (!GetProductionStatus()) {\n LogStatus(`🌐 [ComponentHierarchyRegistrar] Fetching external registry component: ${rootSpec.registry}/${rootSpec.name}`);\n }\n resolvedRootSpec = (await this.fetchExternalComponent(rootSpec, options.contextUser)) || rootSpec;\n }\n const { styles, namespace = 'Global', version = 'v1', continueOnError = true, allowOverride = true } = options;\n\n const registeredComponents: string[] = [];\n const errors: ComponentRegistrationError[] = [];\n const warnings: string[] = [];\n\n if (!GetProductionStatus()) {\n LogStatus('🌳 ComponentHierarchyRegistrar.registerHierarchy:', undefined, {\n rootComponent: resolvedRootSpec.name,\n hasLibraries: !!(resolvedRootSpec.libraries && resolvedRootSpec.libraries.length > 0),\n libraryCount: resolvedRootSpec.libraries?.length || 0,\n });\n }\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 const allLoadedLibraries = new Map<string, any>(); // Track all loaded libraries\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 // Filter out invalid library entries before compilation\n const validLibraries = spec.libraries?.filter((lib) => {\n if (!lib || typeof lib !== 'object') return false;\n if (!lib.name || lib.name === 'unknown' || lib.name === 'null' || lib.name === 'undefined') return false;\n if (!lib.globalVariable || lib.globalVariable === 'undefined' || lib.globalVariable === 'null') return false;\n return true;\n });\n\n const compileOptions: CompileOptions = {\n componentName: spec.name,\n componentCode: spec.code,\n styles,\n libraries: validLibraries,\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\n // Extract and accumulate loaded libraries from the compilation\n if (result.loadedLibraries) {\n result.loadedLibraries.forEach((value, key) => {\n if (!allLoadedLibraries.has(key)) {\n allLoadedLibraries.set(key, value);\n if (!GetProductionStatus()) {\n LogStatus(`📚 [registerHierarchy] Added library ${key} to accumulated libraries`);\n }\n }\n });\n }\n\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 = [resolvedRootSpec];\n const visited = new Set<string>();\n\n while (compileQueue.length > 0) {\n let spec = compileQueue.shift()!;\n if (visited.has(spec.name)) continue;\n visited.add(spec.name);\n\n // If this is an external registry component without code, fetch it first\n if (spec.location === 'registry' && spec.registry && !spec.code) {\n const fetched = await this.fetchExternalComponent(spec, options.contextUser);\n if (fetched) {\n spec = fetched;\n } else {\n console.warn(`⚠️ [ComponentHierarchyRegistrar] Could not fetch external component ${spec.name}, skipping`);\n continue;\n }\n }\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, resolvedSpec: resolvedRootSpec };\n }\n }\n\n if (spec.dependencies) {\n compileQueue.push(...spec.dependencies);\n }\n }\n\n // Add all accumulated libraries to runtime context\n if (allLoadedLibraries.size > 0) {\n if (!this.runtimeContext.libraries) {\n this.runtimeContext.libraries = {};\n }\n allLoadedLibraries.forEach((value, key) => {\n this.runtimeContext.libraries![key] = value;\n if (!GetProductionStatus()) {\n LogStatus(`✅ [registerHierarchy] Added ${key} to runtime context libraries`);\n }\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(spec.name, componentObject, spec.namespace || namespace, version);\n\n registeredComponents.push(spec.name);\n }\n\n return {\n success: errors.length === 0,\n registeredComponents,\n errors,\n warnings,\n resolvedSpec: resolvedRootSpec,\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 // Filter out invalid library entries before compilation\n const validLibraries = spec.libraries?.filter((lib) => {\n if (!lib || typeof lib !== 'object') return false;\n if (!lib.name || lib.name === 'unknown' || lib.name === 'null' || lib.name === 'undefined') return false;\n if (!lib.globalVariable || lib.globalVariable === 'undefined' || lib.globalVariable === 'null') return false;\n return true;\n });\n\n if (!GetProductionStatus()) {\n LogStatus(`🔧 Compiling component ${spec.name} with libraries:`, undefined, {\n originalCount: spec.libraries?.length || 0,\n filteredCount: validLibraries?.length || 0,\n libraries: validLibraries?.map((l) => l.name) || [],\n });\n }\n\n // Compile the component\n const compileOptions: CompileOptions = {\n componentName: spec.name,\n componentCode: spec.code,\n styles,\n libraries: validLibraries, // Pass along filtered library dependencies\n dependencies: spec.dependencies, // Pass along child component dependencies\n allLibraries: options.allLibraries,\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 // Add loaded libraries to runtime context\n if (compilationResult.loadedLibraries && compilationResult.loadedLibraries.size > 0) {\n if (!this.runtimeContext.libraries) {\n this.runtimeContext.libraries = {};\n }\n compilationResult.loadedLibraries.forEach((value, key) => {\n this.runtimeContext.libraries![key] = value;\n if (!GetProductionStatus()) {\n LogStatus(`✅ [registerSingleComponent] Added ${key} to runtime context libraries`);\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 if (!GetProductionStatus()) {\n LogStatus(`🏭 Calling factory for ${spec.name} with runtime context:`, undefined, {\n hasReact: !!this.runtimeContext.React,\n hasReactDOM: !!this.runtimeContext.ReactDOM,\n libraryCount: Object.keys(this.runtimeContext.libraries || {}).length,\n });\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(spec.name, componentObject, spec.namespace || namespace, version);\n\n return { success: true };\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(nestedChildren, options, registeredComponents, errors, warnings);\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(rootSpec: ComponentSpec, includeEmpty: boolean = false): 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}\n"]}
|
|
@@ -1 +1 @@
|
|
|
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;AAO1C,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,kBA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M,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,CAkBhG;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,CAAC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,cAAc,KAAK,cAAc,CAyBtI;AAQD,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,GAAG,kBAAkB,CAoDjH;AAOD,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,CAchE"}
|
|
@@ -1,13 +1,13 @@
|
|
|
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
|
-
const
|
|
4
|
+
const global_1 = require("@memberjunction/global");
|
|
5
5
|
function buildComponentProps(data = {}, userState = {}, utilities = {}, callbacks = {
|
|
6
6
|
OpenEntityRecord: () => { },
|
|
7
7
|
RegisterMethod: () => { },
|
|
8
|
-
CreateSimpleNotification: () => { }
|
|
8
|
+
CreateSimpleNotification: () => { },
|
|
9
9
|
}, components = {}, styles, options = {}, onStateChanged) {
|
|
10
|
-
const { validate = true, transformData, transformState, debounceUpdateUserState = 3000 } = options;
|
|
10
|
+
const { validate = true, transformData, transformState, debounceUpdateUserState = 3000, } = options;
|
|
11
11
|
const transformedData = transformData ? transformData(data) : data;
|
|
12
12
|
const transformedState = transformState ? transformState(userState) : userState;
|
|
13
13
|
const props = {
|
|
@@ -17,7 +17,7 @@ function buildComponentProps(data = {}, userState = {}, utilities = {}, callback
|
|
|
17
17
|
callbacks: normalizeCallbacks(callbacks, debounceUpdateUserState),
|
|
18
18
|
components,
|
|
19
19
|
styles: normalizeStyles(styles),
|
|
20
|
-
onStateChanged
|
|
20
|
+
onStateChanged,
|
|
21
21
|
};
|
|
22
22
|
if (validate) {
|
|
23
23
|
validateComponentProps(props);
|
|
@@ -51,10 +51,10 @@ function normalizeCallbacks(callbacks, debounceMs = 3000) {
|
|
|
51
51
|
const normalized = {
|
|
52
52
|
OpenEntityRecord: callbacks?.OpenEntityRecord || (() => { }),
|
|
53
53
|
RegisterMethod: callbacks?.RegisterMethod || (() => { }),
|
|
54
|
-
CreateSimpleNotification: callbacks?.CreateSimpleNotification || (() => { })
|
|
54
|
+
CreateSimpleNotification: callbacks?.CreateSimpleNotification || (() => { }),
|
|
55
55
|
};
|
|
56
56
|
if (callbacks) {
|
|
57
|
-
Object.keys(callbacks).forEach(key => {
|
|
57
|
+
Object.keys(callbacks).forEach((key) => {
|
|
58
58
|
if (typeof callbacks[key] === 'function' && !normalized.hasOwnProperty(key)) {
|
|
59
59
|
normalized[key] = callbacks[key];
|
|
60
60
|
}
|
|
@@ -94,7 +94,7 @@ function mergeProps(...propsList) {
|
|
|
94
94
|
utilities: {},
|
|
95
95
|
callbacks: {},
|
|
96
96
|
components: {},
|
|
97
|
-
styles: {}
|
|
97
|
+
styles: {},
|
|
98
98
|
};
|
|
99
99
|
for (const props of propsList) {
|
|
100
100
|
if (props.data) {
|
|
@@ -144,13 +144,16 @@ function wrapCallbacksWithLogging(callbacks, componentName) {
|
|
|
144
144
|
const wrapped = {
|
|
145
145
|
OpenEntityRecord: callbacks?.OpenEntityRecord || (() => { }),
|
|
146
146
|
RegisterMethod: callbacks?.RegisterMethod || (() => { }),
|
|
147
|
-
CreateSimpleNotification: callbacks?.CreateSimpleNotification || (() => { })
|
|
147
|
+
CreateSimpleNotification: callbacks?.CreateSimpleNotification || (() => { }),
|
|
148
148
|
};
|
|
149
|
-
Object.keys(callbacks).forEach(key => {
|
|
150
|
-
if (key !== 'OpenEntityRecord' &&
|
|
149
|
+
Object.keys(callbacks).forEach((key) => {
|
|
150
|
+
if (key !== 'OpenEntityRecord' &&
|
|
151
|
+
key !== 'RegisterMethod' &&
|
|
152
|
+
key !== 'CreateSimpleNotification' &&
|
|
153
|
+
typeof callbacks[key] === 'function') {
|
|
151
154
|
wrapped[key] = (...args) => {
|
|
152
|
-
if (!(0,
|
|
153
|
-
(0,
|
|
155
|
+
if (!(0, global_1.GetProductionStatus)()) {
|
|
156
|
+
(0, global_1.LogStatus)(`[${componentName}] ${key} called with args:`, undefined, args);
|
|
154
157
|
}
|
|
155
158
|
return callbacks[key](...args);
|
|
156
159
|
};
|
|
@@ -158,24 +161,24 @@ function wrapCallbacksWithLogging(callbacks, componentName) {
|
|
|
158
161
|
});
|
|
159
162
|
if (callbacks.OpenEntityRecord) {
|
|
160
163
|
wrapped.OpenEntityRecord = (entityName, key) => {
|
|
161
|
-
if (!(0,
|
|
162
|
-
(0,
|
|
164
|
+
if (!(0, global_1.GetProductionStatus)()) {
|
|
165
|
+
(0, global_1.LogStatus)(`[${componentName}] OpenEntityRecord called:`, undefined, { entityName, key });
|
|
163
166
|
}
|
|
164
167
|
callbacks.OpenEntityRecord(entityName, key);
|
|
165
168
|
};
|
|
166
169
|
}
|
|
167
170
|
if (callbacks.RegisterMethod) {
|
|
168
171
|
wrapped.RegisterMethod = (methodName, handler) => {
|
|
169
|
-
if (!(0,
|
|
170
|
-
(0,
|
|
172
|
+
if (!(0, global_1.GetProductionStatus)()) {
|
|
173
|
+
(0, global_1.LogStatus)(`[${componentName}] RegisterMethod called for:`, undefined, methodName);
|
|
171
174
|
}
|
|
172
175
|
callbacks.RegisterMethod(methodName, handler);
|
|
173
176
|
};
|
|
174
177
|
}
|
|
175
178
|
if (callbacks.CreateSimpleNotification) {
|
|
176
179
|
wrapped.CreateSimpleNotification = (message, style, hideAfter) => {
|
|
177
|
-
if (!(0,
|
|
178
|
-
(0,
|
|
180
|
+
if (!(0, global_1.GetProductionStatus)()) {
|
|
181
|
+
(0, global_1.LogStatus)(`[${componentName}] CreateSimpleNotification called:`, undefined, { message, style, hideAfter });
|
|
179
182
|
}
|
|
180
183
|
callbacks.CreateSimpleNotification(message, style, hideAfter);
|
|
181
184
|
};
|
|
@@ -185,12 +188,7 @@ function wrapCallbacksWithLogging(callbacks, componentName) {
|
|
|
185
188
|
exports.wrapCallbacksWithLogging = wrapCallbacksWithLogging;
|
|
186
189
|
function extractPropPaths(componentCode) {
|
|
187
190
|
const paths = [];
|
|
188
|
-
const patterns = [
|
|
189
|
-
/props\.data\.(\w+)/g,
|
|
190
|
-
/props\.userState\.(\w+)/g,
|
|
191
|
-
/props\.utilities\.(\w+)/g,
|
|
192
|
-
/props\.callbacks\.(\w+)/g
|
|
193
|
-
];
|
|
191
|
+
const patterns = [/props\.data\.(\w+)/g, /props\.userState\.(\w+)/g, /props\.utilities\.(\w+)/g, /props\.callbacks\.(\w+)/g];
|
|
194
192
|
for (const pattern of patterns) {
|
|
195
193
|
let match;
|
|
196
194
|
while ((match = pattern.exec(componentCode)) !== null) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prop-builder.js","sourceRoot":"","sources":["../../src/runtime/prop-builder.ts"],"names":[],"mappings":";;;AASA,+CAAsE;AA6BtE,SAAgB,mBAAmB,CACjC,OAAY,EAAE,EACd,YAAiB,EAAE,EACnB,YAAiB,EAAE,EACn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J,CAAC;IAED,IAAI,SAAS,CAAC,wBAAwB,EAAE,CAAC;QACvC,OAAO,CAAC,wBAAwB,GAAG,CAAC,OAAe,EAAE,KAAwD,EAAE,SAAkB,EAAE,EAAE;YACnI,IAAI,CAAC,IAAA,0BAAmB,GAAE,EAAE,CAAC;gBAC3B,IAAA,gBAAS,EAAC,IAAI,aAAa,oCAAoC,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;YAC7G,CAAC;YACD,SAAS,CAAC,wBAAyB,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;QACjE,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAlDD,4DAkDC;AAOD,SAAgB,gBAAgB,CAAC,aAAqB;IACpD,MAAM,KAAK,GAAa,EAAE,CAAC;IAG3B,MAAM,QAAQ,GAAG;QACf,qBAAqB;QACrB,0BAA0B;QAC1B,0BAA0B;QAC1B,0BAA0B;KAC3B,CAAC;IAEF,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,KAAK,CAAC;QACV,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YACtD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7B,CAAC;AAnBD,4CAmBC","sourcesContent":["/**\n * @fileoverview Props builder utilities for React components.\n * Provides utilities for constructing and validating component props.\n * @module @memberjunction/react-runtime/runtime\n */\n\nimport { ComponentStyles, ComponentCallbacks } from '@memberjunction/interactive-component-types';\nimport { ComponentProps } from '../types';\nimport { Subject, debounceTime, Subscription } from 'rxjs';\nimport { LogStatus, GetProductionStatus } from '@memberjunction/core';\n\n/**\n * Options for building component props\n */\nexport interface PropBuilderOptions {\n /** Validate props before building */\n validate?: boolean;\n /** Merge with existing props */\n merge?: boolean;\n /** Transform data before passing to component */\n transformData?: (data: any) => any;\n /** Transform state before passing to component */\n transformState?: (state: any) => any;\n /** Debounce time for UpdateUserState callback in milliseconds */\n debounceUpdateUserState?: number;\n}\n\n/**\n * Builds component props from various sources\n * @param data - Component data\n * @param userState - User state object\n * @param utilities - Utility functions\n * @param callbacks - Component callbacks\n * @param components - Child components\n * @param styles - Component styles\n * @param options - Builder options\n * @returns Built component props\n */\nexport function buildComponentProps(\n data: any = {},\n userState: any = {},\n utilities: any = {},\n callbacks: ComponentCallbacks = {\n OpenEntityRecord: () => {},\n RegisterMethod: () => {},\n CreateSimpleNotification: () => {}\n },\n components: Record<string, any> = {},\n styles?: ComponentStyles,\n options: PropBuilderOptions = {},\n onStateChanged?: (stateUpdate: Record<string, any>) => void\n): ComponentProps {\n const {\n validate = true,\n transformData,\n transformState,\n debounceUpdateUserState = 3000 // Default 3 seconds\n } = options;\n\n // Transform data if transformer provided\n const transformedData = transformData ? transformData(data) : data;\n const transformedState = transformState ? transformState(userState) : userState;\n\n // Build props object\n const props: ComponentProps = {\n data: transformedData,\n userState: transformedState,\n utilities,\n callbacks: normalizeCallbacks(callbacks, debounceUpdateUserState),\n components,\n styles: normalizeStyles(styles),\n onStateChanged\n };\n\n // Validate if enabled\n if (validate) {\n validateComponentProps(props);\n }\n\n return props;\n}\n\n// Store subjects for debouncing per component instance\nconst updateUserStateSubjects = new WeakMap<Function, Subject<any>>();\n\n// Store subscriptions for cleanup\nconst updateUserStateSubscriptions = new WeakMap<Function, Subscription>();\n\n// Loop detection state\ninterface LoopDetectionState {\n count: number;\n lastUpdate: number;\n lastState: any;\n}\nconst loopDetectionStates = new WeakMap<Function, LoopDetectionState>();\n\n// Deep equality check for objects\nfunction deepEqual(obj1: any, obj2: any): boolean {\n if (obj1 === obj2) return true;\n \n if (!obj1 || !obj2) return false;\n if (typeof obj1 !== 'object' || typeof obj2 !== 'object') return false;\n \n const keys1 = Object.keys(obj1);\n const keys2 = Object.keys(obj2);\n \n if (keys1.length !== keys2.length) return false;\n \n for (const key of keys1) {\n if (!keys2.includes(key)) return false;\n if (!deepEqual(obj1[key], obj2[key])) return false;\n }\n \n return true;\n}\n\n/**\n * Normalizes component callbacks\n * @param callbacks - Raw callbacks object\n * @param debounceMs - Debounce time for UpdateUserState in milliseconds\n * @returns Normalized callbacks\n */\nexport function normalizeCallbacks(callbacks: any, debounceMs: number = 3000): ComponentCallbacks {\n // Provide default implementations for required callbacks\n const normalized: ComponentCallbacks = {\n OpenEntityRecord: callbacks?.OpenEntityRecord || (() => {}),\n RegisterMethod: callbacks?.RegisterMethod || (() => {}),\n CreateSimpleNotification: callbacks?.CreateSimpleNotification || (() => {})\n };\n\n // Copy any additional callbacks that might exist\n if (callbacks) {\n Object.keys(callbacks).forEach(key => {\n if (typeof callbacks[key] === 'function' && !normalized.hasOwnProperty(key)) {\n (normalized as any)[key] = callbacks[key];\n }\n });\n }\n\n return normalized;\n}\n\n/**\n * Normalizes component styles\n * @param styles - Raw styles object\n * @returns Normalized styles\n */\nexport function normalizeStyles(styles?: any): any {\n // Pass through the full styles object as-is\n // This allows Skip components to access their full style structure\n // including colors, typography, borders, etc.\n return styles;\n}\n\n/**\n * Validates component props\n * @param props - Props to validate\n * @throws Error if validation fails\n */\nexport function validateComponentProps(props: ComponentProps): void {\n // Validate data\n if (props.data === null || props.data === undefined) {\n throw new Error('Component props.data cannot be null or undefined');\n }\n\n // Validate userState\n if (props.userState === null) {\n throw new Error('Component props.userState cannot be null');\n }\n\n // Validate utilities\n if (props.utilities === null) {\n throw new Error('Component props.utilities cannot be null');\n }\n\n // Validate callbacks\n if (!props.callbacks || typeof props.callbacks !== 'object') {\n throw new Error('Component props.callbacks must be an object');\n }\n\n // Validate callback functions\n for (const [key, value] of Object.entries(props.callbacks)) {\n if (value !== undefined && typeof value !== 'function') {\n throw new Error(`Component callback \"${key}\" must be a function`);\n }\n }\n}\n\n/**\n * Merges multiple prop objects\n * @param propsList - Array of props to merge\n * @returns Merged props\n */\nexport function mergeProps(...propsList: Partial<ComponentProps>[]): ComponentProps {\n const merged: ComponentProps = {\n data: {},\n userState: {},\n utilities: {},\n callbacks: {},\n components: {},\n styles: {} as ComponentStyles\n };\n\n for (const props of propsList) {\n if (props.data) {\n merged.data = { ...merged.data, ...props.data };\n }\n\n if (props.userState) {\n merged.userState = { ...merged.userState, ...props.userState };\n }\n\n if (props.utilities) {\n merged.utilities = { ...merged.utilities, ...props.utilities };\n }\n\n if (props.callbacks) {\n merged.callbacks = { ...merged.callbacks, ...props.callbacks };\n }\n\n if (props.components) {\n merged.components = { ...merged.components, ...props.components };\n }\n\n if (props.styles) {\n merged.styles = { ...merged.styles, ...props.styles };\n }\n }\n\n return merged;\n}\n \n/**\n * Creates a props transformer function\n * @param transformations - Map of prop paths to transformer functions\n * @returns Props transformer\n */\nexport function createPropsTransformer(\n transformations: Record<string, (value: any) => any>\n): (props: ComponentProps) => ComponentProps {\n return (props: ComponentProps) => {\n const transformed = { ...props };\n\n for (const [path, transformer] of Object.entries(transformations)) {\n const pathParts = path.split('.');\n let current: any = transformed;\n \n // Navigate to the parent of the target property\n for (let i = 0; i < pathParts.length - 1; i++) {\n if (!current[pathParts[i]]) {\n current[pathParts[i]] = {};\n }\n current = current[pathParts[i]];\n }\n\n // Apply transformation\n const lastPart = pathParts[pathParts.length - 1];\n if (current[lastPart] !== undefined) {\n current[lastPart] = transformer(current[lastPart]);\n }\n }\n\n return transformed;\n };\n}\n\n/**\n * Creates a callback wrapper that adds logging\n * @param callbacks - Original callbacks\n * @param componentName - Component name for logging\n * @returns Wrapped callbacks\n */\nexport function wrapCallbacksWithLogging(\n callbacks: ComponentCallbacks,\n componentName: string\n): ComponentCallbacks {\n const wrapped: ComponentCallbacks = {\n OpenEntityRecord: callbacks?.OpenEntityRecord || (() => {}),\n RegisterMethod: callbacks?.RegisterMethod || (() => {}),\n CreateSimpleNotification: callbacks?.CreateSimpleNotification || (() => {})\n };\n\n // Wrap any additional callbacks that might exist\n Object.keys(callbacks).forEach(key => {\n if (key !== 'OpenEntityRecord' && key !== 'RegisterMethod' && key !== 'CreateSimpleNotification' && typeof (callbacks as any)[key] === 'function') {\n (wrapped as any)[key] = (...args: any[]) => {\n if (!GetProductionStatus()) {\n LogStatus(`[${componentName}] ${key} called with args:`, undefined, args);\n }\n return (callbacks as any)[key](...args);\n };\n }\n });\n\n if (callbacks.OpenEntityRecord) {\n wrapped.OpenEntityRecord = (entityName: string, key: any) => {\n if (!GetProductionStatus()) {\n LogStatus(`[${componentName}] OpenEntityRecord called:`, undefined, { entityName, key });\n }\n callbacks.OpenEntityRecord!(entityName, key);\n };\n }\n\n if (callbacks.RegisterMethod) {\n wrapped.RegisterMethod = (methodName: any, handler: any) => {\n if (!GetProductionStatus()) {\n LogStatus(`[${componentName}] RegisterMethod called for:`, undefined, methodName);\n }\n callbacks.RegisterMethod!(methodName, handler);\n };\n }\n\n if (callbacks.CreateSimpleNotification) {\n wrapped.CreateSimpleNotification = (message: string, style: \"none\" | \"success\" | \"error\" | \"warning\" | \"info\", hideAfter?: number) => {\n if (!GetProductionStatus()) {\n LogStatus(`[${componentName}] CreateSimpleNotification called:`, undefined, { message, style, hideAfter });\n }\n callbacks.CreateSimpleNotification!(message, style, hideAfter);\n };\n }\n\n return wrapped;\n}\n\n/**\n * Extracts props paths used by a component\n * @param componentCode - Component source code\n * @returns Array of prop paths\n */\nexport function extractPropPaths(componentCode: string): string[] {\n const paths: string[] = [];\n \n // Simple regex patterns to find prop access\n const patterns = [\n /props\\.data\\.(\\w+)/g,\n /props\\.userState\\.(\\w+)/g,\n /props\\.utilities\\.(\\w+)/g,\n /props\\.callbacks\\.(\\w+)/g\n ];\n\n for (const pattern of patterns) {\n let match;\n while ((match = pattern.exec(componentCode)) !== null) {\n paths.push(match[0]);\n }\n }\n\n return [...new Set(paths)]; // Remove duplicates\n}"]}
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constructing and validating component props.\n * @module @memberjunction/react-runtime/runtime\n */\n\nimport { ComponentStyles, ComponentCallbacks } from '@memberjunction/interactive-component-types';\nimport { ComponentProps } from '../types';\nimport { Subject, debounceTime, Subscription } from 'rxjs';\nimport { LogStatus, GetProductionStatus } from '@memberjunction/global';\n\n/**\n * Options for building component props\n */\nexport interface PropBuilderOptions {\n /** Validate props before building */\n validate?: boolean;\n /** Merge with existing props */\n merge?: boolean;\n /** Transform data before passing to component */\n transformData?: (data: any) => any;\n /** Transform state before passing to component */\n transformState?: (state: any) => any;\n /** Debounce time for UpdateUserState callback in milliseconds */\n debounceUpdateUserState?: number;\n}\n\n/**\n * Builds component props from various sources\n * @param data - Component data\n * @param userState - User state object\n * @param utilities - Utility functions\n * @param callbacks - Component callbacks\n * @param components - Child components\n * @param styles - Component styles\n * @param options - Builder options\n * @returns Built component props\n */\nexport function buildComponentProps(\n data: any = {},\n userState: any = {},\n utilities: any = {},\n callbacks: ComponentCallbacks = {\n OpenEntityRecord: () => {},\n RegisterMethod: () => {},\n CreateSimpleNotification: () => {},\n },\n components: Record<string, any> = {},\n styles?: ComponentStyles,\n options: PropBuilderOptions = {},\n onStateChanged?: (stateUpdate: Record<string, any>) => void\n): ComponentProps {\n const {\n validate = true,\n transformData,\n transformState,\n debounceUpdateUserState = 3000, // Default 3 seconds\n } = options;\n\n // Transform data if transformer provided\n const transformedData = transformData ? transformData(data) : data;\n const transformedState = transformState ? transformState(userState) : userState;\n\n // Build props object\n const props: ComponentProps = {\n data: transformedData,\n userState: transformedState,\n utilities,\n callbacks: normalizeCallbacks(callbacks, debounceUpdateUserState),\n components,\n styles: normalizeStyles(styles),\n onStateChanged,\n };\n\n // Validate if enabled\n if (validate) {\n validateComponentProps(props);\n }\n\n return props;\n}\n\n// Store subjects for debouncing per component instance\nconst updateUserStateSubjects = new WeakMap<Function, Subject<any>>();\n\n// Store subscriptions for cleanup\nconst updateUserStateSubscriptions = new WeakMap<Function, Subscription>();\n\n// Loop detection state\ninterface LoopDetectionState {\n count: number;\n lastUpdate: number;\n lastState: any;\n}\nconst loopDetectionStates = new WeakMap<Function, LoopDetectionState>();\n\n// Deep equality check for objects\nfunction deepEqual(obj1: any, obj2: any): boolean {\n if (obj1 === obj2) return true;\n\n if (!obj1 || !obj2) return false;\n if (typeof obj1 !== 'object' || typeof obj2 !== 'object') return false;\n\n const keys1 = Object.keys(obj1);\n const keys2 = Object.keys(obj2);\n\n if (keys1.length !== keys2.length) return false;\n\n for (const key of keys1) {\n if (!keys2.includes(key)) return false;\n if (!deepEqual(obj1[key], obj2[key])) return false;\n }\n\n return true;\n}\n\n/**\n * Normalizes component callbacks\n * @param callbacks - Raw callbacks object\n * @param debounceMs - Debounce time for UpdateUserState in milliseconds\n * @returns Normalized callbacks\n */\nexport function normalizeCallbacks(callbacks: any, debounceMs: number = 3000): ComponentCallbacks {\n // Provide default implementations for required callbacks\n const normalized: ComponentCallbacks = {\n OpenEntityRecord: callbacks?.OpenEntityRecord || (() => {}),\n RegisterMethod: callbacks?.RegisterMethod || (() => {}),\n CreateSimpleNotification: callbacks?.CreateSimpleNotification || (() => {}),\n };\n\n // Copy any additional callbacks that might exist\n if (callbacks) {\n Object.keys(callbacks).forEach((key) => {\n if (typeof callbacks[key] === 'function' && !normalized.hasOwnProperty(key)) {\n (normalized as any)[key] = callbacks[key];\n }\n });\n }\n\n return normalized;\n}\n\n/**\n * Normalizes component styles\n * @param styles - Raw styles object\n * @returns Normalized styles\n */\nexport function normalizeStyles(styles?: any): any {\n // Pass through the full styles object as-is\n // This allows Skip components to access their full style structure\n // including colors, typography, borders, etc.\n return styles;\n}\n\n/**\n * Validates component props\n * @param props - Props to validate\n * @throws Error if validation fails\n */\nexport function validateComponentProps(props: ComponentProps): void {\n // Validate data\n if (props.data === null || props.data === undefined) {\n throw new Error('Component props.data cannot be null or undefined');\n }\n\n // Validate userState\n if (props.userState === null) {\n throw new Error('Component props.userState cannot be null');\n }\n\n // Validate utilities\n if (props.utilities === null) {\n throw new Error('Component props.utilities cannot be null');\n }\n\n // Validate callbacks\n if (!props.callbacks || typeof props.callbacks !== 'object') {\n throw new Error('Component props.callbacks must be an object');\n }\n\n // Validate callback functions\n for (const [key, value] of Object.entries(props.callbacks)) {\n if (value !== undefined && typeof value !== 'function') {\n throw new Error(`Component callback \"${key}\" must be a function`);\n }\n }\n}\n\n/**\n * Merges multiple prop objects\n * @param propsList - Array of props to merge\n * @returns Merged props\n */\nexport function mergeProps(...propsList: Partial<ComponentProps>[]): ComponentProps {\n const merged: ComponentProps = {\n data: {},\n userState: {},\n utilities: {},\n callbacks: {},\n components: {},\n styles: {} as ComponentStyles,\n };\n\n for (const props of propsList) {\n if (props.data) {\n merged.data = { ...merged.data, ...props.data };\n }\n\n if (props.userState) {\n merged.userState = { ...merged.userState, ...props.userState };\n }\n\n if (props.utilities) {\n merged.utilities = { ...merged.utilities, ...props.utilities };\n }\n\n if (props.callbacks) {\n merged.callbacks = { ...merged.callbacks, ...props.callbacks };\n }\n\n if (props.components) {\n merged.components = { ...merged.components, ...props.components };\n }\n\n if (props.styles) {\n merged.styles = { ...merged.styles, ...props.styles };\n }\n }\n\n return merged;\n}\n\n/**\n * Creates a props transformer function\n * @param transformations - Map of prop paths to transformer functions\n * @returns Props transformer\n */\nexport function createPropsTransformer(transformations: Record<string, (value: any) => any>): (props: ComponentProps) => ComponentProps {\n return (props: ComponentProps) => {\n const transformed = { ...props };\n\n for (const [path, transformer] of Object.entries(transformations)) {\n const pathParts = path.split('.');\n let current: any = transformed;\n\n // Navigate to the parent of the target property\n for (let i = 0; i < pathParts.length - 1; i++) {\n if (!current[pathParts[i]]) {\n current[pathParts[i]] = {};\n }\n current = current[pathParts[i]];\n }\n\n // Apply transformation\n const lastPart = pathParts[pathParts.length - 1];\n if (current[lastPart] !== undefined) {\n current[lastPart] = transformer(current[lastPart]);\n }\n }\n\n return transformed;\n };\n}\n\n/**\n * Creates a callback wrapper that adds logging\n * @param callbacks - Original callbacks\n * @param componentName - Component name for logging\n * @returns Wrapped callbacks\n */\nexport function wrapCallbacksWithLogging(callbacks: ComponentCallbacks, componentName: string): ComponentCallbacks {\n const wrapped: ComponentCallbacks = {\n OpenEntityRecord: callbacks?.OpenEntityRecord || (() => {}),\n RegisterMethod: callbacks?.RegisterMethod || (() => {}),\n CreateSimpleNotification: callbacks?.CreateSimpleNotification || (() => {}),\n };\n\n // Wrap any additional callbacks that might exist\n Object.keys(callbacks).forEach((key) => {\n if (\n key !== 'OpenEntityRecord' &&\n key !== 'RegisterMethod' &&\n key !== 'CreateSimpleNotification' &&\n typeof (callbacks as any)[key] === 'function'\n ) {\n (wrapped as any)[key] = (...args: any[]) => {\n if (!GetProductionStatus()) {\n LogStatus(`[${componentName}] ${key} called with args:`, undefined, args);\n }\n return (callbacks as any)[key](...args);\n };\n }\n });\n\n if (callbacks.OpenEntityRecord) {\n wrapped.OpenEntityRecord = (entityName: string, key: any) => {\n if (!GetProductionStatus()) {\n LogStatus(`[${componentName}] OpenEntityRecord called:`, undefined, { entityName, key });\n }\n callbacks.OpenEntityRecord!(entityName, key);\n };\n }\n\n if (callbacks.RegisterMethod) {\n wrapped.RegisterMethod = (methodName: any, handler: any) => {\n if (!GetProductionStatus()) {\n LogStatus(`[${componentName}] RegisterMethod called for:`, undefined, methodName);\n }\n callbacks.RegisterMethod!(methodName, handler);\n };\n }\n\n if (callbacks.CreateSimpleNotification) {\n wrapped.CreateSimpleNotification = (message: string, style: 'none' | 'success' | 'error' | 'warning' | 'info', hideAfter?: number) => {\n if (!GetProductionStatus()) {\n LogStatus(`[${componentName}] CreateSimpleNotification called:`, undefined, { message, style, hideAfter });\n }\n callbacks.CreateSimpleNotification!(message, style, hideAfter);\n };\n }\n\n return wrapped;\n}\n\n/**\n * Extracts props paths used by a component\n * @param componentCode - Component source code\n * @returns Array of prop paths\n */\nexport function extractPropPaths(componentCode: string): string[] {\n const paths: string[] = [];\n\n // Simple regex patterns to find prop access\n const patterns = [/props\\.data\\.(\\w+)/g, /props\\.userState\\.(\\w+)/g, /props\\.utilities\\.(\\w+)/g, /props\\.callbacks\\.(\\w+)/g];\n\n for (const pattern of patterns) {\n let match;\n while ((match = pattern.exec(componentCode)) !== null) {\n paths.push(match[0]);\n }\n }\n\n return [...new Set(paths)]; // Remove duplicates\n}\n"]}
|