@creact-labs/creact 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +212 -0
- package/README.md +379 -0
- package/dist/cli/commands/BuildCommand.d.ts +40 -0
- package/dist/cli/commands/BuildCommand.js +151 -0
- package/dist/cli/commands/DeployCommand.d.ts +38 -0
- package/dist/cli/commands/DeployCommand.js +194 -0
- package/dist/cli/commands/DevCommand.d.ts +52 -0
- package/dist/cli/commands/DevCommand.js +385 -0
- package/dist/cli/commands/PlanCommand.d.ts +39 -0
- package/dist/cli/commands/PlanCommand.js +164 -0
- package/dist/cli/commands/index.d.ts +36 -0
- package/dist/cli/commands/index.js +43 -0
- package/dist/cli/core/ArgumentParser.d.ts +46 -0
- package/dist/cli/core/ArgumentParser.js +127 -0
- package/dist/cli/core/BaseCommand.d.ts +75 -0
- package/dist/cli/core/BaseCommand.js +95 -0
- package/dist/cli/core/CLIContext.d.ts +68 -0
- package/dist/cli/core/CLIContext.js +183 -0
- package/dist/cli/core/CommandRegistry.d.ts +64 -0
- package/dist/cli/core/CommandRegistry.js +89 -0
- package/dist/cli/core/index.d.ts +36 -0
- package/dist/cli/core/index.js +43 -0
- package/dist/cli/index.d.ts +35 -0
- package/dist/cli/index.js +100 -0
- package/dist/cli/output.d.ts +204 -0
- package/dist/cli/output.js +437 -0
- package/dist/cli/utils.d.ts +59 -0
- package/dist/cli/utils.js +76 -0
- package/dist/context/createContext.d.ts +90 -0
- package/dist/context/createContext.js +113 -0
- package/dist/context/index.d.ts +30 -0
- package/dist/context/index.js +35 -0
- package/dist/core/CReact.d.ts +409 -0
- package/dist/core/CReact.js +1127 -0
- package/dist/core/CloudDOMBuilder.d.ts +429 -0
- package/dist/core/CloudDOMBuilder.js +1198 -0
- package/dist/core/ContextDependencyTracker.d.ts +165 -0
- package/dist/core/ContextDependencyTracker.js +448 -0
- package/dist/core/ErrorRecoveryManager.d.ts +145 -0
- package/dist/core/ErrorRecoveryManager.js +443 -0
- package/dist/core/EventBus.d.ts +91 -0
- package/dist/core/EventBus.js +185 -0
- package/dist/core/ProviderOutputTracker.d.ts +211 -0
- package/dist/core/ProviderOutputTracker.js +476 -0
- package/dist/core/ReactiveUpdateQueue.d.ts +76 -0
- package/dist/core/ReactiveUpdateQueue.js +121 -0
- package/dist/core/Reconciler.d.ts +415 -0
- package/dist/core/Reconciler.js +1037 -0
- package/dist/core/RenderScheduler.d.ts +153 -0
- package/dist/core/RenderScheduler.js +519 -0
- package/dist/core/Renderer.d.ts +276 -0
- package/dist/core/Renderer.js +791 -0
- package/dist/core/Runtime.d.ts +246 -0
- package/dist/core/Runtime.js +640 -0
- package/dist/core/StateBindingManager.d.ts +121 -0
- package/dist/core/StateBindingManager.js +309 -0
- package/dist/core/StateMachine.d.ts +424 -0
- package/dist/core/StateMachine.js +787 -0
- package/dist/core/StructuralChangeDetector.d.ts +140 -0
- package/dist/core/StructuralChangeDetector.js +363 -0
- package/dist/core/Validator.d.ts +127 -0
- package/dist/core/Validator.js +279 -0
- package/dist/core/errors.d.ts +153 -0
- package/dist/core/errors.js +202 -0
- package/dist/core/index.d.ts +38 -0
- package/dist/core/index.js +64 -0
- package/dist/core/types.d.ts +263 -0
- package/dist/core/types.js +48 -0
- package/dist/hooks/context.d.ts +147 -0
- package/dist/hooks/context.js +334 -0
- package/dist/hooks/useContext.d.ts +113 -0
- package/dist/hooks/useContext.js +169 -0
- package/dist/hooks/useEffect.d.ts +105 -0
- package/dist/hooks/useEffect.js +540 -0
- package/dist/hooks/useInstance.d.ts +139 -0
- package/dist/hooks/useInstance.js +441 -0
- package/dist/hooks/useState.d.ts +120 -0
- package/dist/hooks/useState.js +298 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +70 -0
- package/dist/jsx.d.ts +64 -0
- package/dist/jsx.js +76 -0
- package/dist/providers/DummyBackendProvider.d.ts +193 -0
- package/dist/providers/DummyBackendProvider.js +189 -0
- package/dist/providers/DummyCloudProvider.d.ts +128 -0
- package/dist/providers/DummyCloudProvider.js +157 -0
- package/dist/providers/IBackendProvider.d.ts +177 -0
- package/dist/providers/IBackendProvider.js +31 -0
- package/dist/providers/ICloudProvider.d.ts +146 -0
- package/dist/providers/ICloudProvider.js +31 -0
- package/dist/providers/index.d.ts +31 -0
- package/dist/providers/index.js +31 -0
- package/dist/test-event-callbacks.d.ts +0 -0
- package/dist/test-event-callbacks.js +1 -0
- package/dist/utils/Logger.d.ts +144 -0
- package/dist/utils/Logger.js +220 -0
- package/dist/utils/Output.d.ts +161 -0
- package/dist/utils/Output.js +401 -0
- package/dist/utils/deepEqual.d.ts +71 -0
- package/dist/utils/deepEqual.js +276 -0
- package/dist/utils/naming.d.ts +241 -0
- package/dist/utils/naming.js +376 -0
- package/package.json +87 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
*
|
|
11
|
+
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
|
|
14
|
+
*
|
|
15
|
+
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
|
|
22
|
+
* See the License for the specific language governing permissions and
|
|
23
|
+
|
|
24
|
+
* limitations under the License.
|
|
25
|
+
|
|
26
|
+
*
|
|
27
|
+
|
|
28
|
+
* Copyright 2025 Daniel Coutinho Ribeiro
|
|
29
|
+
|
|
30
|
+
*/
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.Validator = exports.ValidationError = void 0;
|
|
33
|
+
const Logger_1 = require("../utils/Logger");
|
|
34
|
+
const logger = Logger_1.LoggerFactory.getLogger('validator');
|
|
35
|
+
/**
|
|
36
|
+
* Validation error with component stack trace
|
|
37
|
+
* REQ-NF-03.1: Enhanced error messages with file and line trace
|
|
38
|
+
*/
|
|
39
|
+
class ValidationError extends Error {
|
|
40
|
+
constructor(message, componentStack, filePath, lineNumber) {
|
|
41
|
+
super(message);
|
|
42
|
+
this.componentStack = componentStack;
|
|
43
|
+
this.filePath = filePath;
|
|
44
|
+
this.lineNumber = lineNumber;
|
|
45
|
+
this.name = 'ValidationError';
|
|
46
|
+
// Enhance error message with stack trace
|
|
47
|
+
this.message = this.formatError(message, componentStack, filePath, lineNumber);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get a quick summary of the error for dev tools
|
|
51
|
+
* REQ-NF-03.1: Enhanced error messages
|
|
52
|
+
*/
|
|
53
|
+
get summary() {
|
|
54
|
+
return `${this.message.split('\n')[0]} (${this.filePath || 'unknown'})`;
|
|
55
|
+
}
|
|
56
|
+
formatError(message, componentStack, filePath, lineNumber) {
|
|
57
|
+
let formatted = message;
|
|
58
|
+
// Add file location if available
|
|
59
|
+
if (filePath) {
|
|
60
|
+
formatted += `\n at ${filePath}`;
|
|
61
|
+
if (lineNumber) {
|
|
62
|
+
formatted += `:${lineNumber}`;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Add component stack trace
|
|
66
|
+
if (componentStack.length > 0) {
|
|
67
|
+
formatted += '\n\nComponent stack:';
|
|
68
|
+
componentStack.forEach((component, index) => {
|
|
69
|
+
const indent = ' '.repeat(index + 1);
|
|
70
|
+
formatted += `\n${indent}in ${component}`;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return formatted;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.ValidationError = ValidationError;
|
|
77
|
+
/**
|
|
78
|
+
* Validator validates Fiber tree before committing to CloudDOM
|
|
79
|
+
*
|
|
80
|
+
* Validation checks:
|
|
81
|
+
* - Required props are present
|
|
82
|
+
* - Context is available when useStackContext is called
|
|
83
|
+
* - Resource IDs are unique
|
|
84
|
+
* - No circular dependencies
|
|
85
|
+
*
|
|
86
|
+
* No dependencies injected - pure validation logic
|
|
87
|
+
*/
|
|
88
|
+
class Validator {
|
|
89
|
+
/**
|
|
90
|
+
* Validate a Fiber tree
|
|
91
|
+
*
|
|
92
|
+
* @param fiber - Root Fiber node to validate
|
|
93
|
+
* @throws ValidationError if validation fails
|
|
94
|
+
*/
|
|
95
|
+
validate(fiber) {
|
|
96
|
+
if (!fiber) {
|
|
97
|
+
throw new Error('Cannot validate null Fiber tree');
|
|
98
|
+
}
|
|
99
|
+
// Track resource IDs for uniqueness check
|
|
100
|
+
const resourceIds = new Set();
|
|
101
|
+
// Track visited nodes for circular dependency check
|
|
102
|
+
const visitedPaths = new Set();
|
|
103
|
+
// Validate recursively
|
|
104
|
+
this.validateNode(fiber, [], resourceIds, visitedPaths);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Validate a single Fiber node and its children
|
|
108
|
+
*
|
|
109
|
+
* @param node - Fiber node to validate
|
|
110
|
+
* @param componentStack - Stack of component names for error reporting
|
|
111
|
+
* @param resourceIds - Set of resource IDs seen so far
|
|
112
|
+
* @param visitedPaths - Set of visited paths for circular dependency detection
|
|
113
|
+
*/
|
|
114
|
+
validateNode(node, componentStack, resourceIds, visitedPaths) {
|
|
115
|
+
// Defensive: Handle corrupted nodes
|
|
116
|
+
if (!node) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
// Get component name for stack trace
|
|
120
|
+
const componentName = this.getComponentName(node);
|
|
121
|
+
const currentStack = [...componentStack, componentName];
|
|
122
|
+
// Optional debug trace for development introspection
|
|
123
|
+
const pathStr = node.path ? node.path.join('.') : 'unknown';
|
|
124
|
+
logger.debug('Validating', pathStr);
|
|
125
|
+
// REQ-07.4: Circular dependency detection
|
|
126
|
+
const pathKey = node.path ? node.path.join('.') : '';
|
|
127
|
+
if (pathKey && visitedPaths.has(pathKey)) {
|
|
128
|
+
throw new ValidationError(`Circular dependency detected: ${pathKey}`, currentStack, this.getFilePath(node), this.getLineNumber(node));
|
|
129
|
+
}
|
|
130
|
+
if (pathKey) {
|
|
131
|
+
visitedPaths.add(pathKey);
|
|
132
|
+
}
|
|
133
|
+
// REQ-07.1: Required props validation
|
|
134
|
+
this.validateRequiredProps(node, currentStack);
|
|
135
|
+
// REQ-07.3: Unique resource IDs - check cloudDOMNodes array
|
|
136
|
+
if (node.cloudDOMNodes && node.cloudDOMNodes.length > 0) {
|
|
137
|
+
for (const cloudNode of node.cloudDOMNodes) {
|
|
138
|
+
const resourceId = cloudNode.id;
|
|
139
|
+
if (resourceIds.has(resourceId)) {
|
|
140
|
+
throw new ValidationError(`Duplicate resource ID: '${resourceId}'. Resource IDs must be unique.`, currentStack, this.getFilePath(node), this.getLineNumber(node));
|
|
141
|
+
}
|
|
142
|
+
resourceIds.add(resourceId);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// REQ-07.2: Context validation
|
|
146
|
+
// Note: This will be implemented when hooks are added
|
|
147
|
+
// For now, we check if the node has a marker indicating context usage
|
|
148
|
+
if (node.props && node.props.__usesStackContext) {
|
|
149
|
+
this.validateContextAvailable(node, currentStack);
|
|
150
|
+
}
|
|
151
|
+
// Recursively validate children
|
|
152
|
+
// Clone visitedPaths for each child to ensure isolation per branch
|
|
153
|
+
// This prevents false circular dependency warnings for sibling nodes
|
|
154
|
+
if (node.children && Array.isArray(node.children)) {
|
|
155
|
+
for (const child of node.children) {
|
|
156
|
+
this.validateNode(child, currentStack, resourceIds, new Set(visitedPaths));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Validate that required props are present
|
|
162
|
+
* REQ-07.1: Required props validation
|
|
163
|
+
*
|
|
164
|
+
* @param node - Fiber node to validate
|
|
165
|
+
* @param componentStack - Component stack for error reporting
|
|
166
|
+
*/
|
|
167
|
+
validateRequiredProps(node, componentStack) {
|
|
168
|
+
// Get required props from component type
|
|
169
|
+
const requiredProps = this.getRequiredProps(node.type);
|
|
170
|
+
// Check each required prop
|
|
171
|
+
for (const propName of requiredProps) {
|
|
172
|
+
if (!(propName in node.props) || node.props[propName] === undefined) {
|
|
173
|
+
const componentName = this.getComponentName(node);
|
|
174
|
+
throw new ValidationError(`Missing required prop '${propName}' in ${componentName} component`, componentStack, this.getFilePath(node), this.getLineNumber(node));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Validate that context is available when useStackContext is called
|
|
180
|
+
* REQ-07.2: Context validation
|
|
181
|
+
*
|
|
182
|
+
* @param node - Fiber node that uses context
|
|
183
|
+
* @param componentStack - Component stack for error reporting
|
|
184
|
+
*/
|
|
185
|
+
validateContextAvailable(node, componentStack) {
|
|
186
|
+
// Note: In a real implementation, we would traverse the parent chain
|
|
187
|
+
// For now, we check if there's a provider marker in the tree
|
|
188
|
+
// This will be properly implemented when StackContext is added
|
|
189
|
+
// Check if any ancestor has a provider
|
|
190
|
+
// (This is a simplified check - full implementation will traverse parent references)
|
|
191
|
+
if (node.props.__hasContextProvider === false) {
|
|
192
|
+
const componentName = this.getComponentName(node);
|
|
193
|
+
throw new ValidationError(`useStackContext() called in ${componentName} but no StackContext.Provider found in ancestor tree`, componentStack, this.getFilePath(node), this.getLineNumber(node));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Get required props for a component type
|
|
198
|
+
*
|
|
199
|
+
* Checks for:
|
|
200
|
+
* - Static requiredProps property
|
|
201
|
+
* - PropTypes (if available)
|
|
202
|
+
* - TypeScript metadata (future enhancement)
|
|
203
|
+
*
|
|
204
|
+
* @param type - Component type
|
|
205
|
+
* @returns Array of required prop names
|
|
206
|
+
*/
|
|
207
|
+
getRequiredProps(type) {
|
|
208
|
+
// Check for static requiredProps property
|
|
209
|
+
if (type && type.requiredProps && Array.isArray(type.requiredProps)) {
|
|
210
|
+
return type.requiredProps;
|
|
211
|
+
}
|
|
212
|
+
// Check for PropTypes (React-style)
|
|
213
|
+
if (type && type.propTypes) {
|
|
214
|
+
const required = [];
|
|
215
|
+
for (const [propName, propType] of Object.entries(type.propTypes)) {
|
|
216
|
+
// Check if prop is marked as required
|
|
217
|
+
if (propType && typeof propType === 'object' && propType.isRequired) {
|
|
218
|
+
required.push(propName);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return required;
|
|
222
|
+
}
|
|
223
|
+
// No required props found
|
|
224
|
+
return [];
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Get component name for error reporting
|
|
228
|
+
*
|
|
229
|
+
* @param node - Fiber node
|
|
230
|
+
* @returns Component name
|
|
231
|
+
*/
|
|
232
|
+
getComponentName(node) {
|
|
233
|
+
if (typeof node.type === 'function') {
|
|
234
|
+
return node.type.displayName || node.type.name || 'Anonymous';
|
|
235
|
+
}
|
|
236
|
+
if (typeof node.type === 'string') {
|
|
237
|
+
return node.type;
|
|
238
|
+
}
|
|
239
|
+
return 'Unknown';
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Get file path from Fiber node (if available)
|
|
243
|
+
*
|
|
244
|
+
* In a real implementation, this would use source maps or
|
|
245
|
+
* stack trace analysis to determine the file path.
|
|
246
|
+
*
|
|
247
|
+
* @param node - Fiber node
|
|
248
|
+
* @returns File path or undefined
|
|
249
|
+
*/
|
|
250
|
+
getFilePath(node) {
|
|
251
|
+
// Check if component has __source metadata (added by Babel/TypeScript)
|
|
252
|
+
if (node.type && node.type.__source) {
|
|
253
|
+
return node.type.__source.fileName;
|
|
254
|
+
}
|
|
255
|
+
// Check props for source metadata
|
|
256
|
+
if (node.props && node.props.__source) {
|
|
257
|
+
return node.props.__source.fileName;
|
|
258
|
+
}
|
|
259
|
+
return undefined;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Get line number from Fiber node (if available)
|
|
263
|
+
*
|
|
264
|
+
* @param node - Fiber node
|
|
265
|
+
* @returns Line number or undefined
|
|
266
|
+
*/
|
|
267
|
+
getLineNumber(node) {
|
|
268
|
+
// Check if component has __source metadata
|
|
269
|
+
if (node.type && node.type.__source) {
|
|
270
|
+
return node.type.__source.lineNumber;
|
|
271
|
+
}
|
|
272
|
+
// Check props for source metadata
|
|
273
|
+
if (node.props && node.props.__source) {
|
|
274
|
+
return node.props.__source.lineNumber;
|
|
275
|
+
}
|
|
276
|
+
return undefined;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
exports.Validator = Validator;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
*
|
|
10
|
+
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
*
|
|
14
|
+
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
|
|
23
|
+
* limitations under the License.
|
|
24
|
+
|
|
25
|
+
*
|
|
26
|
+
|
|
27
|
+
* Copyright 2025 Daniel Coutinho Ribeiro
|
|
28
|
+
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Base error class for all CReact errors
|
|
32
|
+
*/
|
|
33
|
+
export declare class CReactError extends Error {
|
|
34
|
+
readonly code: string;
|
|
35
|
+
constructor(message: string, code: string);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Validation error - thrown when CloudDOM validation fails
|
|
39
|
+
*
|
|
40
|
+
* Used for:
|
|
41
|
+
* - Circular dependencies
|
|
42
|
+
* - Invalid node structure
|
|
43
|
+
* - Schema validation failures
|
|
44
|
+
*/
|
|
45
|
+
export declare class ValidationError extends CReactError {
|
|
46
|
+
readonly details?: Record<string, any> | undefined;
|
|
47
|
+
constructor(message: string, details?: Record<string, any> | undefined);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Reconciliation error - thrown when diff computation fails
|
|
51
|
+
*
|
|
52
|
+
* Used for:
|
|
53
|
+
* - Circular dependencies in dependency graph
|
|
54
|
+
* - Invalid change detection
|
|
55
|
+
*/
|
|
56
|
+
export declare class ReconciliationError extends CReactError {
|
|
57
|
+
readonly details?: Record<string, any> | undefined;
|
|
58
|
+
constructor(message: string, details?: Record<string, any> | undefined);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Deployment error data structure
|
|
62
|
+
*
|
|
63
|
+
* Provides structured error information for audit logs and debugging.
|
|
64
|
+
*/
|
|
65
|
+
export interface DeploymentErrorData {
|
|
66
|
+
/** Error code for categorization */
|
|
67
|
+
code?: string;
|
|
68
|
+
/** Error message */
|
|
69
|
+
message: string;
|
|
70
|
+
/** Stack trace */
|
|
71
|
+
stack?: string;
|
|
72
|
+
/** Root cause description */
|
|
73
|
+
cause?: string;
|
|
74
|
+
/** Additional context */
|
|
75
|
+
details?: Record<string, any>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Deployment error - thrown when deployment fails
|
|
79
|
+
*
|
|
80
|
+
* Used for:
|
|
81
|
+
* - Provider failures
|
|
82
|
+
* - Resource creation failures
|
|
83
|
+
* - State persistence failures
|
|
84
|
+
* - State machine transition errors
|
|
85
|
+
*
|
|
86
|
+
* Provides structured error data for audit logs and telemetry.
|
|
87
|
+
*/
|
|
88
|
+
export declare class DeploymentError extends CReactError {
|
|
89
|
+
readonly data: DeploymentErrorData;
|
|
90
|
+
constructor(message: string, data?: DeploymentErrorData);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Provider error - thrown when provider operations fail
|
|
94
|
+
*
|
|
95
|
+
* Used for:
|
|
96
|
+
* - Provider initialization failures
|
|
97
|
+
* - Materialization failures
|
|
98
|
+
* - Backend state operations
|
|
99
|
+
*/
|
|
100
|
+
export declare class ProviderError extends CReactError {
|
|
101
|
+
readonly details?: Record<string, any> | undefined;
|
|
102
|
+
constructor(message: string, details?: Record<string, any> | undefined);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Reactive system error - thrown when reactive operations fail
|
|
106
|
+
*
|
|
107
|
+
* Used for:
|
|
108
|
+
* - Re-render failures
|
|
109
|
+
* - Circular dependency detection
|
|
110
|
+
* - State update failures
|
|
111
|
+
* - Context propagation failures
|
|
112
|
+
*/
|
|
113
|
+
export declare class ReactiveError extends CReactError {
|
|
114
|
+
readonly details?: Record<string, any> | undefined;
|
|
115
|
+
constructor(message: string, details?: Record<string, any> | undefined);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Circular dependency error - thrown when circular dependencies are detected
|
|
119
|
+
*/
|
|
120
|
+
export declare class CircularDependencyError extends ReactiveError {
|
|
121
|
+
readonly cyclePath: string[];
|
|
122
|
+
readonly details?: Record<string, any> | undefined;
|
|
123
|
+
constructor(message: string, cyclePath: string[], details?: Record<string, any> | undefined);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Re-render error - thrown when component re-rendering fails
|
|
127
|
+
*/
|
|
128
|
+
export declare class ReRenderError extends ReactiveError {
|
|
129
|
+
readonly fiberPath: string[];
|
|
130
|
+
readonly cause?: Error | undefined;
|
|
131
|
+
readonly details?: Record<string, any> | undefined;
|
|
132
|
+
constructor(message: string, fiberPath: string[], cause?: Error | undefined, details?: Record<string, any> | undefined);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* State update error - thrown when state updates fail
|
|
136
|
+
*/
|
|
137
|
+
export declare class StateUpdateError extends ReactiveError {
|
|
138
|
+
readonly fiberPath: string[];
|
|
139
|
+
readonly hookIndex: number;
|
|
140
|
+
readonly cause?: Error | undefined;
|
|
141
|
+
readonly details?: Record<string, any> | undefined;
|
|
142
|
+
constructor(message: string, fiberPath: string[], hookIndex: number, cause?: Error | undefined, details?: Record<string, any> | undefined);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Context propagation error - thrown when context updates fail
|
|
146
|
+
*/
|
|
147
|
+
export declare class ContextPropagationError extends ReactiveError {
|
|
148
|
+
readonly contextId: symbol;
|
|
149
|
+
readonly affectedFibers: string[][];
|
|
150
|
+
readonly cause?: Error | undefined;
|
|
151
|
+
readonly details?: Record<string, any> | undefined;
|
|
152
|
+
constructor(message: string, contextId: symbol, affectedFibers: string[][], cause?: Error | undefined, details?: Record<string, any> | undefined);
|
|
153
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
*
|
|
11
|
+
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
|
|
14
|
+
*
|
|
15
|
+
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
|
|
22
|
+
* See the License for the specific language governing permissions and
|
|
23
|
+
|
|
24
|
+
* limitations under the License.
|
|
25
|
+
|
|
26
|
+
*
|
|
27
|
+
|
|
28
|
+
* Copyright 2025 Daniel Coutinho Ribeiro
|
|
29
|
+
|
|
30
|
+
*/
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.ContextPropagationError = exports.StateUpdateError = exports.ReRenderError = exports.CircularDependencyError = exports.ReactiveError = exports.ProviderError = exports.DeploymentError = exports.ReconciliationError = exports.ValidationError = exports.CReactError = void 0;
|
|
33
|
+
// Custom error classes for CReact
|
|
34
|
+
// Provides typed errors for better error handling and debugging
|
|
35
|
+
/**
|
|
36
|
+
* Base error class for all CReact errors
|
|
37
|
+
*/
|
|
38
|
+
class CReactError extends Error {
|
|
39
|
+
constructor(message, code) {
|
|
40
|
+
super(message);
|
|
41
|
+
this.code = code;
|
|
42
|
+
this.name = 'CReactError';
|
|
43
|
+
// Maintain proper stack trace for where error was thrown (V8 only)
|
|
44
|
+
if (Error.captureStackTrace) {
|
|
45
|
+
Error.captureStackTrace(this, this.constructor);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.CReactError = CReactError;
|
|
50
|
+
/**
|
|
51
|
+
* Validation error - thrown when CloudDOM validation fails
|
|
52
|
+
*
|
|
53
|
+
* Used for:
|
|
54
|
+
* - Circular dependencies
|
|
55
|
+
* - Invalid node structure
|
|
56
|
+
* - Schema validation failures
|
|
57
|
+
*/
|
|
58
|
+
class ValidationError extends CReactError {
|
|
59
|
+
constructor(message, details) {
|
|
60
|
+
super(message, 'VALIDATION_ERROR');
|
|
61
|
+
this.details = details;
|
|
62
|
+
this.name = 'ValidationError';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.ValidationError = ValidationError;
|
|
66
|
+
/**
|
|
67
|
+
* Reconciliation error - thrown when diff computation fails
|
|
68
|
+
*
|
|
69
|
+
* Used for:
|
|
70
|
+
* - Circular dependencies in dependency graph
|
|
71
|
+
* - Invalid change detection
|
|
72
|
+
*/
|
|
73
|
+
class ReconciliationError extends CReactError {
|
|
74
|
+
constructor(message, details) {
|
|
75
|
+
super(message, 'RECONCILIATION_ERROR');
|
|
76
|
+
this.details = details;
|
|
77
|
+
this.name = 'ReconciliationError';
|
|
78
|
+
// Maintain proper stack trace (V8 only)
|
|
79
|
+
if (Error.captureStackTrace) {
|
|
80
|
+
Error.captureStackTrace(this, ReconciliationError);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.ReconciliationError = ReconciliationError;
|
|
85
|
+
/**
|
|
86
|
+
* Deployment error - thrown when deployment fails
|
|
87
|
+
*
|
|
88
|
+
* Used for:
|
|
89
|
+
* - Provider failures
|
|
90
|
+
* - Resource creation failures
|
|
91
|
+
* - State persistence failures
|
|
92
|
+
* - State machine transition errors
|
|
93
|
+
*
|
|
94
|
+
* Provides structured error data for audit logs and telemetry.
|
|
95
|
+
*/
|
|
96
|
+
class DeploymentError extends CReactError {
|
|
97
|
+
constructor(message, data = { message }) {
|
|
98
|
+
super(message, data.code || 'DEPLOYMENT_ERROR');
|
|
99
|
+
this.data = data;
|
|
100
|
+
this.name = 'DeploymentError';
|
|
101
|
+
// Ensure message is in data
|
|
102
|
+
if (!this.data.message) {
|
|
103
|
+
this.data.message = message;
|
|
104
|
+
}
|
|
105
|
+
// Maintain proper stack trace (V8 only)
|
|
106
|
+
if (Error.captureStackTrace) {
|
|
107
|
+
Error.captureStackTrace(this, DeploymentError);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.DeploymentError = DeploymentError;
|
|
112
|
+
/**
|
|
113
|
+
* Provider error - thrown when provider operations fail
|
|
114
|
+
*
|
|
115
|
+
* Used for:
|
|
116
|
+
* - Provider initialization failures
|
|
117
|
+
* - Materialization failures
|
|
118
|
+
* - Backend state operations
|
|
119
|
+
*/
|
|
120
|
+
class ProviderError extends CReactError {
|
|
121
|
+
constructor(message, details) {
|
|
122
|
+
super(message, 'PROVIDER_ERROR');
|
|
123
|
+
this.details = details;
|
|
124
|
+
this.name = 'ProviderError';
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.ProviderError = ProviderError;
|
|
128
|
+
/**
|
|
129
|
+
* Reactive system error - thrown when reactive operations fail
|
|
130
|
+
*
|
|
131
|
+
* Used for:
|
|
132
|
+
* - Re-render failures
|
|
133
|
+
* - Circular dependency detection
|
|
134
|
+
* - State update failures
|
|
135
|
+
* - Context propagation failures
|
|
136
|
+
*/
|
|
137
|
+
class ReactiveError extends CReactError {
|
|
138
|
+
constructor(message, details) {
|
|
139
|
+
super(message, 'REACTIVE_ERROR');
|
|
140
|
+
this.details = details;
|
|
141
|
+
this.name = 'ReactiveError';
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.ReactiveError = ReactiveError;
|
|
145
|
+
/**
|
|
146
|
+
* Circular dependency error - thrown when circular dependencies are detected
|
|
147
|
+
*/
|
|
148
|
+
class CircularDependencyError extends ReactiveError {
|
|
149
|
+
constructor(message, cyclePath, details) {
|
|
150
|
+
super(message, { ...details, cyclePath });
|
|
151
|
+
this.cyclePath = cyclePath;
|
|
152
|
+
this.details = details;
|
|
153
|
+
this.name = 'CircularDependencyError';
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.CircularDependencyError = CircularDependencyError;
|
|
157
|
+
/**
|
|
158
|
+
* Re-render error - thrown when component re-rendering fails
|
|
159
|
+
*/
|
|
160
|
+
class ReRenderError extends ReactiveError {
|
|
161
|
+
constructor(message, fiberPath, cause, details) {
|
|
162
|
+
super(message, { ...details, fiberPath, cause: cause?.message });
|
|
163
|
+
this.fiberPath = fiberPath;
|
|
164
|
+
this.cause = cause;
|
|
165
|
+
this.details = details;
|
|
166
|
+
this.name = 'ReRenderError';
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
exports.ReRenderError = ReRenderError;
|
|
170
|
+
/**
|
|
171
|
+
* State update error - thrown when state updates fail
|
|
172
|
+
*/
|
|
173
|
+
class StateUpdateError extends ReactiveError {
|
|
174
|
+
constructor(message, fiberPath, hookIndex, cause, details) {
|
|
175
|
+
super(message, { ...details, fiberPath, hookIndex, cause: cause?.message });
|
|
176
|
+
this.fiberPath = fiberPath;
|
|
177
|
+
this.hookIndex = hookIndex;
|
|
178
|
+
this.cause = cause;
|
|
179
|
+
this.details = details;
|
|
180
|
+
this.name = 'StateUpdateError';
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
exports.StateUpdateError = StateUpdateError;
|
|
184
|
+
/**
|
|
185
|
+
* Context propagation error - thrown when context updates fail
|
|
186
|
+
*/
|
|
187
|
+
class ContextPropagationError extends ReactiveError {
|
|
188
|
+
constructor(message, contextId, affectedFibers, cause, details) {
|
|
189
|
+
super(message, {
|
|
190
|
+
...details,
|
|
191
|
+
contextId: String(contextId),
|
|
192
|
+
affectedFibers,
|
|
193
|
+
cause: cause?.message,
|
|
194
|
+
});
|
|
195
|
+
this.contextId = contextId;
|
|
196
|
+
this.affectedFibers = affectedFibers;
|
|
197
|
+
this.cause = cause;
|
|
198
|
+
this.details = details;
|
|
199
|
+
this.name = 'ContextPropagationError';
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
exports.ContextPropagationError = ContextPropagationError;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
*
|
|
10
|
+
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
*
|
|
14
|
+
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
|
|
23
|
+
* limitations under the License.
|
|
24
|
+
|
|
25
|
+
*
|
|
26
|
+
|
|
27
|
+
* Copyright 2025 Daniel Coutinho Ribeiro
|
|
28
|
+
|
|
29
|
+
*/
|
|
30
|
+
export * from './types';
|
|
31
|
+
export * from './Renderer';
|
|
32
|
+
export * from './Validator';
|
|
33
|
+
export * from './CloudDOMBuilder';
|
|
34
|
+
export * from './CReact';
|
|
35
|
+
export { CloudDOMEventBus } from './EventBus';
|
|
36
|
+
export { Reconciler } from './Reconciler';
|
|
37
|
+
export { ReconciliationError, DeploymentError, DeploymentErrorData, ValidationError, ProviderError, } from './errors';
|
|
38
|
+
export { StateMachine, DeploymentStatus, DeploymentState, StateMachineEvent, StateMachineEventPayload, AuditLogEntry, } from './StateMachine';
|