@creact-labs/creact 0.1.8 → 0.2.1
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/README.md +85 -22
- package/dist/cli.d.ts +11 -0
- package/dist/cli.js +88 -0
- package/dist/index.d.ts +19 -44
- package/dist/index.js +20 -68
- package/dist/jsx/index.d.ts +2 -0
- package/dist/jsx/index.js +1 -0
- package/dist/jsx/jsx-dev-runtime.d.ts +4 -0
- package/dist/jsx/jsx-dev-runtime.js +4 -0
- package/dist/jsx/jsx-runtime.d.ts +38 -0
- package/dist/jsx/jsx-runtime.js +38 -0
- package/dist/jsx/types.d.ts +12 -0
- package/dist/jsx/types.js +4 -0
- package/dist/primitives/context.d.ts +34 -0
- package/dist/primitives/context.js +63 -0
- package/dist/primitives/index.d.ts +3 -0
- package/dist/primitives/index.js +3 -0
- package/dist/primitives/instance.d.ts +72 -0
- package/dist/primitives/instance.js +235 -0
- package/dist/primitives/store.d.ts +22 -0
- package/dist/primitives/store.js +97 -0
- package/dist/provider/backend.d.ts +110 -0
- package/dist/provider/backend.js +37 -0
- package/dist/provider/interface.d.ts +48 -0
- package/dist/provider/interface.js +39 -0
- package/dist/reactive/effect.d.ts +11 -0
- package/dist/reactive/effect.js +42 -0
- package/dist/reactive/index.d.ts +3 -0
- package/dist/reactive/index.js +3 -0
- package/dist/reactive/signal.d.ts +32 -0
- package/dist/reactive/signal.js +60 -0
- package/dist/reactive/tracking.d.ts +41 -0
- package/dist/reactive/tracking.js +161 -0
- package/dist/runtime/fiber.d.ts +21 -0
- package/dist/runtime/fiber.js +16 -0
- package/dist/runtime/index.d.ts +4 -0
- package/dist/runtime/index.js +4 -0
- package/dist/runtime/reconcile.d.ts +66 -0
- package/dist/runtime/reconcile.js +210 -0
- package/dist/runtime/render.d.ts +42 -0
- package/dist/runtime/render.js +231 -0
- package/dist/runtime/run.d.ts +119 -0
- package/dist/runtime/run.js +334 -0
- package/dist/runtime/state-machine.d.ts +95 -0
- package/dist/runtime/state-machine.js +209 -0
- package/dist/types.d.ts +13 -0
- package/dist/types.js +4 -0
- package/package.json +29 -24
- package/dist/cli/commands/BuildCommand.d.ts +0 -40
- package/dist/cli/commands/BuildCommand.js +0 -151
- package/dist/cli/commands/DeployCommand.d.ts +0 -38
- package/dist/cli/commands/DeployCommand.js +0 -194
- package/dist/cli/commands/DevCommand.d.ts +0 -52
- package/dist/cli/commands/DevCommand.js +0 -394
- package/dist/cli/commands/PlanCommand.d.ts +0 -39
- package/dist/cli/commands/PlanCommand.js +0 -164
- package/dist/cli/commands/index.d.ts +0 -36
- package/dist/cli/commands/index.js +0 -43
- package/dist/cli/core/ArgumentParser.d.ts +0 -46
- package/dist/cli/core/ArgumentParser.js +0 -127
- package/dist/cli/core/BaseCommand.d.ts +0 -75
- package/dist/cli/core/BaseCommand.js +0 -95
- package/dist/cli/core/CLIContext.d.ts +0 -68
- package/dist/cli/core/CLIContext.js +0 -183
- package/dist/cli/core/CommandRegistry.d.ts +0 -64
- package/dist/cli/core/CommandRegistry.js +0 -89
- package/dist/cli/core/index.d.ts +0 -36
- package/dist/cli/core/index.js +0 -43
- package/dist/cli/index.d.ts +0 -35
- package/dist/cli/index.js +0 -100
- package/dist/cli/output.d.ts +0 -204
- package/dist/cli/output.js +0 -437
- package/dist/cli/utils.d.ts +0 -59
- package/dist/cli/utils.js +0 -76
- package/dist/context/createContext.d.ts +0 -90
- package/dist/context/createContext.js +0 -113
- package/dist/context/index.d.ts +0 -30
- package/dist/context/index.js +0 -35
- package/dist/core/CReact.d.ts +0 -409
- package/dist/core/CReact.js +0 -1151
- package/dist/core/CloudDOMBuilder.d.ts +0 -447
- package/dist/core/CloudDOMBuilder.js +0 -1234
- package/dist/core/ContextDependencyTracker.d.ts +0 -165
- package/dist/core/ContextDependencyTracker.js +0 -448
- package/dist/core/ErrorRecoveryManager.d.ts +0 -145
- package/dist/core/ErrorRecoveryManager.js +0 -443
- package/dist/core/EventBus.d.ts +0 -91
- package/dist/core/EventBus.js +0 -185
- package/dist/core/ProviderOutputTracker.d.ts +0 -211
- package/dist/core/ProviderOutputTracker.js +0 -476
- package/dist/core/ReactiveUpdateQueue.d.ts +0 -76
- package/dist/core/ReactiveUpdateQueue.js +0 -121
- package/dist/core/Reconciler.d.ts +0 -415
- package/dist/core/Reconciler.js +0 -1044
- package/dist/core/RenderScheduler.d.ts +0 -153
- package/dist/core/RenderScheduler.js +0 -519
- package/dist/core/Renderer.d.ts +0 -336
- package/dist/core/Renderer.js +0 -944
- package/dist/core/Runtime.d.ts +0 -246
- package/dist/core/Runtime.js +0 -640
- package/dist/core/StateBindingManager.d.ts +0 -121
- package/dist/core/StateBindingManager.js +0 -309
- package/dist/core/StateMachine.d.ts +0 -441
- package/dist/core/StateMachine.js +0 -883
- package/dist/core/StructuralChangeDetector.d.ts +0 -140
- package/dist/core/StructuralChangeDetector.js +0 -363
- package/dist/core/Validator.d.ts +0 -127
- package/dist/core/Validator.js +0 -279
- package/dist/core/errors.d.ts +0 -153
- package/dist/core/errors.js +0 -202
- package/dist/core/index.d.ts +0 -38
- package/dist/core/index.js +0 -64
- package/dist/core/types.d.ts +0 -265
- package/dist/core/types.js +0 -48
- package/dist/hooks/context.d.ts +0 -147
- package/dist/hooks/context.js +0 -334
- package/dist/hooks/useContext.d.ts +0 -113
- package/dist/hooks/useContext.js +0 -169
- package/dist/hooks/useEffect.d.ts +0 -105
- package/dist/hooks/useEffect.js +0 -540
- package/dist/hooks/useInstance.d.ts +0 -139
- package/dist/hooks/useInstance.js +0 -455
- package/dist/hooks/useState.d.ts +0 -120
- package/dist/hooks/useState.js +0 -298
- package/dist/jsx.d.ts +0 -143
- package/dist/jsx.js +0 -76
- package/dist/providers/DummyBackendProvider.d.ts +0 -193
- package/dist/providers/DummyBackendProvider.js +0 -189
- package/dist/providers/DummyCloudProvider.d.ts +0 -128
- package/dist/providers/DummyCloudProvider.js +0 -157
- package/dist/providers/IBackendProvider.d.ts +0 -177
- package/dist/providers/IBackendProvider.js +0 -31
- package/dist/providers/ICloudProvider.d.ts +0 -230
- package/dist/providers/ICloudProvider.js +0 -31
- package/dist/providers/index.d.ts +0 -31
- package/dist/providers/index.js +0 -31
- package/dist/test-event-callbacks.d.ts +0 -0
- package/dist/test-event-callbacks.js +0 -1
- package/dist/utils/Logger.d.ts +0 -144
- package/dist/utils/Logger.js +0 -220
- package/dist/utils/Output.d.ts +0 -161
- package/dist/utils/Output.js +0 -401
- package/dist/utils/deepEqual.d.ts +0 -71
- package/dist/utils/deepEqual.js +0 -276
- package/dist/utils/naming.d.ts +0 -241
- package/dist/utils/naming.js +0 -376
package/dist/utils/deepEqual.js
DELETED
|
@@ -1,276 +0,0 @@
|
|
|
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.deepEqual = deepEqual;
|
|
33
|
-
exports.clearEqualityCache = clearEqualityCache;
|
|
34
|
-
exports.getEqualityCacheStats = getEqualityCacheStats;
|
|
35
|
-
// Utility for deep equality comparison
|
|
36
|
-
// Used by Reconciler for prop diffing and StateMachine for checkpoint diffs
|
|
37
|
-
/**
|
|
38
|
-
* Cache for memoizing deep equality comparisons
|
|
39
|
-
* Key format: `${hashA}::${hashB}` (using content hashes for performance)
|
|
40
|
-
*/
|
|
41
|
-
const equalityCache = new Map();
|
|
42
|
-
/**
|
|
43
|
-
* Cache for object hashes to avoid repeated JSON.stringify calls
|
|
44
|
-
* Uses WeakMap for automatic garbage collection
|
|
45
|
-
*/
|
|
46
|
-
const hashCache = new WeakMap();
|
|
47
|
-
/**
|
|
48
|
-
* Cache for primitive hashes (strings, numbers, etc.)
|
|
49
|
-
* Uses regular Map with size limit since primitives aren't garbage collected
|
|
50
|
-
*/
|
|
51
|
-
const primitiveHashCache = new Map();
|
|
52
|
-
/**
|
|
53
|
-
* Cache hit/miss statistics for performance profiling
|
|
54
|
-
*/
|
|
55
|
-
let cacheHits = 0;
|
|
56
|
-
let cacheMisses = 0;
|
|
57
|
-
/**
|
|
58
|
-
* Maximum cache size to prevent memory leaks
|
|
59
|
-
*/
|
|
60
|
-
const MAX_CACHE_SIZE = 1000;
|
|
61
|
-
const MAX_PRIMITIVE_CACHE_SIZE = 500;
|
|
62
|
-
/**
|
|
63
|
-
* Compute a fast hash of a value for cache keys
|
|
64
|
-
*
|
|
65
|
-
* Uses WeakMap to cache hashes per object reference.
|
|
66
|
-
* Uses regular Map with size limit for primitives.
|
|
67
|
-
*
|
|
68
|
-
* @param value - Value to hash
|
|
69
|
-
* @returns Hash string
|
|
70
|
-
*/
|
|
71
|
-
function fastHash(value) {
|
|
72
|
-
// Primitives: use string representation with caching
|
|
73
|
-
if (value === null || value === undefined) {
|
|
74
|
-
return String(value);
|
|
75
|
-
}
|
|
76
|
-
if (typeof value !== 'object') {
|
|
77
|
-
const primitiveKey = `${typeof value}:${String(value)}`;
|
|
78
|
-
// Check primitive cache
|
|
79
|
-
if (primitiveHashCache.has(primitiveKey)) {
|
|
80
|
-
return primitiveHashCache.get(primitiveKey);
|
|
81
|
-
}
|
|
82
|
-
// Store in primitive cache (with size limit)
|
|
83
|
-
if (primitiveHashCache.size >= MAX_PRIMITIVE_CACHE_SIZE) {
|
|
84
|
-
// Clear oldest entry (simple FIFO)
|
|
85
|
-
const firstKey = primitiveHashCache.keys().next().value;
|
|
86
|
-
if (firstKey !== undefined) {
|
|
87
|
-
primitiveHashCache.delete(firstKey);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
primitiveHashCache.set(primitiveKey, primitiveKey);
|
|
91
|
-
return primitiveKey;
|
|
92
|
-
}
|
|
93
|
-
// Objects: use WeakMap cache
|
|
94
|
-
if (hashCache.has(value)) {
|
|
95
|
-
return hashCache.get(value);
|
|
96
|
-
}
|
|
97
|
-
// Compute hash (simple but fast)
|
|
98
|
-
try {
|
|
99
|
-
const hash = JSON.stringify(value);
|
|
100
|
-
hashCache.set(value, hash);
|
|
101
|
-
return hash;
|
|
102
|
-
}
|
|
103
|
-
catch {
|
|
104
|
-
// Circular reference or non-serializable - use object identity
|
|
105
|
-
const hash = `obj:${Math.random()}`;
|
|
106
|
-
hashCache.set(value, hash);
|
|
107
|
-
return hash;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Deep equality comparison with memoization
|
|
112
|
-
*
|
|
113
|
-
* Compares two values deeply, handling:
|
|
114
|
-
* - Primitives (string, number, boolean, null, undefined)
|
|
115
|
-
* - Arrays (order matters)
|
|
116
|
-
* - Objects (key order doesn't matter)
|
|
117
|
-
* - Nested structures
|
|
118
|
-
*
|
|
119
|
-
* Memoizes results for performance on large graphs.
|
|
120
|
-
*
|
|
121
|
-
* Note: Does not handle:
|
|
122
|
-
* - Functions (always considered unequal)
|
|
123
|
-
* - Symbols (always considered unequal)
|
|
124
|
-
* - Circular references (will throw)
|
|
125
|
-
* - Special objects (Date, RegExp, Map, Set) - uses JSON serialization
|
|
126
|
-
*
|
|
127
|
-
* @param a - First value
|
|
128
|
-
* @param b - Second value
|
|
129
|
-
* @param useMemoization - Enable memoization (default: true)
|
|
130
|
-
* @returns True if values are deeply equal
|
|
131
|
-
*/
|
|
132
|
-
function deepEqual(a, b, useMemoization = true) {
|
|
133
|
-
// Fast path: reference equality
|
|
134
|
-
if (a === b) {
|
|
135
|
-
return true;
|
|
136
|
-
}
|
|
137
|
-
// Fast path: type mismatch
|
|
138
|
-
if (typeof a !== typeof b) {
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
// Fast path: null/undefined
|
|
142
|
-
if (a === null || b === null || a === undefined || b === undefined) {
|
|
143
|
-
return a === b;
|
|
144
|
-
}
|
|
145
|
-
// Check memoization cache
|
|
146
|
-
if (useMemoization) {
|
|
147
|
-
try {
|
|
148
|
-
const hashA = fastHash(a);
|
|
149
|
-
const hashB = fastHash(b);
|
|
150
|
-
const cacheKey = `${hashA}::${hashB}`;
|
|
151
|
-
if (equalityCache.has(cacheKey)) {
|
|
152
|
-
cacheHits++;
|
|
153
|
-
return equalityCache.get(cacheKey);
|
|
154
|
-
}
|
|
155
|
-
cacheMisses++;
|
|
156
|
-
// Compute equality
|
|
157
|
-
const result = deepEqualImpl(a, b);
|
|
158
|
-
// Store in cache (with size limit)
|
|
159
|
-
if (equalityCache.size >= MAX_CACHE_SIZE) {
|
|
160
|
-
// Clear oldest entries (simple FIFO)
|
|
161
|
-
const firstKey = equalityCache.keys().next().value;
|
|
162
|
-
if (firstKey !== undefined) {
|
|
163
|
-
equalityCache.delete(firstKey);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
equalityCache.set(cacheKey, result);
|
|
167
|
-
return result;
|
|
168
|
-
}
|
|
169
|
-
catch {
|
|
170
|
-
// If hashing fails, fall back to non-memoized
|
|
171
|
-
cacheMisses++;
|
|
172
|
-
return deepEqualImpl(a, b);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
return deepEqualImpl(a, b);
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Internal implementation of deep equality (without memoization)
|
|
179
|
-
*
|
|
180
|
-
* Optimized for performance:
|
|
181
|
-
* - Short-circuits on primitives
|
|
182
|
-
* - Fast path for common types
|
|
183
|
-
* - Avoids redundant checks
|
|
184
|
-
* - Handles circular references using WeakMap
|
|
185
|
-
*
|
|
186
|
-
* @param a - First value
|
|
187
|
-
* @param b - Second value
|
|
188
|
-
* @param visited - WeakMap tracking visited pairs to handle circular refs
|
|
189
|
-
* @returns True if values are deeply equal
|
|
190
|
-
*/
|
|
191
|
-
function deepEqualImpl(a, b, visited = new WeakMap()) {
|
|
192
|
-
// Fast path: primitives and null/undefined
|
|
193
|
-
const typeA = typeof a;
|
|
194
|
-
const typeB = typeof b;
|
|
195
|
-
if (typeA !== 'object' || typeB !== 'object') {
|
|
196
|
-
return a === b;
|
|
197
|
-
}
|
|
198
|
-
if (a === null || b === null) {
|
|
199
|
-
return a === b;
|
|
200
|
-
}
|
|
201
|
-
// Fast path: same reference
|
|
202
|
-
if (a === b) {
|
|
203
|
-
return true;
|
|
204
|
-
}
|
|
205
|
-
// Circular reference detection
|
|
206
|
-
if (visited.has(a)) {
|
|
207
|
-
return visited.get(a) === b;
|
|
208
|
-
}
|
|
209
|
-
visited.set(a, b);
|
|
210
|
-
// Arrays
|
|
211
|
-
if (Array.isArray(a)) {
|
|
212
|
-
if (!Array.isArray(b)) {
|
|
213
|
-
return false;
|
|
214
|
-
}
|
|
215
|
-
if (a.length !== b.length) {
|
|
216
|
-
return false;
|
|
217
|
-
}
|
|
218
|
-
for (let i = 0; i < a.length; i++) {
|
|
219
|
-
if (!deepEqualImpl(a[i], b[i], visited)) {
|
|
220
|
-
return false;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
return true;
|
|
224
|
-
}
|
|
225
|
-
// Array vs non-array
|
|
226
|
-
if (Array.isArray(b)) {
|
|
227
|
-
return false;
|
|
228
|
-
}
|
|
229
|
-
// Objects
|
|
230
|
-
const keysA = Object.keys(a);
|
|
231
|
-
const keysB = Object.keys(b);
|
|
232
|
-
if (keysA.length !== keysB.length) {
|
|
233
|
-
return false;
|
|
234
|
-
}
|
|
235
|
-
// Convert keysB to Set for O(1) lookup
|
|
236
|
-
const keysBSet = new Set(keysB);
|
|
237
|
-
// Check all keys exist and values are equal
|
|
238
|
-
for (const key of keysA) {
|
|
239
|
-
if (!keysBSet.has(key)) {
|
|
240
|
-
return false;
|
|
241
|
-
}
|
|
242
|
-
if (!deepEqualImpl(a[key], b[key], visited)) {
|
|
243
|
-
return false;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
return true;
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Clear the memoization caches
|
|
250
|
-
*
|
|
251
|
-
* Useful for testing or when memory usage is a concern.
|
|
252
|
-
*/
|
|
253
|
-
function clearEqualityCache() {
|
|
254
|
-
equalityCache.clear();
|
|
255
|
-
primitiveHashCache.clear();
|
|
256
|
-
cacheHits = 0;
|
|
257
|
-
cacheMisses = 0;
|
|
258
|
-
// Note: hashCache (WeakMap) is automatically garbage collected
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Get cache statistics for monitoring and performance profiling
|
|
262
|
-
*
|
|
263
|
-
* @returns Cache size, hit rate, and performance metrics
|
|
264
|
-
*/
|
|
265
|
-
function getEqualityCacheStats() {
|
|
266
|
-
const total = cacheHits + cacheMisses;
|
|
267
|
-
const hitRate = total > 0 ? cacheHits / total : 0;
|
|
268
|
-
return {
|
|
269
|
-
size: equalityCache.size,
|
|
270
|
-
maxSize: MAX_CACHE_SIZE,
|
|
271
|
-
hits: cacheHits,
|
|
272
|
-
misses: cacheMisses,
|
|
273
|
-
hitRate,
|
|
274
|
-
primitiveSize: primitiveHashCache.size,
|
|
275
|
-
};
|
|
276
|
-
}
|
package/dist/utils/naming.d.ts
DELETED
|
@@ -1,241 +0,0 @@
|
|
|
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
|
-
* Generate a resource ID from a Fiber path
|
|
32
|
-
*
|
|
33
|
-
* Converts a hierarchical path array into a dot-separated resource ID.
|
|
34
|
-
* Each path segment is converted to kebab-case for consistency.
|
|
35
|
-
*
|
|
36
|
-
* Examples:
|
|
37
|
-
* - ['registry', 'service'] → 'registry.service'
|
|
38
|
-
* - ['Registry', 'ServiceAPI'] → 'registry.service-api'
|
|
39
|
-
* - ['my-app', 'database'] → 'my-app.database'
|
|
40
|
-
*
|
|
41
|
-
* REQ-01: Resource ID generation from component hierarchy
|
|
42
|
-
*
|
|
43
|
-
* @param path - Hierarchical path segments
|
|
44
|
-
* @returns Dot-separated resource ID
|
|
45
|
-
*/
|
|
46
|
-
export declare function generateResourceId(path: string[]): string;
|
|
47
|
-
/**
|
|
48
|
-
* Convert a string to kebab-case
|
|
49
|
-
*
|
|
50
|
-
* Handles various input formats:
|
|
51
|
-
* - PascalCase: 'RegistryStack' → 'registry-stack'
|
|
52
|
-
* - camelCase: 'serviceAPI' → 'service-api'
|
|
53
|
-
* - snake_case: 'my_service' → 'my-service'
|
|
54
|
-
* - spaces: 'My Service' → 'my-service'
|
|
55
|
-
* - Already kebab: 'my-service' → 'my-service'
|
|
56
|
-
*
|
|
57
|
-
* REQ-01: Kebab-case formatting for multi-word names
|
|
58
|
-
*
|
|
59
|
-
* @param str - String to convert
|
|
60
|
-
* @returns Kebab-case string
|
|
61
|
-
*/
|
|
62
|
-
export declare function toKebabCase(str: string): string;
|
|
63
|
-
/**
|
|
64
|
-
* Generate a node name from component type and key
|
|
65
|
-
*
|
|
66
|
-
* Priority order:
|
|
67
|
-
* 1. Custom key prop (highest priority, for identity)
|
|
68
|
-
* 2. Component function name or displayName
|
|
69
|
-
* 3. Type string (for intrinsic elements)
|
|
70
|
-
* 4. 'anonymous' (fallback)
|
|
71
|
-
* 5. Append siblingIndex if > 0 (for automatic position-based keys)
|
|
72
|
-
*
|
|
73
|
-
* Note: The props parameter is kept for future extensibility and for passing
|
|
74
|
-
* to child components during execution, but props are NOT used for node identity.
|
|
75
|
-
* Only the 'key' prop determines identity.
|
|
76
|
-
*
|
|
77
|
-
* REQ-01: Support custom keys via key prop
|
|
78
|
-
* REQ-6.9: Only key prop is used for identity, not name prop
|
|
79
|
-
* REQ-6.2: Automatic position-based keys for static JSX siblings
|
|
80
|
-
*
|
|
81
|
-
* @param type - Component type (function, class, or string)
|
|
82
|
-
* @param props - Component props (for component execution, not identity)
|
|
83
|
-
* @param key - Optional key prop (for identity)
|
|
84
|
-
* @param siblingIndex - Optional sibling index for automatic key generation
|
|
85
|
-
* @returns Node name in kebab-case
|
|
86
|
-
*/
|
|
87
|
-
export declare function getNodeName(type: any, props?: Record<string, any>, key?: string | number, siblingIndex?: number): string;
|
|
88
|
-
/**
|
|
89
|
-
* Validate resource ID uniqueness within a scope
|
|
90
|
-
*
|
|
91
|
-
* Checks if a resource ID already exists in the given set.
|
|
92
|
-
* Throws an error if duplicate is found.
|
|
93
|
-
*
|
|
94
|
-
* REQ-01: Ensure IDs are unique within scope
|
|
95
|
-
*
|
|
96
|
-
* @param id - Resource ID to validate
|
|
97
|
-
* @param existingIds - Set of existing IDs in scope
|
|
98
|
-
* @param componentStack - Component stack for error reporting
|
|
99
|
-
* @throws Error if ID is not unique
|
|
100
|
-
*/
|
|
101
|
-
export declare function validateIdUniqueness(id: string, existingIds: Set<string>, componentStack?: string[]): void;
|
|
102
|
-
/**
|
|
103
|
-
* Normalize a path segment for consistent resource addressing
|
|
104
|
-
*
|
|
105
|
-
* Applies full kebab-case conversion for consistency:
|
|
106
|
-
* - Converts PascalCase/camelCase to kebab-case
|
|
107
|
-
* - Handles underscores, spaces, numbers
|
|
108
|
-
* - Trims whitespace
|
|
109
|
-
* - Removes leading/trailing hyphens
|
|
110
|
-
*
|
|
111
|
-
* @param segment - Path segment to normalize
|
|
112
|
-
* @returns Normalized segment in kebab-case
|
|
113
|
-
*/
|
|
114
|
-
export declare function normalizePathSegment(segment: string): string;
|
|
115
|
-
/**
|
|
116
|
-
* Normalize an entire path for consistent resource addressing
|
|
117
|
-
*
|
|
118
|
-
* Converts all path segments to kebab-case for consistency.
|
|
119
|
-
*
|
|
120
|
-
* @param path - Path segments to normalize
|
|
121
|
-
* @returns Normalized path segments in kebab-case
|
|
122
|
-
*/
|
|
123
|
-
export declare function normalizePath(path: string[]): string[];
|
|
124
|
-
/**
|
|
125
|
-
* Format a path for human-readable display
|
|
126
|
-
*
|
|
127
|
-
* Examples:
|
|
128
|
-
* - ['registry', 'service'] → 'registry > service'
|
|
129
|
-
* - ['app', 'database', 'table'] → 'app > database > table'
|
|
130
|
-
*
|
|
131
|
-
* @param path - Path segments
|
|
132
|
-
* @returns Formatted path string
|
|
133
|
-
*/
|
|
134
|
-
export declare function formatPath(path: string[]): string;
|
|
135
|
-
/**
|
|
136
|
-
* Parse a resource ID back into path segments
|
|
137
|
-
*
|
|
138
|
-
* Inverse of generateResourceId.
|
|
139
|
-
*
|
|
140
|
-
* Examples:
|
|
141
|
-
* - 'registry.service' → ['registry', 'service']
|
|
142
|
-
* - 'app.database.table' → ['app', 'database', 'table']
|
|
143
|
-
*
|
|
144
|
-
* @param id - Resource ID
|
|
145
|
-
* @returns Path segments
|
|
146
|
-
*/
|
|
147
|
-
export declare function parseResourceId(id: string): string[];
|
|
148
|
-
/**
|
|
149
|
-
* Generate a binding key for state-output binding tracking
|
|
150
|
-
*
|
|
151
|
-
* Creates a consistent key format for tracking bindings between
|
|
152
|
-
* component state and provider outputs.
|
|
153
|
-
*
|
|
154
|
-
* Examples:
|
|
155
|
-
* - ('registry.service', 'url') → 'registry.service.url'
|
|
156
|
-
* - ('app.database', 'connectionString') → 'app.database.connection-string'
|
|
157
|
-
*
|
|
158
|
-
* @param nodeId - CloudDOM node ID
|
|
159
|
-
* @param outputKey - Output key name
|
|
160
|
-
* @returns Binding key
|
|
161
|
-
*/
|
|
162
|
-
export declare function generateBindingKey(nodeId: string, outputKey: string): string;
|
|
163
|
-
/**
|
|
164
|
-
* Parse a binding key back into nodeId and outputKey
|
|
165
|
-
*
|
|
166
|
-
* Inverse of generateBindingKey.
|
|
167
|
-
*
|
|
168
|
-
* Examples:
|
|
169
|
-
* - 'registry.service.url' → { nodeId: 'registry.service', outputKey: 'url' }
|
|
170
|
-
* - 'app.database.connection-string' → { nodeId: 'app.database', outputKey: 'connection-string' }
|
|
171
|
-
*
|
|
172
|
-
* @param bindingKey - Binding key
|
|
173
|
-
* @returns Object with nodeId and outputKey
|
|
174
|
-
*/
|
|
175
|
-
export declare function parseBindingKey(bindingKey: string): {
|
|
176
|
-
nodeId: string;
|
|
177
|
-
outputKey: string;
|
|
178
|
-
};
|
|
179
|
-
/**
|
|
180
|
-
* Generate a state output key for useState hooks
|
|
181
|
-
*
|
|
182
|
-
* REQ-3.1: Generate state keys without prefix (stored in separate state field)
|
|
183
|
-
*
|
|
184
|
-
* Creates a key for useState outputs. Uses 1-based indexing for consistency.
|
|
185
|
-
* State values are stored in the separate `state` field on CloudDOMNode,
|
|
186
|
-
* not in the `outputs` field, so no prefix is needed.
|
|
187
|
-
*
|
|
188
|
-
* Examples:
|
|
189
|
-
* - generateStateOutputKey(0) → 'state1'
|
|
190
|
-
* - generateStateOutputKey(1) → 'state2'
|
|
191
|
-
* - generateStateOutputKey(2) → 'state3'
|
|
192
|
-
*
|
|
193
|
-
* @param hookIndex - Zero-based hook index
|
|
194
|
-
* @returns State output key without prefix
|
|
195
|
-
*/
|
|
196
|
-
export declare function generateStateOutputKey(hookIndex: number): string;
|
|
197
|
-
/**
|
|
198
|
-
* Check if an output key is a state output (matches state key format)
|
|
199
|
-
*
|
|
200
|
-
* REQ-3.1: Identify useState outputs by their key format (state1, state2, etc.)
|
|
201
|
-
*
|
|
202
|
-
* Examples:
|
|
203
|
-
* - isStateOutputKey('state1') → true
|
|
204
|
-
* - isStateOutputKey('state2') → true
|
|
205
|
-
* - isStateOutputKey('connectionUrl') → false
|
|
206
|
-
* - isStateOutputKey('vaultUrl') → false
|
|
207
|
-
*
|
|
208
|
-
* @param outputKey - Output key to check
|
|
209
|
-
* @returns True if the key is a state output
|
|
210
|
-
*/
|
|
211
|
-
export declare function isStateOutputKey(outputKey: string): boolean;
|
|
212
|
-
/**
|
|
213
|
-
* Check if an output key is a provider output (not a state key)
|
|
214
|
-
*
|
|
215
|
-
* REQ-3.1: Identify provider outputs by absence of state key format
|
|
216
|
-
*
|
|
217
|
-
* Examples:
|
|
218
|
-
* - isProviderOutputKey('connectionUrl') → true
|
|
219
|
-
* - isProviderOutputKey('vaultUrl') → true
|
|
220
|
-
* - isProviderOutputKey('state1') → false
|
|
221
|
-
* - isProviderOutputKey('state2') → false
|
|
222
|
-
*
|
|
223
|
-
* @param outputKey - Output key to check
|
|
224
|
-
* @returns True if the key is a provider output
|
|
225
|
-
*/
|
|
226
|
-
export declare function isProviderOutputKey(outputKey: string): boolean;
|
|
227
|
-
/**
|
|
228
|
-
* Parse a state output key to extract the hook index
|
|
229
|
-
*
|
|
230
|
-
* Inverse of generateStateOutputKey.
|
|
231
|
-
*
|
|
232
|
-
* Examples:
|
|
233
|
-
* - parseStateOutputKey('state1') → 0
|
|
234
|
-
* - parseStateOutputKey('state2') → 1
|
|
235
|
-
* - parseStateOutputKey('state3') → 2
|
|
236
|
-
*
|
|
237
|
-
* @param stateOutputKey - State output key
|
|
238
|
-
* @returns Zero-based hook index
|
|
239
|
-
* @throws Error if the key is not a valid state output key
|
|
240
|
-
*/
|
|
241
|
-
export declare function parseStateOutputKey(stateOutputKey: string): number;
|