frosty 0.0.50 → 0.0.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/_native.js +2 -2
  2. package/dist/_native.mjs +2 -2
  3. package/dist/dom.js +3 -3
  4. package/dist/dom.mjs +3 -3
  5. package/dist/index.js +2 -2
  6. package/dist/index.mjs +3 -3
  7. package/dist/internals/{common-wMxJm6pW.js → common-BrS7yTQo.js} +3 -3
  8. package/dist/internals/{common-wMxJm6pW.js.map → common-BrS7yTQo.js.map} +1 -1
  9. package/dist/internals/{common-BDn2ckJk.mjs → common-CJlRgbfA.mjs} +3 -3
  10. package/dist/internals/{common-BDn2ckJk.mjs.map → common-CJlRgbfA.mjs.map} +1 -1
  11. package/dist/internals/{renderer-CjXZC-f9.mjs → renderer-8aUacmAw.mjs} +2 -2
  12. package/dist/internals/{renderer-CjXZC-f9.mjs.map → renderer-8aUacmAw.mjs.map} +1 -1
  13. package/dist/internals/{renderer-HTYBeiZu.js → renderer-CnT8kPxx.js} +2 -2
  14. package/dist/internals/{renderer-HTYBeiZu.js.map → renderer-CnT8kPxx.js.map} +1 -1
  15. package/dist/internals/{state-Lf_tbWNd.js → state-Bh2gCPTd.js} +7 -4
  16. package/dist/internals/state-Bh2gCPTd.js.map +1 -0
  17. package/dist/internals/{state-5PNx91ec.mjs → state-BlrAjoLt.mjs} +7 -4
  18. package/dist/internals/state-BlrAjoLt.mjs.map +1 -0
  19. package/dist/internals/{sync-e3464vDv.js → sync-BTFAme8k.js} +2 -2
  20. package/dist/internals/{sync-e3464vDv.js.map → sync-BTFAme8k.js.map} +1 -1
  21. package/dist/internals/{sync-C4RmxDzS.mjs → sync-Cec6c-K_.mjs} +2 -2
  22. package/dist/internals/{sync-C4RmxDzS.mjs.map → sync-Cec6c-K_.mjs.map} +1 -1
  23. package/dist/server-dom.js +3 -3
  24. package/dist/server-dom.mjs +3 -3
  25. package/dist/web.js +4 -4
  26. package/dist/web.mjs +5 -5
  27. package/package.json +1 -1
  28. package/dist/internals/state-5PNx91ec.mjs.map +0 -1
  29. package/dist/internals/state-Lf_tbWNd.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { r as reconciler, V as VNode, e as equalDeps } from './state-5PNx91ec.mjs';
2
+ import { r as reconciler, V as VNode, e as equalDeps } from './state-BlrAjoLt.mjs';
3
3
  import { N as NativeElementType } from './component-BzurKp_J.mjs';
4
4
  import nextick from 'nextick';
5
5
 
@@ -158,4 +158,4 @@ class _Renderer {
158
158
  }
159
159
 
160
160
  export { _Renderer as _ };
161
- //# sourceMappingURL=renderer-CjXZC-f9.mjs.map
161
+ //# sourceMappingURL=renderer-8aUacmAw.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderer-CjXZC-f9.mjs","sources":["../../../src/core/renderer.ts"],"sourcesContent":["//\n// renderer.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 { VNode } from './reconciler/vnode';\nimport { ComponentNode, NativeElementType } from './types/component';\nimport { reconciler } from './reconciler/state';\nimport nextick from 'nextick';\nimport { equalDeps } from './reconciler/utils';\n\nexport abstract class _Renderer<T> {\n\n protected abstract _beforeUpdate(): void;\n\n protected abstract _afterUpdate(): void;\n\n protected abstract _createElement(node: VNode, stack: VNode[]): T;\n\n protected abstract _updateElement(node: VNode, element: T, stack: VNode[]): void;\n\n protected abstract _destroyElement(node: VNode, element: T): void;\n\n protected abstract _replaceChildren(node: VNode, element: T, children: (T | string)[], stack: VNode[], force?: boolean): void;\n\n abstract get _server(): boolean;\n\n private _createRoot(\n root: T | null,\n component: ComponentNode,\n options?: {\n skipMount?: boolean;\n },\n ) {\n\n const runtime = reconciler.buildVNodes(component, this);\n\n type _State = {\n hook: string;\n deps: any;\n unmount?: () => void;\n };\n\n const mountState = new Map<VNode, _State[]>();\n\n const children = (node: VNode, elements: Map<VNode, { native?: T }>): (string | T)[] => {\n return _.flatMap(node.children, x => _.isString(x) ? x : elements.get(x)?.native ?? children(x, elements));\n };\n\n const commit = (elements: Map<VNode, { native?: T }>) => {\n\n const _mount = (node: VNode, stack: VNode[]) => {\n for (const item of node.children) {\n if (item instanceof VNode) _mount(item, [...stack, node]);\n }\n const element = elements.get(node)?.native;\n if (element) {\n this._replaceChildren(node, element, children(node, elements), stack);\n }\n const state: _State[] = [];\n const prevState = mountState.get(node) ?? [];\n const curState = node.state;\n for (const i of _.range(Math.max(prevState.length, curState.length))) {\n const unmount = prevState[i]?.unmount;\n const changed = prevState[i]?.hook !== curState[i]?.hook || !equalDeps(prevState[i].deps, curState[i]?.deps);\n if (unmount && changed) unmount();\n state.push({\n hook: curState[i].hook,\n deps: curState[i].deps,\n unmount: options?.skipMount || !changed ? prevState[i]?.unmount : curState[i].mount?.(),\n });\n }\n mountState.set(node, state);\n };\n\n for (const [node, state] of mountState) {\n if (elements.has(node)) continue;\n for (const { unmount } of state) unmount?.();\n mountState.delete(node);\n }\n if (root) this._replaceChildren(\n runtime.node, root,\n _.castArray(elements.get(runtime.node)?.native ?? children(runtime.node, elements)),\n [], true\n );\n _mount(runtime.node, []);\n };\n\n const update = (elements?: Map<VNode, { native?: T }>) => {\n this._beforeUpdate();\n const map = new Map<VNode, { native?: T }>();\n for (const { node, stack, updated } of runtime.excute()) {\n if (node.error) continue;\n if (_.isFunction(node.type) && !(node.type.prototype instanceof NativeElementType)) {\n map.set(node, {});\n continue;\n }\n if (updated) {\n let elem = elements?.get(node)?.native;\n if (elem) {\n this._updateElement(node, elem, stack);\n } else {\n elem = this._createElement(node, stack);\n }\n map.set(node, { native: elem });\n } else {\n map.set(node, { native: elements?.get(node)?.native ?? this._createElement(node, stack) });\n }\n }\n commit(map);\n if (elements) {\n for (const [node, element] of elements) {\n if (map.has(node) || !element.native) continue;\n this._destroyElement(node, element.native);\n }\n }\n this._afterUpdate();\n return map;\n };\n\n let update_count = 0;\n let render_count = 0;\n let destroyed = false;\n let elements = update();\n\n const listener = runtime.event.register('onchange', () => {\n if (render_count !== update_count++) return;\n nextick(() => {\n if (destroyed) return;\n render_count = update_count;\n elements = update(elements);\n });\n });\n\n return {\n get root() {\n if (root) return root;\n const elems = _.castArray(elements.get(runtime.node)?.native ?? children(runtime.node, elements));\n const nodes = _.filter(elems, x => !_.isString(x)) as T[];\n return nodes.length === 1 ? nodes[0] : nodes;\n },\n destroy: () => {\n if (root) this._replaceChildren(runtime.node, root, [], [], true);\n destroyed = true;\n listener.remove();\n for (const state of mountState.values()) {\n for (const { unmount } of state) unmount?.();\n }\n },\n };\n }\n\n createRoot(root?: T) {\n let state: ReturnType<typeof this._createRoot> | undefined;\n return {\n get root() {\n return state?.root;\n },\n mount: (\n component: ComponentNode,\n options?: {\n skipMount?: boolean;\n },\n ) => {\n state = this._createRoot(root ?? null, component, options);\n },\n unmount: () => {\n state?.destroy();\n state = undefined;\n },\n };\n }\n}"],"names":[],"mapp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CAAC,CAAC,CAAC,CAAQ;AACzD,gBAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK;aAC7C;YACD,OAAO,EAAE,MAAK;AACZ,gBAAA,IAAI,IAAI;AAAE,oBAAA,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC;gBACjE,SAAS,GAAG,IAAI;gBAChB,QAAQ,CAAC,MAAM,EAAE;gBACjB,KAAK,MAAM,KAAK,IAAI,UAAU,CAAC,MAAM,EAAE,EAAE;AACvC,oBAAA,KAAK,MAAM,EAAE,OAAO,EAAE,IAAI,KAAK;wBAAE,OAAO,IAAI;;aAE/C;SACF;;AAGH,IAAA,UAAU,CAAC,IAAQ,EAAA;AACjB,QAAA,IAAI,KAAsD;QAC1D,OAAO;AACL,YAAA,IAAI,IAAI,GAAA;gBACN,OAAO,KAAK,EAAE,IAAI;aACnB;AACD,YAAA,KAAK,EAAE,CACL,SAAwB,EACxB,OAEC,KACC;AACF,gBAAA,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC;aAC3D;YACD,OAAO,EAAE,MAAK;gBACZ,KAAK,EAAE,OAAO,EAAE;gBAChB,KAAK,GAAG,SAAS;aAClB;SACF;;AAEJ;;;;"}
1
+ {"version":3,"file":"renderer-8aUacmAw.mjs","sources":["../../../src/core/renderer.ts"],"sourcesContent":["//\n// renderer.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 { VNode } from './reconciler/vnode';\nimport { ComponentNode, NativeElementType } from './types/component';\nimport { reconciler } from './reconciler/state';\nimport nextick from 'nextick';\nimport { equalDeps } from './reconciler/utils';\n\nexport abstract class _Renderer<T> {\n\n protected abstract _beforeUpdate(): void;\n\n protected abstract _afterUpdate(): void;\n\n protected abstract _createElement(node: VNode, stack: VNode[]): T;\n\n protected abstract _updateElement(node: VNode, element: T, stack: VNode[]): void;\n\n protected abstract _destroyElement(node: VNode, element: T): void;\n\n protected abstract _replaceChildren(node: VNode, element: T, children: (T | string)[], stack: VNode[], force?: boolean): void;\n\n abstract get _server(): boolean;\n\n private _createRoot(\n root: T | null,\n component: ComponentNode,\n options?: {\n skipMount?: boolean;\n },\n ) {\n\n const runtime = reconciler.buildVNodes(component, this);\n\n type _State = {\n hook: string;\n deps: any;\n unmount?: () => void;\n };\n\n const mountState = new Map<VNode, _State[]>();\n\n const children = (node: VNode, elements: Map<VNode, { native?: T }>): (string | T)[] => {\n return _.flatMap(node.children, x => _.isString(x) ? x : elements.get(x)?.native ?? children(x, elements));\n };\n\n const commit = (elements: Map<VNode, { native?: T }>) => {\n\n const _mount = (node: VNode, stack: VNode[]) => {\n for (const item of node.children) {\n if (item instanceof VNode) _mount(item, [...stack, node]);\n }\n const element = elements.get(node)?.native;\n if (element) {\n this._replaceChildren(node, element, children(node, elements), stack);\n }\n const state: _State[] = [];\n const prevState = mountState.get(node) ?? [];\n const curState = node.state;\n for (const i of _.range(Math.max(prevState.length, curState.length))) {\n const unmount = prevState[i]?.unmount;\n const changed = prevState[i]?.hook !== curState[i]?.hook || !equalDeps(prevState[i].deps, curState[i]?.deps);\n if (unmount && changed) unmount();\n state.push({\n hook: curState[i].hook,\n deps: curState[i].deps,\n unmount: options?.skipMount || !changed ? prevState[i]?.unmount : curState[i].mount?.(),\n });\n }\n mountState.set(node, state);\n };\n\n for (const [node, state] of mountState) {\n if (elements.has(node)) continue;\n for (const { unmount } of state) unmount?.();\n mountState.delete(node);\n }\n if (root) this._replaceChildren(\n runtime.node, root,\n _.castArray(elements.get(runtime.node)?.native ?? children(runtime.node, elements)),\n [], true\n );\n _mount(runtime.node, []);\n };\n\n const update = (elements?: Map<VNode, { native?: T }>) => {\n this._beforeUpdate();\n const map = new Map<VNode, { native?: T }>();\n for (const { node, stack, updated } of runtime.excute()) {\n if (node.error) continue;\n if (_.isFunction(node.type) && !(node.type.prototype instanceof NativeElementType)) {\n map.set(node, {});\n continue;\n }\n if (updated) {\n let elem = elements?.get(node)?.native;\n if (elem) {\n this._updateElement(node, elem, stack);\n } else {\n elem = this._createElement(node, stack);\n }\n map.set(node, { native: elem });\n } else {\n map.set(node, { native: elements?.get(node)?.native ?? this._createElement(node, stack) });\n }\n }\n commit(map);\n if (elements) {\n for (const [node, element] of elements) {\n if (map.has(node) || !element.native) continue;\n this._destroyElement(node, element.native);\n }\n }\n this._afterUpdate();\n return map;\n };\n\n let update_count = 0;\n let render_count = 0;\n let destroyed = false;\n let elements = update();\n\n const listener = runtime.event.register('onchange', () => {\n if (render_count !== update_count++) return;\n nextick(() => {\n if (destroyed) return;\n render_count = update_count;\n elements = update(elements);\n });\n });\n\n return {\n get root() {\n if (root) return root;\n const elems = _.castArray(elements.get(runtime.node)?.native ?? children(runtime.node, elements));\n const nodes = _.filter(elems, x => !_.isString(x)) as T[];\n return nodes.length === 1 ? nodes[0] : nodes;\n },\n destroy: () => {\n if (root) this._replaceChildren(runtime.node, root, [], [], true);\n destroyed = true;\n listener.remove();\n for (const state of mountState.values()) {\n for (const { unmount } of state) unmount?.();\n }\n },\n };\n }\n\n createRoot(root?: T) {\n let state: ReturnType<typeof this._createRoot> | undefined;\n return {\n get root() {\n return state?.root;\n },\n mount: (\n component: ComponentNode,\n options?: {\n skipMount?: boolean;\n },\n ) => {\n state = this._createRoot(root ?? null, component, options);\n },\n unmount: () => {\n state?.destroy();\n state = undefined;\n },\n };\n }\n}"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MASsB,SAAS,CAAA;AAgBrB,IAAA,WAAW,CACjB,IAAc,EACd,SAAwB,EACxB,OAEC,EAAA;QAGD,MAAM,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,SAAS,EAAE,IAAI,CAAC;AAQvD,QAAA,MAAM,UAAU,GAAG,IAAI,GAAG,EAAmB;AAE7C,QAAA,MAAM,QAAQ,GAAG,CAAC,IAAW,EAAE,QAAoC,KAAoB;AACrF,YAAA,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC5G,SAAC;AAED,QAAA,MAAM,MAAM,GAAG,CAAC,QAAoC,KAAI;AAEtD,YAAA,MAAM,MAAM,GAAG,CAAC,IAAW,EAAE,KAAc,KAAI;AAC7C,gBAAA,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE;oBACh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AAK,EAAE,OAAO,EAAE;gBAChB,KAAK,GAAG,SAAS;aAClB;SACF;;AAEJ;;;;"}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var _ = require('lodash');
4
- var state = require('./state-Lf_tbWNd.js');
4
+ var state = require('./state-Bh2gCPTd.js');
5
5
  var component = require('./component-BiP3XIPe.js');
6
6
  var nextick = require('nextick');
7
7
 
@@ -160,4 +160,4 @@ class _Renderer {
160
160
  }
161
161
 
162
162
  exports._Renderer = _Renderer;
163
- //# sourceMappingURL=renderer-HTYBeiZu.js.map
163
+ //# sourceMappingURL=renderer-CnT8kPxx.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderer-HTYBeiZu.js","sources":["../../../src/core/renderer.ts"],"sourcesContent":["//\n// renderer.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 { VNode } from './reconciler/vnode';\nimport { ComponentNode, NativeElementType } from './types/component';\nimport { reconciler } from './reconciler/state';\nimport nextick from 'nextick';\nimport { equalDeps } from './reconciler/utils';\n\nexport abstract class _Renderer<T> {\n\n protected abstract _beforeUpdate(): void;\n\n protected abstract _afterUpdate(): void;\n\n protected abstract _createElement(node: VNode, stack: VNode[]): T;\n\n protected abstract _updateElement(node: VNode, element: T, stack: VNode[]): void;\n\n protected abstract _destroyElement(node: VNode, element: T): void;\n\n protected abstract _replaceChildren(node: VNode, element: T, children: (T | string)[], stack: VNode[], force?: boolean): void;\n\n abstract get _server(): boolean;\n\n private _createRoot(\n root: T | null,\n component: ComponentNode,\n options?: {\n skipMount?: boolean;\n },\n ) {\n\n const runtime = reconciler.buildVNodes(component, this);\n\n type _State = {\n hook: string;\n deps: any;\n unmount?: () => void;\n };\n\n const mountState = new Map<VNode, _State[]>();\n\n const children = (node: VNode, elements: Map<VNode, { native?: T }>): (string | T)[] => {\n return _.flatMap(node.children, x => _.isString(x) ? x : elements.get(x)?.native ?? children(x, elements));\n };\n\n const commit = (elements: Map<VNode, { native?: T }>) => {\n\n const _mount = (node: VNode, stack: VNode[]) => {\n for (const item of node.children) {\n if (item instanceof VNode) _mount(item, [...stack, node]);\n }\n const element = elements.get(node)?.native;\n if (element) {\n this._replaceChildren(node, element, children(node, elements), stack);\n }\n const state: _State[] = [];\n const prevState = mountState.get(node) ?? [];\n const curState = node.state;\n for (const i of _.range(Math.max(prevState.length, curState.length))) {\n const unmount = prevState[i]?.unmount;\n const changed = prevState[i]?.hook !== curState[i]?.hook || !equalDeps(prevState[i].deps, curState[i]?.deps);\n if (unmount && changed) unmount();\n state.push({\n hook: curState[i].hook,\n deps: curState[i].deps,\n unmount: options?.skipMount || !changed ? prevState[i]?.unmount : curState[i].mount?.(),\n });\n }\n mountState.set(node, state);\n };\n\n for (const [node, state] of mountState) {\n if (elements.has(node)) continue;\n for (const { unmount } of state) unmount?.();\n mountState.delete(node);\n }\n if (root) this._replaceChildren(\n runtime.node, root,\n _.castArray(elements.get(runtime.node)?.native ?? children(runtime.node, elements)),\n [], true\n );\n _mount(runtime.node, []);\n };\n\n const update = (elements?: Map<VNode, { native?: T }>) => {\n this._beforeUpdate();\n const map = new Map<VNode, { native?: T }>();\n for (const { node, stack, updated } of runtime.excute()) {\n if (node.error) continue;\n if (_.isFunction(node.type) && !(node.type.prototype instanceof NativeElementType)) {\n map.set(node, {});\n continue;\n }\n if (updated) {\n let elem = elements?.get(node)?.native;\n if (elem) {\n this._updateElement(node, elem, stack);\n } else {\n elem = this._createElement(node, stack);\n }\n map.set(node, { native: elem });\n } else {\n map.set(node, { native: elements?.get(node)?.native ?? this._createElement(node, stack) });\n }\n }\n commit(map);\n if (elements) {\n for (const [node, element] of elements) {\n if (map.has(node) || !element.native) continue;\n this._destroyElement(node, element.native);\n }\n }\n this._afterUpdate();\n return map;\n };\n\n let update_count = 0;\n let render_count = 0;\n let destroyed = false;\n let elements = update();\n\n const listener = runtime.event.register('onchange', () => {\n if (render_count !== update_count++) return;\n nextick(() => {\n if (destroyed) return;\n render_count = update_count;\n elements = update(elements);\n });\n });\n\n return {\n get root() {\n if (root) return root;\n const elems = _.castArray(elements.get(runtime.node)?.native ?? children(runtime.node, elements));\n const nodes = _.filter(elems, x => !_.isString(x)) as T[];\n return nodes.length === 1 ? nodes[0] : nodes;\n },\n destroy: () => {\n if (root) this._replaceChildren(runtime.node, root, [], [], true);\n destroyed = true;\n listener.remove();\n for (const state of mountState.values()) {\n for (const { unmount } of state) unmount?.();\n }\n },\n };\n }\n\n createRoot(root?: T) {\n let state: ReturnType<typeof this._createRoot> | undefined;\n return {\n get root() {\n return state?.root;\n },\n mount: (\n component: ComponentNode,\n options?: {\n skipMount?: boolean;\n },\n ) => {\n state = this._createRoot(root ?? null, component, options);\n },\n unmount: () => {\n state?.destroy();\n state = undefined;\n },\n };\n }\n}"],"names":["component","reconciler","VNode","state","equalDeps","NativeElementType"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AAC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gBAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK;aAC7C;YACD,OAAO,EAAE,MAAK;AACZ,gBAAA,IAAI,IAAI;AAAE,oBAAA,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC;gBACjE,SAAS,GAAG,IAAI;gBAChB,QAAQ,CAAC,MAAM,EAAE;gBACjB,KAAK,MAAM,KAAK,IAAI,UAAU,CAAC,MAAM,EAAE,EAAE;AACvC,oBAAA,KAAK,MAAM,EAAE,OAAO,EAAE,IAAI,KAAK;wBAAE,OAAO,IAAI;;aAE/C;SACF;;AAGH,IAAA,UAAU,CAAC,IAAQ,EAAA;AACjB,QAAA,IAAI,KAAsD;QAC1D,OAAO;AACL,YAAA,IAAI,IAAI,GAAA;gBACN,OAAO,KAAK,EAAE,IAAI;aACnB;AACD,YAAA,KAAK,EAAE,CACL,SAAwB,EACxB,OAEC,KACC;AACF,gBAAA,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC;aAC3D;YACD,OAAO,EAAE,MAAK;gBACZ,KAAK,EAAE,OAAO,EAAE;gBAChB,KAAK,GAAG,SAAS;aAClB;SACF;;AAEJ;;;;"}
1
+ {"version":3,"file":"renderer-CnT8kPxx.js","sources":["../../../src/core/renderer.ts"],"sourcesContent":["//\n// renderer.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 { VNode } from './reconciler/vnode';\nimport { ComponentNode, NativeElementType } from './types/component';\nimport { reconciler } from './reconciler/state';\nimport nextick from 'nextick';\nimport { equalDeps } from './reconciler/utils';\n\nexport abstract class _Renderer<T> {\n\n protected abstract _beforeUpdate(): void;\n\n protected abstract _afterUpdate(): void;\n\n protected abstract _createElement(node: VNode, stack: VNode[]): T;\n\n protected abstract _updateElement(node: VNode, element: T, stack: VNode[]): void;\n\n protected abstract _destroyElement(node: VNode, element: T): void;\n\n protected abstract _replaceChildren(node: VNode, element: T, children: (T | string)[], stack: VNode[], force?: boolean): void;\n\n abstract get _server(): boolean;\n\n private _createRoot(\n root: T | null,\n component: ComponentNode,\n options?: {\n skipMount?: boolean;\n },\n ) {\n\n const runtime = reconciler.buildVNodes(component, this);\n\n type _State = {\n hook: string;\n deps: any;\n unmount?: () => void;\n };\n\n const mountState = new Map<VNode, _State[]>();\n\n const children = (node: VNode, elements: Map<VNode, { native?: T }>): (string | T)[] => {\n return _.flatMap(node.children, x => _.isString(x) ? x : elements.get(x)?.native ?? children(x, elements));\n };\n\n const commit = (elements: Map<VNode, { native?: T }>) => {\n\n const _mount = (node: VNode, stack: VNode[]) => {\n for (const item of node.children) {\n if (item instanceof VNode) _mount(item, [...stack, node]);\n }\n const element = elements.get(node)?.native;\n if (element) {\n this._replaceChildren(node, element, children(node, elements), stack);\n }\n const state: _State[] = [];\n const prevState = mountState.get(node) ?? [];\n const curState = node.state;\n for (const i of _.range(Math.max(prevState.length, curState.length))) {\n const unmount = prevState[i]?.unmount;\n const changed = prevState[i]?.hook !== curState[i]?.hook || !equalDeps(prevState[i].deps, curState[i]?.deps);\n if (unmount && changed) unmount();\n state.push({\n hook: curState[i].hook,\n deps: curState[i].deps,\n unmount: options?.skipMount || !changed ? prevState[i]?.unmount : curState[i].mount?.(),\n });\n }\n mountState.set(node, state);\n };\n\n for (const [node, state] of mountState) {\n if (elements.has(node)) continue;\n for (const { unmount } of state) unmount?.();\n mountState.delete(node);\n }\n if (root) this._replaceChildren(\n runtime.node, root,\n _.castArray(elements.get(runtime.node)?.native ?? children(runtime.node, elements)),\n [], true\n );\n _mount(runtime.node, []);\n };\n\n const update = (elements?: Map<VNode, { native?: T }>) => {\n this._beforeUpdate();\n const map = new Map<VNode, { native?: T }>();\n for (const { node, stack, updated } of runtime.excute()) {\n if (node.error) continue;\n if (_.isFunction(node.type) && !(node.type.prototype instanceof NativeElementType)) {\n map.set(node, {});\n continue;\n }\n if (updated) {\n let elem = elements?.get(node)?.native;\n if (elem) {\n this._updateElement(node, elem, stack);\n } else {\n elem = this._createElement(node, stack);\n }\n map.set(node, { native: elem });\n } else {\n map.set(node, { native: elements?.get(node)?.native ?? this._createElement(node, stack) });\n }\n }\n commit(map);\n if (elements) {\n for (const [node, element] of elements) {\n if (map.has(node) || !element.native) continue;\n this._destroyElement(node, element.native);\n }\n }\n this._afterUpdate();\n return map;\n };\n\n let update_count = 0;\n let render_count = 0;\n let destroyed = false;\n let elements = update();\n\n const listener = runtime.event.register('onchange', () => {\n if (render_count !== update_count++) return;\n nextick(() => {\n if (destroyed) return;\n render_count = update_count;\n elements = update(elements);\n });\n });\n\n return {\n get root() {\n if (root) return root;\n const elems = _.castArray(elements.get(runtime.node)?.native ?? children(runtime.node, elements));\n const nodes = _.filter(elems, x => !_.isString(x)) as T[];\n return nodes.length === 1 ? nodes[0] : nodes;\n },\n destroy: () => {\n if (root) this._replaceChildren(runtime.node, root, [], [], true);\n destroyed = true;\n listener.remove();\n for (const state of mountState.values()) {\n for (const { unmount } of state) unmount?.();\n }\n },\n };\n }\n\n createRoot(root?: T) {\n let state: ReturnType<typeof this._createRoot> | undefined;\n return {\n get root() {\n return state?.root;\n },\n mount: (\n component: ComponentNode,\n options?: {\n skipMount?: boolean;\n },\n ) => {\n state = this._createRoot(root ?? null, component, options);\n },\n unmount: () => {\n state?.destroy();\n state = undefined;\n },\n };\n }\n}"],"names":["component","reconciler","VNode","state","equalDeps","NativeElementType"],"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;MASsB,SAAS,CAAA;AAgBrB,IAAA,WAAW,CACjB,IAAc,EACdA,WAAwB,EACxB,OAEC,EAAA;QAGD,MAAM,OAAO,GAAGC,gBAAU,CAAC,WAAW,CAACD,WAAS,EAAE,IAAI,CAAC;AAQvD,QAAA,MAAM,UAAU,GAAG,IAAI,GAAG,EAAmB;AAE7C,QAAA,MAAM,QAAQ,GAAG,CAAC,IAAW,EAAE,QAAoC,KAAoB;AACrF,YAAA,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC5G,SAAC;AAED,QAAA,MAAM,MAAM,GAAG,CAAC,QAAoC,KAAI;AAEtD,YAAA,MAAM,MAAM,GAAG,CAAC,IAAW,EAAE,KAAc,KAAI;AAC7C,gBAAA,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE;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K;gBACZ,KAAK,EAAE,OAAO,EAAE;gBAChB,KAAK,GAAG,SAAS;aAClB;SACF;;AAEJ;;;;"}
@@ -105,7 +105,7 @@ const useContext = (context, selector = v => v) => {
105
105
  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
106
106
  // THE SOFTWARE.
107
107
  //
108
- const equalDeps = (lhs, rhs) => _.isEqual(lhs ?? null, rhs);
108
+ const equalDeps = (lhs, rhs, customizer) => customizer ? _.isEqualWith(lhs ?? null, rhs, customizer) : _.isEqual(lhs ?? null, rhs);
109
109
 
110
110
  //
111
111
  // utils.ts
@@ -245,7 +245,10 @@ class VNode {
245
245
  return false;
246
246
  try {
247
247
  const { type, props: _props } = this._component;
248
- const props = options.propsProvider.reduceRight((p, node) => node.props.callback({ type, props: p }), _props);
248
+ const props = _.mapValues(options.propsProvider.reduceRight((p, node) => node.props.callback({ type, props: p }), _props), (v, k) => _.isFunction(v) ? (...args) => {
249
+ const current = this._component.props[k];
250
+ return _.isFunction(current) ? current(...args) : v(...args);
251
+ } : v);
249
252
  let children;
250
253
  if (_.isString(type) || type.prototype instanceof component.NativeElementType) {
251
254
  children = this._resolve_children(props.children);
@@ -289,7 +292,7 @@ class VNode {
289
292
  continue;
290
293
  if (!(children[i] instanceof VNode))
291
294
  continue;
292
- if (!equalDeps(item._component.props, children[i]._component.props))
295
+ if (!equalDeps(item._component.props, children[i]._component.props, (l, r) => _.isFunction(l) && _.isFunction(r) ? true : undefined))
293
296
  item._dirty = true;
294
297
  item._component = children[i]._component;
295
298
  }
@@ -544,4 +547,4 @@ exports.mergeRefs = mergeRefs;
544
547
  exports.reconciler = reconciler;
545
548
  exports.uniqueId = uniqueId;
546
549
  exports.useContext = useContext;
547
- //# sourceMappingURL=state-Lf_tbWNd.js.map
550
+ //# sourceMappingURL=state-Bh2gCPTd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-Bh2gCPTd.js","sources":["../../../src/core/hooks/context.ts","../../../src/core/reconciler/utils.ts","../../../src/core/utils.ts","../../../src/core/reconciler/vnode.ts","../../../src/core/reconciler/events.ts","../../../src/core/types/props.ts","../../../src/core/types/error.ts","../../../src/core/reconciler/state.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 { reconciler } from '../reconciler/state';\nimport { ComponentType, ElementNode } from '../types/common';\n\nconst _contextDefaultValue = new WeakMap<Context<any>, any>();\n\nexport const isContext = (type: any): type is Context<any> => {\n return _contextDefaultValue.has(type as any);\n};\n\nexport type Context<Value> = ReturnType<typeof _createContext<Value>>;\nexport type ContextType<C extends Context<any>> = C extends Context<infer T> ? T : never;\n\nconst _createContext = <Value extends unknown>(defaultValue: Value) => {\n const _context: ComponentType<{\n value: Value;\n children?: ElementNode | ((value: Value) => ElementNode);\n }> = ({ value, children }) => {\n return _.isFunction(children) ? children(value) : children;\n };\n const Consumer: ComponentType<{\n children: (value: Value) => ElementNode;\n }> = ({ children }) => {\n const value = useContext(_context as Context<Value>);\n return children(value);\n };\n _contextDefaultValue.set(_context as Context<Value>, defaultValue);\n return _.assign(_context, { Consumer });\n};\n\n/**\n * Creates a new context object with an optional default value.\n *\n * A context object allows you to share a value across a component tree\n * without explicitly passing it as a prop to every level.\n *\n * @template Value - The type of the value to be stored in the context.\n * @param - The default value for the context.\n * @returns A context object that can be used to provide and consume the value.\n */\n\nexport function createContext<Value>(defaultValue: Value): Context<Value>;\nexport function createContext<Value = undefined>(): Context<Value | undefined>;\n\nexport function createContext(defaultValue?: any) {\n return _createContext(defaultValue);\n}\n\n/**\n * A hook that retrieves the current value of a context and optionally applies\n * a selector function to transform the context value. This hook ensures that the component\n * subscribes to the context and re-renders when the context value changes.\n *\n * @template T - The type of the context value.\n * @template R - The type of the transformed value returned by the selector.\n * @param context - The context object to retrieve the value from.\n * @param selector - An optional selector function to transform the context value.\n * Defaults to an identity function.\n * @returns - The current value of the context, optionally transformed by the selector.\n *\n * @throws - Throws an error if the provided context is invalid or if the hook\n * is used outside of a render function.\n *\n * @example\n * const MyContext = createContext({ user: null });\n * \n * function MyComponent() {\n * const user = useContext(MyContext, context => context.user);\n * return <div>{user ? `Hello, ${user.name}` : 'Hello, Guest'}</div>;\n * }\n */\nexport const useContext = <T, R = T>(\n context: Context<T>,\n selector: (state: T) => R = v => v as any\n) => {\n if (!isContext(context)) throw Error(`Invalid type of ${context}`);\n const state = reconciler.currentHookState;\n if (!state) throw Error('useContext must be used within a render function.');\n const { contextValue, listens } = state;\n listens.add(context);\n const { value = _contextDefaultValue.get(context) } = contextValue.get(context) ?? {};\n return selector(value);\n};\n","//\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';\n\nexport const equalDeps = (lhs: any, rhs: any, customizer?: _.IsEqualCustomizer) => customizer ? _.isEqualWith(lhs ?? null, rhs, customizer) : _.isEqual(lhs ?? null, rhs);\n","//\n// utils.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 { Ref } from './types/common';\n\nexport const mergeRefs = <T>(...refs: (Ref<T> | null | undefined)[]) => (x: T) => {\n for (const ref of refs) {\n if (_.isNil(ref)) continue;\n else if (typeof ref === 'function') ref(x);\n else if (typeof ref === 'object') ref.current = x;\n else {\n console.error(`mergeRefs cannot handle Refs of type boolean, number or string, received ref ${ref}`);\n }\n }\n}\n\nlet counter = 0;\n\nexport const uniqueId = () => `${Date.now().toString(36)}${(counter++).toString(36)}${Math.random().toString(36).slice(2)}`;\n","//\n// vnode.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 { ComponentNode, NativeElementType } from '../types/component';\nimport { Context, isContext } from '../hooks/context';\nimport { reconciler } from './state';\nimport { myersSync } from 'myers.js';\nimport { EventEmitter } from './events';\nimport { equalDeps } from './utils';\nimport { _Renderer } from '../renderer';\nimport { PropsType } from '../types/runtime';\nimport { uniqueId } from '../utils';\n\nexport type VNodeState = {\n hook: string;\n deps: any;\n data?: any;\n mount?: () => () => void;\n};\n\nexport type _ContextState = {\n value: any;\n state: string;\n node: VNode;\n};\n\nexport class VNode {\n\n /** @internal */\n _component: ComponentNode;\n\n private _id = uniqueId();\n\n private _event: EventEmitter;\n private _props: PropsType = {};\n private _error?: any;\n private _children: (VNode | string)[] = [];\n private _state?: VNodeState[];\n private _dirty = true;\n private _listens = new Map<Context<any>, Omit<_ContextState, 'value'>>();\n\n /** @internal */\n _content_state = uniqueId();\n private _content_value?: any;\n\n /** @internal */\n constructor(component: ComponentNode, event: EventEmitter) {\n this._component = component;\n this._event = event;\n }\n\n /** @internal */\n _resolve_children(child: any): (VNode | string)[] {\n if (_.isBoolean(child) || _.isNil(child)) return [];\n if (_.isString(child)) return [child];\n if (_.isNumber(child)) return [`${child}`];\n if (child instanceof ComponentNode) return [new VNode(child, this._event)];\n if (_.isArrayLikeObject(child)) return _.flatMap(child, x => this._resolve_children(x));\n if (typeof child[Symbol.iterator] === 'function') return _.flatMap([...child], x => this._resolve_children(x));\n throw Error(`${child} are not valid as a child.`);\n }\n\n get id() {\n return this._id;\n }\n\n get type() {\n return this._component.type;\n }\n\n get props() {\n return this._props;\n }\n\n get key() {\n return this._component.key;\n }\n\n get state() {\n return this._state ?? [];\n }\n\n get children() {\n return this._children;\n }\n\n get error() {\n return this._error;\n }\n\n /** @internal */\n _setDirty() {\n this._dirty = true;\n this._event.emit('onchange');\n }\n\n /** @internal */\n private _check_context(values: Map<Context<any>, Omit<_ContextState, 'value'>>) {\n return this._listens.entries().every(([k, v]) => {\n const { state, node } = values.get(k) ?? {};\n return state === v.state && node === v.node;\n });\n }\n\n /** @internal */\n _updateIfNeed(options: {\n renderer: _Renderer<any>;\n stack: VNode[];\n propsProvider: VNode[];\n errorBoundary?: VNode;\n contextValue: Map<Context<any>, _ContextState>;\n }) {\n if (!this._dirty && this._check_context(options.contextValue)) return false;\n try {\n const { type, props: _props } = this._component;\n const props = _.mapValues(\n options.propsProvider.reduceRight((p, node) => node.props.callback({ type, props: p }), _props),\n (v, k) => _.isFunction(v) ? (...args: any[]) => {\n const current = this._component.props[k];\n return _.isFunction(current) ? current(...args) : v(...args);\n } : v,\n );\n let children: (VNode | string)[];\n if (_.isString(type) || type.prototype instanceof NativeElementType) {\n children = this._resolve_children(props.children);\n } else if (isContext(type)) {\n const { value } = props;\n if (!equalDeps(this._content_value, value)) this._content_state = uniqueId();\n this._content_value = value;\n children = this._resolve_children(type(props as any));\n } else if (_.isFunction(type)) {\n const { rendered, state } = reconciler.withHookState({\n renderer: options.renderer,\n node: this,\n state: this._state,\n stack: options.stack,\n contextValue: options.contextValue,\n }, (state) => ({ rendered: type(props), state }));\n this._state = state.state;\n this._listens = new Map(options.contextValue.entries().filter(([k]) => state.listens.has(k)));\n children = this._resolve_children(rendered);\n } else {\n throw Error(`Invalid node type ${type}`);\n }\n const diff = myersSync(this._children, children, {\n compare: (lhs, rhs) => {\n if (_.isString(lhs) && _.isString(rhs)) return lhs === rhs;\n if (lhs instanceof VNode && rhs instanceof VNode) return lhs._component._equal(rhs._component);\n return false;\n },\n });\n this._props = _.omit(props, 'children');\n this._children = _.flatMap(diff, x => x.equivalent ?? x.insert ?? []);\n this._error = undefined;\n for (const [i, item] of this._children.entries()) {\n if (!(item instanceof VNode)) continue;\n if (!(children[i] instanceof VNode)) continue;\n if (!equalDeps(item._component.props, children[i]._component.props, (l, r) => _.isFunction(l) && _.isFunction(r) ? true : undefined)) item._dirty = true;\n item._component = children[i]._component;\n }\n } catch (error) {\n this._props = {};\n this._children = [];\n this._error = error;\n (async () => {\n try {\n const { onError, silent } = options.errorBoundary?.props ?? {};\n if (!silent) console.error(error);\n if (_.isFunction(onError)) await onError(error, this._component, _.map(options.stack, x => x._component));\n } catch (e) {\n console.error(e);\n }\n })();\n } finally {\n this._dirty = false;\n }\n return true;\n }\n}\n","//\n// events.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';\n\nexport class EventEmitter {\n\n private _listeners: Record<string, ((...args: any[]) => void)[]> = {};\n\n register(event: string, callback: (event: string, ...args: any[]) => void) {\n if (_.isNil(this._listeners[event])) this._listeners[event] = [];\n const _callback = (...args: any[]) => callback(event, ...args);\n this._listeners[event].push(_callback);\n return {\n remove: () => {\n this._listeners[event] = _.filter(this._listeners[event], x => x !== _callback);\n },\n };\n }\n\n emit(event: string, ...args: any[]) {\n this._listeners[event]?.forEach(async callback => {\n try {\n await callback(...args)\n } catch (e) {\n console.error(e);\n }\n });\n }\n}\n","//\n// props.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 { ComponentType, PropsWithChildren } from './common';\nimport { NativeElementType } from './component';\nimport { _ElementType, PropsType } from './runtime';\n\ntype PropsProviderProps = PropsWithChildren<{\n callback: (v: {\n type: _ElementType | typeof NativeElementType,\n props: PropsType\n }) => PropsType | undefined | null;\n}>;\n\nexport const PropsProvider: ComponentType<PropsProviderProps> = ({ children }) => {\n return children;\n}\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 { ComponentType, PropsWithChildren } from './common';\nimport { ComponentNode } from './component';\n\ntype ErrorBoundaryProps = PropsWithChildren<{\n silent?: boolean;\n onError?: (\n error: any,\n component: ComponentNode,\n stack: ComponentNode[],\n ) => void;\n}>;\n\nexport const ErrorBoundary: ComponentType<ErrorBoundaryProps> = ({ children }) => {\n return children;\n}\n","//\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 { ComponentNode } from '../types/component';\nimport { Context, isContext } from '../hooks/context';\nimport { _ContextState, VNode, VNodeState } from './vnode';\nimport { EventEmitter } from './events';\nimport { PropsProvider } from '../types/props';\nimport { ErrorBoundary } from '../types/error';\nimport { _Renderer } from '../renderer';\n\nclass HookState {\n\n renderer: _Renderer<any>;\n\n contextValue: Map<Context<any>, _ContextState>;\n prevState?: VNodeState[];\n state: VNodeState[] = [];\n stack: VNode[] = [];\n node?: VNode;\n\n listens = new WeakSet<Context<any>>();\n\n constructor(options: {\n renderer: _Renderer<any>;\n node: VNode;\n stack: VNode[];\n state?: VNodeState[];\n contextValue: Map<Context<any>, _ContextState>;\n }) {\n this.renderer = options.renderer;\n this.node = options.node;\n this.stack = options.stack;\n this.prevState = options.state;\n this.contextValue = options.contextValue ?? new Map();\n }\n}\n\nexport const reconciler = new class {\n\n /** @internal */\n _registry = new WeakMap<any, string>();\n\n /** @internal */\n _currentHookState: HookState | undefined;\n\n get currentHookState() {\n return this._currentHookState;\n }\n\n withHookState<R = void>(\n options: ConstructorParameters<typeof HookState>[0],\n callback: (state: HookState) => R,\n ) {\n try {\n const state = new HookState(options);\n reconciler._currentHookState = state;\n return callback(state);\n } finally {\n reconciler._currentHookState = undefined;\n }\n }\n\n buildVNodes(component: ComponentNode, renderer: _Renderer<any>) {\n const event = new EventEmitter();\n const root = new VNode(component, event);\n const excute = function* () {\n const items: {\n node: VNode;\n stack: VNode[];\n propsProvider: VNode[];\n errorBoundary?: VNode;\n contextValue: Map<Context<any>, _ContextState>;\n }[] = [{\n node: root,\n stack: [],\n propsProvider: [],\n contextValue: new Map(),\n }];\n let item;\n while (item = items.shift()) {\n\n const { node, stack, propsProvider, errorBoundary, contextValue } = item;\n yield {\n node,\n stack,\n updated: node._updateIfNeed({\n renderer,\n stack,\n propsProvider,\n errorBoundary,\n contextValue\n }),\n };\n\n let _contextValue = contextValue;\n if (isContext(node.type)) {\n _contextValue = new Map(_contextValue);\n _contextValue.set(node.type, {\n value: node.props.value,\n state: node._content_state,\n node: node,\n });\n }\n\n const _propsProvider = node.type === PropsProvider ? [...propsProvider, node] : propsProvider;\n const _errorBoundary = node.type === ErrorBoundary ? node : errorBoundary;\n\n const _stack = [...stack, node];\n for (const item of node.children) {\n if (item instanceof VNode) {\n items.push({\n node: item,\n stack: _stack,\n propsProvider: _propsProvider,\n errorBoundary: _errorBoundary,\n contextValue: _contextValue,\n });\n }\n }\n }\n };\n return { node: root, event, excute };\n }\n};\n"],"names":["ComponentNode","NativeElementType","myersSync"],"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,oBAAoB,GAAG,IAAI,OAAO,EAAqB;AAEtD,MAAM,SAAS,GAAG,CAAC,IAAS,KAA0B;AAC3D,IAAA,OAAO,oBAAoB,CAAC,GAAG,CAAC,IAAW,CAAC;AAC9C,CAAC;AAKD,MAAM,cAAc,GAAG,CAAwB,YAAmB,KAAI;IACpE,MAAM,QAAQ,GAGT,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAI;AAC3B,QAAA,OAAO,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,QAAQ;AAC5D,KAAC;AACD,IAAA,MAAM,QAAQ,GAET,CAAC,EAAE,QAAQ,EAAE,KAAI;AACpB,QAAA,MAAM,KAAK,GAAG,UAAU,CAAC,QAA0B,CAAC;AACpD,QAAA,OAAO,QAAQ,CAAC,KAAK,CAAC;AACxB,KAAC;AACD,IAAA,oBAAoB,CAAC,GAAG,CAAC,QAA0B,EAAE,YAAY,CAAC;IAClE,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,CAAC;AACzC,CAAC;AAgBK,SAAU,aAAa,C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,CAAC,GAAG,KAAK,EAAE,IAAI,CAAC;AAC/B,gBAAA,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE;AAChC,oBAAA,IAAI,IAAI,YAAY,KAAK,EAAE;wBACzB,KAAK,CAAC,IAAI,CAAC;AACT,4BAAA,IAAI,EAAE,IAAI;AACV,4BAAA,KAAK,EAAE,MAAM;AACb,4BAAA,aAAa,EAAE,cAAc;AAC7B,4BAAA,aAAa,EAAE,cAAc;AAC7B,4BAAA,YAAY,EAAE,aAAa;AAC5B,yBAAA,CAAC;;;;AAIV,SAAC;QACD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE;;;;;;;;;;;;;;;"}
@@ -103,7 +103,7 @@ const useContext = (context, selector = v => v) => {
103
103
  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
104
104
  // THE SOFTWARE.
105
105
  //
106
- const equalDeps = (lhs, rhs) => _.isEqual(lhs ?? null, rhs);
106
+ const equalDeps = (lhs, rhs, customizer) => customizer ? _.isEqualWith(lhs ?? null, rhs, customizer) : _.isEqual(lhs ?? null, rhs);
107
107
 
108
108
  //
109
109
  // utils.ts
@@ -243,7 +243,10 @@ class VNode {
243
243
  return false;
244
244
  try {
245
245
  const { type, props: _props } = this._component;
246
- const props = options.propsProvider.reduceRight((p, node) => node.props.callback({ type, props: p }), _props);
246
+ const props = _.mapValues(options.propsProvider.reduceRight((p, node) => node.props.callback({ type, props: p }), _props), (v, k) => _.isFunction(v) ? (...args) => {
247
+ const current = this._component.props[k];
248
+ return _.isFunction(current) ? current(...args) : v(...args);
249
+ } : v);
247
250
  let children;
248
251
  if (_.isString(type) || type.prototype instanceof NativeElementType) {
249
252
  children = this._resolve_children(props.children);
@@ -287,7 +290,7 @@ class VNode {
287
290
  continue;
288
291
  if (!(children[i] instanceof VNode))
289
292
  continue;
290
- if (!equalDeps(item._component.props, children[i]._component.props))
293
+ if (!equalDeps(item._component.props, children[i]._component.props, (l, r) => _.isFunction(l) && _.isFunction(r) ? true : undefined))
291
294
  item._dirty = true;
292
295
  item._component = children[i]._component;
293
296
  }
@@ -533,4 +536,4 @@ const reconciler = new class {
533
536
  };
534
537
 
535
538
  export { ErrorBoundary as E, PropsProvider as P, VNode as V, uniqueId as a, EventEmitter as b, createContext as c, equalDeps as e, mergeRefs as m, reconciler as r, useContext as u };
536
- //# sourceMappingURL=state-5PNx91ec.mjs.map
539
+ //# sourceMappingURL=state-BlrAjoLt.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-BlrAjoLt.mjs","sources":["../../../src/core/hooks/context.ts","../../../src/core/reconciler/utils.ts","../../../src/core/utils.ts","../../../src/core/reconciler/vnode.ts","../../../src/core/reconciler/events.ts","../../../src/core/types/props.ts","../../../src/core/types/error.ts","../../../src/core/reconciler/state.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 { reconciler } from '../reconciler/state';\nimport { ComponentType, ElementNode } from '../types/common';\n\nconst _contextDefaultValue = new WeakMap<Context<any>, any>();\n\nexport const isContext = (type: any): type is Context<any> => {\n return _contextDefaultValue.has(type as any);\n};\n\nexport type Context<Value> = ReturnType<typeof _createContext<Value>>;\nexport type ContextType<C extends Context<any>> = C extends Context<infer T> ? T : never;\n\nconst _createContext = <Value extends unknown>(defaultValue: Value) => {\n const _context: ComponentType<{\n value: Value;\n children?: ElementNode | ((value: Value) => ElementNode);\n }> = ({ value, children }) => {\n return _.isFunction(children) ? children(value) : children;\n };\n const Consumer: ComponentType<{\n children: (value: Value) => ElementNode;\n }> = ({ children }) => {\n const value = useContext(_context as Context<Value>);\n return children(value);\n };\n _contextDefaultValue.set(_context as Context<Value>, defaultValue);\n return _.assign(_context, { Consumer });\n};\n\n/**\n * Creates a new context object with an optional default value.\n *\n * A context object allows you to share a value across a component tree\n * without explicitly passing it as a prop to every level.\n *\n * @template Value - The type of the value to be stored in the context.\n * @param - The default value for the context.\n * @returns A context object that can be used to provide and consume the value.\n */\n\nexport function createContext<Value>(defaultValue: Value): Context<Value>;\nexport function createContext<Value = undefined>(): Context<Value | undefined>;\n\nexport function createContext(defaultValue?: any) {\n return _createContext(defaultValue);\n}\n\n/**\n * A hook that retrieves the current value of a context and optionally applies\n * a selector function to transform the context value. This hook ensures that the component\n * subscribes to the context and re-renders when the context value changes.\n *\n * @template T - The type of the context value.\n * @template R - The type of the transformed value returned by the selector.\n * @param context - The context object to retrieve the value from.\n * @param selector - An optional selector function to transform the context value.\n * Defaults to an identity function.\n * @returns - The current value of the context, optionally transformed by the selector.\n *\n * @throws - Throws an error if the provided context is invalid or if the hook\n * is used outside of a render function.\n *\n * @example\n * const MyContext = createContext({ user: null });\n * \n * function MyComponent() {\n * const user = useContext(MyContext, context => context.user);\n * return <div>{user ? `Hello, ${user.name}` : 'Hello, Guest'}</div>;\n * }\n */\nexport const useContext = <T, R = T>(\n context: Context<T>,\n selector: (state: T) => R = v => v as any\n) => {\n if (!isContext(context)) throw Error(`Invalid type of ${context}`);\n const state = reconciler.currentHookState;\n if (!state) throw Error('useContext must be used within a render function.');\n const { contextValue, listens } = state;\n listens.add(context);\n const { value = _contextDefaultValue.get(context) } = contextValue.get(context) ?? {};\n return selector(value);\n};\n","//\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';\n\nexport const equalDeps = (lhs: any, rhs: any, customizer?: _.IsEqualCustomizer) => customizer ? _.isEqualWith(lhs ?? null, rhs, customizer) : _.isEqual(lhs ?? null, rhs);\n","//\n// utils.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 { Ref } from './types/common';\n\nexport const mergeRefs = <T>(...refs: (Ref<T> | null | undefined)[]) => (x: T) => {\n for (const ref of refs) {\n if (_.isNil(ref)) continue;\n else if (typeof ref === 'function') ref(x);\n else if (typeof ref === 'object') ref.current = x;\n else {\n console.error(`mergeRefs cannot handle Refs of type boolean, number or string, received ref ${ref}`);\n }\n }\n}\n\nlet counter = 0;\n\nexport const uniqueId = () => `${Date.now().toString(36)}${(counter++).toString(36)}${Math.random().toString(36).slice(2)}`;\n","//\n// vnode.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 { ComponentNode, NativeElementType } from '../types/component';\nimport { Context, isContext } from '../hooks/context';\nimport { reconciler } from './state';\nimport { myersSync } from 'myers.js';\nimport { EventEmitter } from './events';\nimport { equalDeps } from './utils';\nimport { _Renderer } from '../renderer';\nimport { PropsType } from '../types/runtime';\nimport { uniqueId } from '../utils';\n\nexport type VNodeState = {\n hook: string;\n deps: any;\n data?: any;\n mount?: () => () => void;\n};\n\nexport type _ContextState = {\n value: any;\n state: string;\n node: VNode;\n};\n\nexport class VNode {\n\n /** @internal */\n _component: ComponentNode;\n\n private _id = uniqueId();\n\n private _event: EventEmitter;\n private _props: PropsType = {};\n private _error?: any;\n private _children: (VNode | string)[] = [];\n private _state?: VNodeState[];\n private _dirty = true;\n private _listens = new Map<Context<any>, Omit<_ContextState, 'value'>>();\n\n /** @internal */\n _content_state = uniqueId();\n private _content_value?: any;\n\n /** @internal */\n constructor(component: ComponentNode, event: EventEmitter) {\n this._component = component;\n this._event = event;\n }\n\n /** @internal */\n _resolve_children(child: any): (VNode | string)[] {\n if (_.isBoolean(child) || _.isNil(child)) return [];\n if (_.isString(child)) return [child];\n if (_.isNumber(child)) return [`${child}`];\n if (child instanceof ComponentNode) return [new VNode(child, this._event)];\n if (_.isArrayLikeObject(child)) return _.flatMap(child, x => this._resolve_children(x));\n if (typeof child[Symbol.iterator] === 'function') return _.flatMap([...child], x => this._resolve_children(x));\n throw Error(`${child} are not valid as a child.`);\n }\n\n get id() {\n return this._id;\n }\n\n get type() {\n return this._component.type;\n }\n\n get props() {\n return this._props;\n }\n\n get key() {\n return this._component.key;\n }\n\n get state() {\n return this._state ?? [];\n }\n\n get children() {\n return this._children;\n }\n\n get error() {\n return this._error;\n }\n\n /** @internal */\n _setDirty() {\n this._dirty = true;\n this._event.emit('onchange');\n }\n\n /** @internal */\n private _check_context(values: Map<Context<any>, Omit<_ContextState, 'value'>>) {\n return this._listens.entries().every(([k, v]) => {\n const { state, node } = values.get(k) ?? {};\n return state === v.state && node === v.node;\n });\n }\n\n /** @internal */\n _updateIfNeed(options: {\n renderer: _Renderer<any>;\n stack: VNode[];\n propsProvider: VNode[];\n errorBoundary?: VNode;\n contextValue: Map<Context<any>, _ContextState>;\n }) {\n if (!this._dirty && this._check_context(options.contextValue)) return false;\n try {\n const { type, props: _props } = this._component;\n const props = _.mapValues(\n options.propsProvider.reduceRight((p, node) => node.props.callback({ type, props: p }), _props),\n (v, k) => _.isFunction(v) ? (...args: any[]) => {\n const current = this._component.props[k];\n return _.isFunction(current) ? current(...args) : v(...args);\n } : v,\n );\n let children: (VNode | string)[];\n if (_.isString(type) || type.prototype instanceof NativeElementType) {\n children = this._resolve_children(props.children);\n } else if (isContext(type)) {\n const { value } = props;\n if (!equalDeps(this._content_value, value)) this._content_state = uniqueId();\n this._content_value = value;\n children = this._resolve_children(type(props as any));\n } else if (_.isFunction(type)) {\n const { rendered, state } = reconciler.withHookState({\n renderer: options.renderer,\n node: this,\n state: this._state,\n stack: options.stack,\n contextValue: options.contextValue,\n }, (state) => ({ rendered: type(props), state }));\n this._state = state.state;\n this._listens = new Map(options.contextValue.entries().filter(([k]) => state.listens.has(k)));\n children = this._resolve_children(rendered);\n } else {\n throw Error(`Invalid node type ${type}`);\n }\n const diff = myersSync(this._children, children, {\n compare: (lhs, rhs) => {\n if (_.isString(lhs) && _.isString(rhs)) return lhs === rhs;\n if (lhs instanceof VNode && rhs instanceof VNode) return lhs._component._equal(rhs._component);\n return false;\n },\n });\n this._props = _.omit(props, 'children');\n this._children = _.flatMap(diff, x => x.equivalent ?? x.insert ?? []);\n this._error = undefined;\n for (const [i, item] of this._children.entries()) {\n if (!(item instanceof VNode)) continue;\n if (!(children[i] instanceof VNode)) continue;\n if (!equalDeps(item._component.props, children[i]._component.props, (l, r) => _.isFunction(l) && _.isFunction(r) ? true : undefined)) item._dirty = true;\n item._component = children[i]._component;\n }\n } catch (error) {\n this._props = {};\n this._children = [];\n this._error = error;\n (async () => {\n try {\n const { onError, silent } = options.errorBoundary?.props ?? {};\n if (!silent) console.error(error);\n if (_.isFunction(onError)) await onError(error, this._component, _.map(options.stack, x => x._component));\n } catch (e) {\n console.error(e);\n }\n })();\n } finally {\n this._dirty = false;\n }\n return true;\n }\n}\n","//\n// events.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';\n\nexport class EventEmitter {\n\n private _listeners: Record<string, ((...args: any[]) => void)[]> = {};\n\n register(event: string, callback: (event: string, ...args: any[]) => void) {\n if (_.isNil(this._listeners[event])) this._listeners[event] = [];\n const _callback = (...args: any[]) => callback(event, ...args);\n this._listeners[event].push(_callback);\n return {\n remove: () => {\n this._listeners[event] = _.filter(this._listeners[event], x => x !== _callback);\n },\n };\n }\n\n emit(event: string, ...args: any[]) {\n this._listeners[event]?.forEach(async callback => {\n try {\n await callback(...args)\n } catch (e) {\n console.error(e);\n }\n });\n }\n}\n","//\n// props.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 { ComponentType, PropsWithChildren } from './common';\nimport { NativeElementType } from './component';\nimport { _ElementType, PropsType } from './runtime';\n\ntype PropsProviderProps = PropsWithChildren<{\n callback: (v: {\n type: _ElementType | typeof NativeElementType,\n props: PropsType\n }) => PropsType | undefined | null;\n}>;\n\nexport const PropsProvider: ComponentType<PropsProviderProps> = ({ children }) => {\n return children;\n}\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 { ComponentType, PropsWithChildren } from './common';\nimport { ComponentNode } from './component';\n\ntype ErrorBoundaryProps = PropsWithChildren<{\n silent?: boolean;\n onError?: (\n error: any,\n component: ComponentNode,\n stack: ComponentNode[],\n ) => void;\n}>;\n\nexport const ErrorBoundary: ComponentType<ErrorBoundaryProps> = ({ children }) => {\n return children;\n}\n","//\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 { ComponentNode } from '../types/component';\nimport { Context, isContext } from '../hooks/context';\nimport { _ContextState, VNode, VNodeState } from './vnode';\nimport { EventEmitter } from './events';\nimport { PropsProvider } from '../types/props';\nimport { ErrorBoundary } from '../types/error';\nimport { _Renderer } from '../renderer';\n\nclass HookState {\n\n renderer: _Renderer<any>;\n\n contextValue: Map<Context<any>, _ContextState>;\n prevState?: VNodeState[];\n state: VNodeState[] = [];\n stack: VNode[] = [];\n node?: VNode;\n\n listens = new WeakSet<Context<any>>();\n\n constructor(options: {\n renderer: _Renderer<any>;\n node: VNode;\n stack: VNode[];\n state?: VNodeState[];\n contextValue: Map<Context<any>, _ContextState>;\n }) {\n this.renderer = options.renderer;\n this.node = options.node;\n this.stack = options.stack;\n this.prevState = options.state;\n this.contextValue = options.contextValue ?? new Map();\n }\n}\n\nexport const reconciler = new class {\n\n /** @internal */\n _registry = new WeakMap<any, string>();\n\n /** @internal */\n _currentHookState: HookState | undefined;\n\n get currentHookState() {\n return this._currentHookState;\n }\n\n withHookState<R = void>(\n options: ConstructorParameters<typeof HookState>[0],\n callback: (state: HookState) => R,\n ) {\n try {\n const state = new HookState(options);\n reconciler._currentHookState = state;\n return callback(state);\n } finally {\n reconciler._currentHookState = undefined;\n }\n }\n\n buildVNodes(component: ComponentNode, renderer: _Renderer<any>) {\n const event = new EventEmitter();\n const root = new VNode(component, event);\n const excute = function* () {\n const items: {\n node: VNode;\n stack: VNode[];\n propsProvider: VNode[];\n errorBoundary?: VNode;\n contextValue: Map<Context<any>, _ContextState>;\n }[] = [{\n node: root,\n stack: [],\n propsProvider: [],\n contextValue: new Map(),\n }];\n let item;\n while (item = items.shift()) {\n\n const { node, stack, propsProvider, errorBoundary, contextValue } = item;\n yield {\n node,\n stack,\n updated: node._updateIfNeed({\n renderer,\n stack,\n propsProvider,\n errorBoundary,\n contextValue\n }),\n };\n\n let _contextValue = contextValue;\n if (isContext(node.type)) {\n _contextValue = new Map(_contextValue);\n _contextValue.set(node.type, {\n value: node.props.value,\n state: node._content_state,\n node: node,\n });\n }\n\n const _propsProvider = node.type === PropsProvider ? [...propsProvider, node] : propsProvider;\n const _errorBoundary = node.type === ErrorBoundary ? node : errorBoundary;\n\n const _stack = [...stack, node];\n for (const item of node.children) {\n if (item instanceof VNode) {\n items.push({\n node: item,\n stack: _stack,\n propsProvider: _propsProvider,\n errorBoundary: _errorBoundary,\n contextValue: _contextValue,\n });\n }\n }\n }\n };\n return { node: root, event, excute };\n }\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA,MAAM,oBAAoB,GAAG,IAAI,OAAO,EAAqB;AAEtD,MAAM,SAAS,GAAG,CAAC,IAAS,KAA0B;AAC3D,IAAA,OAAO,oBAAoB,CAAC,GAAG,CAAC,IAAW,CAAC;AAC9C,CAAC;AAKD,MAAM,cAAc,GAAG,CAAwB,YAAmB,KAAI;IACpE,MAAM,QAAQ,GAGT,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAI;AAC3B,QAAA,OAAO,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,QAAQ,C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AI,EAAE;AAC3B,wBAAA,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;wBACvB,KAAK,EAAE,IAAI,CAAC,cAAc;AAC1B,wBAAA,IAAI,EAAE,IAAI;AACX,qBAAA,CAAC;;gBAGJ,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,KAAK,aAAa,GAAG,CAAC,GAAG,aAAa,EAAE,IAAI,CAAC,GAAG,aAAa;AAC7F,gBAAA,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,KAAK,aAAa,GAAG,IAAI,GAAG,aAAa;gBAEzE,MAAM,MAAM,GAAG,CAAC,GAAG,KAAK,EAAE,IAAI,CAAC;AAC/B,gBAAA,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE;AAChC,oBAAA,IAAI,IAAI,YAAY,KAAK,EAAE;wBACzB,KAAK,CAAC,IAAI,CAAC;AACT,4BAAA,IAAI,EAAE,IAAI;AACV,4BAAA,KAAK,EAAE,MAAM;AACb,4BAAA,aAAa,EAAE,cAAc;AAC7B,4BAAA,aAAa,EAAE,cAAc;AAC7B,4BAAA,YAAY,EAAE,aAAa;AAC5B,yBAAA,CAAC;;;;AAIV,SAAC;QACD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE;;;;;;"}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var _ = require('lodash');
4
- var state = require('./state-Lf_tbWNd.js');
4
+ var state = require('./state-Bh2gCPTd.js');
5
5
 
6
6
  //
7
7
  // index.ts
@@ -310,4 +310,4 @@ exports.useCallback = useCallback;
310
310
  exports.useEffect = useEffect;
311
311
  exports.useMemo = useMemo;
312
312
  exports.useSyncExternalStore = useSyncExternalStore;
313
- //# sourceMappingURL=sync-e3464vDv.js.map
313
+ //# sourceMappingURL=sync-BTFAme8k.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sync-e3464vDv.js","sources":["../../../src/core/reconciler/hooks.ts","../../../src/core/hooks/callback.ts","../../../src/core/hooks/effect.ts","../../../src/core/hooks/memo.ts","../../../src/core/hooks/sync.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 { 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';\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// 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// 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":["state","reconciler","equalDeps"],"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,YA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nB,GAAG;AACN,aAAC;;QACD,OAAO,CAAC,EAAE;AACV,YAAA,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AAChB,YAAA,OAAO,MAAM,KAAK,CAAC,KAAK,EAAE;;KAE7B,EAAE,IAAI,CAAC;IACR,IAAI,iBAAiB,IAAIA,OAAK,CAAC,QAAQ,CAAC,OAAO,EAAE;QAC/C,OAAO,iBAAiB,EAAE;;IAE5B,OAAO,WAAW,EAAE;AACtB;;;;;;;;;"}
1
+ {"version":3,"file":"sync-BTFAme8k.js","sources":["../../../src/core/reconciler/hooks.ts","../../../src/core/hooks/callback.ts","../../../src/core/hooks/effect.ts","../../../src/core/hooks/memo.ts","../../../src/core/hooks/sync.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 { 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';\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// 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// 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":["state","reconciler","equalDeps"],"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,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C,QAAQ,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC;AACxE,YAAA,OAAO,MAAK;gBACV,KAAK,CAAC,KAAK,EAAE;gBACb,CAAC,YAAW;AACV,oBAAA,IAAI;AACF,wBAAA,MAAM,WAAW,GAAG,MAAM,UAAU;AACpC,wBAAA,IAAI,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC;AAAE,4BAAA,WAAW,EAAE;;oBAC5C,OAAO,CAAC,EAAE;AACV,wBAAA,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;;iBAEnB,GAAG;AACN,aAAC;;QACD,OAAO,CAAC,EAAE;AACV,YAAA,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AAChB,YAAA,OAAO,MAAM,KAAK,CAAC,KAAK,EAAE;;KAE7B,EAAE,IAAI,CAAC;IACR,IAAI,iBAAiB,IAAIA,OAAK,CAAC,QAAQ,CAAC,OAAO,EAAE;QAC/C,OAAO,iBAAiB,EAAE;;IAE5B,OAAO,WAAW,EAAE;AACtB;;;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { e as equalDeps, r as reconciler } from './state-5PNx91ec.mjs';
2
+ import { e as equalDeps, r as reconciler } from './state-BlrAjoLt.mjs';
3
3
 
4
4
  //
5
5
  // index.ts
@@ -303,4 +303,4 @@ const useSyncExternalStore = (subscribe, getSnapshot, getServerSnapshot) => {
303
303
  };
304
304
 
305
305
  export { _useEffect as _, _useMemo as a, useMemo as b, useEffect as c, useSyncExternalStore as d, useCallback as u };
306
- //# sourceMappingURL=sync-C4RmxDzS.mjs.map
306
+ //# sourceMappingURL=sync-Cec6c-K_.mjs.map