@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
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function CreateErrorBoundary(React, options = {}) {
|
|
2
2
|
const { onError, fallback, logErrors = true, recovery = 'none' } = options;
|
|
3
3
|
return class ErrorBoundary extends React.Component {
|
|
4
|
+
get state() {
|
|
5
|
+
return this.State;
|
|
6
|
+
}
|
|
7
|
+
set state(value) {
|
|
8
|
+
this.State = value;
|
|
9
|
+
}
|
|
4
10
|
constructor(props) {
|
|
5
11
|
super(props);
|
|
6
|
-
this.
|
|
12
|
+
this.HandleRetry = () => {
|
|
7
13
|
this.setState((prevState) => ({
|
|
8
14
|
hasError: false,
|
|
9
15
|
error: null,
|
|
@@ -11,7 +17,7 @@ export function createErrorBoundary(React, options = {}) {
|
|
|
11
17
|
retryCount: prevState.retryCount + 1
|
|
12
18
|
}));
|
|
13
19
|
};
|
|
14
|
-
this.
|
|
20
|
+
this.HandleReset = () => {
|
|
15
21
|
this.setState({
|
|
16
22
|
hasError: false,
|
|
17
23
|
error: null,
|
|
@@ -19,7 +25,7 @@ export function createErrorBoundary(React, options = {}) {
|
|
|
19
25
|
retryCount: 0
|
|
20
26
|
});
|
|
21
27
|
};
|
|
22
|
-
this.
|
|
28
|
+
this.State = {
|
|
23
29
|
hasError: false,
|
|
24
30
|
error: null,
|
|
25
31
|
errorInfo: null,
|
|
@@ -44,21 +50,33 @@ export function createErrorBoundary(React, options = {}) {
|
|
|
44
50
|
}
|
|
45
51
|
this.setState({ errorInfo });
|
|
46
52
|
}
|
|
53
|
+
get handleRetry() {
|
|
54
|
+
return this.HandleRetry;
|
|
55
|
+
}
|
|
56
|
+
set handleRetry(value) {
|
|
57
|
+
this.HandleRetry = value;
|
|
58
|
+
}
|
|
59
|
+
get handleReset() {
|
|
60
|
+
return this.HandleReset;
|
|
61
|
+
}
|
|
62
|
+
set handleReset(value) {
|
|
63
|
+
this.HandleReset = value;
|
|
64
|
+
}
|
|
47
65
|
render() {
|
|
48
|
-
if (this.
|
|
66
|
+
if (this.State.hasError) {
|
|
49
67
|
if (fallback) {
|
|
50
68
|
if (typeof fallback === 'function') {
|
|
51
69
|
return fallback({
|
|
52
|
-
error: this.
|
|
53
|
-
errorInfo: this.
|
|
54
|
-
retry: this.
|
|
55
|
-
reset: this.
|
|
56
|
-
retryCount: this.
|
|
70
|
+
error: this.State.error,
|
|
71
|
+
errorInfo: this.State.errorInfo,
|
|
72
|
+
retry: this.HandleRetry,
|
|
73
|
+
reset: this.HandleReset,
|
|
74
|
+
retryCount: this.State.retryCount
|
|
57
75
|
});
|
|
58
76
|
}
|
|
59
77
|
return fallback;
|
|
60
78
|
}
|
|
61
|
-
const showRetry = recovery === 'retry' && this.
|
|
79
|
+
const showRetry = recovery === 'retry' && this.State.retryCount < 3;
|
|
62
80
|
const showReset = recovery === 'reset';
|
|
63
81
|
return React.createElement('div', {
|
|
64
82
|
style: {
|
|
@@ -68,7 +86,7 @@ export function createErrorBoundary(React, options = {}) {
|
|
|
68
86
|
borderRadius: '4px',
|
|
69
87
|
margin: '10px'
|
|
70
88
|
}
|
|
71
|
-
}, React.createElement('h2', { style: { color: '#d32f2f' } }, 'Component Error'), React.createElement('p', { style: { color: '#666' } }, 'An error occurred while rendering this component.'), this.
|
|
89
|
+
}, React.createElement('h2', { style: { color: '#d32f2f' } }, 'Component Error'), React.createElement('p', { style: { color: '#666' } }, 'An error occurred while rendering this component.'), this.State.error && React.createElement('details', { style: { marginTop: '10px' } }, React.createElement('summary', { style: { cursor: 'pointer', color: '#333' } }, 'Error Details'), React.createElement('pre', {
|
|
72
90
|
style: {
|
|
73
91
|
backgroundColor: '#f0f0f0',
|
|
74
92
|
padding: '10px',
|
|
@@ -76,8 +94,8 @@ export function createErrorBoundary(React, options = {}) {
|
|
|
76
94
|
overflow: 'auto',
|
|
77
95
|
fontSize: '12px'
|
|
78
96
|
}
|
|
79
|
-
}, this.
|
|
80
|
-
onClick: this.
|
|
97
|
+
}, this.State.error.toString(), '\n\n', this.State.error.stack)), (showRetry || showReset) && React.createElement('div', { style: { marginTop: '10px' } }, showRetry && React.createElement('button', {
|
|
98
|
+
onClick: this.HandleRetry,
|
|
81
99
|
style: {
|
|
82
100
|
padding: '8px 16px',
|
|
83
101
|
marginRight: '10px',
|
|
@@ -87,8 +105,8 @@ export function createErrorBoundary(React, options = {}) {
|
|
|
87
105
|
borderRadius: '4px',
|
|
88
106
|
cursor: 'pointer'
|
|
89
107
|
}
|
|
90
|
-
}, `Retry (${3 - this.
|
|
91
|
-
onClick: this.
|
|
108
|
+
}, `Retry (${3 - this.State.retryCount} attempts left)`), showReset && React.createElement('button', {
|
|
109
|
+
onClick: this.HandleReset,
|
|
92
110
|
style: {
|
|
93
111
|
padding: '8px 16px',
|
|
94
112
|
backgroundColor: '#757575',
|
|
@@ -103,13 +121,19 @@ export function createErrorBoundary(React, options = {}) {
|
|
|
103
121
|
}
|
|
104
122
|
};
|
|
105
123
|
}
|
|
106
|
-
export function
|
|
107
|
-
|
|
124
|
+
export function createErrorBoundary(React, options = {}) {
|
|
125
|
+
return CreateErrorBoundary(React, options);
|
|
126
|
+
}
|
|
127
|
+
export function WithErrorBoundary(React, Component, options = {}) {
|
|
128
|
+
const ErrorBoundaryComponent = CreateErrorBoundary(React, options);
|
|
108
129
|
return (props) => {
|
|
109
130
|
return React.createElement(ErrorBoundaryComponent, null, React.createElement(Component, props));
|
|
110
131
|
};
|
|
111
132
|
}
|
|
112
|
-
export function
|
|
133
|
+
export function withErrorBoundary(React, Component, options = {}) {
|
|
134
|
+
return WithErrorBoundary(React, Component, options);
|
|
135
|
+
}
|
|
136
|
+
export function FormatComponentError(error, componentName, phase) {
|
|
113
137
|
return {
|
|
114
138
|
message: error.message || 'Unknown error',
|
|
115
139
|
stack: error.stack,
|
|
@@ -121,7 +145,10 @@ export function formatComponentError(error, componentName, phase) {
|
|
|
121
145
|
}
|
|
122
146
|
};
|
|
123
147
|
}
|
|
124
|
-
export function
|
|
148
|
+
export function formatComponentError(error, componentName, phase) {
|
|
149
|
+
return FormatComponentError(error, componentName, phase);
|
|
150
|
+
}
|
|
151
|
+
export function CreateErrorLogger(componentName) {
|
|
125
152
|
return (error, errorInfo) => {
|
|
126
153
|
console.group(`🚨 React Component Error: ${componentName}`);
|
|
127
154
|
console.error('Error:', error);
|
|
@@ -130,4 +157,7 @@ export function createErrorLogger(componentName) {
|
|
|
130
157
|
console.groupEnd();
|
|
131
158
|
};
|
|
132
159
|
}
|
|
160
|
+
export function createErrorLogger(componentName) {
|
|
161
|
+
return CreateErrorLogger(componentName);
|
|
162
|
+
}
|
|
133
163
|
//# sourceMappingURL=error-boundary.js.map
|
|
@@ -1 +1 @@
|
|
|
1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AAC,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}"]}
|
|
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;QAIhD,IAAI,KAAK;YACP,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;QAED,IAAI,KAAK,CAAC,KAAqF;YAC7F,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;QAED,YAAY,KAAU;YACpB,KAAK,CAAC,KAAK,CAAC,CAAC;YAsCf,gBAAW,GAAG,GAAG,EAAE;gBACjB,IAAI,CAAC,QAAQ,CAAC,CA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ACF,CAAC;AACJ,CAAC;AAGD,MAAM,UAAU,oBAAoB,CAClC,KAAY,EACZ,aAAqB,EACrB,KAA8B;IAE9B,OAAO,oBAAoB,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,CAAC,CAAC;AAC3D,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;AAGD,MAAM,UAAU,iBAAiB,CAAC,aAAqB;IACrD,OAAO,iBAAiB,CAAC,aAAa,CAAC,CAAC;AAC1C,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 /** @deprecated Use {@link State}. */\n get state(): { hasError: boolean; error: Error | null; errorInfo: any; retryCount: number } {\n return this.State;\n }\n /** @deprecated Use {@link State}. */\n set state(value: { hasError: boolean; error: Error | null; errorInfo: any; retryCount: number }) {\n this.State = value;\n }\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 // React reads this static into a local and calls it UNBOUND\n // (`var f = fiber.type.getDerivedStateFromError; f(error)`), so a stub that\n // forwards through `this` throws while handling the child's error and unmounts\n // the whole tree. The name has to stay on the real declaration.\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 /** @deprecated Use {@link HandleRetry}. */\n get handleRetry() {\n return this.HandleRetry;\n }\n /** @deprecated Use {@link HandleRetry}. */\n set handleRetry(value) {\n this.HandleRetry = value;\n }\n\n HandleReset = () => {\n this.setState({\n hasError: false,\n error: null,\n errorInfo: null,\n retryCount: 0\n });\n };\n\n /** @deprecated Use {@link HandleReset}. */\n get handleReset() {\n return this.HandleReset;\n }\n /** @deprecated Use {@link HandleReset}. */\n set handleReset(value) {\n this.HandleReset = value;\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/** @deprecated Use {@link CreateErrorBoundary}. */\nexport function createErrorBoundary(React: any, options: ErrorBoundaryOptions = {}): any {\n return CreateErrorBoundary(React, options);\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/** @deprecated Use {@link WithErrorBoundary}. */\nexport function withErrorBoundary(React: any, Component: any, options: ErrorBoundaryOptions = {}): any {\n return WithErrorBoundary(React, Component, options);\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/** @deprecated Use {@link FormatComponentError}. */\nexport function formatComponentError(\n error: Error,\n componentName: string,\n phase: ComponentError['phase']\n): ComponentError {\n return FormatComponentError(error, componentName, phase);\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}\n\n/** @deprecated Use {@link CreateErrorLogger}. */\nexport function createErrorLogger(componentName: string): (error: Error, errorInfo: any) => void {\n return CreateErrorLogger(componentName);\n}"]}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { createErrorBoundary, withErrorBoundary, formatComponentError, createErrorLogger } from './error-boundary.js';
|
|
2
|
-
export { buildComponentProps, normalizeCallbacks, normalizeStyles, validateComponentProps, mergeProps, createPropsTransformer, wrapCallbacksWithLogging, extractPropPaths, PropBuilderOptions } from './prop-builder.js';
|
|
3
|
-
export { ComponentHierarchyRegistrar, registerComponentHierarchy, validateComponentSpec, flattenComponentHierarchy, countComponentsInHierarchy, HierarchyRegistrationResult, ComponentRegistrationError, HierarchyRegistrationOptions } from './component-hierarchy.js';
|
|
1
|
+
export { CreateErrorBoundary, createErrorBoundary, WithErrorBoundary, withErrorBoundary, FormatComponentError, formatComponentError, CreateErrorLogger, createErrorLogger } from './error-boundary.js';
|
|
2
|
+
export { BuildComponentProps, buildComponentProps, NormalizeCallbacks, normalizeCallbacks, NormalizeStyles, normalizeStyles, ValidateComponentProps, validateComponentProps, MergeProps, mergeProps, CreatePropsTransformer, createPropsTransformer, WrapCallbacksWithLogging, wrapCallbacksWithLogging, ExtractPropPaths, extractPropPaths, PropBuilderOptions } from './prop-builder.js';
|
|
3
|
+
export { ComponentHierarchyRegistrar, RegisterComponentHierarchy, registerComponentHierarchy, ValidateComponentSpec, validateComponentSpec, FlattenComponentHierarchy, flattenComponentHierarchy, CountComponentsInHierarchy, countComponentsInHierarchy, HierarchyRegistrationResult, ComponentRegistrationError, HierarchyRegistrationOptions } from './component-hierarchy.js';
|
|
4
4
|
export { ReactRootManager, reactRootManager, ManagedReactRoot } from './react-root-manager.js';
|
|
5
5
|
export { RuntimeHook, RootHookContext } from './runtime-hooks.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,mBAAmB,EAAE,mBAAmB,EACxC,iBAAiB,EAAE,iBAAiB,EACpC,oBAAoB,EAAE,oBAAoB,EAC1C,iBAAiB,EAAE,iBAAiB,EACrC,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,mBAAmB,EAAE,mBAAmB,EACxC,kBAAkB,EAAE,kBAAkB,EACtC,eAAe,EAAE,eAAe,EAChC,sBAAsB,EAAE,sBAAsB,EAC9C,UAAU,EAAE,UAAU,EACtB,sBAAsB,EAAE,sBAAsB,EAC9C,wBAAwB,EAAE,wBAAwB,EAClD,gBAAgB,EAAE,gBAAgB,EAClC,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAAE,0BAA0B,EACtD,qBAAqB,EAAE,qBAAqB,EAC5C,yBAAyB,EAAE,yBAAyB,EACpD,0BAA0B,EAAE,0BAA0B,EACtD,2BAA2B,EAC3B,0BAA0B,EAC1B,4BAA4B,EAC7B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,WAAW,EACX,eAAe,EAChB,MAAM,iBAAiB,CAAC"}
|
package/dist/runtime/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { createErrorBoundary, withErrorBoundary, formatComponentError, createErrorLogger } from './error-boundary.js';
|
|
2
|
-
export { buildComponentProps, normalizeCallbacks, normalizeStyles, validateComponentProps, mergeProps, createPropsTransformer, wrapCallbacksWithLogging, extractPropPaths } from './prop-builder.js';
|
|
3
|
-
export { ComponentHierarchyRegistrar, registerComponentHierarchy, validateComponentSpec, flattenComponentHierarchy, countComponentsInHierarchy } from './component-hierarchy.js';
|
|
1
|
+
export { CreateErrorBoundary, createErrorBoundary, WithErrorBoundary, withErrorBoundary, FormatComponentError, formatComponentError, CreateErrorLogger, createErrorLogger } from './error-boundary.js';
|
|
2
|
+
export { BuildComponentProps, buildComponentProps, NormalizeCallbacks, normalizeCallbacks, NormalizeStyles, normalizeStyles, ValidateComponentProps, validateComponentProps, MergeProps, mergeProps, CreatePropsTransformer, createPropsTransformer, WrapCallbacksWithLogging, wrapCallbacksWithLogging, ExtractPropPaths, extractPropPaths } from './prop-builder.js';
|
|
3
|
+
export { ComponentHierarchyRegistrar, RegisterComponentHierarchy, registerComponentHierarchy, ValidateComponentSpec, validateComponentSpec, FlattenComponentHierarchy, flattenComponentHierarchy, CountComponentsInHierarchy, countComponentsInHierarchy } from './component-hierarchy.js';
|
|
4
4
|
export { ReactRootManager, reactRootManager } from './react-root-manager.js';
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,mBAAmB,EAAE,mBAAmB,EACxC,iBAAiB,EAAE,iBAAiB,EACpC,oBAAoB,EAAE,oBAAoB,EAC1C,iBAAiB,EAAE,iBAAiB,EACrC,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,mBAAmB,EAAE,mBAAmB,EACxC,kBAAkB,EAAE,kBAAkB,EACtC,eAAe,EAAE,eAAe,EAChC,sBAAsB,EAAE,sBAAsB,EAC9C,UAAU,EAAE,UAAU,EACtB,sBAAsB,EAAE,sBAAsB,EAC9C,wBAAwB,EAAE,wBAAwB,EAClD,gBAAgB,EAAE,gBAAgB,EAEnC,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAAE,0BAA0B,EACtD,qBAAqB,EAAE,qBAAqB,EAC5C,yBAAyB,EAAE,yBAAyB,EACpD,0BAA0B,EAAE,0BAA0B,EAIvD,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAEjB,MAAM,sBAAsB,CAAC","sourcesContent":["/**\n * @fileoverview Runtime module exports\n * @module @memberjunction/react-runtime/runtime\n */\n\nexport {\n CreateErrorBoundary, createErrorBoundary,\n WithErrorBoundary, withErrorBoundary,\n FormatComponentError, formatComponentError,\n CreateErrorLogger, createErrorLogger\n} from './error-boundary';\n\n\nexport {\n BuildComponentProps, buildComponentProps,\n NormalizeCallbacks, normalizeCallbacks,\n NormalizeStyles, normalizeStyles,\n ValidateComponentProps, validateComponentProps,\n MergeProps, mergeProps,\n CreatePropsTransformer, createPropsTransformer,\n WrapCallbacksWithLogging, wrapCallbacksWithLogging,\n ExtractPropPaths, extractPropPaths,\n PropBuilderOptions\n} from './prop-builder';\n\nexport {\n ComponentHierarchyRegistrar,\n RegisterComponentHierarchy, registerComponentHierarchy,\n ValidateComponentSpec, validateComponentSpec,\n FlattenComponentHierarchy, flattenComponentHierarchy,\n CountComponentsInHierarchy, countComponentsInHierarchy,\n HierarchyRegistrationResult,\n ComponentRegistrationError,\n HierarchyRegistrationOptions\n} from './component-hierarchy';\n\nexport {\n ReactRootManager,\n reactRootManager,\n ManagedReactRoot\n} from './react-root-manager';\n\nexport {\n RuntimeHook,\n RootHookContext\n} from './runtime-hooks';"]}
|
|
@@ -7,12 +7,20 @@ export interface PropBuilderOptions {
|
|
|
7
7
|
transformState?: (state: any) => any;
|
|
8
8
|
debounceUpdateUserState?: number;
|
|
9
9
|
}
|
|
10
|
+
export declare function BuildComponentProps(data?: any, userState?: any, utilities?: any, callbacks?: ComponentCallbacks, components?: Record<string, any>, styles?: ComponentStyles, options?: PropBuilderOptions, onStateChanged?: (stateUpdate: Record<string, any>) => void): ComponentProps;
|
|
10
11
|
export declare function buildComponentProps(data?: any, userState?: any, utilities?: any, callbacks?: ComponentCallbacks, components?: Record<string, any>, styles?: ComponentStyles, options?: PropBuilderOptions, onStateChanged?: (stateUpdate: Record<string, any>) => void): ComponentProps;
|
|
12
|
+
export declare function NormalizeCallbacks(callbacks: any, debounceMs?: number): ComponentCallbacks;
|
|
11
13
|
export declare function normalizeCallbacks(callbacks: any, debounceMs?: number): ComponentCallbacks;
|
|
14
|
+
export declare function NormalizeStyles(styles?: any): any;
|
|
12
15
|
export declare function normalizeStyles(styles?: any): any;
|
|
16
|
+
export declare function ValidateComponentProps(props: ComponentProps): void;
|
|
13
17
|
export declare function validateComponentProps(props: ComponentProps): void;
|
|
18
|
+
export declare function MergeProps(...propsList: Partial<ComponentProps>[]): ComponentProps;
|
|
14
19
|
export declare function mergeProps(...propsList: Partial<ComponentProps>[]): ComponentProps;
|
|
20
|
+
export declare function CreatePropsTransformer(transformations: Record<string, (value: any) => any>): (props: ComponentProps) => ComponentProps;
|
|
15
21
|
export declare function createPropsTransformer(transformations: Record<string, (value: any) => any>): (props: ComponentProps) => ComponentProps;
|
|
22
|
+
export declare function WrapCallbacksWithLogging(callbacks: ComponentCallbacks, componentName: string): ComponentCallbacks;
|
|
16
23
|
export declare function wrapCallbacksWithLogging(callbacks: ComponentCallbacks, componentName: string): ComponentCallbacks;
|
|
24
|
+
export declare function ExtractPropPaths(componentCode: string): string[];
|
|
17
25
|
export declare function extractPropPaths(componentCode: string): string[];
|
|
18
26
|
//# sourceMappingURL=prop-builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prop-builder.d.ts","sourceRoot":"","sources":["../../src/runtime/prop-builder.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAClG,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAO1C,MAAM,WAAW,kBAAkB;IAEjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,GAAG,CAAC;IAEnC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;IAErC,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAaD,wBAAgB,mBAAmB,CACjC,IAAI,GAAE,GAAQ,EACd,SAAS,GAAE,GAAQ,EACnB,SAAS,GAAE,GAAQ,EACnB,SAAS,GAAE,kBAIV,EACD,UAAU,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EACpC,MAAM,CAAC,EAAE,eAAe,EACxB,OAAO,GAAE,kBAAuB,EAChC,cAAc,CAAC,EAAE,CAAC,WAAW,E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AAgB,UAAU,CAAC,GAAG,SAAS,EAAE,OAAO,CAAC,cAAc,CAAC,EAAE,GAAG,cAAc,CAElF;AAOD,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC,GACnD,CAAC,KAAK,EAAE,cAAc,KAAK,cAAc,CAyB3C;AAGD,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC,GACnD,CAAC,KAAK,EAAE,cAAc,KAAK,cAAc,CAE3C;AAQD,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,kBAAkB,EAC7B,aAAa,EAAE,MAAM,GACpB,kBAAkB,CA+CpB;AAGD,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,kBAAkB,EAC7B,aAAa,EAAE,MAAM,GACpB,kBAAkB,CAEpB;AAOD,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,CAmBhE;AAGD,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,CAEhE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LogStatus, GetProductionStatus } from '@memberjunction/core';
|
|
2
|
-
export function
|
|
2
|
+
export function BuildComponentProps(data = {}, userState = {}, utilities = {}, callbacks = {
|
|
3
3
|
OpenEntityRecord: () => { },
|
|
4
4
|
RegisterMethod: () => { },
|
|
5
5
|
CreateSimpleNotification: () => { }
|
|
@@ -11,16 +11,23 @@ export function buildComponentProps(data = {}, userState = {}, utilities = {}, c
|
|
|
11
11
|
data: transformedData,
|
|
12
12
|
userState: transformedState,
|
|
13
13
|
utilities,
|
|
14
|
-
callbacks:
|
|
14
|
+
callbacks: NormalizeCallbacks(callbacks, debounceUpdateUserState),
|
|
15
15
|
components,
|
|
16
|
-
styles:
|
|
16
|
+
styles: NormalizeStyles(styles),
|
|
17
17
|
onStateChanged
|
|
18
18
|
};
|
|
19
19
|
if (validate) {
|
|
20
|
-
|
|
20
|
+
ValidateComponentProps(props);
|
|
21
21
|
}
|
|
22
22
|
return props;
|
|
23
23
|
}
|
|
24
|
+
export function buildComponentProps(data = {}, userState = {}, utilities = {}, callbacks = {
|
|
25
|
+
OpenEntityRecord: () => { },
|
|
26
|
+
RegisterMethod: () => { },
|
|
27
|
+
CreateSimpleNotification: () => { }
|
|
28
|
+
}, components = {}, styles, options = {}, onStateChanged) {
|
|
29
|
+
return BuildComponentProps(data, userState, utilities, callbacks, components, styles, options, onStateChanged);
|
|
30
|
+
}
|
|
24
31
|
const updateUserStateSubjects = new WeakMap();
|
|
25
32
|
const updateUserStateSubscriptions = new WeakMap();
|
|
26
33
|
const loopDetectionStates = new WeakMap();
|
|
@@ -43,7 +50,7 @@ function deepEqual(obj1, obj2) {
|
|
|
43
50
|
}
|
|
44
51
|
return true;
|
|
45
52
|
}
|
|
46
|
-
export function
|
|
53
|
+
export function NormalizeCallbacks(callbacks, debounceMs = 3000) {
|
|
47
54
|
const normalized = {
|
|
48
55
|
OpenEntityRecord: callbacks?.OpenEntityRecord || (() => { }),
|
|
49
56
|
RegisterMethod: callbacks?.RegisterMethod || (() => { }),
|
|
@@ -58,10 +65,16 @@ export function normalizeCallbacks(callbacks, debounceMs = 3000) {
|
|
|
58
65
|
}
|
|
59
66
|
return normalized;
|
|
60
67
|
}
|
|
61
|
-
export function
|
|
68
|
+
export function normalizeCallbacks(callbacks, debounceMs = 3000) {
|
|
69
|
+
return NormalizeCallbacks(callbacks, debounceMs);
|
|
70
|
+
}
|
|
71
|
+
export function NormalizeStyles(styles) {
|
|
62
72
|
return styles;
|
|
63
73
|
}
|
|
64
|
-
export function
|
|
74
|
+
export function normalizeStyles(styles) {
|
|
75
|
+
return NormalizeStyles(styles);
|
|
76
|
+
}
|
|
77
|
+
export function ValidateComponentProps(props) {
|
|
65
78
|
if (props.data === null || props.data === undefined) {
|
|
66
79
|
throw new Error('Component props.data cannot be null or undefined');
|
|
67
80
|
}
|
|
@@ -80,7 +93,10 @@ export function validateComponentProps(props) {
|
|
|
80
93
|
}
|
|
81
94
|
}
|
|
82
95
|
}
|
|
83
|
-
export function
|
|
96
|
+
export function validateComponentProps(props) {
|
|
97
|
+
return ValidateComponentProps(props);
|
|
98
|
+
}
|
|
99
|
+
export function MergeProps(...propsList) {
|
|
84
100
|
const merged = {
|
|
85
101
|
data: {},
|
|
86
102
|
userState: {},
|
|
@@ -111,7 +127,10 @@ export function mergeProps(...propsList) {
|
|
|
111
127
|
}
|
|
112
128
|
return merged;
|
|
113
129
|
}
|
|
114
|
-
export function
|
|
130
|
+
export function mergeProps(...propsList) {
|
|
131
|
+
return MergeProps(...propsList);
|
|
132
|
+
}
|
|
133
|
+
export function CreatePropsTransformer(transformations) {
|
|
115
134
|
return (props) => {
|
|
116
135
|
const transformed = { ...props };
|
|
117
136
|
for (const [path, transformer] of Object.entries(transformations)) {
|
|
@@ -131,7 +150,10 @@ export function createPropsTransformer(transformations) {
|
|
|
131
150
|
return transformed;
|
|
132
151
|
};
|
|
133
152
|
}
|
|
134
|
-
export function
|
|
153
|
+
export function createPropsTransformer(transformations) {
|
|
154
|
+
return CreatePropsTransformer(transformations);
|
|
155
|
+
}
|
|
156
|
+
export function WrapCallbacksWithLogging(callbacks, componentName) {
|
|
135
157
|
const wrapped = {
|
|
136
158
|
OpenEntityRecord: callbacks?.OpenEntityRecord || (() => { }),
|
|
137
159
|
RegisterMethod: callbacks?.RegisterMethod || (() => { }),
|
|
@@ -173,7 +195,10 @@ export function wrapCallbacksWithLogging(callbacks, componentName) {
|
|
|
173
195
|
}
|
|
174
196
|
return wrapped;
|
|
175
197
|
}
|
|
176
|
-
export function
|
|
198
|
+
export function wrapCallbacksWithLogging(callbacks, componentName) {
|
|
199
|
+
return WrapCallbacksWithLogging(callbacks, componentName);
|
|
200
|
+
}
|
|
201
|
+
export function ExtractPropPaths(componentCode) {
|
|
177
202
|
const paths = [];
|
|
178
203
|
const patterns = [
|
|
179
204
|
/props\.data\.(\w+)/g,
|
|
@@ -189,4 +214,7 @@ export function extractPropPaths(componentCode) {
|
|
|
189
214
|
}
|
|
190
215
|
return [...new Set(paths)];
|
|
191
216
|
}
|
|
217
|
+
export function extractPropPaths(componentCode) {
|
|
218
|
+
return ExtractPropPaths(componentCode);
|
|
219
|
+
}
|
|
192
220
|
//# sourceMappingURL=prop-builder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prop-builder.js","sourceRoot":"","sources":["../../src/runtime/prop-builder.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AA6BtE,MAAM,UAAU,mBAAmB,CACjC,OAAY,EAAE,EACd,YAAiB,EAAE,EACnB,YAAiB,EAAE,EACnB,YAAgC;IAC9B,gBAAgB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC1B,cAAc,EAAE,GAAG,EAAE,GAAE,CAAC;IACxB,wBAAwB,EAAE,GAAG,EAAE,GAAE,CAAC;CACnC,EACD,aAAkC,EAAE,EACpC,MAAwB,EACxB,UAA8B,EAAE,EAChC,cAA2D;IAE3D,MAAM,EACJ,QAAQ,GAAG,IAAI,EACf,aAAa,EACb,cAAc,EACd,uBAAuB,GAAG,IAAI,EAC/B,GAAG,OAAO,CAAC;IAGZ,MAAM,eAAe,GAAG,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACnE,MAAM,gBAAgB,GAAG,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAGhF,MAAM,KAAK,GAAmB;QAC5B,IAAI,EAAE,eAAe;QACrB,SAAS,EAAE,gBAAgB;QAC3B,SAAS;QACT,SAAS,EAAE,kBAAkB,CAAC,SAAS,EAAE,uBAAuB,CAAC;QACjE,UA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YACtD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["/**\n * @fileoverview Props builder utilities for React components.\n * Provides utilities for constructing and validating component props.\n * @module @memberjunction/react-runtime/runtime\n */\n\nimport { ComponentStyles, ComponentCallbacks } from '@memberjunction/interactive-component-types';\nimport { ComponentProps } from '../types';\nimport { Subject, debounceTime, Subscription } from 'rxjs';\nimport { LogStatus, GetProductionStatus } from '@memberjunction/core';\n\n/**\n * Options for building component props\n */\nexport interface PropBuilderOptions {\n /** Validate props before building */\n validate?: boolean;\n /** Merge with existing props */\n merge?: boolean;\n /** Transform data before passing to component */\n transformData?: (data: any) => any;\n /** Transform state before passing to component */\n transformState?: (state: any) => any;\n /** Debounce time for UpdateUserState callback in milliseconds */\n debounceUpdateUserState?: number;\n}\n\n/**\n * Builds component props from various sources\n * @param data - Component data\n * @param userState - User state object\n * @param utilities - Utility functions\n * @param callbacks - Component callbacks\n * @param components - Child components\n * @param styles - Component styles\n * @param options - Builder options\n * @returns Built component props\n */\nexport function buildComponentProps(\n data: any = {},\n userState: any = {},\n utilities: any = {},\n callbacks: ComponentCallbacks = {\n OpenEntityRecord: () => {},\n RegisterMethod: () => {},\n CreateSimpleNotification: () => {}\n },\n components: Record<string, any> = {},\n styles?: ComponentStyles,\n options: PropBuilderOptions = {},\n onStateChanged?: (stateUpdate: Record<string, any>) => void\n): ComponentProps {\n const {\n validate = true,\n transformData,\n transformState,\n debounceUpdateUserState = 3000 // Default 3 seconds\n } = options;\n\n // Transform data if transformer provided\n const transformedData = transformData ? transformData(data) : data;\n const transformedState = transformState ? transformState(userState) : userState;\n\n // Build props object\n const props: ComponentProps = {\n data: transformedData,\n userState: transformedState,\n utilities,\n callbacks: normalizeCallbacks(callbacks, debounceUpdateUserState),\n components,\n styles: normalizeStyles(styles),\n onStateChanged\n };\n\n // Validate if enabled\n if (validate) {\n validateComponentProps(props);\n }\n\n return props;\n}\n\n// Store subjects for debouncing per component instance\nconst updateUserStateSubjects = new WeakMap<Function, Subject<any>>();\n\n// Store subscriptions for cleanup\nconst updateUserStateSubscriptions = new WeakMap<Function, Subscription>();\n\n// Loop detection state\ninterface LoopDetectionState {\n count: number;\n lastUpdate: number;\n lastState: any;\n}\nconst loopDetectionStates = new WeakMap<Function, LoopDetectionState>();\n\n// Deep equality check for objects\nfunction deepEqual(obj1: any, obj2: any): boolean {\n if (obj1 === obj2) return true;\n \n if (!obj1 || !obj2) return false;\n if (typeof obj1 !== 'object' || typeof obj2 !== 'object') return false;\n \n const keys1 = Object.keys(obj1);\n const keys2 = Object.keys(obj2);\n \n if (keys1.length !== keys2.length) return false;\n \n for (const key of keys1) {\n if (!keys2.includes(key)) return false;\n if (!deepEqual(obj1[key], obj2[key])) return false;\n }\n \n return true;\n}\n\n/**\n * Normalizes component callbacks\n * @param callbacks - Raw callbacks object\n * @param debounceMs - Debounce time for UpdateUserState in milliseconds\n * @returns Normalized callbacks\n */\nexport function normalizeCallbacks(callbacks: any, debounceMs: number = 3000): ComponentCallbacks {\n // Provide default implementations for required callbacks\n const normalized: ComponentCallbacks = {\n OpenEntityRecord: callbacks?.OpenEntityRecord || (() => {}),\n RegisterMethod: callbacks?.RegisterMethod || (() => {}),\n CreateSimpleNotification: callbacks?.CreateSimpleNotification || (() => {})\n };\n\n // Copy any additional callbacks that might exist\n if (callbacks) {\n Object.keys(callbacks).forEach(key => {\n if (typeof callbacks[key] === 'function' && !normalized.hasOwnProperty(key)) {\n (normalized as any)[key] = callbacks[key];\n }\n });\n }\n\n return normalized;\n}\n\n/**\n * Normalizes component styles\n * @param styles - Raw styles object\n * @returns Normalized styles\n */\nexport function normalizeStyles(styles?: any): any {\n // Pass through the full styles object as-is\n // This allows Skip components to access their full style structure\n // including colors, typography, borders, etc.\n return styles;\n}\n\n/**\n * Validates component props\n * @param props - Props to validate\n * @throws Error if validation fails\n */\nexport function validateComponentProps(props: ComponentProps): void {\n // Validate data\n if (props.data === null || props.data === undefined) {\n throw new Error('Component props.data cannot be null or undefined');\n }\n\n // Validate userState\n if (props.userState === null) {\n throw new Error('Component props.userState cannot be null');\n }\n\n // Validate utilities\n if (props.utilities === null) {\n throw new Error('Component props.utilities cannot be null');\n }\n\n // Validate callbacks\n if (!props.callbacks || typeof props.callbacks !== 'object') {\n throw new Error('Component props.callbacks must be an object');\n }\n\n // Validate callback functions\n for (const [key, value] of Object.entries(props.callbacks)) {\n if (value !== undefined && typeof value !== 'function') {\n throw new Error(`Component callback \"${key}\" must be a function`);\n }\n }\n}\n\n/**\n * Merges multiple prop objects\n * @param propsList - Array of props to merge\n * @returns Merged props\n */\nexport function mergeProps(...propsList: Partial<ComponentProps>[]): ComponentProps {\n const merged: ComponentProps = {\n data: {},\n userState: {},\n utilities: {},\n callbacks: {},\n components: {},\n styles: {} as ComponentStyles\n };\n\n for (const props of propsList) {\n if (props.data) {\n merged.data = { ...merged.data, ...props.data };\n }\n\n if (props.userState) {\n merged.userState = { ...merged.userState, ...props.userState };\n }\n\n if (props.utilities) {\n merged.utilities = { ...merged.utilities, ...props.utilities };\n }\n\n if (props.callbacks) {\n merged.callbacks = { ...merged.callbacks, ...props.callbacks };\n }\n\n if (props.components) {\n merged.components = { ...merged.components, ...props.components };\n }\n\n if (props.styles) {\n merged.styles = { ...merged.styles, ...props.styles };\n }\n }\n\n return merged;\n}\n \n/**\n * Creates a props transformer function\n * @param transformations - Map of prop paths to transformer functions\n * @returns Props transformer\n */\nexport function createPropsTransformer(\n transformations: Record<string, (value: any) => any>\n): (props: ComponentProps) => ComponentProps {\n return (props: ComponentProps) => {\n const transformed = { ...props };\n\n for (const [path, transformer] of Object.entries(transformations)) {\n const pathParts = path.split('.');\n let current: any = transformed;\n \n // Navigate to the parent of the target property\n for (let i = 0; i < pathParts.length - 1; i++) {\n if (!current[pathParts[i]]) {\n current[pathParts[i]] = {};\n }\n current = current[pathParts[i]];\n }\n\n // Apply transformation\n const lastPart = pathParts[pathParts.length - 1];\n if (current[lastPart] !== undefined) {\n current[lastPart] = transformer(current[lastPart]);\n }\n }\n\n return transformed;\n };\n}\n\n/**\n * Creates a callback wrapper that adds logging\n * @param callbacks - Original callbacks\n * @param componentName - Component name for logging\n * @returns Wrapped callbacks\n */\nexport function wrapCallbacksWithLogging(\n callbacks: ComponentCallbacks,\n componentName: string\n): ComponentCallbacks {\n const wrapped: ComponentCallbacks = {\n OpenEntityRecord: callbacks?.OpenEntityRecord || (() => {}),\n RegisterMethod: callbacks?.RegisterMethod || (() => {}),\n CreateSimpleNotification: callbacks?.CreateSimpleNotification || (() => {})\n };\n\n // Wrap any additional callbacks that might exist\n Object.keys(callbacks).forEach(key => {\n if (key !== 'OpenEntityRecord' && key !== 'RegisterMethod' && key !== 'CreateSimpleNotification' && typeof (callbacks as any)[key] === 'function') {\n (wrapped as any)[key] = (...args: any[]) => {\n if (!GetProductionStatus()) {\n LogStatus(`[${componentName}] ${key} called with args:`, undefined, args);\n }\n return (callbacks as any)[key](...args);\n };\n }\n });\n\n if (callbacks.OpenEntityRecord) {\n wrapped.OpenEntityRecord = (entityName: string, key: any) => {\n if (!GetProductionStatus()) {\n LogStatus(`[${componentName}] OpenEntityRecord called:`, undefined, { entityName, key });\n }\n callbacks.OpenEntityRecord!(entityName, key);\n };\n }\n\n if (callbacks.RegisterMethod) {\n wrapped.RegisterMethod = (methodName: any, handler: any) => {\n if (!GetProductionStatus()) {\n LogStatus(`[${componentName}] RegisterMethod called for:`, undefined, methodName);\n }\n callbacks.RegisterMethod!(methodName, handler);\n };\n }\n\n if (callbacks.CreateSimpleNotification) {\n wrapped.CreateSimpleNotification = (message: string, style: \"none\" | \"success\" | \"error\" | \"warning\" | \"info\", hideAfter?: number) => {\n if (!GetProductionStatus()) {\n LogStatus(`[${componentName}] CreateSimpleNotification called:`, undefined, { message, style, hideAfter });\n }\n callbacks.CreateSimpleNotification!(message, style, hideAfter);\n };\n }\n\n return wrapped;\n}\n\n/**\n * Extracts props paths used by a component\n * @param componentCode - Component source code\n * @returns Array of prop paths\n */\nexport function extractPropPaths(componentCode: string): string[] {\n const paths: string[] = [];\n \n // Simple regex patterns to find prop access\n const patterns = [\n /props\\.data\\.(\\w+)/g,\n /props\\.userState\\.(\\w+)/g,\n /props\\.utilities\\.(\\w+)/g,\n /props\\.callbacks\\.(\\w+)/g\n ];\n\n for (const pattern of patterns) {\n let match;\n while ((match = pattern.exec(componentCode)) !== null) {\n paths.push(match[0]);\n }\n }\n\n return [...new Set(paths)]; // Remove duplicates\n}"]}
|
|
1
|
+
{"version":3,"file":"prop-builder.js","sourceRoot":"","sources":["../../src/runtime/prop-builder.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AA6BtE,MAAM,UAAU,mBAAmB,CACjC,OAAY,EAAE,EACd,YAAiB,EAAE,EACnB,YAAiB,EAAE,EACnB,YAAgC;IAC9B,gBAAgB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC1B,cAAc,EAAE,GAAG,EAAE,GAAE,CAAC;IACxB,wBAAwB,EAAE,GAAG,EAAE,GAAE,CAAC;CACnC,EACD,aAAkC,EAAE,EACpC,MAAwB,EACxB,UAA8B,EAAE,EAChC,cAA2D;IAE3D,MAAM,EACJ,QAAQ,GAAG,IAAI,EACf,aAAa,EACb,cAAc,EACd,uBAAuB,GAAG,IAAI,EAC/B,GAAG,OAAO,CAAC;IAGZ,MAAM,eAAe,GAAG,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACnE,MAAM,gBAAgB,GAAG,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAGhF,MAAM,KAAK,GAAmB;QAC5B,IAAI,EAAE,eAAe;QACrB,SAA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CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7B,CAAC;AAGD,MAAM,UAAU,gBAAgB,CAAC,aAAqB;IACpD,OAAO,gBAAgB,CAAC,aAAa,CAAC,CAAC;AACzC,CAAC","sourcesContent":["/**\n * @fileoverview Props builder utilities for React components.\n * Provides utilities for constructing and validating component props.\n * @module @memberjunction/react-runtime/runtime\n */\n\nimport { ComponentStyles, ComponentCallbacks } from '@memberjunction/interactive-component-types';\nimport { ComponentProps } from '../types';\nimport { Subject, debounceTime, Subscription } from 'rxjs';\nimport { LogStatus, GetProductionStatus } from '@memberjunction/core';\n\n/**\n * Options for building component props\n */\nexport interface PropBuilderOptions {\n /** Validate props before building */\n validate?: boolean;\n /** Merge with existing props */\n merge?: boolean;\n /** Transform data before passing to component */\n transformData?: (data: any) => any;\n /** Transform state before passing to component */\n transformState?: (state: any) => any;\n /** Debounce time for UpdateUserState callback in milliseconds */\n debounceUpdateUserState?: number;\n}\n\n/**\n * Builds component props from various sources\n * @param data - Component data\n * @param userState - User state object\n * @param utilities - Utility functions\n * @param callbacks - Component callbacks\n * @param components - Child components\n * @param styles - Component styles\n * @param options - Builder options\n * @returns Built component props\n */\nexport function BuildComponentProps(\n data: any = {},\n userState: any = {},\n utilities: any = {},\n callbacks: ComponentCallbacks = {\n OpenEntityRecord: () => {},\n RegisterMethod: () => {},\n CreateSimpleNotification: () => {}\n },\n components: Record<string, any> = {},\n styles?: ComponentStyles,\n options: PropBuilderOptions = {},\n onStateChanged?: (stateUpdate: Record<string, any>) => void\n): ComponentProps {\n const {\n validate = true,\n transformData,\n transformState,\n debounceUpdateUserState = 3000 // Default 3 seconds\n } = options;\n\n // Transform data if transformer provided\n const transformedData = transformData ? transformData(data) : data;\n const transformedState = transformState ? transformState(userState) : userState;\n\n // Build props object\n const props: ComponentProps = {\n data: transformedData,\n userState: transformedState,\n utilities,\n callbacks: NormalizeCallbacks(callbacks, debounceUpdateUserState),\n components,\n styles: NormalizeStyles(styles),\n onStateChanged\n };\n\n // Validate if enabled\n if (validate) {\n ValidateComponentProps(props);\n }\n\n return props;\n}\n\n/** @deprecated Use {@link BuildComponentProps}. */\nexport function buildComponentProps(\n data: any = {},\n userState: any = {},\n utilities: any = {},\n callbacks: ComponentCallbacks = {\n OpenEntityRecord: () => {},\n RegisterMethod: () => {},\n CreateSimpleNotification: () => {}\n },\n components: Record<string, any> = {},\n styles?: ComponentStyles,\n options: PropBuilderOptions = {},\n onStateChanged?: (stateUpdate: Record<string, any>) => void\n): ComponentProps {\n return BuildComponentProps(data, userState, utilities, callbacks, components, styles, options, onStateChanged);\n}\n\n// Store subjects for debouncing per component instance\nconst updateUserStateSubjects = new WeakMap<Function, Subject<any>>();\n\n// Store subscriptions for cleanup\nconst updateUserStateSubscriptions = new WeakMap<Function, Subscription>();\n\n// Loop detection state\ninterface LoopDetectionState {\n count: number;\n lastUpdate: number;\n lastState: any;\n}\nconst loopDetectionStates = new WeakMap<Function, LoopDetectionState>();\n\n// Deep equality check for objects\nfunction deepEqual(obj1: any, obj2: any): boolean {\n if (obj1 === obj2) return true;\n \n if (!obj1 || !obj2) return false;\n if (typeof obj1 !== 'object' || typeof obj2 !== 'object') return false;\n \n const keys1 = Object.keys(obj1);\n const keys2 = Object.keys(obj2);\n \n if (keys1.length !== keys2.length) return false;\n \n for (const key of keys1) {\n if (!keys2.includes(key)) return false;\n if (!deepEqual(obj1[key], obj2[key])) return false;\n }\n \n return true;\n}\n\n/**\n * Normalizes component callbacks\n * @param callbacks - Raw callbacks object\n * @param debounceMs - Debounce time for UpdateUserState in milliseconds\n * @returns Normalized callbacks\n */\nexport function NormalizeCallbacks(callbacks: any, debounceMs: number = 3000): ComponentCallbacks {\n // Provide default implementations for required callbacks\n const normalized: ComponentCallbacks = {\n OpenEntityRecord: callbacks?.OpenEntityRecord || (() => {}),\n RegisterMethod: callbacks?.RegisterMethod || (() => {}),\n CreateSimpleNotification: callbacks?.CreateSimpleNotification || (() => {})\n };\n\n // Copy any additional callbacks that might exist\n if (callbacks) {\n Object.keys(callbacks).forEach(key => {\n if (typeof callbacks[key] === 'function' && !normalized.hasOwnProperty(key)) {\n (normalized as any)[key] = callbacks[key];\n }\n });\n }\n\n return normalized;\n}\n\n/** @deprecated Use {@link NormalizeCallbacks}. */\nexport function normalizeCallbacks(callbacks: any, debounceMs: number = 3000): ComponentCallbacks {\n return NormalizeCallbacks(callbacks, debounceMs);\n}\n\n/**\n * Normalizes component styles\n * @param styles - Raw styles object\n * @returns Normalized styles\n */\nexport function NormalizeStyles(styles?: any): any {\n // Pass through the full styles object as-is\n // This allows Skip components to access their full style structure\n // including colors, typography, borders, etc.\n return styles;\n}\n\n/** @deprecated Use {@link NormalizeStyles}. */\nexport function normalizeStyles(styles?: any): any {\n return NormalizeStyles(styles);\n}\n\n/**\n * Validates component props\n * @param props - Props to validate\n * @throws Error if validation fails\n */\nexport function ValidateComponentProps(props: ComponentProps): void {\n // Validate data\n if (props.data === null || props.data === undefined) {\n throw new Error('Component props.data cannot be null or undefined');\n }\n\n // Validate userState\n if (props.userState === null) {\n throw new Error('Component props.userState cannot be null');\n }\n\n // Validate utilities\n if (props.utilities === null) {\n throw new Error('Component props.utilities cannot be null');\n }\n\n // Validate callbacks\n if (!props.callbacks || typeof props.callbacks !== 'object') {\n throw new Error('Component props.callbacks must be an object');\n }\n\n // Validate callback functions\n for (const [key, value] of Object.entries(props.callbacks)) {\n if (value !== undefined && typeof value !== 'function') {\n throw new Error(`Component callback \"${key}\" must be a function`);\n }\n }\n}\n\n/** @deprecated Use {@link ValidateComponentProps}. */\nexport function validateComponentProps(props: ComponentProps): void {\n return ValidateComponentProps(props);\n}\n\n/**\n * Merges multiple prop objects\n * @param propsList - Array of props to merge\n * @returns Merged props\n */\nexport function MergeProps(...propsList: Partial<ComponentProps>[]): ComponentProps {\n const merged: ComponentProps = {\n data: {},\n userState: {},\n utilities: {},\n callbacks: {},\n components: {},\n styles: {} as ComponentStyles\n };\n\n for (const props of propsList) {\n if (props.data) {\n merged.data = { ...merged.data, ...props.data };\n }\n\n if (props.userState) {\n merged.userState = { ...merged.userState, ...props.userState };\n }\n\n if (props.utilities) {\n merged.utilities = { ...merged.utilities, ...props.utilities };\n }\n\n if (props.callbacks) {\n merged.callbacks = { ...merged.callbacks, ...props.callbacks };\n }\n\n if (props.components) {\n merged.components = { ...merged.components, ...props.components };\n }\n\n if (props.styles) {\n merged.styles = { ...merged.styles, ...props.styles };\n }\n }\n\n return merged;\n}\n\n/** @deprecated Use {@link MergeProps}. */\nexport function mergeProps(...propsList: Partial<ComponentProps>[]): ComponentProps {\n return MergeProps(...propsList);\n}\n \n/**\n * Creates a props transformer function\n * @param transformations - Map of prop paths to transformer functions\n * @returns Props transformer\n */\nexport function CreatePropsTransformer(\n transformations: Record<string, (value: any) => any>\n): (props: ComponentProps) => ComponentProps {\n return (props: ComponentProps) => {\n const transformed = { ...props };\n\n for (const [path, transformer] of Object.entries(transformations)) {\n const pathParts = path.split('.');\n let current: any = transformed;\n \n // Navigate to the parent of the target property\n for (let i = 0; i < pathParts.length - 1; i++) {\n if (!current[pathParts[i]]) {\n current[pathParts[i]] = {};\n }\n current = current[pathParts[i]];\n }\n\n // Apply transformation\n const lastPart = pathParts[pathParts.length - 1];\n if (current[lastPart] !== undefined) {\n current[lastPart] = transformer(current[lastPart]);\n }\n }\n\n return transformed;\n };\n}\n\n/** @deprecated Use {@link CreatePropsTransformer}. */\nexport function createPropsTransformer(\n transformations: Record<string, (value: any) => any>\n): (props: ComponentProps) => ComponentProps {\n return CreatePropsTransformer(transformations);\n}\n\n/**\n * Creates a callback wrapper that adds logging\n * @param callbacks - Original callbacks\n * @param componentName - Component name for logging\n * @returns Wrapped callbacks\n */\nexport function WrapCallbacksWithLogging(\n callbacks: ComponentCallbacks,\n componentName: string\n): ComponentCallbacks {\n const wrapped: ComponentCallbacks = {\n OpenEntityRecord: callbacks?.OpenEntityRecord || (() => {}),\n RegisterMethod: callbacks?.RegisterMethod || (() => {}),\n CreateSimpleNotification: callbacks?.CreateSimpleNotification || (() => {})\n };\n\n // Wrap any additional callbacks that might exist\n Object.keys(callbacks).forEach(key => {\n if (key !== 'OpenEntityRecord' && key !== 'RegisterMethod' && key !== 'CreateSimpleNotification' && typeof (callbacks as any)[key] === 'function') {\n (wrapped as any)[key] = (...args: any[]) => {\n if (!GetProductionStatus()) {\n LogStatus(`[${componentName}] ${key} called with args:`, undefined, args);\n }\n return (callbacks as any)[key](...args);\n };\n }\n });\n\n if (callbacks.OpenEntityRecord) {\n wrapped.OpenEntityRecord = (entityName: string, key: any) => {\n if (!GetProductionStatus()) {\n LogStatus(`[${componentName}] OpenEntityRecord called:`, undefined, { entityName, key });\n }\n callbacks.OpenEntityRecord!(entityName, key);\n };\n }\n\n if (callbacks.RegisterMethod) {\n wrapped.RegisterMethod = (methodName: any, handler: any) => {\n if (!GetProductionStatus()) {\n LogStatus(`[${componentName}] RegisterMethod called for:`, undefined, methodName);\n }\n callbacks.RegisterMethod!(methodName, handler);\n };\n }\n\n if (callbacks.CreateSimpleNotification) {\n wrapped.CreateSimpleNotification = (message: string, style: \"none\" | \"success\" | \"error\" | \"warning\" | \"info\", hideAfter?: number) => {\n if (!GetProductionStatus()) {\n LogStatus(`[${componentName}] CreateSimpleNotification called:`, undefined, { message, style, hideAfter });\n }\n callbacks.CreateSimpleNotification!(message, style, hideAfter);\n };\n }\n\n return wrapped;\n}\n\n/** @deprecated Use {@link WrapCallbacksWithLogging}. */\nexport function wrapCallbacksWithLogging(\n callbacks: ComponentCallbacks,\n componentName: string\n): ComponentCallbacks {\n return WrapCallbacksWithLogging(callbacks, componentName);\n}\n\n/**\n * Extracts props paths used by a component\n * @param componentCode - Component source code\n * @returns Array of prop paths\n */\nexport function ExtractPropPaths(componentCode: string): string[] {\n const paths: string[] = [];\n \n // Simple regex patterns to find prop access\n const patterns = [\n /props\\.data\\.(\\w+)/g,\n /props\\.userState\\.(\\w+)/g,\n /props\\.utilities\\.(\\w+)/g,\n /props\\.callbacks\\.(\\w+)/g\n ];\n\n for (const pattern of patterns) {\n let match;\n while ((match = pattern.exec(componentCode)) !== null) {\n paths.push(match[0]);\n }\n }\n\n return [...new Set(paths)]; // Remove duplicates\n}\n\n/** @deprecated Use {@link ExtractPropPaths}. */\nexport function extractPropPaths(componentCode: string): string[] {\n return ExtractPropPaths(componentCode);\n}"]}
|
|
@@ -15,16 +15,26 @@ export declare class ReactRootManager {
|
|
|
15
15
|
private firstRootCreated;
|
|
16
16
|
RegisterHook(hook: RuntimeHook): void;
|
|
17
17
|
RemoveHook(hookName: string): boolean;
|
|
18
|
+
CreateRoot(container: HTMLElement, createRootFn: (container: HTMLElement) => any, componentId?: string): string;
|
|
18
19
|
createRoot(container: HTMLElement, createRootFn: (container: HTMLElement) => any, componentId?: string): string;
|
|
19
20
|
render(rootId: string, element: any, onComplete?: () => void): void;
|
|
21
|
+
UnmountRoot(rootId: string, force?: boolean): Promise<void>;
|
|
20
22
|
unmountRoot(rootId: string, force?: boolean): Promise<void>;
|
|
23
|
+
UnmountComponentRoots(componentId: string): Promise<void>;
|
|
21
24
|
unmountComponentRoots(componentId: string): Promise<void>;
|
|
25
|
+
IsRendering(rootId: string): boolean;
|
|
22
26
|
isRendering(rootId: string): boolean;
|
|
27
|
+
GetStats(): {
|
|
28
|
+
totalRoots: number;
|
|
29
|
+
renderingRoots: number;
|
|
30
|
+
pendingUnmounts: number;
|
|
31
|
+
};
|
|
23
32
|
getStats(): {
|
|
24
33
|
totalRoots: number;
|
|
25
34
|
renderingRoots: number;
|
|
26
35
|
pendingUnmounts: number;
|
|
27
36
|
};
|
|
37
|
+
Cleanup(): Promise<void>;
|
|
28
38
|
cleanup(): Promise<void>;
|
|
29
39
|
private invokeHooks;
|
|
30
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-root-manager.d.ts","sourceRoot":"","sources":["../../src/runtime/react-root-manager.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAmB,MAAM,iBAAiB,CAAC;AAE/D,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,GAAG,CAAC;IACV,SAAS,EAAE,WAAW,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,IAAI,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAUD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,KAAK,CAAuC;IACpD,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,YAAY,CAAiC;IACrD,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,gBAAgB,CAAS;IAOjC,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IASrC,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAgBrC,UAAU,CACR,SAAS,EAAE,WAAW,EACtB,YAAY,EAAE,CAAC,SAAS,EAAE,WAAW,KAAK,GAAG,EAC7C,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM;
|
|
1
|
+
{"version":3,"file":"react-root-manager.d.ts","sourceRoot":"","sources":["../../src/runtime/react-root-manager.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAmB,MAAM,iBAAiB,CAAC;AAE/D,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,GAAG,CAAC;IACV,SAAS,EAAE,WAAW,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,IAAI,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAUD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,KAAK,CAAuC;IACpD,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,YAAY,CAAiC;IACrD,OAAO,CAAC,KAAK,CAAqB;IAClC,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