@memberjunction/react-runtime 2.70.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/CHANGELOG.md +3 -0
  3. package/README.md +224 -0
  4. package/dist/compiler/babel-config.d.ts +40 -0
  5. package/dist/compiler/babel-config.d.ts.map +1 -0
  6. package/dist/compiler/babel-config.js +52 -0
  7. package/dist/compiler/component-compiler.d.ts +22 -0
  8. package/dist/compiler/component-compiler.d.ts.map +1 -0
  9. package/dist/compiler/component-compiler.js +188 -0
  10. package/dist/compiler/index.d.ts +3 -0
  11. package/dist/compiler/index.d.ts.map +1 -0
  12. package/dist/compiler/index.js +13 -0
  13. package/dist/index.d.ts +41 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +95 -0
  16. package/dist/registry/component-registry.d.ts +32 -0
  17. package/dist/registry/component-registry.d.ts.map +1 -0
  18. package/dist/registry/component-registry.js +197 -0
  19. package/dist/registry/component-resolver.d.ts +29 -0
  20. package/dist/registry/component-resolver.d.ts.map +1 -0
  21. package/dist/registry/component-resolver.js +112 -0
  22. package/dist/registry/index.d.ts +3 -0
  23. package/dist/registry/index.d.ts.map +1 -0
  24. package/dist/registry/index.js +7 -0
  25. package/dist/runtime/component-hierarchy.d.ts +44 -0
  26. package/dist/runtime/component-hierarchy.d.ts.map +1 -0
  27. package/dist/runtime/component-hierarchy.js +162 -0
  28. package/dist/runtime/component-wrapper.d.ts +18 -0
  29. package/dist/runtime/component-wrapper.d.ts.map +1 -0
  30. package/dist/runtime/component-wrapper.js +108 -0
  31. package/dist/runtime/error-boundary.d.ts +6 -0
  32. package/dist/runtime/error-boundary.d.ts.map +1 -0
  33. package/dist/runtime/error-boundary.js +139 -0
  34. package/dist/runtime/index.d.ts +5 -0
  35. package/dist/runtime/index.d.ts.map +1 -0
  36. package/dist/runtime/index.js +31 -0
  37. package/dist/runtime/prop-builder.d.ts +16 -0
  38. package/dist/runtime/prop-builder.d.ts.map +1 -0
  39. package/dist/runtime/prop-builder.js +161 -0
  40. package/dist/types/index.d.ts +98 -0
  41. package/dist/types/index.d.ts.map +1 -0
  42. package/dist/types/index.js +2 -0
  43. package/package.json +36 -0
  44. package/src/compiler/babel-config.ts +97 -0
  45. package/src/compiler/component-compiler.ts +366 -0
  46. package/src/compiler/index.ts +15 -0
  47. package/src/index.ts +125 -0
  48. package/src/registry/component-registry.ts +379 -0
  49. package/src/registry/component-resolver.ts +275 -0
  50. package/src/registry/index.ts +7 -0
  51. package/src/runtime/component-hierarchy.ts +346 -0
  52. package/src/runtime/component-wrapper.ts +249 -0
  53. package/src/runtime/error-boundary.ts +242 -0
  54. package/src/runtime/index.ts +45 -0
  55. package/src/runtime/prop-builder.ts +290 -0
  56. package/src/types/index.ts +226 -0
  57. package/tsconfig.json +37 -0
  58. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.countComponentsInHierarchy = exports.flattenComponentHierarchy = exports.validateComponentSpec = exports.registerComponentHierarchy = exports.ComponentHierarchyRegistrar = void 0;
4
+ class ComponentHierarchyRegistrar {
5
+ constructor(compiler, registry, runtimeContext) {
6
+ this.compiler = compiler;
7
+ this.registry = registry;
8
+ this.runtimeContext = runtimeContext;
9
+ }
10
+ async registerHierarchy(rootSpec, options = {}) {
11
+ const { styles, namespace = 'Global', version = 'v1', continueOnError = true, allowOverride = true } = options;
12
+ const registeredComponents = [];
13
+ const errors = [];
14
+ const warnings = [];
15
+ const rootResult = await this.registerSingleComponent(rootSpec, { styles, namespace, version, allowOverride });
16
+ if (rootResult.success) {
17
+ registeredComponents.push(rootSpec.componentName);
18
+ }
19
+ else {
20
+ errors.push(rootResult.error);
21
+ if (!continueOnError) {
22
+ return { success: false, registeredComponents, errors, warnings };
23
+ }
24
+ }
25
+ const childComponents = rootSpec.childComponents || rootSpec.components || [];
26
+ if (childComponents.length > 0) {
27
+ const childResult = await this.registerChildComponents(childComponents, { styles, namespace, version, continueOnError, allowOverride }, registeredComponents, errors, warnings);
28
+ }
29
+ return {
30
+ success: errors.length === 0,
31
+ registeredComponents,
32
+ errors,
33
+ warnings
34
+ };
35
+ }
36
+ async registerSingleComponent(spec, options) {
37
+ const { styles, namespace = 'Global', version = 'v1', allowOverride = true } = options;
38
+ try {
39
+ if (!spec.componentCode) {
40
+ return {
41
+ success: true,
42
+ error: undefined
43
+ };
44
+ }
45
+ const existingComponent = this.registry.get(spec.componentName, namespace, version);
46
+ if (existingComponent && !allowOverride) {
47
+ return {
48
+ success: false,
49
+ error: {
50
+ componentName: spec.componentName,
51
+ error: `Component already registered in ${namespace}/${version}`,
52
+ phase: 'registration'
53
+ }
54
+ };
55
+ }
56
+ const compileOptions = {
57
+ componentName: spec.componentName,
58
+ componentCode: spec.componentCode,
59
+ styles
60
+ };
61
+ const compilationResult = await this.compiler.compile(compileOptions);
62
+ if (!compilationResult.success) {
63
+ return {
64
+ success: false,
65
+ error: {
66
+ componentName: spec.componentName,
67
+ error: compilationResult.error?.message || 'Unknown compilation error',
68
+ phase: 'compilation'
69
+ }
70
+ };
71
+ }
72
+ const componentFactory = compilationResult.component.component(this.runtimeContext, styles);
73
+ this.registry.register(spec.componentName, componentFactory.component, namespace, version);
74
+ return { success: true };
75
+ }
76
+ catch (error) {
77
+ return {
78
+ success: false,
79
+ error: {
80
+ componentName: spec.componentName,
81
+ error: error instanceof Error ? error.message : String(error),
82
+ phase: 'registration'
83
+ }
84
+ };
85
+ }
86
+ }
87
+ async registerChildComponents(children, options, registeredComponents, errors, warnings) {
88
+ for (const child of children) {
89
+ const childResult = await this.registerSingleComponent(child, {
90
+ styles: options.styles,
91
+ namespace: options.namespace,
92
+ version: options.version,
93
+ allowOverride: options.allowOverride
94
+ });
95
+ if (childResult.success) {
96
+ if (child.componentCode) {
97
+ registeredComponents.push(child.componentName);
98
+ }
99
+ }
100
+ else {
101
+ errors.push(childResult.error);
102
+ if (!options.continueOnError) {
103
+ return;
104
+ }
105
+ }
106
+ const nestedChildren = child.childComponents || child.components || [];
107
+ if (nestedChildren.length > 0) {
108
+ await this.registerChildComponents(nestedChildren, options, registeredComponents, errors, warnings);
109
+ }
110
+ }
111
+ }
112
+ }
113
+ exports.ComponentHierarchyRegistrar = ComponentHierarchyRegistrar;
114
+ async function registerComponentHierarchy(rootSpec, compiler, registry, runtimeContext, options = {}) {
115
+ const registrar = new ComponentHierarchyRegistrar(compiler, registry, runtimeContext);
116
+ return registrar.registerHierarchy(rootSpec, options);
117
+ }
118
+ exports.registerComponentHierarchy = registerComponentHierarchy;
119
+ function validateComponentSpec(spec) {
120
+ const errors = [];
121
+ if (!spec.componentName) {
122
+ errors.push('Component specification must have a componentName');
123
+ }
124
+ if (spec.componentCode) {
125
+ if (typeof spec.componentCode !== 'string') {
126
+ errors.push(`Component code for ${spec.componentName} must be a string`);
127
+ }
128
+ if (spec.componentCode.trim().length === 0) {
129
+ errors.push(`Component code for ${spec.componentName} cannot be empty`);
130
+ }
131
+ }
132
+ const children = spec.childComponents || spec.components || [];
133
+ children.forEach((child, index) => {
134
+ const childErrors = validateComponentSpec(child);
135
+ childErrors.forEach(error => {
136
+ errors.push(`Child ${index} (${child.componentName || 'unnamed'}): ${error}`);
137
+ });
138
+ });
139
+ return errors;
140
+ }
141
+ exports.validateComponentSpec = validateComponentSpec;
142
+ function flattenComponentHierarchy(rootSpec) {
143
+ const components = [rootSpec];
144
+ const children = rootSpec.childComponents || rootSpec.components || [];
145
+ children.forEach(child => {
146
+ components.push(...flattenComponentHierarchy(child));
147
+ });
148
+ return components;
149
+ }
150
+ exports.flattenComponentHierarchy = flattenComponentHierarchy;
151
+ function countComponentsInHierarchy(rootSpec, includeEmpty = false) {
152
+ let count = 0;
153
+ if (includeEmpty || rootSpec.componentCode) {
154
+ count = 1;
155
+ }
156
+ const children = rootSpec.childComponents || rootSpec.components || [];
157
+ children.forEach(child => {
158
+ count += countComponentsInHierarchy(child, includeEmpty);
159
+ });
160
+ return count;
161
+ }
162
+ exports.countComponentsInHierarchy = countComponentsInHierarchy;
@@ -0,0 +1,18 @@
1
+ import { ComponentProps, ComponentLifecycle } from '../types';
2
+ export interface WrapperOptions {
3
+ displayName?: string;
4
+ enableProfiling?: boolean;
5
+ logProps?: boolean;
6
+ lifecycle?: ComponentLifecycle;
7
+ defaultProps?: Partial<ComponentProps>;
8
+ }
9
+ export declare function wrapComponent(React: any, Component: any, options?: WrapperOptions): any;
10
+ export declare function memoizeComponent(React: any, Component: any, propsAreEqual?: (prevProps: any, nextProps: any) => boolean): any;
11
+ export declare function lazyComponent(React: any, loader: () => Promise<{
12
+ default: any;
13
+ }>, fallback?: any): any;
14
+ export declare function injectProps(React: any, Component: any, injectedProps: any): any;
15
+ export declare function conditionalComponent(React: any, Component: any, condition: boolean | ((props: any) => boolean), fallback?: any): any;
16
+ export declare function withErrorHandler(React: any, Component: any, errorHandler: (error: Error) => void): any;
17
+ export declare function portalComponent(React: any, ReactDOM: any, Component: any, container: Element | string): any;
18
+ //# sourceMappingURL=component-wrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-wrapper.d.ts","sourceRoot":"","sources":["../../src/runtime/component-wrapper.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAK9D,MAAM,WAAW,cAAc;IAE7B,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAE/B,YAAY,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;CACxC;AASD,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,GAAE,cAAmB,GAAG,GAAG,CA+E3F;AASD,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,GAAG,EACV,SAAS,EAAE,GAAG,EACd,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,KAAK,OAAO,GAC1D,GAAG,CAEL;AASD,wBAAgB,aAAa,CAC3B,KAAK,EAAE,GAAG,EACV,MAAM,EAAE,MAAM,OAAO,CAAC;IAAE,OAAO,EAAE,GAAG,CAAA;CAAE,CAAC,EACvC,QAAQ,CAAC,EAAE,GAAG,GACb,GAAG,CAYL;AASD,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,GAAG,GAAG,CAK/E;AAUD,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,GAAG,EACV,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,OAAO,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,EAC9C,QAAQ,CAAC,EAAE,GAAG,GACb,GAAG,CAUL;AASD,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,GAAG,EACV,SAAS,EAAE,GAAG,EACd,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GACnC,GAAG,CAUL;AAUD,wBAAgB,eAAe,CAC7B,KAAK,EAAE,GAAG,EACV,QAAQ,EAAE,GAAG,EACb,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,OAAO,GAAG,MAAM,GAC1B,GAAG,CAqBL"}
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.portalComponent = exports.withErrorHandler = exports.conditionalComponent = exports.injectProps = exports.lazyComponent = exports.memoizeComponent = exports.wrapComponent = void 0;
4
+ function wrapComponent(React, Component, options = {}) {
5
+ const { displayName, enableProfiling = false, logProps = false, lifecycle = {}, defaultProps = {} } = options;
6
+ const WrappedComponent = React.forwardRef((props, ref) => {
7
+ const mergedProps = { ...defaultProps, ...props };
8
+ React.useEffect(() => {
9
+ if (logProps) {
10
+ console.log(`[${displayName || Component.name}] Props:`, mergedProps);
11
+ }
12
+ }, [mergedProps]);
13
+ React.useEffect(() => {
14
+ if (lifecycle.beforeMount) {
15
+ lifecycle.beforeMount();
16
+ }
17
+ if (lifecycle.afterMount) {
18
+ lifecycle.afterMount();
19
+ }
20
+ return () => {
21
+ if (lifecycle.beforeUnmount) {
22
+ lifecycle.beforeUnmount();
23
+ }
24
+ };
25
+ }, []);
26
+ const prevPropsRef = React.useRef(mergedProps);
27
+ React.useEffect(() => {
28
+ const prevProps = prevPropsRef.current;
29
+ if (lifecycle.beforeUpdate) {
30
+ lifecycle.beforeUpdate(prevProps, mergedProps);
31
+ }
32
+ if (lifecycle.afterUpdate) {
33
+ Promise.resolve().then(() => {
34
+ lifecycle.afterUpdate(prevProps, mergedProps);
35
+ });
36
+ }
37
+ prevPropsRef.current = mergedProps;
38
+ });
39
+ if (enableProfiling && React.Profiler) {
40
+ return React.createElement(React.Profiler, {
41
+ id: displayName || Component.name || 'WrappedComponent',
42
+ onRender: (id, phase, actualDuration) => {
43
+ console.log(`[Profiler] ${id} (${phase}): ${actualDuration.toFixed(2)}ms`);
44
+ }
45
+ }, React.createElement(Component, { ...mergedProps, ref }));
46
+ }
47
+ return React.createElement(Component, { ...mergedProps, ref });
48
+ });
49
+ WrappedComponent.displayName = displayName || `Wrapped(${Component.displayName || Component.name || 'Component'})`;
50
+ return WrappedComponent;
51
+ }
52
+ exports.wrapComponent = wrapComponent;
53
+ function memoizeComponent(React, Component, propsAreEqual) {
54
+ return React.memo(Component, propsAreEqual);
55
+ }
56
+ exports.memoizeComponent = memoizeComponent;
57
+ function lazyComponent(React, loader, fallback) {
58
+ const LazyComponent = React.lazy(loader);
59
+ if (fallback) {
60
+ return (props) => React.createElement(React.Suspense, { fallback }, React.createElement(LazyComponent, props));
61
+ }
62
+ return LazyComponent;
63
+ }
64
+ exports.lazyComponent = lazyComponent;
65
+ function injectProps(React, Component, injectedProps) {
66
+ return React.forwardRef((props, ref) => {
67
+ const mergedProps = { ...injectedProps, ...props };
68
+ return React.createElement(Component, { ...mergedProps, ref });
69
+ });
70
+ }
71
+ exports.injectProps = injectProps;
72
+ function conditionalComponent(React, Component, condition, fallback) {
73
+ return (props) => {
74
+ const shouldRender = typeof condition === 'function' ? condition(props) : condition;
75
+ if (shouldRender) {
76
+ return React.createElement(Component, props);
77
+ }
78
+ return fallback || null;
79
+ };
80
+ }
81
+ exports.conditionalComponent = conditionalComponent;
82
+ function withErrorHandler(React, Component, errorHandler) {
83
+ return class extends React.Component {
84
+ componentDidCatch(error, errorInfo) {
85
+ errorHandler(error);
86
+ }
87
+ render() {
88
+ return React.createElement(Component, this.props);
89
+ }
90
+ };
91
+ }
92
+ exports.withErrorHandler = withErrorHandler;
93
+ function portalComponent(React, ReactDOM, Component, container) {
94
+ return (props) => {
95
+ const [mountNode, setMountNode] = React.useState(null);
96
+ React.useEffect(() => {
97
+ const node = typeof container === 'string'
98
+ ? document.querySelector(container)
99
+ : container;
100
+ setMountNode(node);
101
+ }, []);
102
+ if (!mountNode || !ReactDOM.createPortal) {
103
+ return null;
104
+ }
105
+ return ReactDOM.createPortal(React.createElement(Component, props), mountNode);
106
+ };
107
+ }
108
+ exports.portalComponent = portalComponent;
@@ -0,0 +1,6 @@
1
+ import { ErrorBoundaryOptions, ComponentError } from '../types';
2
+ export declare function createErrorBoundary(React: any, options?: ErrorBoundaryOptions): any;
3
+ export declare function withErrorBoundary(React: any, Component: any, options?: ErrorBoundaryOptions): any;
4
+ export declare function formatComponentError(error: Error, componentName: string, phase: ComponentError['phase']): ComponentError;
5
+ export declare function createErrorLogger(componentName: string): (error: Error, errorInfo: any) => void;
6
+ //# sourceMappingURL=error-boundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-boundary.d.ts","sourceRoot":"","sources":["../../src/runtime/error-boundary.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAQhE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,GAAE,oBAAyB,GAAG,GAAG,CAyKvF;AASD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,GAAE,oBAAyB,GAAG,GAAG,CAUrG;AASD,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC,GAC7B,cAAc,CAWhB;AAOD,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,KAAK,IAAI,CAQ/F"}
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createErrorLogger = exports.formatComponentError = exports.withErrorBoundary = exports.createErrorBoundary = void 0;
4
+ function createErrorBoundary(React, options = {}) {
5
+ const { onError, fallback, logErrors = true, recovery = 'none' } = options;
6
+ return class ErrorBoundary extends React.Component {
7
+ constructor(props) {
8
+ super(props);
9
+ this.handleRetry = () => {
10
+ this.setState((prevState) => ({
11
+ hasError: false,
12
+ error: null,
13
+ errorInfo: null,
14
+ retryCount: prevState.retryCount + 1
15
+ }));
16
+ };
17
+ this.handleReset = () => {
18
+ this.setState({
19
+ hasError: false,
20
+ error: null,
21
+ errorInfo: null,
22
+ retryCount: 0
23
+ });
24
+ };
25
+ this.state = {
26
+ hasError: false,
27
+ error: null,
28
+ errorInfo: null,
29
+ retryCount: 0
30
+ };
31
+ }
32
+ static getDerivedStateFromError(error) {
33
+ return { hasError: true, error };
34
+ }
35
+ componentDidCatch(error, errorInfo) {
36
+ if (logErrors) {
37
+ console.error('React Error Boundary caught error:', error);
38
+ console.error('Error Info:', errorInfo);
39
+ }
40
+ if (onError) {
41
+ try {
42
+ onError(error, errorInfo);
43
+ }
44
+ catch (handlerError) {
45
+ console.error('Error in custom error handler:', handlerError);
46
+ }
47
+ }
48
+ this.setState({ errorInfo });
49
+ }
50
+ render() {
51
+ if (this.state.hasError) {
52
+ if (fallback) {
53
+ if (typeof fallback === 'function') {
54
+ return fallback({
55
+ error: this.state.error,
56
+ errorInfo: this.state.errorInfo,
57
+ retry: this.handleRetry,
58
+ reset: this.handleReset,
59
+ retryCount: this.state.retryCount
60
+ });
61
+ }
62
+ return fallback;
63
+ }
64
+ const showRetry = recovery === 'retry' && this.state.retryCount < 3;
65
+ const showReset = recovery === 'reset';
66
+ return React.createElement('div', {
67
+ style: {
68
+ padding: '20px',
69
+ backgroundColor: '#f8f8f8',
70
+ border: '1px solid #ddd',
71
+ borderRadius: '4px',
72
+ margin: '10px'
73
+ }
74
+ }, 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', {
75
+ style: {
76
+ backgroundColor: '#f0f0f0',
77
+ padding: '10px',
78
+ marginTop: '10px',
79
+ overflow: 'auto',
80
+ fontSize: '12px'
81
+ }
82
+ }, this.state.error.toString(), '\n\n', this.state.error.stack)), (showRetry || showReset) && React.createElement('div', { style: { marginTop: '10px' } }, showRetry && React.createElement('button', {
83
+ onClick: this.handleRetry,
84
+ style: {
85
+ padding: '8px 16px',
86
+ marginRight: '10px',
87
+ backgroundColor: '#1976d2',
88
+ color: 'white',
89
+ border: 'none',
90
+ borderRadius: '4px',
91
+ cursor: 'pointer'
92
+ }
93
+ }, `Retry (${3 - this.state.retryCount} attempts left)`), showReset && React.createElement('button', {
94
+ onClick: this.handleReset,
95
+ style: {
96
+ padding: '8px 16px',
97
+ backgroundColor: '#757575',
98
+ color: 'white',
99
+ border: 'none',
100
+ borderRadius: '4px',
101
+ cursor: 'pointer'
102
+ }
103
+ }, 'Reset Component')));
104
+ }
105
+ return this.props.children;
106
+ }
107
+ };
108
+ }
109
+ exports.createErrorBoundary = createErrorBoundary;
110
+ function withErrorBoundary(React, Component, options = {}) {
111
+ const ErrorBoundaryComponent = createErrorBoundary(React, options);
112
+ return (props) => {
113
+ return React.createElement(ErrorBoundaryComponent, null, React.createElement(Component, props));
114
+ };
115
+ }
116
+ exports.withErrorBoundary = withErrorBoundary;
117
+ function formatComponentError(error, componentName, phase) {
118
+ return {
119
+ message: error.message || 'Unknown error',
120
+ stack: error.stack,
121
+ componentName,
122
+ phase,
123
+ details: {
124
+ name: error.name,
125
+ timestamp: new Date().toISOString()
126
+ }
127
+ };
128
+ }
129
+ exports.formatComponentError = formatComponentError;
130
+ function createErrorLogger(componentName) {
131
+ return (error, errorInfo) => {
132
+ console.group(`🚨 React Component Error: ${componentName}`);
133
+ console.error('Error:', error);
134
+ console.error('Component Stack:', errorInfo.componentStack);
135
+ console.error('Props:', errorInfo.props);
136
+ console.groupEnd();
137
+ };
138
+ }
139
+ exports.createErrorLogger = createErrorLogger;
@@ -0,0 +1,5 @@
1
+ export { createErrorBoundary, withErrorBoundary, formatComponentError, createErrorLogger } from './error-boundary';
2
+ export { wrapComponent, memoizeComponent, lazyComponent, injectProps, conditionalComponent, withErrorHandler, portalComponent, WrapperOptions } from './component-wrapper';
3
+ export { buildComponentProps, normalizeCallbacks, normalizeStyles, validateComponentProps, mergeProps, createPropsTransformer, wrapCallbacksWithLogging, extractPropPaths, PropBuilderOptions } from './prop-builder';
4
+ export { ComponentHierarchyRegistrar, registerComponentHierarchy, validateComponentSpec, flattenComponentHierarchy, countComponentsInHierarchy, HierarchyRegistrationResult, ComponentRegistrationError, HierarchyRegistrationOptions } from './component-hierarchy';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,UAAU,EACV,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,qBAAqB,EACrB,yBAAyB,EACzB,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,4BAA4B,EAC7B,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.countComponentsInHierarchy = exports.flattenComponentHierarchy = exports.validateComponentSpec = exports.registerComponentHierarchy = exports.ComponentHierarchyRegistrar = exports.extractPropPaths = exports.wrapCallbacksWithLogging = exports.createPropsTransformer = exports.mergeProps = exports.validateComponentProps = exports.normalizeStyles = exports.normalizeCallbacks = exports.buildComponentProps = exports.portalComponent = exports.withErrorHandler = exports.conditionalComponent = exports.injectProps = exports.lazyComponent = exports.memoizeComponent = exports.wrapComponent = exports.createErrorLogger = exports.formatComponentError = exports.withErrorBoundary = exports.createErrorBoundary = void 0;
4
+ var error_boundary_1 = require("./error-boundary");
5
+ Object.defineProperty(exports, "createErrorBoundary", { enumerable: true, get: function () { return error_boundary_1.createErrorBoundary; } });
6
+ Object.defineProperty(exports, "withErrorBoundary", { enumerable: true, get: function () { return error_boundary_1.withErrorBoundary; } });
7
+ Object.defineProperty(exports, "formatComponentError", { enumerable: true, get: function () { return error_boundary_1.formatComponentError; } });
8
+ Object.defineProperty(exports, "createErrorLogger", { enumerable: true, get: function () { return error_boundary_1.createErrorLogger; } });
9
+ var component_wrapper_1 = require("./component-wrapper");
10
+ Object.defineProperty(exports, "wrapComponent", { enumerable: true, get: function () { return component_wrapper_1.wrapComponent; } });
11
+ Object.defineProperty(exports, "memoizeComponent", { enumerable: true, get: function () { return component_wrapper_1.memoizeComponent; } });
12
+ Object.defineProperty(exports, "lazyComponent", { enumerable: true, get: function () { return component_wrapper_1.lazyComponent; } });
13
+ Object.defineProperty(exports, "injectProps", { enumerable: true, get: function () { return component_wrapper_1.injectProps; } });
14
+ Object.defineProperty(exports, "conditionalComponent", { enumerable: true, get: function () { return component_wrapper_1.conditionalComponent; } });
15
+ Object.defineProperty(exports, "withErrorHandler", { enumerable: true, get: function () { return component_wrapper_1.withErrorHandler; } });
16
+ Object.defineProperty(exports, "portalComponent", { enumerable: true, get: function () { return component_wrapper_1.portalComponent; } });
17
+ var prop_builder_1 = require("./prop-builder");
18
+ Object.defineProperty(exports, "buildComponentProps", { enumerable: true, get: function () { return prop_builder_1.buildComponentProps; } });
19
+ Object.defineProperty(exports, "normalizeCallbacks", { enumerable: true, get: function () { return prop_builder_1.normalizeCallbacks; } });
20
+ Object.defineProperty(exports, "normalizeStyles", { enumerable: true, get: function () { return prop_builder_1.normalizeStyles; } });
21
+ Object.defineProperty(exports, "validateComponentProps", { enumerable: true, get: function () { return prop_builder_1.validateComponentProps; } });
22
+ Object.defineProperty(exports, "mergeProps", { enumerable: true, get: function () { return prop_builder_1.mergeProps; } });
23
+ Object.defineProperty(exports, "createPropsTransformer", { enumerable: true, get: function () { return prop_builder_1.createPropsTransformer; } });
24
+ Object.defineProperty(exports, "wrapCallbacksWithLogging", { enumerable: true, get: function () { return prop_builder_1.wrapCallbacksWithLogging; } });
25
+ Object.defineProperty(exports, "extractPropPaths", { enumerable: true, get: function () { return prop_builder_1.extractPropPaths; } });
26
+ var component_hierarchy_1 = require("./component-hierarchy");
27
+ Object.defineProperty(exports, "ComponentHierarchyRegistrar", { enumerable: true, get: function () { return component_hierarchy_1.ComponentHierarchyRegistrar; } });
28
+ Object.defineProperty(exports, "registerComponentHierarchy", { enumerable: true, get: function () { return component_hierarchy_1.registerComponentHierarchy; } });
29
+ Object.defineProperty(exports, "validateComponentSpec", { enumerable: true, get: function () { return component_hierarchy_1.validateComponentSpec; } });
30
+ Object.defineProperty(exports, "flattenComponentHierarchy", { enumerable: true, get: function () { return component_hierarchy_1.flattenComponentHierarchy; } });
31
+ Object.defineProperty(exports, "countComponentsInHierarchy", { enumerable: true, get: function () { return component_hierarchy_1.countComponentsInHierarchy; } });
@@ -0,0 +1,16 @@
1
+ import { ComponentProps, ComponentCallbacks, ComponentStyles } from '../types';
2
+ export interface PropBuilderOptions {
3
+ validate?: boolean;
4
+ merge?: boolean;
5
+ transformData?: (data: any) => any;
6
+ transformState?: (state: any) => any;
7
+ }
8
+ export declare function buildComponentProps(data?: any, userState?: any, utilities?: any, callbacks?: ComponentCallbacks, components?: Record<string, any>, styles?: ComponentStyles, options?: PropBuilderOptions): ComponentProps;
9
+ export declare function normalizeCallbacks(callbacks: any): ComponentCallbacks;
10
+ export declare function normalizeStyles(styles?: any): any;
11
+ export declare function validateComponentProps(props: ComponentProps): void;
12
+ export declare function mergeProps(...propsList: Partial<ComponentProps>[]): ComponentProps;
13
+ export declare function createPropsTransformer(transformations: Record<string, (value: any) => any>): (props: ComponentProps) => ComponentProps;
14
+ export declare function wrapCallbacksWithLogging(callbacks: ComponentCallbacks, componentName: string): ComponentCallbacks;
15
+ export declare function extractPropPaths(componentCode: string): string[];
16
+ //# sourceMappingURL=prop-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prop-builder.d.ts","sourceRoot":"","sources":["../../src/runtime/prop-builder.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAK/E,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;CACtC;AAaD,wBAAgB,mBAAmB,CACjC,IAAI,GAAE,GAAQ,EACd,SAAS,GAAE,GAAQ,EACnB,SAAS,GAAE,GAAQ,EACnB,SAAS,GAAE,kBAAuB,EAClC,UAAU,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EACpC,MAAM,CAAC,EAAE,eAAe,EACxB,OAAO,GAAE,kBAAuB,GAC/B,cAAc,CA2BhB;AAOD,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,GAAG,GAAG,kBAAkB,CAqBrE;AAOD,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,GAAG,GAAG,GAAG,CAKjD;AAOD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CA2BlE;AAOD,wBAAgB,UAAU,CAAC,GAAG,SAAS,EAAE,OAAO,CAAC,cAAc,CAAC,EAAE,GAAG,cAAc,CAqClF;AAOD,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC,GACnD,CAAC,KAAK,EAAE,cAAc,KAAK,cAAc,CAyB3C;AAQD,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,kBAAkB,EAC7B,aAAa,EAAE,MAAM,GACpB,kBAAkB,CAgCpB;AAOD,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,CAmBhE"}