@memberjunction/react-runtime 6.2.0-edge.0 → 6.2.0-edge.2
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 +14 -14
- package/CHANGELOG.md +93 -0
- package/dist/compiler/babel-config.d.ts +14 -0
- package/dist/compiler/babel-config.d.ts.map +1 -1
- package/dist/compiler/babel-config.js +12 -3
- package/dist/compiler/babel-config.js.map +1 -1
- package/dist/compiler/component-compiler.d.ts +5 -0
- package/dist/compiler/component-compiler.d.ts.map +1 -1
- package/dist/compiler/component-compiler.js +24 -9
- package/dist/compiler/component-compiler.js.map +1 -1
- package/dist/compiler/index.d.ts +1 -1
- package/dist/compiler/index.d.ts.map +1 -1
- package/dist/compiler/index.js +1 -1
- package/dist/compiler/index.js.map +1 -1
- package/dist/component-manager/component-manager.d.ts +8 -0
- package/dist/component-manager/component-manager.d.ts.map +1 -1
- package/dist/component-manager/component-manager.js +18 -6
- package/dist/component-manager/component-manager.js.map +1 -1
- package/dist/index.d.ts +21 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -10
- package/dist/index.js.map +1 -1
- package/dist/registry/component-registry-service.d.ts +18 -0
- package/dist/registry/component-registry-service.d.ts.map +1 -1
- package/dist/registry/component-registry-service.js +65 -23
- package/dist/registry/component-registry-service.js.map +1 -1
- package/dist/registry/component-registry.d.ts +24 -1
- package/dist/registry/component-registry.d.ts.map +1 -1
- package/dist/registry/component-registry.js +74 -23
- package/dist/registry/component-registry.js.map +1 -1
- package/dist/registry/component-resolver.d.ts +10 -0
- package/dist/registry/component-resolver.d.ts.map +1 -1
- package/dist/registry/component-resolver.js +30 -9
- package/dist/registry/component-resolver.js.map +1 -1
- package/dist/registry/registry-provider.js.map +1 -1
- package/dist/runtime/component-hierarchy.d.ts +15 -0
- package/dist/runtime/component-hierarchy.d.ts.map +1 -1
- package/dist/runtime/component-hierarchy.js +28 -10
- package/dist/runtime/component-hierarchy.js.map +1 -1
- package/dist/runtime/error-boundary.d.ts +4 -0
- package/dist/runtime/error-boundary.d.ts.map +1 -1
- package/dist/runtime/error-boundary.js +50 -20
- package/dist/runtime/error-boundary.js.map +1 -1
- package/dist/runtime/index.d.ts +3 -3
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +3 -3
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/prop-builder.d.ts +8 -0
- package/dist/runtime/prop-builder.d.ts.map +1 -1
- package/dist/runtime/prop-builder.js +39 -11
- package/dist/runtime/prop-builder.js.map +1 -1
- package/dist/runtime/react-root-manager.d.ts +10 -0
- package/dist/runtime/react-root-manager.d.ts.map +1 -1
- package/dist/runtime/react-root-manager.js +27 -9
- package/dist/runtime/react-root-manager.js.map +1 -1
- package/dist/runtime.umd.js +194 -125
- package/dist/utilities/cache-manager.d.ts +13 -0
- package/dist/utilities/cache-manager.d.ts.map +1 -1
- package/dist/utilities/cache-manager.js +40 -16
- package/dist/utilities/cache-manager.js.map +1 -1
- package/dist/utilities/component-error-analyzer.d.ts +3 -0
- package/dist/utilities/component-error-analyzer.d.ts.map +1 -1
- package/dist/utilities/component-error-analyzer.js +12 -3
- package/dist/utilities/component-error-analyzer.js.map +1 -1
- package/dist/utilities/component-hash.d.ts +1 -0
- package/dist/utilities/component-hash.d.ts.map +1 -1
- package/dist/utilities/component-hash.js +4 -1
- package/dist/utilities/component-hash.js.map +1 -1
- package/dist/utilities/component-library-theming.d.ts +4 -0
- package/dist/utilities/component-library-theming.d.ts.map +1 -1
- package/dist/utilities/component-library-theming.js +12 -6
- package/dist/utilities/component-library-theming.js.map +1 -1
- package/dist/utilities/component-styles.d.ts +1 -0
- package/dist/utilities/component-styles.d.ts.map +1 -1
- package/dist/utilities/component-styles.js +2 -1
- package/dist/utilities/component-styles.js.map +1 -1
- package/dist/utilities/component-unwrapper.d.ts +8 -2
- package/dist/utilities/component-unwrapper.d.ts.map +1 -1
- package/dist/utilities/component-unwrapper.js +19 -7
- package/dist/utilities/component-unwrapper.js.map +1 -1
- package/dist/utilities/core-libraries.d.ts +2 -0
- package/dist/utilities/core-libraries.d.ts.map +1 -1
- package/dist/utilities/core-libraries.js +9 -3
- package/dist/utilities/core-libraries.js.map +1 -1
- package/dist/utilities/entity-record-key.d.ts +1 -0
- package/dist/utilities/entity-record-key.d.ts.map +1 -1
- package/dist/utilities/entity-record-key.js +4 -1
- package/dist/utilities/entity-record-key.js.map +1 -1
- package/dist/utilities/library-dependency-resolver.d.ts +8 -0
- package/dist/utilities/library-dependency-resolver.d.ts.map +1 -1
- package/dist/utilities/library-dependency-resolver.js +39 -15
- package/dist/utilities/library-dependency-resolver.js.map +1 -1
- package/dist/utilities/library-loader.d.ts +12 -0
- package/dist/utilities/library-loader.d.ts.map +1 -1
- package/dist/utilities/library-loader.js +46 -16
- package/dist/utilities/library-loader.js.map +1 -1
- package/dist/utilities/library-registry.d.ts +5 -0
- package/dist/utilities/library-registry.d.ts.map +1 -1
- package/dist/utilities/library-registry.js +20 -5
- package/dist/utilities/library-registry.js.map +1 -1
- package/dist/utilities/resource-manager.d.ts +19 -0
- package/dist/utilities/resource-manager.d.ts.map +1 -1
- package/dist/utilities/resource-manager.js +63 -18
- package/dist/utilities/resource-manager.js.map +1 -1
- package/dist/utilities/runtime-utilities.d.ts +9 -7
- package/dist/utilities/runtime-utilities.d.ts.map +1 -1
- package/dist/utilities/runtime-utilities.js +22 -16
- package/dist/utilities/runtime-utilities.js.map +1 -1
- package/dist/utilities/standard-libraries.d.ts +10 -0
- package/dist/utilities/standard-libraries.d.ts.map +1 -1
- package/dist/utilities/standard-libraries.js +40 -10
- package/dist/utilities/standard-libraries.js.map +1 -1
- package/dist/utilities/user-state.d.ts +5 -0
- package/dist/utilities/user-state.d.ts.map +1 -1
- package/dist/utilities/user-state.js +20 -5
- package/dist/utilities/user-state.js.map +1 -1
- package/package.json +7 -7
- package/src/__tests__/error-boundary.test.ts +80 -0
- package/src/__tests__/runtime-utilities-factory.test.ts +4 -4
- package/src/__tests__/user-state.test.ts +44 -44
- package/src/compiler/babel-config.ts +18 -3
- package/src/compiler/component-compiler.ts +34 -9
- package/src/compiler/index.ts +3 -3
- package/src/component-manager/component-manager.ts +36 -6
- package/src/index.ts +35 -21
- package/src/registry/component-registry-service.ts +126 -23
- package/src/registry/component-registry.ts +122 -24
- package/src/registry/component-resolver.ts +51 -9
- package/src/registry/registry-provider.ts +40 -40
- package/src/runtime/component-hierarchy.ts +61 -10
- package/src/runtime/error-boundary.ts +77 -22
- package/src/runtime/index.ts +16 -16
- package/src/runtime/prop-builder.ts +69 -11
- package/src/runtime/react-root-manager.ts +48 -10
- package/src/utilities/cache-manager.ts +61 -16
- package/src/utilities/component-error-analyzer.ts +18 -3
- package/src/utilities/component-hash.ts +6 -1
- package/src/utilities/component-library-theming.ts +24 -6
- package/src/utilities/component-styles.ts +4 -1
- package/src/utilities/component-unwrapper.ts +34 -7
- package/src/utilities/core-libraries.ts +13 -3
- package/src/utilities/entity-record-key.ts +11 -1
- package/src/utilities/library-dependency-resolver.ts +66 -15
- package/src/utilities/library-loader.ts +81 -17
- package/src/utilities/library-registry.ts +30 -5
- package/src/utilities/resource-manager.ts +126 -19
- package/src/utilities/runtime-utilities.ts +26 -16
- package/src/utilities/standard-libraries.ts +60 -10
- package/src/utilities/user-state.ts +40 -5
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import { ComponentStyles, ComponentObject } from '@memberjunction/interactive-component-types';
|
|
17
17
|
import { LibraryRegistry } from '../utilities/library-registry';
|
|
18
18
|
import { LibraryLoader } from '../utilities/library-loader';
|
|
19
|
-
import {
|
|
19
|
+
import { UnwrapLibraryComponent, UnwrapLibraryComponents, UnwrapAllLibraryComponents } from '../utilities/component-unwrapper';
|
|
20
20
|
import { MJComponentLibraryEntity } from '@memberjunction/core-entities';
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -57,16 +57,21 @@ export class ComponentCompiler {
|
|
|
57
57
|
* Sets the Babel instance to use for compilation
|
|
58
58
|
* @param babel - The Babel standalone instance
|
|
59
59
|
*/
|
|
60
|
-
|
|
60
|
+
SetBabelInstance(babel: any): void {
|
|
61
61
|
this.babelInstance = babel;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
/** @deprecated Use {@link SetBabelInstance}. */
|
|
65
|
+
setBabelInstance(babel: any): void {
|
|
66
|
+
return this.SetBabelInstance(babel);
|
|
67
|
+
}
|
|
68
|
+
|
|
64
69
|
/**
|
|
65
70
|
* Compiles a React component from source code
|
|
66
71
|
* @param options - Compilation options
|
|
67
72
|
* @returns Promise resolving to compilation result
|
|
68
73
|
*/
|
|
69
|
-
async
|
|
74
|
+
async Compile(options: CompileOptions): Promise<CompilationResult> {
|
|
70
75
|
const startTime = Date.now();
|
|
71
76
|
|
|
72
77
|
try {
|
|
@@ -135,6 +140,11 @@ export class ComponentCompiler {
|
|
|
135
140
|
}
|
|
136
141
|
}
|
|
137
142
|
|
|
143
|
+
/** @deprecated Use {@link Compile}. */
|
|
144
|
+
async compile(options: CompileOptions): Promise<CompilationResult> {
|
|
145
|
+
return this.Compile(options);
|
|
146
|
+
}
|
|
147
|
+
|
|
138
148
|
/**
|
|
139
149
|
* Transpiles JSX/React code to JavaScript
|
|
140
150
|
* @param code - Source code to transpile
|
|
@@ -792,9 +802,9 @@ export class ComponentCompiler {
|
|
|
792
802
|
});
|
|
793
803
|
|
|
794
804
|
// Create bound versions of unwrap functions with debug flag
|
|
795
|
-
const boundUnwrapLibraryComponent = (lib: any, name: string) =>
|
|
796
|
-
const boundUnwrapLibraryComponents = (lib: any, ...names: string[]) =>
|
|
797
|
-
const boundUnwrapAllLibraryComponents = (lib: any) =>
|
|
805
|
+
const boundUnwrapLibraryComponent = (lib: any, name: string) => UnwrapLibraryComponent(lib, name, this.config.debug);
|
|
806
|
+
const boundUnwrapLibraryComponents = (lib: any, ...names: string[]) => UnwrapLibraryComponents(lib, ...names, this.config.debug as any);
|
|
807
|
+
const boundUnwrapAllLibraryComponents = (lib: any) => UnwrapAllLibraryComponents(lib, this.config.debug);
|
|
798
808
|
|
|
799
809
|
// Execute the factory creator to get the createComponent function
|
|
800
810
|
let createComponentFn;
|
|
@@ -1000,23 +1010,38 @@ export class ComponentCompiler {
|
|
|
1000
1010
|
/**
|
|
1001
1011
|
* Clears the compilation cache
|
|
1002
1012
|
*/
|
|
1003
|
-
|
|
1013
|
+
ClearCache(): void {
|
|
1004
1014
|
this.compilationCache.clear();
|
|
1005
1015
|
}
|
|
1006
1016
|
|
|
1017
|
+
/** @deprecated Use {@link ClearCache}. */
|
|
1018
|
+
clearCache(): void {
|
|
1019
|
+
return this.ClearCache();
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1007
1022
|
/**
|
|
1008
1023
|
* Gets current cache size
|
|
1009
1024
|
* @returns Number of cached components
|
|
1010
1025
|
*/
|
|
1011
|
-
|
|
1026
|
+
GetCacheSize(): number {
|
|
1012
1027
|
return this.compilationCache.size;
|
|
1013
1028
|
}
|
|
1014
1029
|
|
|
1030
|
+
/** @deprecated Use {@link GetCacheSize}. */
|
|
1031
|
+
getCacheSize(): number {
|
|
1032
|
+
return this.GetCacheSize();
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1015
1035
|
/**
|
|
1016
1036
|
* Updates compiler configuration
|
|
1017
1037
|
* @param config - New configuration options
|
|
1018
1038
|
*/
|
|
1019
|
-
|
|
1039
|
+
UpdateConfig(config: Partial<CompilerConfig>): void {
|
|
1020
1040
|
this.config = { ...this.config, ...config };
|
|
1021
1041
|
}
|
|
1042
|
+
|
|
1043
|
+
/** @deprecated Use {@link UpdateConfig}. */
|
|
1044
|
+
updateConfig(config: Partial<CompilerConfig>): void {
|
|
1045
|
+
return this.UpdateConfig(config);
|
|
1046
|
+
}
|
|
1022
1047
|
}
|
package/src/compiler/index.ts
CHANGED
|
@@ -9,7 +9,7 @@ export {
|
|
|
9
9
|
DEFAULT_PLUGINS,
|
|
10
10
|
PRODUCTION_CONFIG,
|
|
11
11
|
DEVELOPMENT_CONFIG,
|
|
12
|
-
getBabelConfig,
|
|
13
|
-
validateBabelPresets,
|
|
14
|
-
getJSXConfig
|
|
12
|
+
GetBabelConfig, getBabelConfig,
|
|
13
|
+
ValidateBabelPresets, validateBabelPresets,
|
|
14
|
+
GetJSXConfig, getJSXConfig
|
|
15
15
|
} from './babel-config';
|
|
@@ -67,7 +67,7 @@ export class ComponentManager {
|
|
|
67
67
|
/**
|
|
68
68
|
* Main entry point - intelligently handles all component operations
|
|
69
69
|
*/
|
|
70
|
-
async
|
|
70
|
+
async LoadComponent(
|
|
71
71
|
spec: ComponentSpec,
|
|
72
72
|
options: LoadOptions = {}
|
|
73
73
|
): Promise<LoadResult> {
|
|
@@ -118,6 +118,14 @@ export class ComponentManager {
|
|
|
118
118
|
this.loadingPromises.delete(componentKey);
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
+
|
|
122
|
+
/** @deprecated Use {@link LoadComponent}. */
|
|
123
|
+
async loadComponent(
|
|
124
|
+
spec: ComponentSpec,
|
|
125
|
+
options: LoadOptions = {}
|
|
126
|
+
): Promise<LoadResult> {
|
|
127
|
+
return this.LoadComponent(spec, options);
|
|
128
|
+
}
|
|
121
129
|
|
|
122
130
|
/**
|
|
123
131
|
* Internal method that does the actual loading
|
|
@@ -295,7 +303,7 @@ export class ComponentManager {
|
|
|
295
303
|
/**
|
|
296
304
|
* Load a complete hierarchy efficiently
|
|
297
305
|
*/
|
|
298
|
-
async
|
|
306
|
+
async LoadHierarchy(
|
|
299
307
|
rootSpec: ComponentSpec,
|
|
300
308
|
options: LoadOptions = {}
|
|
301
309
|
): Promise<HierarchyResult> {
|
|
@@ -381,6 +389,14 @@ export class ComponentManager {
|
|
|
381
389
|
};
|
|
382
390
|
}
|
|
383
391
|
}
|
|
392
|
+
|
|
393
|
+
/** @deprecated Use {@link LoadHierarchy}. */
|
|
394
|
+
async loadHierarchy(
|
|
395
|
+
rootSpec: ComponentSpec,
|
|
396
|
+
options: LoadOptions = {}
|
|
397
|
+
): Promise<HierarchyResult> {
|
|
398
|
+
return this.LoadHierarchy(rootSpec, options);
|
|
399
|
+
}
|
|
384
400
|
|
|
385
401
|
/**
|
|
386
402
|
* Recursively load a component and its dependencies
|
|
@@ -409,7 +425,7 @@ export class ComponentManager {
|
|
|
409
425
|
visited.add(componentKey);
|
|
410
426
|
|
|
411
427
|
// Load this component
|
|
412
|
-
const result = await this.
|
|
428
|
+
const result = await this.LoadComponent(spec, options);
|
|
413
429
|
|
|
414
430
|
if (result.success && result.component) {
|
|
415
431
|
loaded.push(spec.name);
|
|
@@ -476,7 +492,7 @@ export class ComponentManager {
|
|
|
476
492
|
|
|
477
493
|
for (let i = 0; i < dependencies.length; i += batchSize) {
|
|
478
494
|
const batch = dependencies.slice(i, i + batchSize);
|
|
479
|
-
const batchPromises = batch.map(dep => this.
|
|
495
|
+
const batchPromises = batch.map(dep => this.LoadComponent(dep, options));
|
|
480
496
|
const batchResults = await Promise.all(batchPromises);
|
|
481
497
|
results.push(...batchResults);
|
|
482
498
|
}
|
|
@@ -807,17 +823,22 @@ export class ComponentManager {
|
|
|
807
823
|
/**
|
|
808
824
|
* Clear all caches
|
|
809
825
|
*/
|
|
810
|
-
|
|
826
|
+
ClearCache(): void {
|
|
811
827
|
this.fetchCache.clear();
|
|
812
828
|
this.registryNotifications.clear();
|
|
813
829
|
this.loadingPromises.clear();
|
|
814
830
|
this.log('All caches cleared');
|
|
815
831
|
}
|
|
832
|
+
|
|
833
|
+
/** @deprecated Use {@link ClearCache}. */
|
|
834
|
+
clearCache(): void {
|
|
835
|
+
return this.ClearCache();
|
|
836
|
+
}
|
|
816
837
|
|
|
817
838
|
/**
|
|
818
839
|
* Get cache statistics
|
|
819
840
|
*/
|
|
820
|
-
|
|
841
|
+
GetCacheStats(): {
|
|
821
842
|
fetchCacheSize: number;
|
|
822
843
|
notificationsCount: number;
|
|
823
844
|
loadingCount: number;
|
|
@@ -828,6 +849,15 @@ export class ComponentManager {
|
|
|
828
849
|
loadingCount: this.loadingPromises.size
|
|
829
850
|
};
|
|
830
851
|
}
|
|
852
|
+
|
|
853
|
+
/** @deprecated Use {@link GetCacheStats}. */
|
|
854
|
+
getCacheStats(): {
|
|
855
|
+
fetchCacheSize: number;
|
|
856
|
+
notificationsCount: number;
|
|
857
|
+
loadingCount: number;
|
|
858
|
+
} {
|
|
859
|
+
return this.GetCacheStats();
|
|
860
|
+
}
|
|
831
861
|
|
|
832
862
|
/**
|
|
833
863
|
* Log a message if debug is enabled
|
package/src/index.ts
CHANGED
|
@@ -88,20 +88,20 @@ export {
|
|
|
88
88
|
|
|
89
89
|
export {
|
|
90
90
|
SetupStyles,
|
|
91
|
-
createDefaultComponentStyles,
|
|
91
|
+
CreateDefaultComponentStyles, createDefaultComponentStyles,
|
|
92
92
|
BuildStylesFromTheme,
|
|
93
93
|
ApplyStyleOverrides
|
|
94
94
|
} from './utilities/component-styles';
|
|
95
95
|
|
|
96
96
|
export {
|
|
97
|
-
buildAntdThemeConfig,
|
|
98
|
-
wrapWithLibraryThemeProviders
|
|
97
|
+
BuildAntdThemeConfig, buildAntdThemeConfig,
|
|
98
|
+
WrapWithLibraryThemeProviders, wrapWithLibraryThemeProviders
|
|
99
99
|
} from './utilities/component-library-theming';
|
|
100
100
|
|
|
101
101
|
export {
|
|
102
102
|
StandardLibraries,
|
|
103
103
|
StandardLibraryManager,
|
|
104
|
-
createStandardLibraries
|
|
104
|
+
CreateStandardLibraries, createStandardLibraries
|
|
105
105
|
} from './utilities/standard-libraries';
|
|
106
106
|
|
|
107
107
|
export {
|
|
@@ -111,21 +111,21 @@ export {
|
|
|
111
111
|
} from './utilities/library-loader';
|
|
112
112
|
|
|
113
113
|
export {
|
|
114
|
-
getCoreRuntimeLibraries,
|
|
115
|
-
isCoreRuntimeLibrary
|
|
114
|
+
GetCoreRuntimeLibraries, getCoreRuntimeLibraries,
|
|
115
|
+
IsCoreRuntimeLibrary, isCoreRuntimeLibrary
|
|
116
116
|
} from './utilities/core-libraries';
|
|
117
117
|
|
|
118
118
|
export {
|
|
119
|
-
generateComponentHierarchyHash
|
|
119
|
+
GenerateComponentHierarchyHash, generateComponentHierarchyHash
|
|
120
120
|
} from './utilities/component-hash';
|
|
121
121
|
|
|
122
122
|
export {
|
|
123
123
|
RuntimeUtilities,
|
|
124
|
-
createRuntimeUtilities
|
|
124
|
+
CreateRuntimeUtilities, createRuntimeUtilities
|
|
125
125
|
} from './utilities/runtime-utilities';
|
|
126
126
|
|
|
127
127
|
export {
|
|
128
|
-
resolveEntityRecordKey,
|
|
128
|
+
ResolveEntityRecordKey, resolveEntityRecordKey,
|
|
129
129
|
EntityRecordKeyInput
|
|
130
130
|
} from './utilities/entity-record-key';
|
|
131
131
|
|
|
@@ -152,22 +152,22 @@ export {
|
|
|
152
152
|
} from './utilities/cache-manager';
|
|
153
153
|
|
|
154
154
|
export {
|
|
155
|
-
unwrapLibraryComponent,
|
|
156
|
-
unwrapLibraryComponents,
|
|
157
|
-
unwrapAllLibraryComponents,
|
|
155
|
+
UnwrapLibraryComponent, unwrapLibraryComponent,
|
|
156
|
+
UnwrapLibraryComponents, unwrapLibraryComponents,
|
|
157
|
+
UnwrapAllLibraryComponents, unwrapAllLibraryComponents,
|
|
158
158
|
// Legacy exports for backward compatibility
|
|
159
|
-
unwrapComponent,
|
|
160
|
-
unwrapComponents,
|
|
161
|
-
unwrapAllComponents
|
|
159
|
+
UnwrapComponent, unwrapComponent,
|
|
160
|
+
UnwrapComponents, unwrapComponents,
|
|
161
|
+
UnwrapAllComponents, unwrapAllComponents
|
|
162
162
|
} from './utilities/component-unwrapper';
|
|
163
163
|
|
|
164
164
|
export {
|
|
165
165
|
USER_STATE_KEY_PREFIX,
|
|
166
|
-
resolveUserStateScope,
|
|
167
|
-
userStateStorageKey,
|
|
168
|
-
parseStoredUserSettings,
|
|
169
|
-
mergeUserSettings,
|
|
170
|
-
applyUserSettingsUpdate
|
|
166
|
+
ResolveUserStateScope, resolveUserStateScope,
|
|
167
|
+
UserStateStorageKey, userStateStorageKey,
|
|
168
|
+
ParseStoredUserSettings, parseStoredUserSettings,
|
|
169
|
+
MergeUserSettings, mergeUserSettings,
|
|
170
|
+
ApplyUserSettingsUpdate, applyUserSettingsUpdate
|
|
171
171
|
} from './utilities/user-state';
|
|
172
172
|
|
|
173
173
|
// Version information
|
|
@@ -201,7 +201,7 @@ export const DEFAULT_CONFIGS = {
|
|
|
201
201
|
* @param debug - Enable debug logging (defaults to false)
|
|
202
202
|
* @returns Object containing compiler, registry, and resolver instances
|
|
203
203
|
*/
|
|
204
|
-
export function
|
|
204
|
+
export function CreateReactRuntime(
|
|
205
205
|
babelInstance: any,
|
|
206
206
|
config?: {
|
|
207
207
|
compiler?: Partial<import('./types').CompilerConfig>;
|
|
@@ -249,4 +249,18 @@ export function createReactRuntime(
|
|
|
249
249
|
version: VERSION,
|
|
250
250
|
debug
|
|
251
251
|
};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** @deprecated Use {@link CreateReactRuntime}. */
|
|
255
|
+
export function createReactRuntime(
|
|
256
|
+
babelInstance: any,
|
|
257
|
+
config?: {
|
|
258
|
+
compiler?: Partial<import('./types').CompilerConfig>;
|
|
259
|
+
registry?: Partial<import('./types').RegistryConfig>;
|
|
260
|
+
manager?: Partial<import('./component-manager').ComponentManagerConfig>;
|
|
261
|
+
},
|
|
262
|
+
runtimeContext?: import('./types').RuntimeContext,
|
|
263
|
+
debug: boolean = false
|
|
264
|
+
) {
|
|
265
|
+
return CreateReactRuntime(babelInstance, config, runtimeContext, debug);
|
|
252
266
|
}
|
|
@@ -101,7 +101,7 @@ export class ComponentRegistryService {
|
|
|
101
101
|
/**
|
|
102
102
|
* Get or create the singleton instance
|
|
103
103
|
*/
|
|
104
|
-
static
|
|
104
|
+
static GetInstance(
|
|
105
105
|
compiler: ComponentCompiler,
|
|
106
106
|
context: RuntimeContext,
|
|
107
107
|
debug: boolean = false,
|
|
@@ -112,16 +112,31 @@ export class ComponentRegistryService {
|
|
|
112
112
|
}
|
|
113
113
|
return ComponentRegistryService.instance;
|
|
114
114
|
}
|
|
115
|
+
|
|
116
|
+
/** @deprecated Use {@link GetInstance}. */
|
|
117
|
+
static getInstance(
|
|
118
|
+
compiler: ComponentCompiler,
|
|
119
|
+
context: RuntimeContext,
|
|
120
|
+
debug: boolean = false,
|
|
121
|
+
graphQLClient?: IComponentRegistryClient
|
|
122
|
+
): ComponentRegistryService {
|
|
123
|
+
return this.GetInstance(compiler, context, debug, graphQLClient);
|
|
124
|
+
}
|
|
115
125
|
|
|
116
126
|
/**
|
|
117
127
|
* Set the GraphQL client for registry operations
|
|
118
128
|
*/
|
|
119
|
-
|
|
129
|
+
SetGraphQLClient(client: IComponentRegistryClient): void {
|
|
120
130
|
this.graphQLClient = client;
|
|
121
131
|
if (this.debug) {
|
|
122
132
|
console.log('✅ GraphQL client configured for component registry');
|
|
123
133
|
}
|
|
124
134
|
}
|
|
135
|
+
|
|
136
|
+
/** @deprecated Use {@link SetGraphQLClient}. */
|
|
137
|
+
setGraphQLClient(client: IComponentRegistryClient): void {
|
|
138
|
+
return this.SetGraphQLClient(client);
|
|
139
|
+
}
|
|
125
140
|
|
|
126
141
|
/**
|
|
127
142
|
* Cached GraphQL client instance created from Metadata.Provider
|
|
@@ -189,10 +204,15 @@ export class ComponentRegistryService {
|
|
|
189
204
|
/**
|
|
190
205
|
* Initialize the service with metadata
|
|
191
206
|
*/
|
|
192
|
-
async
|
|
207
|
+
async Initialize(contextUser?: UserInfo): Promise<void> {
|
|
193
208
|
// Initialize metadata engine
|
|
194
209
|
await this.componentEngine.Config(false, contextUser);
|
|
195
210
|
}
|
|
211
|
+
|
|
212
|
+
/** @deprecated Use {@link Initialize}. */
|
|
213
|
+
async initialize(contextUser?: UserInfo): Promise<void> {
|
|
214
|
+
return this.Initialize(contextUser);
|
|
215
|
+
}
|
|
196
216
|
|
|
197
217
|
/**
|
|
198
218
|
* Calculate SHA-256 hash of a component spec for cache comparison
|
|
@@ -225,12 +245,12 @@ export class ComponentRegistryService {
|
|
|
225
245
|
/**
|
|
226
246
|
* Get a compiled component, using cache if available
|
|
227
247
|
*/
|
|
228
|
-
async
|
|
248
|
+
async GetCompiledComponent(
|
|
229
249
|
componentId: string,
|
|
230
250
|
referenceId?: string,
|
|
231
251
|
contextUser?: UserInfo
|
|
232
252
|
): Promise<ComponentObject> {
|
|
233
|
-
await this.
|
|
253
|
+
await this.Initialize(contextUser);
|
|
234
254
|
|
|
235
255
|
// Find component in metadata via targeted query
|
|
236
256
|
const component = await this.componentEngine.FindComponentByID(componentId, contextUser);
|
|
@@ -264,7 +284,7 @@ export class ComponentRegistryService {
|
|
|
264
284
|
}
|
|
265
285
|
|
|
266
286
|
// Get the component specification
|
|
267
|
-
const spec = await this.
|
|
287
|
+
const spec = await this.GetComponentSpec(componentId, contextUser);
|
|
268
288
|
|
|
269
289
|
// Compile the component
|
|
270
290
|
// Load all libraries from metadata engine
|
|
@@ -327,12 +347,21 @@ export class ComponentRegistryService {
|
|
|
327
347
|
// Call the factory function to get the ComponentObject
|
|
328
348
|
return compiledComponentFactory(this.runtimeContext);
|
|
329
349
|
}
|
|
350
|
+
|
|
351
|
+
/** @deprecated Use {@link GetCompiledComponent}. */
|
|
352
|
+
async getCompiledComponent(
|
|
353
|
+
componentId: string,
|
|
354
|
+
referenceId?: string,
|
|
355
|
+
contextUser?: UserInfo
|
|
356
|
+
): Promise<ComponentObject> {
|
|
357
|
+
return this.GetCompiledComponent(componentId, referenceId, contextUser);
|
|
358
|
+
}
|
|
330
359
|
|
|
331
360
|
/**
|
|
332
361
|
* Get compiled component from external registry by registry name
|
|
333
362
|
* This is used when spec.registry field is populated
|
|
334
363
|
*/
|
|
335
|
-
async
|
|
364
|
+
async GetCompiledComponentFromRegistry(
|
|
336
365
|
registryName: string,
|
|
337
366
|
namespace: string,
|
|
338
367
|
name: string,
|
|
@@ -340,7 +369,7 @@ export class ComponentRegistryService {
|
|
|
340
369
|
referenceId?: string,
|
|
341
370
|
contextUser?: UserInfo
|
|
342
371
|
): Promise<any> {
|
|
343
|
-
await this.
|
|
372
|
+
await this.Initialize(contextUser);
|
|
344
373
|
|
|
345
374
|
if (this.debug) {
|
|
346
375
|
console.log(`🌐 [ComponentRegistryService] Fetching from external registry: ${registryName}/${namespace}/${name}@${version}`);
|
|
@@ -477,15 +506,27 @@ export class ComponentRegistryService {
|
|
|
477
506
|
throw error;
|
|
478
507
|
}
|
|
479
508
|
}
|
|
509
|
+
|
|
510
|
+
/** @deprecated Use {@link GetCompiledComponentFromRegistry}. */
|
|
511
|
+
async getCompiledComponentFromRegistry(
|
|
512
|
+
registryName: string,
|
|
513
|
+
namespace: string,
|
|
514
|
+
name: string,
|
|
515
|
+
version: string,
|
|
516
|
+
referenceId?: string,
|
|
517
|
+
contextUser?: UserInfo
|
|
518
|
+
): Promise<any> {
|
|
519
|
+
return this.GetCompiledComponentFromRegistry(registryName, namespace, name, version, referenceId, contextUser);
|
|
520
|
+
}
|
|
480
521
|
|
|
481
522
|
/**
|
|
482
523
|
* Get component specification from database or external registry
|
|
483
524
|
*/
|
|
484
|
-
async
|
|
525
|
+
async GetComponentSpec(
|
|
485
526
|
componentId: string,
|
|
486
527
|
contextUser?: UserInfo
|
|
487
528
|
): Promise<ComponentSpec> {
|
|
488
|
-
await this.
|
|
529
|
+
await this.Initialize(contextUser);
|
|
489
530
|
|
|
490
531
|
const component = await this.componentEngine.FindComponentByID(componentId, contextUser);
|
|
491
532
|
if (!component) {
|
|
@@ -554,6 +595,14 @@ export class ComponentRegistryService {
|
|
|
554
595
|
|
|
555
596
|
return spec;
|
|
556
597
|
}
|
|
598
|
+
|
|
599
|
+
/** @deprecated Use {@link GetComponentSpec}. */
|
|
600
|
+
async getComponentSpec(
|
|
601
|
+
componentId: string,
|
|
602
|
+
contextUser?: UserInfo
|
|
603
|
+
): Promise<ComponentSpec> {
|
|
604
|
+
return this.GetComponentSpec(componentId, contextUser);
|
|
605
|
+
}
|
|
557
606
|
|
|
558
607
|
/**
|
|
559
608
|
* Fetch component from external registry via HTTP
|
|
@@ -683,11 +732,11 @@ export class ComponentRegistryService {
|
|
|
683
732
|
/**
|
|
684
733
|
* Load component dependencies from database
|
|
685
734
|
*/
|
|
686
|
-
async
|
|
735
|
+
async LoadDependencies(
|
|
687
736
|
componentId: string,
|
|
688
737
|
contextUser?: UserInfo
|
|
689
738
|
): Promise<ComponentDependencyInfo[]> {
|
|
690
|
-
await this.
|
|
739
|
+
await this.Initialize(contextUser);
|
|
691
740
|
|
|
692
741
|
// Get dependencies from metadata cache
|
|
693
742
|
const dependencies = this.componentEngine.ComponentDependencies?.filter(
|
|
@@ -714,11 +763,19 @@ export class ComponentRegistryService {
|
|
|
714
763
|
|
|
715
764
|
return result;
|
|
716
765
|
}
|
|
766
|
+
|
|
767
|
+
/** @deprecated Use {@link LoadDependencies}. */
|
|
768
|
+
async loadDependencies(
|
|
769
|
+
componentId: string,
|
|
770
|
+
contextUser?: UserInfo
|
|
771
|
+
): Promise<ComponentDependencyInfo[]> {
|
|
772
|
+
return this.LoadDependencies(componentId, contextUser);
|
|
773
|
+
}
|
|
717
774
|
|
|
718
775
|
/**
|
|
719
776
|
* Resolve full dependency tree for a component
|
|
720
777
|
*/
|
|
721
|
-
async
|
|
778
|
+
async ResolveDependencyTree(
|
|
722
779
|
componentId: string,
|
|
723
780
|
contextUser?: UserInfo,
|
|
724
781
|
visited = new Set<string>()
|
|
@@ -731,7 +788,7 @@ export class ComponentRegistryService {
|
|
|
731
788
|
}
|
|
732
789
|
visited.add(componentId);
|
|
733
790
|
|
|
734
|
-
await this.
|
|
791
|
+
await this.Initialize(contextUser);
|
|
735
792
|
|
|
736
793
|
const component = await this.componentEngine.FindComponentByID(componentId, contextUser);
|
|
737
794
|
if (!component) {
|
|
@@ -739,7 +796,7 @@ export class ComponentRegistryService {
|
|
|
739
796
|
}
|
|
740
797
|
|
|
741
798
|
// Get direct dependencies
|
|
742
|
-
const directDeps = await this.
|
|
799
|
+
const directDeps = await this.LoadDependencies(componentId, contextUser);
|
|
743
800
|
|
|
744
801
|
// Recursively resolve each dependency
|
|
745
802
|
const dependencies: DependencyTree[] = [];
|
|
@@ -747,7 +804,7 @@ export class ComponentRegistryService {
|
|
|
747
804
|
const depComponent = await this.componentEngine.FindComponent(dep.name, dep.namespace, undefined, contextUser);
|
|
748
805
|
|
|
749
806
|
if (depComponent) {
|
|
750
|
-
const subTree = await this.
|
|
807
|
+
const subTree = await this.ResolveDependencyTree(
|
|
751
808
|
depComponent.ID,
|
|
752
809
|
contextUser,
|
|
753
810
|
visited
|
|
@@ -765,15 +822,24 @@ export class ComponentRegistryService {
|
|
|
765
822
|
totalCount: dependencies.reduce((sum, d) => sum + (d.totalCount || 1), 1)
|
|
766
823
|
};
|
|
767
824
|
}
|
|
825
|
+
|
|
826
|
+
/** @deprecated Use {@link ResolveDependencyTree}. */
|
|
827
|
+
async resolveDependencyTree(
|
|
828
|
+
componentId: string,
|
|
829
|
+
contextUser?: UserInfo,
|
|
830
|
+
visited = new Set<string>()
|
|
831
|
+
): Promise<DependencyTree> {
|
|
832
|
+
return this.ResolveDependencyTree(componentId, contextUser, visited);
|
|
833
|
+
}
|
|
768
834
|
|
|
769
835
|
/**
|
|
770
836
|
* Get components to load in dependency order
|
|
771
837
|
*/
|
|
772
|
-
async
|
|
838
|
+
async GetComponentsToLoad(
|
|
773
839
|
rootComponentId: string,
|
|
774
840
|
contextUser?: UserInfo
|
|
775
841
|
): Promise<string[]> {
|
|
776
|
-
const tree = await this.
|
|
842
|
+
const tree = await this.ResolveDependencyTree(rootComponentId, contextUser);
|
|
777
843
|
|
|
778
844
|
// Flatten tree in dependency order (depth-first)
|
|
779
845
|
const ordered: string[] = [];
|
|
@@ -789,6 +855,14 @@ export class ComponentRegistryService {
|
|
|
789
855
|
|
|
790
856
|
return ordered;
|
|
791
857
|
}
|
|
858
|
+
|
|
859
|
+
/** @deprecated Use {@link GetComponentsToLoad}. */
|
|
860
|
+
async getComponentsToLoad(
|
|
861
|
+
rootComponentId: string,
|
|
862
|
+
contextUser?: UserInfo
|
|
863
|
+
): Promise<string[]> {
|
|
864
|
+
return this.GetComponentsToLoad(rootComponentId, contextUser);
|
|
865
|
+
}
|
|
792
866
|
|
|
793
867
|
/**
|
|
794
868
|
* Add a reference to a component
|
|
@@ -803,7 +877,7 @@ export class ComponentRegistryService {
|
|
|
803
877
|
/**
|
|
804
878
|
* Remove a reference to a component
|
|
805
879
|
*/
|
|
806
|
-
|
|
880
|
+
RemoveComponentReference(componentKey: string, referenceId: string): void {
|
|
807
881
|
const refs = this.componentReferences.get(componentKey);
|
|
808
882
|
if (refs) {
|
|
809
883
|
refs.delete(referenceId);
|
|
@@ -814,6 +888,11 @@ export class ComponentRegistryService {
|
|
|
814
888
|
}
|
|
815
889
|
}
|
|
816
890
|
}
|
|
891
|
+
|
|
892
|
+
/** @deprecated Use {@link RemoveComponentReference}. */
|
|
893
|
+
removeComponentReference(componentKey: string, referenceId: string): void {
|
|
894
|
+
return this.RemoveComponentReference(componentKey, referenceId);
|
|
895
|
+
}
|
|
817
896
|
|
|
818
897
|
/**
|
|
819
898
|
* Consider evicting a component from cache
|
|
@@ -849,7 +928,7 @@ export class ComponentRegistryService {
|
|
|
849
928
|
/**
|
|
850
929
|
* Get cache statistics
|
|
851
930
|
*/
|
|
852
|
-
|
|
931
|
+
GetCacheStats(): {
|
|
853
932
|
compiledComponents: number;
|
|
854
933
|
totalUseCount: number;
|
|
855
934
|
memoryEstimate: string;
|
|
@@ -865,11 +944,20 @@ export class ComponentRegistryService {
|
|
|
865
944
|
memoryEstimate: `~${(this.compiledComponentCache.size * 50)}KB` // Rough estimate
|
|
866
945
|
};
|
|
867
946
|
}
|
|
947
|
+
|
|
948
|
+
/** @deprecated Use {@link GetCacheStats}. */
|
|
949
|
+
getCacheStats(): {
|
|
950
|
+
compiledComponents: number;
|
|
951
|
+
totalUseCount: number;
|
|
952
|
+
memoryEstimate: string;
|
|
953
|
+
} {
|
|
954
|
+
return this.GetCacheStats();
|
|
955
|
+
}
|
|
868
956
|
|
|
869
957
|
/**
|
|
870
958
|
* Clear all caches
|
|
871
959
|
*/
|
|
872
|
-
|
|
960
|
+
ClearCache(): void {
|
|
873
961
|
if (this.debug) {
|
|
874
962
|
console.log('🧹 Clearing all component caches');
|
|
875
963
|
}
|
|
@@ -877,26 +965,41 @@ export class ComponentRegistryService {
|
|
|
877
965
|
this.componentReferences.clear();
|
|
878
966
|
}
|
|
879
967
|
|
|
968
|
+
/** @deprecated Use {@link ClearCache}. */
|
|
969
|
+
clearCache(): void {
|
|
970
|
+
return this.ClearCache();
|
|
971
|
+
}
|
|
972
|
+
|
|
880
973
|
/**
|
|
881
974
|
* Force clear all compiled components
|
|
882
975
|
* Used for Component Studio to ensure fresh loads
|
|
883
976
|
*/
|
|
884
|
-
|
|
977
|
+
ForceClearAll(): void {
|
|
885
978
|
this.compiledComponentCache.clear();
|
|
886
979
|
this.componentReferences.clear();
|
|
887
980
|
console.log('🧹 Component cache force cleared');
|
|
888
981
|
}
|
|
889
982
|
|
|
983
|
+
/** @deprecated Use {@link ForceClearAll}. */
|
|
984
|
+
forceClearAll(): void {
|
|
985
|
+
return this.ForceClearAll();
|
|
986
|
+
}
|
|
987
|
+
|
|
890
988
|
/**
|
|
891
989
|
* Reset the singleton instance
|
|
892
990
|
* Forces new instance creation on next access
|
|
893
991
|
*/
|
|
894
|
-
static
|
|
992
|
+
static Reset(): void {
|
|
895
993
|
if (ComponentRegistryService.instance) {
|
|
896
994
|
ComponentRegistryService.instance.forceClearAll();
|
|
897
995
|
ComponentRegistryService.instance = null;
|
|
898
996
|
}
|
|
899
997
|
}
|
|
998
|
+
|
|
999
|
+
/** @deprecated Use {@link Reset}. */
|
|
1000
|
+
static reset(): void {
|
|
1001
|
+
return this.Reset();
|
|
1002
|
+
}
|
|
900
1003
|
|
|
901
1004
|
/**
|
|
902
1005
|
* Generate a cache key for a component
|