@fynixorg/ui 1.0.4 → 1.0.5
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/build.d.ts +1 -0
- package/dist/context/context.d.ts +2 -0
- package/dist/context/context.js +3 -0
- package/dist/context/context.js.map +1 -1
- package/dist/custom/button.d.ts +19 -0
- package/dist/custom/button.js +3 -0
- package/dist/custom/button.js.map +1 -1
- package/dist/custom/index.d.ts +2 -0
- package/dist/custom/path.d.ts +20 -0
- package/dist/custom/path.js +3 -0
- package/dist/custom/path.js.map +2 -2
- package/dist/error/errorOverlay.d.ts +2 -0
- package/dist/error/errorOverlay.js +4 -0
- package/dist/error/errorOverlay.js.map +1 -1
- package/dist/fynix/index.d.ts +4 -0
- package/dist/hooks/nixAsync.d.ts +13 -0
- package/dist/hooks/nixAsync.js +7 -4
- package/dist/hooks/nixAsync.js.map +1 -1
- package/dist/hooks/nixAsyncCache.d.ts +7 -0
- package/dist/hooks/nixAsyncCache.js +7 -4
- package/dist/hooks/nixAsyncCache.js.map +1 -1
- package/dist/hooks/nixAsyncDebounce.d.ts +28 -0
- package/dist/hooks/nixAsyncDebounce.js +9 -6
- package/dist/hooks/nixAsyncDebounce.js.map +1 -1
- package/dist/hooks/nixAsyncQuery.d.ts +40 -0
- package/dist/hooks/nixAsyncQuery.js +7 -4
- package/dist/hooks/nixAsyncQuery.js.map +1 -1
- package/dist/hooks/nixCallback.d.ts +30 -0
- package/dist/hooks/nixCallback.js +4 -0
- package/dist/hooks/nixCallback.js.map +1 -1
- package/dist/hooks/nixComputed.d.ts +94 -0
- package/dist/hooks/nixComputed.js +4 -0
- package/dist/hooks/nixComputed.js.map +1 -1
- package/dist/hooks/nixDebounce.d.ts +28 -0
- package/dist/hooks/nixDebounce.js +7 -4
- package/dist/hooks/nixDebounce.js.map +1 -1
- package/dist/hooks/nixEffect.d.ts +64 -0
- package/dist/hooks/nixEffect.js +6 -0
- package/dist/hooks/nixEffect.js.map +1 -1
- package/dist/hooks/nixForm.d.ts +15 -0
- package/dist/hooks/nixForm.js +11 -0
- package/dist/hooks/nixForm.js.map +1 -1
- package/dist/hooks/nixFormAsync.d.ts +20 -0
- package/dist/hooks/nixFormAsync.js +12 -0
- package/dist/hooks/nixFormAsync.js.map +1 -1
- package/dist/hooks/nixInterval.d.ts +19 -0
- package/dist/hooks/nixInterval.js +6 -3
- package/dist/hooks/nixInterval.js.map +1 -1
- package/dist/hooks/nixLazy.d.ts +19 -0
- package/dist/hooks/nixLazy.js +6 -2
- package/dist/hooks/nixLazy.js.map +1 -1
- package/dist/hooks/nixLazyAsync.d.ts +26 -0
- package/dist/hooks/nixLazyAsync.js +10 -6
- package/dist/hooks/nixLazyAsync.js.map +1 -1
- package/dist/hooks/nixLazyFormAsync.d.ts +29 -0
- package/dist/hooks/nixLazyFormAsync.js +18 -6
- package/dist/hooks/nixLazyFormAsync.js.map +1 -1
- package/dist/hooks/nixLocalStorage.d.ts +11 -0
- package/dist/hooks/nixLocalStorage.js +5 -2
- package/dist/hooks/nixLocalStorage.js.map +1 -1
- package/dist/hooks/nixMemo.d.ts +8 -0
- package/dist/hooks/nixMemo.js +3 -0
- package/dist/hooks/nixMemo.js.map +1 -1
- package/dist/hooks/nixPrevious.d.ts +7 -0
- package/dist/hooks/nixPrevious.js +3 -0
- package/dist/hooks/nixPrevious.js.map +1 -1
- package/dist/hooks/nixRef.d.ts +10 -0
- package/dist/hooks/nixRef.js +3 -0
- package/dist/hooks/nixRef.js.map +1 -1
- package/dist/hooks/nixState.d.ts +73 -0
- package/dist/hooks/nixState.js +3 -0
- package/dist/hooks/nixState.js.map +1 -1
- package/dist/hooks/nixStore.d.ts +9 -0
- package/dist/hooks/nixStore.js +3 -0
- package/dist/hooks/nixStore.js.map +1 -1
- package/dist/plugins/vite-plugin-res.d.ts +12 -0
- package/dist/plugins/vite-plugin-res.js +3 -0
- package/dist/plugins/vite-plugin-res.js.map +1 -1
- package/dist/router/router.d.ts +53 -0
- package/dist/router/router.js +25 -2
- package/dist/router/router.js.map +1 -1
- package/dist/runtime.d.ts +91 -0
- package/dist/runtime.js +18 -0
- package/dist/runtime.js.map +1 -1
- package/package.json +2 -1
- package/types/global.d.ts +29 -19
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a derived/computed state from other states.
|
|
3
|
+
* Automatically tracks dependencies and updates when any dependency changes.
|
|
4
|
+
*
|
|
5
|
+
* @param {() => any} computeFn - Function that computes the derived value
|
|
6
|
+
* @returns {ComputedState} A reactive state object with the computed value
|
|
7
|
+
*
|
|
8
|
+
* @typedef {Object} ComputedState
|
|
9
|
+
* @property {any} value - Get the computed value (read-only)
|
|
10
|
+
* @property {(fn: Function) => Function} subscribe - Subscribe to computed value changes
|
|
11
|
+
* @property {() => void} cleanup - Cleanup all subscriptions and dependencies
|
|
12
|
+
* @property {() => number} getSubscriberCount - Get number of active subscribers (debugging)
|
|
13
|
+
* @property {() => number} getDependencyCount - Get number of tracked dependencies (debugging)
|
|
14
|
+
* @property {() => boolean} isDestroyed - Check if computed state has been destroyed
|
|
15
|
+
* @property {boolean} _isNixState - Internal flag (computed states behave like states)
|
|
16
|
+
* @property {boolean} _isComputed - Internal flag to identify computed states
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* const count = nixState(5);
|
|
20
|
+
* const doubled = nixComputed(() => count.value * 2);
|
|
21
|
+
* console.log(doubled.value); // 10
|
|
22
|
+
* count.value = 10;
|
|
23
|
+
* console.log(doubled.value); // 20
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Multiple dependencies
|
|
27
|
+
* const a = nixState(5);
|
|
28
|
+
* const b = nixState(10);
|
|
29
|
+
* const sum = nixComputed(() => a.value + b.value);
|
|
30
|
+
* console.log(sum.value); // 15
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* // Conditional dependencies
|
|
34
|
+
* const flag = nixState(true);
|
|
35
|
+
* const x = nixState(1);
|
|
36
|
+
* const y = nixState(2);
|
|
37
|
+
* const result = nixComputed(() => flag.value ? x.value : y.value);
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* // With cleanup
|
|
41
|
+
* const MyComponent = () => {
|
|
42
|
+
* const count = nixState(0);
|
|
43
|
+
* const doubled = nixComputed(() => count.value * 2);
|
|
44
|
+
*
|
|
45
|
+
* nixEffect(() => {
|
|
46
|
+
* return () => {
|
|
47
|
+
* doubled.cleanup();
|
|
48
|
+
* count.cleanup();
|
|
49
|
+
* };
|
|
50
|
+
* }, []);
|
|
51
|
+
* };
|
|
52
|
+
*
|
|
53
|
+
* @throws {Error} If called outside a component context
|
|
54
|
+
* @throws {TypeError} If computeFn is not a function
|
|
55
|
+
*/
|
|
56
|
+
export function nixComputed(computeFn: () => any): ComputedState;
|
|
57
|
+
/**
|
|
58
|
+
* Create a derived/computed state from other states.
|
|
59
|
+
* Automatically tracks dependencies and updates when any dependency changes.
|
|
60
|
+
*/
|
|
61
|
+
export type ComputedState = {
|
|
62
|
+
/**
|
|
63
|
+
* - Get the computed value (read-only)
|
|
64
|
+
*/
|
|
65
|
+
value: any;
|
|
66
|
+
/**
|
|
67
|
+
* - Subscribe to computed value changes
|
|
68
|
+
*/
|
|
69
|
+
subscribe: (fn: Function) => Function;
|
|
70
|
+
/**
|
|
71
|
+
* - Cleanup all subscriptions and dependencies
|
|
72
|
+
*/
|
|
73
|
+
cleanup: () => void;
|
|
74
|
+
/**
|
|
75
|
+
* - Get number of active subscribers (debugging)
|
|
76
|
+
*/
|
|
77
|
+
getSubscriberCount: () => number;
|
|
78
|
+
/**
|
|
79
|
+
* - Get number of tracked dependencies (debugging)
|
|
80
|
+
*/
|
|
81
|
+
getDependencyCount: () => number;
|
|
82
|
+
/**
|
|
83
|
+
* - Check if computed state has been destroyed
|
|
84
|
+
*/
|
|
85
|
+
isDestroyed: () => boolean;
|
|
86
|
+
/**
|
|
87
|
+
* - Internal flag (computed states behave like states)
|
|
88
|
+
*/
|
|
89
|
+
_isNixState: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* - Internal flag to identify computed states
|
|
92
|
+
*/
|
|
93
|
+
_isComputed: boolean;
|
|
94
|
+
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
1
3
|
import { activeContext, setActiveContext } from "../context/context";
|
|
2
4
|
function nixComputed(computeFn) {
|
|
3
5
|
const ctx = activeContext;
|
|
@@ -69,6 +71,7 @@ function nixComputed(computeFn) {
|
|
|
69
71
|
}
|
|
70
72
|
return cachedValue;
|
|
71
73
|
};
|
|
74
|
+
__name(compute, "compute");
|
|
72
75
|
const subscribers = /* @__PURE__ */ new Set();
|
|
73
76
|
const dependencies = /* @__PURE__ */ new Set();
|
|
74
77
|
const unsubscribers = /* @__PURE__ */ new Map();
|
|
@@ -194,6 +197,7 @@ function nixComputed(computeFn) {
|
|
|
194
197
|
}
|
|
195
198
|
return ctx.hooks[idx];
|
|
196
199
|
}
|
|
200
|
+
__name(nixComputed, "nixComputed");
|
|
197
201
|
export {
|
|
198
202
|
nixComputed
|
|
199
203
|
};
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../hooks/nixComputed.js"],
|
|
4
4
|
"sourcesContent": ["/* ----------------------\r\n nixComputed - Computed/Derived State\r\n Memory Leaks & Security Issues Resolved\r\n---------------------- */\r\nimport { activeContext, setActiveContext } from \"../context/context\";\r\n\r\n/**\r\n * Create a derived/computed state from other states.\r\n * Automatically tracks dependencies and updates when any dependency changes.\r\n * \r\n * @param {() => any} computeFn - Function that computes the derived value\r\n * @returns {ComputedState} A reactive state object with the computed value\r\n * \r\n * @typedef {Object} ComputedState\r\n * @property {any} value - Get the computed value (read-only)\r\n * @property {(fn: Function) => Function} subscribe - Subscribe to computed value changes\r\n * @property {() => void} cleanup - Cleanup all subscriptions and dependencies\r\n * @property {() => number} getSubscriberCount - Get number of active subscribers (debugging)\r\n * @property {() => number} getDependencyCount - Get number of tracked dependencies (debugging)\r\n * @property {() => boolean} isDestroyed - Check if computed state has been destroyed\r\n * @property {boolean} _isNixState - Internal flag (computed states behave like states)\r\n * @property {boolean} _isComputed - Internal flag to identify computed states\r\n * \r\n * @example\r\n * const count = nixState(5);\r\n * const doubled = nixComputed(() => count.value * 2);\r\n * console.log(doubled.value); // 10\r\n * count.value = 10;\r\n * console.log(doubled.value); // 20\r\n * \r\n * @example\r\n * // Multiple dependencies\r\n * const a = nixState(5);\r\n * const b = nixState(10);\r\n * const sum = nixComputed(() => a.value + b.value);\r\n * console.log(sum.value); // 15\r\n * \r\n * @example\r\n * // Conditional dependencies\r\n * const flag = nixState(true);\r\n * const x = nixState(1);\r\n * const y = nixState(2);\r\n * const result = nixComputed(() => flag.value ? x.value : y.value);\r\n * \r\n * @example\r\n * // With cleanup\r\n * const MyComponent = () => {\r\n * const count = nixState(0);\r\n * const doubled = nixComputed(() => count.value * 2);\r\n * \r\n * nixEffect(() => {\r\n * return () => {\r\n * doubled.cleanup();\r\n * count.cleanup();\r\n * };\r\n * }, []);\r\n * };\r\n * \r\n * @throws {Error} If called outside a component context\r\n * @throws {TypeError} If computeFn is not a function\r\n */\r\nexport function nixComputed(computeFn) {\r\n const ctx = activeContext;\r\n if (!ctx) throw new Error(\"nixComputed() called outside component\");\r\n \r\n // Security: Validate compute function\r\n if (typeof computeFn !== 'function') {\r\n throw new TypeError('[nixComputed] First argument must be a function');\r\n }\r\n\r\n const idx = ctx.hookIndex++;\r\n if (!ctx.hooks[idx]) {\r\n const subscribers = new Set();\r\n const dependencies = new Set();\r\n const unsubscribers = new Map(); // Map<dependency, unsubscribe function>\r\n let cachedValue;\r\n let isStale = true;\r\n let isDestroyed = false;\r\n let isComputing = false; // Prevent infinite loops\r\n\r\n /**\r\n * Compute the value and track dependencies\r\n */\r\n function compute() {\r\n if (isDestroyed) return cachedValue;\r\n \r\n // Prevent infinite computation loops\r\n if (isComputing) {\r\n console.error('[nixComputed] Circular dependency detected');\r\n return cachedValue;\r\n }\r\n \r\n isComputing = true;\r\n \r\n // Create a mock context for dependency tracking\r\n const trackingContext = {\r\n _accessedStates: new Set(),\r\n hookIndex: 0,\r\n hooks: [],\r\n _subscriptions: new Set(),\r\n _subscriptionCleanups: [],\r\n };\r\n \r\n // Save the previous context\r\n const prevContext = activeContext;\r\n \r\n try {\r\n // Temporarily set the tracking context\r\n setActiveContext(trackingContext);\r\n \r\n // Compute the value - this will trigger state.value getters\r\n // which will add themselves to trackingContext._accessedStates\r\n cachedValue = computeFn();\r\n \r\n // Find dependencies that are no longer needed\r\n const oldDeps = Array.from(dependencies);\r\n oldDeps.forEach(dep => {\r\n if (!trackingContext._accessedStates.has(dep)) {\r\n // This dependency is no longer accessed - unsubscribe\r\n if (unsubscribers.has(dep)) {\r\n try {\r\n unsubscribers.get(dep)();\r\n } catch (e) {\r\n console.error('[nixComputed] Error unsubscribing from old dependency:', e);\r\n }\r\n unsubscribers.delete(dep);\r\n }\r\n dependencies.delete(dep);\r\n }\r\n });\r\n \r\n // Subscribe to new dependencies\r\n trackingContext._accessedStates.forEach(state => {\r\n if (!dependencies.has(state)) {\r\n // New dependency found - subscribe to it\r\n const unsub = state.subscribe(() => {\r\n // Mark computed value as stale when dependency changes\r\n isStale = true;\r\n \r\n // Notify computed subscribers\r\n const subsArray = Array.from(subscribers);\r\n subsArray.forEach(fn => {\r\n try { \r\n fn(s.value); \r\n } catch (e) { \r\n console.error('[nixComputed] Subscriber error:', e);\r\n subscribers.delete(fn);\r\n }\r\n });\r\n });\r\n \r\n // Store unsubscribe function\r\n unsubscribers.set(state, unsub);\r\n dependencies.add(state);\r\n }\r\n });\r\n \r\n isStale = false;\r\n } catch (err) {\r\n console.error('[nixComputed] Compute error:', err);\r\n isStale = false; // Don't retry immediately\r\n } finally {\r\n // Restore the previous context\r\n setActiveContext(prevContext);\r\n isComputing = false;\r\n }\r\n \r\n return cachedValue;\r\n }\r\n\r\n const s = {\r\n /**\r\n * Get the computed value (read-only).\r\n * Automatically recomputes if dependencies have changed.\r\n * @returns {any} The computed value\r\n */\r\n get value() {\r\n if (isDestroyed) {\r\n console.warn('[nixComputed] Accessing destroyed computed state');\r\n return cachedValue;\r\n }\r\n \r\n // Recompute if stale\r\n if (isStale) {\r\n compute();\r\n }\r\n \r\n // Track this computed state as a dependency if accessed in another computed\r\n if (activeContext && activeContext._accessedStates) {\r\n activeContext._accessedStates.add(s);\r\n }\r\n \r\n return cachedValue;\r\n },\r\n \r\n /**\r\n * Subscribe to computed value changes.\r\n * @param {(value: T) => void} fn - Callback function\r\n * @returns {() => void} Unsubscribe function\r\n */\r\n subscribe(fn) {\r\n // Security: Validate subscriber function\r\n if (typeof fn !== 'function') {\r\n console.error('[nixComputed] subscribe() requires a function');\r\n return () => {};\r\n }\r\n \r\n // Memory Leak Fix: Don't add subscribers to destroyed state\r\n if (isDestroyed) {\r\n console.warn('[nixComputed] Cannot subscribe to destroyed computed state');\r\n return () => {};\r\n }\r\n \r\n // Security: Limit number of subscribers to prevent DOS\r\n const MAX_SUBSCRIBERS = 1000;\r\n if (subscribers.size >= MAX_SUBSCRIBERS) {\r\n console.error('[nixComputed] Maximum subscriber limit reached');\r\n return () => {};\r\n }\r\n \r\n subscribers.add(fn);\r\n \r\n // Return unsubscribe function\r\n return () => {\r\n subscribers.delete(fn);\r\n };\r\n },\r\n \r\n /**\r\n * Cleanup all subscriptions and dependencies.\r\n * Call this when component unmounts to prevent memory leaks.\r\n * \r\n * @example\r\n * nixEffect(() => {\r\n * return () => myComputed.cleanup();\r\n * }, []);\r\n */\r\n cleanup() {\r\n if (isDestroyed) return;\r\n \r\n // Mark as destroyed to prevent further operations\r\n isDestroyed = true;\r\n \r\n // Unsubscribe from all dependencies\r\n unsubscribers.forEach((unsub, dep) => {\r\n try {\r\n unsub();\r\n } catch (e) {\r\n console.error('[nixComputed] Cleanup error:', e);\r\n }\r\n });\r\n \r\n // Clear all collections\r\n unsubscribers.clear();\r\n dependencies.clear();\r\n subscribers.clear();\r\n \r\n // Clear cached value to help garbage collection\r\n cachedValue = null;\r\n \r\n console.log('[nixComputed] Computed state cleaned up');\r\n },\r\n \r\n /**\r\n * Get the number of active subscribers (useful for debugging)\r\n * @returns {number} Number of active subscribers\r\n */\r\n getSubscriberCount() {\r\n return subscribers.size;\r\n },\r\n \r\n /**\r\n * Get the number of tracked dependencies (useful for debugging)\r\n * @returns {number} Number of dependencies\r\n */\r\n getDependencyCount() {\r\n return dependencies.size;\r\n },\r\n \r\n /**\r\n * Check if computed state has been destroyed\r\n * @returns {boolean} True if state is destroyed\r\n */\r\n isDestroyed() {\r\n return isDestroyed;\r\n },\r\n \r\n /**\r\n * Get information about current dependencies (debugging)\r\n * @returns {Array<{state: Object, hasCleanup: boolean}>} Dependency info\r\n */\r\n getDependencyInfo() {\r\n return Array.from(dependencies).map(dep => ({\r\n state: dep,\r\n hasCleanup: unsubscribers.has(dep),\r\n isComputed: !!dep._isComputed,\r\n }));\r\n },\r\n \r\n // Internal flags\r\n _isNixState: true, // Computed states behave like states\r\n _isComputed: true, // Flag to identify computed states\r\n };\r\n\r\n // Initial computation\r\n compute();\r\n \r\n // Store in hooks\r\n ctx.hooks[idx] = s;\r\n \r\n // Memory Leak Fix: Track for cleanup\r\n if (ctx.stateCleanups) {\r\n ctx.stateCleanups.push(() => s.cleanup());\r\n }\r\n }\r\n\r\n return ctx.hooks[idx];\r\n}"],
|
|
5
|
-
"mappings": "AAIA,SAAS,eAAe,wBAAwB;AAyDzC,SAAS,YAAY,WAAW;AACrC,QAAM,MAAM;AACZ,MAAI,CAAC;AAAK,UAAM,IAAI,MAAM,wCAAwC;AAGlE,MAAI,OAAO,cAAc,YAAY;AACnC,UAAM,IAAI,UAAU,iDAAiD;AAAA,EACvE;AAEA,QAAM,MAAM,IAAI;AAChB,MAAI,CAAC,IAAI,MAAM,GAAG,GAAG;AAYnB,QAAS,UAAT,WAAmB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MAAM,GAAG;AACtB;AAhQgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debounce a function with options for leading, trailing, maxWait, and AbortController support.
|
|
3
|
+
*
|
|
4
|
+
* @param {Function} fn - The function to debounce.
|
|
5
|
+
* @param {number} [delay=300] - Delay in milliseconds.
|
|
6
|
+
* @param {Object} [options={}] - Debounce options.
|
|
7
|
+
* @param {boolean} [options.leading=false] - Invoke on the leading edge.
|
|
8
|
+
* @param {boolean} [options.trailing=true] - Invoke on the trailing edge.
|
|
9
|
+
* @param {number} [options.maxWait] - Maximum wait time before forced invocation.
|
|
10
|
+
* @param {AbortSignal} [options.signal] - Optional AbortSignal to cancel pending calls.
|
|
11
|
+
* @returns {Function} Debounced function with `.cancel()` method.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const controller = new AbortController();
|
|
15
|
+
* const debounced = nixDebounce(() => console.log('Hello'), 500, {
|
|
16
|
+
* leading: true,
|
|
17
|
+
* maxWait: 2000,
|
|
18
|
+
* signal: controller.signal
|
|
19
|
+
* });
|
|
20
|
+
* debounced();
|
|
21
|
+
* controller.abort(); // Cancel pending invocation
|
|
22
|
+
*/
|
|
23
|
+
export function nixDebounce(fn: Function, delay?: number, options?: {
|
|
24
|
+
leading?: boolean;
|
|
25
|
+
trailing?: boolean;
|
|
26
|
+
maxWait?: number;
|
|
27
|
+
signal?: AbortSignal;
|
|
28
|
+
}): Function;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
1
3
|
function nixDebounce(fn, delay = 300, options = {}) {
|
|
2
4
|
let timerId = null;
|
|
3
5
|
let lastInvokeTime = 0;
|
|
@@ -14,14 +16,14 @@ function nixDebounce(fn, delay = 300, options = {}) {
|
|
|
14
16
|
lastThis = null;
|
|
15
17
|
});
|
|
16
18
|
}
|
|
17
|
-
const invoke = () => {
|
|
19
|
+
const invoke = /* @__PURE__ */ __name(() => {
|
|
18
20
|
lastInvokeTime = Date.now();
|
|
19
21
|
if (lastArgs) {
|
|
20
22
|
fn.apply(lastThis, lastArgs);
|
|
21
23
|
lastArgs = lastThis = null;
|
|
22
24
|
}
|
|
23
|
-
};
|
|
24
|
-
const debounced = function(...args) {
|
|
25
|
+
}, "invoke");
|
|
26
|
+
const debounced = /* @__PURE__ */ __name(function(...args) {
|
|
25
27
|
const now = Date.now();
|
|
26
28
|
lastArgs = args;
|
|
27
29
|
lastThis = this;
|
|
@@ -43,7 +45,7 @@ function nixDebounce(fn, delay = 300, options = {}) {
|
|
|
43
45
|
if (trailing) {
|
|
44
46
|
timerId = setTimeout(invoke, remainingTime > 0 ? remainingTime : delay);
|
|
45
47
|
}
|
|
46
|
-
};
|
|
48
|
+
}, "debounced");
|
|
47
49
|
debounced.cancel = () => {
|
|
48
50
|
if (timerId)
|
|
49
51
|
clearTimeout(timerId);
|
|
@@ -51,6 +53,7 @@ function nixDebounce(fn, delay = 300, options = {}) {
|
|
|
51
53
|
};
|
|
52
54
|
return debounced;
|
|
53
55
|
}
|
|
56
|
+
__name(nixDebounce, "nixDebounce");
|
|
54
57
|
export {
|
|
55
58
|
nixDebounce
|
|
56
59
|
};
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../hooks/nixDebounce.js"],
|
|
4
4
|
"sourcesContent": ["/**\r\n * Debounce a function with options for leading, trailing, maxWait, and AbortController support.\r\n *\r\n * @param {Function} fn - The function to debounce.\r\n * @param {number} [delay=300] - Delay in milliseconds.\r\n * @param {Object} [options={}] - Debounce options.\r\n * @param {boolean} [options.leading=false] - Invoke on the leading edge.\r\n * @param {boolean} [options.trailing=true] - Invoke on the trailing edge.\r\n * @param {number} [options.maxWait] - Maximum wait time before forced invocation.\r\n * @param {AbortSignal} [options.signal] - Optional AbortSignal to cancel pending calls.\r\n * @returns {Function} Debounced function with `.cancel()` method.\r\n *\r\n * @example\r\n * const controller = new AbortController();\r\n * const debounced = nixDebounce(() => console.log('Hello'), 500, {\r\n * leading: true,\r\n * maxWait: 2000,\r\n * signal: controller.signal\r\n * });\r\n * debounced();\r\n * controller.abort(); // Cancel pending invocation\r\n */\r\nexport function nixDebounce(fn, delay = 300, options = {}) {\r\n let timerId = null;\r\n let lastInvokeTime = 0;\r\n let lastArgs;\r\n let lastThis;\r\n\r\n const { leading = false, trailing = true, maxWait, signal } = options;\r\n\r\n if (signal) {\r\n signal.addEventListener(\"abort\", () => {\r\n if (timerId) {\r\n clearTimeout(timerId);\r\n timerId = null;\r\n }\r\n lastArgs = null;\r\n lastThis = null;\r\n });\r\n }\r\n\r\n const invoke = () => {\r\n lastInvokeTime = Date.now();\r\n if (lastArgs) {\r\n fn.apply(lastThis, lastArgs);\r\n lastArgs = lastThis = null;\r\n }\r\n };\r\n\r\n const debounced = function (...args) {\r\n const now = Date.now();\r\n lastArgs = args;\r\n lastThis = this;\r\n\r\n const shouldInvokeLeading = leading && !timerId;\r\n const timeSinceLastInvoke = now - lastInvokeTime;\r\n const remainingTime = delay - timeSinceLastInvoke;\r\n\r\n if (maxWait !== undefined && timeSinceLastInvoke >= maxWait) {\r\n if (timerId) clearTimeout(timerId);\r\n timerId = null;\r\n invoke();\r\n return;\r\n }\r\n\r\n if (timerId) clearTimeout(timerId);\r\n\r\n if (shouldInvokeLeading) {\r\n invoke();\r\n }\r\n\r\n if (trailing) {\r\n timerId = setTimeout(invoke, remainingTime > 0 ? remainingTime : delay);\r\n }\r\n };\r\n\r\n debounced.cancel = () => {\r\n if (timerId) clearTimeout(timerId);\r\n timerId = lastArgs = lastThis = null;\r\n };\r\n\r\n return debounced;\r\n}\r\n"],
|
|
5
|
-
"mappings": "AAsBO,SAAS,YAAY,IAAI,QAAQ,KAAK,UAAU,CAAC,GAAG;AACzD,MAAI,UAAU;AACd,MAAI,iBAAiB;AACrB,MAAI;AAC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B;AA2BlB,YAAU,SAAS,MAAM;AACvB,QAAI;AAAS,mBAAa,OAAO;AACjC,cAAU,WAAW,WAAW;AAAA,EAClC;AAEA,SAAO;AACT;AA5DgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execute side effects in a component with automatic cleanup.
|
|
3
|
+
* Similar to React's useEffect.
|
|
4
|
+
*
|
|
5
|
+
* @param {() => (void | (() => void))} effect - Effect function, optionally returns cleanup function
|
|
6
|
+
* @param {Array<any>} [deps=[]] - Dependency array. Effect re-runs when dependencies change.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* // Run once on mount
|
|
10
|
+
* nixEffect(() => {
|
|
11
|
+
* console.log('Component mounted');
|
|
12
|
+
* return () => console.log('Component unmounted');
|
|
13
|
+
* }, []);
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Run when count changes
|
|
17
|
+
* const count = nixState(0);
|
|
18
|
+
* nixEffect(() => {
|
|
19
|
+
* console.log('Count is:', count.value);
|
|
20
|
+
* }, [count.value]);
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Timer with cleanup
|
|
24
|
+
* nixEffect(() => {
|
|
25
|
+
* const timer = setInterval(() => console.log('tick'), 1000);
|
|
26
|
+
* return () => clearInterval(timer);
|
|
27
|
+
* }, []);
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // Event listener with cleanup
|
|
31
|
+
* nixEffect(() => {
|
|
32
|
+
* const handler = (e) => console.log('clicked', e);
|
|
33
|
+
* document.addEventListener('click', handler);
|
|
34
|
+
* return () => document.removeEventListener('click', handler);
|
|
35
|
+
* }, []);
|
|
36
|
+
*
|
|
37
|
+
* @throws {Error} If called outside a component context
|
|
38
|
+
*/
|
|
39
|
+
export function nixEffect(effect: () => (void | (() => void)), deps?: Array<any>): void;
|
|
40
|
+
/**
|
|
41
|
+
* Run an effect only once on component mount.
|
|
42
|
+
* Convenience wrapper around nixEffect.
|
|
43
|
+
*
|
|
44
|
+
* @param {() => (void | (() => void))} effect - Effect function
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* nixEffectOnce(() => {
|
|
48
|
+
* console.log('Mounted');
|
|
49
|
+
* return () => console.log('Unmounted');
|
|
50
|
+
* });
|
|
51
|
+
*/
|
|
52
|
+
export function nixEffectOnce(effect: () => (void | (() => void))): void;
|
|
53
|
+
/**
|
|
54
|
+
* Run an effect every time the component renders.
|
|
55
|
+
* Use with caution - can cause performance issues.
|
|
56
|
+
*
|
|
57
|
+
* @param {() => (void | (() => void))} effect - Effect function
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* nixEffectAlways(() => {
|
|
61
|
+
* console.log('Component rendered');
|
|
62
|
+
* });
|
|
63
|
+
*/
|
|
64
|
+
export function nixEffectAlways(effect: () => (void | (() => void))): void;
|
package/dist/hooks/nixEffect.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
1
3
|
import { activeContext } from "../context/context";
|
|
2
4
|
function nixEffect(effect, deps = []) {
|
|
3
5
|
const ctx = activeContext;
|
|
@@ -48,6 +50,7 @@ function nixEffect(effect, deps = []) {
|
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
52
|
}
|
|
53
|
+
__name(nixEffect, "nixEffect");
|
|
51
54
|
function shallowArrayEqual(arr1, arr2) {
|
|
52
55
|
if (arr1.length !== arr2.length)
|
|
53
56
|
return false;
|
|
@@ -58,9 +61,11 @@ function shallowArrayEqual(arr1, arr2) {
|
|
|
58
61
|
}
|
|
59
62
|
return true;
|
|
60
63
|
}
|
|
64
|
+
__name(shallowArrayEqual, "shallowArrayEqual");
|
|
61
65
|
function nixEffectOnce(effect) {
|
|
62
66
|
return nixEffect(effect, []);
|
|
63
67
|
}
|
|
68
|
+
__name(nixEffectOnce, "nixEffectOnce");
|
|
64
69
|
function nixEffectAlways(effect) {
|
|
65
70
|
const ctx = activeContext;
|
|
66
71
|
if (!ctx)
|
|
@@ -71,6 +76,7 @@ function nixEffectAlways(effect) {
|
|
|
71
76
|
}
|
|
72
77
|
return nixEffect(effect, [ctx.version]);
|
|
73
78
|
}
|
|
79
|
+
__name(nixEffectAlways, "nixEffectAlways");
|
|
74
80
|
export {
|
|
75
81
|
nixEffect,
|
|
76
82
|
nixEffectAlways,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../hooks/nixEffect.js"],
|
|
4
4
|
"sourcesContent": ["/* ----------------------\r\n nixEffect - Side Effects Hook\r\n Memory Leaks & Security Issues Resolved\r\n---------------------- */\r\nimport { activeContext } from \"../context/context\";\r\n\r\n/**\r\n * Execute side effects in a component with automatic cleanup.\r\n * Similar to React's useEffect.\r\n * \r\n * @param {() => (void | (() => void))} effect - Effect function, optionally returns cleanup function\r\n * @param {Array<any>} [deps=[]] - Dependency array. Effect re-runs when dependencies change.\r\n * \r\n * @example\r\n * // Run once on mount\r\n * nixEffect(() => {\r\n * console.log('Component mounted');\r\n * return () => console.log('Component unmounted');\r\n * }, []);\r\n * \r\n * @example\r\n * // Run when count changes\r\n * const count = nixState(0);\r\n * nixEffect(() => {\r\n * console.log('Count is:', count.value);\r\n * }, [count.value]);\r\n * \r\n * @example\r\n * // Timer with cleanup\r\n * nixEffect(() => {\r\n * const timer = setInterval(() => console.log('tick'), 1000);\r\n * return () => clearInterval(timer);\r\n * }, []);\r\n * \r\n * @example\r\n * // Event listener with cleanup\r\n * nixEffect(() => {\r\n * const handler = (e) => console.log('clicked', e);\r\n * document.addEventListener('click', handler);\r\n * return () => document.removeEventListener('click', handler);\r\n * }, []);\r\n * \r\n * @throws {Error} If called outside a component context\r\n */\r\nexport function nixEffect(effect, deps = []) {\r\n const ctx = activeContext;\r\n if (!ctx) throw new Error(\"nixEffect() called outside component\");\r\n\r\n // Security: Validate effect function\r\n if (typeof effect !== 'function') {\r\n console.error('[nixEffect] First argument must be a function');\r\n return;\r\n }\r\n\r\n // Security: Validate deps array\r\n if (!Array.isArray(deps)) {\r\n console.error('[nixEffect] Second argument must be an array');\r\n deps = [];\r\n }\r\n\r\n // Security: Limit dependency array size to prevent DOS\r\n const MAX_DEPS = 100;\r\n if (deps.length > MAX_DEPS) {\r\n console.warn(`[nixEffect] Dependency array too large (${deps.length}). Limited to ${MAX_DEPS}.`);\r\n deps = deps.slice(0, MAX_DEPS);\r\n }\r\n\r\n const idx = ctx.hookIndex++;\r\n const prev = ctx.hooks[idx];\r\n\r\n // Performance & Security: Deep comparison instead of JSON.stringify\r\n // JSON.stringify issues:\r\n // 1. Can throw on circular references\r\n // 2. Fails on undefined, functions, symbols\r\n // 3. Performance issue with large objects\r\n // 4. Security: Can expose internal object structure\r\n const hasChanged = !prev || !shallowArrayEqual(prev.deps, deps);\r\n\r\n if (hasChanged) {\r\n // Memory Leak Fix: Clean up previous effect\r\n if (prev?.cleanup) {\r\n try {\r\n if (typeof prev.cleanup === 'function') {\r\n prev.cleanup();\r\n }\r\n } catch (err) {\r\n console.error('[nixEffect] Cleanup error:', err);\r\n }\r\n }\r\n\r\n // Run the new effect\r\n let cleanup;\r\n try {\r\n cleanup = effect();\r\n \r\n // Validate cleanup return value\r\n if (cleanup !== undefined && typeof cleanup !== 'function') {\r\n console.warn('[nixEffect] Effect should return undefined or a cleanup function');\r\n cleanup = undefined;\r\n }\r\n } catch (err) {\r\n console.error('[nixEffect] Effect error:', err);\r\n cleanup = undefined;\r\n }\r\n\r\n // Store effect data\r\n ctx.hooks[idx] = { deps, cleanup };\r\n\r\n // Memory Leak Fix: Track cleanup for component unmount\r\n if (cleanup && typeof cleanup === 'function') {\r\n if (!ctx.cleanups) ctx.cleanups = [];\r\n ctx.cleanups.push(cleanup);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Shallow comparison of two arrays for dependency checking.\r\n * More reliable and secure than JSON.stringify.\r\n * \r\n * @param {Array<any>} arr1 - First array\r\n * @param {Array<any>} arr2 - Second array\r\n * @returns {boolean} True if arrays are shallowly equal\r\n */\r\nfunction shallowArrayEqual(arr1, arr2) {\r\n if (arr1.length !== arr2.length) return false;\r\n \r\n for (let i = 0; i < arr1.length; i++) {\r\n // Use Object.is for proper comparison (handles NaN, -0, +0)\r\n if (!Object.is(arr1[i], arr2[i])) {\r\n return false;\r\n }\r\n }\r\n \r\n return true;\r\n}\r\n\r\n/**\r\n * Run an effect only once on component mount.\r\n * Convenience wrapper around nixEffect.\r\n * \r\n * @param {() => (void | (() => void))} effect - Effect function\r\n * \r\n * @example\r\n * nixEffectOnce(() => {\r\n * console.log('Mounted');\r\n * return () => console.log('Unmounted');\r\n * });\r\n */\r\nexport function nixEffectOnce(effect) {\r\n return nixEffect(effect, []);\r\n}\r\n\r\n/**\r\n * Run an effect every time the component renders.\r\n * Use with caution - can cause performance issues.\r\n * \r\n * @param {() => (void | (() => void))} effect - Effect function\r\n * \r\n * @example\r\n * nixEffectAlways(() => {\r\n * console.log('Component rendered');\r\n * });\r\n */\r\nexport function nixEffectAlways(effect) {\r\n const ctx = activeContext;\r\n if (!ctx) throw new Error(\"nixEffectAlways() called outside component\");\r\n \r\n if (typeof effect !== 'function') {\r\n console.error('[nixEffectAlways] Argument must be a function');\r\n return;\r\n }\r\n\r\n // Always run by using a unique dependency each time\r\n return nixEffect(effect, [ctx.version]);\r\n}"],
|
|
5
|
-
"mappings": "AAIA,SAAS,qBAAqB;AAwCvB,SAAS,UAAU,QAAQ,OAAO,CAAC,GAAG;AAC3C,QAAM,MAAM;AACZ,MAAI,CAAC;AAAK,UAAM,IAAI,MAAM,sCAAsC;AAGhE,MAAI,OAAO,WAAW,YAAY;AAChC,YAAQ,MAAM,+CAA+C;AAC7D;AAAA,EACF;AAGA,MAAI,CAAC,MAAM,QAAQ,IAAI,GAAG;AACxB,YAAQ,MAAM,8CAA8C;AAC5D,WA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AQ;AACpC,SAAO,UAAU,QAAQ,CAAC,CAAC;AAC7B;AAFgB;AAeT,SAAS,gBAAgB,QAAQ;AACtC,QAAM,MAAM;AACZ,MAAI,CAAC;AAAK,UAAM,IAAI,MAAM,4CAA4C;AAEtE,MAAI,OAAO,WAAW,YAAY;AAChC,YAAQ,MAAM,+CAA+C;AAC7D;AAAA,EACF;AAGA,SAAO,UAAU,QAAQ,CAAC,IAAI,OAAO,CAAC;AACxC;AAXgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reactive form handler with validation, reactive state, and safe async submit.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} [initialValues={}] - Initial values for form fields.
|
|
5
|
+
* @param {Object} [validationRules={}] - Validation rules for fields.
|
|
6
|
+
* @returns {Object} Form utilities: values, errors, touched, isSubmitting, isValid,
|
|
7
|
+
* handleChange, handleBlur, handleSubmit, reset, getFieldProps, cancelSubmit
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const form = nixForm({ email: "" }, {
|
|
11
|
+
* email: { required: true, pattern: /^\S+@\S+$/, message: "Invalid email" }
|
|
12
|
+
* });
|
|
13
|
+
* form.handleSubmit(async (values) => { await api.submit(values); });
|
|
14
|
+
*/
|
|
15
|
+
export function nixForm(initialValues?: any, validationRules?: any): any;
|
package/dist/hooks/nixForm.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
1
3
|
import { nixState } from "./nixState.js";
|
|
2
4
|
import { nixComputed } from "./nixComputed.js";
|
|
3
5
|
function nixForm(initialValues = {}, validationRules = {}) {
|
|
@@ -28,6 +30,7 @@ function nixForm(initialValues = {}, validationRules = {}) {
|
|
|
28
30
|
}
|
|
29
31
|
return null;
|
|
30
32
|
}
|
|
33
|
+
__name(validate, "validate");
|
|
31
34
|
function handleChange(fieldName, value) {
|
|
32
35
|
values.value = { ...values.value, [fieldName]: value };
|
|
33
36
|
if (touched.value[fieldName]) {
|
|
@@ -41,6 +44,7 @@ function nixForm(initialValues = {}, validationRules = {}) {
|
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
46
|
}
|
|
47
|
+
__name(handleChange, "handleChange");
|
|
44
48
|
function handleBlur(fieldName) {
|
|
45
49
|
touched.value = { ...touched.value, [fieldName]: true };
|
|
46
50
|
const error = validate(fieldName, values.value[fieldName]);
|
|
@@ -48,6 +52,7 @@ function nixForm(initialValues = {}, validationRules = {}) {
|
|
|
48
52
|
errors.value = { ...errors.value, [fieldName]: error };
|
|
49
53
|
}
|
|
50
54
|
}
|
|
55
|
+
__name(handleBlur, "handleBlur");
|
|
51
56
|
function validateAll() {
|
|
52
57
|
const newErrors = {};
|
|
53
58
|
Object.keys(validationRules).forEach((fieldName) => {
|
|
@@ -58,6 +63,7 @@ function nixForm(initialValues = {}, validationRules = {}) {
|
|
|
58
63
|
errors.value = newErrors;
|
|
59
64
|
return Object.keys(newErrors).length === 0;
|
|
60
65
|
}
|
|
66
|
+
__name(validateAll, "validateAll");
|
|
61
67
|
async function handleSubmit(onSubmit) {
|
|
62
68
|
const allTouched = Object.keys(validationRules).reduce((acc, key) => {
|
|
63
69
|
acc[key] = true;
|
|
@@ -82,12 +88,14 @@ function nixForm(initialValues = {}, validationRules = {}) {
|
|
|
82
88
|
isSubmitting.value = false;
|
|
83
89
|
}
|
|
84
90
|
}
|
|
91
|
+
__name(handleSubmit, "handleSubmit");
|
|
85
92
|
function cancelSubmit() {
|
|
86
93
|
if (abortController) {
|
|
87
94
|
abortController.abort();
|
|
88
95
|
abortController = null;
|
|
89
96
|
}
|
|
90
97
|
}
|
|
98
|
+
__name(cancelSubmit, "cancelSubmit");
|
|
91
99
|
function reset() {
|
|
92
100
|
values.value = { ...initialValues };
|
|
93
101
|
errors.value = {};
|
|
@@ -95,6 +103,7 @@ function nixForm(initialValues = {}, validationRules = {}) {
|
|
|
95
103
|
isSubmitting.value = false;
|
|
96
104
|
cancelSubmit();
|
|
97
105
|
}
|
|
106
|
+
__name(reset, "reset");
|
|
98
107
|
function getFieldProps(fieldName) {
|
|
99
108
|
return {
|
|
100
109
|
value: values.value[fieldName] || "",
|
|
@@ -102,6 +111,7 @@ function nixForm(initialValues = {}, validationRules = {}) {
|
|
|
102
111
|
"r-blur": () => handleBlur(fieldName)
|
|
103
112
|
};
|
|
104
113
|
}
|
|
114
|
+
__name(getFieldProps, "getFieldProps");
|
|
105
115
|
return {
|
|
106
116
|
values,
|
|
107
117
|
errors,
|
|
@@ -116,6 +126,7 @@ function nixForm(initialValues = {}, validationRules = {}) {
|
|
|
116
126
|
getFieldProps
|
|
117
127
|
};
|
|
118
128
|
}
|
|
129
|
+
__name(nixForm, "nixForm");
|
|
119
130
|
export {
|
|
120
131
|
nixForm
|
|
121
132
|
};
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../hooks/nixForm.js"],
|
|
4
4
|
"sourcesContent": ["// core/hooks/nixForm.js - Form handling utilities with memory-safe async support\r\nimport { nixState } from \"./nixState.js\";\r\nimport { nixComputed } from \"./nixComputed.js\";\r\n\r\n/**\r\n * Reactive form handler with validation, reactive state, and safe async submit.\r\n *\r\n * @param {Object} [initialValues={}] - Initial values for form fields.\r\n * @param {Object} [validationRules={}] - Validation rules for fields.\r\n * @returns {Object} Form utilities: values, errors, touched, isSubmitting, isValid,\r\n * handleChange, handleBlur, handleSubmit, reset, getFieldProps, cancelSubmit\r\n *\r\n * @example\r\n * const form = nixForm({ email: \"\" }, {\r\n * email: { required: true, pattern: /^\\S+@\\S+$/, message: \"Invalid email\" }\r\n * });\r\n * form.handleSubmit(async (values) => { await api.submit(values); });\r\n */\r\nexport function nixForm(initialValues = {}, validationRules = {}) {\r\n const values = nixState({ ...initialValues });\r\n const errors = nixState({});\r\n const touched = nixState({});\r\n const isSubmitting = nixState(false);\r\n\r\n const isValid = nixComputed(() => Object.keys(errors.value).length === 0);\r\n\r\n let abortController = null;\r\n\r\n function validate(fieldName, value) {\r\n const rules = validationRules[fieldName];\r\n if (!rules) return null;\r\n\r\n if (rules.required && !value) {\r\n return rules.message || `${fieldName} is required`;\r\n }\r\n if (rules.minLength && value.length < rules.minLength) {\r\n return rules.message || `${fieldName} must be at least ${rules.minLength} characters`;\r\n }\r\n if (rules.maxLength && value.length > rules.maxLength) {\r\n return rules.message || `${fieldName} must be at most ${rules.maxLength} characters`;\r\n }\r\n if (rules.pattern && !rules.pattern.test(value)) {\r\n return rules.message || `${fieldName} is invalid`;\r\n }\r\n if (rules.custom && !rules.custom(value, values.value)) {\r\n return rules.message || `${fieldName} is invalid`;\r\n }\r\n return null;\r\n }\r\n\r\n function handleChange(fieldName, value) {\r\n values.value = { ...values.value, [fieldName]: value };\r\n\r\n if (touched.value[fieldName]) {\r\n const error = validate(fieldName, value);\r\n if (error) {\r\n errors.value = { ...errors.value, [fieldName]: error };\r\n } else {\r\n const newErrors = { ...errors.value };\r\n delete newErrors[fieldName];\r\n errors.value = newErrors;\r\n }\r\n }\r\n }\r\n\r\n function handleBlur(fieldName) {\r\n touched.value = { ...touched.value, [fieldName]: true };\r\n const error = validate(fieldName, values.value[fieldName]);\r\n if (error) {\r\n errors.value = { ...errors.value, [fieldName]: error };\r\n }\r\n }\r\n\r\n function validateAll() {\r\n const newErrors = {};\r\n Object.keys(validationRules).forEach((fieldName) => {\r\n const error = validate(fieldName, values.value[fieldName]);\r\n if (error) newErrors[fieldName] = error;\r\n });\r\n errors.value = newErrors;\r\n return Object.keys(newErrors).length === 0;\r\n }\r\n\r\n /**\r\n * Submits the form safely with optional async support.\r\n * Cancels previous submission if running.\r\n *\r\n * @param {(values: Object, signal: AbortSignal) => Promise<void>} onSubmit - Async submit callback.\r\n */\r\n async function handleSubmit(onSubmit) {\r\n // Mark all fields as touched\r\n const allTouched = Object.keys(validationRules).reduce((acc, key) => {\r\n acc[key] = true;\r\n return acc;\r\n }, {});\r\n touched.value = allTouched;\r\n\r\n if (!validateAll()) return;\r\n\r\n // Cancel any ongoing submit\r\n if (abortController) abortController.abort();\r\n abortController = new AbortController();\r\n const signal = abortController.signal;\r\n\r\n isSubmitting.value = true;\r\n try {\r\n await onSubmit(values.value, signal);\r\n } catch (err) {\r\n if (err.name !== \"AbortError\") {\r\n console.error(\"[nixForm] Submission error:\", err);\r\n }\r\n } finally {\r\n if (!signal.aborted) isSubmitting.value = false;\r\n }\r\n }\r\n\r\n /**\r\n * Cancels any ongoing async submission.\r\n */\r\n function cancelSubmit() {\r\n if (abortController) {\r\n abortController.abort();\r\n abortController = null;\r\n }\r\n }\r\n\r\n function reset() {\r\n values.value = { ...initialValues };\r\n errors.value = {};\r\n touched.value = {};\r\n isSubmitting.value = false;\r\n cancelSubmit();\r\n }\r\n\r\n function getFieldProps(fieldName) {\r\n return {\r\n value: values.value[fieldName] || \"\",\r\n \"r-input\": (e) => handleChange(fieldName, e.target.value),\r\n \"r-blur\": () => handleBlur(fieldName),\r\n };\r\n }\r\n\r\n return {\r\n values,\r\n errors,\r\n touched,\r\n isSubmitting,\r\n isValid,\r\n handleChange,\r\n handleBlur,\r\n handleSubmit,\r\n cancelSubmit,\r\n reset,\r\n getFieldProps,\r\n };\r\n}\r\n"],
|
|
5
|
-
"mappings": "AACA,SAAS,gBAAgB;AACzB,SAAS,mBAAmB;AAgBrB,SAAS,QAAQ,gBAAgB,CAAC,GAAG,kBAAkB,CAAC,GAAG;AAChE,QAAM,SAAS,SAAS,EAAE,GAAG,cAAc,CAAC;AAC5C,QAAM,SAAS,SAAS,CAAC,CAAC;AAC1B,QAAM,UAAU,SAAS,CAAC,CAAC;AAC3B,QAAM,eAAe,SAAS,KAAK;AAEnC,QAAM,UAAU,YAAY,MAAM,OAAO,KAAK,OAAO,KAAK,EAAE,WAAW,CAAC;AAExE,MAAI,kBAAkB;AAEtB,WAAS,SAAS,WAAW,OAAO;AAClC,U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IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAzIgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Full-featured reactive form with debounced async API submission.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} [initialValues={}] - Initial field values.
|
|
5
|
+
* @param {Object} [validationRules={}] - Validation rules for each field.
|
|
6
|
+
* @param {Object} [options={}] - Async submit options.
|
|
7
|
+
* @param {number} [options.delay=300] - Debounce delay in ms.
|
|
8
|
+
* @param {boolean} [options.leading=false] - Invoke submit on leading edge.
|
|
9
|
+
* @param {boolean} [options.trailing=true] - Invoke submit on trailing edge.
|
|
10
|
+
* @param {number} [options.maxWait] - Maximum wait time before forced invocation.
|
|
11
|
+
* @param {boolean} [options.cache=true] - Cache last submission result.
|
|
12
|
+
* @returns {Object} Form API with state, validation, and debounced async submission.
|
|
13
|
+
*/
|
|
14
|
+
export function nixFormAsync(initialValues?: any, validationRules?: any, options?: {
|
|
15
|
+
delay?: number;
|
|
16
|
+
leading?: boolean;
|
|
17
|
+
trailing?: boolean;
|
|
18
|
+
maxWait?: number;
|
|
19
|
+
cache?: boolean;
|
|
20
|
+
}): any;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
1
3
|
import { nixState } from "./nixState.js";
|
|
2
4
|
import { nixComputed } from "./nixComputed.js";
|
|
3
5
|
function nixFormAsync(initialValues = {}, validationRules = {}, options = {}) {
|
|
@@ -32,6 +34,7 @@ function nixFormAsync(initialValues = {}, validationRules = {}, options = {}) {
|
|
|
32
34
|
return rules.message || `${fieldName} is invalid`;
|
|
33
35
|
return null;
|
|
34
36
|
}
|
|
37
|
+
__name(validate, "validate");
|
|
35
38
|
function handleChange(fieldName, value) {
|
|
36
39
|
values.value = { ...values.value, [fieldName]: value };
|
|
37
40
|
if (touched.value[fieldName]) {
|
|
@@ -45,12 +48,14 @@ function nixFormAsync(initialValues = {}, validationRules = {}, options = {}) {
|
|
|
45
48
|
}
|
|
46
49
|
}
|
|
47
50
|
}
|
|
51
|
+
__name(handleChange, "handleChange");
|
|
48
52
|
function handleBlur(fieldName) {
|
|
49
53
|
touched.value = { ...touched.value, [fieldName]: true };
|
|
50
54
|
const err = validate(fieldName, values.value[fieldName]);
|
|
51
55
|
if (err)
|
|
52
56
|
errors.value = { ...errors.value, [fieldName]: err };
|
|
53
57
|
}
|
|
58
|
+
__name(handleBlur, "handleBlur");
|
|
54
59
|
function validateAll() {
|
|
55
60
|
const newErrors = {};
|
|
56
61
|
Object.keys(validationRules).forEach((fieldName) => {
|
|
@@ -61,6 +66,7 @@ function nixFormAsync(initialValues = {}, validationRules = {}, options = {}) {
|
|
|
61
66
|
errors.value = newErrors;
|
|
62
67
|
return Object.keys(newErrors).length === 0;
|
|
63
68
|
}
|
|
69
|
+
__name(validateAll, "validateAll");
|
|
64
70
|
async function invokeAsync(onSubmit) {
|
|
65
71
|
if (cache && lastResult !== null) {
|
|
66
72
|
data.value = lastResult;
|
|
@@ -93,6 +99,7 @@ function nixFormAsync(initialValues = {}, validationRules = {}, options = {}) {
|
|
|
93
99
|
lastInvokeTime = Date.now();
|
|
94
100
|
}
|
|
95
101
|
}
|
|
102
|
+
__name(invokeAsync, "invokeAsync");
|
|
96
103
|
function handleSubmit(onSubmit) {
|
|
97
104
|
if (!validateAll())
|
|
98
105
|
return;
|
|
@@ -117,6 +124,7 @@ function nixFormAsync(initialValues = {}, validationRules = {}, options = {}) {
|
|
|
117
124
|
}, remainingTime > 0 ? remainingTime : delay);
|
|
118
125
|
}
|
|
119
126
|
}
|
|
127
|
+
__name(handleSubmit, "handleSubmit");
|
|
120
128
|
function cancelSubmit() {
|
|
121
129
|
if (abortController) {
|
|
122
130
|
abortController.abort();
|
|
@@ -126,6 +134,7 @@ function nixFormAsync(initialValues = {}, validationRules = {}, options = {}) {
|
|
|
126
134
|
clearTimeout(timerId);
|
|
127
135
|
timerId = null;
|
|
128
136
|
}
|
|
137
|
+
__name(cancelSubmit, "cancelSubmit");
|
|
129
138
|
function reset() {
|
|
130
139
|
values.value = { ...initialValues };
|
|
131
140
|
errors.value = {};
|
|
@@ -136,6 +145,7 @@ function nixFormAsync(initialValues = {}, validationRules = {}, options = {}) {
|
|
|
136
145
|
error.value = null;
|
|
137
146
|
loading.value = false;
|
|
138
147
|
}
|
|
148
|
+
__name(reset, "reset");
|
|
139
149
|
function getFieldProps(fieldName) {
|
|
140
150
|
return {
|
|
141
151
|
value: values.value[fieldName] || "",
|
|
@@ -143,6 +153,7 @@ function nixFormAsync(initialValues = {}, validationRules = {}, options = {}) {
|
|
|
143
153
|
"r-blur": () => handleBlur(fieldName)
|
|
144
154
|
};
|
|
145
155
|
}
|
|
156
|
+
__name(getFieldProps, "getFieldProps");
|
|
146
157
|
return {
|
|
147
158
|
values,
|
|
148
159
|
errors,
|
|
@@ -160,6 +171,7 @@ function nixFormAsync(initialValues = {}, validationRules = {}, options = {}) {
|
|
|
160
171
|
getFieldProps
|
|
161
172
|
};
|
|
162
173
|
}
|
|
174
|
+
__name(nixFormAsync, "nixFormAsync");
|
|
163
175
|
export {
|
|
164
176
|
nixFormAsync
|
|
165
177
|
};
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../hooks/nixFormAsync.js"],
|
|
4
4
|
"sourcesContent": ["// core/hooks/nixFormAsync.js\r\nimport { nixState } from \"./nixState.js\";\r\nimport { nixComputed } from \"./nixComputed.js\";\r\n\r\n/**\r\n * Full-featured reactive form with debounced async API submission.\r\n *\r\n * @param {Object} [initialValues={}] - Initial field values.\r\n * @param {Object} [validationRules={}] - Validation rules for each field.\r\n * @param {Object} [options={}] - Async submit options.\r\n * @param {number} [options.delay=300] - Debounce delay in ms.\r\n * @param {boolean} [options.leading=false] - Invoke submit on leading edge.\r\n * @param {boolean} [options.trailing=true] - Invoke submit on trailing edge.\r\n * @param {number} [options.maxWait] - Maximum wait time before forced invocation.\r\n * @param {boolean} [options.cache=true] - Cache last submission result.\r\n * @returns {Object} Form API with state, validation, and debounced async submission.\r\n */\r\nexport function nixFormAsync(initialValues = {}, validationRules = {}, options = {}) {\r\n // Form state\r\n const values = nixState({ ...initialValues });\r\n const errors = nixState({});\r\n const touched = nixState({});\r\n const isSubmitting = nixState(false);\r\n const isValid = nixComputed(() => Object.keys(errors.value).length === 0);\r\n\r\n // Async submit state\r\n const { delay = 300, leading = false, trailing = true, maxWait, cache = true } = options;\r\n const data = nixState(null);\r\n const error = nixState(null);\r\n const loading = nixState(false);\r\n\r\n let abortController = null;\r\n let timerId = null;\r\n let lastInvokeTime = 0;\r\n let lastResult = null;\r\n let lastError = null;\r\n let pendingPromise = null;\r\n\r\n /** ------------------------ Validation ------------------------ */\r\n function validate(fieldName, value) {\r\n const rules = validationRules[fieldName];\r\n if (!rules) return null;\r\n\r\n if (rules.required && !value) return rules.message || `${fieldName} is required`;\r\n if (rules.minLength && value.length < rules.minLength)\r\n return rules.message || `${fieldName} must be at least ${rules.minLength} characters`;\r\n if (rules.maxLength && value.length > rules.maxLength)\r\n return rules.message || `${fieldName} must be at most ${rules.maxLength} characters`;\r\n if (rules.pattern && !rules.pattern.test(value))\r\n return rules.message || `${fieldName} is invalid`;\r\n if (rules.custom && !rules.custom(value, values.value))\r\n return rules.message || `${fieldName} is invalid`;\r\n\r\n return null;\r\n }\r\n\r\n function handleChange(fieldName, value) {\r\n values.value = { ...values.value, [fieldName]: value };\r\n\r\n if (touched.value[fieldName]) {\r\n const err = validate(fieldName, value);\r\n if (err) errors.value = { ...errors.value, [fieldName]: err };\r\n else {\r\n const newErrors = { ...errors.value };\r\n delete newErrors[fieldName];\r\n errors.value = newErrors;\r\n }\r\n }\r\n }\r\n\r\n function handleBlur(fieldName) {\r\n touched.value = { ...touched.value, [fieldName]: true };\r\n const err = validate(fieldName, values.value[fieldName]);\r\n if (err) errors.value = { ...errors.value, [fieldName]: err };\r\n }\r\n\r\n function validateAll() {\r\n const newErrors = {};\r\n Object.keys(validationRules).forEach((fieldName) => {\r\n const err = validate(fieldName, values.value[fieldName]);\r\n if (err) newErrors[fieldName] = err;\r\n });\r\n errors.value = newErrors;\r\n return Object.keys(newErrors).length === 0;\r\n }\r\n\r\n /** ------------------------ Debounced Async Submit ------------------------ */\r\n async function invokeAsync(onSubmit) {\r\n // Use cache if available\r\n if (cache && lastResult !== null) {\r\n data.value = lastResult;\r\n error.value = lastError;\r\n loading.value = false;\r\n return lastResult;\r\n }\r\n\r\n // Cancel any ongoing submit\r\n if (abortController) abortController.abort();\r\n abortController = new AbortController();\r\n const signal = abortController.signal;\r\n\r\n loading.value = true;\r\n error.value = null;\r\n\r\n pendingPromise = onSubmit(values.value, signal);\r\n\r\n try {\r\n const result = await pendingPromise;\r\n lastResult = result;\r\n data.value = result;\r\n return result;\r\n } catch (err) {\r\n if (err.name !== \"AbortError\") {\r\n lastError = err;\r\n error.value = err;\r\n console.error(\"[nixFormAsync] submit error:\", err);\r\n }\r\n throw err;\r\n } finally {\r\n loading.value = false;\r\n pendingPromise = null;\r\n lastInvokeTime = Date.now();\r\n }\r\n }\r\n\r\n function handleSubmit(onSubmit) {\r\n if (!validateAll()) return;\r\n\r\n const now = Date.now();\r\n const timeSinceLastInvoke = now - lastInvokeTime;\r\n const remainingTime = delay - timeSinceLastInvoke;\r\n const shouldInvokeLeading = leading && !timerId;\r\n\r\n if (maxWait !== undefined && timeSinceLastInvoke >= maxWait) {\r\n if (timerId) clearTimeout(timerId);\r\n timerId = null;\r\n return invokeAsync(onSubmit);\r\n }\r\n\r\n if (timerId) clearTimeout(timerId);\r\n\r\n if (shouldInvokeLeading) return invokeAsync(onSubmit);\r\n\r\n if (trailing) {\r\n timerId = setTimeout(() => {\r\n timerId = null;\r\n invokeAsync(onSubmit);\r\n }, remainingTime > 0 ? remainingTime : delay);\r\n }\r\n }\r\n\r\n /** Cancel ongoing submit */\r\n function cancelSubmit() {\r\n if (abortController) {\r\n abortController.abort();\r\n abortController = null;\r\n }\r\n if (timerId) clearTimeout(timerId);\r\n timerId = null;\r\n }\r\n\r\n /** Reset form and cancel pending submit */\r\n function reset() {\r\n values.value = { ...initialValues };\r\n errors.value = {};\r\n touched.value = {};\r\n isSubmitting.value = false;\r\n cancelSubmit();\r\n data.value = null;\r\n error.value = null;\r\n loading.value = false;\r\n }\r\n\r\n function getFieldProps(fieldName) {\r\n return {\r\n value: values.value[fieldName] || \"\",\r\n \"r-input\": (e) => handleChange(fieldName, e.target.value),\r\n \"r-blur\": () => handleBlur(fieldName),\r\n };\r\n }\r\n\r\n return {\r\n values,\r\n errors,\r\n touched,\r\n isSubmitting,\r\n isValid,\r\n data,\r\n error,\r\n loading,\r\n handleChange,\r\n handleBlur,\r\n handleSubmit,\r\n cancelSubmit,\r\n reset,\r\n getFieldProps,\r\n };\r\n}\r\n"],
|
|
5
|
-
"mappings": "AACA,SAAS,gBAAgB;AACzB,SAAS,mBAAmB;AAerB,SAAS,aAAa,gBAAgB,CAAC,GAAG,kBAAkB,CAAC,GAAG,UAAU,CAAC,GAAG;AAEnF,QAAM,SAAS,SAAS,EAAE,GAAG,cAAc,CAAC;AAC5C,QAAM,SAAS,SAAS,CAAC,CAAC;AAC1B,QAAM,UAAU,SAAS,CAAC,CAAC;AAC3B,QAAM,eAAe,SAAS,KAAK;AACnC,QAAM,UAAU,YAAY,MAAM,OAAO,KAAK,OAAO,KAAK,EAAE,WAAW,CAAC;AAGxE,QAAM,EAAE,QAAQ,KAAK,UAAU,OAAO,WAAW,MAAM,SAAS,QAAQ,KAAK,IAAI;AACjF,QAAM,OAAO,SAAS,IAAI;AAC1B,QAAM,QAAQ,SAAS,IAAI;AAC3B,QAAM,UAAU,SAAS,KAAK;AAE9B,MAAI,kBAAkB;AACtB,MAAI,UAAU;AACd,MAAI,iBAAiB;AACrB,MAAI,aA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