frosty 0.0.78 → 0.0.80

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 (47) hide show
  1. package/README.md +0 -1
  2. package/dist/_native.d.ts +3 -3
  3. package/dist/_native.mjs +2 -2
  4. package/dist/dom.d.ts +3 -3
  5. package/dist/dom.mjs +3 -3
  6. package/dist/index.d.ts +7 -7
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +6 -6
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.mjs +9 -9
  11. package/dist/index.mjs.map +1 -1
  12. package/dist/internals/{common-lfYTb1eV.d.ts → common-C5xm7xDw.d.ts} +3 -3
  13. package/dist/internals/{common-lfYTb1eV.d.ts.map → common-C5xm7xDw.d.ts.map} +1 -1
  14. package/dist/internals/{common-CPQORaXm.mjs → common-IghNU-hG.mjs} +3 -3
  15. package/dist/internals/{common-CPQORaXm.mjs.map → common-IghNU-hG.mjs.map} +1 -1
  16. package/dist/internals/{common-B0Nya-9e.d.ts → common-jmXMOod4.d.ts} +3 -3
  17. package/dist/internals/{common-B0Nya-9e.d.ts.map → common-jmXMOod4.d.ts.map} +1 -1
  18. package/dist/internals/{fragment-CApRh6Hp.d.ts → fragment-BQXp1_iv.d.ts} +2 -2
  19. package/dist/internals/{fragment-CApRh6Hp.d.ts.map → fragment-BQXp1_iv.d.ts.map} +1 -1
  20. package/dist/internals/{renderer-DBPR_8BN.d.ts → renderer-D4aiCZGU.d.ts} +2 -2
  21. package/dist/internals/{renderer-DBPR_8BN.d.ts.map → renderer-D4aiCZGU.d.ts.map} +1 -1
  22. package/dist/internals/{renderer-DnIxEcQv.mjs → renderer-Dn64xymQ.mjs} +2 -2
  23. package/dist/internals/{renderer-DnIxEcQv.mjs.map → renderer-Dn64xymQ.mjs.map} +1 -1
  24. package/dist/internals/{state-BIFtc4bv.mjs → state-BRL-17Kd.mjs} +2 -2
  25. package/dist/internals/{state-BIFtc4bv.mjs.map → state-BRL-17Kd.mjs.map} +1 -1
  26. package/dist/internals/{sync-2I_UkBG9.mjs → sync-BlGknxx_.mjs} +3 -3
  27. package/dist/internals/{sync-2I_UkBG9.mjs.map → sync-BlGknxx_.mjs.map} +1 -1
  28. package/dist/internals/{utils-CyrF9IfR.d.ts → utils-B_4b5vas.d.ts} +2 -2
  29. package/dist/internals/{utils-CyrF9IfR.d.ts.map → utils-B_4b5vas.d.ts.map} +1 -1
  30. package/dist/jsx-dev-runtime.d.ts +7 -3
  31. package/dist/jsx-dev-runtime.d.ts.map +1 -1
  32. package/dist/jsx-dev-runtime.js +28 -2
  33. package/dist/jsx-dev-runtime.js.map +1 -1
  34. package/dist/jsx-dev-runtime.mjs +32 -1
  35. package/dist/jsx-dev-runtime.mjs.map +1 -1
  36. package/dist/jsx-runtime.d.ts +2 -2
  37. package/dist/server-dom.d.ts +3 -3
  38. package/dist/server-dom.mjs +3 -3
  39. package/dist/web.d.ts +3 -3
  40. package/dist/web.mjs +5 -5
  41. package/package.json +1 -1
  42. package/packages/frosty-cli/src/server/{default.js → default.ts} +2 -3
  43. package/packages/frosty-cli/src/server/{env.js → env.ts} +3 -1
  44. package/packages/frosty-cli/src/server/index.js +2 -6
  45. package/packages/frosty-cli/src/server/render.js +11 -11
  46. package/packages/frosty-cli/src/server/route.ts +1 -27
  47. package/packages/frosty-cli/webpack.mjs +0 -1
@@ -1,5 +1,5 @@
1
- import { N as NativeElementType, a as ComponentNode } from './common-lfYTb1eV.js';
2
- import { _ as _Renderer } from './renderer-DBPR_8BN.js';
1
+ import { N as NativeElementType, b as ComponentNode } from './common-C5xm7xDw.js';
2
+ import { _ as _Renderer } from './renderer-D4aiCZGU.js';
3
3
  import { DOMWindow } from 'jsdom';
4
4
 
5
5
  declare abstract class DOMNativeNode extends NativeElementType {
@@ -28,4 +28,4 @@ declare abstract class _DOMRenderer extends _Renderer<Element | DOMNativeNode> {
28
28
  }
29
29
 
30
30
  export { DOMNativeNode as D, _DOMRenderer as _ };
31
- //# sourceMappingURL=common-B0Nya-9e.d.ts.map
31
+ //# sourceMappingURL=common-jmXMOod4.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"common-B0Nya-9e.d.ts","sources":["../../src/renderer/common.ts"],"sourcesContent":["//\n// common.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 '../core/reconciler/vnode';\nimport { myersSync } from 'myers.js';\nimport { globalEvents } from '../core/web/event';\nimport { ComponentNode, NativeElementType } from '../core/types/component';\nimport { svgProps, htmlProps, tags } from '../../generated/elements';\nimport { _propValue } from '../core/web/props';\nimport { ClassName, StyleProp } from '../core/types/style';\nimport { ExtendedCSSProperties } from '../core/web/styles/css';\nimport { _Renderer } from '../core/renderer';\nimport { processCss } from '../core/web/styles/process';\nimport { StyleBuilder } from './style';\nimport { mergeRefs } from '../core/utils';\nimport type { DOMWindow } from 'jsdom';\n\nconst SVG_NS = 'http://www.w3.org/2000/svg';\nconst HTML_NS = 'http://www.w3.org/1999/xhtml';\nconst MATHML_NS = 'http://www.w3.org/1998/Math/MathML';\n\nconst findPrototypeProperty = (object: any, propertyName: string) => {\n while (object && object.constructor && object.constructor.name !== 'Object') {\n let desc = Object.getOwnPropertyDescriptor(object, propertyName);\n if (desc) return desc;\n object = Object.getPrototypeOf(object);\n }\n return null;\n};\n\nconst isWriteable = (object: any, propertyName: string) => {\n let desc = findPrototypeProperty(object, propertyName);\n if (!desc) {\n return false;\n }\n if (desc.writable && typeof desc.value !== 'function') {\n return true;\n }\n return !!desc.set;\n};\n\nexport abstract class DOMNativeNode extends NativeElementType {\n\n static createElement: (doc: Document, renderer: _DOMRenderer) => DOMNativeNode;\n\n abstract get target(): Element | Element[];\n\n abstract update(props: Record<string, any> & {\n className?: string;\n style?: string;\n }): void;\n\n abstract replaceChildren(children: (string | Element | DOMNativeNode)[]): void;\n\n abstract destroy(): void;\n}\n\nexport abstract class _DOMRenderer extends _Renderer<Element | DOMNativeNode> {\n\n private _window: Window | DOMWindow;\n private _namespace_map = new WeakMap<VNode, string | undefined>();\n\n private _tracked_head_children: (string | Element | DOMNativeNode)[] = [];\n private _tracked_style = new StyleBuilder();\n private _tracked_elements = new Map<Element | DOMNativeNode, { props: string[]; className: string[]; listener: Record<string, EventListener | undefined>; }>();\n\n constructor(window: Window | DOMWindow) {\n super();\n this._window = window;\n }\n\n get document() {\n return this.window.document;\n }\n\n get window() {\n return this._window;\n }\n\n /** @internal */\n _beforeUpdate() {\n if (this._server) {\n this._tracked_head_children = [];\n }\n }\n\n /** @internal */\n _afterUpdate() {\n this._tracked_style.select([...this._tracked_elements.values().flatMap(({ className }) => className)]);\n const head = this.document.head ?? this.document.createElementNS(HTML_NS, 'head');\n if (this._tracked_style.isEmpty) {\n if (this._server) {\n this.__replaceChildren(head, this._tracked_head_children);\n }\n } else {\n const styleElem = this.document.querySelector('style[data-frosty-style]') ?? this.document.createElementNS(HTML_NS, 'style');\n styleElem.setAttribute('data-frosty-style', '');\n if (styleElem.textContent !== this._tracked_style.css)\n styleElem.textContent = this._tracked_style.css;\n if (this._server) {\n this.__replaceChildren(head, [...this._tracked_head_children, styleElem]);\n } else if (styleElem.parentNode !== head) {\n head.appendChild(styleElem);\n }\n }\n if (!this.document.head) {\n this.document.documentElement.insertBefore(head, this.document.body);\n }\n }\n\n /** @internal */\n _createElement(node: VNode, stack: VNode[]) {\n const { type } = node;\n if (!_.isString(type) && type.prototype instanceof DOMNativeNode) {\n const ElementType = type as typeof DOMNativeNode;\n const elem = ElementType.createElement(this.document, this);\n this._tracked_elements.set(elem, {\n props: [],\n className: [],\n listener: {},\n });\n this._updateElement(node, elem, stack);\n return elem;\n }\n if (!_.isString(type)) throw Error('Invalid type');\n switch (type) {\n case 'html': return this.document.documentElement;\n case 'head': return this.document.head ?? this.document.createElementNS(HTML_NS, 'head');\n case 'body': return this.document.body ?? this.document.createElementNS(HTML_NS, 'body');\n default: break;\n }\n const _ns_list = _.compact([\n _.includes(tags.svg, type) && SVG_NS,\n _.includes(tags.html, type) && HTML_NS,\n _.includes(tags.mathml, type) && MATHML_NS,\n ]);\n const parent = _.last(stack);\n const ns = _ns_list.length > 1 ? parent && _.first(_.intersection([this._namespace_map.get(parent)], _ns_list)) : _.first(_ns_list);\n const elem = ns ? this.document.createElementNS(ns, type) : this.document.createElement(type);\n this._namespace_map.set(node, ns);\n this._tracked_elements.set(elem, {\n props: [],\n className: [],\n listener: {},\n });\n this._updateElement(node, elem, stack);\n return elem;\n }\n\n private __createBuiltClassName(\n element: Element | DOMNativeNode,\n className: ClassName,\n style: StyleProp<ExtendedCSSProperties>,\n ) {\n const _className = _.compact(_.flattenDeep([className]));\n const built = this._tracked_style.buildStyle(_.compact(_.flattenDeep([style])));\n const tracked = this._tracked_elements.get(element);\n if (tracked) tracked.className = built;\n return [..._className, ...built].join(' ');\n }\n\n private __updateEventListener(\n element: Element,\n key: string,\n listener: EventListener | undefined,\n options?: AddEventListenerOptions,\n ) {\n const event = key.endsWith('Capture') ? key.slice(2, -7).toLowerCase() : key.slice(2).toLowerCase();\n const tracked_listener = this._tracked_elements.get(element)?.listener;\n if (!tracked_listener) return;\n if (tracked_listener[key] !== listener) {\n if (_.isFunction(tracked_listener[key])) element.removeEventListener(event, tracked_listener[key], options);\n if (_.isFunction(listener)) element.addEventListener(event, listener, options);\n }\n tracked_listener[key] = listener;\n }\n\n /** @internal */\n _updateElement(node: VNode, element: Element | DOMNativeNode, stack: VNode[]) {\n\n if (element instanceof DOMNativeNode) {\n const {\n props: { ref, className, style, inlineStyle, ..._props }\n } = node;\n if (ref) mergeRefs(ref)(element.target);\n const builtClassName = this.__createBuiltClassName(element, className, style);\n const { css } = processCss(inlineStyle);\n element.update({\n className: builtClassName ? builtClassName : undefined,\n style: css ? css : undefined,\n ..._props\n });\n return;\n }\n\n const {\n type,\n props: { ref, className, style, inlineStyle, innerHTML, ..._props }\n } = node;\n\n if (!_.isString(type)) throw Error('Invalid type');\n switch (type) {\n case 'html': return;\n case 'head': return;\n case 'body': return;\n default: break;\n }\n\n if (ref) mergeRefs(ref)(element);\n\n const builtClassName = this.__createBuiltClassName(element, className, style);\n if (_.isEmpty(builtClassName)) {\n if (!_.isNil(element.getAttribute('class')))\n element.removeAttribute('class');\n } else if (element.className !== builtClassName) {\n element.className = builtClassName;\n }\n if (!_.isEmpty(innerHTML) && element.innerHTML !== innerHTML) element.innerHTML = innerHTML;\n\n if (inlineStyle) {\n const { css } = processCss(inlineStyle);\n const oldValue = element.getAttribute('style');\n const newValue = css.split('\\n').join('');\n if (oldValue !== newValue)\n element.setAttribute('style', newValue);\n } else if (!_.isNil(element.getAttribute('style'))) {\n element.removeAttribute('style');\n }\n\n const tracked = this._tracked_elements.get(element);\n if (!tracked) return;\n const removed = _.difference(tracked.props, _.keys(_props));\n const props = {\n ..._props,\n ..._.fromPairs(_.map(removed, x => [x, undefined])),\n };\n tracked.props = _.keys(_props);\n\n for (const [key, value] of _.entries(props)) {\n if (_.includes(globalEvents, key)) {\n this.__updateEventListener(element, key, value, { capture: false });\n } else if (key.endsWith('Capture') && _.includes(globalEvents, key.slice(0, -7))) {\n this.__updateEventListener(element, key, value, { capture: true });\n } else if (isWriteable(element, key)) {\n if ((element as any)[key] !== value)\n (element as any)[key] = value;\n } else if (key.startsWith('data-')) {\n const oldValue = element.getAttribute(key);\n if (value === false || _.isNil(value)) {\n if (!_.isNil(oldValue))\n element.removeAttribute(key);\n } else {\n const newValue = value === true ? '' : `${value}`;\n if (oldValue !== newValue)\n element.setAttribute(key, newValue);\n }\n } else {\n const { type: _type, attr } = (htmlProps as any)['*'][key]\n ?? (htmlProps as any)[type]?.[key]\n ?? (svgProps as any)['*'][key]\n ?? (svgProps as any)[type]?.[key]\n ?? {};\n if (_type && attr && (_propValue as any)[_type]) {\n const oldValue = element.getAttribute(key);\n if (value === false || _.isNil(value)) {\n if (!_.isNil(oldValue))\n element.removeAttribute(key);\n } else {\n const newValue = value === true ? '' : `${value}`;\n if (oldValue !== newValue)\n element.setAttribute(key, newValue);\n }\n }\n }\n }\n }\n\n /** @internal */\n _replaceChildren(node: VNode, element: Element | DOMNativeNode, children: (string | Element | DOMNativeNode)[], stack: VNode[], force?: boolean) {\n if (element instanceof DOMNativeNode) {\n element.replaceChildren(children);\n } else {\n const {\n type,\n props: { innerHTML }\n } = node;\n if (type === 'head') {\n this._tracked_head_children.push(...children);\n } else if (_.isEmpty(innerHTML)) {\n this.__replaceChildren(element, children, force);\n }\n }\n }\n\n /** @internal */\n _destroyElement(node: VNode, element: Element | DOMNativeNode) {\n if (element instanceof DOMNativeNode) {\n element.destroy();\n } else {\n const tracked_listener = this._tracked_elements.get(element)?.listener;\n for (const [key, listener] of _.entries(tracked_listener)) {\n const event = key.endsWith('Capture') ? key.slice(2, -7).toLowerCase() : key.slice(2).toLowerCase();\n if (_.isFunction(listener)) {\n element.removeEventListener(event, listener, { capture: key.endsWith('Capture') });\n }\n }\n }\n this._tracked_elements.delete(element);\n }\n\n __replaceChildren(element: Element, children: (string | Element | DOMNativeNode)[], force?: boolean) {\n const diff = myersSync(\n _.map(element.childNodes, x => x.nodeType === this.document.TEXT_NODE ? x.textContent ?? '' : x),\n _.flatMap(children, x => x instanceof DOMNativeNode ? x.target : x),\n { compare: (a, b) => a === b },\n );\n let i = 0;\n for (const { remove, insert, equivalent } of diff) {\n if (equivalent) {\n i += equivalent.length;\n } else if (remove) {\n for (const child of remove) {\n if (force || _.isString(child) || this._tracked_elements.has(child as any)) {\n element.removeChild(element.childNodes[i]);\n } else {\n i++;\n }\n }\n }\n if (insert) {\n for (const child of insert) {\n const node = _.isString(child) ? this.document.createTextNode(child) : child;\n element.insertBefore(node, element.childNodes[i++]);\n }\n }\n }\n }\n\n async renderToString(component: ComponentNode) {\n const root = this.createRoot();\n try {\n await root.mount(component, { skipMount: true });\n const elements = _.flatMap(_.castArray(root.root ?? []), x => x instanceof DOMNativeNode ? x.target : x);\n const str = _.map(elements, x => x.outerHTML).join('');\n return str.startsWith('<html>') ? `<!DOCTYPE html>${str}` : str;\n } finally {\n root.unmount();\n }\n }\n}\n"],"names":[],"mappings":";;;;AAGO,uBAAA,aAAA,SAAA,iBAAA;AACP,gCAAA,QAAA,YAAA,YAAA,KAAA,aAAA;AACA,2BAAA,OAAA,GAAA,OAAA;AACA,2BAAA,MAAA;AACA;AACA;AACA;AACA,iDAAA,OAAA,GAAA,aAAA;AACA;AACA;AACO,uBAAA,YAAA,SAAA,SAAA,CAAA,OAAA,GAAA,aAAA;AACP;AACA;AACA;AACA;AACA;AACA,wBAAA,MAAA,GAAA,SAAA;AACA,oBAAA,QAAA;AACA,kBAAA,MAAA,GAAA,SAAA;AACA;AACA;AACA,+BAAA,OAAA,sBAAA,OAAA,GAAA,aAAA;AACA,8BAAA,aAAA,GAAA,OAAA;AACA;;;;"}
1
+ {"version":3,"file":"common-jmXMOod4.d.ts","sources":["../../src/renderer/common.ts"],"sourcesContent":["//\n// common.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 '../core/reconciler/vnode';\nimport { myersSync } from 'myers.js';\nimport { globalEvents } from '../core/web/event';\nimport { ComponentNode, NativeElementType } from '../core/types/component';\nimport { svgProps, htmlProps, tags } from '../../generated/elements';\nimport { _propValue } from '../core/web/props';\nimport { ClassName, StyleProp } from '../core/types/style';\nimport { ExtendedCSSProperties } from '../core/web/styles/css';\nimport { _Renderer } from '../core/renderer';\nimport { processCss } from '../core/web/styles/process';\nimport { StyleBuilder } from './style';\nimport { mergeRefs } from '../core/utils';\nimport type { DOMWindow } from 'jsdom';\n\nconst SVG_NS = 'http://www.w3.org/2000/svg';\nconst HTML_NS = 'http://www.w3.org/1999/xhtml';\nconst MATHML_NS = 'http://www.w3.org/1998/Math/MathML';\n\nconst findPrototypeProperty = (object: any, propertyName: string) => {\n while (object && object.constructor && object.constructor.name !== 'Object') {\n let desc = Object.getOwnPropertyDescriptor(object, propertyName);\n if (desc) return desc;\n object = Object.getPrototypeOf(object);\n }\n return null;\n};\n\nconst isWriteable = (object: any, propertyName: string) => {\n let desc = findPrototypeProperty(object, propertyName);\n if (!desc) {\n return false;\n }\n if (desc.writable && typeof desc.value !== 'function') {\n return true;\n }\n return !!desc.set;\n};\n\nexport abstract class DOMNativeNode extends NativeElementType {\n\n static createElement: (doc: Document, renderer: _DOMRenderer) => DOMNativeNode;\n\n abstract get target(): Element | Element[];\n\n abstract update(props: Record<string, any> & {\n className?: string;\n style?: string;\n }): void;\n\n abstract replaceChildren(children: (string | Element | DOMNativeNode)[]): void;\n\n abstract destroy(): void;\n}\n\nexport abstract class _DOMRenderer extends _Renderer<Element | DOMNativeNode> {\n\n private _window: Window | DOMWindow;\n private _namespace_map = new WeakMap<VNode, string | undefined>();\n\n private _tracked_head_children: (string | Element | DOMNativeNode)[] = [];\n private _tracked_style = new StyleBuilder();\n private _tracked_elements = new Map<Element | DOMNativeNode, { props: string[]; className: string[]; listener: Record<string, EventListener | undefined>; }>();\n\n constructor(window: Window | DOMWindow) {\n super();\n this._window = window;\n }\n\n get document() {\n return this.window.document;\n }\n\n get window() {\n return this._window;\n }\n\n /** @internal */\n _beforeUpdate() {\n if (this._server) {\n this._tracked_head_children = [];\n }\n }\n\n /** @internal */\n _afterUpdate() {\n this._tracked_style.select([...this._tracked_elements.values().flatMap(({ className }) => className)]);\n const head = this.document.head ?? this.document.createElementNS(HTML_NS, 'head');\n if (this._tracked_style.isEmpty) {\n if (this._server) {\n this.__replaceChildren(head, this._tracked_head_children);\n }\n } else {\n const styleElem = this.document.querySelector('style[data-frosty-style]') ?? this.document.createElementNS(HTML_NS, 'style');\n styleElem.setAttribute('data-frosty-style', '');\n if (styleElem.textContent !== this._tracked_style.css)\n styleElem.textContent = this._tracked_style.css;\n if (this._server) {\n this.__replaceChildren(head, [...this._tracked_head_children, styleElem]);\n } else if (styleElem.parentNode !== head) {\n head.appendChild(styleElem);\n }\n }\n if (!this.document.head) {\n this.document.documentElement.insertBefore(head, this.document.body);\n }\n }\n\n /** @internal */\n _createElement(node: VNode, stack: VNode[]) {\n const { type } = node;\n if (!_.isString(type) && type.prototype instanceof DOMNativeNode) {\n const ElementType = type as typeof DOMNativeNode;\n const elem = ElementType.createElement(this.document, this);\n this._tracked_elements.set(elem, {\n props: [],\n className: [],\n listener: {},\n });\n this._updateElement(node, elem, stack);\n return elem;\n }\n if (!_.isString(type)) throw Error('Invalid type');\n switch (type) {\n case 'html': return this.document.documentElement;\n case 'head': return this.document.head ?? this.document.createElementNS(HTML_NS, 'head');\n case 'body': return this.document.body ?? this.document.createElementNS(HTML_NS, 'body');\n default: break;\n }\n const _ns_list = _.compact([\n _.includes(tags.svg, type) && SVG_NS,\n _.includes(tags.html, type) && HTML_NS,\n _.includes(tags.mathml, type) && MATHML_NS,\n ]);\n const parent = _.last(stack);\n const ns = _ns_list.length > 1 ? parent && _.first(_.intersection([this._namespace_map.get(parent)], _ns_list)) : _.first(_ns_list);\n const elem = ns ? this.document.createElementNS(ns, type) : this.document.createElement(type);\n this._namespace_map.set(node, ns);\n this._tracked_elements.set(elem, {\n props: [],\n className: [],\n listener: {},\n });\n this._updateElement(node, elem, stack);\n return elem;\n }\n\n private __createBuiltClassName(\n element: Element | DOMNativeNode,\n className: ClassName,\n style: StyleProp<ExtendedCSSProperties>,\n ) {\n const _className = _.compact(_.flattenDeep([className]));\n const built = this._tracked_style.buildStyle(_.compact(_.flattenDeep([style])));\n const tracked = this._tracked_elements.get(element);\n if (tracked) tracked.className = built;\n return [..._className, ...built].join(' ');\n }\n\n private __updateEventListener(\n element: Element,\n key: string,\n listener: EventListener | undefined,\n options?: AddEventListenerOptions,\n ) {\n const event = key.endsWith('Capture') ? key.slice(2, -7).toLowerCase() : key.slice(2).toLowerCase();\n const tracked_listener = this._tracked_elements.get(element)?.listener;\n if (!tracked_listener) return;\n if (tracked_listener[key] !== listener) {\n if (_.isFunction(tracked_listener[key])) element.removeEventListener(event, tracked_listener[key], options);\n if (_.isFunction(listener)) element.addEventListener(event, listener, options);\n }\n tracked_listener[key] = listener;\n }\n\n /** @internal */\n _updateElement(node: VNode, element: Element | DOMNativeNode, stack: VNode[]) {\n\n if (element instanceof DOMNativeNode) {\n const {\n props: { ref, className, style, inlineStyle, ..._props }\n } = node;\n if (ref) mergeRefs(ref)(element.target);\n const builtClassName = this.__createBuiltClassName(element, className, style);\n const { css } = processCss(inlineStyle);\n element.update({\n className: builtClassName ? builtClassName : undefined,\n style: css ? css : undefined,\n ..._props\n });\n return;\n }\n\n const {\n type,\n props: { ref, className, style, inlineStyle, innerHTML, ..._props }\n } = node;\n\n if (!_.isString(type)) throw Error('Invalid type');\n switch (type) {\n case 'html': return;\n case 'head': return;\n case 'body': return;\n default: break;\n }\n\n if (ref) mergeRefs(ref)(element);\n\n const builtClassName = this.__createBuiltClassName(element, className, style);\n if (_.isEmpty(builtClassName)) {\n if (!_.isNil(element.getAttribute('class')))\n element.removeAttribute('class');\n } else if (element.className !== builtClassName) {\n element.className = builtClassName;\n }\n if (!_.isEmpty(innerHTML) && element.innerHTML !== innerHTML) element.innerHTML = innerHTML;\n\n if (inlineStyle) {\n const { css } = processCss(inlineStyle);\n const oldValue = element.getAttribute('style');\n const newValue = css.split('\\n').join('');\n if (oldValue !== newValue)\n element.setAttribute('style', newValue);\n } else if (!_.isNil(element.getAttribute('style'))) {\n element.removeAttribute('style');\n }\n\n const tracked = this._tracked_elements.get(element);\n if (!tracked) return;\n const removed = _.difference(tracked.props, _.keys(_props));\n const props = {\n ..._props,\n ..._.fromPairs(_.map(removed, x => [x, undefined])),\n };\n tracked.props = _.keys(_props);\n\n for (const [key, value] of _.entries(props)) {\n if (_.includes(globalEvents, key)) {\n this.__updateEventListener(element, key, value, { capture: false });\n } else if (key.endsWith('Capture') && _.includes(globalEvents, key.slice(0, -7))) {\n this.__updateEventListener(element, key, value, { capture: true });\n } else if (isWriteable(element, key)) {\n if ((element as any)[key] !== value)\n (element as any)[key] = value;\n } else if (key.startsWith('data-')) {\n const oldValue = element.getAttribute(key);\n if (value === false || _.isNil(value)) {\n if (!_.isNil(oldValue))\n element.removeAttribute(key);\n } else {\n const newValue = value === true ? '' : `${value}`;\n if (oldValue !== newValue)\n element.setAttribute(key, newValue);\n }\n } else {\n const { type: _type, attr } = (htmlProps as any)['*'][key]\n ?? (htmlProps as any)[type]?.[key]\n ?? (svgProps as any)['*'][key]\n ?? (svgProps as any)[type]?.[key]\n ?? {};\n if (_type && attr && (_propValue as any)[_type]) {\n const oldValue = element.getAttribute(key);\n if (value === false || _.isNil(value)) {\n if (!_.isNil(oldValue))\n element.removeAttribute(key);\n } else {\n const newValue = value === true ? '' : `${value}`;\n if (oldValue !== newValue)\n element.setAttribute(key, newValue);\n }\n }\n }\n }\n }\n\n /** @internal */\n _replaceChildren(node: VNode, element: Element | DOMNativeNode, children: (string | Element | DOMNativeNode)[], stack: VNode[], force?: boolean) {\n if (element instanceof DOMNativeNode) {\n element.replaceChildren(children);\n } else {\n const {\n type,\n props: { innerHTML }\n } = node;\n if (type === 'head') {\n this._tracked_head_children.push(...children);\n } else if (_.isEmpty(innerHTML)) {\n this.__replaceChildren(element, children, force);\n }\n }\n }\n\n /** @internal */\n _destroyElement(node: VNode, element: Element | DOMNativeNode) {\n if (element instanceof DOMNativeNode) {\n element.destroy();\n } else {\n const tracked_listener = this._tracked_elements.get(element)?.listener;\n for (const [key, listener] of _.entries(tracked_listener)) {\n const event = key.endsWith('Capture') ? key.slice(2, -7).toLowerCase() : key.slice(2).toLowerCase();\n if (_.isFunction(listener)) {\n element.removeEventListener(event, listener, { capture: key.endsWith('Capture') });\n }\n }\n }\n this._tracked_elements.delete(element);\n }\n\n __replaceChildren(element: Element, children: (string | Element | DOMNativeNode)[], force?: boolean) {\n const diff = myersSync(\n _.map(element.childNodes, x => x.nodeType === this.document.TEXT_NODE ? x.textContent ?? '' : x),\n _.flatMap(children, x => x instanceof DOMNativeNode ? x.target : x),\n { compare: (a, b) => a === b },\n );\n let i = 0;\n for (const { remove, insert, equivalent } of diff) {\n if (equivalent) {\n i += equivalent.length;\n } else if (remove) {\n for (const child of remove) {\n if (force || _.isString(child) || this._tracked_elements.has(child as any)) {\n element.removeChild(element.childNodes[i]);\n } else {\n i++;\n }\n }\n }\n if (insert) {\n for (const child of insert) {\n const node = _.isString(child) ? this.document.createTextNode(child) : child;\n element.insertBefore(node, element.childNodes[i++]);\n }\n }\n }\n }\n\n async renderToString(component: ComponentNode) {\n const root = this.createRoot();\n try {\n await root.mount(component, { skipMount: true });\n const elements = _.flatMap(_.castArray(root.root ?? []), x => x instanceof DOMNativeNode ? x.target : x);\n const str = _.map(elements, x => x.outerHTML).join('');\n return str.startsWith('<html>') ? `<!DOCTYPE html>${str}` : str;\n } finally {\n root.unmount();\n }\n }\n}\n"],"names":[],"mappings":";;;;AAGO,uBAAA,aAAA,SAAA,iBAAA;AACP,gCAAA,QAAA,YAAA,YAAA,KAAA,aAAA;AACA,2BAAA,OAAA,GAAA,OAAA;AACA,2BAAA,MAAA;AACA;AACA;AACA;AACA,iDAAA,OAAA,GAAA,aAAA;AACA;AACA;AACO,uBAAA,YAAA,SAAA,SAAA,CAAA,OAAA,GAAA,aAAA;AACP;AACA;AACA;AACA;AACA;AACA,wBAAA,MAAA,GAAA,SAAA;AACA,oBAAA,QAAA;AACA,kBAAA,MAAA,GAAA,SAAA;AACA;AACA;AACA,+BAAA,OAAA,sBAAA,OAAA,GAAA,aAAA;AACA,8BAAA,aAAA,GAAA,OAAA;AACA;;;;"}
@@ -1,6 +1,6 @@
1
- import { C as ComponentType, P as PropsWithChildren } from './common-lfYTb1eV.js';
1
+ import { C as ComponentType, P as PropsWithChildren } from './common-C5xm7xDw.js';
2
2
 
3
3
  declare const Fragment: ComponentType<PropsWithChildren<{}>>;
4
4
 
5
5
  export { Fragment as F };
6
- //# sourceMappingURL=fragment-CApRh6Hp.d.ts.map
6
+ //# sourceMappingURL=fragment-BQXp1_iv.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fragment-CApRh6Hp.d.ts","sources":["../../src/core/types/fragment.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 { ComponentType, PropsWithChildren } from './common';\n\nexport const Fragment: ComponentType<PropsWithChildren<{}>> = ({ children }) => {\n return children;\n}\n"],"names":[],"mappings":";;AACO,cAAA,QAAA,EAAA,aAAA,CAAA,iBAAA;;;;"}
1
+ {"version":3,"file":"fragment-BQXp1_iv.d.ts","sources":["../../src/core/types/fragment.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 { ComponentType, PropsWithChildren } from './common';\n\nexport const Fragment: ComponentType<PropsWithChildren<{}>> = ({ children }) => {\n return children;\n}\n"],"names":[],"mappings":";;AACO,cAAA,QAAA,EAAA,aAAA,CAAA,iBAAA;;;;"}
@@ -1,4 +1,4 @@
1
- import { N as NativeElementType, _ as _ElementType, b as PropsType, a as ComponentNode } from './common-lfYTb1eV.js';
1
+ import { N as NativeElementType, _ as _ElementType, c as PropsType, b as ComponentNode } from './common-C5xm7xDw.js';
2
2
 
3
3
  type VNodeState = {
4
4
  hook: string;
@@ -44,4 +44,4 @@ declare abstract class _Renderer<T> {
44
44
  }
45
45
 
46
46
  export { VNode as V, _Renderer as _ };
47
- //# sourceMappingURL=renderer-DBPR_8BN.d.ts.map
47
+ //# sourceMappingURL=renderer-D4aiCZGU.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderer-DBPR_8BN.d.ts","sources":["../../src/core/reconciler/vnode.ts","../../src/core/renderer.ts"],"sourcesContent":["//\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 async _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 self = this;\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) ? function (this: any, ...args: any[]) {\n const current = self._component.props[k];\n return _.isFunction(current) ? current.call(this, ...args) : v.call(this, ...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 let resolved;\n while (true) {\n resolved = 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 = resolved.state.state;\n if (_.isEmpty(resolved.state.tasks)) break;\n await Promise.all(resolved.state.tasks);\n }\n this._listens = new Map(options.contextValue.entries().filter(([k]) => resolved.state.listens.has(k)));\n children = this._resolve_children(resolved.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// 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 async _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 = async (elements?: Map<VNode, { native?: T }>) => {\n this._beforeUpdate();\n const map = new Map<VNode, { native?: T }>();\n for await (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 = await update();\n\n const listener = runtime.event.register('onchange', () => {\n if (render_count !== update_count++) return;\n nextick(async () => {\n while (render_count !== update_count) {\n if (destroyed) return;\n const current = update_count;\n elements = await update(elements);\n render_count = current;\n }\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: Awaited<ReturnType<typeof this._createRoot>> | undefined;\n return {\n get root() {\n return state?.root;\n },\n mount: async (\n component: ComponentNode,\n options?: {\n skipMount?: boolean;\n },\n ) => {\n state = await this._createRoot(root ?? null, component, options);\n },\n unmount: () => {\n state?.destroy();\n state = undefined;\n },\n };\n }\n}"],"names":[],"mappings":";;AAEO;AACP;AACA;AACA;AACA;AACA;AAMO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC5BO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;"}
1
+ {"version":3,"file":"renderer-D4aiCZGU.d.ts","sources":["../../src/core/reconciler/vnode.ts","../../src/core/renderer.ts"],"sourcesContent":["//\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 async _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 self = this;\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) ? function (this: any, ...args: any[]) {\n const current = self._component.props[k];\n return _.isFunction(current) ? current.call(this, ...args) : v.call(this, ...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 let resolved;\n while (true) {\n resolved = 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 = resolved.state.state;\n if (_.isEmpty(resolved.state.tasks)) break;\n await Promise.all(resolved.state.tasks);\n }\n this._listens = new Map(options.contextValue.entries().filter(([k]) => resolved.state.listens.has(k)));\n children = this._resolve_children(resolved.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// 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 async _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 = async (elements?: Map<VNode, { native?: T }>) => {\n this._beforeUpdate();\n const map = new Map<VNode, { native?: T }>();\n for await (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 = await update();\n\n const listener = runtime.event.register('onchange', () => {\n if (render_count !== update_count++) return;\n nextick(async () => {\n while (render_count !== update_count) {\n if (destroyed) return;\n const current = update_count;\n elements = await update(elements);\n render_count = current;\n }\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: Awaited<ReturnType<typeof this._createRoot>> | undefined;\n return {\n get root() {\n return state?.root;\n },\n mount: async (\n component: ComponentNode,\n options?: {\n skipMount?: boolean;\n },\n ) => {\n state = await this._createRoot(root ?? null, component, options);\n },\n unmount: () => {\n state?.destroy();\n state = undefined;\n },\n };\n }\n}"],"names":[],"mappings":";;AAEO;AACP;AACA;AACA;AACA;AACA;AAMO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC5BO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;"}
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { r as reconciler, V as VNode, e as equalDeps } from './state-BIFtc4bv.mjs';
2
+ import { r as reconciler, V as VNode, e as equalDeps } from './state-BRL-17Kd.mjs';
3
3
  import { N as NativeElementType } from './component-BzurKp_J.mjs';
4
4
  import nextick from 'nextick';
5
5
 
@@ -161,4 +161,4 @@ class _Renderer {
161
161
  }
162
162
 
163
163
  export { _Renderer as _ };
164
- //# sourceMappingURL=renderer-DnIxEcQv.mjs.map
164
+ //# sourceMappingURL=renderer-Dn64xymQ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderer-DnIxEcQv.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 async _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 = async (elements?: Map<VNode, { native?: T }>) => {\n this._beforeUpdate();\n const map = new Map<VNode, { native?: T }>();\n for await (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 = await update();\n\n const listener = runtime.event.register('onchange', () => {\n if (render_count !== update_count++) return;\n nextick(async () => {\n while (render_count !== update_count) {\n if (destroyed) return;\n const current = update_count;\n elements = await update(elements);\n render_count = current;\n }\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: Awaited<ReturnType<typeof this._createRoot>> | undefined;\n return {\n get root() {\n return state?.root;\n },\n mount: async (\n component: ComponentNode,\n options?: {\n skipMount?: boolean;\n },\n ) => {\n state = await this._createRoot(root ?? null, component, options);\n },\n unmount: () => {\n state?.dest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":["//\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 async _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 = async (elements?: Map<VNode, { native?: T }>) => {\n this._beforeUpdate();\n const map = new Map<VNode, { native?: T }>();\n for await (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 = await update();\n\n const listener = runtime.event.register('onchange', () => {\n if (render_count !== update_count++) return;\n nextick(async () => {\n while (render_count !== update_count) {\n if (destroyed) return;\n const current = update_count;\n elements = await update(elements);\n render_count = current;\n }\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: Awaited<ReturnType<typeof this._createRoot>> | undefined;\n return {\n get root() {\n return state?.root;\n },\n mount: async (\n component: ComponentNode,\n options?: {\n skipMount?: boolean;\n },\n ) => {\n state = await 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,MAAM,WAAW,CACvB,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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BAChB,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;gBAC9C;YACF,CAAC;SACF;IACH;AAEA,IAAA,UAAU,CAAC,IAAQ,EAAA;AACjB,QAAA,IAAI,KAA+D;QACnE,OAAO;AACL,YAAA,IAAI,IAAI,GAAA;gBACN,OAAO,KAAK,EAAE,IAAI;YACpB,CAAC;AACD,YAAA,KAAK,EAAE,OACL,SAAwB,EACxB,OAEC,KACC;AACF,gBAAA,KAAK,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC;YAClE,CAAC;YACD,OAAO,EAAE,MAAK;gBACZ,KAAK,EAAE,OAAO,EAAE;gBAChB,KAAK,GAAG,SAAS;YACnB,CAAC;SACF;IACH;AACD;;;;"}
@@ -543,5 +543,5 @@ const reconciler = new class {
543
543
  }
544
544
  };
545
545
 
546
- export { EventEmitter as E, PropsProvider as P, VNode as V, useContext as a, ErrorBoundary as b, createContext as c, equalDeps as e, mergeRefs as m, reconciler as r, uniqueId as u };
547
- //# sourceMappingURL=state-BIFtc4bv.mjs.map
546
+ 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 };
547
+ //# sourceMappingURL=state-BRL-17Kd.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"state-BIFtc4bv.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 async _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 self = this;\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) ? function (this: any, ...args: any[]) {\n const current = self._component.props[k];\n return _.isFunction(current) ? current.call(this, ...args) : v.call(this, ...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 let resolved;\n while (true) {\n resolved = 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 = resolved.state.state;\n if (_.isEmpty(resolved.state.tasks)) break;\n await Promise.all(resolved.state.tasks);\n }\n this._listens = new Map(options.contextValue.entries().filter(([k]) => resolved.state.listens.has(k)));\n children = this._resolve_children(resolved.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 tasks: PromiseLike<void>[] = [];\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 = async 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: await 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,CAAC,KAAK,CAAC,GAAG,QAAQ;AAC5D,IAAA,CAAC;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,IAAA,CAAC;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,CAAC,YAAkB,EAAA;AAC9C,IAAA,OAAO,cAAc,CAAC,YAAY,CAAC;AACrC;AAEA;;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C;AACtC,oBAAA,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE;AAC3B,wBAAA,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;wBACvB,KAAK,EAAE,IAAI,CAAC,cAAc;AAC1B,wBAAA,IAAI,EAAE,IAAI;AACX,qBAAA,CAAC;gBACJ;gBAEA,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;oBACJ;gBACF;YACF;AACF,QAAA,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE;IACtC;;;;;"}
1
+ {"version":3,"file":"state-BRL-17Kd.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 async _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 self = this;\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) ? function (this: any, ...args: any[]) {\n const current = self._component.props[k];\n return _.isFunction(current) ? current.call(this, ...args) : v.call(this, ...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 let resolved;\n while (true) {\n resolved = 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 = resolved.state.state;\n if (_.isEmpty(resolved.state.tasks)) break;\n await Promise.all(resolved.state.tasks);\n }\n this._listens = new Map(options.contextValue.entries().filter(([k]) => resolved.state.listens.has(k)));\n children = this._resolve_children(resolved.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 tasks: PromiseLike<void>[] = [];\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 = async 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: await 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,CAAC,KAAK,CAAC,GAAG,QAAQ;AAC5D,IAAA,CAAC;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,IAAA,CAAC;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,CAAC,YAAkB,EAAA;AAC9C,IAAA,OAAO,cAAc,CAAC,YAAY,CAAC;AACrC;AAEA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACI,MAAM,UAAU,GAAG,CACxB,OAAmB,E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B,wBAAA,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;wBACvB,KAAK,EAAE,IAAI,CAAC,cAAc;AAC1B,wBAAA,IAAI,EAAE,IAAI;AACX,qBAAA,CAAC;gBACJ;gBAEA,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;oBACJ;gBACF;YACF;AACF,QAAA,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE;IACtC;;;;;"}
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { e as equalDeps, r as reconciler } from './state-BIFtc4bv.mjs';
2
+ import { e as equalDeps, r as reconciler } from './state-BRL-17Kd.mjs';
3
3
 
4
4
  //
5
5
  // index.ts
@@ -288,5 +288,5 @@ const useSyncExternalStore = (subscribe, getSnapshot, getServerSnapshot) => {
288
288
  return getSnapshot();
289
289
  };
290
290
 
291
- export { _useEffect as _, useMemo as a, useCallback as b, useEffect as c, _useMemo as d, useSyncExternalStore as u };
292
- //# sourceMappingURL=sync-2I_UkBG9.mjs.map
291
+ export { _useEffect as _, _useMemo as a, useMemo as b, useEffect as c, useSyncExternalStore as d, useCallback as u };
292
+ //# sourceMappingURL=sync-BlGknxx_.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"sync-2I_UkBG9.mjs","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 */\n\nexport function useCallback<T extends (...args: any) => any>(\n callback: T,\n deps?: any\n): T;\n\nexport function useCallback<T extends ((...args: any) => any) | _.Falsey>(\n callback: T,\n deps?: any\n): T;\n\nexport function useCallback<T extends ((...args: any) => any) | _.Falsey>(\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: function (this: any, ...args: any) {\n if (store.current) return store.current.call(this, ...args);\n },\n };\n return store;\n }, null);\n if (callback) store.current = callback;\n return callback && (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":[],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA,MAAM,aAAa,GAAG,CAAC,IAAY,KAAI;AACrC,IAAA,MAAM,KAAK,GAAG,UAAU,CAAC,gBAAgB;AACzC,IAAA,IAAI,CAAC,K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,IAAI;AACF,YAAA,MAAM,UAAU,GAAG,SAAS,CAAC,QAAQ,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,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;oBAC9C;oBAAE,OAAO,CAAC,EAAE;AACV,wBAAA,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;oBAClB;gBACF,CAAC,GAAG;AACN,YAAA,CAAC;QACH;QAAE,OAAO,CAAC,EAAE;AACV,YAAA,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AAChB,YAAA,OAAO,MAAM,KAAK,CAAC,KAAK,EAAE;QAC5B;IACF,CAAC,EAAE,IAAI,CAAC;IACR,IAAI,iBAAiB,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE;QAC/C,OAAO,iBAAiB,EAAE;IAC5B;IACA,OAAO,WAAW,EAAE;AACtB;;;;"}
1
+ {"version":3,"file":"sync-BlGknxx_.mjs","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 */\n\nexport function useCallback<T extends (...args: any) => any>(\n callback: T,\n deps?: any\n): T;\n\nexport function useCallback<T extends ((...args: any) => any) | _.Falsey>(\n callback: T,\n deps?: any\n): T;\n\nexport function useCallback<T extends ((...args: any) => any) | _.Falsey>(\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: function (this: any, ...args: any) {\n if (store.current) return store.current.call(this, ...args);\n },\n };\n return store;\n }, null);\n if (callback) store.current = callback;\n return callback && (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":[],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA,MAAM,aAAa,GAAG,CAAC,IAAY,KAAI;AACrC,IAAA,MAAM,KAAK,GAAG,UAAU,CAAC,gBAAgB;AACzC,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,MAAM,KAAK,CAAC,CAAA,EAAG,IAAI,CAAA,uCAAA,CAAyC,CAAC;IACzE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK;AAC5C,IAAA,IAAI,SAAS,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,KAAK,IAAI,EAAE;QAC1D,OAAO,CAAC,IAAI,CAAC;AACX,YAAA,CAAA,MAAA,EAAS,IAAI,CAAA,0BAAA,CAA4B;YACzC,yEAAyE;YACzE;AACD,SAAA,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACd;AACA,IAAA,OAAO,KAAK;AACd,CAAC;AAEM,MAAM,UAAU,GAAG,CACxB,IAAY,EACZ,MAA+D,EAC/D,IAAU,KACR;AACF,IAAA,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAA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