@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,64 @@
|
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
32
|
+
if (k2 === undefined) k2 = k;
|
|
33
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
34
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
35
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
36
|
+
}
|
|
37
|
+
Object.defineProperty(o, k2, desc);
|
|
38
|
+
}) : (function(o, m, k, k2) {
|
|
39
|
+
if (k2 === undefined) k2 = k;
|
|
40
|
+
o[k2] = m[k];
|
|
41
|
+
}));
|
|
42
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
43
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.StateMachine = exports.ProviderError = exports.ValidationError = exports.DeploymentError = exports.ReconciliationError = exports.Reconciler = exports.CloudDOMEventBus = void 0;
|
|
47
|
+
// REQ-01: Core module exports
|
|
48
|
+
__exportStar(require("./types"), exports);
|
|
49
|
+
__exportStar(require("./Renderer"), exports);
|
|
50
|
+
__exportStar(require("./Validator"), exports);
|
|
51
|
+
__exportStar(require("./CloudDOMBuilder"), exports);
|
|
52
|
+
__exportStar(require("./CReact"), exports);
|
|
53
|
+
var EventBus_1 = require("./EventBus");
|
|
54
|
+
Object.defineProperty(exports, "CloudDOMEventBus", { enumerable: true, get: function () { return EventBus_1.CloudDOMEventBus; } });
|
|
55
|
+
var Reconciler_1 = require("./Reconciler");
|
|
56
|
+
Object.defineProperty(exports, "Reconciler", { enumerable: true, get: function () { return Reconciler_1.Reconciler; } });
|
|
57
|
+
var errors_1 = require("./errors");
|
|
58
|
+
Object.defineProperty(exports, "ReconciliationError", { enumerable: true, get: function () { return errors_1.ReconciliationError; } });
|
|
59
|
+
Object.defineProperty(exports, "DeploymentError", { enumerable: true, get: function () { return errors_1.DeploymentError; } });
|
|
60
|
+
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return errors_1.ValidationError; } });
|
|
61
|
+
Object.defineProperty(exports, "ProviderError", { enumerable: true, get: function () { return errors_1.ProviderError; } });
|
|
62
|
+
var StateMachine_1 = require("./StateMachine");
|
|
63
|
+
Object.defineProperty(exports, "StateMachine", { enumerable: true, get: function () { return StateMachine_1.StateMachine; } });
|
|
64
|
+
// Runtime removed - not being used, CReact handles all orchestration
|
|
@@ -0,0 +1,263 @@
|
|
|
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
|
+
* Fiber Node - Intermediate representation of JSX tree
|
|
32
|
+
* Contains all components (containers + resources) before filtering to CloudDOM
|
|
33
|
+
*/
|
|
34
|
+
export interface FiberNode {
|
|
35
|
+
/** Component type (function or class) */
|
|
36
|
+
type: any;
|
|
37
|
+
/** Props passed to the component */
|
|
38
|
+
props: Record<string, any>;
|
|
39
|
+
/** Child Fiber nodes */
|
|
40
|
+
children: FiberNode[];
|
|
41
|
+
/** Hierarchical path from root (e.g., ['registry', 'service']) */
|
|
42
|
+
path: string[];
|
|
43
|
+
/** CloudDOM nodes attached by useInstance calls (if any) */
|
|
44
|
+
cloudDOMNodes?: CloudDOMNode[];
|
|
45
|
+
/** Hooks attached by useState/useEffect calls (if any) */
|
|
46
|
+
hooks?: any[];
|
|
47
|
+
/** State attached by useState (if any) */
|
|
48
|
+
state?: Record<string, any>;
|
|
49
|
+
/** Key for stable identity (optional) */
|
|
50
|
+
key?: string | number;
|
|
51
|
+
/** Reactive state tracking for re-rendering system */
|
|
52
|
+
reactiveState?: {
|
|
53
|
+
/** Reason for the last re-render */
|
|
54
|
+
lastRenderReason?: ReRenderReason;
|
|
55
|
+
/** Timestamp of the last render */
|
|
56
|
+
lastRenderTime?: number;
|
|
57
|
+
/** Total number of times this component has been rendered */
|
|
58
|
+
renderCount: number;
|
|
59
|
+
/** Whether this component needs re-rendering */
|
|
60
|
+
isDirty: boolean;
|
|
61
|
+
/** Whether this component has a pending update (mark-and-sweep model) */
|
|
62
|
+
updatePending: boolean;
|
|
63
|
+
/** Context IDs that triggered the pending update (for debugging) */
|
|
64
|
+
pendingContexts?: Set<symbol>;
|
|
65
|
+
};
|
|
66
|
+
/** Dependency tracking for selective re-rendering */
|
|
67
|
+
dependencies?: Set<FiberNode>;
|
|
68
|
+
/** Components that depend on this component */
|
|
69
|
+
dependents?: Set<FiberNode>;
|
|
70
|
+
/** Effect bindings for reactive system integration */
|
|
71
|
+
effectBindings?: Map<number, {
|
|
72
|
+
boundOutputs: string[];
|
|
73
|
+
registeredAt: number;
|
|
74
|
+
}>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* CloudDOM Event Callbacks - Lifecycle event handlers for resources
|
|
78
|
+
* These are extracted from component props and triggered during deployment
|
|
79
|
+
*/
|
|
80
|
+
export interface CloudDOMEventCallbacks {
|
|
81
|
+
/** Called when resource deployment starts */
|
|
82
|
+
onDeploy?: (context: CloudDOMEventContext) => void | Promise<void>;
|
|
83
|
+
/** Called when resource deployment fails */
|
|
84
|
+
onError?: (context: CloudDOMEventContext, error: Error) => void | Promise<void>;
|
|
85
|
+
/** Called when resource is destroyed/deleted */
|
|
86
|
+
onDestroy?: (context: CloudDOMEventContext) => void | Promise<void>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* CloudDOM Event Context - Information passed to event callbacks
|
|
90
|
+
*/
|
|
91
|
+
export interface CloudDOMEventContext {
|
|
92
|
+
/** Resource ID */
|
|
93
|
+
resourceId: string;
|
|
94
|
+
/** Resource path */
|
|
95
|
+
path: string[];
|
|
96
|
+
/** Construct type */
|
|
97
|
+
construct: any;
|
|
98
|
+
/** Resource props (without event callbacks) */
|
|
99
|
+
props: Record<string, any>;
|
|
100
|
+
/** Resource outputs (if available) */
|
|
101
|
+
outputs?: Record<string, any>;
|
|
102
|
+
/** Deployment phase */
|
|
103
|
+
phase: 'deploy' | 'error' | 'destroy';
|
|
104
|
+
/** Timestamp when event occurred */
|
|
105
|
+
timestamp: number;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Event callback props that are automatically available to components using useInstance
|
|
109
|
+
*/
|
|
110
|
+
export interface CloudDOMEventProps {
|
|
111
|
+
/** Called when resource deployment starts */
|
|
112
|
+
onDeploy?: (ctx: CloudDOMEventContext) => void | Promise<void>;
|
|
113
|
+
/** Called when resource deployment fails */
|
|
114
|
+
onError?: (ctx: CloudDOMEventContext, error: Error) => void | Promise<void>;
|
|
115
|
+
/** Called when resource is destroyed/deleted */
|
|
116
|
+
onDestroy?: (ctx: CloudDOMEventContext) => void | Promise<void>;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Utility type that adds event callback props to any component props
|
|
120
|
+
* Use this for components that call useInstance
|
|
121
|
+
*/
|
|
122
|
+
export type WithCloudDOMEvents<T = {}> = T & CloudDOMEventProps;
|
|
123
|
+
/**
|
|
124
|
+
* CloudDOM Node - Represents actual cloud resources
|
|
125
|
+
* Only includes components that called useInstance
|
|
126
|
+
*/
|
|
127
|
+
export interface CloudDOMNode {
|
|
128
|
+
/** Unique resource ID (e.g., 'registry.service') */
|
|
129
|
+
id: string;
|
|
130
|
+
/** Hierarchical path (e.g., ['registry', 'service']) */
|
|
131
|
+
path: string[];
|
|
132
|
+
/** Construct type (e.g., EcrRepository, AppRunnerService) */
|
|
133
|
+
construct: any;
|
|
134
|
+
/** Serializable construct type name (e.g., 'EcrRepository', 'AppRunnerService') */
|
|
135
|
+
constructType: string;
|
|
136
|
+
/** Props for the construct */
|
|
137
|
+
props: Record<string, any>;
|
|
138
|
+
/** Child CloudDOM nodes */
|
|
139
|
+
children: CloudDOMNode[];
|
|
140
|
+
/** Infrastructure outputs from cloud provider (e.g., connectionUrl, port, bucketName) */
|
|
141
|
+
outputs?: Record<string, any>;
|
|
142
|
+
/** Application state from useState hooks (e.g., { state1: "...", state2: 123 }) */
|
|
143
|
+
state?: Record<string, any>;
|
|
144
|
+
/** Event callbacks extracted from component props (optional) */
|
|
145
|
+
eventCallbacks?: CloudDOMEventCallbacks;
|
|
146
|
+
/** Internal: Cached shallow hash of props for fast diff (optional) */
|
|
147
|
+
_propHash?: string;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* JSX Element type
|
|
151
|
+
*/
|
|
152
|
+
export interface JSXElement {
|
|
153
|
+
type: any;
|
|
154
|
+
props: any;
|
|
155
|
+
key?: string | number;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* ChangeSet represents the minimal set of operations to reconcile two CloudDOM states
|
|
159
|
+
*
|
|
160
|
+
* REQ-O01: State Machine needs diff to detect changes
|
|
161
|
+
* REQ-O04: Plan Command needs diff to show preview
|
|
162
|
+
*/
|
|
163
|
+
export interface ChangeSet {
|
|
164
|
+
/** Nodes that exist in current but not in previous (need to be created) */
|
|
165
|
+
creates: CloudDOMNode[];
|
|
166
|
+
/** Nodes that exist in both but have different props (need to be updated) */
|
|
167
|
+
updates: CloudDOMNode[];
|
|
168
|
+
/** Nodes that exist in previous but not in current (need to be deleted) */
|
|
169
|
+
deletes: CloudDOMNode[];
|
|
170
|
+
/** Nodes that changed type (need to be replaced: delete + create) */
|
|
171
|
+
replacements: CloudDOMNode[];
|
|
172
|
+
/** Nodes that moved in the hierarchy (includes node ID for traceability) */
|
|
173
|
+
moves: Array<{
|
|
174
|
+
nodeId: string;
|
|
175
|
+
from: string;
|
|
176
|
+
to: string;
|
|
177
|
+
}>;
|
|
178
|
+
/** Deployment order based on dependency graph (topologically sorted) */
|
|
179
|
+
deploymentOrder: string[];
|
|
180
|
+
/** Parallel deployment batches (nodes at same depth can deploy in parallel) */
|
|
181
|
+
parallelBatches: string[][];
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Get filtered deployment order containing only resources that need deployment
|
|
185
|
+
* (creates, updates, replacements) - excludes unchanged resources
|
|
186
|
+
*
|
|
187
|
+
* @param changeSet - The change set to filter
|
|
188
|
+
* @returns Array of resource IDs that need deployment, in dependency order
|
|
189
|
+
*/
|
|
190
|
+
export declare function getResourcesToDeploy(changeSet: ChangeSet): string[];
|
|
191
|
+
/**
|
|
192
|
+
* DependencyGraph represents resource dependencies for deployment ordering
|
|
193
|
+
*
|
|
194
|
+
* Maps node ID → array of dependency IDs
|
|
195
|
+
*/
|
|
196
|
+
export interface DependencyGraph {
|
|
197
|
+
/** Adjacency list: node ID → dependency IDs */
|
|
198
|
+
dependencies: Map<string, string[]>;
|
|
199
|
+
/** Reverse adjacency list: node ID → dependent IDs (nodes that depend on this node) */
|
|
200
|
+
dependents: Map<string, string[]>;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* ReRenderReason - Reasons why a component re-render was triggered
|
|
204
|
+
* Used for debugging, performance monitoring, and selective re-rendering
|
|
205
|
+
*
|
|
206
|
+
* Note: useState changes alone do NOT trigger re-renders in CReact.
|
|
207
|
+
* Re-renders only occur when provider outputs that are bound to state change.
|
|
208
|
+
*/
|
|
209
|
+
export type ReRenderReason = 'output-update' | 'context-change' | 'structural-change' | 'hot-reload' | 'manual';
|
|
210
|
+
/**
|
|
211
|
+
* CReactEvents - Lifecycle event hooks for reactive system
|
|
212
|
+
* Optional interface for tooling, debugging, and performance monitoring
|
|
213
|
+
*/
|
|
214
|
+
export interface CReactEvents {
|
|
215
|
+
/** Called when a component render starts */
|
|
216
|
+
onRenderStart(fiber: FiberNode): void;
|
|
217
|
+
/** Called when a component render completes successfully */
|
|
218
|
+
onRenderComplete(fiber: FiberNode): void;
|
|
219
|
+
/** Called when deployment starts for a stack */
|
|
220
|
+
onDeployStart(stack: string): void;
|
|
221
|
+
/** Called when deployment completes successfully for a stack */
|
|
222
|
+
onDeployComplete(stack: string): void;
|
|
223
|
+
/** Called when an error occurs during rendering or deployment */
|
|
224
|
+
onError(error: Error, fiber?: FiberNode): void;
|
|
225
|
+
/** Called when a context value is updated (for observability) */
|
|
226
|
+
onContextUpdate?(contextId: symbol, previousValue: any, newValue: any): void;
|
|
227
|
+
/** Called when a fiber is scheduled for re-render (for telemetry/visualization) */
|
|
228
|
+
onFiberReRenderScheduled?(fiber: FiberNode, reason: ReRenderReason, contextId?: symbol): void;
|
|
229
|
+
/** Called when structural changes are detected in CloudDOM topology */
|
|
230
|
+
onStructuralChange?(change: any): void;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* OutputBinding - Tracks binding between component state and provider outputs
|
|
234
|
+
* Used by StateBindingManager to detect when outputs change
|
|
235
|
+
*/
|
|
236
|
+
export interface OutputBinding {
|
|
237
|
+
/** CloudDOM node ID that provides the output */
|
|
238
|
+
nodeId: string;
|
|
239
|
+
/** Output key from the provider */
|
|
240
|
+
outputKey: string;
|
|
241
|
+
/** Last known value of the output */
|
|
242
|
+
lastValue: any;
|
|
243
|
+
/** Timestamp when binding was created */
|
|
244
|
+
bindTime: number;
|
|
245
|
+
/** Timestamp when binding was last updated (optional, for observability) */
|
|
246
|
+
lastUpdate?: number;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* OutputChange - Represents a change in provider output
|
|
250
|
+
* Used to track what changed and which components are affected
|
|
251
|
+
*/
|
|
252
|
+
export interface OutputChange {
|
|
253
|
+
/** CloudDOM node ID that changed */
|
|
254
|
+
nodeId: string;
|
|
255
|
+
/** Output key that changed */
|
|
256
|
+
outputKey: string;
|
|
257
|
+
/** Previous value */
|
|
258
|
+
previousValue: any;
|
|
259
|
+
/** New value */
|
|
260
|
+
newValue: any;
|
|
261
|
+
/** Fiber nodes affected by this change */
|
|
262
|
+
affectedFibers: FiberNode[];
|
|
263
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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.getResourcesToDeploy = getResourcesToDeploy;
|
|
33
|
+
/**
|
|
34
|
+
* Get filtered deployment order containing only resources that need deployment
|
|
35
|
+
* (creates, updates, replacements) - excludes unchanged resources
|
|
36
|
+
*
|
|
37
|
+
* @param changeSet - The change set to filter
|
|
38
|
+
* @returns Array of resource IDs that need deployment, in dependency order
|
|
39
|
+
*/
|
|
40
|
+
function getResourcesToDeploy(changeSet) {
|
|
41
|
+
const resourcesToDeploy = new Set([
|
|
42
|
+
...changeSet.creates.map(n => n.id),
|
|
43
|
+
...changeSet.updates.map(n => n.id),
|
|
44
|
+
...changeSet.replacements.map(n => n.id),
|
|
45
|
+
]);
|
|
46
|
+
// Filter deployment order to maintain dependency ordering
|
|
47
|
+
return changeSet.deploymentOrder.filter(id => resourcesToDeploy.has(id));
|
|
48
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
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 { FiberNode } from '../core/types';
|
|
31
|
+
/**
|
|
32
|
+
* Access tracking session for output dependency analysis
|
|
33
|
+
*/
|
|
34
|
+
interface AccessTrackingSession {
|
|
35
|
+
fiber: FiberNode;
|
|
36
|
+
startTime: number;
|
|
37
|
+
trackedOutputs: Set<string>;
|
|
38
|
+
isActive: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Consolidated Hook Context - Single source of truth for all hook state
|
|
42
|
+
* Addresses Issue #9: Hook Context Consolidation
|
|
43
|
+
*/
|
|
44
|
+
interface ConsolidatedHookContext {
|
|
45
|
+
currentFiber: FiberNode | null;
|
|
46
|
+
stateHookIndex: number;
|
|
47
|
+
effectHookIndex: number;
|
|
48
|
+
contextHookIndex: number;
|
|
49
|
+
instanceHookIndex: number;
|
|
50
|
+
contextStacks: Map<symbol, any[]>;
|
|
51
|
+
currentPath: string[];
|
|
52
|
+
previousOutputsMap: Map<string, Record<string, any>> | null;
|
|
53
|
+
accessTrackingSessions: Map<FiberNode, AccessTrackingSession>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get the consolidated hook context with validation
|
|
57
|
+
* This is the primary function all hooks should use
|
|
58
|
+
*/
|
|
59
|
+
export declare function requireHookContext(): ConsolidatedHookContext;
|
|
60
|
+
/**
|
|
61
|
+
* Run a function with a new consolidated hook context
|
|
62
|
+
*/
|
|
63
|
+
export declare function runWithHookContext<T>(fn: () => T): T;
|
|
64
|
+
/**
|
|
65
|
+
* Increment hook index for specific hook type
|
|
66
|
+
*/
|
|
67
|
+
export declare function incrementHookIndex(hookType?: 'state' | 'effect' | 'context' | 'instance'): number;
|
|
68
|
+
/**
|
|
69
|
+
* Set the current rendering context for all hooks
|
|
70
|
+
* Called by Renderer before executing a component
|
|
71
|
+
*
|
|
72
|
+
* Requirements: 8.2, 8.4
|
|
73
|
+
*/
|
|
74
|
+
export declare function setRenderContext(fiber: FiberNode, path?: string[]): void;
|
|
75
|
+
/**
|
|
76
|
+
* Clear the current rendering context for all hooks
|
|
77
|
+
* Called by Renderer after component execution
|
|
78
|
+
*
|
|
79
|
+
* Requirements: 8.2, 8.4
|
|
80
|
+
*/
|
|
81
|
+
export declare function clearRenderContext(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Check if there is an active render context
|
|
84
|
+
*/
|
|
85
|
+
export declare function hasRenderContext(): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Get the current fiber state
|
|
88
|
+
*/
|
|
89
|
+
export declare function getCurrentState(): Record<string, any> | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Push a context value onto the stack
|
|
92
|
+
* Called by Renderer when entering a Provider
|
|
93
|
+
*/
|
|
94
|
+
export declare function pushContextValue(contextId: symbol, value: any): void;
|
|
95
|
+
/**
|
|
96
|
+
* Pop a context value from the stack
|
|
97
|
+
* Called by Renderer when exiting a Provider
|
|
98
|
+
*/
|
|
99
|
+
export declare function popContextValue(contextId: symbol): void;
|
|
100
|
+
/**
|
|
101
|
+
* Get the current context value from the stack
|
|
102
|
+
*/
|
|
103
|
+
export declare function getContextValue(contextId: symbol): {
|
|
104
|
+
hasValue: boolean;
|
|
105
|
+
value: any;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Clear all context stacks
|
|
109
|
+
* Called by Renderer to prevent memory leaks
|
|
110
|
+
*/
|
|
111
|
+
export declare function clearContextStacks(): void;
|
|
112
|
+
/**
|
|
113
|
+
* Clear the global previous outputs map
|
|
114
|
+
* Called for test isolation and cleanup
|
|
115
|
+
*/
|
|
116
|
+
export declare function clearPreviousOutputs(): void;
|
|
117
|
+
/**
|
|
118
|
+
* Set previous outputs map for restoration during render
|
|
119
|
+
* Called by CReact before rendering
|
|
120
|
+
*/
|
|
121
|
+
export declare function setPreviousOutputs(outputsMap: Map<string, Record<string, any>> | null): void;
|
|
122
|
+
/**
|
|
123
|
+
* Get the current rendering path
|
|
124
|
+
*/
|
|
125
|
+
export declare function getCurrentPath(): string[];
|
|
126
|
+
/**
|
|
127
|
+
* Check if currently rendering
|
|
128
|
+
*/
|
|
129
|
+
export declare function isRendering(): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Start tracking output accesses for a fiber
|
|
132
|
+
* Used by useEffect to track which outputs are accessed in dependencies
|
|
133
|
+
*/
|
|
134
|
+
export declare function startAccessTracking(fiber: FiberNode): void;
|
|
135
|
+
/**
|
|
136
|
+
* End tracking and return the set of accessed outputs
|
|
137
|
+
*/
|
|
138
|
+
export declare function endAccessTracking(fiber: FiberNode): Set<string>;
|
|
139
|
+
/**
|
|
140
|
+
* Track an output access during an active tracking session
|
|
141
|
+
*/
|
|
142
|
+
export declare function trackOutputAccess(fiber: FiberNode, bindingKey: string): void;
|
|
143
|
+
/**
|
|
144
|
+
* Get the current access tracking session for a fiber
|
|
145
|
+
*/
|
|
146
|
+
export declare function getAccessTrackingSession(fiber: FiberNode): AccessTrackingSession | undefined;
|
|
147
|
+
export {};
|