@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
|
@@ -117,7 +117,7 @@ export class ComponentHierarchyRegistrar {
|
|
|
117
117
|
* @param options - Registration options
|
|
118
118
|
* @returns Registration result with details about success/failures
|
|
119
119
|
*/
|
|
120
|
-
async
|
|
120
|
+
async RegisterHierarchy(
|
|
121
121
|
rootSpec: ComponentSpec,
|
|
122
122
|
options: HierarchyRegistrationOptions
|
|
123
123
|
): Promise<HierarchyRegistrationResult> {
|
|
@@ -297,13 +297,21 @@ export class ComponentHierarchyRegistrar {
|
|
|
297
297
|
};
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
+
/** @deprecated Use {@link RegisterHierarchy}. */
|
|
301
|
+
async registerHierarchy(
|
|
302
|
+
rootSpec: ComponentSpec,
|
|
303
|
+
options: HierarchyRegistrationOptions
|
|
304
|
+
): Promise<HierarchyRegistrationResult> {
|
|
305
|
+
return this.RegisterHierarchy(rootSpec, options);
|
|
306
|
+
}
|
|
307
|
+
|
|
300
308
|
/**
|
|
301
309
|
* Registers a single component from a specification
|
|
302
310
|
* @param spec - Component specification
|
|
303
311
|
* @param options - Registration options
|
|
304
312
|
* @returns Registration result for this component
|
|
305
313
|
*/
|
|
306
|
-
async
|
|
314
|
+
async RegisterSingleComponent(
|
|
307
315
|
spec: ComponentSpec,
|
|
308
316
|
options: {
|
|
309
317
|
styles?: ComponentStyles;
|
|
@@ -423,6 +431,20 @@ export class ComponentHierarchyRegistrar {
|
|
|
423
431
|
}
|
|
424
432
|
}
|
|
425
433
|
|
|
434
|
+
/** @deprecated Use {@link RegisterSingleComponent}. */
|
|
435
|
+
async registerSingleComponent(
|
|
436
|
+
spec: ComponentSpec,
|
|
437
|
+
options: {
|
|
438
|
+
styles?: ComponentStyles;
|
|
439
|
+
namespace?: string;
|
|
440
|
+
version?: string;
|
|
441
|
+
allowOverride?: boolean;
|
|
442
|
+
allLibraries: MJComponentLibraryEntity[];
|
|
443
|
+
}
|
|
444
|
+
): Promise<{ success: boolean; error?: ComponentRegistrationError }> {
|
|
445
|
+
return this.RegisterSingleComponent(spec, options);
|
|
446
|
+
}
|
|
447
|
+
|
|
426
448
|
/**
|
|
427
449
|
* Recursively registers child components
|
|
428
450
|
* @param children - Array of child component specifications
|
|
@@ -440,7 +462,7 @@ export class ComponentHierarchyRegistrar {
|
|
|
440
462
|
): Promise<void> {
|
|
441
463
|
for (const child of children) {
|
|
442
464
|
// Register this child
|
|
443
|
-
const childResult = await this.
|
|
465
|
+
const childResult = await this.RegisterSingleComponent(child, {
|
|
444
466
|
styles: options.styles,
|
|
445
467
|
namespace: options.namespace,
|
|
446
468
|
version: options.version,
|
|
@@ -483,7 +505,7 @@ export class ComponentHierarchyRegistrar {
|
|
|
483
505
|
* @param options - Registration options
|
|
484
506
|
* @returns Registration result
|
|
485
507
|
*/
|
|
486
|
-
export async function
|
|
508
|
+
export async function RegisterComponentHierarchy(
|
|
487
509
|
rootSpec: ComponentSpec,
|
|
488
510
|
compiler: ComponentCompiler,
|
|
489
511
|
registry: ComponentRegistry,
|
|
@@ -494,12 +516,23 @@ export async function registerComponentHierarchy(
|
|
|
494
516
|
return registrar.registerHierarchy(rootSpec, options);
|
|
495
517
|
}
|
|
496
518
|
|
|
519
|
+
/** @deprecated Use {@link RegisterComponentHierarchy}. */
|
|
520
|
+
export async function registerComponentHierarchy(
|
|
521
|
+
rootSpec: ComponentSpec,
|
|
522
|
+
compiler: ComponentCompiler,
|
|
523
|
+
registry: ComponentRegistry,
|
|
524
|
+
runtimeContext: RuntimeContext,
|
|
525
|
+
options: HierarchyRegistrationOptions
|
|
526
|
+
): Promise<HierarchyRegistrationResult> {
|
|
527
|
+
return RegisterComponentHierarchy(rootSpec, compiler, registry, runtimeContext, options);
|
|
528
|
+
}
|
|
529
|
+
|
|
497
530
|
/**
|
|
498
531
|
* Validates a component specification before registration
|
|
499
532
|
* @param spec - Component specification to validate
|
|
500
533
|
* @returns Array of validation errors (empty if valid)
|
|
501
534
|
*/
|
|
502
|
-
export function
|
|
535
|
+
export function ValidateComponentSpec(spec: ComponentSpec): string[] {
|
|
503
536
|
const errors: string[] = [];
|
|
504
537
|
|
|
505
538
|
if (!spec.name) {
|
|
@@ -519,7 +552,7 @@ export function validateComponentSpec(spec: ComponentSpec): string[] {
|
|
|
519
552
|
// Validate child components recursively
|
|
520
553
|
const children = spec.dependencies || [];
|
|
521
554
|
children.forEach((child, index) => {
|
|
522
|
-
const childErrors =
|
|
555
|
+
const childErrors = ValidateComponentSpec(child);
|
|
523
556
|
childErrors.forEach(error => {
|
|
524
557
|
errors.push(`Child ${index} (${child.name || 'unnamed'}): ${error}`);
|
|
525
558
|
});
|
|
@@ -528,29 +561,39 @@ export function validateComponentSpec(spec: ComponentSpec): string[] {
|
|
|
528
561
|
return errors;
|
|
529
562
|
}
|
|
530
563
|
|
|
564
|
+
/** @deprecated Use {@link ValidateComponentSpec}. */
|
|
565
|
+
export function validateComponentSpec(spec: ComponentSpec): string[] {
|
|
566
|
+
return ValidateComponentSpec(spec);
|
|
567
|
+
}
|
|
568
|
+
|
|
531
569
|
/**
|
|
532
570
|
* Flattens a component hierarchy into a list of all components
|
|
533
571
|
* @param rootSpec - The root component specification
|
|
534
572
|
* @returns Array of all component specifications in the hierarchy
|
|
535
573
|
*/
|
|
536
|
-
export function
|
|
574
|
+
export function FlattenComponentHierarchy(rootSpec: ComponentSpec): ComponentSpec[] {
|
|
537
575
|
const components: ComponentSpec[] = [rootSpec];
|
|
538
576
|
|
|
539
577
|
const children = rootSpec.dependencies || [];
|
|
540
578
|
children.forEach(child => {
|
|
541
|
-
components.push(...
|
|
579
|
+
components.push(...FlattenComponentHierarchy(child));
|
|
542
580
|
});
|
|
543
581
|
|
|
544
582
|
return components;
|
|
545
583
|
}
|
|
546
584
|
|
|
585
|
+
/** @deprecated Use {@link FlattenComponentHierarchy}. */
|
|
586
|
+
export function flattenComponentHierarchy(rootSpec: ComponentSpec): ComponentSpec[] {
|
|
587
|
+
return FlattenComponentHierarchy(rootSpec);
|
|
588
|
+
}
|
|
589
|
+
|
|
547
590
|
/**
|
|
548
591
|
* Counts the total number of components in a hierarchy
|
|
549
592
|
* @param rootSpec - The root component specification
|
|
550
593
|
* @param includeEmpty - Whether to include components without code
|
|
551
594
|
* @returns Total component count
|
|
552
595
|
*/
|
|
553
|
-
export function
|
|
596
|
+
export function CountComponentsInHierarchy(
|
|
554
597
|
rootSpec: ComponentSpec,
|
|
555
598
|
includeEmpty: boolean = false
|
|
556
599
|
): number {
|
|
@@ -562,8 +605,16 @@ export function countComponentsInHierarchy(
|
|
|
562
605
|
|
|
563
606
|
const children = rootSpec.dependencies || [];
|
|
564
607
|
children.forEach(child => {
|
|
565
|
-
count +=
|
|
608
|
+
count += CountComponentsInHierarchy(child, includeEmpty);
|
|
566
609
|
});
|
|
567
610
|
|
|
568
611
|
return count;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/** @deprecated Use {@link CountComponentsInHierarchy}. */
|
|
615
|
+
export function countComponentsInHierarchy(
|
|
616
|
+
rootSpec: ComponentSpec,
|
|
617
|
+
includeEmpty: boolean = false
|
|
618
|
+
): number {
|
|
619
|
+
return CountComponentsInHierarchy(rootSpec, includeEmpty);
|
|
569
620
|
}
|
|
@@ -12,7 +12,7 @@ import { ErrorBoundaryOptions, ComponentError } from '../types';
|
|
|
12
12
|
* @param options - Error boundary options
|
|
13
13
|
* @returns Error boundary component class
|
|
14
14
|
*/
|
|
15
|
-
export function
|
|
15
|
+
export function CreateErrorBoundary(React: any, options: ErrorBoundaryOptions = {}): any {
|
|
16
16
|
const {
|
|
17
17
|
onError,
|
|
18
18
|
fallback,
|
|
@@ -24,11 +24,20 @@ export function createErrorBoundary(React: any, options: ErrorBoundaryOptions =
|
|
|
24
24
|
* Error boundary component class
|
|
25
25
|
*/
|
|
26
26
|
return class ErrorBoundary extends React.Component {
|
|
27
|
-
|
|
27
|
+
State: { hasError: boolean; error: Error | null; errorInfo: any; retryCount: number };
|
|
28
|
+
|
|
29
|
+
/** @deprecated Use {@link State}. */
|
|
30
|
+
get state(): { hasError: boolean; error: Error | null; errorInfo: any; retryCount: number } {
|
|
31
|
+
return this.State;
|
|
32
|
+
}
|
|
33
|
+
/** @deprecated Use {@link State}. */
|
|
34
|
+
set state(value: { hasError: boolean; error: Error | null; errorInfo: any; retryCount: number }) {
|
|
35
|
+
this.State = value;
|
|
36
|
+
}
|
|
28
37
|
|
|
29
38
|
constructor(props: any) {
|
|
30
39
|
super(props);
|
|
31
|
-
this.
|
|
40
|
+
this.State = {
|
|
32
41
|
hasError: false,
|
|
33
42
|
error: null,
|
|
34
43
|
errorInfo: null,
|
|
@@ -36,6 +45,10 @@ export function createErrorBoundary(React: any, options: ErrorBoundaryOptions =
|
|
|
36
45
|
};
|
|
37
46
|
}
|
|
38
47
|
|
|
48
|
+
// React reads this static into a local and calls it UNBOUND
|
|
49
|
+
// (`var f = fiber.type.getDerivedStateFromError; f(error)`), so a stub that
|
|
50
|
+
// forwards through `this` throws while handling the child's error and unmounts
|
|
51
|
+
// the whole tree. The name has to stay on the real declaration.
|
|
39
52
|
static getDerivedStateFromError(error: Error): any {
|
|
40
53
|
// Update state to trigger fallback UI
|
|
41
54
|
return { hasError: true, error };
|
|
@@ -61,7 +74,7 @@ export function createErrorBoundary(React: any, options: ErrorBoundaryOptions =
|
|
|
61
74
|
this.setState({ errorInfo });
|
|
62
75
|
}
|
|
63
76
|
|
|
64
|
-
|
|
77
|
+
HandleRetry = () => {
|
|
65
78
|
this.setState((prevState: any) => ({
|
|
66
79
|
hasError: false,
|
|
67
80
|
error: null,
|
|
@@ -70,7 +83,16 @@ export function createErrorBoundary(React: any, options: ErrorBoundaryOptions =
|
|
|
70
83
|
}));
|
|
71
84
|
};
|
|
72
85
|
|
|
73
|
-
|
|
86
|
+
/** @deprecated Use {@link HandleRetry}. */
|
|
87
|
+
get handleRetry() {
|
|
88
|
+
return this.HandleRetry;
|
|
89
|
+
}
|
|
90
|
+
/** @deprecated Use {@link HandleRetry}. */
|
|
91
|
+
set handleRetry(value) {
|
|
92
|
+
this.HandleRetry = value;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
HandleReset = () => {
|
|
74
96
|
this.setState({
|
|
75
97
|
hasError: false,
|
|
76
98
|
error: null,
|
|
@@ -79,24 +101,33 @@ export function createErrorBoundary(React: any, options: ErrorBoundaryOptions =
|
|
|
79
101
|
});
|
|
80
102
|
};
|
|
81
103
|
|
|
104
|
+
/** @deprecated Use {@link HandleReset}. */
|
|
105
|
+
get handleReset() {
|
|
106
|
+
return this.HandleReset;
|
|
107
|
+
}
|
|
108
|
+
/** @deprecated Use {@link HandleReset}. */
|
|
109
|
+
set handleReset(value) {
|
|
110
|
+
this.HandleReset = value;
|
|
111
|
+
}
|
|
112
|
+
|
|
82
113
|
render() {
|
|
83
|
-
if (this.
|
|
114
|
+
if (this.State.hasError) {
|
|
84
115
|
// Use custom fallback if provided
|
|
85
116
|
if (fallback) {
|
|
86
117
|
if (typeof fallback === 'function') {
|
|
87
118
|
return fallback({
|
|
88
|
-
error: this.
|
|
89
|
-
errorInfo: this.
|
|
90
|
-
retry: this.
|
|
91
|
-
reset: this.
|
|
92
|
-
retryCount: this.
|
|
119
|
+
error: this.State.error,
|
|
120
|
+
errorInfo: this.State.errorInfo,
|
|
121
|
+
retry: this.HandleRetry,
|
|
122
|
+
reset: this.HandleReset,
|
|
123
|
+
retryCount: this.State.retryCount
|
|
93
124
|
});
|
|
94
125
|
}
|
|
95
126
|
return fallback;
|
|
96
127
|
}
|
|
97
128
|
|
|
98
129
|
// Default error UI
|
|
99
|
-
const showRetry = recovery === 'retry' && this.
|
|
130
|
+
const showRetry = recovery === 'retry' && this.State.retryCount < 3;
|
|
100
131
|
const showReset = recovery === 'reset';
|
|
101
132
|
|
|
102
133
|
return React.createElement(
|
|
@@ -116,7 +147,7 @@ export function createErrorBoundary(React: any, options: ErrorBoundaryOptions =
|
|
|
116
147
|
{ style: { color: '#666' } },
|
|
117
148
|
'An error occurred while rendering this component.'
|
|
118
149
|
),
|
|
119
|
-
this.
|
|
150
|
+
this.State.error && React.createElement(
|
|
120
151
|
'details',
|
|
121
152
|
{ style: { marginTop: '10px' } },
|
|
122
153
|
React.createElement(
|
|
@@ -135,9 +166,9 @@ export function createErrorBoundary(React: any, options: ErrorBoundaryOptions =
|
|
|
135
166
|
fontSize: '12px'
|
|
136
167
|
}
|
|
137
168
|
},
|
|
138
|
-
this.
|
|
169
|
+
this.State.error.toString(),
|
|
139
170
|
'\n\n',
|
|
140
|
-
this.
|
|
171
|
+
this.State.error.stack
|
|
141
172
|
)
|
|
142
173
|
),
|
|
143
174
|
(showRetry || showReset) && React.createElement(
|
|
@@ -146,7 +177,7 @@ export function createErrorBoundary(React: any, options: ErrorBoundaryOptions =
|
|
|
146
177
|
showRetry && React.createElement(
|
|
147
178
|
'button',
|
|
148
179
|
{
|
|
149
|
-
onClick: this.
|
|
180
|
+
onClick: this.HandleRetry,
|
|
150
181
|
style: {
|
|
151
182
|
padding: '8px 16px',
|
|
152
183
|
marginRight: '10px',
|
|
@@ -157,12 +188,12 @@ export function createErrorBoundary(React: any, options: ErrorBoundaryOptions =
|
|
|
157
188
|
cursor: 'pointer'
|
|
158
189
|
}
|
|
159
190
|
},
|
|
160
|
-
`Retry (${3 - this.
|
|
191
|
+
`Retry (${3 - this.State.retryCount} attempts left)`
|
|
161
192
|
),
|
|
162
193
|
showReset && React.createElement(
|
|
163
194
|
'button',
|
|
164
195
|
{
|
|
165
|
-
onClick: this.
|
|
196
|
+
onClick: this.HandleReset,
|
|
166
197
|
style: {
|
|
167
198
|
padding: '8px 16px',
|
|
168
199
|
backgroundColor: '#757575',
|
|
@@ -183,6 +214,11 @@ export function createErrorBoundary(React: any, options: ErrorBoundaryOptions =
|
|
|
183
214
|
};
|
|
184
215
|
}
|
|
185
216
|
|
|
217
|
+
/** @deprecated Use {@link CreateErrorBoundary}. */
|
|
218
|
+
export function createErrorBoundary(React: any, options: ErrorBoundaryOptions = {}): any {
|
|
219
|
+
return CreateErrorBoundary(React, options);
|
|
220
|
+
}
|
|
221
|
+
|
|
186
222
|
/**
|
|
187
223
|
* Creates a functional error boundary wrapper using React hooks
|
|
188
224
|
* @param React - React library instance
|
|
@@ -190,8 +226,8 @@ export function createErrorBoundary(React: any, options: ErrorBoundaryOptions =
|
|
|
190
226
|
* @param options - Error boundary options
|
|
191
227
|
* @returns Wrapped component with error boundary
|
|
192
228
|
*/
|
|
193
|
-
export function
|
|
194
|
-
const ErrorBoundaryComponent =
|
|
229
|
+
export function WithErrorBoundary(React: any, Component: any, options: ErrorBoundaryOptions = {}): any {
|
|
230
|
+
const ErrorBoundaryComponent = CreateErrorBoundary(React, options);
|
|
195
231
|
|
|
196
232
|
return (props: any) => {
|
|
197
233
|
return React.createElement(
|
|
@@ -202,6 +238,11 @@ export function withErrorBoundary(React: any, Component: any, options: ErrorBoun
|
|
|
202
238
|
};
|
|
203
239
|
}
|
|
204
240
|
|
|
241
|
+
/** @deprecated Use {@link WithErrorBoundary}. */
|
|
242
|
+
export function withErrorBoundary(React: any, Component: any, options: ErrorBoundaryOptions = {}): any {
|
|
243
|
+
return WithErrorBoundary(React, Component, options);
|
|
244
|
+
}
|
|
245
|
+
|
|
205
246
|
/**
|
|
206
247
|
* Formats a component error for display or logging
|
|
207
248
|
* @param error - Error to format
|
|
@@ -209,7 +250,7 @@ export function withErrorBoundary(React: any, Component: any, options: ErrorBoun
|
|
|
209
250
|
* @param phase - Phase when error occurred
|
|
210
251
|
* @returns Formatted component error
|
|
211
252
|
*/
|
|
212
|
-
export function
|
|
253
|
+
export function FormatComponentError(
|
|
213
254
|
error: Error,
|
|
214
255
|
componentName: string,
|
|
215
256
|
phase: ComponentError['phase']
|
|
@@ -226,12 +267,21 @@ export function formatComponentError(
|
|
|
226
267
|
};
|
|
227
268
|
}
|
|
228
269
|
|
|
270
|
+
/** @deprecated Use {@link FormatComponentError}. */
|
|
271
|
+
export function formatComponentError(
|
|
272
|
+
error: Error,
|
|
273
|
+
componentName: string,
|
|
274
|
+
phase: ComponentError['phase']
|
|
275
|
+
): ComponentError {
|
|
276
|
+
return FormatComponentError(error, componentName, phase);
|
|
277
|
+
}
|
|
278
|
+
|
|
229
279
|
/**
|
|
230
280
|
* Creates a simple error logger for error boundaries
|
|
231
281
|
* @param componentName - Name of the component
|
|
232
282
|
* @returns Error logging function
|
|
233
283
|
*/
|
|
234
|
-
export function
|
|
284
|
+
export function CreateErrorLogger(componentName: string): (error: Error, errorInfo: any) => void {
|
|
235
285
|
return (error: Error, errorInfo: any) => {
|
|
236
286
|
console.group(`🚨 React Component Error: ${componentName}`);
|
|
237
287
|
console.error('Error:', error);
|
|
@@ -239,4 +289,9 @@ export function createErrorLogger(componentName: string): (error: Error, errorIn
|
|
|
239
289
|
console.error('Props:', errorInfo.props);
|
|
240
290
|
console.groupEnd();
|
|
241
291
|
};
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/** @deprecated Use {@link CreateErrorLogger}. */
|
|
295
|
+
export function createErrorLogger(componentName: string): (error: Error, errorInfo: any) => void {
|
|
296
|
+
return CreateErrorLogger(componentName);
|
|
242
297
|
}
|
package/src/runtime/index.ts
CHANGED
|
@@ -4,31 +4,31 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
export {
|
|
7
|
-
createErrorBoundary,
|
|
8
|
-
withErrorBoundary,
|
|
9
|
-
formatComponentError,
|
|
10
|
-
createErrorLogger
|
|
7
|
+
CreateErrorBoundary, createErrorBoundary,
|
|
8
|
+
WithErrorBoundary, withErrorBoundary,
|
|
9
|
+
FormatComponentError, formatComponentError,
|
|
10
|
+
CreateErrorLogger, createErrorLogger
|
|
11
11
|
} from './error-boundary';
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
export {
|
|
15
|
-
buildComponentProps,
|
|
16
|
-
normalizeCallbacks,
|
|
17
|
-
normalizeStyles,
|
|
18
|
-
validateComponentProps,
|
|
19
|
-
mergeProps,
|
|
20
|
-
createPropsTransformer,
|
|
21
|
-
wrapCallbacksWithLogging,
|
|
22
|
-
extractPropPaths,
|
|
15
|
+
BuildComponentProps, buildComponentProps,
|
|
16
|
+
NormalizeCallbacks, normalizeCallbacks,
|
|
17
|
+
NormalizeStyles, normalizeStyles,
|
|
18
|
+
ValidateComponentProps, validateComponentProps,
|
|
19
|
+
MergeProps, mergeProps,
|
|
20
|
+
CreatePropsTransformer, createPropsTransformer,
|
|
21
|
+
WrapCallbacksWithLogging, wrapCallbacksWithLogging,
|
|
22
|
+
ExtractPropPaths, extractPropPaths,
|
|
23
23
|
PropBuilderOptions
|
|
24
24
|
} from './prop-builder';
|
|
25
25
|
|
|
26
26
|
export {
|
|
27
27
|
ComponentHierarchyRegistrar,
|
|
28
|
-
registerComponentHierarchy,
|
|
29
|
-
validateComponentSpec,
|
|
30
|
-
flattenComponentHierarchy,
|
|
31
|
-
countComponentsInHierarchy,
|
|
28
|
+
RegisterComponentHierarchy, registerComponentHierarchy,
|
|
29
|
+
ValidateComponentSpec, validateComponentSpec,
|
|
30
|
+
FlattenComponentHierarchy, flattenComponentHierarchy,
|
|
31
|
+
CountComponentsInHierarchy, countComponentsInHierarchy,
|
|
32
32
|
HierarchyRegistrationResult,
|
|
33
33
|
ComponentRegistrationError,
|
|
34
34
|
HierarchyRegistrationOptions
|
|
@@ -36,7 +36,7 @@ export interface PropBuilderOptions {
|
|
|
36
36
|
* @param options - Builder options
|
|
37
37
|
* @returns Built component props
|
|
38
38
|
*/
|
|
39
|
-
export function
|
|
39
|
+
export function BuildComponentProps(
|
|
40
40
|
data: any = {},
|
|
41
41
|
userState: any = {},
|
|
42
42
|
utilities: any = {},
|
|
@@ -66,20 +66,38 @@ export function buildComponentProps(
|
|
|
66
66
|
data: transformedData,
|
|
67
67
|
userState: transformedState,
|
|
68
68
|
utilities,
|
|
69
|
-
callbacks:
|
|
69
|
+
callbacks: NormalizeCallbacks(callbacks, debounceUpdateUserState),
|
|
70
70
|
components,
|
|
71
|
-
styles:
|
|
71
|
+
styles: NormalizeStyles(styles),
|
|
72
72
|
onStateChanged
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
// Validate if enabled
|
|
76
76
|
if (validate) {
|
|
77
|
-
|
|
77
|
+
ValidateComponentProps(props);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
return props;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
/** @deprecated Use {@link BuildComponentProps}. */
|
|
84
|
+
export function buildComponentProps(
|
|
85
|
+
data: any = {},
|
|
86
|
+
userState: any = {},
|
|
87
|
+
utilities: any = {},
|
|
88
|
+
callbacks: ComponentCallbacks = {
|
|
89
|
+
OpenEntityRecord: () => {},
|
|
90
|
+
RegisterMethod: () => {},
|
|
91
|
+
CreateSimpleNotification: () => {}
|
|
92
|
+
},
|
|
93
|
+
components: Record<string, any> = {},
|
|
94
|
+
styles?: ComponentStyles,
|
|
95
|
+
options: PropBuilderOptions = {},
|
|
96
|
+
onStateChanged?: (stateUpdate: Record<string, any>) => void
|
|
97
|
+
): ComponentProps {
|
|
98
|
+
return BuildComponentProps(data, userState, utilities, callbacks, components, styles, options, onStateChanged);
|
|
99
|
+
}
|
|
100
|
+
|
|
83
101
|
// Store subjects for debouncing per component instance
|
|
84
102
|
const updateUserStateSubjects = new WeakMap<Function, Subject<any>>();
|
|
85
103
|
|
|
@@ -120,7 +138,7 @@ function deepEqual(obj1: any, obj2: any): boolean {
|
|
|
120
138
|
* @param debounceMs - Debounce time for UpdateUserState in milliseconds
|
|
121
139
|
* @returns Normalized callbacks
|
|
122
140
|
*/
|
|
123
|
-
export function
|
|
141
|
+
export function NormalizeCallbacks(callbacks: any, debounceMs: number = 3000): ComponentCallbacks {
|
|
124
142
|
// Provide default implementations for required callbacks
|
|
125
143
|
const normalized: ComponentCallbacks = {
|
|
126
144
|
OpenEntityRecord: callbacks?.OpenEntityRecord || (() => {}),
|
|
@@ -140,24 +158,34 @@ export function normalizeCallbacks(callbacks: any, debounceMs: number = 3000): C
|
|
|
140
158
|
return normalized;
|
|
141
159
|
}
|
|
142
160
|
|
|
161
|
+
/** @deprecated Use {@link NormalizeCallbacks}. */
|
|
162
|
+
export function normalizeCallbacks(callbacks: any, debounceMs: number = 3000): ComponentCallbacks {
|
|
163
|
+
return NormalizeCallbacks(callbacks, debounceMs);
|
|
164
|
+
}
|
|
165
|
+
|
|
143
166
|
/**
|
|
144
167
|
* Normalizes component styles
|
|
145
168
|
* @param styles - Raw styles object
|
|
146
169
|
* @returns Normalized styles
|
|
147
170
|
*/
|
|
148
|
-
export function
|
|
171
|
+
export function NormalizeStyles(styles?: any): any {
|
|
149
172
|
// Pass through the full styles object as-is
|
|
150
173
|
// This allows Skip components to access their full style structure
|
|
151
174
|
// including colors, typography, borders, etc.
|
|
152
175
|
return styles;
|
|
153
176
|
}
|
|
154
177
|
|
|
178
|
+
/** @deprecated Use {@link NormalizeStyles}. */
|
|
179
|
+
export function normalizeStyles(styles?: any): any {
|
|
180
|
+
return NormalizeStyles(styles);
|
|
181
|
+
}
|
|
182
|
+
|
|
155
183
|
/**
|
|
156
184
|
* Validates component props
|
|
157
185
|
* @param props - Props to validate
|
|
158
186
|
* @throws Error if validation fails
|
|
159
187
|
*/
|
|
160
|
-
export function
|
|
188
|
+
export function ValidateComponentProps(props: ComponentProps): void {
|
|
161
189
|
// Validate data
|
|
162
190
|
if (props.data === null || props.data === undefined) {
|
|
163
191
|
throw new Error('Component props.data cannot be null or undefined');
|
|
@@ -186,12 +214,17 @@ export function validateComponentProps(props: ComponentProps): void {
|
|
|
186
214
|
}
|
|
187
215
|
}
|
|
188
216
|
|
|
217
|
+
/** @deprecated Use {@link ValidateComponentProps}. */
|
|
218
|
+
export function validateComponentProps(props: ComponentProps): void {
|
|
219
|
+
return ValidateComponentProps(props);
|
|
220
|
+
}
|
|
221
|
+
|
|
189
222
|
/**
|
|
190
223
|
* Merges multiple prop objects
|
|
191
224
|
* @param propsList - Array of props to merge
|
|
192
225
|
* @returns Merged props
|
|
193
226
|
*/
|
|
194
|
-
export function
|
|
227
|
+
export function MergeProps(...propsList: Partial<ComponentProps>[]): ComponentProps {
|
|
195
228
|
const merged: ComponentProps = {
|
|
196
229
|
data: {},
|
|
197
230
|
userState: {},
|
|
@@ -229,13 +262,18 @@ export function mergeProps(...propsList: Partial<ComponentProps>[]): ComponentPr
|
|
|
229
262
|
|
|
230
263
|
return merged;
|
|
231
264
|
}
|
|
265
|
+
|
|
266
|
+
/** @deprecated Use {@link MergeProps}. */
|
|
267
|
+
export function mergeProps(...propsList: Partial<ComponentProps>[]): ComponentProps {
|
|
268
|
+
return MergeProps(...propsList);
|
|
269
|
+
}
|
|
232
270
|
|
|
233
271
|
/**
|
|
234
272
|
* Creates a props transformer function
|
|
235
273
|
* @param transformations - Map of prop paths to transformer functions
|
|
236
274
|
* @returns Props transformer
|
|
237
275
|
*/
|
|
238
|
-
export function
|
|
276
|
+
export function CreatePropsTransformer(
|
|
239
277
|
transformations: Record<string, (value: any) => any>
|
|
240
278
|
): (props: ComponentProps) => ComponentProps {
|
|
241
279
|
return (props: ComponentProps) => {
|
|
@@ -264,13 +302,20 @@ export function createPropsTransformer(
|
|
|
264
302
|
};
|
|
265
303
|
}
|
|
266
304
|
|
|
305
|
+
/** @deprecated Use {@link CreatePropsTransformer}. */
|
|
306
|
+
export function createPropsTransformer(
|
|
307
|
+
transformations: Record<string, (value: any) => any>
|
|
308
|
+
): (props: ComponentProps) => ComponentProps {
|
|
309
|
+
return CreatePropsTransformer(transformations);
|
|
310
|
+
}
|
|
311
|
+
|
|
267
312
|
/**
|
|
268
313
|
* Creates a callback wrapper that adds logging
|
|
269
314
|
* @param callbacks - Original callbacks
|
|
270
315
|
* @param componentName - Component name for logging
|
|
271
316
|
* @returns Wrapped callbacks
|
|
272
317
|
*/
|
|
273
|
-
export function
|
|
318
|
+
export function WrapCallbacksWithLogging(
|
|
274
319
|
callbacks: ComponentCallbacks,
|
|
275
320
|
componentName: string
|
|
276
321
|
): ComponentCallbacks {
|
|
@@ -322,12 +367,20 @@ export function wrapCallbacksWithLogging(
|
|
|
322
367
|
return wrapped;
|
|
323
368
|
}
|
|
324
369
|
|
|
370
|
+
/** @deprecated Use {@link WrapCallbacksWithLogging}. */
|
|
371
|
+
export function wrapCallbacksWithLogging(
|
|
372
|
+
callbacks: ComponentCallbacks,
|
|
373
|
+
componentName: string
|
|
374
|
+
): ComponentCallbacks {
|
|
375
|
+
return WrapCallbacksWithLogging(callbacks, componentName);
|
|
376
|
+
}
|
|
377
|
+
|
|
325
378
|
/**
|
|
326
379
|
* Extracts props paths used by a component
|
|
327
380
|
* @param componentCode - Component source code
|
|
328
381
|
* @returns Array of prop paths
|
|
329
382
|
*/
|
|
330
|
-
export function
|
|
383
|
+
export function ExtractPropPaths(componentCode: string): string[] {
|
|
331
384
|
const paths: string[] = [];
|
|
332
385
|
|
|
333
386
|
// Simple regex patterns to find prop access
|
|
@@ -346,4 +399,9 @@ export function extractPropPaths(componentCode: string): string[] {
|
|
|
346
399
|
}
|
|
347
400
|
|
|
348
401
|
return [...new Set(paths)]; // Remove duplicates
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/** @deprecated Use {@link ExtractPropPaths}. */
|
|
405
|
+
export function extractPropPaths(componentCode: string): string[] {
|
|
406
|
+
return ExtractPropPaths(componentCode);
|
|
349
407
|
}
|