fractostate 1.0.1 → 2.0.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.
Files changed (52) hide show
  1. package/dist/cjs/index.js +2 -0
  2. package/dist/cjs/package.json +3 -0
  3. package/dist/cjs/src/index.js +135 -0
  4. package/dist/cjs/src/index.js.map +1 -0
  5. package/dist/cjs/src/proxy.js +289 -0
  6. package/dist/cjs/src/proxy.js.map +1 -0
  7. package/dist/cjs/src/store.js +373 -0
  8. package/dist/cjs/src/store.js.map +1 -0
  9. package/dist/esm/index.js +2 -0
  10. package/dist/esm/package.json +3 -0
  11. package/dist/esm/src/index.js +131 -0
  12. package/dist/esm/src/index.js.map +1 -0
  13. package/dist/esm/src/proxy.js +286 -0
  14. package/dist/esm/src/proxy.js.map +1 -0
  15. package/dist/esm/src/store.js +371 -0
  16. package/dist/esm/src/store.js.map +1 -0
  17. package/dist/index.d.ts +170 -0
  18. package/package.json +41 -10
  19. package/docs/api-reference.md +0 -46
  20. package/docs/architecture.md +0 -27
  21. package/docs/getting-started.md +0 -94
  22. package/src/index.ts +0 -82
  23. package/src/proxy.ts +0 -313
  24. package/src/store.ts +0 -324
  25. package/src/types.ts +0 -126
  26. package/test/README.md +0 -73
  27. package/test/eslint.config.js +0 -23
  28. package/test/index.html +0 -13
  29. package/test/package.json +0 -47
  30. package/test/postcss.config.mjs +0 -7
  31. package/test/public/vite.svg +0 -1
  32. package/test/src/App.css +0 -42
  33. package/test/src/App.tsx +0 -44
  34. package/test/src/assets/react.svg +0 -1
  35. package/test/src/components/CartDrawer.tsx +0 -79
  36. package/test/src/components/Navbar.tsx +0 -48
  37. package/test/src/components/Notifications.tsx +0 -27
  38. package/test/src/components/ProductList.tsx +0 -56
  39. package/test/src/flows.ts +0 -7
  40. package/test/src/index.css +0 -33
  41. package/test/src/layout/Layout.tsx +0 -68
  42. package/test/src/layout/ProtectedRoute.tsx +0 -19
  43. package/test/src/main.tsx +0 -10
  44. package/test/src/pages/LoginPage.tsx +0 -86
  45. package/test/src/pages/ProfilePage.tsx +0 -48
  46. package/test/src/pages/ShopPage.tsx +0 -54
  47. package/test/src/store/auth.ts +0 -39
  48. package/test/src/store/flows.ts +0 -74
  49. package/test/tsconfig.app.json +0 -31
  50. package/test/tsconfig.json +0 -7
  51. package/test/tsconfig.node.json +0 -29
  52. package/test/vite.config.ts +0 -16
@@ -0,0 +1,2 @@
1
+ // CommonJS re-export from src directory
2
+ module.exports = require('./src/index.js');
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,135 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var store = require('./store.js');
5
+ var proxy = require('./proxy.js');
6
+
7
+ /***************************************************************************
8
+ * FractoState - Fast And Secure
9
+ *
10
+ * @author Nehonix
11
+ * @license NOSL
12
+ *
13
+ * Copyright (c) 2025 Nehonix. All rights reserved.
14
+ *
15
+ * This License governs the use, modification, and distribution of software
16
+ * provided by NEHONIX under its open source projects.
17
+ * NEHONIX is committed to fostering collaborative innovation while strictly
18
+ * protecting its intellectual property rights.
19
+ * Violation of any term of this License will result in immediate termination of all granted rights
20
+ * and may subject the violator to legal action.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
23
+ * INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
24
+ * AND NON-INFRINGEMENT.
25
+ * IN NO EVENT SHALL NEHONIX BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
+ * OR CONSEQUENTIAL DAMAGES ARISING FROM THE USE OR INABILITY TO USE THE SOFTWARE,
27
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
28
+ *
29
+ ***************************************************************************** */
30
+ /**
31
+ * Defines a derived flow that automatically updates based on a source flow.
32
+ * No store registration happens here; it's purely a definition for the hook.
33
+ */
34
+ function defineDerived(source, selector, derivedKey) {
35
+ return {
36
+ key: derivedKey || `${source.key}_derived_${Date.now()}`,
37
+ source,
38
+ selector,
39
+ };
40
+ }
41
+ /**
42
+ * Defines a flow in a centralized manner.
43
+ * Allows defining the key, initial state, and options in a single reusable object.
44
+ */
45
+ function defineFlow(key, initial, options) {
46
+ // If generic T is provided manually but A is not, we want A to be inferred from options
47
+ // However, explicit generics override inference.
48
+ // The user should ideally use `defineFlow('key', { ...initial }, { actions: ... })`
49
+ // without explicit generics to get full inference.
50
+ // Or provide both. This signature supports both but relies on inference for best DX.
51
+ return { key, initial, options };
52
+ }
53
+ // --- Implementation ---
54
+ function useFlow(keyOrDef, maybeInitialValue, options = {}) {
55
+ // 1. Identify if we are dealing with a Derived Flow
56
+ const isDerived = typeof keyOrDef === "object" &&
57
+ "selector" in keyOrDef &&
58
+ "source" in keyOrDef;
59
+ // --- Logic for DERIVED Flows (Read-Only Reactive) ---
60
+ if (isDerived) {
61
+ const derivedDef = keyOrDef;
62
+ const sourceKey = derivedDef.source.key;
63
+ const selector = derivedDef.selector;
64
+ const getSourceState = () => store.store.get(sourceKey, derivedDef.source.initial);
65
+ // Initial derived state
66
+ const [derivedState, setDerivedState] = react.useState(() => selector(getSourceState()));
67
+ react.useEffect(() => {
68
+ const unsub = store.store.subscribe(sourceKey, () => {
69
+ const nextSource = getSourceState();
70
+ const nextDerived = selector(nextSource);
71
+ setDerivedState((prev) => {
72
+ if (prev === nextDerived)
73
+ return prev;
74
+ return nextDerived;
75
+ });
76
+ });
77
+ return unsub;
78
+ }, [sourceKey, selector]);
79
+ return [derivedState, {}];
80
+ }
81
+ // --- Logic for STANDARD Flows (Read-Write) ---
82
+ const isDef = typeof keyOrDef !== "string";
83
+ const key = isDef
84
+ ? keyOrDef.key
85
+ : keyOrDef;
86
+ const initialValue = isDef
87
+ ? keyOrDef.initial
88
+ : maybeInitialValue;
89
+ const opt = isDef
90
+ ? { ...keyOrDef.options, ...options }
91
+ : options;
92
+ const [state, setState] = react.useState(() => store.store.get(key, initialValue));
93
+ react.useEffect(() => {
94
+ const unsub = store.store.subscribe(key, () => {
95
+ setState(store.store.get(key, initialValue));
96
+ });
97
+ return unsub;
98
+ }, [key, initialValue]);
99
+ const setManual = react.useCallback((val) => {
100
+ const current = store.store.get(key, initialValue);
101
+ const next = typeof val === "function" ? val(current) : val;
102
+ store.store.set(key, next, opt);
103
+ }, [key, initialValue, opt]);
104
+ const toolbox = react.useMemo(() => {
105
+ const defaultOps = {
106
+ get self() {
107
+ return proxy.createDeepProxy(key, [], store.store.get(key, initialValue), opt);
108
+ },
109
+ };
110
+ const boundActions = {};
111
+ if (opt.actions) {
112
+ for (const [actionName, actionFn] of Object.entries(opt.actions)) {
113
+ boundActions[actionName] = (...args) => actionFn(defaultOps, ...args);
114
+ }
115
+ }
116
+ return {
117
+ ops: defaultOps,
118
+ actions: boundActions,
119
+ set: setManual,
120
+ undo: () => store.store.undo(key),
121
+ redo: () => store.store.redo(key),
122
+ history: store.store.getHistory(key),
123
+ canUndo: store.store.getHistory(key).length > 1,
124
+ canRedo: store.store.getRedoStack(key).length > 0,
125
+ reset: () => store.store.reset(key),
126
+ cf: opt,
127
+ };
128
+ }, [key, opt, state, initialValue, setManual]);
129
+ return [state, toolbox];
130
+ }
131
+
132
+ exports.defineDerived = defineDerived;
133
+ exports.defineFlow = defineFlow;
134
+ exports.useFlow = useFlow;
135
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/index.ts"],"sourcesContent":["/***************************************************************************\n * FractoState - Fast And Secure\n *\n * @author Nehonix\n * @license NOSL\n *\n * Copyright (c) 2025 Nehonix. All rights reserved.\n *\n * This License governs the use, modification, and distribution of software\n * provided by NEHONIX under its open source projects.\n * NEHONIX is committed to fostering collaborative innovation while strictly\n * protecting its intellectual property rights.\n * Violation of any term of this License will result in immediate termination of all granted rights\n * and may subject the violator to legal action.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,\n * AND NON-INFRINGEMENT.\n * IN NO EVENT SHALL NEHONIX BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,\n * OR CONSEQUENTIAL DAMAGES ARISING FROM THE USE OR INABILITY TO USE THE SOFTWARE,\n * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\n *\n ***************************************************************************** */\n\nimport { useState, useEffect, useCallback, useMemo } from \"react\";\nimport type {\n FlowOptions,\n FlowOperations,\n FlowDefinition,\n FlowAction,\n} from \"./types\";\nimport { store } from \"./store\";\nimport { createDeepProxy } from \"./proxy\";\n\nexport * from \"./types\";\n\n// --- New feature: Derived Flows ---\n\nexport interface DerivedFlowDefinition<T, R> {\n key: string;\n source: FlowDefinition<T, any>; // The source flow\n selector: (state: T) => R; // The computation logic\n options?: any;\n}\n\n/**\n * Defines a derived flow that automatically updates based on a source flow.\n * No store registration happens here; it's purely a definition for the hook.\n */\nexport function defineDerived<T, R>(\n source: FlowDefinition<T, any>,\n selector: (state: T) => R,\n derivedKey?: string,\n): DerivedFlowDefinition<T, R> {\n return {\n key: derivedKey || `${source.key}_derived_${Date.now()}`,\n source,\n selector,\n };\n}\n\n/**\n * Defines a flow in a centralized manner.\n * Allows defining the key, initial state, and options in a single reusable object.\n */\nexport function defineFlow<T, A extends Record<string, FlowAction<T>> = {}>(\n key: string,\n initial: T,\n options?: FlowOptions<T, A>,\n): FlowDefinition<T, A> {\n // If generic T is provided manually but A is not, we want A to be inferred from options\n // However, explicit generics override inference.\n // The user should ideally use `defineFlow('key', { ...initial }, { actions: ... })`\n // without explicit generics to get full inference.\n // Or provide both. This signature supports both but relies on inference for best DX.\n return { key, initial, options };\n}\n\n// --- 1. Overload for DERIVED Flows (Read-Only) ---\nexport function useFlow<T, R>(derivedDef: DerivedFlowDefinition<T, R>): [R, {}];\n\n// --- 2. Overload for STANDARD Flows (Read-Write) ---\nexport function useFlow<\n T,\n A extends Record<string, FlowAction<T>> = Record<string, FlowAction<T>>,\n>(\n keyOrDef: string | FlowDefinition<T, A>,\n maybeInitialValue?: T,\n options?: FlowOptions<T, A>,\n): [T, FlowOperations<T, A>];\n\n// --- Implementation ---\nexport function useFlow<\n T,\n A extends Record<string, FlowAction<T>> = Record<string, FlowAction<T>>,\n R = T,\n>(\n keyOrDef: string | FlowDefinition<T, A> | DerivedFlowDefinition<any, R>,\n maybeInitialValue?: T,\n options: FlowOptions<T, A> = {},\n): [R extends T ? T : R, Partial<FlowOperations<T, A>>] {\n // 1. Identify if we are dealing with a Derived Flow\n const isDerived =\n typeof keyOrDef === \"object\" &&\n \"selector\" in keyOrDef &&\n \"source\" in keyOrDef;\n\n // --- Logic for DERIVED Flows (Read-Only Reactive) ---\n if (isDerived) {\n const derivedDef = keyOrDef as DerivedFlowDefinition<any, R>;\n const sourceKey = derivedDef.source.key;\n const selector = derivedDef.selector;\n\n const getSourceState = () =>\n store.get(sourceKey, derivedDef.source.initial);\n\n // Initial derived state\n const [derivedState, setDerivedState] = useState(() =>\n selector(getSourceState()),\n );\n\n useEffect(() => {\n const unsub = store.subscribe(sourceKey, () => {\n const nextSource = getSourceState();\n const nextDerived = selector(nextSource);\n setDerivedState((prev) => {\n if (prev === nextDerived) return prev;\n return nextDerived;\n });\n });\n return unsub;\n }, [sourceKey, selector]);\n\n return [derivedState as any, {}];\n }\n\n // --- Logic for STANDARD Flows (Read-Write) ---\n const isDef = typeof keyOrDef !== \"string\";\n const key = isDef\n ? (keyOrDef as FlowDefinition<T, A>).key\n : (keyOrDef as string);\n\n const initialValue = isDef\n ? (keyOrDef as FlowDefinition<T, A>).initial\n : maybeInitialValue;\n\n const opt: FlowOptions<T, A> = isDef\n ? { ...(keyOrDef as FlowDefinition<T, A>).options, ...options }\n : options;\n\n const [state, setState] = useState(() => store.get(key, initialValue));\n\n useEffect(() => {\n const unsub = store.subscribe(key, () => {\n setState(store.get(key, initialValue));\n });\n return unsub;\n }, [key, initialValue]);\n\n const setManual = useCallback(\n (val: T | ((prev: T) => T)) => {\n const current = store.get(key, initialValue);\n const next = typeof val === \"function\" ? (val as any)(current) : val;\n store.set(key, next, opt);\n },\n [key, initialValue, opt],\n );\n\n const toolbox = useMemo((): FlowOperations<T, A> => {\n const defaultOps = {\n get self() {\n return createDeepProxy<T>(key, [], store.get(key, initialValue), opt);\n },\n };\n\n const boundActions = {} as any;\n if (opt.actions) {\n for (const [actionName, actionFn] of Object.entries(opt.actions)) {\n boundActions[actionName] = (...args: any[]) =>\n (actionFn as Function)(defaultOps as any, ...args);\n }\n }\n\n return {\n ops: defaultOps,\n actions: boundActions,\n set: setManual,\n undo: () => store.undo(key),\n redo: () => store.redo(key),\n history: store.getHistory(key),\n canUndo: store.getHistory(key).length > 1,\n canRedo: store.getRedoStack(key).length > 0,\n reset: () => store.reset(key),\n cf: opt,\n };\n }, [key, opt, state, initialValue, setManual]);\n\n return [state as any, toolbox];\n}\n"],"names":["store","useState","useEffect","useCallback","useMemo","createDeepProxy"],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBiF;AAuBjF;;;AAGG;SACa,aAAa,CAC3B,MAA8B,EAC9B,QAAyB,EACzB,UAAmB,EAAA;IAEnB,OAAO;AACL,QAAA,GAAG,EAAE,UAAU,IAAI,CAAA,EAAG,MAAM,CAAC,GAAG,CAAA,SAAA,EAAY,IAAI,CAAC,GAAG,EAAE,CAAA,CAAE;QACxD,MAAM;QACN,QAAQ;KACT;AACH;AAEA;;;AAGG;SACa,UAAU,CACxB,GAAW,EACX,OAAU,EACV,OAA2B,EAAA;;;;;;AAO3B,IAAA,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE;AAClC;AAeA;AACM,SAAU,OAAO,CAKrB,QAAuE,EACvE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C,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;AAChE,gBAAA,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,IAAW,KACvC,QAAqB,CAAC,UAAiB,EAAE,GAAG,IAAI,CAAC;YACtD;QACF;QAEA,OAAO;AACL,YAAA,GAAG,EAAE,UAAU;AACf,YAAA,OAAO,EAAE,YAAY;AACrB,YAAA,GAAG,EAAE,SAAS;YACd,IAAI,EAAE,MAAMA,WAAK,CAAC,IAAI,CAAC,GAAG,CAAC;YAC3B,IAAI,EAAE,MAAMA,WAAK,CAAC,IAAI,CAAC,GAAG,CAAC;AAC3B,YAAA,OAAO,EAAEA,WAAK,CAAC,UAAU,CAAC,GAAG,CAAC;YAC9B,OAAO,EAAEA,WAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC;YACzC,OAAO,EAAEA,WAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC;YAC3C,KAAK,EAAE,MAAMA,WAAK,CAAC,KAAK,CAAC,GAAG,CAAC;AAC7B,YAAA,EAAE,EAAE,GAAG;SACR;AACH,IAAA,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;AAE9C,IAAA,OAAO,CAAC,KAAY,EAAE,OAAO,CAAC;AAChC;;;;;;"}
@@ -0,0 +1,289 @@
1
+ 'use strict';
2
+
3
+ var store = require('./store.js');
4
+
5
+ /**
6
+ * Creates a deep proxy that provides type-specific atomic operations for a flow.
7
+ * The proxy tracks its path within the state tree and maps access to specific update logic.
8
+ */
9
+ function createDeepProxy(key, path, currentVal, options) {
10
+ return new Proxy(() => { }, {
11
+ get(_target, prop) {
12
+ if (typeof prop === "symbol")
13
+ return undefined;
14
+ const newPath = [...path, prop];
15
+ // --- Meta-Operations ---
16
+ // Generic property replacement
17
+ if (prop === "set") {
18
+ return (val) => {
19
+ try {
20
+ const currentState = store.store.get(key, undefined);
21
+ const newState = setInPath(currentState, path, val);
22
+ store.store.set(key, newState, options);
23
+ }
24
+ catch (error) {
25
+ console.error(`[FlowProxy] Error setting value at path ${path.join(".")}:`, error);
26
+ throw error;
27
+ }
28
+ };
29
+ }
30
+ // --- Type-Specific Atomic Operations ---
31
+ // Number Operations
32
+ if (typeof currentVal === "number") {
33
+ if (prop === "increment")
34
+ return (amount = 1) => {
35
+ if (typeof amount !== "number" || !isFinite(amount)) {
36
+ console.warn(`[FlowProxy] Invalid increment amount: ${amount}`);
37
+ return;
38
+ }
39
+ update(currentVal + amount);
40
+ };
41
+ if (prop === "decrement")
42
+ return (amount = 1) => {
43
+ if (typeof amount !== "number" || !isFinite(amount)) {
44
+ console.warn(`[FlowProxy] Invalid decrement amount: ${amount}`);
45
+ return;
46
+ }
47
+ update(currentVal - amount);
48
+ };
49
+ if (prop === "add")
50
+ return (amount) => {
51
+ if (typeof amount !== "number" || !isFinite(amount)) {
52
+ console.warn(`[FlowProxy] Invalid add amount: ${amount}`);
53
+ return;
54
+ }
55
+ update(currentVal + amount);
56
+ };
57
+ if (prop === "subtract")
58
+ return (amount) => {
59
+ if (typeof amount !== "number" || !isFinite(amount)) {
60
+ console.warn(`[FlowProxy] Invalid subtract amount: ${amount}`);
61
+ return;
62
+ }
63
+ update(currentVal - amount);
64
+ };
65
+ if (prop === "multiply")
66
+ return (amount) => {
67
+ if (typeof amount !== "number" || !isFinite(amount)) {
68
+ console.warn(`[FlowProxy] Invalid multiply amount: ${amount}`);
69
+ return;
70
+ }
71
+ update(currentVal * amount);
72
+ };
73
+ if (prop === "divide")
74
+ return (amount) => {
75
+ if (typeof amount !== "number" || !isFinite(amount)) {
76
+ console.warn(`[FlowProxy] Invalid divide amount: ${amount}`);
77
+ return;
78
+ }
79
+ if (amount === 0) {
80
+ console.error(`[FlowProxy] Cannot divide by zero`);
81
+ return;
82
+ }
83
+ update(currentVal / amount);
84
+ };
85
+ }
86
+ // Array Operations
87
+ if (Array.isArray(currentVal)) {
88
+ if (prop === "push")
89
+ return (item) => update([...currentVal, item]);
90
+ if (prop === "pop")
91
+ return () => {
92
+ if (currentVal.length === 0) {
93
+ console.warn(`[FlowProxy] Cannot pop from empty array`);
94
+ return;
95
+ }
96
+ update(currentVal.slice(0, -1));
97
+ };
98
+ if (prop === "shift")
99
+ return () => {
100
+ if (currentVal.length === 0) {
101
+ console.warn(`[FlowProxy] Cannot shift from empty array`);
102
+ return;
103
+ }
104
+ update(currentVal.slice(1));
105
+ };
106
+ if (prop === "unshift")
107
+ return (item) => update([item, ...currentVal]);
108
+ if (prop === "filter")
109
+ return (fn) => {
110
+ if (typeof fn !== "function") {
111
+ console.error(`[FlowProxy] Filter requires a function`);
112
+ return;
113
+ }
114
+ try {
115
+ update(currentVal.filter(fn));
116
+ }
117
+ catch (error) {
118
+ console.error(`[FlowProxy] Filter function threw error:`, error);
119
+ }
120
+ };
121
+ if (prop === "map")
122
+ return (fn) => {
123
+ if (typeof fn !== "function") {
124
+ console.error(`[FlowProxy] Map requires a function`);
125
+ return;
126
+ }
127
+ try {
128
+ update(currentVal.map(fn));
129
+ }
130
+ catch (error) {
131
+ console.error(`[FlowProxy] Map function threw error:`, error);
132
+ }
133
+ };
134
+ if (prop === "splice")
135
+ return (...args) => {
136
+ try {
137
+ const next = [...currentVal];
138
+ const start = args[0] ?? 0;
139
+ const deleteCount = args[1] ?? 0;
140
+ if (typeof start !== "number" ||
141
+ typeof deleteCount !== "number") {
142
+ console.error(`[FlowProxy] Splice requires numeric arguments`);
143
+ return;
144
+ }
145
+ next.splice(start, deleteCount, ...args.slice(2));
146
+ update(next);
147
+ }
148
+ catch (error) {
149
+ console.error(`[FlowProxy] Splice error:`, error);
150
+ }
151
+ };
152
+ if (prop === "removeAt")
153
+ return (index) => {
154
+ if (typeof index !== "number" ||
155
+ index < 0 ||
156
+ index >= currentVal.length) {
157
+ console.warn(`[FlowProxy] Invalid index: ${index}`);
158
+ return;
159
+ }
160
+ update(currentVal.filter((_, i) => i !== index));
161
+ };
162
+ if (prop === "insertAt")
163
+ return (index, item) => {
164
+ if (typeof index !== "number" ||
165
+ index < 0 ||
166
+ index > currentVal.length) {
167
+ console.warn(`[FlowProxy] Invalid index: ${index}`);
168
+ return;
169
+ }
170
+ const next = [...currentVal];
171
+ next.splice(index, 0, item);
172
+ update(next);
173
+ };
174
+ }
175
+ // String Operations
176
+ if (typeof currentVal === "string") {
177
+ if (prop === "append")
178
+ return (str) => {
179
+ if (typeof str !== "string") {
180
+ console.warn(`[FlowProxy] Append requires a string`);
181
+ return;
182
+ }
183
+ update(currentVal + str);
184
+ };
185
+ if (prop === "prepend")
186
+ return (str) => {
187
+ if (typeof str !== "string") {
188
+ console.warn(`[FlowProxy] Prepend requires a string`);
189
+ return;
190
+ }
191
+ update(str + currentVal);
192
+ };
193
+ if (prop === "uppercase")
194
+ return () => update(currentVal.toUpperCase());
195
+ if (prop === "lowercase")
196
+ return () => update(currentVal.toLowerCase());
197
+ if (prop === "trim")
198
+ return () => update(currentVal.trim());
199
+ if (prop === "replace")
200
+ return (search, replace) => {
201
+ if (typeof replace !== "string") {
202
+ console.warn(`[FlowProxy] Replace requires a string replacement`);
203
+ return;
204
+ }
205
+ try {
206
+ update(currentVal.replace(search, replace));
207
+ }
208
+ catch (error) {
209
+ console.error(`[FlowProxy] Replace error:`, error);
210
+ }
211
+ };
212
+ }
213
+ // Object Operations
214
+ if (currentVal !== null &&
215
+ typeof currentVal === "object" &&
216
+ !Array.isArray(currentVal)) {
217
+ if (prop === "merge")
218
+ return (obj) => {
219
+ if (typeof obj !== "object" || obj === null || Array.isArray(obj)) {
220
+ console.warn(`[FlowProxy] Merge requires an object`);
221
+ return;
222
+ }
223
+ update({ ...currentVal, ...obj });
224
+ };
225
+ if (prop === "delete")
226
+ return (keyToDel) => {
227
+ if (typeof keyToDel !== "string") {
228
+ console.warn(`[FlowProxy] Delete requires a string key`);
229
+ return;
230
+ }
231
+ if (!(keyToDel in currentVal)) {
232
+ console.warn(`[FlowProxy] Key "${keyToDel}" does not exist`);
233
+ return;
234
+ }
235
+ const next = { ...currentVal };
236
+ delete next[keyToDel];
237
+ update(next);
238
+ };
239
+ }
240
+ /**
241
+ * Internal helper to commit a value update to the store.
242
+ */
243
+ function update(val) {
244
+ try {
245
+ const currentState = store.store.get(key, undefined);
246
+ const newState = setInPath(currentState, path, val);
247
+ store.store.set(key, newState, options);
248
+ }
249
+ catch (error) {
250
+ console.error(`[FlowProxy] Error updating value at path ${path.join(".")}:`, error);
251
+ throw error;
252
+ }
253
+ }
254
+ // Recursive step: create a new proxy for the child property
255
+ const nextVal = currentVal ? currentVal[prop] : undefined;
256
+ return createDeepProxy(key, newPath, nextVal, options);
257
+ },
258
+ });
259
+ }
260
+ /**
261
+ * Immutable update utility that sets a value at a specific path within an object/array.
262
+ */
263
+ function setInPath(obj, path, value) {
264
+ if (path.length === 0)
265
+ return value;
266
+ const [head, ...tail] = path;
267
+ if (Array.isArray(obj)) {
268
+ const index = parseInt(head, 10);
269
+ if (isNaN(index) || index < 0) {
270
+ throw new Error(`[FlowProxy] Invalid array index: ${head}`);
271
+ }
272
+ const newArr = [...obj];
273
+ if (index >= newArr.length) {
274
+ newArr.length = index + 1;
275
+ }
276
+ newArr[index] = setInPath(newArr[index], tail, value);
277
+ return newArr;
278
+ }
279
+ // Handle nested objects (including null/undefined recovery)
280
+ const currentObj = obj ?? {};
281
+ return {
282
+ ...currentObj,
283
+ [head]: setInPath(currentObj[head], tail, value),
284
+ };
285
+ }
286
+
287
+ exports.createDeepProxy = createDeepProxy;
288
+ exports.setInPath = setInPath;
289
+ //# 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":["store"],"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,GAAGA,WAAK,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC;wBAC9C,MAAM,QAAQ,GAAG,SAAS,CAAC,YAAY,EAAE,IAAI,EAAE,GAAG,CAAC;wBACnDA,WAAK,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC;oBACnC;oBAAE,OAAO,KAAK,EAAE;AACd,wBAAA,OAAO,CAAC,KAAK,CACX,CAAA,wCAAA,EAA2C,IAAI,CAAC,IAAI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