fractostate 1.0.0 → 1.0.2
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/dist/cjs/index.js +2 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/src/index.js +66 -0
- package/dist/cjs/src/index.js.map +1 -0
- package/dist/cjs/src/proxy.js +289 -0
- package/dist/cjs/src/proxy.js.map +1 -0
- package/dist/cjs/src/store.js +373 -0
- package/dist/cjs/src/store.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/src/index.js +63 -0
- package/dist/esm/src/index.js.map +1 -0
- package/dist/esm/src/proxy.js +286 -0
- package/dist/esm/src/proxy.js.map +1 -0
- package/dist/esm/src/store.js +371 -0
- package/dist/esm/src/store.js.map +1 -0
- package/dist/index.d.ts +124 -0
- package/package.json +49 -9
- package/docs/api-reference.md +0 -46
- package/docs/architecture.md +0 -27
- package/docs/getting-started.md +0 -94
- package/src/index.ts +0 -82
- package/src/proxy.ts +0 -313
- package/src/store.ts +0 -324
- package/src/types.ts +0 -126
- package/test/README.md +0 -73
- package/test/eslint.config.js +0 -23
- package/test/index.html +0 -13
- package/test/package.json +0 -47
- package/test/postcss.config.mjs +0 -7
- package/test/public/vite.svg +0 -1
- package/test/src/App.css +0 -42
- package/test/src/App.tsx +0 -44
- package/test/src/assets/react.svg +0 -1
- package/test/src/components/CartDrawer.tsx +0 -79
- package/test/src/components/Navbar.tsx +0 -48
- package/test/src/components/Notifications.tsx +0 -27
- package/test/src/components/ProductList.tsx +0 -56
- package/test/src/flows.ts +0 -7
- package/test/src/index.css +0 -33
- package/test/src/layout/Layout.tsx +0 -68
- package/test/src/layout/ProtectedRoute.tsx +0 -19
- package/test/src/main.tsx +0 -10
- package/test/src/pages/LoginPage.tsx +0 -86
- package/test/src/pages/ProfilePage.tsx +0 -48
- package/test/src/pages/ShopPage.tsx +0 -54
- package/test/src/store/auth.ts +0 -39
- package/test/src/store/flows.ts +0 -74
- package/test/tsconfig.app.json +0 -31
- package/test/tsconfig.json +0 -7
- package/test/tsconfig.node.json +0 -29
- package/test/vite.config.ts +0 -16
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { store } from './store.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a deep proxy that provides type-specific atomic operations for a flow.
|
|
5
|
+
* The proxy tracks its path within the state tree and maps access to specific update logic.
|
|
6
|
+
*/
|
|
7
|
+
function createDeepProxy(key, path, currentVal, options) {
|
|
8
|
+
return new Proxy(() => { }, {
|
|
9
|
+
get(_target, prop) {
|
|
10
|
+
if (typeof prop === "symbol")
|
|
11
|
+
return undefined;
|
|
12
|
+
const newPath = [...path, prop];
|
|
13
|
+
// --- Meta-Operations ---
|
|
14
|
+
// Generic property replacement
|
|
15
|
+
if (prop === "set") {
|
|
16
|
+
return (val) => {
|
|
17
|
+
try {
|
|
18
|
+
const currentState = store.get(key, undefined);
|
|
19
|
+
const newState = setInPath(currentState, path, val);
|
|
20
|
+
store.set(key, newState, options);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
console.error(`[FlowProxy] Error setting value at path ${path.join(".")}:`, error);
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
// --- Type-Specific Atomic Operations ---
|
|
29
|
+
// Number Operations
|
|
30
|
+
if (typeof currentVal === "number") {
|
|
31
|
+
if (prop === "increment")
|
|
32
|
+
return (amount = 1) => {
|
|
33
|
+
if (typeof amount !== "number" || !isFinite(amount)) {
|
|
34
|
+
console.warn(`[FlowProxy] Invalid increment amount: ${amount}`);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
update(currentVal + amount);
|
|
38
|
+
};
|
|
39
|
+
if (prop === "decrement")
|
|
40
|
+
return (amount = 1) => {
|
|
41
|
+
if (typeof amount !== "number" || !isFinite(amount)) {
|
|
42
|
+
console.warn(`[FlowProxy] Invalid decrement amount: ${amount}`);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
update(currentVal - amount);
|
|
46
|
+
};
|
|
47
|
+
if (prop === "add")
|
|
48
|
+
return (amount) => {
|
|
49
|
+
if (typeof amount !== "number" || !isFinite(amount)) {
|
|
50
|
+
console.warn(`[FlowProxy] Invalid add amount: ${amount}`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
update(currentVal + amount);
|
|
54
|
+
};
|
|
55
|
+
if (prop === "subtract")
|
|
56
|
+
return (amount) => {
|
|
57
|
+
if (typeof amount !== "number" || !isFinite(amount)) {
|
|
58
|
+
console.warn(`[FlowProxy] Invalid subtract amount: ${amount}`);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
update(currentVal - amount);
|
|
62
|
+
};
|
|
63
|
+
if (prop === "multiply")
|
|
64
|
+
return (amount) => {
|
|
65
|
+
if (typeof amount !== "number" || !isFinite(amount)) {
|
|
66
|
+
console.warn(`[FlowProxy] Invalid multiply amount: ${amount}`);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
update(currentVal * amount);
|
|
70
|
+
};
|
|
71
|
+
if (prop === "divide")
|
|
72
|
+
return (amount) => {
|
|
73
|
+
if (typeof amount !== "number" || !isFinite(amount)) {
|
|
74
|
+
console.warn(`[FlowProxy] Invalid divide amount: ${amount}`);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (amount === 0) {
|
|
78
|
+
console.error(`[FlowProxy] Cannot divide by zero`);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
update(currentVal / amount);
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
// Array Operations
|
|
85
|
+
if (Array.isArray(currentVal)) {
|
|
86
|
+
if (prop === "push")
|
|
87
|
+
return (item) => update([...currentVal, item]);
|
|
88
|
+
if (prop === "pop")
|
|
89
|
+
return () => {
|
|
90
|
+
if (currentVal.length === 0) {
|
|
91
|
+
console.warn(`[FlowProxy] Cannot pop from empty array`);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
update(currentVal.slice(0, -1));
|
|
95
|
+
};
|
|
96
|
+
if (prop === "shift")
|
|
97
|
+
return () => {
|
|
98
|
+
if (currentVal.length === 0) {
|
|
99
|
+
console.warn(`[FlowProxy] Cannot shift from empty array`);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
update(currentVal.slice(1));
|
|
103
|
+
};
|
|
104
|
+
if (prop === "unshift")
|
|
105
|
+
return (item) => update([item, ...currentVal]);
|
|
106
|
+
if (prop === "filter")
|
|
107
|
+
return (fn) => {
|
|
108
|
+
if (typeof fn !== "function") {
|
|
109
|
+
console.error(`[FlowProxy] Filter requires a function`);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
update(currentVal.filter(fn));
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
console.error(`[FlowProxy] Filter function threw error:`, error);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
if (prop === "map")
|
|
120
|
+
return (fn) => {
|
|
121
|
+
if (typeof fn !== "function") {
|
|
122
|
+
console.error(`[FlowProxy] Map requires a function`);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
try {
|
|
126
|
+
update(currentVal.map(fn));
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
console.error(`[FlowProxy] Map function threw error:`, error);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
if (prop === "splice")
|
|
133
|
+
return (...args) => {
|
|
134
|
+
try {
|
|
135
|
+
const next = [...currentVal];
|
|
136
|
+
const start = args[0] ?? 0;
|
|
137
|
+
const deleteCount = args[1] ?? 0;
|
|
138
|
+
if (typeof start !== "number" ||
|
|
139
|
+
typeof deleteCount !== "number") {
|
|
140
|
+
console.error(`[FlowProxy] Splice requires numeric arguments`);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
next.splice(start, deleteCount, ...args.slice(2));
|
|
144
|
+
update(next);
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
console.error(`[FlowProxy] Splice error:`, error);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
if (prop === "removeAt")
|
|
151
|
+
return (index) => {
|
|
152
|
+
if (typeof index !== "number" ||
|
|
153
|
+
index < 0 ||
|
|
154
|
+
index >= currentVal.length) {
|
|
155
|
+
console.warn(`[FlowProxy] Invalid index: ${index}`);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
update(currentVal.filter((_, i) => i !== index));
|
|
159
|
+
};
|
|
160
|
+
if (prop === "insertAt")
|
|
161
|
+
return (index, item) => {
|
|
162
|
+
if (typeof index !== "number" ||
|
|
163
|
+
index < 0 ||
|
|
164
|
+
index > currentVal.length) {
|
|
165
|
+
console.warn(`[FlowProxy] Invalid index: ${index}`);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const next = [...currentVal];
|
|
169
|
+
next.splice(index, 0, item);
|
|
170
|
+
update(next);
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
// String Operations
|
|
174
|
+
if (typeof currentVal === "string") {
|
|
175
|
+
if (prop === "append")
|
|
176
|
+
return (str) => {
|
|
177
|
+
if (typeof str !== "string") {
|
|
178
|
+
console.warn(`[FlowProxy] Append requires a string`);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
update(currentVal + str);
|
|
182
|
+
};
|
|
183
|
+
if (prop === "prepend")
|
|
184
|
+
return (str) => {
|
|
185
|
+
if (typeof str !== "string") {
|
|
186
|
+
console.warn(`[FlowProxy] Prepend requires a string`);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
update(str + currentVal);
|
|
190
|
+
};
|
|
191
|
+
if (prop === "uppercase")
|
|
192
|
+
return () => update(currentVal.toUpperCase());
|
|
193
|
+
if (prop === "lowercase")
|
|
194
|
+
return () => update(currentVal.toLowerCase());
|
|
195
|
+
if (prop === "trim")
|
|
196
|
+
return () => update(currentVal.trim());
|
|
197
|
+
if (prop === "replace")
|
|
198
|
+
return (search, replace) => {
|
|
199
|
+
if (typeof replace !== "string") {
|
|
200
|
+
console.warn(`[FlowProxy] Replace requires a string replacement`);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
update(currentVal.replace(search, replace));
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
console.error(`[FlowProxy] Replace error:`, error);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
// Object Operations
|
|
212
|
+
if (currentVal !== null &&
|
|
213
|
+
typeof currentVal === "object" &&
|
|
214
|
+
!Array.isArray(currentVal)) {
|
|
215
|
+
if (prop === "merge")
|
|
216
|
+
return (obj) => {
|
|
217
|
+
if (typeof obj !== "object" || obj === null || Array.isArray(obj)) {
|
|
218
|
+
console.warn(`[FlowProxy] Merge requires an object`);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
update({ ...currentVal, ...obj });
|
|
222
|
+
};
|
|
223
|
+
if (prop === "delete")
|
|
224
|
+
return (keyToDel) => {
|
|
225
|
+
if (typeof keyToDel !== "string") {
|
|
226
|
+
console.warn(`[FlowProxy] Delete requires a string key`);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if (!(keyToDel in currentVal)) {
|
|
230
|
+
console.warn(`[FlowProxy] Key "${keyToDel}" does not exist`);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const next = { ...currentVal };
|
|
234
|
+
delete next[keyToDel];
|
|
235
|
+
update(next);
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Internal helper to commit a value update to the store.
|
|
240
|
+
*/
|
|
241
|
+
function update(val) {
|
|
242
|
+
try {
|
|
243
|
+
const currentState = store.get(key, undefined);
|
|
244
|
+
const newState = setInPath(currentState, path, val);
|
|
245
|
+
store.set(key, newState, options);
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
console.error(`[FlowProxy] Error updating value at path ${path.join(".")}:`, error);
|
|
249
|
+
throw error;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
// Recursive step: create a new proxy for the child property
|
|
253
|
+
const nextVal = currentVal ? currentVal[prop] : undefined;
|
|
254
|
+
return createDeepProxy(key, newPath, nextVal, options);
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Immutable update utility that sets a value at a specific path within an object/array.
|
|
260
|
+
*/
|
|
261
|
+
function setInPath(obj, path, value) {
|
|
262
|
+
if (path.length === 0)
|
|
263
|
+
return value;
|
|
264
|
+
const [head, ...tail] = path;
|
|
265
|
+
if (Array.isArray(obj)) {
|
|
266
|
+
const index = parseInt(head, 10);
|
|
267
|
+
if (isNaN(index) || index < 0) {
|
|
268
|
+
throw new Error(`[FlowProxy] Invalid array index: ${head}`);
|
|
269
|
+
}
|
|
270
|
+
const newArr = [...obj];
|
|
271
|
+
if (index >= newArr.length) {
|
|
272
|
+
newArr.length = index + 1;
|
|
273
|
+
}
|
|
274
|
+
newArr[index] = setInPath(newArr[index], tail, value);
|
|
275
|
+
return newArr;
|
|
276
|
+
}
|
|
277
|
+
// Handle nested objects (including null/undefined recovery)
|
|
278
|
+
const currentObj = obj ?? {};
|
|
279
|
+
return {
|
|
280
|
+
...currentObj,
|
|
281
|
+
[head]: setInPath(currentObj[head], tail, value),
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export { createDeepProxy, setInPath };
|
|
286
|
+
//# sourceMappingURL=proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.js","sources":["../../../src/proxy.ts"],"sourcesContent":["import type { FlowOptions, TypeAwareOps } from \"./types\";\nimport { store } from \"./store\";\n\n/**\n * Creates a deep proxy that provides type-specific atomic operations for a flow.\n * The proxy tracks its path within the state tree and maps access to specific update logic.\n */\nexport function createDeepProxy<T = any>(\n key: string,\n path: string[],\n currentVal: any,\n options: FlowOptions<any>,\n): TypeAwareOps<T> {\n return new Proxy(() => {}, {\n get(_target: any, prop: any) {\n if (typeof prop === \"symbol\") return undefined;\n\n const newPath = [...path, prop];\n\n // --- Meta-Operations ---\n\n // Generic property replacement\n if (prop === \"set\") {\n return (val: any) => {\n try {\n const currentState = store.get(key, undefined);\n const newState = setInPath(currentState, path, val);\n store.set(key, newState, options);\n } catch (error) {\n console.error(\n `[FlowProxy] Error setting value at path ${path.join(\".\")}:`,\n error,\n );\n throw error;\n }\n };\n }\n\n // --- Type-Specific Atomic Operations ---\n\n // Number Operations\n if (typeof currentVal === \"number\") {\n if (prop === \"increment\")\n return (amount = 1) => {\n if (typeof amount !== \"number\" || !isFinite(amount)) {\n console.warn(`[FlowProxy] Invalid increment amount: ${amount}`);\n return;\n }\n update(currentVal + amount);\n };\n if (prop === \"decrement\")\n return (amount = 1) => {\n if (typeof amount !== \"number\" || !isFinite(amount)) {\n console.warn(`[FlowProxy] Invalid decrement amount: ${amount}`);\n return;\n }\n update(currentVal - amount);\n };\n if (prop === \"add\")\n return (amount: number) => {\n if (typeof amount !== \"number\" || !isFinite(amount)) {\n console.warn(`[FlowProxy] Invalid add amount: ${amount}`);\n return;\n }\n update(currentVal + amount);\n };\n if (prop === \"subtract\")\n return (amount: number) => {\n if (typeof amount !== \"number\" || !isFinite(amount)) {\n console.warn(`[FlowProxy] Invalid subtract amount: ${amount}`);\n return;\n }\n update(currentVal - amount);\n };\n if (prop === \"multiply\")\n return (amount: number) => {\n if (typeof amount !== \"number\" || !isFinite(amount)) {\n console.warn(`[FlowProxy] Invalid multiply amount: ${amount}`);\n return;\n }\n update(currentVal * amount);\n };\n if (prop === \"divide\")\n return (amount: number) => {\n if (typeof amount !== \"number\" || !isFinite(amount)) {\n console.warn(`[FlowProxy] Invalid divide amount: ${amount}`);\n return;\n }\n if (amount === 0) {\n console.error(`[FlowProxy] Cannot divide by zero`);\n return;\n }\n update(currentVal / amount);\n };\n }\n\n // Array Operations\n if (Array.isArray(currentVal)) {\n if (prop === \"push\")\n return (item: any) => update([...currentVal, item]);\n if (prop === \"pop\")\n return () => {\n if (currentVal.length === 0) {\n console.warn(`[FlowProxy] Cannot pop from empty array`);\n return;\n }\n update(currentVal.slice(0, -1));\n };\n if (prop === \"shift\")\n return () => {\n if (currentVal.length === 0) {\n console.warn(`[FlowProxy] Cannot shift from empty array`);\n return;\n }\n update(currentVal.slice(1));\n };\n if (prop === \"unshift\")\n return (item: any) => update([item, ...currentVal]);\n if (prop === \"filter\")\n return (fn: any) => {\n if (typeof fn !== \"function\") {\n console.error(`[FlowProxy] Filter requires a function`);\n return;\n }\n try {\n update(currentVal.filter(fn));\n } catch (error) {\n console.error(`[FlowProxy] Filter function threw error:`, error);\n }\n };\n if (prop === \"map\")\n return (fn: any) => {\n if (typeof fn !== \"function\") {\n console.error(`[FlowProxy] Map requires a function`);\n return;\n }\n try {\n update(currentVal.map(fn));\n } catch (error) {\n console.error(`[FlowProxy] Map function threw error:`, error);\n }\n };\n if (prop === \"splice\")\n return (...args: any[]) => {\n try {\n const next = [...currentVal];\n const start = args[0] ?? 0;\n const deleteCount = args[1] ?? 0;\n\n if (\n typeof start !== \"number\" ||\n typeof deleteCount !== \"number\"\n ) {\n console.error(`[FlowProxy] Splice requires numeric arguments`);\n return;\n }\n\n next.splice(start, deleteCount, ...args.slice(2));\n update(next);\n } catch (error) {\n console.error(`[FlowProxy] Splice error:`, error);\n }\n };\n if (prop === \"removeAt\")\n return (index: number) => {\n if (\n typeof index !== \"number\" ||\n index < 0 ||\n index >= currentVal.length\n ) {\n console.warn(`[FlowProxy] Invalid index: ${index}`);\n return;\n }\n update(currentVal.filter((_, i) => i !== index));\n };\n if (prop === \"insertAt\")\n return (index: number, item: any) => {\n if (\n typeof index !== \"number\" ||\n index < 0 ||\n index > currentVal.length\n ) {\n console.warn(`[FlowProxy] Invalid index: ${index}`);\n return;\n }\n const next = [...currentVal];\n next.splice(index, 0, item);\n update(next);\n };\n }\n\n // String Operations\n if (typeof currentVal === \"string\") {\n if (prop === \"append\")\n return (str: string) => {\n if (typeof str !== \"string\") {\n console.warn(`[FlowProxy] Append requires a string`);\n return;\n }\n update(currentVal + str);\n };\n if (prop === \"prepend\")\n return (str: string) => {\n if (typeof str !== \"string\") {\n console.warn(`[FlowProxy] Prepend requires a string`);\n return;\n }\n update(str + currentVal);\n };\n if (prop === \"uppercase\") return () => update(currentVal.toUpperCase());\n if (prop === \"lowercase\") return () => update(currentVal.toLowerCase());\n if (prop === \"trim\") return () => update(currentVal.trim());\n if (prop === \"replace\")\n return (search: string | RegExp, replace: string) => {\n if (typeof replace !== \"string\") {\n console.warn(`[FlowProxy] Replace requires a string replacement`);\n return;\n }\n try {\n update(currentVal.replace(search, replace));\n } catch (error) {\n console.error(`[FlowProxy] Replace error:`, error);\n }\n };\n }\n\n // Object Operations\n if (\n currentVal !== null &&\n typeof currentVal === \"object\" &&\n !Array.isArray(currentVal)\n ) {\n if (prop === \"merge\")\n return (obj: any) => {\n if (typeof obj !== \"object\" || obj === null || Array.isArray(obj)) {\n console.warn(`[FlowProxy] Merge requires an object`);\n return;\n }\n update({ ...currentVal, ...obj });\n };\n if (prop === \"delete\")\n return (keyToDel: string) => {\n if (typeof keyToDel !== \"string\") {\n console.warn(`[FlowProxy] Delete requires a string key`);\n return;\n }\n if (!(keyToDel in currentVal)) {\n console.warn(`[FlowProxy] Key \"${keyToDel}\" does not exist`);\n return;\n }\n const next = { ...currentVal };\n delete next[keyToDel];\n update(next);\n };\n }\n\n /**\n * Internal helper to commit a value update to the store.\n */\n function update(val: any) {\n try {\n const currentState = store.get(key, undefined);\n const newState = setInPath(currentState, path, val);\n store.set(key, newState, options);\n } catch (error) {\n console.error(\n `[FlowProxy] Error updating value at path ${path.join(\".\")}:`,\n error,\n );\n throw error;\n }\n }\n\n // Recursive step: create a new proxy for the child property\n const nextVal = currentVal ? currentVal[prop] : undefined;\n return createDeepProxy(key, newPath, nextVal, options);\n },\n }) as unknown as TypeAwareOps<T>;\n}\n\n/**\n * Immutable update utility that sets a value at a specific path within an object/array.\n */\nexport function setInPath(obj: any, path: string[], value: any): any {\n if (path.length === 0) return value;\n\n const [head, ...tail] = path;\n\n if (Array.isArray(obj)) {\n const index = parseInt(head, 10);\n\n if (isNaN(index) || index < 0) {\n throw new Error(`[FlowProxy] Invalid array index: ${head}`);\n }\n\n const newArr = [...obj];\n\n if (index >= newArr.length) {\n newArr.length = index + 1;\n }\n\n newArr[index] = setInPath(newArr[index], tail, value);\n return newArr;\n }\n\n // Handle nested objects (including null/undefined recovery)\n const currentObj = obj ?? {};\n\n return {\n ...currentObj,\n [head]: setInPath(currentObj[head], tail, value),\n };\n}\n"],"names":[],"mappings":";;AAGA;;;AAGG;AACG,SAAU,eAAe,CAC7B,GAAW,EACX,IAAc,EACd,UAAe,EACf,OAAyB,EAAA;AAEzB,IAAA,OAAO,IAAI,KAAK,CAAC,MAAK,EAAE,CAAC,EAAE;QACzB,GAAG,CAAC,OAAY,EAAE,IAAS,EAAA;YACzB,IAAI,OAAO,IAAI,KAAK,QAAQ;AAAE,gBAAA,OAAO,SAAS;YAE9C,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,EAAE,IAAI,CAAC;;;AAK/B,YAAA,IAAI,IAAI,KAAK,KAAK,EAAE;gBAClB,OAAO,CAAC,GAAQ,KAAI;AAClB,oBAAA,IAAI;wBACF,MAAM,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC;wBAC9C,MAAM,QAAQ,GAAG,SAAS,CAAC,YAAY,EAAE,IAAI,EAAE,GAAG,CAAC;wBACnD,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC;oBACnC;oBAAE,OAAO,KAAK,EAAE;AACd,wBAAA,OAAO,CAAC,KAAK,CACX,CAAA,wCAAA,EAA2C,IAAI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