frosty 0.0.36 → 0.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_native.d.ts +3 -3
- package/dist/_native.js +5 -4
- package/dist/_native.js.map +1 -1
- package/dist/_native.mjs +4 -4
- package/dist/dom.d.ts +3 -3
- package/dist/dom.js +4 -6
- package/dist/dom.js.map +1 -1
- package/dist/dom.mjs +4 -6
- package/dist/dom.mjs.map +1 -1
- package/dist/index.d.ts +5 -50
- package/dist/index.js +109 -77
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +99 -62
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{common-BOZ7LFsB.mjs → common-BoxPKJqo.mjs} +4 -5
- package/dist/internals/{common-BOZ7LFsB.mjs.map → common-BoxPKJqo.mjs.map} +1 -1
- package/dist/internals/{common-CjVBgVnj.js → common-CRYEvU6P.js} +5 -6
- package/dist/internals/{common-CjVBgVnj.js.map → common-CRYEvU6P.js.map} +1 -1
- package/dist/internals/{common-oNHXt-X6.d.ts → common-CUIKizze.d.ts} +6 -6
- package/dist/internals/common-CUIKizze.d.ts.map +1 -0
- package/dist/internals/{common-BLDQwvsd.d.ts → common-D44KuOmi.d.ts} +3 -3
- package/dist/internals/common-D44KuOmi.d.ts.map +1 -0
- package/dist/internals/{runtime-PKOt40BM.js → component-BiP3XIPe.js} +1 -33
- package/dist/internals/component-BiP3XIPe.js.map +1 -0
- package/dist/internals/{runtime-DrGYUphO.mjs → component-BzurKp_J.mjs} +2 -32
- package/dist/internals/component-BzurKp_J.mjs.map +1 -0
- package/dist/internals/{fragment-BkyAEmoa.d.ts → fragment-50WCFjrW.d.ts} +2 -2
- package/dist/internals/fragment-50WCFjrW.d.ts.map +1 -0
- package/dist/internals/{renderer-BIGBfQIc.mjs → renderer-ClDlweEF.mjs} +3 -3
- package/dist/internals/{renderer-BIGBfQIc.mjs.map → renderer-ClDlweEF.mjs.map} +1 -1
- package/dist/internals/{renderer-Bmw8wKAf.d.ts → renderer-DPoACdip.d.ts} +2 -2
- package/dist/internals/renderer-DPoACdip.d.ts.map +1 -0
- package/dist/internals/{renderer-Ds5Glygc.js → renderer-a9zN1_RB.js} +12 -12
- package/dist/internals/{renderer-Ds5Glygc.js.map → renderer-a9zN1_RB.js.map} +1 -1
- package/dist/internals/runtime-DCKT7fd6.js +37 -0
- package/dist/internals/runtime-DCKT7fd6.js.map +1 -0
- package/dist/internals/runtime-DK28Kyy2.mjs +34 -0
- package/dist/internals/runtime-DK28Kyy2.mjs.map +1 -0
- package/dist/internals/{state-CK2bzUOk.mjs → state-5PNx91ec.mjs} +3 -3
- package/dist/internals/{state-CK2bzUOk.mjs.map → state-5PNx91ec.mjs.map} +1 -1
- package/dist/internals/{state-CKAt_mTM.js → state-Lf_tbWNd.js} +4 -4
- package/dist/internals/{state-CKAt_mTM.js.map → state-Lf_tbWNd.js.map} +1 -1
- package/dist/internals/{sync-CyAho2g-.mjs → sync-C4RmxDzS.mjs} +99 -4
- package/dist/internals/sync-C4RmxDzS.mjs.map +1 -0
- package/dist/internals/{sync-w9XkAX8E.js → sync-e3464vDv.js} +105 -7
- package/dist/internals/sync-e3464vDv.js.map +1 -0
- package/dist/internals/{utils--X3fYqdu.d.ts → utils-DWp2-G3N.d.ts} +2 -2
- package/dist/internals/utils-DWp2-G3N.d.ts.map +1 -0
- package/dist/jsx-runtime.d.ts +2 -2
- package/dist/jsx-runtime.js +3 -2
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/jsx-runtime.mjs +2 -1
- package/dist/jsx-runtime.mjs.map +1 -1
- package/dist/server-dom.d.ts +3 -3
- package/dist/server-dom.js +4 -6
- package/dist/server-dom.js.map +1 -1
- package/dist/server-dom.mjs +4 -6
- package/dist/server-dom.mjs.map +1 -1
- package/dist/web.d.ts +3 -3
- package/dist/web.js +6 -8
- package/dist/web.js.map +1 -1
- package/dist/web.mjs +6 -8
- package/dist/web.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/internals/common-BLDQwvsd.d.ts.map +0 -1
- package/dist/internals/common-oNHXt-X6.d.ts.map +0 -1
- package/dist/internals/error-BT7hiUUR.mjs +0 -193
- package/dist/internals/error-BT7hiUUR.mjs.map +0 -1
- package/dist/internals/error-Cbb2rheX.js +0 -201
- package/dist/internals/error-Cbb2rheX.js.map +0 -1
- package/dist/internals/fragment-BkyAEmoa.d.ts.map +0 -1
- package/dist/internals/renderer-Bmw8wKAf.d.ts.map +0 -1
- package/dist/internals/runtime-DrGYUphO.mjs.map +0 -1
- package/dist/internals/runtime-PKOt40BM.js.map +0 -1
- package/dist/internals/sync-CyAho2g-.mjs.map +0 -1
- package/dist/internals/sync-w9XkAX8E.js.map +0 -1
- package/dist/internals/utils--X3fYqdu.d.ts.map +0 -1
package/dist/web.mjs
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import { r as reconciler, b as EventEmitter,
|
|
2
|
-
import { _ as _DOMRenderer } from './internals/common-
|
|
3
|
-
export { D as DOMNativeNode } from './internals/common-
|
|
1
|
+
import { r as reconciler, b as EventEmitter, a as uniqueId } from './internals/state-5PNx91ec.mjs';
|
|
2
|
+
import { _ as _DOMRenderer } from './internals/common-BoxPKJqo.mjs';
|
|
3
|
+
export { D as DOMNativeNode } from './internals/common-BoxPKJqo.mjs';
|
|
4
4
|
import _ from 'lodash';
|
|
5
|
-
import { b as useMemo } from './internals/
|
|
6
|
-
import
|
|
7
|
-
import './internals/runtime-DrGYUphO.mjs';
|
|
5
|
+
import { d as useSyncExternalStore, b as useMemo, u as useCallback, c as useEffect } from './internals/sync-C4RmxDzS.mjs';
|
|
6
|
+
import './internals/component-BzurKp_J.mjs';
|
|
8
7
|
import 'myers.js';
|
|
9
|
-
import './internals/renderer-
|
|
8
|
+
import './internals/renderer-ClDlweEF.mjs';
|
|
10
9
|
import 'nextick';
|
|
11
10
|
import 'postcss';
|
|
12
11
|
import 'postcss-js';
|
|
13
12
|
import 'postcss-nested';
|
|
14
13
|
import 'autoprefixer';
|
|
15
|
-
import './jsx-runtime.mjs';
|
|
16
14
|
|
|
17
15
|
//
|
|
18
16
|
// document.ts
|
package/dist/web.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.mjs","sources":["../../src/web/document.ts","../../src/web/location.ts","../../src/web/observer.ts","../../src/web/online.ts","../../src/web/storage.ts","../../src/web/window.ts"],"sourcesContent":["//\n// document.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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 '../core/reconciler/state';\nimport { _DOMRenderer } from '../renderer/common';\n\nexport const useDocument = () => {\n const state = reconciler.currentHookState;\n if (!state) throw Error('useDocument must be used within a render function.');\n if (state.renderer instanceof _DOMRenderer) {\n return state.renderer.doc;\n } else {\n throw Error('Unsupported renderer.');\n }\n}","//\n// location.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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 '../core/hooks/memo';\nimport { useCallback } from '../core/hooks/callback';\nimport { useSyncExternalStore } from '../core/hooks/sync';\nimport { EventEmitter } from '../core/reconciler/events';\nimport { useDocument } from './document';\n\nconst emitters = new WeakMap<Document, EventEmitter>();\nconst emitterFor = (document: Document) => {\n if (!emitters.has(document)) emitters.set(document, new EventEmitter());\n return emitters.get(document)!;\n}\n\n/**\n * A hook that provides the current browser location and methods to manipulate the browser history.\n *\n * @returns An object with the following properties and methods:\n * - `hash`: The fragment identifier of the URL.\n * - `host`: The hostname and port number.\n * - `hostname`: The domain name.\n * - `href`: The full URL.\n * - `origin`: The protocol, hostname, and port.\n * - `pathname`: The path of the URL.\n * - `port`: The port number.\n * - `protocol`: The protocol scheme.\n * - `search`: The query string.\n * - `state`: The current state object associated with the history entry.\n * - `back()`: Navigates to the previous entry in the history stack.\n * - `forward()`: Navigates to the next entry in the history stack.\n * - `pushState(data, url)`: Pushes a new entry onto the history stack.\n * - `replaceState(data, url)`: Replaces the current history entry.\n *\n * The hook subscribes to changes in the browser's history and location, causing components to re-render when navigation occurs.\n *\n * @example\n * const location = useLocation();\n * console.log(location.pathname); // e.g., \"/about\"\n * location.pushState({ some: 'state' }, '/new-path');\n */\nexport const useLocation = () => {\n const document = useDocument();\n const emitter = emitterFor(document);\n const result = (history?: History) => ({\n ..._.pick(document.location, 'hash', 'host', 'hostname', 'href', 'origin', 'pathname', 'port', 'protocol', 'search'),\n state: history?.state ?? null,\n back: () => {\n history?.back();\n },\n forward: () => {\n history?.forward();\n emitter.emit('change');\n },\n pushState: (data: any, url?: string | URL | null) => {\n history?.pushState(data, '', url);\n emitter.emit('change');\n },\n replaceState: (data: any, url?: string | URL | null) => {\n history?.replaceState(data, '', url);\n emitter.emit('change');\n },\n });\n return useSyncExternalStore((onStoreChange) => {\n window.addEventListener('popstate', onStoreChange);\n const event = emitter.register('change', onStoreChange);\n return () => {\n window.removeEventListener('popstate', onStoreChange);\n event.remove();\n }\n }, () => result(window.history), () => result());\n}\n\ntype URLSearchParamsInit = ConstructorParameters<typeof URLSearchParams>[0];\n\n/**\n * A hook for reading and updating the URL's query string (search parameters).\n *\n * @returns A tuple:\n * - The first element is a `URLSearchParams` instance representing the current query string.\n * - The second element is a function to update the search parameters, which accepts any valid\n * `URLSearchParams` initializer (string, array, or object).\n *\n * Updating the search parameters will push a new history entry and update the URL in the address bar.\n *\n * @example\n * const [searchParams, setSearchParams] = useSearchParams();\n * const page = searchParams.get('page');\n * setSearchParams({ page: '2', filter: 'active' });\n */\nexport const useSearchParams = () => {\n const location = useLocation();\n const searchParams = useMemo(() => new URLSearchParams(location.search), [location.search]);\n const setSearchParams = useCallback((params: URLSearchParamsInit) => {\n const newParams = new URLSearchParams(params);\n location.pushState(location.state, `?${newParams.toString()}`);\n });\n return [searchParams, setSearchParams];\n}\n","//\n// observer.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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 { useEffect } from '../core/hooks/effect';\nimport { useCallback } from '../core/hooks/callback';\n\ninterface _Observer<T> {\n observe(target: Element, options?: T): void;\n unobserve(target: Element): void;\n}\n\nconst createObserver = <E extends { target: Element; }, T>(\n constructor: new (callback: (entries: E[]) => void) => _Observer<T>\n) => {\n const listeners = new WeakMap<Element, ((entry: E) => void)[]>();\n const observer = new constructor((entries) => {\n for (const entry of entries) {\n for (const listener of listeners.get(entry.target) ?? []) {\n (async () => {\n try {\n await listener(entry);\n } catch (e) {\n console.error(e);\n }\n })();\n }\n }\n });\n return {\n observe: (target: Element, callback: (entry: E) => void, options?: T) => {\n observer.observe(target, options);\n listeners.set(target, [...listeners.get(target) ?? [], callback]);\n },\n unobserve: (target: Element, callback: (entry: E) => void) => {\n const list = _.filter(listeners.get(target), x => x !== callback);\n listeners.set(target, list);\n if (_.isEmpty(list)) observer.unobserve?.(target);\n },\n };\n};\n\nconst observer = typeof window === 'undefined' ? undefined : {\n resize: createObserver(ResizeObserver),\n intersection: createObserver(IntersectionObserver),\n};\n\nexport const useResizeObserver = (\n target: Element | null | undefined,\n callback: (entry: ResizeObserverEntry) => void,\n options?: ResizeObserverOptions,\n) => {\n const _callback = useCallback(callback);\n useEffect(() => {\n if (!observer || !target) return;\n observer.resize.observe(target, _callback, options);\n return () => observer.resize.unobserve(target, _callback);\n }, [target]);\n}\n\nexport const useIntersectionObserver = (\n target: Element | null | undefined,\n callback: (entry: IntersectionObserverEntry) => void,\n) => {\n const _callback = useCallback(callback);\n useEffect(() => {\n if (!observer || !target) return;\n observer.intersection.observe(target, _callback);\n return () => observer.intersection.unobserve(target, _callback);\n }, [target]);\n}\n\nexport const useMutationObserver = (\n target: Node | null | undefined,\n callback: MutationCallback,\n options?: MutationObserverInit,\n) => {\n const _callback = useCallback(callback);\n useEffect(() => {\n if (typeof window === 'undefined' || !target) return;\n const observer = new MutationObserver(_callback);\n observer.observe(target, options);\n return () => observer.disconnect();\n }, [target]);\n}\n\nexport const usePerformanceObserver = (\n callback: PerformanceObserverCallback,\n options?: PerformanceObserverInit,\n) => {\n const _callback = useCallback(callback);\n useEffect(() => {\n if (typeof window === 'undefined') return;\n const observer = new PerformanceObserver(_callback);\n observer.observe(options);\n return () => observer.disconnect();\n }, []);\n}\n","//\n// online.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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 { useSyncExternalStore } from '../core/hooks/sync';\n\nexport const useOnline = () => useSyncExternalStore((onStoreChange) => {\n window.addEventListener('offline', onStoreChange);\n window.addEventListener('online', onStoreChange);\n return () => {\n window.removeEventListener('offline', onStoreChange);\n window.removeEventListener('online', onStoreChange);\n };\n}, () => navigator.onLine, () => false);","//\n// storage.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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 { useSyncExternalStore } from '../core/hooks/sync';\nimport { useCallback } from '../core/hooks/callback';\nimport { SetStateAction } from '../core/types/common';\nimport { EventEmitter } from '../core/reconciler/events';\n\nconst emitters = new WeakMap<Storage, EventEmitter>();\nconst emitterFor = (storage: Storage) => {\n if (!emitters.has(storage)) emitters.set(storage, new EventEmitter());\n return emitters.get(storage)!;\n}\n\nconst _useStorage = (\n storage: () => Storage,\n key: string,\n initialValue?: string | null\n) => {\n const state = useSyncExternalStore((onStoreChange) => {\n const _storage = storage();\n const emitter = emitterFor(_storage);\n const callback = (ev: StorageEvent) => { \n if (!ev.storageArea || ev.storageArea === _storage) onStoreChange();\n };\n window.addEventListener('storage', callback);\n const event = emitter.register('change', onStoreChange);\n return () => {\n window.removeEventListener('storage', callback);\n event.remove();\n }\n }, () => storage().getItem(key), () => undefined);\n const setState = useCallback((v: SetStateAction<string | null | undefined>) => {\n try {\n const _storage = storage();\n const newValue = _.isFunction(v) ? v(state) : v;\n if (_.isNil(newValue)) {\n _storage.removeItem(key);\n } else {\n _storage.setItem(key, newValue);\n }\n const emitter = emitterFor(_storage);\n emitter.emit('change');\n } catch (e) {\n console.error(e);\n }\n }, [key]);\n return [state ?? initialValue ?? null, setState] as const;\n}\n\nexport const useLocalStorage = (\n key: string,\n initialValue?: string | null\n) => _useStorage(() => window.localStorage, key, initialValue);\n\nexport const useSessionStorage = (\n key: string,\n initialValue?: string | null\n) => _useStorage(() => window.sessionStorage, key, initialValue);\n","//\n// window.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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 { useSyncExternalStore } from '../core/hooks/sync';\nimport { uniqueId } from '../core/utils';\n\nconst colorSchemeDark = typeof window !== 'undefined' ? window.matchMedia?.('(prefers-color-scheme: dark)') : undefined;\n\nconst emptyInsets = { top: 0, left: 0, right: 0, bottom: 0 };\nconst safeAreaInsets = () => {\n let support;\n if (!('CSS' in window) || typeof CSS.supports != 'function') {\n return emptyInsets;\n }\n if (CSS.supports('top: env(safe-area-inset-top)')) {\n support = 'env'\n } else if (CSS.supports('top: constant(safe-area-inset-top)')) {\n support = 'constant'\n } else {\n return emptyInsets;\n }\n const id = uniqueId();\n const style = document.createElement('style');\n style.textContent = `:root {\n --${id}-top: ${support}(safe-area-inset-top);\n --${id}-left: ${support}(safe-area-inset-left);\n --${id}-right: ${support}(safe-area-inset-right);\n --${id}-bottom: ${support}(safe-area-inset-bottom);\n }`;\n document.head.appendChild(style);\n const computedStyle = getComputedStyle(document.documentElement);\n const insets = {\n top: computedStyle.getPropertyValue(`--${id}-top`),\n left: computedStyle.getPropertyValue(`--${id}-left`),\n right: computedStyle.getPropertyValue(`--${id}-right`),\n bottom: computedStyle.getPropertyValue(`--${id}-bottom`),\n };\n style.remove();\n return _.mapValues(insets, v => parseFloat(v));\n}\n\nexport const useWindowMetrics = () => useSyncExternalStore((onStoreChange) => {\n window.addEventListener('resize', onStoreChange);\n return () => {\n window.removeEventListener('resize', onStoreChange);\n };\n}, () => ({\n safeAreaInsets: safeAreaInsets(),\n devicePixelRatio: window.devicePixelRatio,\n outerWidth: window.outerWidth,\n outerHeight: window.outerHeight,\n innerWidth: window.innerWidth,\n innerHeight: window.innerHeight,\n}), () => ({\n safeAreaInsets: emptyInsets,\n devicePixelRatio: 1,\n outerWidth: 0,\n outerHeight: 0,\n innerWidth: 0,\n innerHeight: 0,\n}));\n\nexport const useWindowScroll = () => useSyncExternalStore((onStoreChange) => {\n window.addEventListener('scroll', onStoreChange);\n return () => {\n window.removeEventListener('scroll', onStoreChange);\n };\n}, () => ({\n scrollX: window.scrollX,\n scrollY: window.scrollY,\n}), () => ({\n scrollX: 0,\n scrollY: 0,\n}));\n\nexport const useColorScheme = () => useSyncExternalStore((onStoreChange) => {\n colorSchemeDark?.addEventListener('change', onStoreChange);\n return () => {\n colorSchemeDark?.removeEventListener('change', onStoreChange);\n };\n}, () => colorSchemeDark?.matches ? 'dark' : 'light', () => 'light');\n"],"names":["emitters","emitterFor"],"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;AAMO,MAAM,WAAW,GAAG,MAAK;AAC9B,IAAA,MAAM,KAAK,GAAG,UAAU,CAAC,gBAAgB;AACzC,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,MAAM,KAAK,CAAC,oDAAoD,CAAC;AAC7E,IAAA,IAAI,KAAK,CAAC,QAAQ,YAAY,YAAY,EAAE;AAC1C,QAAA,OAAO,KAAK,CAAC,QAAQ,CAAC,GAAG;;SACpB;AACL,QAAA,MAAM,KAAK,CAAC,uBAAuB,CAAC;;AAExC;;ACrCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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../../src/web/document.ts","../../src/web/location.ts","../../src/web/observer.ts","../../src/web/online.ts","../../src/web/storage.ts","../../src/web/window.ts"],"sourcesContent":["//\n// document.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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 '../core/reconciler/state';\nimport { _DOMRenderer } from '../renderer/common';\n\nexport const useDocument = () => {\n const state = reconciler.currentHookState;\n if (!state) throw Error('useDocument must be used within a render function.');\n if (state.renderer instanceof _DOMRenderer) {\n return state.renderer.doc;\n } else {\n throw Error('Unsupported renderer.');\n }\n}","//\n// location.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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 '../core/hooks/memo';\nimport { useCallback } from '../core/hooks/callback';\nimport { useSyncExternalStore } from '../core/hooks/sync';\nimport { EventEmitter } from '../core/reconciler/events';\nimport { useDocument } from './document';\n\nconst emitters = new WeakMap<Document, EventEmitter>();\nconst emitterFor = (document: Document) => {\n if (!emitters.has(document)) emitters.set(document, new EventEmitter());\n return emitters.get(document)!;\n}\n\n/**\n * A hook that provides the current browser location and methods to manipulate the browser history.\n *\n * @returns An object with the following properties and methods:\n * - `hash`: The fragment identifier of the URL.\n * - `host`: The hostname and port number.\n * - `hostname`: The domain name.\n * - `href`: The full URL.\n * - `origin`: The protocol, hostname, and port.\n * - `pathname`: The path of the URL.\n * - `port`: The port number.\n * - `protocol`: The protocol scheme.\n * - `search`: The query string.\n * - `state`: The current state object associated with the history entry.\n * - `back()`: Navigates to the previous entry in the history stack.\n * - `forward()`: Navigates to the next entry in the history stack.\n * - `pushState(data, url)`: Pushes a new entry onto the history stack.\n * - `replaceState(data, url)`: Replaces the current history entry.\n *\n * The hook subscribes to changes in the browser's history and location, causing components to re-render when navigation occurs.\n *\n * @example\n * const location = useLocation();\n * console.log(location.pathname); // e.g., \"/about\"\n * location.pushState({ some: 'state' }, '/new-path');\n */\nexport const useLocation = () => {\n const document = useDocument();\n const emitter = emitterFor(document);\n const result = (history?: History) => ({\n ..._.pick(document.location, 'hash', 'host', 'hostname', 'href', 'origin', 'pathname', 'port', 'protocol', 'search'),\n state: history?.state ?? null,\n back: () => {\n history?.back();\n },\n forward: () => {\n history?.forward();\n emitter.emit('change');\n },\n pushState: (data: any, url?: string | URL | null) => {\n history?.pushState(data, '', url);\n emitter.emit('change');\n },\n replaceState: (data: any, url?: string | URL | null) => {\n history?.replaceState(data, '', url);\n emitter.emit('change');\n },\n });\n return useSyncExternalStore((onStoreChange) => {\n window.addEventListener('popstate', onStoreChange);\n const event = emitter.register('change', onStoreChange);\n return () => {\n window.removeEventListener('popstate', onStoreChange);\n event.remove();\n }\n }, () => result(window.history), () => result());\n}\n\ntype URLSearchParamsInit = ConstructorParameters<typeof URLSearchParams>[0];\n\n/**\n * A hook for reading and updating the URL's query string (search parameters).\n *\n * @returns A tuple:\n * - The first element is a `URLSearchParams` instance representing the current query string.\n * - The second element is a function to update the search parameters, which accepts any valid\n * `URLSearchParams` initializer (string, array, or object).\n *\n * Updating the search parameters will push a new history entry and update the URL in the address bar.\n *\n * @example\n * const [searchParams, setSearchParams] = useSearchParams();\n * const page = searchParams.get('page');\n * setSearchParams({ page: '2', filter: 'active' });\n */\nexport const useSearchParams = () => {\n const location = useLocation();\n const searchParams = useMemo(() => new URLSearchParams(location.search), [location.search]);\n const setSearchParams = useCallback((params: URLSearchParamsInit) => {\n const newParams = new URLSearchParams(params);\n location.pushState(location.state, `?${newParams.toString()}`);\n });\n return [searchParams, setSearchParams];\n}\n","//\n// observer.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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 { useEffect } from '../core/hooks/effect';\nimport { useCallback } from '../core/hooks/callback';\n\ninterface _Observer<T> {\n observe(target: Element, options?: T): void;\n unobserve(target: Element): void;\n}\n\nconst createObserver = <E extends { target: Element; }, T>(\n constructor: new (callback: (entries: E[]) => void) => _Observer<T>\n) => {\n const listeners = new WeakMap<Element, ((entry: E) => void)[]>();\n const observer = new constructor((entries) => {\n for (const entry of entries) {\n for (const listener of listeners.get(entry.target) ?? []) {\n (async () => {\n try {\n await listener(entry);\n } catch (e) {\n console.error(e);\n }\n })();\n }\n }\n });\n return {\n observe: (target: Element, callback: (entry: E) => void, options?: T) => {\n observer.observe(target, options);\n listeners.set(target, [...listeners.get(target) ?? [], callback]);\n },\n unobserve: (target: Element, callback: (entry: E) => void) => {\n const list = _.filter(listeners.get(target), x => x !== callback);\n listeners.set(target, list);\n if (_.isEmpty(list)) observer.unobserve?.(target);\n },\n };\n};\n\nconst observer = typeof window === 'undefined' ? undefined : {\n resize: createObserver(ResizeObserver),\n intersection: createObserver(IntersectionObserver),\n};\n\nexport const useResizeObserver = (\n target: Element | null | undefined,\n callback: (entry: ResizeObserverEntry) => void,\n options?: ResizeObserverOptions,\n) => {\n const _callback = useCallback(callback);\n useEffect(() => {\n if (!observer || !target) return;\n observer.resize.observe(target, _callback, options);\n return () => observer.resize.unobserve(target, _callback);\n }, [target]);\n}\n\nexport const useIntersectionObserver = (\n target: Element | null | undefined,\n callback: (entry: IntersectionObserverEntry) => void,\n) => {\n const _callback = useCallback(callback);\n useEffect(() => {\n if (!observer || !target) return;\n observer.intersection.observe(target, _callback);\n return () => observer.intersection.unobserve(target, _callback);\n }, [target]);\n}\n\nexport const useMutationObserver = (\n target: Node | null | undefined,\n callback: MutationCallback,\n options?: MutationObserverInit,\n) => {\n const _callback = useCallback(callback);\n useEffect(() => {\n if (typeof window === 'undefined' || !target) return;\n const observer = new MutationObserver(_callback);\n observer.observe(target, options);\n return () => observer.disconnect();\n }, [target]);\n}\n\nexport const usePerformanceObserver = (\n callback: PerformanceObserverCallback,\n options?: PerformanceObserverInit,\n) => {\n const _callback = useCallback(callback);\n useEffect(() => {\n if (typeof window === 'undefined') return;\n const observer = new PerformanceObserver(_callback);\n observer.observe(options);\n return () => observer.disconnect();\n }, []);\n}\n","//\n// online.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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 { useSyncExternalStore } from '../core/hooks/sync';\n\nexport const useOnline = () => useSyncExternalStore((onStoreChange) => {\n window.addEventListener('offline', onStoreChange);\n window.addEventListener('online', onStoreChange);\n return () => {\n window.removeEventListener('offline', onStoreChange);\n window.removeEventListener('online', onStoreChange);\n };\n}, () => navigator.onLine, () => false);","//\n// storage.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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 { useSyncExternalStore } from '../core/hooks/sync';\nimport { useCallback } from '../core/hooks/callback';\nimport { SetStateAction } from '../core/types/common';\nimport { EventEmitter } from '../core/reconciler/events';\n\nconst emitters = new WeakMap<Storage, EventEmitter>();\nconst emitterFor = (storage: Storage) => {\n if (!emitters.has(storage)) emitters.set(storage, new EventEmitter());\n return emitters.get(storage)!;\n}\n\nconst _useStorage = (\n storage: () => Storage,\n key: string,\n initialValue?: string | null\n) => {\n const state = useSyncExternalStore((onStoreChange) => {\n const _storage = storage();\n const emitter = emitterFor(_storage);\n const callback = (ev: StorageEvent) => { \n if (!ev.storageArea || ev.storageArea === _storage) onStoreChange();\n };\n window.addEventListener('storage', callback);\n const event = emitter.register('change', onStoreChange);\n return () => {\n window.removeEventListener('storage', callback);\n event.remove();\n }\n }, () => storage().getItem(key), () => undefined);\n const setState = useCallback((v: SetStateAction<string | null | undefined>) => {\n try {\n const _storage = storage();\n const newValue = _.isFunction(v) ? v(state) : v;\n if (_.isNil(newValue)) {\n _storage.removeItem(key);\n } else {\n _storage.setItem(key, newValue);\n }\n const emitter = emitterFor(_storage);\n emitter.emit('change');\n } catch (e) {\n console.error(e);\n }\n }, [key]);\n return [state ?? initialValue ?? null, setState] as const;\n}\n\nexport const useLocalStorage = (\n key: string,\n initialValue?: string | null\n) => _useStorage(() => window.localStorage, key, initialValue);\n\nexport const useSessionStorage = (\n key: string,\n initialValue?: string | null\n) => _useStorage(() => window.sessionStorage, key, initialValue);\n","//\n// window.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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 { useSyncExternalStore } from '../core/hooks/sync';\nimport { uniqueId } from '../core/utils';\n\nconst colorSchemeDark = typeof window !== 'undefined' ? window.matchMedia?.('(prefers-color-scheme: dark)') : undefined;\n\nconst emptyInsets = { top: 0, left: 0, right: 0, bottom: 0 };\nconst safeAreaInsets = () => {\n let support;\n if (!('CSS' in window) || typeof CSS.supports != 'function') {\n return emptyInsets;\n }\n if (CSS.supports('top: env(safe-area-inset-top)')) {\n support = 'env'\n } else if (CSS.supports('top: constant(safe-area-inset-top)')) {\n support = 'constant'\n } else {\n return emptyInsets;\n }\n const id = uniqueId();\n const style = document.createElement('style');\n style.textContent = `:root {\n --${id}-top: ${support}(safe-area-inset-top);\n --${id}-left: ${support}(safe-area-inset-left);\n --${id}-right: ${support}(safe-area-inset-right);\n --${id}-bottom: ${support}(safe-area-inset-bottom);\n }`;\n document.head.appendChild(style);\n const computedStyle = getComputedStyle(document.documentElement);\n const insets = {\n top: computedStyle.getPropertyValue(`--${id}-top`),\n left: computedStyle.getPropertyValue(`--${id}-left`),\n right: computedStyle.getPropertyValue(`--${id}-right`),\n bottom: computedStyle.getPropertyValue(`--${id}-bottom`),\n };\n style.remove();\n return _.mapValues(insets, v => parseFloat(v));\n}\n\nexport const useWindowMetrics = () => useSyncExternalStore((onStoreChange) => {\n window.addEventListener('resize', onStoreChange);\n return () => {\n window.removeEventListener('resize', onStoreChange);\n };\n}, () => ({\n safeAreaInsets: safeAreaInsets(),\n devicePixelRatio: window.devicePixelRatio,\n outerWidth: window.outerWidth,\n outerHeight: window.outerHeight,\n innerWidth: window.innerWidth,\n innerHeight: window.innerHeight,\n}), () => ({\n safeAreaInsets: emptyInsets,\n devicePixelRatio: 1,\n outerWidth: 0,\n outerHeight: 0,\n innerWidth: 0,\n innerHeight: 0,\n}));\n\nexport const useWindowScroll = () => useSyncExternalStore((onStoreChange) => {\n window.addEventListener('scroll', onStoreChange);\n return () => {\n window.removeEventListener('scroll', onStoreChange);\n };\n}, () => ({\n scrollX: window.scrollX,\n scrollY: window.scrollY,\n}), () => ({\n scrollX: 0,\n scrollY: 0,\n}));\n\nexport const useColorScheme = () => useSyncExternalStore((onStoreChange) => {\n colorSchemeDark?.addEventListener('change', onStoreChange);\n return () => {\n colorSchemeDark?.removeEventListener('change', onStoreChange);\n };\n}, () => colorSchemeDark?.matches ? 'dark' : 'light', () => 'light');\n"],"names":["emitters","emitterFor"],"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;AAMO,MAAM,WAAW,GAAG,MAAK;AAC9B,IAAA,MAAM,KAAK,GAAG,UAAU,CAAC,gBAAgB;AACzC,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,MAAM,KAAK,CAAC,oDAAoD,CAAC;AAC7E,IAAA,IAAI,KAAK,CAAC,QAAQ,YAAY,YAAY,EAAE;AAC1C,QAAA,OAAO,KAAK,CAAC,QAAQ,CAAC,GAAG;;SACpB;AACL,QAAA,MAAM,KAAK,CAAC,uBAAuB,CAAC;;AAExC;;ACrCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AASA,MAAMA,UAAQ,GAAG,IAAI,OAAO,EAA0B;AACtD,MAAMC,YAAU,GAAG,CAAC,QAAkB,KAAI;AACxC,IAAA,IAAI,CAACD,UAAQ,CAAC,GAAG,CAAC,QAAQ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U,EAAE,MAAM,CAAC,UAAU;IAC7B,WAAW,EAAE,MAAM,CAAC,WAAW;AAChC,CAAA,CAAC,EAAE,OAAO;AACT,IAAA,cAAc,EAAE,WAAW;AAC3B,IAAA,gBAAgB,EAAE,CAAC;AACnB,IAAA,UAAU,EAAE,CAAC;AACb,IAAA,WAAW,EAAE,CAAC;AACd,IAAA,UAAU,EAAE,CAAC;AACb,IAAA,WAAW,EAAE,CAAC;AACf,CAAA,CAAC;AAEK,MAAM,eAAe,GAAG,MAAM,oBAAoB,CAAC,CAAC,aAAa,KAAI;AAC1E,IAAA,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,aAAa,CAAC;AAChD,IAAA,OAAO,MAAK;AACV,QAAA,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,aAAa,CAAC;AACrD,KAAC;AACH,CAAC,EAAE,OAAO;IACR,OAAO,EAAE,MAAM,CAAC,OAAO;IACvB,OAAO,EAAE,MAAM,CAAC,OAAO;AACxB,CAAA,CAAC,EAAE,OAAO;AACT,IAAA,OAAO,EAAE,CAAC;AACV,IAAA,OAAO,EAAE,CAAC;AACX,CAAA,CAAC;AAEK,MAAM,cAAc,GAAG,MAAM,oBAAoB,CAAC,CAAC,aAAa,KAAI;AACzE,IAAA,eAAe,EAAE,gBAAgB,CAAC,QAAQ,EAAE,aAAa,CAAC;AAC1D,IAAA,OAAO,MAAK;AACV,QAAA,eAAe,EAAE,mBAAmB,CAAC,QAAQ,EAAE,aAAa,CAAC;AAC/D,KAAC;AACH,CAAC,EAAE,MAAM,eAAe,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,EAAE,MAAM,OAAO;;;;"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common-BLDQwvsd.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common-oNHXt-X6.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { jsx } from '../jsx-runtime.mjs';
|
|
2
|
-
import { e as equalDeps, r as reconciler, c as createContext, a as useContext } from './state-CK2bzUOk.mjs';
|
|
3
|
-
import _ from 'lodash';
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
// index.ts
|
|
7
|
-
//
|
|
8
|
-
// The MIT License
|
|
9
|
-
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
10
|
-
//
|
|
11
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
13
|
-
// in the Software without restriction, including without limitation the rights
|
|
14
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
16
|
-
// furnished to do so, subject to the following conditions:
|
|
17
|
-
//
|
|
18
|
-
// The above copyright notice and this permission notice shall be included in
|
|
19
|
-
// all copies or substantial portions of the Software.
|
|
20
|
-
//
|
|
21
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
27
|
-
// THE SOFTWARE.
|
|
28
|
-
//
|
|
29
|
-
const _useHookState = (hook) => {
|
|
30
|
-
const state = reconciler.currentHookState;
|
|
31
|
-
if (!state)
|
|
32
|
-
throw Error(`${hook} must be used within a render function.`);
|
|
33
|
-
const { prevState, state: newState } = state;
|
|
34
|
-
if (prevState && prevState[newState.length]?.hook !== hook) {
|
|
35
|
-
console.warn([
|
|
36
|
-
`Hook "${hook}" is called conditionally.`,
|
|
37
|
-
'Hooks must be called in the exact same order in every component render.',
|
|
38
|
-
'Did you accidentally call a hook after an early return?'
|
|
39
|
-
].join(' '));
|
|
40
|
-
}
|
|
41
|
-
return state;
|
|
42
|
-
};
|
|
43
|
-
const _useEffect = (hook, effect, deps) => {
|
|
44
|
-
const state = _useHookState(hook);
|
|
45
|
-
const { state: newState } = state;
|
|
46
|
-
newState.push({
|
|
47
|
-
mount: () => effect(state),
|
|
48
|
-
deps,
|
|
49
|
-
hook,
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
const _useMemo = (hook, factory, deps) => {
|
|
53
|
-
const state = _useHookState(hook);
|
|
54
|
-
const { prevState, state: newState } = state;
|
|
55
|
-
const idx = newState.length;
|
|
56
|
-
const changed = prevState?.[idx]?.hook !== hook || !equalDeps(prevState[idx].deps, deps);
|
|
57
|
-
const data = changed ? factory(state) : prevState[idx].data;
|
|
58
|
-
newState.push({
|
|
59
|
-
deps,
|
|
60
|
-
hook,
|
|
61
|
-
data
|
|
62
|
-
});
|
|
63
|
-
return data;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
//
|
|
67
|
-
// memo.ts
|
|
68
|
-
//
|
|
69
|
-
// The MIT License
|
|
70
|
-
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
71
|
-
//
|
|
72
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
73
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
74
|
-
// in the Software without restriction, including without limitation the rights
|
|
75
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
76
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
77
|
-
// furnished to do so, subject to the following conditions:
|
|
78
|
-
//
|
|
79
|
-
// The above copyright notice and this permission notice shall be included in
|
|
80
|
-
// all copies or substantial portions of the Software.
|
|
81
|
-
//
|
|
82
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
83
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
84
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
85
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
86
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
87
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
88
|
-
// THE SOFTWARE.
|
|
89
|
-
//
|
|
90
|
-
function useState(initialState) {
|
|
91
|
-
const { value, setValue } = _useMemo('useState', ({ node }) => {
|
|
92
|
-
const state = {
|
|
93
|
-
value: _.isFunction(initialState) ? initialState() : initialState,
|
|
94
|
-
setValue: (dispatch) => {
|
|
95
|
-
state.value = _.isFunction(dispatch) ? dispatch(state.value) : dispatch;
|
|
96
|
-
node?._setDirty();
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
return state;
|
|
100
|
-
}, null);
|
|
101
|
-
return [value, setValue];
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
//
|
|
105
|
-
// memo.ts
|
|
106
|
-
//
|
|
107
|
-
// The MIT License
|
|
108
|
-
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
109
|
-
//
|
|
110
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
111
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
112
|
-
// in the Software without restriction, including without limitation the rights
|
|
113
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
114
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
115
|
-
// furnished to do so, subject to the following conditions:
|
|
116
|
-
//
|
|
117
|
-
// The above copyright notice and this permission notice shall be included in
|
|
118
|
-
// all copies or substantial portions of the Software.
|
|
119
|
-
//
|
|
120
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
121
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
122
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
123
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
124
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
125
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
126
|
-
// THE SOFTWARE.
|
|
127
|
-
//
|
|
128
|
-
/**
|
|
129
|
-
* A utility function that memoizes the result of a factory function.
|
|
130
|
-
*
|
|
131
|
-
* @template T The type of the value returned by the factory function.
|
|
132
|
-
* @param factory A function that produces a value to be memoized.
|
|
133
|
-
* @param deps An optional dependency array. The memoized value is recalculated
|
|
134
|
-
* only when the dependencies change.
|
|
135
|
-
* @returns The memoized value produced by the factory function.
|
|
136
|
-
*/
|
|
137
|
-
const useMemo = (factory, deps) => _useMemo('useMemo', factory, deps);
|
|
138
|
-
|
|
139
|
-
const Context = createContext({
|
|
140
|
-
errors: [],
|
|
141
|
-
setErrors: () => { },
|
|
142
|
-
});
|
|
143
|
-
/**
|
|
144
|
-
* A context provider component for managing asynchronous resource errors.
|
|
145
|
-
*
|
|
146
|
-
* This component provides a shared context for tracking errors encountered during
|
|
147
|
-
* asynchronous operations. It allows child components to access and manage these errors
|
|
148
|
-
* using the `useResourceErrors` hook.
|
|
149
|
-
*
|
|
150
|
-
* ### Usage:
|
|
151
|
-
* Wrap your application or specific parts of it with this component to enable error tracking:
|
|
152
|
-
*
|
|
153
|
-
* ```tsx
|
|
154
|
-
* <ResourceErrors>
|
|
155
|
-
* <YourComponent />
|
|
156
|
-
* </ResourceErrors>
|
|
157
|
-
* ```
|
|
158
|
-
*
|
|
159
|
-
* @param children - The child components that will have access to the error context.
|
|
160
|
-
*
|
|
161
|
-
* @returns A context provider that wraps the provided children.
|
|
162
|
-
*/
|
|
163
|
-
const ResourceErrors = ({ children }) => {
|
|
164
|
-
const [errors, setErrors] = useState([]);
|
|
165
|
-
const value = useMemo(() => ({ errors, setErrors }), [errors, setErrors]);
|
|
166
|
-
return (jsx(Context, { value: value, children: children }));
|
|
167
|
-
};
|
|
168
|
-
/**
|
|
169
|
-
* A hook to access the list of asynchronous resource errors.
|
|
170
|
-
*
|
|
171
|
-
* This hook allows components to retrieve the current list of errors being tracked
|
|
172
|
-
* in the `ResourceErrors` context. It must be used within a component that is
|
|
173
|
-
* a descendant of the `ResourceErrors` provider.
|
|
174
|
-
*
|
|
175
|
-
* ### Usage:
|
|
176
|
-
* ```tsx
|
|
177
|
-
* const errors = useResourceErrors();
|
|
178
|
-
*
|
|
179
|
-
* errors.forEach(({ token, error, refresh }) => {
|
|
180
|
-
* console.error(`Error [${token}]:`, error);
|
|
181
|
-
* // Optionally call refresh() to retry the operation
|
|
182
|
-
* });
|
|
183
|
-
* ```
|
|
184
|
-
*
|
|
185
|
-
* @returns The list of errors currently being tracked in the context. Each error includes:
|
|
186
|
-
* - `token`: A unique identifier for the error.
|
|
187
|
-
* - `error`: The error object or message.
|
|
188
|
-
* - `refresh`: A function to retry the operation that caused the error.
|
|
189
|
-
*/
|
|
190
|
-
const useResourceErrors = () => useContext(Context).errors;
|
|
191
|
-
|
|
192
|
-
export { Context as C, ResourceErrors as R, _useEffect as _, _useMemo as a, useMemo as b, useResourceErrors as c, useState as u };
|
|
193
|
-
//# sourceMappingURL=error-BT7hiUUR.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error-BT7hiUUR.mjs","sources":["../../../src/core/reconciler/hooks.ts","../../../src/core/hooks/state.ts","../../../src/core/hooks/memo.ts","../../../src/core/hooks/misc/resource/error.tsx"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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 './state';\nimport { equalDeps } from './utils';\n\nconst _useHookState = (hook: string) => {\n const state = reconciler.currentHookState;\n if (!state) throw Error(`${hook} must be used within a render function.`);\n const { prevState, state: newState } = state;\n if (prevState && prevState[newState.length]?.hook !== hook) {\n console.warn([\n `Hook \"${hook}\" is called conditionally.`,\n 'Hooks must be called in the exact same order in every component render.',\n 'Did you accidentally call a hook after an early return?'\n ].join(' '));\n }\n return state;\n};\n\nexport const _useEffect = (\n hook: string,\n effect: (state: ReturnType<typeof _useHookState>) => () => void,\n deps?: any\n) => {\n const state = _useHookState(hook);\n const { state: newState } = state;\n newState.push({\n mount: () => effect(state),\n deps,\n hook,\n });\n};\n\nexport const _useMemo = <T>(\n hook: string,\n factory: (state: ReturnType<typeof _useHookState>) => T,\n deps?: any\n): T => {\n const state = _useHookState(hook);\n const { prevState, state: newState } = state;\n const idx = newState.length;\n const changed = prevState?.[idx]?.hook !== hook || !equalDeps(prevState[idx].deps, deps);\n const data = changed ? factory(state) : prevState[idx].data;\n newState.push({\n deps,\n hook,\n data\n });\n return data;\n};\n","//\n// memo.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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', ({ node }) => {\n const state = {\n value: _.isFunction(initialState) ? initialState() : initialState,\n setValue: (dispatch: SetStateAction<any>) => {\n state.value = _.isFunction(dispatch) ? dispatch(state.value) : dispatch;\n node?._setDirty();\n },\n };\n return state;\n }, null);\n return [value, setValue];\n}\n","//\n// memo.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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';\n\n/**\n * A utility function that memoizes the result of a factory function.\n * \n * @template T The type of the value returned by the factory function.\n * @param factory A function that produces a value to be memoized.\n * @param deps An optional dependency array. The memoized value is recalculated \n * only when the dependencies change.\n * @returns The memoized value produced by the factory function.\n */\nexport const useMemo = <T>(\n factory: () => T,\n deps?: any,\n) => _useMemo('useMemo', factory, deps);\n","//\n// error.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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';\n\ntype Errors = {\n token: string;\n error: any;\n refresh: () => Awaitable<void>;\n refreshing: boolean;\n loading: boolean;\n}[];\n\nexport const Context = createContext<{\n errors: Errors;\n setErrors: (values: SetStateAction<Errors>) => void;\n}>({\n errors: [],\n setErrors: () => { },\n});\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\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 * const errors = useResourceErrors();\n * \n * errors.forEach(({ token, error, refresh }) => {\n * console.error(`Error [${token}]:`, error);\n * // Optionally call refresh() to retry the operation\n * });\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 = () => useContext(Context).errors;\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;AAMA,MAAM,aAAa,GAAG,CAAC,IAAY,KAAI;AACrC,IAAA,MAAM,KAAK,GAAG,UAAU,CAAC,gBAAgB;AACzC,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,MAAM,KAAK,CAAC,CAAA,EAAG,IAAI,CAAA,uCAAA,CAAyC,CAAC;IACzE,MAAM,EAAE,SAAS,EAAE,K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AM,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACzE,QACEA,GAAC,CAAA,OAAO,EAAC,EAAA,KAAK,EAAE,KAAK,EAAG,QAAA,EAAA,QAAQ,EAAW,CAAA;AAE/C;AAEA;;;;;;;;;;;;;;;;;;;;;AAqBG;AACI,MAAM,iBAAiB,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC;;;;"}
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var jsxRuntime = require('../jsx-runtime.js');
|
|
4
|
-
var state = require('./state-CKAt_mTM.js');
|
|
5
|
-
var _ = require('lodash');
|
|
6
|
-
|
|
7
|
-
//
|
|
8
|
-
// index.ts
|
|
9
|
-
//
|
|
10
|
-
// The MIT License
|
|
11
|
-
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
12
|
-
//
|
|
13
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
15
|
-
// in the Software without restriction, including without limitation the rights
|
|
16
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
18
|
-
// furnished to do so, subject to the following conditions:
|
|
19
|
-
//
|
|
20
|
-
// The above copyright notice and this permission notice shall be included in
|
|
21
|
-
// all copies or substantial portions of the Software.
|
|
22
|
-
//
|
|
23
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
29
|
-
// THE SOFTWARE.
|
|
30
|
-
//
|
|
31
|
-
const _useHookState = (hook) => {
|
|
32
|
-
const state$1 = state.reconciler.currentHookState;
|
|
33
|
-
if (!state$1)
|
|
34
|
-
throw Error(`${hook} must be used within a render function.`);
|
|
35
|
-
const { prevState, state: newState } = state$1;
|
|
36
|
-
if (prevState && prevState[newState.length]?.hook !== hook) {
|
|
37
|
-
console.warn([
|
|
38
|
-
`Hook "${hook}" is called conditionally.`,
|
|
39
|
-
'Hooks must be called in the exact same order in every component render.',
|
|
40
|
-
'Did you accidentally call a hook after an early return?'
|
|
41
|
-
].join(' '));
|
|
42
|
-
}
|
|
43
|
-
return state$1;
|
|
44
|
-
};
|
|
45
|
-
const _useEffect = (hook, effect, deps) => {
|
|
46
|
-
const state = _useHookState(hook);
|
|
47
|
-
const { state: newState } = state;
|
|
48
|
-
newState.push({
|
|
49
|
-
mount: () => effect(state),
|
|
50
|
-
deps,
|
|
51
|
-
hook,
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
const _useMemo = (hook, factory, deps) => {
|
|
55
|
-
const state$1 = _useHookState(hook);
|
|
56
|
-
const { prevState, state: newState } = state$1;
|
|
57
|
-
const idx = newState.length;
|
|
58
|
-
const changed = prevState?.[idx]?.hook !== hook || !state.equalDeps(prevState[idx].deps, deps);
|
|
59
|
-
const data = changed ? factory(state$1) : prevState[idx].data;
|
|
60
|
-
newState.push({
|
|
61
|
-
deps,
|
|
62
|
-
hook,
|
|
63
|
-
data
|
|
64
|
-
});
|
|
65
|
-
return data;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
//
|
|
69
|
-
// memo.ts
|
|
70
|
-
//
|
|
71
|
-
// The MIT License
|
|
72
|
-
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
73
|
-
//
|
|
74
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
75
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
76
|
-
// in the Software without restriction, including without limitation the rights
|
|
77
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
78
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
79
|
-
// furnished to do so, subject to the following conditions:
|
|
80
|
-
//
|
|
81
|
-
// The above copyright notice and this permission notice shall be included in
|
|
82
|
-
// all copies or substantial portions of the Software.
|
|
83
|
-
//
|
|
84
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
85
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
86
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
87
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
88
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
89
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
90
|
-
// THE SOFTWARE.
|
|
91
|
-
//
|
|
92
|
-
function useState(initialState) {
|
|
93
|
-
const { value, setValue } = _useMemo('useState', ({ node }) => {
|
|
94
|
-
const state = {
|
|
95
|
-
value: _.isFunction(initialState) ? initialState() : initialState,
|
|
96
|
-
setValue: (dispatch) => {
|
|
97
|
-
state.value = _.isFunction(dispatch) ? dispatch(state.value) : dispatch;
|
|
98
|
-
node?._setDirty();
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
return state;
|
|
102
|
-
}, null);
|
|
103
|
-
return [value, setValue];
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
//
|
|
107
|
-
// memo.ts
|
|
108
|
-
//
|
|
109
|
-
// The MIT License
|
|
110
|
-
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
111
|
-
//
|
|
112
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
113
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
114
|
-
// in the Software without restriction, including without limitation the rights
|
|
115
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
116
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
117
|
-
// furnished to do so, subject to the following conditions:
|
|
118
|
-
//
|
|
119
|
-
// The above copyright notice and this permission notice shall be included in
|
|
120
|
-
// all copies or substantial portions of the Software.
|
|
121
|
-
//
|
|
122
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
123
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
124
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
125
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
126
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
127
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
128
|
-
// THE SOFTWARE.
|
|
129
|
-
//
|
|
130
|
-
/**
|
|
131
|
-
* A utility function that memoizes the result of a factory function.
|
|
132
|
-
*
|
|
133
|
-
* @template T The type of the value returned by the factory function.
|
|
134
|
-
* @param factory A function that produces a value to be memoized.
|
|
135
|
-
* @param deps An optional dependency array. The memoized value is recalculated
|
|
136
|
-
* only when the dependencies change.
|
|
137
|
-
* @returns The memoized value produced by the factory function.
|
|
138
|
-
*/
|
|
139
|
-
const useMemo = (factory, deps) => _useMemo('useMemo', factory, deps);
|
|
140
|
-
|
|
141
|
-
const Context = state.createContext({
|
|
142
|
-
errors: [],
|
|
143
|
-
setErrors: () => { },
|
|
144
|
-
});
|
|
145
|
-
/**
|
|
146
|
-
* A context provider component for managing asynchronous resource errors.
|
|
147
|
-
*
|
|
148
|
-
* This component provides a shared context for tracking errors encountered during
|
|
149
|
-
* asynchronous operations. It allows child components to access and manage these errors
|
|
150
|
-
* using the `useResourceErrors` hook.
|
|
151
|
-
*
|
|
152
|
-
* ### Usage:
|
|
153
|
-
* Wrap your application or specific parts of it with this component to enable error tracking:
|
|
154
|
-
*
|
|
155
|
-
* ```tsx
|
|
156
|
-
* <ResourceErrors>
|
|
157
|
-
* <YourComponent />
|
|
158
|
-
* </ResourceErrors>
|
|
159
|
-
* ```
|
|
160
|
-
*
|
|
161
|
-
* @param children - The child components that will have access to the error context.
|
|
162
|
-
*
|
|
163
|
-
* @returns A context provider that wraps the provided children.
|
|
164
|
-
*/
|
|
165
|
-
const ResourceErrors = ({ children }) => {
|
|
166
|
-
const [errors, setErrors] = useState([]);
|
|
167
|
-
const value = useMemo(() => ({ errors, setErrors }), [errors, setErrors]);
|
|
168
|
-
return (jsxRuntime.jsx(Context, { value: value, children: children }));
|
|
169
|
-
};
|
|
170
|
-
/**
|
|
171
|
-
* A hook to access the list of asynchronous resource errors.
|
|
172
|
-
*
|
|
173
|
-
* This hook allows components to retrieve the current list of errors being tracked
|
|
174
|
-
* in the `ResourceErrors` context. It must be used within a component that is
|
|
175
|
-
* a descendant of the `ResourceErrors` provider.
|
|
176
|
-
*
|
|
177
|
-
* ### Usage:
|
|
178
|
-
* ```tsx
|
|
179
|
-
* const errors = useResourceErrors();
|
|
180
|
-
*
|
|
181
|
-
* errors.forEach(({ token, error, refresh }) => {
|
|
182
|
-
* console.error(`Error [${token}]:`, error);
|
|
183
|
-
* // Optionally call refresh() to retry the operation
|
|
184
|
-
* });
|
|
185
|
-
* ```
|
|
186
|
-
*
|
|
187
|
-
* @returns The list of errors currently being tracked in the context. Each error includes:
|
|
188
|
-
* - `token`: A unique identifier for the error.
|
|
189
|
-
* - `error`: The error object or message.
|
|
190
|
-
* - `refresh`: A function to retry the operation that caused the error.
|
|
191
|
-
*/
|
|
192
|
-
const useResourceErrors = () => state.useContext(Context).errors;
|
|
193
|
-
|
|
194
|
-
exports.Context = Context;
|
|
195
|
-
exports.ResourceErrors = ResourceErrors;
|
|
196
|
-
exports._useEffect = _useEffect;
|
|
197
|
-
exports._useMemo = _useMemo;
|
|
198
|
-
exports.useMemo = useMemo;
|
|
199
|
-
exports.useResourceErrors = useResourceErrors;
|
|
200
|
-
exports.useState = useState;
|
|
201
|
-
//# sourceMappingURL=error-Cbb2rheX.js.map
|