@memberjunction/react-runtime 2.103.0 → 2.104.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 -10
- package/CHANGELOG.md +59 -0
- package/README.md +95 -0
- package/dist/runtime/component-hierarchy.d.ts.map +1 -1
- package/dist/runtime/component-hierarchy.js +36 -21
- 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 +13 -4
- package/dist/runtime/prop-builder.js.map +1 -1
- package/dist/runtime.umd.js +20 -10
- package/package.json +4 -4
- package/src/runtime/component-hierarchy.ts +42 -27
- package/src/runtime/prop-builder.ts +13 -4
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
|
|
2
|
-
> @memberjunction/react-runtime@2.
|
|
2
|
+
> @memberjunction/react-runtime@2.104.0 build
|
|
3
3
|
> npm run build:node && npm run build:umd
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @memberjunction/react-runtime@2.
|
|
6
|
+
> @memberjunction/react-runtime@2.104.0 build:node
|
|
7
7
|
> tsc
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @memberjunction/react-runtime@2.
|
|
10
|
+
> @memberjunction/react-runtime@2.104.0 build:umd
|
|
11
11
|
> webpack --config webpack.umd.config.js
|
|
12
12
|
|
|
13
13
|
[BABEL] Note: The code generator has deoptimised the styling of /home/runner/work/MJ/MJ/packages/MJCoreEntities/dist/generated/entity_subclasses.js as it exceeds the max of 500KB.
|
|
14
|
-
asset runtime.umd.js 2.
|
|
14
|
+
asset runtime.umd.js 2.33 MiB [emitted] [minimized] [big] (name: main) 1 related asset
|
|
15
15
|
orphan modules 513 KiB [orphan] 123 modules
|
|
16
16
|
runtime modules 1010 bytes 5 modules
|
|
17
|
-
modules by path ../../ 4.
|
|
17
|
+
modules by path ../../ 4.72 MiB
|
|
18
18
|
modules by path ../../../node_modules/ 1.62 MiB 258 modules
|
|
19
19
|
modules by path ../../MJGlobal/ 174 KiB 35 modules
|
|
20
|
-
modules by path ../../MJCore/
|
|
21
|
-
modules by path ../../
|
|
22
|
-
modules by path ../../
|
|
20
|
+
modules by path ../../MJCore/ 645 KiB 31 modules
|
|
21
|
+
modules by path ../../MJCoreEntities/dist/ 2.16 MiB 22 modules
|
|
22
|
+
modules by path ../../GraphQLDataProvider/ 112 KiB 22 modules
|
|
23
23
|
modules by path ../../InteractiveComponents/dist/*.js 36.8 KiB 10 modules
|
|
24
|
-
modules by path ./dist/
|
|
25
|
-
webpack 5.92.1 compiled successfully in
|
|
24
|
+
modules by path ./dist/ 473 KiB 28 modules
|
|
25
|
+
webpack 5.92.1 compiled successfully in 138493 ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,64 @@
|
|
|
1
1
|
# @memberjunction/react-runtime
|
|
2
2
|
|
|
3
|
+
## 2.104.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4567af3: **Component Feedback System (Registry-Agnostic)**
|
|
8
|
+
|
|
9
|
+
Implement comprehensive component feedback system that works across any component registry (Skip, MJ Central, etc.) with support for custom feedback handlers.
|
|
10
|
+
|
|
11
|
+
- Add skip-component-feedback-panel component with sliding panel UI (444 lines CSS, 161 lines HTML, 274 lines TS)
|
|
12
|
+
- Add star ratings (0-5 scale), comments, and component hierarchy visualization
|
|
13
|
+
- Add FeedbackHandler interface for customizable feedback logic per registry
|
|
14
|
+
- Add ComponentFeedbackParams and ComponentFeedbackResponse types with full parameter set
|
|
15
|
+
- Add POST /api/v1/feedback endpoint to ComponentRegistryAPIServer
|
|
16
|
+
- Add submitFeedback() method to ComponentRegistryClient SDK
|
|
17
|
+
- Add SendComponentFeedback mutation to ComponentRegistryResolver (replaces AskSkipResolver implementation)
|
|
18
|
+
- Use ComponentRegistryClient SDK with REGISTRY*URI_OVERRIDE*_ and REGISTRY*API_KEY*_ support
|
|
19
|
+
- Update skip-artifact-viewer to use GraphQLComponentRegistryClient for feedback submission
|
|
20
|
+
- Extract registry name from component spec with fallback to 'Skip'
|
|
21
|
+
- Update dynamic-ui-component and linear-report with component hierarchy tracking
|
|
22
|
+
- Pass conversationID and authenticated user email for contact resolution
|
|
23
|
+
|
|
24
|
+
**React Runtime Debug Logging Enhancements**
|
|
25
|
+
|
|
26
|
+
Restore debug logging with production guards for better debugging capabilities.
|
|
27
|
+
|
|
28
|
+
- Restore 12 debug console.log statements throughout React runtime (prop-builder, component-hierarchy)
|
|
29
|
+
- Wrap all debug logs with LogStatus/GetProductionStatus checks
|
|
30
|
+
- Add comprehensive README.md documentation (95 lines) for debug configuration
|
|
31
|
+
- Logs only execute when not in production mode
|
|
32
|
+
- Update ReactDebugConfig with enhanced environment variable support
|
|
33
|
+
|
|
34
|
+
**AI Prompt Error Handling Improvements**
|
|
35
|
+
|
|
36
|
+
Replace hardcoded error truncation with configurable maxErrorLength parameter.
|
|
37
|
+
|
|
38
|
+
- Add maxErrorLength?: number property to AIPromptParams class
|
|
39
|
+
- Update AIPromptRunner.logError() to accept maxErrorLength in options
|
|
40
|
+
- Thread maxErrorLength through 18 logError calls throughout AIPromptRunner
|
|
41
|
+
- Remove hardcoded MAX_ERROR_LENGTH constant (500 chars)
|
|
42
|
+
- When undefined (default), errors are returned in full for debugging
|
|
43
|
+
- When set, errors are truncated with "... [truncated]" suffix
|
|
44
|
+
|
|
45
|
+
**Bug Fixes**
|
|
46
|
+
|
|
47
|
+
- Fix AI parameter extraction edge cases in AIPromptRunner and QueryEntity
|
|
48
|
+
- Fix mj.config.cjs configuration
|
|
49
|
+
- Fix component hierarchy tracking in dynamic reports
|
|
50
|
+
|
|
51
|
+
Addresses PR #1426 comments #5, #7, and #8
|
|
52
|
+
|
|
53
|
+
- Updated dependencies [2ff5428]
|
|
54
|
+
- Updated dependencies [4567af3]
|
|
55
|
+
- Updated dependencies [9ad6353]
|
|
56
|
+
- @memberjunction/global@2.104.0
|
|
57
|
+
- @memberjunction/graphql-dataprovider@2.104.0
|
|
58
|
+
- @memberjunction/core-entities@2.104.0
|
|
59
|
+
- @memberjunction/core@2.104.0
|
|
60
|
+
- @memberjunction/interactive-component-types@2.104.0
|
|
61
|
+
|
|
3
62
|
## 2.103.0
|
|
4
63
|
|
|
5
64
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -591,6 +591,101 @@ The runtime uses SHA-256 hashing to ensure cached components are up-to-date:
|
|
|
591
591
|
- **Local Registry** (`registry` field undefined): Components stored in local database
|
|
592
592
|
- **External Registry** (`registry` field defined): Components fetched from remote registries via MJServer
|
|
593
593
|
|
|
594
|
+
## Debug Configuration
|
|
595
|
+
|
|
596
|
+
The React runtime includes comprehensive debug logging that can be controlled via environment configuration. This is useful for troubleshooting component loading, compilation, and runtime issues.
|
|
597
|
+
|
|
598
|
+
### Enabling Debug Mode
|
|
599
|
+
|
|
600
|
+
Debug mode controls verbose console logging throughout the React runtime. When enabled, you'll see detailed information about:
|
|
601
|
+
|
|
602
|
+
- Component compilation and registration
|
|
603
|
+
- Library loading and initialization
|
|
604
|
+
- Component lifecycle events
|
|
605
|
+
- Method registration and invocation
|
|
606
|
+
- Cache hits and misses
|
|
607
|
+
- Performance metrics
|
|
608
|
+
|
|
609
|
+
### Configuration Methods
|
|
610
|
+
|
|
611
|
+
#### Option 1: Angular Environment (Recommended for MJExplorer)
|
|
612
|
+
|
|
613
|
+
Set the `DEBUG` flag in your Angular environment files:
|
|
614
|
+
|
|
615
|
+
```typescript
|
|
616
|
+
// In environment.development.ts
|
|
617
|
+
export const environment = {
|
|
618
|
+
// ... other settings
|
|
619
|
+
DEBUG: true // Enable detailed debug logging
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
// In main.ts (before Angular bootstraps)
|
|
623
|
+
import { environment } from './environments/environment';
|
|
624
|
+
import { ReactDebugConfig } from '@memberjunction/ng-react';
|
|
625
|
+
|
|
626
|
+
ReactDebugConfig.setDebugMode(environment.DEBUG || false);
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
#### Option 2: Window Global (For Quick Testing)
|
|
630
|
+
|
|
631
|
+
Useful for temporarily enabling debug mode without changing code:
|
|
632
|
+
|
|
633
|
+
```typescript
|
|
634
|
+
// In browser console or before React components load
|
|
635
|
+
(window as any).__MJ_REACT_DEBUG_MODE__ = true;
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
#### Option 3: Direct API Call
|
|
639
|
+
|
|
640
|
+
Call the API directly in your initialization code:
|
|
641
|
+
|
|
642
|
+
```typescript
|
|
643
|
+
import { ReactDebugConfig } from '@memberjunction/ng-react';
|
|
644
|
+
|
|
645
|
+
// Enable debug mode
|
|
646
|
+
ReactDebugConfig.setDebugMode(true);
|
|
647
|
+
|
|
648
|
+
// Check current debug mode
|
|
649
|
+
const isDebug = ReactDebugConfig.getDebugMode();
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
### Debug Mode Priority
|
|
653
|
+
|
|
654
|
+
The debug mode follows this priority order (highest to lowest):
|
|
655
|
+
|
|
656
|
+
1. **Window global override** (`__MJ_REACT_DEBUG_MODE__`) - Highest priority
|
|
657
|
+
2. **Static property** (set via `setDebugMode()` or environment) - Default
|
|
658
|
+
3. **Default** - `false` (debug disabled)
|
|
659
|
+
|
|
660
|
+
### When to Enable Debug Mode
|
|
661
|
+
|
|
662
|
+
✅ **Enable in these scenarios:**
|
|
663
|
+
- During local development
|
|
664
|
+
- When troubleshooting component loading failures
|
|
665
|
+
- When debugging component compilation errors
|
|
666
|
+
- When investigating library dependency issues
|
|
667
|
+
- When analyzing runtime performance
|
|
668
|
+
|
|
669
|
+
❌ **Disable in these scenarios:**
|
|
670
|
+
- Production environments (cleaner console output)
|
|
671
|
+
- Staging environments (unless actively debugging)
|
|
672
|
+
- Performance profiling (reduces console overhead)
|
|
673
|
+
- Automated testing (reduces noise in logs)
|
|
674
|
+
|
|
675
|
+
### Example Debug Output
|
|
676
|
+
|
|
677
|
+
When debug mode is enabled, you'll see output like:
|
|
678
|
+
|
|
679
|
+
```
|
|
680
|
+
[ReactRuntime] Compiling component: Dashboard
|
|
681
|
+
[ReactRuntime] Component registered: Dashboard (namespace: analytics, version: 1.0.0)
|
|
682
|
+
[ReactRuntime] Loading library: lodash (version: 4.17.21)
|
|
683
|
+
[ReactRuntime] Library loaded successfully: lodash
|
|
684
|
+
[ReactRuntime] Cache hit for component: Chart@analytics:1.0.0
|
|
685
|
+
[ReactRuntime] Method registered: getCurrentDataState
|
|
686
|
+
[ReactRuntime] Component hierarchy loaded: 5 components in 234ms
|
|
687
|
+
```
|
|
688
|
+
|
|
594
689
|
## Configuration
|
|
595
690
|
|
|
596
691
|
### Compiler Configuration
|
|
@@ -1 +1 @@
|
|
|
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,MAAM,6CAA6C,CAAC;AAC7F,OAAO,EAAE,QAAQ,
|
|
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,MAAM,6CAA6C,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAA4C,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAKvE,MAAM,WAAW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AO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,0BAA0B,CAAA;KAAE,CAAC;YAuHtD,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"}
|
|
@@ -47,7 +47,9 @@ class ComponentHierarchyRegistrar {
|
|
|
47
47
|
version: spec.version || 'latest'
|
|
48
48
|
});
|
|
49
49
|
if (fullSpec && fullSpec.code) {
|
|
50
|
-
|
|
50
|
+
if (!(0, core_1.GetProductionStatus)()) {
|
|
51
|
+
(0, core_1.LogStatus)(`✅ [ComponentHierarchyRegistrar] Fetched external component ${spec.name} with code (${fullSpec.code.length} chars)`);
|
|
52
|
+
}
|
|
51
53
|
return fullSpec;
|
|
52
54
|
}
|
|
53
55
|
else {
|
|
@@ -63,19 +65,22 @@ class ComponentHierarchyRegistrar {
|
|
|
63
65
|
async registerHierarchy(rootSpec, options) {
|
|
64
66
|
let resolvedRootSpec = rootSpec;
|
|
65
67
|
if (rootSpec.location === 'registry' && rootSpec.registry && !rootSpec.code) {
|
|
66
|
-
|
|
68
|
+
if (!(0, core_1.GetProductionStatus)()) {
|
|
69
|
+
(0, core_1.LogStatus)(`🌐 [ComponentHierarchyRegistrar] Fetching external registry component: ${rootSpec.registry}/${rootSpec.name}`);
|
|
70
|
+
}
|
|
67
71
|
resolvedRootSpec = await this.fetchExternalComponent(rootSpec, options.contextUser) || rootSpec;
|
|
68
72
|
}
|
|
69
73
|
const { styles, namespace = 'Global', version = 'v1', continueOnError = true, allowOverride = true } = options;
|
|
70
|
-
console.log('🌳 ComponentHierarchyRegistrar.registerHierarchy:', {
|
|
71
|
-
rootComponent: resolvedRootSpec.name,
|
|
72
|
-
hasLibraries: !!(resolvedRootSpec.libraries && resolvedRootSpec.libraries.length > 0),
|
|
73
|
-
libraryCount: resolvedRootSpec.libraries?.length || 0,
|
|
74
|
-
libraries: resolvedRootSpec.libraries?.map(l => l.name)
|
|
75
|
-
});
|
|
76
74
|
const registeredComponents = [];
|
|
77
75
|
const errors = [];
|
|
78
76
|
const warnings = [];
|
|
77
|
+
if (!(0, core_1.GetProductionStatus)()) {
|
|
78
|
+
(0, core_1.LogStatus)('🌳 ComponentHierarchyRegistrar.registerHierarchy:', undefined, {
|
|
79
|
+
rootComponent: resolvedRootSpec.name,
|
|
80
|
+
hasLibraries: !!(resolvedRootSpec.libraries && resolvedRootSpec.libraries.length > 0),
|
|
81
|
+
libraryCount: resolvedRootSpec.libraries?.length || 0
|
|
82
|
+
});
|
|
83
|
+
}
|
|
79
84
|
const compiledMap = new Map();
|
|
80
85
|
const specMap = new Map();
|
|
81
86
|
const allLoadedLibraries = new Map();
|
|
@@ -108,7 +113,9 @@ class ComponentHierarchyRegistrar {
|
|
|
108
113
|
result.loadedLibraries.forEach((value, key) => {
|
|
109
114
|
if (!allLoadedLibraries.has(key)) {
|
|
110
115
|
allLoadedLibraries.set(key, value);
|
|
111
|
-
|
|
116
|
+
if (!(0, core_1.GetProductionStatus)()) {
|
|
117
|
+
(0, core_1.LogStatus)(`📚 [registerHierarchy] Added library ${key} to accumulated libraries`);
|
|
118
|
+
}
|
|
112
119
|
}
|
|
113
120
|
});
|
|
114
121
|
}
|
|
@@ -170,7 +177,9 @@ class ComponentHierarchyRegistrar {
|
|
|
170
177
|
}
|
|
171
178
|
allLoadedLibraries.forEach((value, key) => {
|
|
172
179
|
this.runtimeContext.libraries[key] = value;
|
|
173
|
-
|
|
180
|
+
if (!(0, core_1.GetProductionStatus)()) {
|
|
181
|
+
(0, core_1.LogStatus)(`✅ [registerHierarchy] Added ${key} to runtime context libraries`);
|
|
182
|
+
}
|
|
174
183
|
});
|
|
175
184
|
}
|
|
176
185
|
for (const [name, compiled] of compiledMap) {
|
|
@@ -221,6 +230,13 @@ class ComponentHierarchyRegistrar {
|
|
|
221
230
|
return false;
|
|
222
231
|
return true;
|
|
223
232
|
});
|
|
233
|
+
if (!(0, core_1.GetProductionStatus)()) {
|
|
234
|
+
(0, core_1.LogStatus)(`🔧 Compiling component ${spec.name} with libraries:`, undefined, {
|
|
235
|
+
originalCount: spec.libraries?.length || 0,
|
|
236
|
+
filteredCount: validLibraries?.length || 0,
|
|
237
|
+
libraries: validLibraries?.map(l => l.name) || []
|
|
238
|
+
});
|
|
239
|
+
}
|
|
224
240
|
const compileOptions = {
|
|
225
241
|
componentName: spec.name,
|
|
226
242
|
componentCode: spec.code,
|
|
@@ -229,11 +245,6 @@ class ComponentHierarchyRegistrar {
|
|
|
229
245
|
dependencies: spec.dependencies,
|
|
230
246
|
allLibraries: options.allLibraries
|
|
231
247
|
};
|
|
232
|
-
console.log(`🔧 Compiling component ${spec.name} with libraries:`, {
|
|
233
|
-
originalCount: spec.libraries?.length || 0,
|
|
234
|
-
filteredCount: validLibraries?.length || 0,
|
|
235
|
-
validLibraries: validLibraries?.map(l => ({ name: l.name, globalVariable: l.globalVariable }))
|
|
236
|
-
});
|
|
237
248
|
const compilationResult = await this.compiler.compile(compileOptions);
|
|
238
249
|
if (!compilationResult.success) {
|
|
239
250
|
return {
|
|
@@ -251,14 +262,18 @@ class ComponentHierarchyRegistrar {
|
|
|
251
262
|
}
|
|
252
263
|
compilationResult.loadedLibraries.forEach((value, key) => {
|
|
253
264
|
this.runtimeContext.libraries[key] = value;
|
|
254
|
-
|
|
265
|
+
if (!(0, core_1.GetProductionStatus)()) {
|
|
266
|
+
(0, core_1.LogStatus)(`✅ [registerSingleComponent] Added ${key} to runtime context libraries`);
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
if (!(0, core_1.GetProductionStatus)()) {
|
|
271
|
+
(0, core_1.LogStatus)(`🏭 Calling factory for ${spec.name} with runtime context:`, undefined, {
|
|
272
|
+
hasReact: !!this.runtimeContext.React,
|
|
273
|
+
hasReactDOM: !!this.runtimeContext.ReactDOM,
|
|
274
|
+
libraryCount: Object.keys(this.runtimeContext.libraries || {}).length
|
|
255
275
|
});
|
|
256
276
|
}
|
|
257
|
-
console.log(`🏭 Calling factory for ${spec.name} with runtime context:`, {
|
|
258
|
-
hasReact: !!this.runtimeContext.React,
|
|
259
|
-
hasReactDOM: !!this.runtimeContext.ReactDOM,
|
|
260
|
-
libraryKeys: Object.keys(this.runtimeContext.libraries || {})
|
|
261
|
-
});
|
|
262
277
|
const componentObject = compilationResult.component.factory(this.runtimeContext, styles);
|
|
263
278
|
this.registry.register(spec.name, componentObject, spec.namespace || namespace, version);
|
|
264
279
|
return { success: true };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-hierarchy.js","sourceRoot":"","sources":["../../src/runtime/component-hierarchy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,+CAA0D;AAkD1D,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,OAA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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 } 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 console.log(`✅ [ComponentHierarchyRegistrar] Fetched external component ${spec.name} with code (${fullSpec.code.length} chars)`);\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 console.log(`🌐 [ComponentHierarchyRegistrar] Fetching external registry component: ${rootSpec.registry}/${rootSpec.name}`);\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 console.log('🌳 ComponentHierarchyRegistrar.registerHierarchy:', {\n rootComponent: resolvedRootSpec.name,\n hasLibraries: !!(resolvedRootSpec.libraries && resolvedRootSpec.libraries.length > 0),\n libraryCount: resolvedRootSpec.libraries?.length || 0,\n libraries: resolvedRootSpec.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 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 console.log(`📚 [registerHierarchy] Added library ${key} to accumulated libraries`);\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 console.log(`✅ [registerHierarchy] Added ${key} to runtime context libraries`);\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 // 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 console.log(`🔧 Compiling component ${spec.name} with libraries:`, {\n originalCount: spec.libraries?.length || 0,\n filteredCount: validLibraries?.length || 0,\n validLibraries: validLibraries?.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 // 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 console.log(`✅ [registerSingleComponent] Added ${key} to runtime context libraries`);\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
|
+
{"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,sBAA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AC,IAAI,CAAC,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACpB,CAAC;AATD,8DASC;AAQD,SAAgB,0BAA0B,CACxC,QAAuB,EACvB,eAAwB,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 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 +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;
|
|
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,kBAIV,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,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,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+CpB;AAOD,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,CAmBhE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
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 core_1 = require("@memberjunction/core");
|
|
4
5
|
function buildComponentProps(data = {}, userState = {}, utilities = {}, callbacks = {
|
|
5
6
|
OpenEntityRecord: () => { },
|
|
6
7
|
RegisterMethod: () => { },
|
|
@@ -148,26 +149,34 @@ function wrapCallbacksWithLogging(callbacks, componentName) {
|
|
|
148
149
|
Object.keys(callbacks).forEach(key => {
|
|
149
150
|
if (key !== 'OpenEntityRecord' && key !== 'RegisterMethod' && key !== 'CreateSimpleNotification' && typeof callbacks[key] === 'function') {
|
|
150
151
|
wrapped[key] = (...args) => {
|
|
151
|
-
|
|
152
|
+
if (!(0, core_1.GetProductionStatus)()) {
|
|
153
|
+
(0, core_1.LogStatus)(`[${componentName}] ${key} called with args:`, undefined, args);
|
|
154
|
+
}
|
|
152
155
|
return callbacks[key](...args);
|
|
153
156
|
};
|
|
154
157
|
}
|
|
155
158
|
});
|
|
156
159
|
if (callbacks.OpenEntityRecord) {
|
|
157
160
|
wrapped.OpenEntityRecord = (entityName, key) => {
|
|
158
|
-
|
|
161
|
+
if (!(0, core_1.GetProductionStatus)()) {
|
|
162
|
+
(0, core_1.LogStatus)(`[${componentName}] OpenEntityRecord called:`, undefined, { entityName, key });
|
|
163
|
+
}
|
|
159
164
|
callbacks.OpenEntityRecord(entityName, key);
|
|
160
165
|
};
|
|
161
166
|
}
|
|
162
167
|
if (callbacks.RegisterMethod) {
|
|
163
168
|
wrapped.RegisterMethod = (methodName, handler) => {
|
|
164
|
-
|
|
169
|
+
if (!(0, core_1.GetProductionStatus)()) {
|
|
170
|
+
(0, core_1.LogStatus)(`[${componentName}] RegisterMethod called for:`, undefined, methodName);
|
|
171
|
+
}
|
|
165
172
|
callbacks.RegisterMethod(methodName, handler);
|
|
166
173
|
};
|
|
167
174
|
}
|
|
168
175
|
if (callbacks.CreateSimpleNotification) {
|
|
169
176
|
wrapped.CreateSimpleNotification = (message, style, hideAfter) => {
|
|
170
|
-
|
|
177
|
+
if (!(0, core_1.GetProductionStatus)()) {
|
|
178
|
+
(0, core_1.LogStatus)(`[${componentName}] CreateSimpleNotification called:`, undefined, { message, style, hideAfter });
|
|
179
|
+
}
|
|
171
180
|
callbacks.CreateSimpleNotification(message, style, hideAfter);
|
|
172
181
|
};
|
|
173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I,SAAS,CAAC,wBAAwB,EAAE,CAAC;QACvC,OAAO,CAAC,wBAAwB,GAAG,CAAC,OAAe,EAAE,KAAwD,EAAE,SAAkB,EAAE,EAAE;YACnI,OAAO,CAAC,GAAG,CAAC,IAAI,aAAa,oCAAoC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;YAClG,SAAS,CAAC,wBAAyB,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;QACjE,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AA1CD,4DA0CC;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';\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 console.log(`[${componentName}] ${key} called with args:`, args);\n return (callbacks as any)[key](...args);\n };\n }\n });\n\n if (callbacks.OpenEntityRecord) {\n wrapped.OpenEntityRecord = (entityName: string, key: any) => {\n console.log(`[${componentName}] OpenEntityRecord called:`, { entityName, key });\n callbacks.OpenEntityRecord!(entityName, key);\n };\n }\n\n if (callbacks.RegisterMethod) {\n wrapped.RegisterMethod = (methodName: any, handler: any) => {\n console.log(`[${componentName}] RegisterMethod called for:`, methodName);\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 console.log(`[${componentName}] CreateSimpleNotification called:`, { message, style, hideAfter });\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}"]}
|
|
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,EACnB,YAAgC;IAC9B,gBAAgB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC1B,cA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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}"]}
|