frosty 0.0.158 → 0.0.159

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 (108) hide show
  1. package/dist/_native.d.mts +3 -3
  2. package/dist/_native.d.mts.map +1 -1
  3. package/dist/_native.d.ts +3 -3
  4. package/dist/_native.d.ts.map +1 -1
  5. package/dist/_native.js +5 -5
  6. package/dist/_native.js.map +1 -1
  7. package/dist/_native.mjs +4 -4
  8. package/dist/dom.d.mts +3 -3
  9. package/dist/dom.d.mts.map +1 -1
  10. package/dist/dom.d.ts +3 -3
  11. package/dist/dom.d.ts.map +1 -1
  12. package/dist/dom.js +4 -4
  13. package/dist/dom.mjs +4 -4
  14. package/dist/i18n.d.mts.map +1 -1
  15. package/dist/i18n.d.ts.map +1 -1
  16. package/dist/i18n.js +3 -3
  17. package/dist/i18n.mjs +3 -3
  18. package/dist/index.d.mts +4 -4
  19. package/dist/index.d.mts.map +1 -1
  20. package/dist/index.d.ts +4 -4
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +7 -7
  23. package/dist/index.mjs +7 -7
  24. package/dist/internals/{callback-DEKCuARB.mjs → callback-8cBbAwKI.mjs} +3 -3
  25. package/dist/internals/{callback-DEKCuARB.mjs.map → callback-8cBbAwKI.mjs.map} +1 -1
  26. package/dist/internals/{callback-DVD1MTA9.js → callback-l1HafY8p.js} +2 -2
  27. package/dist/internals/{callback-DVD1MTA9.js.map → callback-l1HafY8p.js.map} +1 -1
  28. package/dist/internals/{common-BMp06ZN_.d.mts → common-uQrs1G5-.d.mts} +2 -2
  29. package/dist/internals/common-uQrs1G5-.d.mts.map +1 -0
  30. package/dist/internals/{common-BMp06ZN_.d.ts → common-uQrs1G5-.d.ts} +2 -2
  31. package/dist/internals/common-uQrs1G5-.d.ts.map +1 -0
  32. package/dist/internals/{form-CC8A5nkh.js → form-CgyPc937.js} +3 -3
  33. package/dist/internals/{form-CC8A5nkh.js.map → form-CgyPc937.js.map} +1 -1
  34. package/dist/internals/{form-Cee86QUZ.mjs → form-DAr0GAYA.mjs} +3 -3
  35. package/dist/internals/{form-Cee86QUZ.mjs.map → form-DAr0GAYA.mjs.map} +1 -1
  36. package/dist/internals/{runtime-Bpq-U9sI.mjs → fragment-DnpshXqL.mjs} +32 -32
  37. package/dist/internals/fragment-DnpshXqL.mjs.map +1 -0
  38. package/dist/internals/{fragment-Dhp_GJso.d.mts → fragment-DuyNMgL3.d.mts} +2 -2
  39. package/dist/internals/fragment-DuyNMgL3.d.mts.map +1 -0
  40. package/dist/internals/{fragment-C8nMwgq0.d.ts → fragment-HkiF2xeJ.d.ts} +2 -2
  41. package/dist/internals/fragment-HkiF2xeJ.d.ts.map +1 -0
  42. package/dist/internals/{runtime-CeVOFcK_.js → fragment-JOzjl1Lc.js} +32 -32
  43. package/dist/internals/fragment-JOzjl1Lc.js.map +1 -0
  44. package/dist/internals/{index-Bvwj3lIq.js → index-BnS7TiLo.js} +52 -52
  45. package/dist/internals/{index-Bvwj3lIq.js.map → index-BnS7TiLo.js.map} +1 -1
  46. package/dist/internals/{index-CUCYNdr9.d.ts → index-CdMvWgIS.d.ts} +3 -3
  47. package/dist/internals/index-CdMvWgIS.d.ts.map +1 -0
  48. package/dist/internals/{index-CODWK-gF.mjs → index-CoURz_S4.mjs} +50 -50
  49. package/dist/internals/{index-CODWK-gF.mjs.map → index-CoURz_S4.mjs.map} +1 -1
  50. package/dist/internals/{index-CgIOFVc1.d.mts → index-D_01nFU0.d.mts} +3 -3
  51. package/dist/internals/index-D_01nFU0.d.mts.map +1 -0
  52. package/dist/internals/{renderer-C5NIsxDg.js → renderer-CRX8gzMA.js} +5 -5
  53. package/dist/internals/{renderer-C5NIsxDg.js.map → renderer-CRX8gzMA.js.map} +1 -1
  54. package/dist/internals/{renderer-DaX4zUo8.mjs → renderer-CoINnhjj.mjs} +3 -3
  55. package/dist/internals/{renderer-DaX4zUo8.mjs.map → renderer-CoINnhjj.mjs.map} +1 -1
  56. package/dist/internals/{renderer-DR_CVQzd.js → renderer-CoiNiH-1.js} +4 -4
  57. package/dist/internals/{renderer-DR_CVQzd.js.map → renderer-CoiNiH-1.js.map} +1 -1
  58. package/dist/internals/{renderer-BFv842Qz.d.ts → renderer-DWRFEffh.d.ts} +3 -3
  59. package/dist/internals/renderer-DWRFEffh.d.ts.map +1 -0
  60. package/dist/internals/{renderer-BvM6i6Cl.mjs → renderer-DXQYsBvG.mjs} +4 -4
  61. package/dist/internals/{renderer-BvM6i6Cl.mjs.map → renderer-DXQYsBvG.mjs.map} +1 -1
  62. package/dist/internals/{renderer-5Al4VWW1.d.mts → renderer-Qq2yni7e.d.mts} +3 -3
  63. package/dist/internals/renderer-Qq2yni7e.d.mts.map +1 -0
  64. package/dist/internals/{utils-BGg0L3IY.d.ts → utils-DeZcxzm0.d.ts} +2 -2
  65. package/dist/internals/utils-DeZcxzm0.d.ts.map +1 -0
  66. package/dist/internals/{utils-qS8tRYZD.d.mts → utils-LlN8w8CJ.d.mts} +2 -2
  67. package/dist/internals/utils-LlN8w8CJ.d.mts.map +1 -0
  68. package/dist/jsx-dev-runtime.d.mts +2 -2
  69. package/dist/jsx-dev-runtime.d.mts.map +1 -1
  70. package/dist/jsx-dev-runtime.d.ts +2 -2
  71. package/dist/jsx-dev-runtime.d.ts.map +1 -1
  72. package/dist/jsx-dev-runtime.js +2 -2
  73. package/dist/jsx-dev-runtime.mjs +1 -1
  74. package/dist/jsx-runtime.d.mts +2 -2
  75. package/dist/jsx-runtime.d.mts.map +1 -1
  76. package/dist/jsx-runtime.d.ts +2 -2
  77. package/dist/jsx-runtime.d.ts.map +1 -1
  78. package/dist/jsx-runtime.js +4 -4
  79. package/dist/jsx-runtime.js.map +1 -1
  80. package/dist/jsx-runtime.mjs +2 -2
  81. package/dist/server-dom.d.mts +3 -3
  82. package/dist/server-dom.d.mts.map +1 -1
  83. package/dist/server-dom.d.ts +3 -3
  84. package/dist/server-dom.d.ts.map +1 -1
  85. package/dist/server-dom.js +4 -4
  86. package/dist/server-dom.mjs +4 -4
  87. package/dist/web.d.mts +3 -3
  88. package/dist/web.d.mts.map +1 -1
  89. package/dist/web.d.ts +3 -3
  90. package/dist/web.d.ts.map +1 -1
  91. package/dist/web.js +6 -6
  92. package/dist/web.mjs +7 -7
  93. package/package.json +12 -12
  94. package/packages/frosty-cli/package.json +13 -13
  95. package/packages/frosty-cli/webpack.mjs +5 -5
  96. package/packages/frosty-cli/yarn.lock +1181 -1404
  97. package/dist/internals/common-BMp06ZN_.d.mts.map +0 -1
  98. package/dist/internals/common-BMp06ZN_.d.ts.map +0 -1
  99. package/dist/internals/fragment-C8nMwgq0.d.ts.map +0 -1
  100. package/dist/internals/fragment-Dhp_GJso.d.mts.map +0 -1
  101. package/dist/internals/index-CUCYNdr9.d.ts.map +0 -1
  102. package/dist/internals/index-CgIOFVc1.d.mts.map +0 -1
  103. package/dist/internals/renderer-5Al4VWW1.d.mts.map +0 -1
  104. package/dist/internals/renderer-BFv842Qz.d.ts.map +0 -1
  105. package/dist/internals/runtime-Bpq-U9sI.mjs.map +0 -1
  106. package/dist/internals/runtime-CeVOFcK_.js.map +0 -1
  107. package/dist/internals/utils-BGg0L3IY.d.ts.map +0 -1
  108. package/dist/internals/utils-qS8tRYZD.d.mts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"form-CC8A5nkh.js","sources":["../../../src/core/hooks/state.ts","../../../src/core/hooks/misc/activity.tsx","../../../src/core/hooks/effect.ts","../../../src/core/hooks/storage.ts","../../../src/core/hooks/misc/resource/error.tsx","../../../src/core/hooks/sync.ts","../../../src/core/hooks/misc/form.ts"],"sourcesContent":["//\n// memo.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { _useMemo } from '../reconciler/hooks';\nimport { SetStateAction } from '../types/common';\n\n/**\n * A hook function for managing state within a custom framework or library.\n *\n * @template T - The type of the state value.\n * @param - The initial state value or a function that returns the initial state.\n * @returns - A tuple containing the current state value and a function to update the state.\n *\n * The `useState` function provides a way to manage stateful values. It returns the current state\n * and a setter function that can update the state. The setter function accepts either a new value\n * or a function that receives the current state and returns the updated state.\n *\n * Example:\n * ```typescript\n * const [count, setCount] = useState(0);\n * setCount(5); // Updates the state to 5\n * setCount(prev => prev + 1); // Updates the state to the previous value + 1\n * ```\n */\nexport function useState<T>(initialState: T | (() => T)): [T, (dispatch: SetStateAction<T>) => void];\nexport function useState<T = undefined>(): [T | undefined, (dispatch: SetStateAction<T | undefined>) => void];\n\nexport function useState(initialState?: any) {\n const { value, setValue } = _useMemo('useState', (_state) => {\n const state = {\n value: _.isFunction(initialState) ? initialState() : initialState,\n setValue: (dispatch: SetStateAction<any>) => {\n const oldValue = state.value;\n const newValue = _.isFunction(dispatch) ? dispatch(oldValue) : dispatch;\n if (oldValue === newValue) return;\n state.value = newValue;\n _state.setDirty();\n },\n };\n return state;\n }, null);\n return [value, setValue];\n}\n","//\n// activity.tsx\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Awaitable } from '@o2ter/utils-js';\nimport { useState } from '../state';\nimport { ElementNode, SetStateAction } from '../../types/common';\nimport { Context, createContext, useContext } from '../context';\nimport { createCache, uniqueId } from '../../utils';\nimport { useMemo } from '../memo';\n\ntype ActivityContextValue = {\n setTasks: (dispatch: SetStateAction<string[]>) => void;\n defaultDelay: number;\n};\n\nconst contextMap: WeakMap<any, Context<ActivityContextValue>> = new WeakMap();\nconst dispatchCache = createCache();\n\n/**\n * Creates an activity tracking component that monitors and counts active asynchronous tasks.\n * Returns a component that provides an activity context and renders children with the current task count.\n * \n * @param options - Configuration options for the activity tracker.\n * @param options.defaultDelay - Default delay in milliseconds before a task is considered active.\n * Defaults to 250ms. Set to 0 for immediate tracking.\n * \n * @returns A component that accepts `defaultDelay` (optional override) and `children` \n * (a render function that receives the number of active tasks).\n * \n * @example\n * ```tsx\n * const ActivityIndicator = createActivity({ defaultDelay: 300 });\n * \n * function App() {\n * return (\n * <ActivityIndicator>\n * {(taskCount) => (\n * <div>\n * {taskCount > 0 && <Spinner />}\n * <MyContent />\n * </div>\n * )}\n * </ActivityIndicator>\n * );\n * }\n * ```\n */\nexport const createActivity = ({\n defaultDelay: _defaultDelay = 250,\n}: {\n defaultDelay?: number;\n} = {}) => {\n const Context = createContext<ActivityContextValue>({\n setTasks: () => { },\n defaultDelay: _defaultDelay,\n });\n const component = ({\n defaultDelay = _defaultDelay,\n children,\n }: {\n defaultDelay?: number;\n children: ((tasks: number) => ElementNode);\n }) => {\n const [tasks, setTasks] = useState<string[]>([]);\n const value = useMemo(() => ({ setTasks, defaultDelay }), []);\n return (\n <Context value={value}>\n {children(tasks.length)}\n </Context>\n );\n };\n contextMap.set(component, Context);\n return component;\n};\n\n/**\n * A hook that returns a wrapper function for tracking asynchronous operations as active tasks.\n * Tasks are registered in the activity context created by `createActivity`, allowing parent\n * components to show loading indicators based on the number of active tasks.\n * \n * @template T - The return type of the callback function.\n * @param component - The activity component created by `createActivity`.\n * \n * @returns An async wrapper function that accepts a callback and optional delay override.\n * The wrapper executes the callback while tracking it as an active task.\n * \n * @throws {Error} If the provided component was not created by `createActivity`.\n * \n * @example\n * ```tsx\n * const ActivityIndicator = createActivity({ defaultDelay: 250 });\n * \n * function MyComponent() {\n * const trackActivity = useActivity(ActivityIndicator);\n * \n * const handleClick = async () => {\n * // Task is tracked after 250ms delay (default)\n * const result = await trackActivity(async () => {\n * const response = await fetch('/api/data');\n * return response.json();\n * });\n * console.log(result);\n * };\n * \n * const handleUrgent = async () => {\n * // Task is tracked immediately (0ms delay)\n * await trackActivity(async () => {\n * await criticalOperation();\n * }, 0);\n * };\n * \n * return <button onClick={handleClick}>Load Data</button>;\n * }\n * ```\n */\nexport const useActivity = (component: ReturnType<typeof createActivity>) => {\n const context = contextMap.get(component);\n if (!context) throw new Error('Invalid activity component');\n const store = useContext(context);\n return dispatchCache(store, () => async <T extends any>(callback: () => Awaitable<T>, delay?: number) => {\n const id = uniqueId();\n let timeout;\n const _delay = delay ?? store.defaultDelay;\n if (_.isNumber(_delay) && _delay > 0) {\n timeout = setTimeout(() => {\n store.setTasks(tasks => [...tasks, id]);\n }, _delay);\n } else {\n store.setTasks(tasks => [...tasks, id]);\n }\n try {\n return await callback();\n } finally {\n if (timeout) clearTimeout(timeout);\n store.setTasks(tasks => _.filter(tasks, x => x !== id));\n }\n });\n};","//\n// effect.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Awaitable } from '@o2ter/utils-js';\nimport { _useEffect } from '../reconciler/hooks';\n\n/**\n * A hook that manages side effects with support for an `AbortSignal`.\n * It ensures proper cleanup logic and handles asynchronous operations effectively.\n *\n * **Use `useEffect` for:**\n * - Registering and cleaning up event listeners\n * - Synchronizing with external APIs/events (browser APIs, third-party libraries)\n * - Performing actions on component mount/unmount\n * - Imperative operations (e.g., focus management, animations, logging)\n *\n * **Do NOT use `useEffect` for:**\n * - Computing UI state → Use `useMemo` instead\n * - Fetching data → Use `useResource` or `useServerResource` instead\n * - Subscribing to external stores → Use `useSyncExternalStore` instead\n * - Deriving state from props → Use `useMemo` or compute during render\n *\n * @param effect - \n * A function that receives an `AbortSignal` and performs side effects. \n * It can optionally return a cleanup function or a promise that resolves to a cleanup function.\n *\n * @param deps - \n * An optional dependencies array that determines when the effect should be re-executed.\n *\n * @example\n * // Register a window event listener\n * useEffect((signal) => {\n * const handleResize = () => {\n * console.log('Window resized:', window.innerWidth);\n * };\n * \n * window.addEventListener('resize', handleResize, { signal });\n * \n * // Cleanup happens automatically via AbortSignal\n * // Optional: return additional cleanup logic if needed\n * return () => {\n * console.log('Component unmounting');\n * };\n * }, []);\n *\n * @example\n * // Perform side effects on mount/unmount\n * useEffect((signal) => {\n * console.log('Component mounted');\n * \n * // Perform initialization work\n * document.title = 'My App';\n * \n * return () => {\n * console.log('Component unmounting, cleanup here');\n * };\n * }, []);\n */\nexport const useEffect = (\n effect: (\n signal: AbortSignal,\n ) => Awaitable<void | (() => Awaitable<void>)>,\n deps?: any,\n) => _useEffect('useEffect', () => {\n const abort = new AbortController();\n try {\n const destructor = effect(abort.signal);\n return () => {\n abort.abort();\n (async () => {\n try {\n const _destructor = await destructor;\n if (_.isFunction(_destructor)) _destructor();\n } catch (e) {\n console.error(e);\n }\n })();\n };\n } catch (e) {\n console.error(e);\n return () => abort.abort();\n }\n}, deps);","//\n// storage.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { reconciler } from '../reconciler';\n\nconst storage = new WeakMap<any, Map<any, any>>();\n\n/**\n * Returns a persistent storage Map associated with the current renderer instance.\n * This hook allows components to store and retrieve values that persist across renders,\n * scoped to the renderer. Must be called within a render function.\n *\n * @throws Error if called outside of a render function.\n * @returns {Map<any, any>} The storage map for the current renderer.\n */\nexport const useRendererStorage = (\n persist = true\n) => {\n const state = reconciler.currentHookState;\n if (!state) throw Error('useRendererStorage must be used within a render function.');\n if (!persist) return state.renderer.renderStorage;\n const found = storage.get(state.renderer);\n const store = found ?? new Map<any, any>();\n if (!found) storage.set(state.renderer, store);\n return store;\n};\n","//\n// error.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Awaitable } from '@o2ter/utils-js';\nimport { ComponentType, PropsWithChildren, SetStateAction } from '../../../types/common';\nimport { createContext } from '../../context';\nimport { useContext } from '../../context';\nimport { useState } from '../../state';\nimport { useMemo } from '../../memo';\nimport { useRendererStorage } from '../../storage';\n\ntype Errors = {\n token: string;\n error: any;\n refresh: () => Awaitable<void>;\n refreshing: boolean;\n loading: boolean;\n}[];\n\ntype ContextValue = {\n errors: Errors;\n setErrors: (values: SetStateAction<Errors>) => void;\n};\n\nconst defaultStorageKey = Symbol();\nconst Context = createContext<ContextValue>();\n\n/**\n * A context provider component for managing asynchronous resource errors.\n * \n * This component provides a shared context for tracking errors encountered during\n * asynchronous operations. It allows child components to access and manage these errors\n * using the `useResourceErrors` hook.\n * \n * ### Usage:\n * Wrap your application or specific parts of it with this component to enable error tracking:\n * \n * ```tsx\n * <ResourceErrors>\n * <YourComponent />\n * </ResourceErrors>\n * ```\n * \n * @param children - The child components that will have access to the error context.\n * \n * @returns A context provider that wraps the provided children.\n */\nexport const ResourceErrors: ComponentType<PropsWithChildren<{}>> = ({\n children\n}) => {\n const [errors, setErrors] = useState<Errors>([]);\n const value = useMemo(() => ({ errors, setErrors }), [errors, setErrors]);\n return (\n <Context value={value}>{children}</Context>\n );\n}\n\nexport const useErrorContext = () => {\n const value = useContext(Context);\n if (value) return value;\n const storage = useRendererStorage();\n const found = storage.get(defaultStorageKey);\n if (found) return found as ContextValue;\n const store: ContextValue = {\n errors: [],\n setErrors: (values: SetStateAction<Errors>) => {\n store.errors = _.isFunction(values) ? values(store.errors) : values;\n },\n };\n storage.set(defaultStorageKey, store);\n return store;\n};\n\n/**\n * A hook to access the list of asynchronous resource errors.\n * \n * This hook allows components to retrieve the current list of errors being tracked\n * in the `ResourceErrors` context. It must be used within a component that is\n * a descendant of the `ResourceErrors` provider.\n * \n * ### Usage:\n * ```tsx\n * import { useEffect, useResourceErrors } from 'frosty';\n * \n * const errors = useResourceErrors();\n * \n * useEffect(() => {\n * errors.forEach(({ token, error, refresh }) => {\n * console.error(`Error [${token}]:`, error);\n * // Optionally call refresh() to retry the operation\n * });\n * }, [errors]);\n * ```\n * \n * @returns The list of errors currently being tracked in the context. Each error includes:\n * - `token`: A unique identifier for the error.\n * - `error`: The error object or message.\n * - `refresh`: A function to retry the operation that caused the error.\n */\nexport const useResourceErrors = () => useErrorContext().errors;\n","//\n// sync.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Awaitable } from '@o2ter/utils-js';\nimport { _useEffect } from '../reconciler/hooks';\nimport { reconciler } from '../reconciler';\n\n/**\n * A hook utility for synchronizing with an external store.\n *\n * @template Snapshot - The type of the snapshot returned by the store.\n * @param subscribe - A function that sets up a subscription to the external store.\n * - `onStoreChange`: A callback to invoke when the store changes.\n * - `signal`: An `AbortSignal` to handle cleanup when the subscription is no longer needed.\n * - Returns an optional cleanup function or a promise resolving to one.\n * @param getSnapshot - A function that retrieves the current snapshot of the store.\n * @param getServerSnapshot - (Optional) A function that retrieves the snapshot of the store\n * in a server environment.\n * @returns The current snapshot of the store.\n *\n * @throws Will throw an error if used outside of a valid render context.\n */\nexport const useSyncExternalStore = <Snapshot>(\n subscribe: (\n onStoreChange: () => void,\n signal: AbortSignal,\n ) => Awaitable<void | (() => Awaitable<void>)>,\n getSnapshot: () => Snapshot,\n getServerSnapshot?: () => Snapshot,\n) => {\n const state = reconciler.currentHookState;\n if (!state) throw Error('useSyncExternalStore must be used within a render function.');\n _useEffect('useSyncExternalStore', (_state) => {\n const abort = new AbortController();\n try {\n const destructor = subscribe(() => { _state.setDirty(); }, abort.signal);\n return () => {\n abort.abort();\n (async () => {\n try {\n const _destructor = await destructor;\n if (_.isFunction(_destructor)) _destructor();\n } catch (e) {\n console.error(e);\n }\n })();\n };\n } catch (e) {\n console.error(e);\n return () => abort.abort();\n }\n }, null);\n if (getServerSnapshot && state.renderer._server) {\n return getServerSnapshot();\n }\n return getSnapshot();\n};","//\n// form.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Awaitable } from '@o2ter/utils-js';\nimport { useState } from '../state';\nimport { useMemo } from '../memo';\nimport { SetStateAction } from '../../../core/types/common';\nimport { createActivity, useActivity } from './activity';\nimport { useEffect } from '../effect';\nimport { uniqueId } from '../../../core/utils';\nimport { _useCallbacks } from '../callback';\n\nexport const FormActivity = createActivity();\n\ntype FormAction = 'submit' | 'reset' | string & {};\n\ntype FormState<V extends Record<string, any>> = {\n readonly dirty: boolean;\n readonly values: V;\n readonly loading: string[];\n readonly count: Record<string, number>;\n readonly setValues: (update: SetStateAction<V>) => void;\n setValue: (path: string, value: any) => void;\n perform: (action: FormAction) => Promise<void>;\n addEventListener: (callback: (action: string, state: FormState<V>) => Awaitable<void>) => void;\n removeEventListener: (callback: (action: string, state: FormState<V>) => Awaitable<void>) => void;\n};\n\nconst cloneValue = (x: any): any => {\n if (_.isArray(x)) return x.map(v => cloneValue(v));\n if (_.isPlainObject(x)) return _.mapValues(x, v => cloneValue(v));\n return x;\n};\n\nexport const useFormState = <V extends Record<string, any>>({\n initialValues,\n activity,\n callback,\n}: {\n initialValues: V,\n activity?: boolean | { actions?: string[]; delay?: number; };\n callback: (action: FormAction | 'error', state: FormState<V>, error?: any) => Awaitable<void>,\n}): FormState<V> => {\n const [state, setState] = useState<{\n values?: V;\n loading?: Record<string, string[]>;\n count?: Record<string, number>;\n listeners?: ((action: string, state: FormState<V>) => void)[];\n }>({});\n const startActivity = useActivity(FormActivity);\n const [nextTick, setNextTick] = useState<((state: FormState<V>) => void)[]>([]);\n const {\n setValues,\n setListeners,\n perform,\n } = _useCallbacks({\n setValues: (update: SetStateAction<V>) => setState(s => ({ ...s, values: _.isFunction(update) ? update(s.values ?? initialValues) : update })),\n setListeners: (update: SetStateAction<((action: string, state: FormState<V>) => void)[]>) => setState(s => ({ ...s, listeners: _.isFunction(update) ? update(s.listeners ?? []) : update })),\n perform: (action: string) => {\n const perform = async () => {\n const taskId = uniqueId();\n const _callback = async (state: FormState<V>) => {\n if (action === 'reset') setState(s => _.omit(s, 'values'));\n await callback(action, state);\n setState(s => ({\n ...s,\n count: { ...s.count, [action]: (s.count?.[action] ?? 0) + 1 },\n }))\n };\n try {\n setState(s => ({\n ...s,\n loading: { ...s.loading, [action]: [...(s.loading?.[action] ?? []), taskId] },\n }));\n const resolved = await Promise.all(_.map(state.listeners, l => l(action, formState)));\n if (_.isEmpty(resolved)) {\n await _callback(formState);\n } else {\n await new Promise((resolve, reject) => {\n setNextTick(v => [...v, (formState) => { _callback(formState).then(resolve, reject); }]);\n });\n }\n } catch (error) {\n callback('error', formState, error);\n } finally {\n setState(s => ({\n ...s,\n loading: { ...s.loading, [action]: _.without(s.loading?.[action] ?? [], taskId) },\n }));\n }\n };\n if (_.isBoolean(activity) ? activity : (activity?.actions?.includes(action) ?? _.isNumber(activity?.delay))) {\n return startActivity(perform, _.isBoolean(activity) ? undefined : activity?.delay);\n } else {\n return perform();\n }\n },\n });\n const formState = useMemo(() => ({\n get dirty() { return !_.isNil(state.values) },\n get values() { return state.values ?? initialValues },\n get loading() { return _.keys(_.pickBy(state.loading, x => !_.isEmpty(x))) },\n get count() { return state.count ?? {} },\n get setValues() { return setValues },\n setValue: (path: string, value: any) => setValues(\n values => _.set(cloneValue(values), path, _.isFunction(value) ? value(_.get(values, path)) : value)\n ),\n perform: (action: FormAction) => perform(action),\n addEventListener: (callback: (action: string, state: FormState<V>) => Awaitable<void>) => setListeners(v => [...v, callback]),\n removeEventListener: (callback: (action: string, state: FormState<V>) => Awaitable<void>) => setListeners(v => _.filter(v, x => x !== callback)),\n }), [state, initialValues]);\n useEffect(() => {\n if (_.isEmpty(nextTick)) return;\n for (const callback of nextTick) callback(formState);\n setNextTick(v => _.filter(v, x => _.every(nextTick, c => c !== x)));\n }, [nextTick]);\n return formState;\n};\n"],"names":["_useMemo","_","createCache","createContext","useMemo","_jsx","useContext","uniqueId","_useEffect","reconciler","callback","_useCallbacks"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA2BM,SAAU,QAAQ,CAAC,YAAkB,EAAA;AACzC,IAAA,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAGA,iBAAQ,CAAC,UAAU,EAAE,CAAC,MAAM,KAAI;AAC1D,QAAA,MAAM,KAAK,GAAG;AACZ,YAAA,KAAK,EAAEC,kBAAC,CAAC,UAAU,CAAC,YAAY,CAAC,GAAG,YAAY,EAAE,GAAG,YAAY;AACjE,YAAA,QAAQ,EAAE,CAAC,QAA6B,KAAI;AAC1C,gBAAA,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK;AAC5B,gBAAA,MAAM,QAAQ,GAAGA,kBAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,QAAQ;gBACvE,IAAI,QAAQ,KAAK,QAAQ;oBAAE;AAC3B,gBAAA,KAAK,CAAC,KAAK,GAAG,QAAQ;gBACtB,MAAM,CAAC,QAAQ,EAAE;YACnB,CAAC;SACF;AACD,QAAA,OAAO,KAAK;IACd,CAAC,EAAE,IAAI,CAAC;AACR,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AAC,MAAM,CAAC,CAAC,EAAE,CAAC,IAAIA,kBAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACrE,IAAA,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;AACd,IAAA,OAAO,SAAS;AAClB;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"form-CgyPc937.js","sources":["../../../src/core/hooks/state.ts","../../../src/core/hooks/misc/activity.tsx","../../../src/core/hooks/effect.ts","../../../src/core/hooks/storage.ts","../../../src/core/hooks/misc/resource/error.tsx","../../../src/core/hooks/sync.ts","../../../src/core/hooks/misc/form.ts"],"sourcesContent":["//\n// memo.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { _useMemo } from '../reconciler/hooks';\nimport { SetStateAction } from '../types/common';\n\n/**\n * A hook function for managing state within a custom framework or library.\n *\n * @template T - The type of the state value.\n * @param - The initial state value or a function that returns the initial state.\n * @returns - A tuple containing the current state value and a function to update the state.\n *\n * The `useState` function provides a way to manage stateful values. It returns the current state\n * and a setter function that can update the state. The setter function accepts either a new value\n * or a function that receives the current state and returns the updated state.\n *\n * Example:\n * ```typescript\n * const [count, setCount] = useState(0);\n * setCount(5); // Updates the state to 5\n * setCount(prev => prev + 1); // Updates the state to the previous value + 1\n * ```\n */\nexport function useState<T>(initialState: T | (() => T)): [T, (dispatch: SetStateAction<T>) => void];\nexport function useState<T = undefined>(): [T | undefined, (dispatch: SetStateAction<T | undefined>) => void];\n\nexport function useState(initialState?: any) {\n const { value, setValue } = _useMemo('useState', (_state) => {\n const state = {\n value: _.isFunction(initialState) ? initialState() : initialState,\n setValue: (dispatch: SetStateAction<any>) => {\n const oldValue = state.value;\n const newValue = _.isFunction(dispatch) ? dispatch(oldValue) : dispatch;\n if (oldValue === newValue) return;\n state.value = newValue;\n _state.setDirty();\n },\n };\n return state;\n }, null);\n return [value, setValue];\n}\n","//\n// activity.tsx\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Awaitable } from '@o2ter/utils-js';\nimport { useState } from '../state';\nimport { ElementNode, SetStateAction } from '../../types/common';\nimport { Context, createContext, useContext } from '../context';\nimport { createCache, uniqueId } from '../../utils';\nimport { useMemo } from '../memo';\n\ntype ActivityContextValue = {\n setTasks: (dispatch: SetStateAction<string[]>) => void;\n defaultDelay: number;\n};\n\nconst contextMap: WeakMap<any, Context<ActivityContextValue>> = new WeakMap();\nconst dispatchCache = createCache();\n\n/**\n * Creates an activity tracking component that monitors and counts active asynchronous tasks.\n * Returns a component that provides an activity context and renders children with the current task count.\n * \n * @param options - Configuration options for the activity tracker.\n * @param options.defaultDelay - Default delay in milliseconds before a task is considered active.\n * Defaults to 250ms. Set to 0 for immediate tracking.\n * \n * @returns A component that accepts `defaultDelay` (optional override) and `children` \n * (a render function that receives the number of active tasks).\n * \n * @example\n * ```tsx\n * const ActivityIndicator = createActivity({ defaultDelay: 300 });\n * \n * function App() {\n * return (\n * <ActivityIndicator>\n * {(taskCount) => (\n * <div>\n * {taskCount > 0 && <Spinner />}\n * <MyContent />\n * </div>\n * )}\n * </ActivityIndicator>\n * );\n * }\n * ```\n */\nexport const createActivity = ({\n defaultDelay: _defaultDelay = 250,\n}: {\n defaultDelay?: number;\n} = {}) => {\n const Context = createContext<ActivityContextValue>({\n setTasks: () => { },\n defaultDelay: _defaultDelay,\n });\n const component = ({\n defaultDelay = _defaultDelay,\n children,\n }: {\n defaultDelay?: number;\n children: ((tasks: number) => ElementNode);\n }) => {\n const [tasks, setTasks] = useState<string[]>([]);\n const value = useMemo(() => ({ setTasks, defaultDelay }), []);\n return (\n <Context value={value}>\n {children(tasks.length)}\n </Context>\n );\n };\n contextMap.set(component, Context);\n return component;\n};\n\n/**\n * A hook that returns a wrapper function for tracking asynchronous operations as active tasks.\n * Tasks are registered in the activity context created by `createActivity`, allowing parent\n * components to show loading indicators based on the number of active tasks.\n * \n * @template T - The return type of the callback function.\n * @param component - The activity component created by `createActivity`.\n * \n * @returns An async wrapper function that accepts a callback and optional delay override.\n * The wrapper executes the callback while tracking it as an active task.\n * \n * @throws {Error} If the provided component was not created by `createActivity`.\n * \n * @example\n * ```tsx\n * const ActivityIndicator = createActivity({ defaultDelay: 250 });\n * \n * function MyComponent() {\n * const trackActivity = useActivity(ActivityIndicator);\n * \n * const handleClick = async () => {\n * // Task is tracked after 250ms delay (default)\n * const result = await trackActivity(async () => {\n * const response = await fetch('/api/data');\n * return response.json();\n * });\n * console.log(result);\n * };\n * \n * const handleUrgent = async () => {\n * // Task is tracked immediately (0ms delay)\n * await trackActivity(async () => {\n * await criticalOperation();\n * }, 0);\n * };\n * \n * return <button onClick={handleClick}>Load Data</button>;\n * }\n * ```\n */\nexport const useActivity = (component: ReturnType<typeof createActivity>) => {\n const context = contextMap.get(component);\n if (!context) throw new Error('Invalid activity component');\n const store = useContext(context);\n return dispatchCache(store, () => async <T extends any>(callback: () => Awaitable<T>, delay?: number) => {\n const id = uniqueId();\n let timeout;\n const _delay = delay ?? store.defaultDelay;\n if (_.isNumber(_delay) && _delay > 0) {\n timeout = setTimeout(() => {\n store.setTasks(tasks => [...tasks, id]);\n }, _delay);\n } else {\n store.setTasks(tasks => [...tasks, id]);\n }\n try {\n return await callback();\n } finally {\n if (timeout) clearTimeout(timeout);\n store.setTasks(tasks => _.filter(tasks, x => x !== id));\n }\n });\n};","//\n// effect.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Awaitable } from '@o2ter/utils-js';\nimport { _useEffect } from '../reconciler/hooks';\n\n/**\n * A hook that manages side effects with support for an `AbortSignal`.\n * It ensures proper cleanup logic and handles asynchronous operations effectively.\n *\n * **Use `useEffect` for:**\n * - Registering and cleaning up event listeners\n * - Synchronizing with external APIs/events (browser APIs, third-party libraries)\n * - Performing actions on component mount/unmount\n * - Imperative operations (e.g., focus management, animations, logging)\n *\n * **Do NOT use `useEffect` for:**\n * - Computing UI state → Use `useMemo` instead\n * - Fetching data → Use `useResource` or `useServerResource` instead\n * - Subscribing to external stores → Use `useSyncExternalStore` instead\n * - Deriving state from props → Use `useMemo` or compute during render\n *\n * @param effect - \n * A function that receives an `AbortSignal` and performs side effects. \n * It can optionally return a cleanup function or a promise that resolves to a cleanup function.\n *\n * @param deps - \n * An optional dependencies array that determines when the effect should be re-executed.\n *\n * @example\n * // Register a window event listener\n * useEffect((signal) => {\n * const handleResize = () => {\n * console.log('Window resized:', window.innerWidth);\n * };\n * \n * window.addEventListener('resize', handleResize, { signal });\n * \n * // Cleanup happens automatically via AbortSignal\n * // Optional: return additional cleanup logic if needed\n * return () => {\n * console.log('Component unmounting');\n * };\n * }, []);\n *\n * @example\n * // Perform side effects on mount/unmount\n * useEffect((signal) => {\n * console.log('Component mounted');\n * \n * // Perform initialization work\n * document.title = 'My App';\n * \n * return () => {\n * console.log('Component unmounting, cleanup here');\n * };\n * }, []);\n */\nexport const useEffect = (\n effect: (\n signal: AbortSignal,\n ) => Awaitable<void | (() => Awaitable<void>)>,\n deps?: any,\n) => _useEffect('useEffect', () => {\n const abort = new AbortController();\n try {\n const destructor = effect(abort.signal);\n return () => {\n abort.abort();\n (async () => {\n try {\n const _destructor = await destructor;\n if (_.isFunction(_destructor)) _destructor();\n } catch (e) {\n console.error(e);\n }\n })();\n };\n } catch (e) {\n console.error(e);\n return () => abort.abort();\n }\n}, deps);","//\n// storage.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { reconciler } from '../reconciler';\n\nconst storage = new WeakMap<any, Map<any, any>>();\n\n/**\n * Returns a persistent storage Map associated with the current renderer instance.\n * This hook allows components to store and retrieve values that persist across renders,\n * scoped to the renderer. Must be called within a render function.\n *\n * @throws Error if called outside of a render function.\n * @returns {Map<any, any>} The storage map for the current renderer.\n */\nexport const useRendererStorage = (\n persist = true\n) => {\n const state = reconciler.currentHookState;\n if (!state) throw Error('useRendererStorage must be used within a render function.');\n if (!persist) return state.renderer.renderStorage;\n const found = storage.get(state.renderer);\n const store = found ?? new Map<any, any>();\n if (!found) storage.set(state.renderer, store);\n return store;\n};\n","//\n// error.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Awaitable } from '@o2ter/utils-js';\nimport { ComponentType, PropsWithChildren, SetStateAction } from '../../../types/common';\nimport { createContext } from '../../context';\nimport { useContext } from '../../context';\nimport { useState } from '../../state';\nimport { useMemo } from '../../memo';\nimport { useRendererStorage } from '../../storage';\n\ntype Errors = {\n token: string;\n error: any;\n refresh: () => Awaitable<void>;\n refreshing: boolean;\n loading: boolean;\n}[];\n\ntype ContextValue = {\n errors: Errors;\n setErrors: (values: SetStateAction<Errors>) => void;\n};\n\nconst defaultStorageKey = Symbol();\nconst Context = createContext<ContextValue>();\n\n/**\n * A context provider component for managing asynchronous resource errors.\n * \n * This component provides a shared context for tracking errors encountered during\n * asynchronous operations. It allows child components to access and manage these errors\n * using the `useResourceErrors` hook.\n * \n * ### Usage:\n * Wrap your application or specific parts of it with this component to enable error tracking:\n * \n * ```tsx\n * <ResourceErrors>\n * <YourComponent />\n * </ResourceErrors>\n * ```\n * \n * @param children - The child components that will have access to the error context.\n * \n * @returns A context provider that wraps the provided children.\n */\nexport const ResourceErrors: ComponentType<PropsWithChildren<{}>> = ({\n children\n}) => {\n const [errors, setErrors] = useState<Errors>([]);\n const value = useMemo(() => ({ errors, setErrors }), [errors, setErrors]);\n return (\n <Context value={value}>{children}</Context>\n );\n}\n\nexport const useErrorContext = () => {\n const value = useContext(Context);\n if (value) return value;\n const storage = useRendererStorage();\n const found = storage.get(defaultStorageKey);\n if (found) return found as ContextValue;\n const store: ContextValue = {\n errors: [],\n setErrors: (values: SetStateAction<Errors>) => {\n store.errors = _.isFunction(values) ? values(store.errors) : values;\n },\n };\n storage.set(defaultStorageKey, store);\n return store;\n};\n\n/**\n * A hook to access the list of asynchronous resource errors.\n * \n * This hook allows components to retrieve the current list of errors being tracked\n * in the `ResourceErrors` context. It must be used within a component that is\n * a descendant of the `ResourceErrors` provider.\n * \n * ### Usage:\n * ```tsx\n * import { useEffect, useResourceErrors } from 'frosty';\n * \n * const errors = useResourceErrors();\n * \n * useEffect(() => {\n * errors.forEach(({ token, error, refresh }) => {\n * console.error(`Error [${token}]:`, error);\n * // Optionally call refresh() to retry the operation\n * });\n * }, [errors]);\n * ```\n * \n * @returns The list of errors currently being tracked in the context. Each error includes:\n * - `token`: A unique identifier for the error.\n * - `error`: The error object or message.\n * - `refresh`: A function to retry the operation that caused the error.\n */\nexport const useResourceErrors = () => useErrorContext().errors;\n","//\n// sync.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Awaitable } from '@o2ter/utils-js';\nimport { _useEffect } from '../reconciler/hooks';\nimport { reconciler } from '../reconciler';\n\n/**\n * A hook utility for synchronizing with an external store.\n *\n * @template Snapshot - The type of the snapshot returned by the store.\n * @param subscribe - A function that sets up a subscription to the external store.\n * - `onStoreChange`: A callback to invoke when the store changes.\n * - `signal`: An `AbortSignal` to handle cleanup when the subscription is no longer needed.\n * - Returns an optional cleanup function or a promise resolving to one.\n * @param getSnapshot - A function that retrieves the current snapshot of the store.\n * @param getServerSnapshot - (Optional) A function that retrieves the snapshot of the store\n * in a server environment.\n * @returns The current snapshot of the store.\n *\n * @throws Will throw an error if used outside of a valid render context.\n */\nexport const useSyncExternalStore = <Snapshot>(\n subscribe: (\n onStoreChange: () => void,\n signal: AbortSignal,\n ) => Awaitable<void | (() => Awaitable<void>)>,\n getSnapshot: () => Snapshot,\n getServerSnapshot?: () => Snapshot,\n) => {\n const state = reconciler.currentHookState;\n if (!state) throw Error('useSyncExternalStore must be used within a render function.');\n _useEffect('useSyncExternalStore', (_state) => {\n const abort = new AbortController();\n try {\n const destructor = subscribe(() => { _state.setDirty(); }, abort.signal);\n return () => {\n abort.abort();\n (async () => {\n try {\n const _destructor = await destructor;\n if (_.isFunction(_destructor)) _destructor();\n } catch (e) {\n console.error(e);\n }\n })();\n };\n } catch (e) {\n console.error(e);\n return () => abort.abort();\n }\n }, null);\n if (getServerSnapshot && state.renderer._server) {\n return getServerSnapshot();\n }\n return getSnapshot();\n};","//\n// form.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Awaitable } from '@o2ter/utils-js';\nimport { useState } from '../state';\nimport { useMemo } from '../memo';\nimport { SetStateAction } from '../../../core/types/common';\nimport { createActivity, useActivity } from './activity';\nimport { useEffect } from '../effect';\nimport { uniqueId } from '../../../core/utils';\nimport { _useCallbacks } from '../callback';\n\nexport const FormActivity = createActivity();\n\ntype FormAction = 'submit' | 'reset' | string & {};\n\ntype FormState<V extends Record<string, any>> = {\n readonly dirty: boolean;\n readonly values: V;\n readonly loading: string[];\n readonly count: Record<string, number>;\n readonly setValues: (update: SetStateAction<V>) => void;\n setValue: (path: string, value: any) => void;\n perform: (action: FormAction) => Promise<void>;\n addEventListener: (callback: (action: string, state: FormState<V>) => Awaitable<void>) => void;\n removeEventListener: (callback: (action: string, state: FormState<V>) => Awaitable<void>) => void;\n};\n\nconst cloneValue = (x: any): any => {\n if (_.isArray(x)) return x.map(v => cloneValue(v));\n if (_.isPlainObject(x)) return _.mapValues(x, v => cloneValue(v));\n return x;\n};\n\nexport const useFormState = <V extends Record<string, any>>({\n initialValues,\n activity,\n callback,\n}: {\n initialValues: V,\n activity?: boolean | { actions?: string[]; delay?: number; };\n callback: (action: FormAction | 'error', state: FormState<V>, error?: any) => Awaitable<void>,\n}): FormState<V> => {\n const [state, setState] = useState<{\n values?: V;\n loading?: Record<string, string[]>;\n count?: Record<string, number>;\n listeners?: ((action: string, state: FormState<V>) => void)[];\n }>({});\n const startActivity = useActivity(FormActivity);\n const [nextTick, setNextTick] = useState<((state: FormState<V>) => void)[]>([]);\n const {\n setValues,\n setListeners,\n perform,\n } = _useCallbacks({\n setValues: (update: SetStateAction<V>) => setState(s => ({ ...s, values: _.isFunction(update) ? update(s.values ?? initialValues) : update })),\n setListeners: (update: SetStateAction<((action: string, state: FormState<V>) => void)[]>) => setState(s => ({ ...s, listeners: _.isFunction(update) ? update(s.listeners ?? []) : update })),\n perform: (action: string) => {\n const perform = async () => {\n const taskId = uniqueId();\n const _callback = async (state: FormState<V>) => {\n if (action === 'reset') setState(s => _.omit(s, 'values'));\n await callback(action, state);\n setState(s => ({\n ...s,\n count: { ...s.count, [action]: (s.count?.[action] ?? 0) + 1 },\n }))\n };\n try {\n setState(s => ({\n ...s,\n loading: { ...s.loading, [action]: [...(s.loading?.[action] ?? []), taskId] },\n }));\n const resolved = await Promise.all(_.map(state.listeners, l => l(action, formState)));\n if (_.isEmpty(resolved)) {\n await _callback(formState);\n } else {\n await new Promise((resolve, reject) => {\n setNextTick(v => [...v, (formState) => { _callback(formState).then(resolve, reject); }]);\n });\n }\n } catch (error) {\n callback('error', formState, error);\n } finally {\n setState(s => ({\n ...s,\n loading: { ...s.loading, [action]: _.without(s.loading?.[action] ?? [], taskId) },\n }));\n }\n };\n if (_.isBoolean(activity) ? activity : (activity?.actions?.includes(action) ?? _.isNumber(activity?.delay))) {\n return startActivity(perform, _.isBoolean(activity) ? undefined : activity?.delay);\n } else {\n return perform();\n }\n },\n });\n const formState = useMemo(() => ({\n get dirty() { return !_.isNil(state.values) },\n get values() { return state.values ?? initialValues },\n get loading() { return _.keys(_.pickBy(state.loading, x => !_.isEmpty(x))) },\n get count() { return state.count ?? {} },\n get setValues() { return setValues },\n setValue: (path: string, value: any) => setValues(\n values => _.set(cloneValue(values), path, _.isFunction(value) ? value(_.get(values, path)) : value)\n ),\n perform: (action: FormAction) => perform(action),\n addEventListener: (callback: (action: string, state: FormState<V>) => Awaitable<void>) => setListeners(v => [...v, callback]),\n removeEventListener: (callback: (action: string, state: FormState<V>) => Awaitable<void>) => setListeners(v => _.filter(v, x => x !== callback)),\n }), [state, initialValues]);\n useEffect(() => {\n if (_.isEmpty(nextTick)) return;\n for (const callback of nextTick) callback(formState);\n setNextTick(v => _.filter(v, x => _.every(nextTick, c => c !== x)));\n }, [nextTick]);\n return formState;\n};\n"],"names":["_useMemo","_","createCache","createContext","useMemo","_jsx","useContext","uniqueId","_useEffect","reconciler","callback","_useCallbacks"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA2BM,SAAU,QAAQ,CAA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AG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CACpG;QACD,OAAO,EAAE,CAAC,MAAkB,KAAK,OAAO,CAAC,MAAM,CAAC;AAChD,QAAA,gBAAgB,EAAE,CAAC,QAAkE,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC;QAC7H,mBAAmB,EAAE,CAAC,QAAkE,KAAK,YAAY,CAAC,CAAC,IAAIA,kBAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,QAAQ,CAAC,CAAC;AACjJ,KAAA,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IAC3B,SAAS,CAAC,MAAK;AACb,QAAA,IAAIA,kBAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;YAAE;QACzB,KAAK,MAAM,QAAQ,IAAI,QAAQ;YAAE,QAAQ,CAAC,SAAS,CAAC;AACpD,QAAA,WAAW,CAAC,CAAC,IAAIA,kBAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,IAAIA,kBAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACrE,IAAA,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;AACd,IAAA,OAAO,SAAS;AAClB;;;;;;;;;;;;;;"}
@@ -1,7 +1,7 @@
1
1
  import { jsx } from '../jsx-runtime.mjs';
2
2
  import _ from 'lodash';
3
- import { c as createContext, b as useContext, u as uniqueId, d as createCache, r as reconciler } from './index-CODWK-gF.mjs';
4
- import { _ as _useMemo, c as useMemo, a as _useEffect, b as _useCallbacks } from './callback-DEKCuARB.mjs';
3
+ import { c as createContext, b as useContext, u as uniqueId, d as createCache, r as reconciler } from './index-CoURz_S4.mjs';
4
+ import { _ as _useMemo, u as useMemo, b as _useEffect, c as _useCallbacks } from './callback-8cBbAwKI.mjs';
5
5
 
6
6
  //
7
7
  // memo.ts
@@ -553,4 +553,4 @@ const useFormState = ({ initialValues, activity, callback, }) => {
553
553
  };
554
554
 
555
555
  export { FormActivity as F, ResourceErrors as R, useEffect as a, useErrorContext as b, useSyncExternalStore as c, createActivity as d, useActivity as e, useFormState as f, useRendererStorage as g, useResourceErrors as h, useState as u };
556
- //# sourceMappingURL=form-Cee86QUZ.mjs.map
556
+ //# sourceMappingURL=form-DAr0GAYA.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"form-Cee86QUZ.mjs","sources":["../../../src/core/hooks/state.ts","../../../src/core/hooks/misc/activity.tsx","../../../src/core/hooks/effect.ts","../../../src/core/hooks/storage.ts","../../../src/core/hooks/misc/resource/error.tsx","../../../src/core/hooks/sync.ts","../../../src/core/hooks/misc/form.ts"],"sourcesContent":["//\n// memo.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { _useMemo } from '../reconciler/hooks';\nimport { SetStateAction } from '../types/common';\n\n/**\n * A hook function for managing state within a custom framework or library.\n *\n * @template T - The type of the state value.\n * @param - The initial state value or a function that returns the initial state.\n * @returns - A tuple containing the current state value and a function to update the state.\n *\n * The `useState` function provides a way to manage stateful values. It returns the current state\n * and a setter function that can update the state. The setter function accepts either a new value\n * or a function that receives the current state and returns the updated state.\n *\n * Example:\n * ```typescript\n * const [count, setCount] = useState(0);\n * setCount(5); // Updates the state to 5\n * setCount(prev => prev + 1); // Updates the state to the previous value + 1\n * ```\n */\nexport function useState<T>(initialState: T | (() => T)): [T, (dispatch: SetStateAction<T>) => void];\nexport function useState<T = undefined>(): [T | undefined, (dispatch: SetStateAction<T | undefined>) => void];\n\nexport function useState(initialState?: any) {\n const { value, setValue } = _useMemo('useState', (_state) => {\n const state = {\n value: _.isFunction(initialState) ? initialState() : initialState,\n setValue: (dispatch: SetStateAction<any>) => {\n const oldValue = state.value;\n const newValue = _.isFunction(dispatch) ? dispatch(oldValue) : dispatch;\n if (oldValue === newValue) return;\n state.value = newValue;\n _state.setDirty();\n },\n };\n return state;\n }, null);\n return [value, setValue];\n}\n","//\n// activity.tsx\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Awaitable } from '@o2ter/utils-js';\nimport { useState } from '../state';\nimport { ElementNode, SetStateAction } from '../../types/common';\nimport { Context, createContext, useContext } from '../context';\nimport { createCache, uniqueId } from '../../utils';\nimport { useMemo } from '../memo';\n\ntype ActivityContextValue = {\n setTasks: (dispatch: SetStateAction<string[]>) => void;\n defaultDelay: number;\n};\n\nconst contextMap: WeakMap<any, Context<ActivityContextValue>> = new WeakMap();\nconst dispatchCache = createCache();\n\n/**\n * Creates an activity tracking component that monitors and counts active asynchronous tasks.\n * Returns a component that provides an activity context and renders children with the current task count.\n * \n * @param options - Configuration options for the activity tracker.\n * @param options.defaultDelay - Default delay in milliseconds before a task is considered active.\n * Defaults to 250ms. Set to 0 for immediate tracking.\n * \n * @returns A component that accepts `defaultDelay` (optional override) and `children` \n * (a render function that receives the number of active tasks).\n * \n * @example\n * ```tsx\n * const ActivityIndicator = createActivity({ defaultDelay: 300 });\n * \n * function App() {\n * return (\n * <ActivityIndicator>\n * {(taskCount) => (\n * <div>\n * {taskCount > 0 && <Spinner />}\n * <MyContent />\n * </div>\n * )}\n * </ActivityIndicator>\n * );\n * }\n * ```\n */\nexport const createActivity = ({\n defaultDelay: _defaultDelay = 250,\n}: {\n defaultDelay?: number;\n} = {}) => {\n const Context = createContext<ActivityContextValue>({\n setTasks: () => { },\n defaultDelay: _defaultDelay,\n });\n const component = ({\n defaultDelay = _defaultDelay,\n children,\n }: {\n defaultDelay?: number;\n children: ((tasks: number) => ElementNode);\n }) => {\n const [tasks, setTasks] = useState<string[]>([]);\n const value = useMemo(() => ({ setTasks, defaultDelay }), []);\n return (\n <Context value={value}>\n {children(tasks.length)}\n </Context>\n );\n };\n contextMap.set(component, Context);\n return component;\n};\n\n/**\n * A hook that returns a wrapper function for tracking asynchronous operations as active tasks.\n * Tasks are registered in the activity context created by `createActivity`, allowing parent\n * components to show loading indicators based on the number of active tasks.\n * \n * @template T - The return type of the callback function.\n * @param component - The activity component created by `createActivity`.\n * \n * @returns An async wrapper function that accepts a callback and optional delay override.\n * The wrapper executes the callback while tracking it as an active task.\n * \n * @throws {Error} If the provided component was not created by `createActivity`.\n * \n * @example\n * ```tsx\n * const ActivityIndicator = createActivity({ defaultDelay: 250 });\n * \n * function MyComponent() {\n * const trackActivity = useActivity(ActivityIndicator);\n * \n * const handleClick = async () => {\n * // Task is tracked after 250ms delay (default)\n * const result = await trackActivity(async () => {\n * const response = await fetch('/api/data');\n * return response.json();\n * });\n * console.log(result);\n * };\n * \n * const handleUrgent = async () => {\n * // Task is tracked immediately (0ms delay)\n * await trackActivity(async () => {\n * await criticalOperation();\n * }, 0);\n * };\n * \n * return <button onClick={handleClick}>Load Data</button>;\n * }\n * ```\n */\nexport const useActivity = (component: ReturnType<typeof createActivity>) => {\n const context = contextMap.get(component);\n if (!context) throw new Error('Invalid activity component');\n const store = useContext(context);\n return dispatchCache(store, () => async <T extends any>(callback: () => Awaitable<T>, delay?: number) => {\n const id = uniqueId();\n let timeout;\n const _delay = delay ?? store.defaultDelay;\n if (_.isNumber(_delay) && _delay > 0) {\n timeout = setTimeout(() => {\n store.setTasks(tasks => [...tasks, id]);\n }, _delay);\n } else {\n store.setTasks(tasks => [...tasks, id]);\n }\n try {\n return await callback();\n } finally {\n if (timeout) clearTimeout(timeout);\n store.setTasks(tasks => _.filter(tasks, x => x !== id));\n }\n });\n};","//\n// effect.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Awaitable } from '@o2ter/utils-js';\nimport { _useEffect } from '../reconciler/hooks';\n\n/**\n * A hook that manages side effects with support for an `AbortSignal`.\n * It ensures proper cleanup logic and handles asynchronous operations effectively.\n *\n * **Use `useEffect` for:**\n * - Registering and cleaning up event listeners\n * - Synchronizing with external APIs/events (browser APIs, third-party libraries)\n * - Performing actions on component mount/unmount\n * - Imperative operations (e.g., focus management, animations, logging)\n *\n * **Do NOT use `useEffect` for:**\n * - Computing UI state → Use `useMemo` instead\n * - Fetching data → Use `useResource` or `useServerResource` instead\n * - Subscribing to external stores → Use `useSyncExternalStore` instead\n * - Deriving state from props → Use `useMemo` or compute during render\n *\n * @param effect - \n * A function that receives an `AbortSignal` and performs side effects. \n * It can optionally return a cleanup function or a promise that resolves to a cleanup function.\n *\n * @param deps - \n * An optional dependencies array that determines when the effect should be re-executed.\n *\n * @example\n * // Register a window event listener\n * useEffect((signal) => {\n * const handleResize = () => {\n * console.log('Window resized:', window.innerWidth);\n * };\n * \n * window.addEventListener('resize', handleResize, { signal });\n * \n * // Cleanup happens automatically via AbortSignal\n * // Optional: return additional cleanup logic if needed\n * return () => {\n * console.log('Component unmounting');\n * };\n * }, []);\n *\n * @example\n * // Perform side effects on mount/unmount\n * useEffect((signal) => {\n * console.log('Component mounted');\n * \n * // Perform initialization work\n * document.title = 'My App';\n * \n * return () => {\n * console.log('Component unmounting, cleanup here');\n * };\n * }, []);\n */\nexport const useEffect = (\n effect: (\n signal: AbortSignal,\n ) => Awaitable<void | (() => Awaitable<void>)>,\n deps?: any,\n) => _useEffect('useEffect', () => {\n const abort = new AbortController();\n try {\n const destructor = effect(abort.signal);\n return () => {\n abort.abort();\n (async () => {\n try {\n const _destructor = await destructor;\n if (_.isFunction(_destructor)) _destructor();\n } catch (e) {\n console.error(e);\n }\n })();\n };\n } catch (e) {\n console.error(e);\n return () => abort.abort();\n }\n}, deps);","//\n// storage.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { reconciler } from '../reconciler';\n\nconst storage = new WeakMap<any, Map<any, any>>();\n\n/**\n * Returns a persistent storage Map associated with the current renderer instance.\n * This hook allows components to store and retrieve values that persist across renders,\n * scoped to the renderer. Must be called within a render function.\n *\n * @throws Error if called outside of a render function.\n * @returns {Map<any, any>} The storage map for the current renderer.\n */\nexport const useRendererStorage = (\n persist = true\n) => {\n const state = reconciler.currentHookState;\n if (!state) throw Error('useRendererStorage must be used within a render function.');\n if (!persist) return state.renderer.renderStorage;\n const found = storage.get(state.renderer);\n const store = found ?? new Map<any, any>();\n if (!found) storage.set(state.renderer, store);\n return store;\n};\n","//\n// error.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Awaitable } from '@o2ter/utils-js';\nimport { ComponentType, PropsWithChildren, SetStateAction } from '../../../types/common';\nimport { createContext } from '../../context';\nimport { useContext } from '../../context';\nimport { useState } from '../../state';\nimport { useMemo } from '../../memo';\nimport { useRendererStorage } from '../../storage';\n\ntype Errors = {\n token: string;\n error: any;\n refresh: () => Awaitable<void>;\n refreshing: boolean;\n loading: boolean;\n}[];\n\ntype ContextValue = {\n errors: Errors;\n setErrors: (values: SetStateAction<Errors>) => void;\n};\n\nconst defaultStorageKey = Symbol();\nconst Context = createContext<ContextValue>();\n\n/**\n * A context provider component for managing asynchronous resource errors.\n * \n * This component provides a shared context for tracking errors encountered during\n * asynchronous operations. It allows child components to access and manage these errors\n * using the `useResourceErrors` hook.\n * \n * ### Usage:\n * Wrap your application or specific parts of it with this component to enable error tracking:\n * \n * ```tsx\n * <ResourceErrors>\n * <YourComponent />\n * </ResourceErrors>\n * ```\n * \n * @param children - The child components that will have access to the error context.\n * \n * @returns A context provider that wraps the provided children.\n */\nexport const ResourceErrors: ComponentType<PropsWithChildren<{}>> = ({\n children\n}) => {\n const [errors, setErrors] = useState<Errors>([]);\n const value = useMemo(() => ({ errors, setErrors }), [errors, setErrors]);\n return (\n <Context value={value}>{children}</Context>\n );\n}\n\nexport const useErrorContext = () => {\n const value = useContext(Context);\n if (value) return value;\n const storage = useRendererStorage();\n const found = storage.get(defaultStorageKey);\n if (found) return found as ContextValue;\n const store: ContextValue = {\n errors: [],\n setErrors: (values: SetStateAction<Errors>) => {\n store.errors = _.isFunction(values) ? values(store.errors) : values;\n },\n };\n storage.set(defaultStorageKey, store);\n return store;\n};\n\n/**\n * A hook to access the list of asynchronous resource errors.\n * \n * This hook allows components to retrieve the current list of errors being tracked\n * in the `ResourceErrors` context. It must be used within a component that is\n * a descendant of the `ResourceErrors` provider.\n * \n * ### Usage:\n * ```tsx\n * import { useEffect, useResourceErrors } from 'frosty';\n * \n * const errors = useResourceErrors();\n * \n * useEffect(() => {\n * errors.forEach(({ token, error, refresh }) => {\n * console.error(`Error [${token}]:`, error);\n * // Optionally call refresh() to retry the operation\n * });\n * }, [errors]);\n * ```\n * \n * @returns The list of errors currently being tracked in the context. Each error includes:\n * - `token`: A unique identifier for the error.\n * - `error`: The error object or message.\n * - `refresh`: A function to retry the operation that caused the error.\n */\nexport const useResourceErrors = () => useErrorContext().errors;\n","//\n// sync.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Awaitable } from '@o2ter/utils-js';\nimport { _useEffect } from '../reconciler/hooks';\nimport { reconciler } from '../reconciler';\n\n/**\n * A hook utility for synchronizing with an external store.\n *\n * @template Snapshot - The type of the snapshot returned by the store.\n * @param subscribe - A function that sets up a subscription to the external store.\n * - `onStoreChange`: A callback to invoke when the store changes.\n * - `signal`: An `AbortSignal` to handle cleanup when the subscription is no longer needed.\n * - Returns an optional cleanup function or a promise resolving to one.\n * @param getSnapshot - A function that retrieves the current snapshot of the store.\n * @param getServerSnapshot - (Optional) A function that retrieves the snapshot of the store\n * in a server environment.\n * @returns The current snapshot of the store.\n *\n * @throws Will throw an error if used outside of a valid render context.\n */\nexport const useSyncExternalStore = <Snapshot>(\n subscribe: (\n onStoreChange: () => void,\n signal: AbortSignal,\n ) => Awaitable<void | (() => Awaitable<void>)>,\n getSnapshot: () => Snapshot,\n getServerSnapshot?: () => Snapshot,\n) => {\n const state = reconciler.currentHookState;\n if (!state) throw Error('useSyncExternalStore must be used within a render function.');\n _useEffect('useSyncExternalStore', (_state) => {\n const abort = new AbortController();\n try {\n const destructor = subscribe(() => { _state.setDirty(); }, abort.signal);\n return () => {\n abort.abort();\n (async () => {\n try {\n const _destructor = await destructor;\n if (_.isFunction(_destructor)) _destructor();\n } catch (e) {\n console.error(e);\n }\n })();\n };\n } catch (e) {\n console.error(e);\n return () => abort.abort();\n }\n }, null);\n if (getServerSnapshot && state.renderer._server) {\n return getServerSnapshot();\n }\n return getSnapshot();\n};","//\n// form.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Awaitable } from '@o2ter/utils-js';\nimport { useState } from '../state';\nimport { useMemo } from '../memo';\nimport { SetStateAction } from '../../../core/types/common';\nimport { createActivity, useActivity } from './activity';\nimport { useEffect } from '../effect';\nimport { uniqueId } from '../../../core/utils';\nimport { _useCallbacks } from '../callback';\n\nexport const FormActivity = createActivity();\n\ntype FormAction = 'submit' | 'reset' | string & {};\n\ntype FormState<V extends Record<string, any>> = {\n readonly dirty: boolean;\n readonly values: V;\n readonly loading: string[];\n readonly count: Record<string, number>;\n readonly setValues: (update: SetStateAction<V>) => void;\n setValue: (path: string, value: any) => void;\n perform: (action: FormAction) => Promise<void>;\n addEventListener: (callback: (action: string, state: FormState<V>) => Awaitable<void>) => void;\n removeEventListener: (callback: (action: string, state: FormState<V>) => Awaitable<void>) => void;\n};\n\nconst cloneValue = (x: any): any => {\n if (_.isArray(x)) return x.map(v => cloneValue(v));\n if (_.isPlainObject(x)) return _.mapValues(x, v => cloneValue(v));\n return x;\n};\n\nexport const useFormState = <V extends Record<string, any>>({\n initialValues,\n activity,\n callback,\n}: {\n initialValues: V,\n activity?: boolean | { actions?: string[]; delay?: number; };\n callback: (action: FormAction | 'error', state: FormState<V>, error?: any) => Awaitable<void>,\n}): FormState<V> => {\n const [state, setState] = useState<{\n values?: V;\n loading?: Record<string, string[]>;\n count?: Record<string, number>;\n listeners?: ((action: string, state: FormState<V>) => void)[];\n }>({});\n const startActivity = useActivity(FormActivity);\n const [nextTick, setNextTick] = useState<((state: FormState<V>) => void)[]>([]);\n const {\n setValues,\n setListeners,\n perform,\n } = _useCallbacks({\n setValues: (update: SetStateAction<V>) => setState(s => ({ ...s, values: _.isFunction(update) ? update(s.values ?? initialValues) : update })),\n setListeners: (update: SetStateAction<((action: string, state: FormState<V>) => void)[]>) => setState(s => ({ ...s, listeners: _.isFunction(update) ? update(s.listeners ?? []) : update })),\n perform: (action: string) => {\n const perform = async () => {\n const taskId = uniqueId();\n const _callback = async (state: FormState<V>) => {\n if (action === 'reset') setState(s => _.omit(s, 'values'));\n await callback(action, state);\n setState(s => ({\n ...s,\n count: { ...s.count, [action]: (s.count?.[action] ?? 0) + 1 },\n }))\n };\n try {\n setState(s => ({\n ...s,\n loading: { ...s.loading, [action]: [...(s.loading?.[action] ?? []), taskId] },\n }));\n const resolved = await Promise.all(_.map(state.listeners, l => l(action, formState)));\n if (_.isEmpty(resolved)) {\n await _callback(formState);\n } else {\n await new Promise((resolve, reject) => {\n setNextTick(v => [...v, (formState) => { _callback(formState).then(resolve, reject); }]);\n });\n }\n } catch (error) {\n callback('error', formState, error);\n } finally {\n setState(s => ({\n ...s,\n loading: { ...s.loading, [action]: _.without(s.loading?.[action] ?? [], taskId) },\n }));\n }\n };\n if (_.isBoolean(activity) ? activity : (activity?.actions?.includes(action) ?? _.isNumber(activity?.delay))) {\n return startActivity(perform, _.isBoolean(activity) ? undefined : activity?.delay);\n } else {\n return perform();\n }\n },\n });\n const formState = useMemo(() => ({\n get dirty() { return !_.isNil(state.values) },\n get values() { return state.values ?? initialValues },\n get loading() { return _.keys(_.pickBy(state.loading, x => !_.isEmpty(x))) },\n get count() { return state.count ?? {} },\n get setValues() { return setValues },\n setValue: (path: string, value: any) => setValues(\n values => _.set(cloneValue(values), path, _.isFunction(value) ? value(_.get(values, path)) : value)\n ),\n perform: (action: FormAction) => perform(action),\n addEventListener: (callback: (action: string, state: FormState<V>) => Awaitable<void>) => setListeners(v => [...v, callback]),\n removeEventListener: (callback: (action: string, state: FormState<V>) => Awaitable<void>) => setListeners(v => _.filter(v, x => x !== callback)),\n }), [state, initialValues]);\n useEffect(() => {\n if (_.isEmpty(nextTick)) return;\n for (const callback of nextTick) callback(formState);\n setNextTick(v => _.filter(v, x => _.every(nextTick, c => c !== x)));\n }, [nextTick]);\n return formState;\n};\n"],"names":["_jsx"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA2BM,SAAU,QAAQ,CAAC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OAAO,CAAC,MAAM,CAAC;AAChD,QAAA,gBAAgB,EAAE,CAAC,QAAkE,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC;QAC7H,mBAAmB,EAAE,CAAC,QAAkE,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,QAAQ,CAAC,CAAC;AACjJ,KAAA,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IAC3B,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;YAAE;QACzB,KAAK,MAAM,QAAQ,IAAI,QAAQ;YAAE,QAAQ,CAAC,SAAS,CAAC;AACpD,QAAA,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACrE,IAAA,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;AACd,IAAA,OAAO,SAAS;AAClB;;;;"}
1
+ {"version":3,"file":"form-DAr0GAYA.mjs","sources":["../../../src/core/hooks/state.ts","../../../src/core/hooks/misc/activity.tsx","../../../src/core/hooks/effect.ts","../../../src/core/hooks/storage.ts","../../../src/core/hooks/misc/resource/error.tsx","../../../src/core/hooks/sync.ts","../../../src/core/hooks/misc/form.ts"],"sourcesContent":["//\n// memo.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { _useMemo } from '../reconciler/hooks';\nimport { SetStateAction } from '../types/common';\n\n/**\n * A hook function for managing state within a custom framework or library.\n *\n * @template T - The type of the state value.\n * @param - The initial state value or a function that returns the initial state.\n * @returns - A tuple containing the current state value and a function to update the state.\n *\n * The `useState` function provides a way to manage stateful values. It returns the current state\n * and a setter function that can update the state. The setter function accepts either a new value\n * or a function that receives the current state and returns the updated state.\n *\n * Example:\n * ```typescript\n * const [count, setCount] = useState(0);\n * setCount(5); // Updates the state to 5\n * setCount(prev => prev + 1); // Updates the state to the previous value + 1\n * ```\n */\nexport function useState<T>(initialState: T | (() => T)): [T, (dispatch: SetStateAction<T>) => void];\nexport function useState<T = undefined>(): [T | undefined, (dispatch: SetStateAction<T | undefined>) => void];\n\nexport function useState(initialState?: any) {\n const { value, setValue } = _useMemo('useState', (_state) => {\n const state = {\n value: _.isFunction(initialState) ? initialState() : initialState,\n setValue: (dispatch: SetStateAction<any>) => {\n const oldValue = state.value;\n const newValue = _.isFunction(dispatch) ? dispatch(oldValue) : dispatch;\n if (oldValue === newValue) return;\n state.value = newValue;\n _state.setDirty();\n },\n };\n return state;\n }, null);\n return [value, setValue];\n}\n","//\n// activity.tsx\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Awaitable } from '@o2ter/utils-js';\nimport { useState } from '../state';\nimport { ElementNode, SetStateAction } from '../../types/common';\nimport { Context, createContext, useContext } from '../context';\nimport { createCache, uniqueId } from '../../utils';\nimport { useMemo } from '../memo';\n\ntype ActivityContextValue = {\n setTasks: (dispatch: SetStateAction<string[]>) => void;\n defaultDelay: number;\n};\n\nconst contextMap: WeakMap<any, Context<ActivityContextValue>> = new WeakMap();\nconst dispatchCache = createCache();\n\n/**\n * Creates an activity tracking component that monitors and counts active asynchronous tasks.\n * Returns a component that provides an activity context and renders children with the current task count.\n * \n * @param options - Configuration options for the activity tracker.\n * @param options.defaultDelay - Default delay in milliseconds before a task is considered active.\n * Defaults to 250ms. Set to 0 for immediate tracking.\n * \n * @returns A component that accepts `defaultDelay` (optional override) and `children` \n * (a render function that receives the number of active tasks).\n * \n * @example\n * ```tsx\n * const ActivityIndicator = createActivity({ defaultDelay: 300 });\n * \n * function App() {\n * return (\n * <ActivityIndicator>\n * {(taskCount) => (\n * <div>\n * {taskCount > 0 && <Spinner />}\n * <MyContent />\n * </div>\n * )}\n * </ActivityIndicator>\n * );\n * }\n * ```\n */\nexport const createActivity = ({\n defaultDelay: _defaultDelay = 250,\n}: {\n defaultDelay?: number;\n} = {}) => {\n const Context = createContext<ActivityContextValue>({\n setTasks: () => { },\n defaultDelay: _defaultDelay,\n });\n const component = ({\n defaultDelay = _defaultDelay,\n children,\n }: {\n defaultDelay?: number;\n children: ((tasks: number) => ElementNode);\n }) => {\n const [tasks, setTasks] = useState<string[]>([]);\n const value = useMemo(() => ({ setTasks, defaultDelay }), []);\n return (\n <Context value={value}>\n {children(tasks.length)}\n </Context>\n );\n };\n contextMap.set(component, Context);\n return component;\n};\n\n/**\n * A hook that returns a wrapper function for tracking asynchronous operations as active tasks.\n * Tasks are registered in the activity context created by `createActivity`, allowing parent\n * components to show loading indicators based on the number of active tasks.\n * \n * @template T - The return type of the callback function.\n * @param component - The activity component created by `createActivity`.\n * \n * @returns An async wrapper function that accepts a callback and optional delay override.\n * The wrapper executes the callback while tracking it as an active task.\n * \n * @throws {Error} If the provided component was not created by `createActivity`.\n * \n * @example\n * ```tsx\n * const ActivityIndicator = createActivity({ defaultDelay: 250 });\n * \n * function MyComponent() {\n * const trackActivity = useActivity(ActivityIndicator);\n * \n * const handleClick = async () => {\n * // Task is tracked after 250ms delay (default)\n * const result = await trackActivity(async () => {\n * const response = await fetch('/api/data');\n * return response.json();\n * });\n * console.log(result);\n * };\n * \n * const handleUrgent = async () => {\n * // Task is tracked immediately (0ms delay)\n * await trackActivity(async () => {\n * await criticalOperation();\n * }, 0);\n * };\n * \n * return <button onClick={handleClick}>Load Data</button>;\n * }\n * ```\n */\nexport const useActivity = (component: ReturnType<typeof createActivity>) => {\n const context = contextMap.get(component);\n if (!context) throw new Error('Invalid activity component');\n const store = useContext(context);\n return dispatchCache(store, () => async <T extends any>(callback: () => Awaitable<T>, delay?: number) => {\n const id = uniqueId();\n let timeout;\n const _delay = delay ?? store.defaultDelay;\n if (_.isNumber(_delay) && _delay > 0) {\n timeout = setTimeout(() => {\n store.setTasks(tasks => [...tasks, id]);\n }, _delay);\n } else {\n store.setTasks(tasks => [...tasks, id]);\n }\n try {\n return await callback();\n } finally {\n if (timeout) clearTimeout(timeout);\n store.setTasks(tasks => _.filter(tasks, x => x !== id));\n }\n });\n};","//\n// effect.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Awaitable } from '@o2ter/utils-js';\nimport { _useEffect } from '../reconciler/hooks';\n\n/**\n * A hook that manages side effects with support for an `AbortSignal`.\n * It ensures proper cleanup logic and handles asynchronous operations effectively.\n *\n * **Use `useEffect` for:**\n * - Registering and cleaning up event listeners\n * - Synchronizing with external APIs/events (browser APIs, third-party libraries)\n * - Performing actions on component mount/unmount\n * - Imperative operations (e.g., focus management, animations, logging)\n *\n * **Do NOT use `useEffect` for:**\n * - Computing UI state → Use `useMemo` instead\n * - Fetching data → Use `useResource` or `useServerResource` instead\n * - Subscribing to external stores → Use `useSyncExternalStore` instead\n * - Deriving state from props → Use `useMemo` or compute during render\n *\n * @param effect - \n * A function that receives an `AbortSignal` and performs side effects. \n * It can optionally return a cleanup function or a promise that resolves to a cleanup function.\n *\n * @param deps - \n * An optional dependencies array that determines when the effect should be re-executed.\n *\n * @example\n * // Register a window event listener\n * useEffect((signal) => {\n * const handleResize = () => {\n * console.log('Window resized:', window.innerWidth);\n * };\n * \n * window.addEventListener('resize', handleResize, { signal });\n * \n * // Cleanup happens automatically via AbortSignal\n * // Optional: return additional cleanup logic if needed\n * return () => {\n * console.log('Component unmounting');\n * };\n * }, []);\n *\n * @example\n * // Perform side effects on mount/unmount\n * useEffect((signal) => {\n * console.log('Component mounted');\n * \n * // Perform initialization work\n * document.title = 'My App';\n * \n * return () => {\n * console.log('Component unmounting, cleanup here');\n * };\n * }, []);\n */\nexport const useEffect = (\n effect: (\n signal: AbortSignal,\n ) => Awaitable<void | (() => Awaitable<void>)>,\n deps?: any,\n) => _useEffect('useEffect', () => {\n const abort = new AbortController();\n try {\n const destructor = effect(abort.signal);\n return () => {\n abort.abort();\n (async () => {\n try {\n const _destructor = await destructor;\n if (_.isFunction(_destructor)) _destructor();\n } catch (e) {\n console.error(e);\n }\n })();\n };\n } catch (e) {\n console.error(e);\n return () => abort.abort();\n }\n}, deps);","//\n// storage.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { reconciler } from '../reconciler';\n\nconst storage = new WeakMap<any, Map<any, any>>();\n\n/**\n * Returns a persistent storage Map associated with the current renderer instance.\n * This hook allows components to store and retrieve values that persist across renders,\n * scoped to the renderer. Must be called within a render function.\n *\n * @throws Error if called outside of a render function.\n * @returns {Map<any, any>} The storage map for the current renderer.\n */\nexport const useRendererStorage = (\n persist = true\n) => {\n const state = reconciler.currentHookState;\n if (!state) throw Error('useRendererStorage must be used within a render function.');\n if (!persist) return state.renderer.renderStorage;\n const found = storage.get(state.renderer);\n const store = found ?? new Map<any, any>();\n if (!found) storage.set(state.renderer, store);\n return store;\n};\n","//\n// error.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Awaitable } from '@o2ter/utils-js';\nimport { ComponentType, PropsWithChildren, SetStateAction } from '../../../types/common';\nimport { createContext } from '../../context';\nimport { useContext } from '../../context';\nimport { useState } from '../../state';\nimport { useMemo } from '../../memo';\nimport { useRendererStorage } from '../../storage';\n\ntype Errors = {\n token: string;\n error: any;\n refresh: () => Awaitable<void>;\n refreshing: boolean;\n loading: boolean;\n}[];\n\ntype ContextValue = {\n errors: Errors;\n setErrors: (values: SetStateAction<Errors>) => void;\n};\n\nconst defaultStorageKey = Symbol();\nconst Context = createContext<ContextValue>();\n\n/**\n * A context provider component for managing asynchronous resource errors.\n * \n * This component provides a shared context for tracking errors encountered during\n * asynchronous operations. It allows child components to access and manage these errors\n * using the `useResourceErrors` hook.\n * \n * ### Usage:\n * Wrap your application or specific parts of it with this component to enable error tracking:\n * \n * ```tsx\n * <ResourceErrors>\n * <YourComponent />\n * </ResourceErrors>\n * ```\n * \n * @param children - The child components that will have access to the error context.\n * \n * @returns A context provider that wraps the provided children.\n */\nexport const ResourceErrors: ComponentType<PropsWithChildren<{}>> = ({\n children\n}) => {\n const [errors, setErrors] = useState<Errors>([]);\n const value = useMemo(() => ({ errors, setErrors }), [errors, setErrors]);\n return (\n <Context value={value}>{children}</Context>\n );\n}\n\nexport const useErrorContext = () => {\n const value = useContext(Context);\n if (value) return value;\n const storage = useRendererStorage();\n const found = storage.get(defaultStorageKey);\n if (found) return found as ContextValue;\n const store: ContextValue = {\n errors: [],\n setErrors: (values: SetStateAction<Errors>) => {\n store.errors = _.isFunction(values) ? values(store.errors) : values;\n },\n };\n storage.set(defaultStorageKey, store);\n return store;\n};\n\n/**\n * A hook to access the list of asynchronous resource errors.\n * \n * This hook allows components to retrieve the current list of errors being tracked\n * in the `ResourceErrors` context. It must be used within a component that is\n * a descendant of the `ResourceErrors` provider.\n * \n * ### Usage:\n * ```tsx\n * import { useEffect, useResourceErrors } from 'frosty';\n * \n * const errors = useResourceErrors();\n * \n * useEffect(() => {\n * errors.forEach(({ token, error, refresh }) => {\n * console.error(`Error [${token}]:`, error);\n * // Optionally call refresh() to retry the operation\n * });\n * }, [errors]);\n * ```\n * \n * @returns The list of errors currently being tracked in the context. Each error includes:\n * - `token`: A unique identifier for the error.\n * - `error`: The error object or message.\n * - `refresh`: A function to retry the operation that caused the error.\n */\nexport const useResourceErrors = () => useErrorContext().errors;\n","//\n// sync.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Awaitable } from '@o2ter/utils-js';\nimport { _useEffect } from '../reconciler/hooks';\nimport { reconciler } from '../reconciler';\n\n/**\n * A hook utility for synchronizing with an external store.\n *\n * @template Snapshot - The type of the snapshot returned by the store.\n * @param subscribe - A function that sets up a subscription to the external store.\n * - `onStoreChange`: A callback to invoke when the store changes.\n * - `signal`: An `AbortSignal` to handle cleanup when the subscription is no longer needed.\n * - Returns an optional cleanup function or a promise resolving to one.\n * @param getSnapshot - A function that retrieves the current snapshot of the store.\n * @param getServerSnapshot - (Optional) A function that retrieves the snapshot of the store\n * in a server environment.\n * @returns The current snapshot of the store.\n *\n * @throws Will throw an error if used outside of a valid render context.\n */\nexport const useSyncExternalStore = <Snapshot>(\n subscribe: (\n onStoreChange: () => void,\n signal: AbortSignal,\n ) => Awaitable<void | (() => Awaitable<void>)>,\n getSnapshot: () => Snapshot,\n getServerSnapshot?: () => Snapshot,\n) => {\n const state = reconciler.currentHookState;\n if (!state) throw Error('useSyncExternalStore must be used within a render function.');\n _useEffect('useSyncExternalStore', (_state) => {\n const abort = new AbortController();\n try {\n const destructor = subscribe(() => { _state.setDirty(); }, abort.signal);\n return () => {\n abort.abort();\n (async () => {\n try {\n const _destructor = await destructor;\n if (_.isFunction(_destructor)) _destructor();\n } catch (e) {\n console.error(e);\n }\n })();\n };\n } catch (e) {\n console.error(e);\n return () => abort.abort();\n }\n }, null);\n if (getServerSnapshot && state.renderer._server) {\n return getServerSnapshot();\n }\n return getSnapshot();\n};","//\n// form.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Awaitable } from '@o2ter/utils-js';\nimport { useState } from '../state';\nimport { useMemo } from '../memo';\nimport { SetStateAction } from '../../../core/types/common';\nimport { createActivity, useActivity } from './activity';\nimport { useEffect } from '../effect';\nimport { uniqueId } from '../../../core/utils';\nimport { _useCallbacks } from '../callback';\n\nexport const FormActivity = createActivity();\n\ntype FormAction = 'submit' | 'reset' | string & {};\n\ntype FormState<V extends Record<string, any>> = {\n readonly dirty: boolean;\n readonly values: V;\n readonly loading: string[];\n readonly count: Record<string, number>;\n readonly setValues: (update: SetStateAction<V>) => void;\n setValue: (path: string, value: any) => void;\n perform: (action: FormAction) => Promise<void>;\n addEventListener: (callback: (action: string, state: FormState<V>) => Awaitable<void>) => void;\n removeEventListener: (callback: (action: string, state: FormState<V>) => Awaitable<void>) => void;\n};\n\nconst cloneValue = (x: any): any => {\n if (_.isArray(x)) return x.map(v => cloneValue(v));\n if (_.isPlainObject(x)) return _.mapValues(x, v => cloneValue(v));\n return x;\n};\n\nexport const useFormState = <V extends Record<string, any>>({\n initialValues,\n activity,\n callback,\n}: {\n initialValues: V,\n activity?: boolean | { actions?: string[]; delay?: number; };\n callback: (action: FormAction | 'error', state: FormState<V>, error?: any) => Awaitable<void>,\n}): FormState<V> => {\n const [state, setState] = useState<{\n values?: V;\n loading?: Record<string, string[]>;\n count?: Record<string, number>;\n listeners?: ((action: string, state: FormState<V>) => void)[];\n }>({});\n const startActivity = useActivity(FormActivity);\n const [nextTick, setNextTick] = useState<((state: FormState<V>) => void)[]>([]);\n const {\n setValues,\n setListeners,\n perform,\n } = _useCallbacks({\n setValues: (update: SetStateAction<V>) => setState(s => ({ ...s, values: _.isFunction(update) ? update(s.values ?? initialValues) : update })),\n setListeners: (update: SetStateAction<((action: string, state: FormState<V>) => void)[]>) => setState(s => ({ ...s, listeners: _.isFunction(update) ? update(s.listeners ?? []) : update })),\n perform: (action: string) => {\n const perform = async () => {\n const taskId = uniqueId();\n const _callback = async (state: FormState<V>) => {\n if (action === 'reset') setState(s => _.omit(s, 'values'));\n await callback(action, state);\n setState(s => ({\n ...s,\n count: { ...s.count, [action]: (s.count?.[action] ?? 0) + 1 },\n }))\n };\n try {\n setState(s => ({\n ...s,\n loading: { ...s.loading, [action]: [...(s.loading?.[action] ?? []), taskId] },\n }));\n const resolved = await Promise.all(_.map(state.listeners, l => l(action, formState)));\n if (_.isEmpty(resolved)) {\n await _callback(formState);\n } else {\n await new Promise((resolve, reject) => {\n setNextTick(v => [...v, (formState) => { _callback(formState).then(resolve, reject); }]);\n });\n }\n } catch (error) {\n callback('error', formState, error);\n } finally {\n setState(s => ({\n ...s,\n loading: { ...s.loading, [action]: _.without(s.loading?.[action] ?? [], taskId) },\n }));\n }\n };\n if (_.isBoolean(activity) ? activity : (activity?.actions?.includes(action) ?? _.isNumber(activity?.delay))) {\n return startActivity(perform, _.isBoolean(activity) ? undefined : activity?.delay);\n } else {\n return perform();\n }\n },\n });\n const formState = useMemo(() => ({\n get dirty() { return !_.isNil(state.values) },\n get values() { return state.values ?? initialValues },\n get loading() { return _.keys(_.pickBy(state.loading, x => !_.isEmpty(x))) },\n get count() { return state.count ?? {} },\n get setValues() { return setValues },\n setValue: (path: string, value: any) => setValues(\n values => _.set(cloneValue(values), path, _.isFunction(value) ? value(_.get(values, path)) : value)\n ),\n perform: (action: FormAction) => perform(action),\n addEventListener: (callback: (action: string, state: FormState<V>) => Awaitable<void>) => setListeners(v => [...v, callback]),\n removeEventListener: (callback: (action: string, state: FormState<V>) => Awaitable<void>) => setListeners(v => _.filter(v, x => x !== callback)),\n }), [state, initialValues]);\n useEffect(() => {\n if (_.isEmpty(nextTick)) return;\n for (const callback of nextTick) callback(formState);\n setNextTick(v => _.filter(v, x => _.every(nextTick, c => c !== x)));\n }, [nextTick]);\n return formState;\n};\n"],"names":["_jsx"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA2BM,SAAU,QAAQ,CAAC,YAAkB,EAAA;AACzC,IAAA,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC,UAAU,EAAE,CAAC,MAAM,KAAI;AAC1D,QAAA,MAAM,KAAK,GAAG;AACZ,YAAA,KAAK,EAAE,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,GAAG,YAAY,EAAE,GAAG,YAAY;AACjE,YAAA,QAAQ,EAAE,CAAC,QAA6B,KAAI;AAC1C,gBAAA,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK;AAC5B,gBAAA,MAAM,QAAQ,GAAG,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,QAAQ;gBACvE,IAAI,QAAQ,KAAK,QAAQ;oBAAE;AAC3B,gBAAA,KAAK,CAAC,KAAK,GAAG,QAAQ;gBACtB,MAAM,CAAC,QAAQ,EAAE;YACnB,CAAC;SACF;AACD,QAAA,OAAO,KAAK;IACd,CAAC,EAAE,IAAI,CAAC;AACR,IAAA,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC;AAC1B;;AC3BA,MAAM,UAAU,GAAgD,IAAI,OAAO,EAAE;AAC7E,MAAM,aAAa,GAAG,WAAW,EA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@
1
- //
2
- // fragment.ts
3
- //
4
- // The MIT License
5
- // Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.
6
- //
7
- // Permission is hereby granted, free of charge, to any person obtaining a copy
8
- // of this software and associated documentation files (the "Software"), to deal
9
- // in the Software without restriction, including without limitation the rights
10
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- // copies of the Software, and to permit persons to whom the Software is
12
- // furnished to do so, subject to the following conditions:
13
- //
14
- // The above copyright notice and this permission notice shall be included in
15
- // all copies or substantial portions of the Software.
16
- //
17
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
- // THE SOFTWARE.
24
- //
25
- /**
26
- * A component that renders its children without adding extra nodes to the DOM.
27
- */
28
- const Fragment = ({ children }) => {
29
- return children;
30
- };
31
-
32
1
  //
33
2
  // index.ts
34
3
  //
@@ -111,5 +80,36 @@ const _createElement = (type, props) => {
111
80
  };
112
81
  const createElement = (type, props, ...children) => _createElement(type, { ...props ?? {}, children });
113
82
 
83
+ //
84
+ // fragment.ts
85
+ //
86
+ // The MIT License
87
+ // Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.
88
+ //
89
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
90
+ // of this software and associated documentation files (the "Software"), to deal
91
+ // in the Software without restriction, including without limitation the rights
92
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
93
+ // copies of the Software, and to permit persons to whom the Software is
94
+ // furnished to do so, subject to the following conditions:
95
+ //
96
+ // The above copyright notice and this permission notice shall be included in
97
+ // all copies or substantial portions of the Software.
98
+ //
99
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
100
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
101
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
102
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
103
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
104
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
105
+ // THE SOFTWARE.
106
+ //
107
+ /**
108
+ * A component that renders its children without adding extra nodes to the DOM.
109
+ */
110
+ const Fragment = ({ children }) => {
111
+ return children;
112
+ };
113
+
114
114
  export { ComponentNode as C, Fragment as F, NativeElementType as N, _createElement as _, createElement as c };
115
- //# sourceMappingURL=runtime-Bpq-U9sI.mjs.map
115
+ //# sourceMappingURL=fragment-DnpshXqL.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fragment-DnpshXqL.mjs","sources":["../../../src/core/types/component.ts","../../../src/core/types/runtime.ts","../../../src/core/components/fragment.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { _ElementType, PropsType } from './runtime';\n\nexport abstract class NativeElementType {\n constructor(...args: any[]) { };\n}\n\nexport class ComponentNode {\n\n #type: _ElementType | typeof NativeElementType;\n #props: PropsType;\n #key?: string | number | bigint | null;\n\n /** @internal */\n constructor(\n type: _ElementType | typeof NativeElementType,\n props: PropsType,\n key?: string | number\n ) {\n this.#type = type;\n this.#props = props;\n this.#key = key;\n }\n\n get type() {\n return this.#type;\n }\n\n get props() {\n return this.#props;\n }\n\n get key() {\n return this.#key;\n }\n\n equalType(other: ComponentNode) {\n return this.type === other.type && this.key === other.key;\n }\n}\n","//\n// basic.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { MergeObject, PickType, WritableKeys } from '@o2ter/utils-js';\nimport { ComponentType, ElementNode, PropsWithChildren, RefAttribute } from './common';\nimport { ClassName, StyleProp } from './style';\nimport { CSSProperties, ExtendedCSSProperties } from '../web/styles/css';\nimport { globalEvents } from '../web/event';\nimport { ComponentNode, NativeElementType } from './component';\nimport { _HTMLElementTagNameMap, _MathMLElementTagNameMap, _SVGElementTagNameMap } from '../web/props';\n\nexport type _ElementType = string | ComponentType<any>;\n\nexport type _IntrinsicAttributes = {\n key?: string | number | bigint | null;\n};\n\nexport type PropsType = Record<string, any>;\n\ntype EventHandler<E extends Event, C, T = EventTarget> = (this: C | void, event: E & {\n currentTarget: C;\n target: T;\n }) => void;\ntype EventMap = {\n [ev in keyof typeof globalEvents]: ev extends `on${infer x}`\n ? Lowercase<x> extends keyof GlobalEventHandlersEventMap ? GlobalEventHandlersEventMap[Lowercase<x>] : Event\n : never;\n};\n\ntype _PropsOfInstance<Instance> = Omit<\n PickType<{\n [k in WritableKeys<Instance>]: Instance[k];\n }, boolean | number | string | null | undefined>,\n 'className' | 'style' | 'innerText' | 'outerText' | 'outerHTML' | 'nodeValue'\n> & {\n [x in keyof EventMap]?: EventHandler<EventMap[x], Instance>;\n} & {\n [x in keyof EventMap as `${x}Capture`]?: EventHandler<EventMap[x], Instance>;\n};\n\ntype Combine<T, R> = Omit<T, keyof R> & R;\n\ntype _ElementProps<ElementMap extends { [x: string]: { type: any; props?: any; } }> = {\n [x in keyof ElementMap]: PropsWithChildren<\n Partial<\n _IntrinsicAttributes\n & RefAttribute<ElementMap[x]['type'] | null | undefined>\n & {\n className?: ClassName;\n style?: StyleProp<ExtendedCSSProperties>;\n inlineStyle?: CSSProperties;\n }\n & Combine<ElementMap[x]['props'], _PropsOfInstance<ElementMap[x]['type']>>\n >\n >\n};\n\nexport type _IntrinsicElements = MergeObject<\n | _ElementProps<_HTMLElementTagNameMap>\n | _ElementProps<_SVGElementTagNameMap>\n | _ElementProps<_MathMLElementTagNameMap>\n> & { [x: string]: any; };\n\nexport const _createElement = (\n type: _ElementType | typeof NativeElementType,\n props: PropsType\n) => {\n const { key, ..._props } = props;\n return new ComponentNode(type, _props, key);\n}\n\nexport const createElement = (\n type: _ElementType,\n props?: PropsType | null,\n ...children: ElementNode[]\n) => _createElement(type, { ...props ?? {}, children });\n","//\n// fragment.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { ComponentType, PropsWithChildren } from '../types/common';\n\n/**\n * A component that renders its children without adding extra nodes to the DOM.\n */\nexport const Fragment: ComponentType<PropsWithChildren<{}>> = ({ children }) => {\n return children;\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MAKsB,iBAAiB,CAAA;IACrC,WAAA,CAAY,GAAG,IAAW,EAAA,EAAI;;AAC/B;MAEY,aAAa,CAAA;AAExB,IAAA,KAAK;AACL,IAAA,MAAM;AACN,IAAA,IAAI;;AAGJ,IAAA,WAAA,CACE,IAA6C,EAC7C,KAAgB,EAChB,GAAqB,EAAA;AAErB,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI;AACjB,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK;AACnB,QAAA,IAAI,CAAC,IAAI,GAAG,GAAG;IACjB;AAEA,IAAA,IAAI,IAAI,GAAA;QACN,OAAO,IAAI,CAAC,KAAK;IACnB;AAEA,IAAA,IAAI,KAAK,GAAA;QACP,OAAO,IAAI,CAAC,MAAM;IACpB;AAEA,IAAA,IAAI,GAAG,GAAA;QACL,OAAO,IAAI,CAAC,IAAI;IAClB;AAEA,IAAA,SAAS,CAAC,KAAoB,EAAA;AAC5B,QAAA,OAAO,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG;IAC3D;AACD;;AChED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MA8Da,cAAc,GAAG,CAC5B,IAA6C,EAC7C,KAAgB,KACd;IACF,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,KAAK;IAChC,OAAO,IAAI,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC;AAC7C;AAEO,MAAM,aAAa,GAAG,CAC3B,IAAkB,EAClB,KAAwB,EACxB,GAAG,QAAuB,KACvB,cAAc,CAAC,IAAI,EAAE,EAAE,GAAG,KAAK,IAAI,EAAE,EAAE,QAAQ,EAAE;;ACjGtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;;AAEG;MACU,QAAQ,GAAyC,CAAC,EAAE,QAAQ,EAAE,KAAI;AAC7E,IAAA,OAAO,QAAQ;AACjB;;;;"}
@@ -1,4 +1,4 @@
1
- import { C as ComponentType, P as PropsWithChildren } from './common-BMp06ZN_.mjs';
1
+ import { C as ComponentType, P as PropsWithChildren } from './common-uQrs1G5-.mjs';
2
2
 
3
3
  /**
4
4
  * A component that renders its children without adding extra nodes to the DOM.
@@ -6,4 +6,4 @@ import { C as ComponentType, P as PropsWithChildren } from './common-BMp06ZN_.mj
6
6
  declare const Fragment: ComponentType<PropsWithChildren<{}>>;
7
7
 
8
8
  export { Fragment as F };
9
- //# sourceMappingURL=fragment-Dhp_GJso.d.mts.map
9
+ //# sourceMappingURL=fragment-DuyNMgL3.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fragment-DuyNMgL3.d.mts","sources":["../../src/core/components/fragment.ts"],"mappings":";;AACA;AACA;AACA;AACA,cAAc,QAAQ,EAAE,aAAa,CAAC,iBAAiB;;;;","names":[]}
@@ -1,4 +1,4 @@
1
- import { C as ComponentType, P as PropsWithChildren } from './common-BMp06ZN_.js';
1
+ import { C as ComponentType, P as PropsWithChildren } from './common-uQrs1G5-.js';
2
2
 
3
3
  /**
4
4
  * A component that renders its children without adding extra nodes to the DOM.
@@ -6,4 +6,4 @@ import { C as ComponentType, P as PropsWithChildren } from './common-BMp06ZN_.js
6
6
  declare const Fragment: ComponentType<PropsWithChildren<{}>>;
7
7
 
8
8
  export { Fragment as F };
9
- //# sourceMappingURL=fragment-C8nMwgq0.d.ts.map
9
+ //# sourceMappingURL=fragment-HkiF2xeJ.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fragment-HkiF2xeJ.d.ts","sources":["../../src/core/components/fragment.ts"],"mappings":";;AACA;AACA;AACA;AACA,cAAc,QAAQ,EAAE,aAAa,CAAC,iBAAiB;;;;","names":[]}