frosty 0.0.93 → 0.0.95
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/dom.d.ts +1 -1
- package/dist/dom.js +3 -3
- package/dist/dom.js.map +1 -1
- package/dist/dom.mjs +2 -2
- package/dist/internals/{common-jmXMOod4.d.ts → renderer-Blzqzjhg.d.ts} +10 -3
- package/dist/internals/renderer-Blzqzjhg.d.ts.map +1 -0
- package/dist/internals/{common-BbURUhvO.js → renderer-CXenrlwR.js} +411 -377
- package/dist/internals/renderer-CXenrlwR.js.map +1 -0
- package/dist/internals/{common-D932m3CD.mjs → renderer-mmUwu_Ch.mjs} +411 -377
- package/dist/internals/renderer-mmUwu_Ch.mjs.map +1 -0
- package/dist/server-dom.d.ts +1 -1
- package/dist/server-dom.js +3 -3
- package/dist/server-dom.js.map +1 -1
- package/dist/server-dom.mjs +2 -2
- package/dist/web.d.ts +1 -1
- package/dist/web.js +8 -8
- package/dist/web.js.map +1 -1
- package/dist/web.mjs +5 -5
- package/package.json +1 -1
- package/dist/internals/common-BbURUhvO.js.map +0 -1
- package/dist/internals/common-D932m3CD.mjs.map +0 -1
- package/dist/internals/common-jmXMOod4.d.ts.map +0 -1
package/dist/dom.d.ts
CHANGED
package/dist/dom.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var renderer = require('./internals/renderer-CXenrlwR.js');
|
|
4
4
|
require('lodash');
|
|
5
5
|
require('myers.js');
|
|
6
|
-
require('./internals/component-BiP3XIPe.js');
|
|
7
6
|
require('./internals/renderer-CdsGzt2W.js');
|
|
8
7
|
require('./internals/state-CdizLCyu.js');
|
|
8
|
+
require('./internals/component-BiP3XIPe.js');
|
|
9
9
|
require('nextick');
|
|
10
10
|
require('postcss');
|
|
11
11
|
require('postcss-js');
|
|
@@ -36,7 +36,7 @@ require('autoprefixer');
|
|
|
36
36
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
37
37
|
// THE SOFTWARE.
|
|
38
38
|
//
|
|
39
|
-
class DOMRenderer extends
|
|
39
|
+
class DOMRenderer extends renderer._DOMRenderer {
|
|
40
40
|
static default = new DOMRenderer(window);
|
|
41
41
|
static createRoot(root) {
|
|
42
42
|
return this.default.createRoot(root);
|
package/dist/dom.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.js","sources":["../../src/renderer/dom.ts"],"sourcesContent":["//\n// dom.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 { _DOMRenderer } from './common';\n\nexport class DOMRenderer extends _DOMRenderer {\n\n static default = new DOMRenderer(window);\n\n static createRoot(root: Element): ReturnType<typeof DOMRenderer.default.createRoot> {\n return this.default.createRoot(root);\n }\n\n /** @internal */\n get _server(): boolean {\n return false;\n }\n}\n"],"names":["_DOMRenderer"],"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;AAKM,MAAO,WAAY,SAAQA,
|
|
1
|
+
{"version":3,"file":"dom.js","sources":["../../src/renderer/dom.ts"],"sourcesContent":["//\n// dom.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 { _DOMRenderer } from './common';\n\nexport class DOMRenderer extends _DOMRenderer {\n\n static default = new DOMRenderer(window);\n\n static createRoot(root: Element): ReturnType<typeof DOMRenderer.default.createRoot> {\n return this.default.createRoot(root);\n }\n\n /** @internal */\n get _server(): boolean {\n return false;\n }\n}\n"],"names":["_DOMRenderer"],"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;AAKM,MAAO,WAAY,SAAQA,qBAAY,CAAA;IAE3C,OAAO,OAAO,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC;IAExC,OAAO,UAAU,CAAC,IAAa,EAAA;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC;IACtC;;AAGA,IAAA,IAAI,OAAO,GAAA;AACT,QAAA,OAAO,KAAK;IACd;;;;;"}
|
package/dist/dom.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { _ as _DOMRenderer } from './internals/
|
|
1
|
+
import { _ as _DOMRenderer } from './internals/renderer-mmUwu_Ch.mjs';
|
|
2
2
|
import 'lodash';
|
|
3
3
|
import 'myers.js';
|
|
4
|
-
import './internals/component-BzurKp_J.mjs';
|
|
5
4
|
import './internals/renderer-C3Lq-xHV.mjs';
|
|
6
5
|
import './internals/state-BRL-17Kd.mjs';
|
|
6
|
+
import './internals/component-BzurKp_J.mjs';
|
|
7
7
|
import 'nextick';
|
|
8
8
|
import 'postcss';
|
|
9
9
|
import 'postcss-js';
|
|
@@ -3,6 +3,14 @@ import { _ as _Renderer } from './renderer-D4aiCZGU.js';
|
|
|
3
3
|
import { DOMWindow } from 'jsdom';
|
|
4
4
|
|
|
5
5
|
declare abstract class DOMNativeNode extends NativeElementType {
|
|
6
|
+
static get Utils(): {
|
|
7
|
+
update(element: Element, { className, style, ...props }: Record<string, any> & {
|
|
8
|
+
className?: string;
|
|
9
|
+
style?: string;
|
|
10
|
+
}): void;
|
|
11
|
+
replaceChildren(element: Element, children: (string | Element | DOMNativeNode)[], shouldRemove?: (child: ChildNode) => boolean): void;
|
|
12
|
+
destroyElement(element: Element): void;
|
|
13
|
+
};
|
|
6
14
|
static createElement: (doc: Document, renderer: _DOMRenderer) => DOMNativeNode;
|
|
7
15
|
abstract get target(): Element | Element[];
|
|
8
16
|
abstract update(props: Record<string, any> & {
|
|
@@ -12,6 +20,7 @@ declare abstract class DOMNativeNode extends NativeElementType {
|
|
|
12
20
|
abstract replaceChildren(children: (string | Element | DOMNativeNode)[]): void;
|
|
13
21
|
abstract destroy(): void;
|
|
14
22
|
}
|
|
23
|
+
|
|
15
24
|
declare abstract class _DOMRenderer extends _Renderer<Element | DOMNativeNode> {
|
|
16
25
|
private _window;
|
|
17
26
|
private _namespace_map;
|
|
@@ -22,10 +31,8 @@ declare abstract class _DOMRenderer extends _Renderer<Element | DOMNativeNode> {
|
|
|
22
31
|
get document(): Document;
|
|
23
32
|
get window(): Window | DOMWindow;
|
|
24
33
|
private __createBuiltClassName;
|
|
25
|
-
private __updateEventListener;
|
|
26
|
-
__replaceChildren(element: Element, children: (string | Element | DOMNativeNode)[], force?: boolean): void;
|
|
27
34
|
renderToString(component: ComponentNode): Promise<string>;
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
export { DOMNativeNode as D, _DOMRenderer as _ };
|
|
31
|
-
//# sourceMappingURL=
|
|
38
|
+
//# sourceMappingURL=renderer-Blzqzjhg.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer-Blzqzjhg.d.ts","sources":["../../src/renderer/common/node.ts","../../src/renderer/common/renderer.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 type { _DOMRenderer } from './renderer';\nimport { myersSync } from 'myers.js';\nimport { globalEvents } from '../../core/web/event';\nimport { NativeElementType } from '../../core/types/component';\nimport { svgProps, htmlProps } from '../../../generated/elements';\nimport { _propValue } from '../../core/web/props';\nimport { _Renderer } from '../../core/renderer';\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\nconst tracked_listeners = new WeakMap<Element, Record<string, EventListener | undefined>>();\nconst _updateEventListener = (\n element: Element,\n key: string,\n listener: EventListener | undefined,\n) => {\n const event = key.endsWith('Capture') ? key.slice(2, -7).toLowerCase() : key.slice(2).toLowerCase();\n const listeners = tracked_listeners.get(element) ?? {};\n if (!tracked_listeners.has(element)) tracked_listeners.set(element, listeners);\n if (listeners[key] !== listener) {\n const options = { capture: key.endsWith('Capture') };\n if (_.isFunction(listeners[key])) element.removeEventListener(event, listeners[key], options);\n if (_.isFunction(listener)) element.addEventListener(event, listener, options);\n }\n listeners[key] = listener;\n}\n\nconst DOMUtils = new class {\n\n update(\n element: Element,\n { className, style, ...props }: Record<string, any> & {\n className?: string;\n style?: string;\n },\n ) {\n if (className) {\n if (element.className !== className)\n element.className = className;\n } else if (!_.isNil(element.getAttribute('class'))) {\n element.removeAttribute('class');\n }\n if (style) {\n const oldValue = element.getAttribute('style');\n if (oldValue !== style)\n element.setAttribute('style', style);\n } else if (!_.isNil(element.getAttribute('style'))) {\n element.removeAttribute('style');\n }\n for (const [key, value] of _.entries(props)) {\n if (_.includes(globalEvents, key)) {\n _updateEventListener(element, key, value);\n } else if (key.endsWith('Capture') && _.includes(globalEvents, key.slice(0, -7))) {\n _updateEventListener(element, 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 tagName = _.toLower(element.tagName);\n const { type: _type, attr } = (htmlProps as any)['*'][key]\n ?? (htmlProps as any)[tagName]?.[key]\n ?? (svgProps as any)['*'][key]\n ?? (svgProps as any)[tagName]?.[key]\n ?? {};\n const writeable = isWriteable(element, key);\n if (writeable && !_.isNil(value)) {\n if ((element as any)[key] !== value) (element as any)[key] = value;\n } else if (_type && attr && (_propValue as any)[_type]) {\n const oldValue = element.getAttribute(attr);\n if (value === false || _.isNil(value)) {\n if (!_.isNil(oldValue))\n element.removeAttribute(attr);\n } else {\n const newValue = value === true ? '' : `${value}`;\n if (oldValue !== newValue)\n element.setAttribute(attr, newValue);\n }\n } else if (writeable) {\n if ((element as any)[key] !== value) (element as any)[key] = value;\n }\n }\n }\n }\n\n replaceChildren(\n element: Element,\n children: (string | Element | DOMNativeNode)[],\n shouldRemove: (child: ChildNode) => boolean = () => true,\n ) {\n const document = element.ownerDocument;\n const diff = myersSync(\n _.map(element.childNodes, x => x.nodeType === 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 (_.isString(child) || shouldRemove(child)) {\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) ? document.createTextNode(child) : child;\n element.insertBefore(node, element.childNodes[i++]);\n }\n }\n }\n }\n\n destroyElement(element: Element) {\n const listeners = tracked_listeners.get(element);\n for (const [key, listener] of _.entries(listeners)) {\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 tracked_listeners.delete(element);\n }\n}\n\nexport abstract class DOMNativeNode extends NativeElementType {\n\n static get Utils() { return DOMUtils; }\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","//\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 '../../core/reconciler/vnode';\nimport { ComponentNode } from '../../core/types/component';\nimport { 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';\nimport { compress } from '../minify/compress';\nimport { DOMNativeNode } from './node';\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\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 /** @internal */\n _tracked_server_resource = new Map<string, string>();\n private _tracked_elements = new Map<Element | DOMNativeNode, { props: string[]; className: string[]; }>();\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 this._tracked_server_resource = new Map<string, string>();\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 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 const ssrData = this._tracked_server_resource.size ? this.document.createElementNS(HTML_NS, 'script') : undefined;\n if (ssrData) {\n ssrData.setAttribute('data-frosty-ssr-data', '');\n ssrData.setAttribute('type', 'text/plain');\n ssrData.innerHTML = compress(JSON.stringify(Object.fromEntries(this._tracked_server_resource)));\n }\n DOMNativeNode.Utils.replaceChildren(head, _.compact([\n ...this._tracked_head_children,\n styleElem.textContent && styleElem,\n ssrData,\n ]), (x) => this._tracked_elements.has(x as any));\n } else if (styleElem.parentNode !== head && styleElem.textContent) {\n head.appendChild(styleElem);\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 });\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 });\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 /** @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 tracked = this._tracked_elements.get(element);\n if (!tracked) return;\n const removed = _.difference(tracked.props, _.keys(_props));\n tracked.props = _.keys(_props);\n\n const builtClassName = this.__createBuiltClassName(element, className, style);\n if (!_.isEmpty(innerHTML) && element.innerHTML !== innerHTML) element.innerHTML = innerHTML;\n\n DOMNativeNode.Utils.update(element, {\n className: builtClassName,\n style: inlineStyle ? processCss(inlineStyle).css : undefined,\n ..._props,\n ..._.fromPairs(_.map(removed, x => [x, undefined])),\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 DOMNativeNode.Utils.replaceChildren(element, children, (x) => !!force || this._tracked_elements.has(x as any));\n }\n }\n }\n\n /** @internal */\n _destroyElement(node: VNode, element: Element | DOMNativeNode) {\n if (element instanceof DOMNativeNode) {\n element.destroy();\n } else {\n DOMNativeNode.Utils.destroyElement(element);\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":";;;;AAEO,uBAAA,aAAA,SAAA,iBAAA;AACP;AACA,wBAAA,OAAA,kCAAA,MAAA;AACA;AACA;AACA;AACA,iCAAA,OAAA,sBAAA,OAAA,GAAA,aAAA,4BAAA,SAAA;AACA,gCAAA,OAAA;AACA;AACA,gCAAA,QAAA,YAAA,YAAA,KAAA,aAAA;AACA,2BAAA,OAAA,GAAA,OAAA;AACA,2BAAA,MAAA;AACA;AACA;AACA;AACA,iDAAA,OAAA,GAAA,aAAA;AACA;AACA;;ACfO,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,8BAAA,aAAA,GAAA,OAAA;AACA;;;;"}
|