@memberjunction/react-runtime 3.3.0 → 4.0.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 +33 -25
- package/CHANGELOG.md +40 -0
- package/dist/324.runtime.umd.js +817 -0
- package/dist/490.runtime.umd.js +1 -0
- package/dist/compiler/babel-config.js +15 -21
- package/dist/compiler/babel-config.js.map +1 -1
- package/dist/compiler/component-compiler.js +13 -17
- package/dist/compiler/component-compiler.js.map +1 -1
- package/dist/compiler/index.js +2 -13
- package/dist/compiler/index.js.map +1 -1
- package/dist/component-manager/component-manager.js +7 -34
- package/dist/component-manager/component-manager.js.map +1 -1
- package/dist/component-manager/index.js +1 -5
- package/dist/component-manager/index.js.map +1 -1
- package/dist/component-manager/types.js +1 -2
- package/dist/index.js +31 -100
- package/dist/index.js.map +1 -1
- package/dist/registry/component-registry-service.js +8 -35
- package/dist/registry/component-registry-service.js.map +1 -1
- package/dist/registry/component-registry.js +5 -9
- package/dist/registry/component-registry.js.map +1 -1
- package/dist/registry/component-resolver.js +5 -9
- package/dist/registry/component-resolver.js.map +1 -1
- package/dist/registry/index.js +4 -11
- package/dist/registry/index.js.map +1 -1
- package/dist/registry/registry-provider.js +1 -2
- package/dist/runtime/component-hierarchy.js +24 -55
- package/dist/runtime/component-hierarchy.js.map +1 -1
- package/dist/runtime/component-wrapper.d.ts +18 -0
- package/dist/runtime/component-wrapper.d.ts.map +1 -0
- package/dist/runtime/component-wrapper.js +108 -0
- package/dist/runtime/error-boundary.js +4 -11
- package/dist/runtime/error-boundary.js.map +1 -1
- package/dist/runtime/index.js +4 -26
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/prop-builder.js +17 -28
- package/dist/runtime/prop-builder.js.map +1 -1
- package/dist/runtime/react-root-manager.js +4 -8
- package/dist/runtime/react-root-manager.js.map +1 -1
- package/dist/runtime.umd.js +1 -801
- package/dist/types/dependency-types.js +1 -2
- package/dist/types/index.js +2 -18
- package/dist/types/index.js.map +1 -1
- package/dist/types/library-config.js +1 -2
- package/dist/utilities/cache-manager.js +1 -5
- package/dist/utilities/cache-manager.js.map +1 -1
- package/dist/utilities/component-error-analyzer.js +53 -57
- package/dist/utilities/component-error-analyzer.js.map +1 -1
- package/dist/utilities/component-styles.js +2 -6
- package/dist/utilities/component-styles.js.map +1 -1
- package/dist/utilities/component-unwrapper.d.ts.map +1 -1
- package/dist/utilities/component-unwrapper.js +6 -13
- package/dist/utilities/component-unwrapper.js.map +1 -1
- package/dist/utilities/core-libraries.js +2 -7
- package/dist/utilities/core-libraries.js.map +1 -1
- package/dist/utilities/index.js +9 -25
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/library-dependency-resolver.js +1 -5
- package/dist/utilities/library-dependency-resolver.js.map +1 -1
- package/dist/utilities/library-loader.js +23 -27
- package/dist/utilities/library-loader.js.map +1 -1
- package/dist/utilities/library-registry.d.ts.map +1 -1
- package/dist/utilities/library-registry.js +3 -7
- package/dist/utilities/library-registry.js.map +1 -1
- package/dist/utilities/resource-manager.d.ts +0 -1
- package/dist/utilities/resource-manager.d.ts.map +1 -1
- package/dist/utilities/resource-manager.js +2 -6
- package/dist/utilities/resource-manager.js.map +1 -1
- package/dist/utilities/runtime-utilities.d.ts +10 -0
- package/dist/utilities/runtime-utilities.d.ts.map +1 -0
- package/dist/utilities/runtime-utilities.js +92 -0
- package/dist/utilities/standard-libraries.js +3 -8
- package/dist/utilities/standard-libraries.js.map +1 -1
- package/package.json +17 -17
- package/tsconfig.json +7 -22
- package/tsconfig.tsbuildinfo +1 -0
- package/typedoc.json +9 -0
package/dist/registry/index.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "ComponentRegistry", { enumerable: true, get: function () { return component_registry_1.ComponentRegistry; } });
|
|
6
|
-
var component_resolver_1 = require("./component-resolver");
|
|
7
|
-
Object.defineProperty(exports, "ComponentResolver", { enumerable: true, get: function () { return component_resolver_1.ComponentResolver; } });
|
|
8
|
-
var component_registry_service_1 = require("./component-registry-service");
|
|
9
|
-
Object.defineProperty(exports, "ComponentRegistryService", { enumerable: true, get: function () { return component_registry_service_1.ComponentRegistryService; } });
|
|
10
|
-
var interactive_component_types_1 = require("@memberjunction/interactive-component-types");
|
|
11
|
-
Object.defineProperty(exports, "ComponentSpec", { enumerable: true, get: function () { return interactive_component_types_1.ComponentSpec; } });
|
|
1
|
+
export { ComponentRegistry } from './component-registry';
|
|
2
|
+
export { ComponentResolver } from './component-resolver';
|
|
3
|
+
export { ComponentRegistryService } from './component-registry-service';
|
|
4
|
+
export { ComponentSpec } from '@memberjunction/interactive-component-types';
|
|
12
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAsB,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,wBAAwB,EAA4B,MAAM,8BAA8B,CAAC;AASlG,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC","sourcesContent":["/**\n * @fileoverview Registry module exports\n * @module @memberjunction/react-runtime/registry\n */\n\nexport { ComponentRegistry } from './component-registry';\nexport { ComponentResolver, ResolvedComponents } from './component-resolver';\nexport { ComponentRegistryService, IComponentRegistryClient } from './component-registry-service';\nexport { \n RegistryProvider,\n RegistryComponentMetadata,\n RegistryComponentResponse,\n RegistrySearchFilters,\n ComponentDependencyInfo,\n DependencyTree\n} from './registry-provider';\nexport { ComponentSpec } from '@memberjunction/interactive-component-types';"]}
|
|
@@ -1,31 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.countComponentsInHierarchy = exports.flattenComponentHierarchy = exports.validateComponentSpec = exports.registerComponentHierarchy = exports.ComponentHierarchyRegistrar = void 0;
|
|
27
|
-
const core_1 = require("@memberjunction/core");
|
|
28
|
-
class ComponentHierarchyRegistrar {
|
|
1
|
+
import { Metadata, LogStatus, GetProductionStatus } from '@memberjunction/core';
|
|
2
|
+
export class ComponentHierarchyRegistrar {
|
|
29
3
|
constructor(compiler, registry, runtimeContext) {
|
|
30
4
|
this.compiler = compiler;
|
|
31
5
|
this.registry = registry;
|
|
@@ -33,12 +7,12 @@ class ComponentHierarchyRegistrar {
|
|
|
33
7
|
}
|
|
34
8
|
async fetchExternalComponent(spec, contextUser) {
|
|
35
9
|
try {
|
|
36
|
-
const provider =
|
|
10
|
+
const provider = Metadata?.Provider;
|
|
37
11
|
if (!provider || !provider.ExecuteGQL) {
|
|
38
12
|
console.warn('⚠️ [ComponentHierarchyRegistrar] No GraphQL provider available for external registry fetch');
|
|
39
13
|
return null;
|
|
40
14
|
}
|
|
41
|
-
const { GraphQLComponentRegistryClient } = await
|
|
15
|
+
const { GraphQLComponentRegistryClient } = await import('@memberjunction/graphql-dataprovider');
|
|
42
16
|
const graphQLClient = new GraphQLComponentRegistryClient(provider);
|
|
43
17
|
const fullSpec = await graphQLClient.GetRegistryComponent({
|
|
44
18
|
registryName: spec.registry,
|
|
@@ -47,8 +21,8 @@ class ComponentHierarchyRegistrar {
|
|
|
47
21
|
version: spec.version || 'latest'
|
|
48
22
|
});
|
|
49
23
|
if (fullSpec && fullSpec.code) {
|
|
50
|
-
if (!
|
|
51
|
-
|
|
24
|
+
if (!GetProductionStatus()) {
|
|
25
|
+
LogStatus(`✅ [ComponentHierarchyRegistrar] Fetched external component ${spec.name} with code (${fullSpec.code.length} chars)`);
|
|
52
26
|
}
|
|
53
27
|
return fullSpec;
|
|
54
28
|
}
|
|
@@ -65,8 +39,8 @@ class ComponentHierarchyRegistrar {
|
|
|
65
39
|
async registerHierarchy(rootSpec, options) {
|
|
66
40
|
let resolvedRootSpec = rootSpec;
|
|
67
41
|
if (rootSpec.location === 'registry' && rootSpec.registry && !rootSpec.code) {
|
|
68
|
-
if (!
|
|
69
|
-
|
|
42
|
+
if (!GetProductionStatus()) {
|
|
43
|
+
LogStatus(`🌐 [ComponentHierarchyRegistrar] Fetching external registry component: ${rootSpec.registry}/${rootSpec.name}`);
|
|
70
44
|
}
|
|
71
45
|
resolvedRootSpec = await this.fetchExternalComponent(rootSpec, options.contextUser) || rootSpec;
|
|
72
46
|
}
|
|
@@ -74,8 +48,8 @@ class ComponentHierarchyRegistrar {
|
|
|
74
48
|
const registeredComponents = [];
|
|
75
49
|
const errors = [];
|
|
76
50
|
const warnings = [];
|
|
77
|
-
if (!
|
|
78
|
-
|
|
51
|
+
if (!GetProductionStatus()) {
|
|
52
|
+
LogStatus('🌳 ComponentHierarchyRegistrar.registerHierarchy:', undefined, {
|
|
79
53
|
rootComponent: resolvedRootSpec.name,
|
|
80
54
|
hasLibraries: !!(resolvedRootSpec.libraries && resolvedRootSpec.libraries.length > 0),
|
|
81
55
|
libraryCount: resolvedRootSpec.libraries?.length || 0
|
|
@@ -113,8 +87,8 @@ class ComponentHierarchyRegistrar {
|
|
|
113
87
|
result.loadedLibraries.forEach((value, key) => {
|
|
114
88
|
if (!allLoadedLibraries.has(key)) {
|
|
115
89
|
allLoadedLibraries.set(key, value);
|
|
116
|
-
if (!
|
|
117
|
-
|
|
90
|
+
if (!GetProductionStatus()) {
|
|
91
|
+
LogStatus(`📚 [registerHierarchy] Added library ${key} to accumulated libraries`);
|
|
118
92
|
}
|
|
119
93
|
}
|
|
120
94
|
});
|
|
@@ -177,8 +151,8 @@ class ComponentHierarchyRegistrar {
|
|
|
177
151
|
}
|
|
178
152
|
allLoadedLibraries.forEach((value, key) => {
|
|
179
153
|
this.runtimeContext.libraries[key] = value;
|
|
180
|
-
if (!
|
|
181
|
-
|
|
154
|
+
if (!GetProductionStatus()) {
|
|
155
|
+
LogStatus(`✅ [registerHierarchy] Added ${key} to runtime context libraries`);
|
|
182
156
|
}
|
|
183
157
|
});
|
|
184
158
|
}
|
|
@@ -230,8 +204,8 @@ class ComponentHierarchyRegistrar {
|
|
|
230
204
|
return false;
|
|
231
205
|
return true;
|
|
232
206
|
});
|
|
233
|
-
if (!
|
|
234
|
-
|
|
207
|
+
if (!GetProductionStatus()) {
|
|
208
|
+
LogStatus(`🔧 Compiling component ${spec.name} with libraries:`, undefined, {
|
|
235
209
|
originalCount: spec.libraries?.length || 0,
|
|
236
210
|
filteredCount: validLibraries?.length || 0,
|
|
237
211
|
libraries: validLibraries?.map(l => l.name) || []
|
|
@@ -262,13 +236,13 @@ class ComponentHierarchyRegistrar {
|
|
|
262
236
|
}
|
|
263
237
|
compilationResult.loadedLibraries.forEach((value, key) => {
|
|
264
238
|
this.runtimeContext.libraries[key] = value;
|
|
265
|
-
if (!
|
|
266
|
-
|
|
239
|
+
if (!GetProductionStatus()) {
|
|
240
|
+
LogStatus(`✅ [registerSingleComponent] Added ${key} to runtime context libraries`);
|
|
267
241
|
}
|
|
268
242
|
});
|
|
269
243
|
}
|
|
270
|
-
if (!
|
|
271
|
-
|
|
244
|
+
if (!GetProductionStatus()) {
|
|
245
|
+
LogStatus(`🏭 Calling factory for ${spec.name} with runtime context:`, undefined, {
|
|
272
246
|
hasReact: !!this.runtimeContext.React,
|
|
273
247
|
hasReactDOM: !!this.runtimeContext.ReactDOM,
|
|
274
248
|
libraryCount: Object.keys(this.runtimeContext.libraries || {}).length
|
|
@@ -316,13 +290,11 @@ class ComponentHierarchyRegistrar {
|
|
|
316
290
|
}
|
|
317
291
|
}
|
|
318
292
|
}
|
|
319
|
-
|
|
320
|
-
async function registerComponentHierarchy(rootSpec, compiler, registry, runtimeContext, options) {
|
|
293
|
+
export async function registerComponentHierarchy(rootSpec, compiler, registry, runtimeContext, options) {
|
|
321
294
|
const registrar = new ComponentHierarchyRegistrar(compiler, registry, runtimeContext);
|
|
322
295
|
return registrar.registerHierarchy(rootSpec, options);
|
|
323
296
|
}
|
|
324
|
-
|
|
325
|
-
function validateComponentSpec(spec) {
|
|
297
|
+
export function validateComponentSpec(spec) {
|
|
326
298
|
const errors = [];
|
|
327
299
|
if (!spec.name) {
|
|
328
300
|
errors.push('Component specification must have a name');
|
|
@@ -344,8 +316,7 @@ function validateComponentSpec(spec) {
|
|
|
344
316
|
});
|
|
345
317
|
return errors;
|
|
346
318
|
}
|
|
347
|
-
|
|
348
|
-
function flattenComponentHierarchy(rootSpec) {
|
|
319
|
+
export function flattenComponentHierarchy(rootSpec) {
|
|
349
320
|
const components = [rootSpec];
|
|
350
321
|
const children = rootSpec.dependencies || [];
|
|
351
322
|
children.forEach(child => {
|
|
@@ -353,8 +324,7 @@ function flattenComponentHierarchy(rootSpec) {
|
|
|
353
324
|
});
|
|
354
325
|
return components;
|
|
355
326
|
}
|
|
356
|
-
|
|
357
|
-
function countComponentsInHierarchy(rootSpec, includeEmpty = false) {
|
|
327
|
+
export function countComponentsInHierarchy(rootSpec, includeEmpty = false) {
|
|
358
328
|
let count = 0;
|
|
359
329
|
if (includeEmpty || rootSpec.code) {
|
|
360
330
|
count = 1;
|
|
@@ -365,5 +335,4 @@ function countComponentsInHierarchy(rootSpec, includeEmpty = false) {
|
|
|
365
335
|
});
|
|
366
336
|
return count;
|
|
367
337
|
}
|
|
368
|
-
exports.countComponentsInHierarchy = countComponentsInHierarchy;
|
|
369
338
|
//# sourceMappingURL=component-hierarchy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-hierarchy.js","sourceRoot":"","sources":["../../src/runtime/component-hierarchy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,+CAA0F;AAkD1F,MAAa,2BAA2B;IACtC,YACU,QAA2B,EAC3B,QAA2B,EAC3B,cAA8B;QAF9B,aAAQ,GAAR,QAAQ,CAAmB;QAC3B,aAAQ,GAAR,QAAQ,CAAmB;QAC3B,mBAAc,GAAd,cAAc,CAAgB;IACrC,CAAC;IAKI,KAAK,CAAC,sBAAsB,CAClC,IAAmB,EACnB,WAAsB;QAEtB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,eAAQ,EAAE,QAAQ,CAAC;YACpC,IAAI,CAAC,QAAQ,IAAI,CAAE,QAAgB,CAAC,UAAU,EAAE,CAAC;gBAC/C,OAAO,CAAC,IAAI,CAAC,4FAA4F,CAAC,CAAC;gBAC3G,OAAO,IAAI,CAAC;YACd,CAAC;YAGD,MAAM,EAAE,8BAA8B,EAAE,GAAG,wDAAa,sCAAsC,GAAC,CAAC;YAChG,MAAM,aAAa,GAAG,IAAI,8BAA8B,CAAC,QAAe,CAAC,CAAC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C,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
|
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;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAOD,MAAM,UAAU,yBAAyB,CAAC,QAAuB;IAC/D,MAAM,UAAU,GAAoB,CAAC,QAAQ,CAAC,CAAC;IAE/C,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,IAAI,EAAE,CAAC;IAC7C,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACvB,UAAU,CAAC,IAAI,CAAC,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACpB,CAAC;AAQD,MAAM,UAAU,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","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}"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ComponentProps, ComponentLifecycle } from '../types';
|
|
2
|
+
export interface WrapperOptions {
|
|
3
|
+
displayName?: string;
|
|
4
|
+
enableProfiling?: boolean;
|
|
5
|
+
logProps?: boolean;
|
|
6
|
+
lifecycle?: ComponentLifecycle;
|
|
7
|
+
defaultProps?: Partial<ComponentProps>;
|
|
8
|
+
}
|
|
9
|
+
export declare function wrapComponent(React: any, Component: any, options?: WrapperOptions): any;
|
|
10
|
+
export declare function memoizeComponent(React: any, Component: any, propsAreEqual?: (prevProps: any, nextProps: any) => boolean): any;
|
|
11
|
+
export declare function lazyComponent(React: any, loader: () => Promise<{
|
|
12
|
+
default: any;
|
|
13
|
+
}>, fallback?: any): any;
|
|
14
|
+
export declare function injectProps(React: any, Component: any, injectedProps: any): any;
|
|
15
|
+
export declare function conditionalComponent(React: any, Component: any, condition: boolean | ((props: any) => boolean), fallback?: any): any;
|
|
16
|
+
export declare function withErrorHandler(React: any, Component: any, errorHandler: (error: Error) => void): any;
|
|
17
|
+
export declare function portalComponent(React: any, ReactDOM: any, Component: any, container: Element | string): any;
|
|
18
|
+
//# sourceMappingURL=component-wrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-wrapper.d.ts","sourceRoot":"","sources":["../../src/runtime/component-wrapper.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAK9D,MAAM,WAAW,cAAc;IAE7B,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAE/B,YAAY,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;CACxC;AASD,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,GAAE,cAAmB,GAAG,GAAG,CA+E3F;AASD,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,GAAG,EACV,SAAS,EAAE,GAAG,EACd,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,KAAK,OAAO,GAC1D,GAAG,CAEL;AASD,wBAAgB,aAAa,CAC3B,KAAK,EAAE,GAAG,EACV,MAAM,EAAE,MAAM,OAAO,CAAC;IAAE,OAAO,EAAE,GAAG,CAAA;CAAE,CAAC,EACvC,QAAQ,CAAC,EAAE,GAAG,GACb,GAAG,CAYL;AASD,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,GAAG,GAAG,CAK/E;AAUD,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,GAAG,EACV,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,OAAO,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,EAC9C,QAAQ,CAAC,EAAE,GAAG,GACb,GAAG,CAUL;AASD,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,GAAG,EACV,SAAS,EAAE,GAAG,EACd,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GACnC,GAAG,CAUL;AAUD,wBAAgB,eAAe,CAC7B,KAAK,EAAE,GAAG,EACV,QAAQ,EAAE,GAAG,EACb,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,OAAO,GAAG,MAAM,GAC1B,GAAG,CAqBL"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.portalComponent = exports.withErrorHandler = exports.conditionalComponent = exports.injectProps = exports.lazyComponent = exports.memoizeComponent = exports.wrapComponent = void 0;
|
|
4
|
+
function wrapComponent(React, Component, options = {}) {
|
|
5
|
+
const { displayName, enableProfiling = false, logProps = false, lifecycle = {}, defaultProps = {} } = options;
|
|
6
|
+
const WrappedComponent = React.forwardRef((props, ref) => {
|
|
7
|
+
const mergedProps = { ...defaultProps, ...props };
|
|
8
|
+
React.useEffect(() => {
|
|
9
|
+
if (logProps) {
|
|
10
|
+
console.log(`[${displayName || Component.name}] Props:`, mergedProps);
|
|
11
|
+
}
|
|
12
|
+
}, [mergedProps]);
|
|
13
|
+
React.useEffect(() => {
|
|
14
|
+
if (lifecycle.beforeMount) {
|
|
15
|
+
lifecycle.beforeMount();
|
|
16
|
+
}
|
|
17
|
+
if (lifecycle.afterMount) {
|
|
18
|
+
lifecycle.afterMount();
|
|
19
|
+
}
|
|
20
|
+
return () => {
|
|
21
|
+
if (lifecycle.beforeUnmount) {
|
|
22
|
+
lifecycle.beforeUnmount();
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}, []);
|
|
26
|
+
const prevPropsRef = React.useRef(mergedProps);
|
|
27
|
+
React.useEffect(() => {
|
|
28
|
+
const prevProps = prevPropsRef.current;
|
|
29
|
+
if (lifecycle.beforeUpdate) {
|
|
30
|
+
lifecycle.beforeUpdate(prevProps, mergedProps);
|
|
31
|
+
}
|
|
32
|
+
if (lifecycle.afterUpdate) {
|
|
33
|
+
Promise.resolve().then(() => {
|
|
34
|
+
lifecycle.afterUpdate(prevProps, mergedProps);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
prevPropsRef.current = mergedProps;
|
|
38
|
+
});
|
|
39
|
+
if (enableProfiling && React.Profiler) {
|
|
40
|
+
return React.createElement(React.Profiler, {
|
|
41
|
+
id: displayName || Component.name || 'WrappedComponent',
|
|
42
|
+
onRender: (id, phase, actualDuration) => {
|
|
43
|
+
console.log(`[Profiler] ${id} (${phase}): ${actualDuration.toFixed(2)}ms`);
|
|
44
|
+
}
|
|
45
|
+
}, React.createElement(Component, { ...mergedProps, ref }));
|
|
46
|
+
}
|
|
47
|
+
return React.createElement(Component, { ...mergedProps, ref });
|
|
48
|
+
});
|
|
49
|
+
WrappedComponent.displayName = displayName || `Wrapped(${Component.displayName || Component.name || 'Component'})`;
|
|
50
|
+
return WrappedComponent;
|
|
51
|
+
}
|
|
52
|
+
exports.wrapComponent = wrapComponent;
|
|
53
|
+
function memoizeComponent(React, Component, propsAreEqual) {
|
|
54
|
+
return React.memo(Component, propsAreEqual);
|
|
55
|
+
}
|
|
56
|
+
exports.memoizeComponent = memoizeComponent;
|
|
57
|
+
function lazyComponent(React, loader, fallback) {
|
|
58
|
+
const LazyComponent = React.lazy(loader);
|
|
59
|
+
if (fallback) {
|
|
60
|
+
return (props) => React.createElement(React.Suspense, { fallback }, React.createElement(LazyComponent, props));
|
|
61
|
+
}
|
|
62
|
+
return LazyComponent;
|
|
63
|
+
}
|
|
64
|
+
exports.lazyComponent = lazyComponent;
|
|
65
|
+
function injectProps(React, Component, injectedProps) {
|
|
66
|
+
return React.forwardRef((props, ref) => {
|
|
67
|
+
const mergedProps = { ...injectedProps, ...props };
|
|
68
|
+
return React.createElement(Component, { ...mergedProps, ref });
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
exports.injectProps = injectProps;
|
|
72
|
+
function conditionalComponent(React, Component, condition, fallback) {
|
|
73
|
+
return (props) => {
|
|
74
|
+
const shouldRender = typeof condition === 'function' ? condition(props) : condition;
|
|
75
|
+
if (shouldRender) {
|
|
76
|
+
return React.createElement(Component, props);
|
|
77
|
+
}
|
|
78
|
+
return fallback || null;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
exports.conditionalComponent = conditionalComponent;
|
|
82
|
+
function withErrorHandler(React, Component, errorHandler) {
|
|
83
|
+
return class extends React.Component {
|
|
84
|
+
componentDidCatch(error, errorInfo) {
|
|
85
|
+
errorHandler(error);
|
|
86
|
+
}
|
|
87
|
+
render() {
|
|
88
|
+
return React.createElement(Component, this.props);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
exports.withErrorHandler = withErrorHandler;
|
|
93
|
+
function portalComponent(React, ReactDOM, Component, container) {
|
|
94
|
+
return (props) => {
|
|
95
|
+
const [mountNode, setMountNode] = React.useState(null);
|
|
96
|
+
React.useEffect(() => {
|
|
97
|
+
const node = typeof container === 'string'
|
|
98
|
+
? document.querySelector(container)
|
|
99
|
+
: container;
|
|
100
|
+
setMountNode(node);
|
|
101
|
+
}, []);
|
|
102
|
+
if (!mountNode || !ReactDOM.createPortal) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
return ReactDOM.createPortal(React.createElement(Component, props), mountNode);
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
exports.portalComponent = portalComponent;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createErrorLogger = exports.formatComponentError = exports.withErrorBoundary = exports.createErrorBoundary = void 0;
|
|
4
|
-
function createErrorBoundary(React, options = {}) {
|
|
1
|
+
export function createErrorBoundary(React, options = {}) {
|
|
5
2
|
const { onError, fallback, logErrors = true, recovery = 'none' } = options;
|
|
6
3
|
return class ErrorBoundary extends React.Component {
|
|
7
4
|
constructor(props) {
|
|
@@ -106,15 +103,13 @@ function createErrorBoundary(React, options = {}) {
|
|
|
106
103
|
}
|
|
107
104
|
};
|
|
108
105
|
}
|
|
109
|
-
|
|
110
|
-
function withErrorBoundary(React, Component, options = {}) {
|
|
106
|
+
export function withErrorBoundary(React, Component, options = {}) {
|
|
111
107
|
const ErrorBoundaryComponent = createErrorBoundary(React, options);
|
|
112
108
|
return (props) => {
|
|
113
109
|
return React.createElement(ErrorBoundaryComponent, null, React.createElement(Component, props));
|
|
114
110
|
};
|
|
115
111
|
}
|
|
116
|
-
|
|
117
|
-
function formatComponentError(error, componentName, phase) {
|
|
112
|
+
export function formatComponentError(error, componentName, phase) {
|
|
118
113
|
return {
|
|
119
114
|
message: error.message || 'Unknown error',
|
|
120
115
|
stack: error.stack,
|
|
@@ -126,8 +121,7 @@ function formatComponentError(error, componentName, phase) {
|
|
|
126
121
|
}
|
|
127
122
|
};
|
|
128
123
|
}
|
|
129
|
-
|
|
130
|
-
function createErrorLogger(componentName) {
|
|
124
|
+
export function createErrorLogger(componentName) {
|
|
131
125
|
return (error, errorInfo) => {
|
|
132
126
|
console.group(`🚨 React Component Error: ${componentName}`);
|
|
133
127
|
console.error('Error:', error);
|
|
@@ -136,5 +130,4 @@ function createErrorLogger(componentName) {
|
|
|
136
130
|
console.groupEnd();
|
|
137
131
|
};
|
|
138
132
|
}
|
|
139
|
-
exports.createErrorLogger = createErrorLogger;
|
|
140
133
|
//# sourceMappingURL=error-boundary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-boundary.js","sourceRoot":"","sources":["../../src/runtime/error-boundary.ts"],"names":[],"mappings":";;;AAcA,SAAgB,mBAAmB,CAAC,KAAU,EAAE,UAAgC,EAAE;IAChF,MAAM,EACJ,OAAO,EACP,QAAQ,EAC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C;QAC5D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;QACzC,OAAO,CAAC,QAAQ,EAAE,CAAC;IACrB,CAAC,CAAC;AACJ,CAAC;AARD,8CAQC","sourcesContent":["/**\n * @fileoverview React error boundary creation utilities.\n * Provides platform-agnostic error boundary components for React applications.\n * @module @memberjunction/react-runtime/runtime\n */\n\nimport { ErrorBoundaryOptions, ComponentError } from '../types';\n\n/**\n * Creates a React error boundary component class\n * @param React - React library instance\n * @param options - Error boundary options\n * @returns Error boundary component class\n */\nexport function createErrorBoundary(React: any, options: ErrorBoundaryOptions = {}): any {\n const {\n onError,\n fallback,\n logErrors = true,\n recovery = 'none'\n } = options;\n\n /**\n * Error boundary component class\n */\n return class ErrorBoundary extends React.Component {\n state: { hasError: boolean; error: Error | null; errorInfo: any; retryCount: number };\n\n constructor(props: any) {\n super(props);\n this.state = {\n hasError: false,\n error: null,\n errorInfo: null,\n retryCount: 0\n };\n }\n\n static getDerivedStateFromError(error: Error): any {\n // Update state to trigger fallback UI\n return { hasError: true, error };\n }\n\n componentDidCatch(error: Error, errorInfo: any) {\n // Log error if enabled\n if (logErrors) {\n console.error('React Error Boundary caught error:', error);\n console.error('Error Info:', errorInfo);\n }\n\n // Call custom error handler if provided\n if (onError) {\n try {\n onError(error, errorInfo);\n } catch (handlerError) {\n console.error('Error in custom error handler:', handlerError);\n }\n }\n\n // Update state with error details\n this.setState({ errorInfo });\n }\n\n handleRetry = () => {\n this.setState((prevState: any) => ({\n hasError: false,\n error: null,\n errorInfo: null,\n retryCount: prevState.retryCount + 1\n }));\n };\n\n handleReset = () => {\n this.setState({\n hasError: false,\n error: null,\n errorInfo: null,\n retryCount: 0\n });\n };\n\n render() {\n if (this.state.hasError) {\n // Use custom fallback if provided\n if (fallback) {\n if (typeof fallback === 'function') {\n return fallback({\n error: this.state.error,\n errorInfo: this.state.errorInfo,\n retry: this.handleRetry,\n reset: this.handleReset,\n retryCount: this.state.retryCount\n });\n }\n return fallback;\n }\n\n // Default error UI\n const showRetry = recovery === 'retry' && this.state.retryCount < 3;\n const showReset = recovery === 'reset';\n\n return React.createElement(\n 'div',\n {\n style: {\n padding: '20px',\n backgroundColor: '#f8f8f8',\n border: '1px solid #ddd',\n borderRadius: '4px',\n margin: '10px'\n }\n },\n React.createElement('h2', { style: { color: '#d32f2f' } }, 'Component Error'),\n React.createElement(\n 'p',\n { style: { color: '#666' } },\n 'An error occurred while rendering this component.'\n ),\n this.state.error && React.createElement(\n 'details',\n { style: { marginTop: '10px' } },\n React.createElement(\n 'summary',\n { style: { cursor: 'pointer', color: '#333' } },\n 'Error Details'\n ),\n React.createElement(\n 'pre',\n {\n style: {\n backgroundColor: '#f0f0f0',\n padding: '10px',\n marginTop: '10px',\n overflow: 'auto',\n fontSize: '12px'\n }\n },\n this.state.error.toString(),\n '\\n\\n',\n this.state.error.stack\n )\n ),\n (showRetry || showReset) && React.createElement(\n 'div',\n { style: { marginTop: '10px' } },\n showRetry && React.createElement(\n 'button',\n {\n onClick: this.handleRetry,\n style: {\n padding: '8px 16px',\n marginRight: '10px',\n backgroundColor: '#1976d2',\n color: 'white',\n border: 'none',\n borderRadius: '4px',\n cursor: 'pointer'\n }\n },\n `Retry (${3 - this.state.retryCount} attempts left)`\n ),\n showReset && React.createElement(\n 'button',\n {\n onClick: this.handleReset,\n style: {\n padding: '8px 16px',\n backgroundColor: '#757575',\n color: 'white',\n border: 'none',\n borderRadius: '4px',\n cursor: 'pointer'\n }\n },\n 'Reset Component'\n )\n )\n );\n }\n\n return this.props.children;\n }\n };\n}\n\n/**\n * Creates a functional error boundary wrapper using React hooks\n * @param React - React library instance\n * @param Component - Component to wrap\n * @param options - Error boundary options\n * @returns Wrapped component with error boundary\n */\nexport function withErrorBoundary(React: any, Component: any, options: ErrorBoundaryOptions = {}): any {\n const ErrorBoundaryComponent = createErrorBoundary(React, options);\n \n return (props: any) => {\n return React.createElement(\n ErrorBoundaryComponent,\n null,\n React.createElement(Component, props)\n );\n };\n}\n\n/**\n * Formats a component error for display or logging\n * @param error - Error to format\n * @param componentName - Name of the component where error occurred\n * @param phase - Phase when error occurred\n * @returns Formatted component error\n */\nexport function formatComponentError(\n error: Error,\n componentName: string,\n phase: ComponentError['phase']\n): ComponentError {\n return {\n message: error.message || 'Unknown error',\n stack: error.stack,\n componentName,\n phase,\n details: {\n name: error.name,\n timestamp: new Date().toISOString()\n }\n };\n}\n\n/**\n * Creates a simple error logger for error boundaries\n * @param componentName - Name of the component\n * @returns Error logging function\n */\nexport function createErrorLogger(componentName: string): (error: Error, errorInfo: any) => void {\n return (error: Error, errorInfo: any) => {\n console.group(`🚨 React Component Error: ${componentName}`);\n console.error('Error:', error);\n console.error('Component Stack:', errorInfo.componentStack);\n console.error('Props:', errorInfo.props);\n console.groupEnd();\n };\n}"]}
|
|
1
|
+
{"version":3,"file":"error-boundary.js","sourceRoot":"","sources":["../../src/runtime/error-boundary.ts"],"names":[],"mappings":"AAcA,MAAM,UAAU,mBAAmB,CAAC,KAAU,EAAE,UAAgC,EAAE;IAChF,MAAM,EACJ,OAAO,EACP,QAAQ,EACR,SAAS,GAAG,IAAI,EAChB,QAAQ,GAAG,MAAM,EAClB,GAAG,OAAO,CAAC;IAKZ,OAAO,MAAM,aAAc,SAAQ,KAAK,CAAC,SAAS;QAGhD,YAAY,KAAU;YACpB,KAAK,CAAC,KAAK,CAAC,CAAC;YAkCf,gBAAW,GAAG,GAAG,EAAE;gBACjB,IAAI,CAAC,QAAQ,CAAC,CAAC,SAAc,EAAE,EAAE,CAAC,CAAC;oBACjC,QAAQ,EAAE,KAAK;oBACf,KAAK,EAAE,IAAI;oBACX,SAAS,EAAE,IAAI;oBACf,UAAU,EAAE,SAAS,CAAC,UAAU,GAAG,CAAC;iBACrC,CAAC,CAAC,CAAC;YACN,CAAC,CAAC;YAEF,gBAAW,GAAG,GAAG,EAAE;gBACjB,IAAI,CAAC,QAAQ,CAAC;oBACZ,QAAQ,EAAE,K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,CAAC,SAAS,EAAE,KAAK,CAAC,CACtC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AASD,MAAM,UAAU,oBAAoB,CAClC,KAAY,EACZ,aAAqB,EACrB,KAA8B;IAE9B,OAAO;QACL,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,eAAe;QACzC,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,aAAa;QACb,KAAK;QACL,OAAO,EAAE;YACP,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC;KACF,CAAC;AACJ,CAAC;AAOD,MAAM,UAAU,iBAAiB,CAAC,aAAqB;IACrD,OAAO,CAAC,KAAY,EAAE,SAAc,EAAE,EAAE;QACtC,OAAO,CAAC,KAAK,CAAC,6BAA6B,aAAa,EAAE,CAAC,CAAC;QAC5D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC/B,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;QAC5D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;QACzC,OAAO,CAAC,QAAQ,EAAE,CAAC;IACrB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * @fileoverview React error boundary creation utilities.\n * Provides platform-agnostic error boundary components for React applications.\n * @module @memberjunction/react-runtime/runtime\n */\n\nimport { ErrorBoundaryOptions, ComponentError } from '../types';\n\n/**\n * Creates a React error boundary component class\n * @param React - React library instance\n * @param options - Error boundary options\n * @returns Error boundary component class\n */\nexport function createErrorBoundary(React: any, options: ErrorBoundaryOptions = {}): any {\n const {\n onError,\n fallback,\n logErrors = true,\n recovery = 'none'\n } = options;\n\n /**\n * Error boundary component class\n */\n return class ErrorBoundary extends React.Component {\n state: { hasError: boolean; error: Error | null; errorInfo: any; retryCount: number };\n\n constructor(props: any) {\n super(props);\n this.state = {\n hasError: false,\n error: null,\n errorInfo: null,\n retryCount: 0\n };\n }\n\n static getDerivedStateFromError(error: Error): any {\n // Update state to trigger fallback UI\n return { hasError: true, error };\n }\n\n componentDidCatch(error: Error, errorInfo: any) {\n // Log error if enabled\n if (logErrors) {\n console.error('React Error Boundary caught error:', error);\n console.error('Error Info:', errorInfo);\n }\n\n // Call custom error handler if provided\n if (onError) {\n try {\n onError(error, errorInfo);\n } catch (handlerError) {\n console.error('Error in custom error handler:', handlerError);\n }\n }\n\n // Update state with error details\n this.setState({ errorInfo });\n }\n\n handleRetry = () => {\n this.setState((prevState: any) => ({\n hasError: false,\n error: null,\n errorInfo: null,\n retryCount: prevState.retryCount + 1\n }));\n };\n\n handleReset = () => {\n this.setState({\n hasError: false,\n error: null,\n errorInfo: null,\n retryCount: 0\n });\n };\n\n render() {\n if (this.state.hasError) {\n // Use custom fallback if provided\n if (fallback) {\n if (typeof fallback === 'function') {\n return fallback({\n error: this.state.error,\n errorInfo: this.state.errorInfo,\n retry: this.handleRetry,\n reset: this.handleReset,\n retryCount: this.state.retryCount\n });\n }\n return fallback;\n }\n\n // Default error UI\n const showRetry = recovery === 'retry' && this.state.retryCount < 3;\n const showReset = recovery === 'reset';\n\n return React.createElement(\n 'div',\n {\n style: {\n padding: '20px',\n backgroundColor: '#f8f8f8',\n border: '1px solid #ddd',\n borderRadius: '4px',\n margin: '10px'\n }\n },\n React.createElement('h2', { style: { color: '#d32f2f' } }, 'Component Error'),\n React.createElement(\n 'p',\n { style: { color: '#666' } },\n 'An error occurred while rendering this component.'\n ),\n this.state.error && React.createElement(\n 'details',\n { style: { marginTop: '10px' } },\n React.createElement(\n 'summary',\n { style: { cursor: 'pointer', color: '#333' } },\n 'Error Details'\n ),\n React.createElement(\n 'pre',\n {\n style: {\n backgroundColor: '#f0f0f0',\n padding: '10px',\n marginTop: '10px',\n overflow: 'auto',\n fontSize: '12px'\n }\n },\n this.state.error.toString(),\n '\\n\\n',\n this.state.error.stack\n )\n ),\n (showRetry || showReset) && React.createElement(\n 'div',\n { style: { marginTop: '10px' } },\n showRetry && React.createElement(\n 'button',\n {\n onClick: this.handleRetry,\n style: {\n padding: '8px 16px',\n marginRight: '10px',\n backgroundColor: '#1976d2',\n color: 'white',\n border: 'none',\n borderRadius: '4px',\n cursor: 'pointer'\n }\n },\n `Retry (${3 - this.state.retryCount} attempts left)`\n ),\n showReset && React.createElement(\n 'button',\n {\n onClick: this.handleReset,\n style: {\n padding: '8px 16px',\n backgroundColor: '#757575',\n color: 'white',\n border: 'none',\n borderRadius: '4px',\n cursor: 'pointer'\n }\n },\n 'Reset Component'\n )\n )\n );\n }\n\n return this.props.children;\n }\n };\n}\n\n/**\n * Creates a functional error boundary wrapper using React hooks\n * @param React - React library instance\n * @param Component - Component to wrap\n * @param options - Error boundary options\n * @returns Wrapped component with error boundary\n */\nexport function withErrorBoundary(React: any, Component: any, options: ErrorBoundaryOptions = {}): any {\n const ErrorBoundaryComponent = createErrorBoundary(React, options);\n \n return (props: any) => {\n return React.createElement(\n ErrorBoundaryComponent,\n null,\n React.createElement(Component, props)\n );\n };\n}\n\n/**\n * Formats a component error for display or logging\n * @param error - Error to format\n * @param componentName - Name of the component where error occurred\n * @param phase - Phase when error occurred\n * @returns Formatted component error\n */\nexport function formatComponentError(\n error: Error,\n componentName: string,\n phase: ComponentError['phase']\n): ComponentError {\n return {\n message: error.message || 'Unknown error',\n stack: error.stack,\n componentName,\n phase,\n details: {\n name: error.name,\n timestamp: new Date().toISOString()\n }\n };\n}\n\n/**\n * Creates a simple error logger for error boundaries\n * @param componentName - Name of the component\n * @returns Error logging function\n */\nexport function createErrorLogger(componentName: string): (error: Error, errorInfo: any) => void {\n return (error: Error, errorInfo: any) => {\n console.group(`🚨 React Component Error: ${componentName}`);\n console.error('Error:', error);\n console.error('Component Stack:', errorInfo.componentStack);\n console.error('Props:', errorInfo.props);\n console.groupEnd();\n };\n}"]}
|