@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,113 @@
|
|
|
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.createContext = createContext;
|
|
33
|
+
/**
|
|
34
|
+
* Create a typed context object (like React.createContext)
|
|
35
|
+
*
|
|
36
|
+
* Returns a context object with Provider and Consumer components.
|
|
37
|
+
* Use with useContext hook to access values from the nearest Provider.
|
|
38
|
+
*
|
|
39
|
+
* REQ-02: Stack Context (declarative outputs)
|
|
40
|
+
*
|
|
41
|
+
* @param defaultValue - Optional default value when no Provider exists
|
|
42
|
+
* @returns Context object with Provider and Consumer
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* // Create a typed context
|
|
47
|
+
* interface RegistryOutputs {
|
|
48
|
+
* repositoryUrl?: string;
|
|
49
|
+
* repositoryArn?: string;
|
|
50
|
+
* }
|
|
51
|
+
*
|
|
52
|
+
* const RegistryContext = createContext<RegistryOutputs>({});
|
|
53
|
+
*
|
|
54
|
+
* // Provider component
|
|
55
|
+
* function RegistryStack({ children }) {
|
|
56
|
+
* const repo = useInstance(EcrRepository, { key: 'repo', name: 'my-app' });
|
|
57
|
+
* const [repositoryUrl, setRepositoryUrl] = useState();
|
|
58
|
+
* const [repositoryArn, setRepositoryArn] = useState();
|
|
59
|
+
*
|
|
60
|
+
* const outputs = { repositoryUrl, repositoryArn };
|
|
61
|
+
* return <RegistryContext.Provider value={outputs}>{children}</RegistryContext.Provider>;
|
|
62
|
+
* }
|
|
63
|
+
*
|
|
64
|
+
* // Consumer component
|
|
65
|
+
* function Service() {
|
|
66
|
+
* const { repositoryUrl } = useContext(RegistryContext);
|
|
67
|
+
* const service = useInstance(AppRunnerService, {
|
|
68
|
+
* image: `${repositoryUrl}:latest`
|
|
69
|
+
* });
|
|
70
|
+
* return <></>;
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
function createContext(defaultValue) {
|
|
75
|
+
// Create unique symbol to identify this context
|
|
76
|
+
const contextId = Symbol('Context');
|
|
77
|
+
/**
|
|
78
|
+
* Provider component - Supplies context value to descendants
|
|
79
|
+
*
|
|
80
|
+
* @param props.value - Value to provide to descendants
|
|
81
|
+
* @param props.children - Child components
|
|
82
|
+
*/
|
|
83
|
+
const Provider = (props) => {
|
|
84
|
+
// Provider is a pass-through component that just returns its children
|
|
85
|
+
// The Renderer will recognize it by the metadata on the function and store the context value in the Fiber
|
|
86
|
+
// The props will be preserved in the Fiber node, including _contextId and _contextValue
|
|
87
|
+
return props.children;
|
|
88
|
+
};
|
|
89
|
+
// Mark Provider with context metadata for Renderer to recognize
|
|
90
|
+
Provider._isContextProvider = true;
|
|
91
|
+
Provider._contextId = contextId;
|
|
92
|
+
/**
|
|
93
|
+
* Consumer component - Consumes context value (alternative to useContext)
|
|
94
|
+
*
|
|
95
|
+
* @param props.children - Render function that receives context value
|
|
96
|
+
*/
|
|
97
|
+
const Consumer = (props) => {
|
|
98
|
+
// Consumer is a placeholder - useContext hook will handle the actual lookup
|
|
99
|
+
// The render function will be called by the Renderer with the context value
|
|
100
|
+
return props.children;
|
|
101
|
+
};
|
|
102
|
+
// Mark Consumer with context metadata
|
|
103
|
+
Consumer._isContextConsumer = true;
|
|
104
|
+
Consumer._contextId = contextId;
|
|
105
|
+
// Return context object
|
|
106
|
+
const context = {
|
|
107
|
+
_contextId: contextId,
|
|
108
|
+
defaultValue,
|
|
109
|
+
Provider,
|
|
110
|
+
Consumer,
|
|
111
|
+
};
|
|
112
|
+
return context;
|
|
113
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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 { createContext, Context } from './createContext';
|
|
@@ -0,0 +1,35 @@
|
|
|
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.createContext = void 0;
|
|
33
|
+
// REQ-02: Context API exports
|
|
34
|
+
var createContext_1 = require("./createContext");
|
|
35
|
+
Object.defineProperty(exports, "createContext", { enumerable: true, get: function () { return createContext_1.createContext; } });
|
|
@@ -0,0 +1,409 @@
|
|
|
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
|
+
import { StateMachine } from './StateMachine';
|
|
31
|
+
import { ICloudProvider } from '../providers/ICloudProvider';
|
|
32
|
+
import { IBackendProvider } from '../providers/IBackendProvider';
|
|
33
|
+
import { CloudDOMNode, JSXElement, ChangeSet, FiberNode, ReRenderReason, CReactEvents } from './types';
|
|
34
|
+
import { CReact as JSXCReact } from '../jsx';
|
|
35
|
+
/**
|
|
36
|
+
* Configuration for CReact orchestrator
|
|
37
|
+
* REQ-04: Dependency injection - providers are injected via config
|
|
38
|
+
*/
|
|
39
|
+
export interface CReactConfig {
|
|
40
|
+
/** Cloud provider for materialization (injected) */
|
|
41
|
+
cloudProvider: ICloudProvider;
|
|
42
|
+
/** Backend provider for state management (injected) */
|
|
43
|
+
backendProvider: IBackendProvider;
|
|
44
|
+
/** Optional migration map for refactoring (REQ-08) */
|
|
45
|
+
migrationMap?: Record<string, string>;
|
|
46
|
+
/** Async timeout in milliseconds (default: 5 minutes) (REQ-10.5) */
|
|
47
|
+
asyncTimeout?: number;
|
|
48
|
+
/** Optional event hooks for reactive system integration */
|
|
49
|
+
eventHooks?: CReactEvents;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Retry policy configuration
|
|
53
|
+
*/
|
|
54
|
+
export interface RetryPolicy {
|
|
55
|
+
maxRetries?: number;
|
|
56
|
+
initialDelay?: number;
|
|
57
|
+
maxDelay?: number;
|
|
58
|
+
backoffMultiplier?: number;
|
|
59
|
+
timeout?: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* CReact orchestrator - main class
|
|
63
|
+
*
|
|
64
|
+
* Orchestrates the entire infrastructure-as-code pipeline:
|
|
65
|
+
* 1. Render JSX → Fiber tree
|
|
66
|
+
* 2. Validate Fiber tree
|
|
67
|
+
* 3. Build CloudDOM from Fiber
|
|
68
|
+
* 4. Compare CloudDOM trees (diff via Reconciler)
|
|
69
|
+
* 5. Deploy CloudDOM via StateMachine
|
|
70
|
+
*
|
|
71
|
+
* REQ-01: JSX → CloudDOM rendering
|
|
72
|
+
* REQ-04: Dependency injection pattern
|
|
73
|
+
* REQ-05: Deployment orchestration via StateMachine
|
|
74
|
+
* REQ-07: Validation before commit/deploy
|
|
75
|
+
* REQ-09: Provider lifecycle hooks
|
|
76
|
+
* REQ-O01: StateMachine handles all state management
|
|
77
|
+
*/
|
|
78
|
+
export declare class CReact {
|
|
79
|
+
private config;
|
|
80
|
+
static cloudProvider: ICloudProvider;
|
|
81
|
+
static backendProvider: IBackendProvider;
|
|
82
|
+
static retryPolicy?: RetryPolicy;
|
|
83
|
+
static asyncTimeout?: number;
|
|
84
|
+
static migrationMap?: Record<string, string>;
|
|
85
|
+
static createElement: typeof JSXCReact.createElement;
|
|
86
|
+
static Fragment: (props: {
|
|
87
|
+
children?: any;
|
|
88
|
+
}) => import("../jsx").JSXElement;
|
|
89
|
+
private static globalInstance;
|
|
90
|
+
private static hydrationMap;
|
|
91
|
+
private renderer;
|
|
92
|
+
private validator;
|
|
93
|
+
private cloudDOMBuilder;
|
|
94
|
+
private reconciler;
|
|
95
|
+
private stateMachine;
|
|
96
|
+
private lastFiberTree;
|
|
97
|
+
private renderScheduler;
|
|
98
|
+
private stateBindingManager;
|
|
99
|
+
private providerOutputTracker;
|
|
100
|
+
private contextDependencyTracker;
|
|
101
|
+
private errorRecoveryManager;
|
|
102
|
+
private structuralChangeDetector;
|
|
103
|
+
private hasReactiveChanges;
|
|
104
|
+
private reactiveCloudDOM;
|
|
105
|
+
private preReactiveCloudDOM;
|
|
106
|
+
/**
|
|
107
|
+
* Constructor receives all dependencies via config (dependency injection)
|
|
108
|
+
*
|
|
109
|
+
* REQ-04: Providers are injected, not inherited
|
|
110
|
+
*
|
|
111
|
+
* @param config - Configuration with injected providers
|
|
112
|
+
*/
|
|
113
|
+
constructor(config: CReactConfig);
|
|
114
|
+
/**
|
|
115
|
+
* Debug logging helper
|
|
116
|
+
* Logs messages when CREACT_DEBUG environment variable is set
|
|
117
|
+
*
|
|
118
|
+
* @param message - Message to log
|
|
119
|
+
*/
|
|
120
|
+
private log;
|
|
121
|
+
/**
|
|
122
|
+
* Get the global CReact instance for hooks to access
|
|
123
|
+
* @internal
|
|
124
|
+
*/
|
|
125
|
+
static getCReactInstance(): CReact | null;
|
|
126
|
+
/**
|
|
127
|
+
* Schedule a component for re-rendering
|
|
128
|
+
* This is called by hooks when reactive state changes
|
|
129
|
+
*
|
|
130
|
+
* @param fiber - Fiber node to re-render
|
|
131
|
+
* @param reason - Reason for the re-render
|
|
132
|
+
*/
|
|
133
|
+
scheduleReRender(fiber: FiberNode, reason: ReRenderReason): void;
|
|
134
|
+
/**
|
|
135
|
+
* Handle output change events from provider (event-driven reactivity)
|
|
136
|
+
* Called when provider emits 'outputsChanged' event
|
|
137
|
+
*
|
|
138
|
+
* This enables real-time reactivity without polling:
|
|
139
|
+
* 1. Update ProviderOutputTracker with new outputs
|
|
140
|
+
* 2. Execute useEffect callbacks bound to these outputs
|
|
141
|
+
* 3. Update bound state and enqueue affected fibers for re-render
|
|
142
|
+
*
|
|
143
|
+
* @param change - Output change event from provider
|
|
144
|
+
*/
|
|
145
|
+
private handleProviderOutputChange;
|
|
146
|
+
/**
|
|
147
|
+
* Handle context value changes and trigger selective re-renders
|
|
148
|
+
* This is called when a context provider value changes
|
|
149
|
+
*
|
|
150
|
+
* @param contextId - Context identifier
|
|
151
|
+
* @param newValue - New context value
|
|
152
|
+
* @returns Promise resolving to affected fibers that were re-rendered
|
|
153
|
+
*/
|
|
154
|
+
handleContextChange(contextId: symbol, newValue: any): Promise<FiberNode[]>;
|
|
155
|
+
/**
|
|
156
|
+
* Manual re-render trigger for CLI/testing
|
|
157
|
+
* Re-renders the entire stack or specific components
|
|
158
|
+
*
|
|
159
|
+
* @param stackName - Stack name to re-render (default: 'default')
|
|
160
|
+
* @param targetComponents - Optional specific components to re-render
|
|
161
|
+
* @returns Promise resolving to updated CloudDOM
|
|
162
|
+
*/
|
|
163
|
+
rerender(stackName?: string, targetComponents?: FiberNode[]): Promise<CloudDOMNode[]>;
|
|
164
|
+
/**
|
|
165
|
+
* Build CloudDOM from JSX
|
|
166
|
+
*
|
|
167
|
+
* Pipeline: render → validate → build → restore outputs
|
|
168
|
+
*
|
|
169
|
+
* REQ-01: JSX → CloudDOM rendering
|
|
170
|
+
* REQ-07: Validate before commit
|
|
171
|
+
*
|
|
172
|
+
* @param jsx - JSX element to render
|
|
173
|
+
* @param stackName - Stack name for state restoration (default: 'default')
|
|
174
|
+
* @returns Promise resolving to CloudDOM tree
|
|
175
|
+
*/
|
|
176
|
+
build(jsx: JSXElement, stackName?: string): Promise<CloudDOMNode[]>;
|
|
177
|
+
/**
|
|
178
|
+
* Build a map of node ID → outputs from previous CloudDOM
|
|
179
|
+
*
|
|
180
|
+
* @param previousCloudDOM - Previous CloudDOM state
|
|
181
|
+
* @returns Map of node ID → outputs
|
|
182
|
+
*/
|
|
183
|
+
private buildOutputsMap;
|
|
184
|
+
/**
|
|
185
|
+
* Build CloudDOM with error handling for CLI/CI environments
|
|
186
|
+
*
|
|
187
|
+
* Provides a safer entrypoint that handles errors gracefully without
|
|
188
|
+
* crashing the entire process. Useful for CI/CD pipelines.
|
|
189
|
+
*
|
|
190
|
+
* @param jsx - JSX element to render
|
|
191
|
+
* @returns Promise resolving to CloudDOM tree, or empty array on error
|
|
192
|
+
*/
|
|
193
|
+
buildSafe(jsx: JSXElement): Promise<CloudDOMNode[]>;
|
|
194
|
+
/**
|
|
195
|
+
* Compare two CloudDOM trees and return diff
|
|
196
|
+
*
|
|
197
|
+
* REQ-05: Reconciliation and diff
|
|
198
|
+
* REQ-07.6: Validate before comparing
|
|
199
|
+
*
|
|
200
|
+
* @param previous - Previous CloudDOM tree
|
|
201
|
+
* @param current - Current CloudDOM tree
|
|
202
|
+
* @returns ChangeSet with creates, updates, deletes, and deployment order
|
|
203
|
+
*/
|
|
204
|
+
compare(previous: CloudDOMNode[], current: CloudDOMNode[]): Promise<ChangeSet>;
|
|
205
|
+
/**
|
|
206
|
+
* Get reactive deployment information if changes are pending
|
|
207
|
+
* Returns null if no reactive changes detected
|
|
208
|
+
*
|
|
209
|
+
* This encapsulates the logic for checking reactive changes and computing diffs,
|
|
210
|
+
* keeping separation of concerns between core and CLI layers.
|
|
211
|
+
*
|
|
212
|
+
* @param stackName - Stack name to compute diff against
|
|
213
|
+
* @returns Reactive deployment info with CloudDOM and ChangeSet, or null
|
|
214
|
+
*/
|
|
215
|
+
getReactiveDeploymentInfo(stackName: string): Promise<{
|
|
216
|
+
cloudDOM: CloudDOMNode[];
|
|
217
|
+
changeSet: any;
|
|
218
|
+
} | null>;
|
|
219
|
+
/**
|
|
220
|
+
* Clear reactive changes flag (called after deployment)
|
|
221
|
+
*/
|
|
222
|
+
private clearReactiveChanges;
|
|
223
|
+
/**
|
|
224
|
+
* Deploy CloudDOM to cloud provider using StateMachine
|
|
225
|
+
*
|
|
226
|
+
* Pipeline: validate → compute diff → start deployment → materialize → checkpoint → complete
|
|
227
|
+
*
|
|
228
|
+
* REQ-05: Deployment orchestration via StateMachine
|
|
229
|
+
* REQ-05.4: Idempotent deployment (via Reconciler diff)
|
|
230
|
+
* REQ-07.6: Validate before deploying
|
|
231
|
+
* REQ-09: Provider lifecycle hooks
|
|
232
|
+
* REQ-O01: StateMachine handles all state management
|
|
233
|
+
*
|
|
234
|
+
* @param cloudDOM - CloudDOM tree to deploy
|
|
235
|
+
* @param stackName - Stack name for state management (default: 'default')
|
|
236
|
+
* @param user - User initiating deployment (default: 'system')
|
|
237
|
+
*/
|
|
238
|
+
deploy(cloudDOM: CloudDOMNode[], stackName?: string, user?: string): Promise<void>;
|
|
239
|
+
/**
|
|
240
|
+
* Load previous state from backend and prepare for hydration
|
|
241
|
+
* This should be called before rendering to restore persisted state
|
|
242
|
+
*
|
|
243
|
+
* @param stackName - Stack name to load state for
|
|
244
|
+
*/
|
|
245
|
+
loadStateForHydration(stackName: string): Promise<void>;
|
|
246
|
+
/**
|
|
247
|
+
* Prepare hydration data from previous CloudDOM
|
|
248
|
+
* This must be called BEFORE rendering to make state available to useState
|
|
249
|
+
*
|
|
250
|
+
* CRITICAL: State outputs belong to the COMPONENT that called useState,
|
|
251
|
+
* not the CloudDOM node. We need to key by component path (parent of node).
|
|
252
|
+
*
|
|
253
|
+
* Example:
|
|
254
|
+
* - Component path: ['web-app-stack']
|
|
255
|
+
* - CloudDOM node paths: ['web-app-stack', 'vpc'], ['web-app-stack', 'database']
|
|
256
|
+
* - All nodes from same component share the same state outputs
|
|
257
|
+
* - Hydration should be keyed by 'web-app-stack', not 'web-app-stack.vpc'
|
|
258
|
+
*
|
|
259
|
+
* @param previousCloudDOM - Previous CloudDOM with persisted state outputs
|
|
260
|
+
* @param clearExisting - Whether to clear existing hydration data (default: false)
|
|
261
|
+
*/
|
|
262
|
+
prepareHydration(previousCloudDOM: CloudDOMNode[], clearExisting?: boolean): void;
|
|
263
|
+
/**
|
|
264
|
+
* Get hydrated value for a specific fiber and hook index
|
|
265
|
+
* Called by useState during render to check for persisted state
|
|
266
|
+
*
|
|
267
|
+
* @param fiberPath - Path of the fiber
|
|
268
|
+
* @param hookIndex - Index of the hook
|
|
269
|
+
* @returns Hydrated value or undefined if not found
|
|
270
|
+
*/
|
|
271
|
+
getHydratedValue(fiberPath: string, hookIndex: number): any;
|
|
272
|
+
/**
|
|
273
|
+
* Get hydrated value for a component by searching for any child node
|
|
274
|
+
* This handles the case where useState is in a parent component but state
|
|
275
|
+
* outputs are stored on child CloudDOM nodes
|
|
276
|
+
*
|
|
277
|
+
* With the path mapping fix, this should now find exact matches.
|
|
278
|
+
* The child node search is kept as a fallback for edge cases.
|
|
279
|
+
*
|
|
280
|
+
* @param componentPath - Path of the component (e.g., 'web-app-stack')
|
|
281
|
+
* @param hookIndex - Index of the hook
|
|
282
|
+
* @returns Hydrated value or undefined if not found
|
|
283
|
+
*/
|
|
284
|
+
getHydratedValueForComponent(componentPath: string, hookIndex: number): any;
|
|
285
|
+
/**
|
|
286
|
+
* Check if hydration data is available
|
|
287
|
+
*
|
|
288
|
+
* @returns True if hydration map has data
|
|
289
|
+
*/
|
|
290
|
+
hasHydrationData(): boolean;
|
|
291
|
+
/**
|
|
292
|
+
* Get hydration map keys for debugging
|
|
293
|
+
*
|
|
294
|
+
* @returns Array of component paths with hydration data
|
|
295
|
+
*/
|
|
296
|
+
getHydrationMapKeys(): string[];
|
|
297
|
+
/**
|
|
298
|
+
* Clear hydration data after rendering is complete
|
|
299
|
+
*/
|
|
300
|
+
clearHydration(): void;
|
|
301
|
+
/**
|
|
302
|
+
* Serialize internal reactive state for hot reload preservation
|
|
303
|
+
* This captures the state of reactive systems that need to survive recompilation
|
|
304
|
+
*
|
|
305
|
+
* @returns Serialized state object
|
|
306
|
+
*/
|
|
307
|
+
serializeReactiveState(): any;
|
|
308
|
+
/**
|
|
309
|
+
* Restore internal reactive state after hot reload recompilation
|
|
310
|
+
* This restores the state of reactive systems from serialized data
|
|
311
|
+
*
|
|
312
|
+
* @param serializedState - Previously serialized state
|
|
313
|
+
*/
|
|
314
|
+
restoreReactiveState(serializedState: any): void;
|
|
315
|
+
/**
|
|
316
|
+
* Hydrate the current fiber tree with state values from previous CloudDOM
|
|
317
|
+
* This is used during hot reload to restore persisted state values
|
|
318
|
+
*
|
|
319
|
+
* @param previousCloudDOM - Previous CloudDOM with persisted state outputs
|
|
320
|
+
*/
|
|
321
|
+
hydrateStateFromPreviousCloudDOM(previousCloudDOM: CloudDOMNode[]): void;
|
|
322
|
+
/**
|
|
323
|
+
* Check if outputs actually changed between previous and current CloudDOM
|
|
324
|
+
* REQ-7.1, 7.2, 7.3: Proper output change detection including undefined → value transitions
|
|
325
|
+
*
|
|
326
|
+
* @param previous - Previous CloudDOM state
|
|
327
|
+
* @param current - Current CloudDOM state
|
|
328
|
+
* @returns True if any outputs actually changed
|
|
329
|
+
*/
|
|
330
|
+
private hasActualOutputChanges;
|
|
331
|
+
/**
|
|
332
|
+
* Find a CloudDOM node by ID
|
|
333
|
+
*
|
|
334
|
+
* @param nodes - CloudDOM tree to search
|
|
335
|
+
* @param id - Node ID to find
|
|
336
|
+
* @returns CloudDOM node or undefined if not found
|
|
337
|
+
*/
|
|
338
|
+
private findNodeById;
|
|
339
|
+
/**
|
|
340
|
+
* Extract outputs from CloudDOM nodes
|
|
341
|
+
*
|
|
342
|
+
* Walks the CloudDOM tree and collects all outputs from nodes.
|
|
343
|
+
* Outputs are formatted as nodeId.outputKey (e.g., 'registry.state-0').
|
|
344
|
+
*
|
|
345
|
+
* REQ-02: Extract outputs from useState calls
|
|
346
|
+
* REQ-06: Universal output access
|
|
347
|
+
*
|
|
348
|
+
* @param cloudDOM - CloudDOM tree
|
|
349
|
+
* @returns Outputs object with keys in format nodeId.outputKey
|
|
350
|
+
*/
|
|
351
|
+
private extractOutputs;
|
|
352
|
+
/**
|
|
353
|
+
* Get the cloud provider (for testing/debugging)
|
|
354
|
+
*
|
|
355
|
+
* @returns The injected cloud provider
|
|
356
|
+
*/
|
|
357
|
+
getCloudProvider(): ICloudProvider;
|
|
358
|
+
/**
|
|
359
|
+
* Get the backend provider (for testing/debugging)
|
|
360
|
+
*
|
|
361
|
+
* @returns The injected backend provider
|
|
362
|
+
*/
|
|
363
|
+
getBackendProvider(): IBackendProvider;
|
|
364
|
+
/**
|
|
365
|
+
* Get the state machine (for testing/debugging)
|
|
366
|
+
*
|
|
367
|
+
* @returns The state machine instance
|
|
368
|
+
*/
|
|
369
|
+
getStateMachine(): StateMachine;
|
|
370
|
+
/**
|
|
371
|
+
* Get backend state for a stack (for CLI/comparison)
|
|
372
|
+
*
|
|
373
|
+
* @param stackName - Stack name to get state for
|
|
374
|
+
* @returns Promise resolving to backend state or null
|
|
375
|
+
*/
|
|
376
|
+
getBackendState(stackName: string): Promise<any>;
|
|
377
|
+
/**
|
|
378
|
+
* React-style render method (singleton API)
|
|
379
|
+
*
|
|
380
|
+
* Renders JSX to CloudDOM using the singleton configuration.
|
|
381
|
+
* This is the recommended API for entry files.
|
|
382
|
+
*
|
|
383
|
+
* Example:
|
|
384
|
+
* ```typescript
|
|
385
|
+
* // Configure providers
|
|
386
|
+
* CReact.cloudProvider = new AwsCloudProvider();
|
|
387
|
+
* CReact.backendProvider = new S3BackendProvider();
|
|
388
|
+
*
|
|
389
|
+
* // Render app
|
|
390
|
+
* export default CReact.renderCloudDOM(<MyApp />, 'my-stack');
|
|
391
|
+
* ```
|
|
392
|
+
*
|
|
393
|
+
* @param element - JSX element to render
|
|
394
|
+
* @param stackName - Stack name for state management
|
|
395
|
+
* @returns Promise resolving to CloudDOM tree
|
|
396
|
+
* @throws Error if providers are not configured
|
|
397
|
+
*/
|
|
398
|
+
static renderCloudDOM(element: JSXElement, stackName: string): Promise<CloudDOMNode[]>;
|
|
399
|
+
/**
|
|
400
|
+
* Get the last instance created by renderCloudDOM (for CLI use)
|
|
401
|
+
* @internal
|
|
402
|
+
*/
|
|
403
|
+
static getLastInstance(): {
|
|
404
|
+
instance: CReact;
|
|
405
|
+
element: JSXElement;
|
|
406
|
+
stackName: string;
|
|
407
|
+
} | null;
|
|
408
|
+
}
|
|
409
|
+
export declare const getCReactInstance: typeof CReact.getCReactInstance;
|