frosty 0.0.117 → 0.0.119
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_native.d.mts +3 -3
- package/dist/_native.d.ts +3 -3
- package/dist/_native.js +2 -2
- package/dist/_native.mjs +2 -2
- package/dist/dom.d.mts +3 -3
- package/dist/dom.d.ts +3 -3
- package/dist/dom.js +3 -3
- package/dist/dom.mjs +3 -3
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/index.mjs +4 -4
- package/dist/internals/{common-CpEB3ieX.d.mts → common-bhZ4PXrN.d.mts} +2 -2
- package/dist/internals/{common-CpEB3ieX.d.mts.map → common-bhZ4PXrN.d.mts.map} +1 -1
- package/dist/internals/{common-CpEB3ieX.d.ts → common-bhZ4PXrN.d.ts} +2 -2
- package/dist/internals/{common-CpEB3ieX.d.ts.map → common-bhZ4PXrN.d.ts.map} +1 -1
- package/dist/internals/{fragment-Dch7YNeZ.d.ts → fragment-BTtOyGrt.d.ts} +2 -2
- package/dist/internals/{fragment-Dch7YNeZ.d.ts.map → fragment-BTtOyGrt.d.ts.map} +1 -1
- package/dist/internals/{fragment-BlS4iF_x.d.mts → fragment-S8Jiu3HG.d.mts} +2 -2
- package/dist/internals/{fragment-BlS4iF_x.d.mts.map → fragment-S8Jiu3HG.d.mts.map} +1 -1
- package/dist/internals/{renderer-D5Ti33Dm.d.mts → renderer-Bb9ZwNV9.d.mts} +2 -2
- package/dist/internals/{renderer-D5Ti33Dm.d.mts.map → renderer-Bb9ZwNV9.d.mts.map} +1 -1
- package/dist/internals/{renderer-Bm-PTZwX.js → renderer-BcmA1sBF.js} +4 -4
- package/dist/internals/renderer-BcmA1sBF.js.map +1 -0
- package/dist/internals/{renderer-BGklQuhL.d.ts → renderer-CNDFwfGu.d.ts} +3 -3
- package/dist/internals/{renderer-BGklQuhL.d.ts.map → renderer-CNDFwfGu.d.ts.map} +1 -1
- package/dist/internals/{renderer-oGiv2WIb.mjs → renderer-D7YbtgQX.mjs} +2 -2
- package/dist/internals/{renderer-oGiv2WIb.mjs.map → renderer-D7YbtgQX.mjs.map} +1 -1
- package/dist/internals/{renderer-BCXo_tVK.js → renderer-DK5OzE35.js} +2 -2
- package/dist/internals/{renderer-BCXo_tVK.js.map → renderer-DK5OzE35.js.map} +1 -1
- package/dist/internals/{renderer-Be-LIw4p.mjs → renderer-DYNo5VgP.mjs} +4 -4
- package/dist/internals/renderer-DYNo5VgP.mjs.map +1 -0
- package/dist/internals/{renderer-_DLTEPZN.d.ts → renderer-dZplPv2-.d.ts} +2 -2
- package/dist/internals/{renderer-_DLTEPZN.d.ts.map → renderer-dZplPv2-.d.ts.map} +1 -1
- package/dist/internals/{renderer-DRuOiuKj.d.mts → renderer-j_b3mDma.d.mts} +3 -3
- package/dist/internals/{renderer-DRuOiuKj.d.mts.map → renderer-j_b3mDma.d.mts.map} +1 -1
- package/dist/internals/{state-C9_fGuhZ.js → state-BcId1rQb.js} +20 -4
- package/dist/internals/state-BcId1rQb.js.map +1 -0
- package/dist/internals/{state-k40d_k34.mjs → state-DQ2OKak8.mjs} +20 -4
- package/dist/internals/state-DQ2OKak8.mjs.map +1 -0
- package/dist/internals/{sync-DRp6Vg-9.mjs → sync-UIYH-wdf.mjs} +2 -2
- package/dist/internals/{sync-DRp6Vg-9.mjs.map → sync-UIYH-wdf.mjs.map} +1 -1
- package/dist/internals/{sync-D4YtyMaB.js → sync-bgrX6wfp.js} +2 -2
- package/dist/internals/{sync-D4YtyMaB.js.map → sync-bgrX6wfp.js.map} +1 -1
- package/dist/internals/{utils-B79j-cNE.d.ts → utils-BPbhSCHS.d.ts} +2 -2
- package/dist/internals/{utils-B79j-cNE.d.ts.map → utils-BPbhSCHS.d.ts.map} +1 -1
- package/dist/internals/{utils-CWsh4Zpu.d.mts → utils-CPic5-1I.d.mts} +2 -2
- package/dist/internals/{utils-CWsh4Zpu.d.mts.map → utils-CPic5-1I.d.mts.map} +1 -1
- package/dist/jsx-dev-runtime.d.mts +2 -2
- package/dist/jsx-dev-runtime.d.ts +2 -2
- package/dist/jsx-runtime.d.mts +2 -2
- package/dist/jsx-runtime.d.ts +2 -2
- package/dist/server-dom.d.mts +3 -3
- package/dist/server-dom.d.ts +3 -3
- package/dist/server-dom.js +3 -3
- package/dist/server-dom.mjs +3 -3
- package/dist/web.d.mts +3 -3
- package/dist/web.d.ts +3 -3
- package/dist/web.js +4 -4
- package/dist/web.mjs +5 -5
- package/package.json +2 -2
- package/dist/internals/renderer-Be-LIw4p.mjs.map +0 -1
- package/dist/internals/renderer-Bm-PTZwX.js.map +0 -1
- package/dist/internals/state-C9_fGuhZ.js.map +0 -1
- package/dist/internals/state-k40d_k34.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ComponentType, P as PropsWithChildren } from './common-
|
|
1
|
+
import { a as ComponentType, P as PropsWithChildren } from './common-bhZ4PXrN.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* A component that renders its children without adding extra nodes to the DOM.
|
|
@@ -6,4 +6,4 @@ import { a as ComponentType, P as PropsWithChildren } from './common-CpEB3ieX.js
|
|
|
6
6
|
declare const Fragment: ComponentType<PropsWithChildren<{}>>;
|
|
7
7
|
|
|
8
8
|
export { Fragment as F };
|
|
9
|
-
//# sourceMappingURL=fragment-
|
|
9
|
+
//# sourceMappingURL=fragment-BTtOyGrt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fragment-
|
|
1
|
+
{"version":3,"file":"fragment-BTtOyGrt.d.ts","sources":["../../src/core/components/fragment.ts"],"sourcesContent":["//\n// fragment.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 '../types/common';\n\n/**\n * A component that renders its children without adding extra nodes to the DOM.\n */\nexport const Fragment: ComponentType<PropsWithChildren<{}>> = ({ children }) => {\n return children;\n}\n"],"names":[],"mappings":";;AACA;AACA;AACA;AACO,cAAA,QAAA,EAAA,aAAA,CAAA,iBAAA;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ComponentType, P as PropsWithChildren } from './common-
|
|
1
|
+
import { a as ComponentType, P as PropsWithChildren } from './common-bhZ4PXrN.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* A component that renders its children without adding extra nodes to the DOM.
|
|
@@ -6,4 +6,4 @@ import { a as ComponentType, P as PropsWithChildren } from './common-CpEB3ieX.mj
|
|
|
6
6
|
declare const Fragment: ComponentType<PropsWithChildren<{}>>;
|
|
7
7
|
|
|
8
8
|
export { Fragment as F };
|
|
9
|
-
//# sourceMappingURL=fragment-
|
|
9
|
+
//# sourceMappingURL=fragment-S8Jiu3HG.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fragment-
|
|
1
|
+
{"version":3,"file":"fragment-S8Jiu3HG.d.mts","sources":["../../src/core/components/fragment.ts"],"sourcesContent":["//\n// fragment.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 '../types/common';\n\n/**\n * A component that renders its children without adding extra nodes to the DOM.\n */\nexport const Fragment: ComponentType<PropsWithChildren<{}>> = ({ children }) => {\n return children;\n}\n"],"names":[],"mappings":";;AACA;AACA;AACA;AACO,cAAA,QAAA,EAAA,aAAA,CAAA,iBAAA;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { N as NativeElementType, _ as _ElementType, c as PropsType, C as ComponentNode } from './common-
|
|
1
|
+
import { N as NativeElementType, _ as _ElementType, c as PropsType, C as ComponentNode } from './common-bhZ4PXrN.mjs';
|
|
2
2
|
|
|
3
3
|
type VNodeState = {
|
|
4
4
|
hook: string;
|
|
@@ -45,4 +45,4 @@ declare abstract class _Renderer<T> {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export { VNode as V, _Renderer as _ };
|
|
48
|
-
//# sourceMappingURL=renderer-
|
|
48
|
+
//# sourceMappingURL=renderer-Bb9ZwNV9.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer-D5Ti33Dm.d.mts","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, equalProps } 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 const {\n resolved: rendered,\n error,\n state,\n } = reconciler.withHookState({\n renderer: options.renderer,\n node: this,\n state: this._state,\n stack: options.stack,\n contextValue: options.contextValue,\n }, () => type(props));\n this._state = state.state;\n if (_.isEmpty(state.tasks)) {\n if (error) throw error;\n resolved = { rendered, state };\n break;\n }\n await Promise.all(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 (!equalProps(item._component.props, children[i]._component.props)) 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';\nimport { _ParentComponent } from './components/pairs';\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, children: (T | string)[], stack: VNode[], force?: boolean): void;\n\n protected abstract _destroyElement(node: VNode, element: T): void;\n\n abstract get _server(): boolean;\n\n private _renderStorage = new Map<any, any>();\n\n get renderStorage() {\n return this._renderStorage;\n }\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 resolveChildren = (node: VNode, elements: Map<VNode, { native?: T }>) => {\n const childrenOfParent = (node: VNode, allowedChild: (node: string | VNode) => boolean): (string | T)[] => _.flatMap(node.children, x => {\n if (_.isString(x)) return allowedChild(x) ? x : [];\n const _node = elements.get(x)?.native;\n if (allowedChild(x)) return _node ?? children(x);\n return _node ? [] : childrenOfParent(x, allowedChild);\n });\n const children = (node: VNode): (string | T)[] => _.flatMap(node.children, x => {\n if (_.isString(x)) return x;\n const _node = elements.get(x)?.native;\n if (_node instanceof _ParentComponent) return childrenOfParent(x, c => _node.isChildNode(c));\n return _node ?? children(x);\n });\n return children(node);\n };\n\n const commit = (elements: Map<VNode, { native?: T }>, updated: Set<VNode>, force?: boolean) => {\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 instanceof _ParentComponent) return;\n if (element && updated.has(node)) {\n try {\n this._updateElement(node, element, resolveChildren(node, elements), stack, force);\n } catch (e) {\n console.error(e);\n }\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) {\n try {\n unmount();\n } catch (e) {\n console.error(e);\n }\n }\n state.push({\n hook: curState[i].hook,\n deps: curState[i].deps,\n unmount: options?.skipMount || !changed ? prevState[i]?.unmount : (() => {\n try {\n return curState[i].mount?.();\n } catch (e) {\n console.error(e);\n }\n })(),\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) {\n try {\n unmount?.();\n } catch (e) {\n console.error(e);\n }\n }\n mountState.delete(node);\n }\n if (root) this._updateElement(\n runtime.node, root,\n _.castArray(elements.get(runtime.node)?.native ?? resolveChildren(runtime.node, elements)),\n [],\n force,\n );\n _mount(runtime.node, [runtime.node]);\n };\n\n const update = async (elements?: Map<VNode, { native?: T }>, force?: boolean) => {\n this._renderStorage = new Map<any, any>();\n try {\n this._beforeUpdate();\n } catch (e) {\n console.error(e);\n }\n const map = new Map<VNode, { native?: T }>();\n const updatedNodes = new Set<VNode>();\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 } else if (_.isFunction(node.type) && node.type.prototype instanceof _ParentComponent) {\n let elem = elements?.get(node)?.native;\n if (!elem) {\n const Component = node.type as any;\n elem = new Component();\n }\n map.set(node, { native: elem });\n } else {\n const elem = elements?.get(node)?.native;\n if (!elem || updated) updatedNodes.add(node);\n try {\n map.set(node, { native: elem ?? this._createElement(node, stack) });\n } catch (e) {\n console.error(e);\n }\n }\n }\n commit(map, updatedNodes, force);\n if (elements) {\n for (const [node, element] of elements) {\n if (map.has(node) || !element.native) continue;\n try {\n this._destroyElement(node, element.native);\n } catch (e) {\n console.error(e);\n }\n }\n }\n try {\n this._afterUpdate();\n } catch (e) {\n console.error(e);\n }\n return map;\n };\n\n let update_count = 0;\n let render_count = 0;\n let destroyed = false;\n let elements = await update(undefined, true);\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, false);\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 ?? resolveChildren(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._updateElement(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;AACA;;"}
|
|
1
|
+
{"version":3,"file":"renderer-Bb9ZwNV9.d.mts","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, equalProps } 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 const {\n resolved: rendered,\n error,\n state,\n } = reconciler.withHookState({\n renderer: options.renderer,\n node: this,\n state: this._state,\n stack: options.stack,\n contextValue: options.contextValue,\n }, () => type(props));\n this._state = state.state;\n if (_.isEmpty(state.tasks)) {\n if (error) throw error;\n resolved = { rendered, state };\n break;\n }\n await Promise.all(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 (!equalProps(item._component.props, children[i]._component.props)) 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';\nimport { _ParentComponent } from './components/pairs';\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, children: (T | string)[], stack: VNode[], force?: boolean): void;\n\n protected abstract _destroyElement(node: VNode, element: T): void;\n\n abstract get _server(): boolean;\n\n private _renderStorage = new Map<any, any>();\n\n get renderStorage() {\n return this._renderStorage;\n }\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 resolveChildren = (node: VNode, elements: Map<VNode, { native?: T }>) => {\n const childrenOfParent = (node: VNode, allowedChild: (node: string | VNode) => boolean): (string | T)[] => _.flatMap(node.children, x => {\n if (_.isString(x)) return allowedChild(x) ? x : [];\n const _node = elements.get(x)?.native;\n if (allowedChild(x)) return _node ?? children(x);\n return _node ? [] : childrenOfParent(x, allowedChild);\n });\n const children = (node: VNode): (string | T)[] => _.flatMap(node.children, x => {\n if (_.isString(x)) return x;\n const _node = elements.get(x)?.native;\n if (_node instanceof _ParentComponent) return childrenOfParent(x, c => _node.isChildNode(c));\n return _node ?? children(x);\n });\n return children(node);\n };\n\n const commit = (elements: Map<VNode, { native?: T }>, updated: Set<VNode>, force?: boolean) => {\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 instanceof _ParentComponent) return;\n if (element && updated.has(node)) {\n try {\n this._updateElement(node, element, resolveChildren(node, elements), stack, force);\n } catch (e) {\n console.error(e);\n }\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) {\n try {\n unmount();\n } catch (e) {\n console.error(e);\n }\n }\n state.push({\n hook: curState[i].hook,\n deps: curState[i].deps,\n unmount: options?.skipMount || !changed ? prevState[i]?.unmount : (() => {\n try {\n return curState[i].mount?.();\n } catch (e) {\n console.error(e);\n }\n })(),\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) {\n try {\n unmount?.();\n } catch (e) {\n console.error(e);\n }\n }\n mountState.delete(node);\n }\n if (root) this._updateElement(\n runtime.node, root,\n _.castArray(elements.get(runtime.node)?.native ?? resolveChildren(runtime.node, elements)),\n [],\n force,\n );\n _mount(runtime.node, [runtime.node]);\n };\n\n const update = async (elements?: Map<VNode, { native?: T }>, force?: boolean) => {\n this._renderStorage = new Map<any, any>();\n try {\n this._beforeUpdate();\n } catch (e) {\n console.error(e);\n }\n const map = new Map<VNode, { native?: T }>();\n const updatedNodes = new Set<VNode>();\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 } else if (_.isFunction(node.type) && node.type.prototype instanceof _ParentComponent) {\n let elem = elements?.get(node)?.native;\n if (!elem) {\n const Component = node.type as any;\n elem = new Component();\n }\n map.set(node, { native: elem });\n } else {\n const elem = elements?.get(node)?.native;\n if (!elem || updated) updatedNodes.add(node);\n try {\n map.set(node, { native: elem ?? this._createElement(node, stack) });\n } catch (e) {\n console.error(e);\n }\n }\n }\n commit(map, updatedNodes, force);\n if (elements) {\n for (const [node, element] of elements) {\n if (map.has(node) || !element.native) continue;\n try {\n this._destroyElement(node, element.native);\n } catch (e) {\n console.error(e);\n }\n }\n }\n try {\n this._afterUpdate();\n } catch (e) {\n console.error(e);\n }\n return map;\n };\n\n let update_count = 0;\n let render_count = 0;\n let destroyed = false;\n let elements = await update(undefined, true);\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, false);\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 ?? resolveChildren(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._updateElement(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;AACA;;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var _ = require('lodash');
|
|
4
|
-
var renderer = require('./renderer-
|
|
4
|
+
var renderer = require('./renderer-DK5OzE35.js');
|
|
5
5
|
var postcss = require('postcss');
|
|
6
6
|
var postcssJs = require('postcss-js');
|
|
7
7
|
var nested = require('postcss-nested');
|
|
8
|
-
var state = require('./state-
|
|
8
|
+
var state = require('./state-BcId1rQb.js');
|
|
9
9
|
var myers_js = require('myers.js');
|
|
10
10
|
var runtime = require('./runtime-57ivQprw.js');
|
|
11
11
|
|
|
@@ -3625,7 +3625,7 @@ class StyleBuilder {
|
|
|
3625
3625
|
const animationName = keyframes ? `__a_${state.uniqueId()}` : undefined;
|
|
3626
3626
|
const _style = {
|
|
3627
3627
|
[`.${name}`]: {
|
|
3628
|
-
...
|
|
3628
|
+
...style,
|
|
3629
3629
|
...animationName ? { animationName } : {},
|
|
3630
3630
|
},
|
|
3631
3631
|
...animationName ? {
|
|
@@ -4390,4 +4390,4 @@ class _DOMRenderer extends renderer._Renderer {
|
|
|
4390
4390
|
|
|
4391
4391
|
exports.DOMNativeNode = DOMNativeNode;
|
|
4392
4392
|
exports._DOMRenderer = _DOMRenderer;
|
|
4393
|
-
//# sourceMappingURL=renderer-
|
|
4393
|
+
//# sourceMappingURL=renderer-BcmA1sBF.js.map
|