frosty 0.0.35 → 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-CpyVZMmY.mjs → common-BoxPKJqo.mjs} +12 -6
- package/dist/internals/{common-CpyVZMmY.mjs.map → common-BoxPKJqo.mjs.map} +1 -1
- package/dist/internals/{common-CpemFzvV.js → common-CRYEvU6P.js} +13 -7
- package/dist/internals/{common-CpemFzvV.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-CltTZzud.d.ts → common-D44KuOmi.d.ts} +7 -4
- 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 +3 -5
- package/dist/internals/common-CltTZzud.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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error-Cbb2rheX.js","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":["state","reconciler","equalDeps","createContext","_jsx","useContext"],"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,MAAMA,OAAK,GAAGC,gBAAU,CAAC,gBAAgB;AACzC,IAAA,IAAI,CAACD,OAAK;AAAE,QAAA,MAAM,KAAK,CAAC,CAAA,EAAG,IAAI,CAAA,uCAAA,CAAyC,CAAC;IACzE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAGA,OAAK;AAC5C,IAAA,IAAI,SAAS,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,KAAK,IAAI,EAAE;QAC1D,OAAO,CAAC,IAAI,CAAC;AACX,YAAA,CAAA,MAAA,EAAS,IAAI,CAA4B,0BAAA,CAAA;YACzC,yEAAyE;YACzE;AACD,SAAA,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;;AAEd,IAAA,OAAOA,OAAK;AACd,CAAC;AAEY,MAAA,UAAU,GAAG,CACxB,IAAY,EACZ,MAA+D,EAC/D,IAAU,KACR;AACF,IAAA,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC;AACjC,IAAA,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK;IACjC,QAAQ,CAAC,IAAI,CAAC;AACZ,QAAA,KAAK,EAAE,MAAM,MAAM,CAAC,KAAK,CAAC;QAC1B,IAAI;QACJ,IAAI;AACL,KAAA,CAAC;AACJ;AAEa,MAAA,QAAQ,GAAG,CACtB,IAAY,EACZ,OAAuD,EACvD,IAAU,KACL;AACL,IAAA,MAAMA,OAAK,G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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;;;;;;;;AAQG;AACU,MAAA,OAAO,GAAG,CACrB,OAAgB,EAChB,IAAU,KACP,QAAQ,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI;;ACC/B,MAAM,OAAO,GAAGG,mBAAa,CAGjC;AACD,IAAA,MAAM,EAAE,EAAE;AACV,IAAA,SAAS,EAAE,MAAK,GAAI;AACrB,CAAA;AAED;;;;;;;;;;;;;;;;;;;AAmBG;MACU,cAAc,GAAyC,CAAC,EACnE,QAAQ,EACT,KAAI;IACH,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAS,EAAE,CAAC;IAChD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACzE,QACEC,cAAC,CAAA,OAAO,EAAC,EAAA,KAAK,EAAE,KAAK,EAAG,QAAA,EAAA,QAAQ,EAAW,CAAA;AAE/C;AAEA;;;;;;;;;;;;;;;;;;;;;AAqBG;AACI,MAAM,iBAAiB,GAAG,MAAMC,gBAAU,CAAC,OAAO,CAAC,CAAC;;;;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fragment-BkyAEmoa.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderer-Bmw8wKAf.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-DrGYUphO.mjs","sources":["../../../src/core/types/component.ts","../../../src/core/types/runtime.ts"],"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 { _ElementType, PropsType } from './runtime';\n\nexport abstract class NativeElementType {\n constructor(...args: any[]) { };\n}\n\nexport class ComponentNode {\n\n /** @internal */\n private _type: _ElementType | typeof NativeElementType;\n\n /** @internal */\n private _props: PropsType;\n\n /** @internal */\n private _key?: string | number;\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 /** @internal */\n _equal(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 - 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 { MergeObject, PickType, WritableKeys } from '@o2ter/utils-js';\nimport { ComponentType, ElementNode, PropsWithChildren, RefAttribute } from './common';\nimport { ClassName, StyleProp } from './style';\nimport { _CSSProperties, CSSProperties } 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;\n};\n\nexport type PropsType = Record<string, any>;\n\ntype EventHandler<E extends Event, C, T = EventTarget> = (event: E & {\n currentTarget: C;\n target: T;\n }) => void;\ntype EventMap = {\n [ev in typeof globalEvents[number]]: 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 RefAttribute<ElementMap[x]['type'] | null | undefined>\n & {\n className?: ClassName;\n style?: StyleProp<CSSProperties>;\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"],"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,WAAY,CAAA,GAAG,IAAW,EAAA;;AAC3B;MAEY,aAAa,CAAA;;AAGhB,IAAA,KAAK;;AAGL,IAAA,MAAM;;AAGN,IAAA,IAAI;;AAGZ,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;;AAGjB,IAAA,IAAI,IAAI,GAAA;QACN,OAAO,IAAI,CAAC,KAAK;;AAGnB,IAAA,IAAI,KAAK,GAAA;QACP,OAAO,IAAI,CAAC,MAAM;;AAGpB,IAAA,IAAI,GAAG,GAAA;QACL,OAAO,IAAI,CAAC,IAAI;;;AAIlB,IAAA,MAAM,CAAC,KAAoB,EAAA;AACzB,QAAA,OAAO,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG;;AAE5D;;ACtED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MA6Da,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;AAEa,MAAA,aAAa,GAAG,CAC3B,IAAkB,EAClB,KAAwB,EACxB,GAAG,QAAuB,KACvB,cAAc,CAAC,IAAI,EAAE,EAAE,GAAG,KAAK,IAAI,EAAE,EAAE,QAAQ,EAAE;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-PKOt40BM.js","sources":["../../../src/core/types/component.ts","../../../src/core/types/runtime.ts"],"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 { _ElementType, PropsType } from './runtime';\n\nexport abstract class NativeElementType {\n constructor(...args: any[]) { };\n}\n\nexport class ComponentNode {\n\n /** @internal */\n private _type: _ElementType | typeof NativeElementType;\n\n /** @internal */\n private _props: PropsType;\n\n /** @internal */\n private _key?: string | number;\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 /** @internal */\n _equal(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 - 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 { MergeObject, PickType, WritableKeys } from '@o2ter/utils-js';\nimport { ComponentType, ElementNode, PropsWithChildren, RefAttribute } from './common';\nimport { ClassName, StyleProp } from './style';\nimport { _CSSProperties, CSSProperties } 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;\n};\n\nexport type PropsType = Record<string, any>;\n\ntype EventHandler<E extends Event, C, T = EventTarget> = (event: E & {\n currentTarget: C;\n target: T;\n }) => void;\ntype EventMap = {\n [ev in typeof globalEvents[number]]: 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 RefAttribute<ElementMap[x]['type'] | null | undefined>\n & {\n className?: ClassName;\n style?: StyleProp<CSSProperties>;\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"],"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,WAAY,CAAA,GAAG,IAAW,EAAA;;AAC3B;MAEY,aAAa,CAAA;;AAGhB,IAAA,KAAK;;AAGL,IAAA,MAAM;;AAGN,IAAA,IAAI;;AAGZ,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;;AAGjB,IAAA,IAAI,IAAI,GAAA;QACN,OAAO,IAAI,CAAC,KAAK;;AAGnB,IAAA,IAAI,KAAK,GAAA;QACP,OAAO,IAAI,CAAC,MAAM;;AAGpB,IAAA,IAAI,GAAG,GAAA;QACL,OAAO,IAAI,CAAC,IAAI;;;AAIlB,IAAA,MAAM,CAAC,KAAoB,EAAA;AACzB,QAAA,OAAO,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG;;AAE5D;;ACtED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MA6Da,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;AAEa,MAAA,aAAa,GAAG,CAC3B,IAAkB,EAClB,KAAwB,EACxB,GAAG,QAAuB,KACvB,cAAc,CAAC,IAAI,EAAE,EAAE,GAAG,KAAK,IAAI,EAAE,EAAE,QAAQ,EAAE;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sync-CyAho2g-.mjs","sources":["../../../src/core/hooks/callback.ts","../../../src/core/hooks/effect.ts","../../../src/core/hooks/sync.ts"],"sourcesContent":["//\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 hook that memoizes a callback function, ensuring that it only changes\n * if its dependencies change. This is useful for optimizing performance by preventing\n * unnecessary re-creations of functions.\n *\n * @template T - The type of the callback function.\n * @param callback - The callback function to be memoized.\n * @param deps - An optional dependencies. If provided, the callback\n * will only be updated when one of these dependencies changes.\n * If not provided, the callback will remain stable.\n * @returns - A stable version of the callback function that will not change unless\n * its dependencies change.\n *\n * @example\n * const memoizedCallback = useCallback(() => {\n * console.log('This function is memoized!');\n * }, [dependency]);\n */\nexport const useCallback = <T extends (...args: any) => any>(\n callback: T,\n deps?: any\n): T => {\n if (!_.isUndefined(deps)) return _useMemo('useCallback', callback, deps);\n const store = _useMemo('useCallback', () => {\n const store = {\n current: callback,\n stable: (...args: Parameters<T>): ReturnType<T> => store.current(...args),\n };\n return store;\n }, null);\n store.current = callback;\n return store.stable as T;\n}\n","//\n// effect.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 { _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 * @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 that determines when the effect should be re-executed.\n *\n * @example\n * useEffect((signal) => {\n * fetch('/api/data', { signal })\n * .then(response => response.json())\n * .then(data => console.log(data))\n * .catch(err => {\n * if (err.name === 'AbortError') {\n * console.log('Fetch aborted');\n * } else {\n * console.error(err);\n * }\n * });\n * \n * return () => {\n * console.log('Cleanup logic 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// sync.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 { _useEffect } from '../reconciler/hooks';\nimport { reconciler } from '../reconciler/state';\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', ({ node }) => {\n const abort = new AbortController();\n try {\n const destructor = subscribe(() => { node?._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 getServ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AAE;AACV,YAAA,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AAChB,YAAA,OAAO,MAAM,KAAK,CAAC,KAAK,EAAE;;KAE7B,EAAE,IAAI,CAAC;IACR,IAAI,iBAAiB,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE;QAC/C,OAAO,iBAAiB,EAAE;;IAE5B,OAAO,WAAW,EAAE;AACtB;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sync-w9XkAX8E.js","sources":["../../../src/core/hooks/callback.ts","../../../src/core/hooks/effect.ts","../../../src/core/hooks/sync.ts"],"sourcesContent":["//\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 hook that memoizes a callback function, ensuring that it only changes\n * if its dependencies change. This is useful for optimizing performance by preventing\n * unnecessary re-creations of functions.\n *\n * @template T - The type of the callback function.\n * @param callback - The callback function to be memoized.\n * @param deps - An optional dependencies. If provided, the callback\n * will only be updated when one of these dependencies changes.\n * If not provided, the callback will remain stable.\n * @returns - A stable version of the callback function that will not change unless\n * its dependencies change.\n *\n * @example\n * const memoizedCallback = useCallback(() => {\n * console.log('This function is memoized!');\n * }, [dependency]);\n */\nexport const useCallback = <T extends (...args: any) => any>(\n callback: T,\n deps?: any\n): T => {\n if (!_.isUndefined(deps)) return _useMemo('useCallback', callback, deps);\n const store = _useMemo('useCallback', () => {\n const store = {\n current: callback,\n stable: (...args: Parameters<T>): ReturnType<T> => store.current(...args),\n };\n return store;\n }, null);\n store.current = callback;\n return store.stable as T;\n}\n","//\n// effect.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 { _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 * @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 that determines when the effect should be re-executed.\n *\n * @example\n * useEffect((signal) => {\n * fetch('/api/data', { signal })\n * .then(response => response.json())\n * .then(data => console.log(data))\n * .catch(err => {\n * if (err.name === 'AbortError') {\n * console.log('Fetch aborted');\n * } else {\n * console.error(err);\n * }\n * });\n * \n * return () => {\n * console.log('Cleanup logic 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// sync.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 { _useEffect } from '../reconciler/hooks';\nimport { reconciler } from '../reconciler/state';\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', ({ node }) => {\n const abort = new AbortController();\n try {\n const destructor = subscribe(() => { node?._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};"],"names":["_useMemo","_useEffect","state","reconciler"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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