frosty 0.0.37 → 0.0.39
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 +2 -1
- package/dist/dom.js +1 -1
- package/dist/dom.mjs +1 -1
- package/dist/internals/{common-D44KuOmi.d.ts → common-Dgt9gkTj.d.ts} +6 -4
- package/dist/internals/common-Dgt9gkTj.d.ts.map +1 -0
- package/dist/internals/{common-BoxPKJqo.mjs → common-Dz0g-ZKV.mjs} +21 -18
- package/dist/internals/{common-BoxPKJqo.mjs.map → common-Dz0g-ZKV.mjs.map} +1 -1
- package/dist/internals/{common-CRYEvU6P.js → common-Q9Xz4i4m.js} +21 -18
- package/dist/internals/{common-CRYEvU6P.js.map → common-Q9Xz4i4m.js.map} +1 -1
- package/dist/server-dom.d.ts +1 -1
- package/dist/server-dom.js +2 -2
- package/dist/server-dom.js.map +1 -1
- package/dist/server-dom.mjs +2 -2
- package/dist/server-dom.mjs.map +1 -1
- package/dist/web.d.ts +6 -4
- package/dist/web.js +56 -42
- package/dist/web.js.map +1 -1
- package/dist/web.mjs +57 -44
- package/dist/web.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/internals/common-D44KuOmi.d.ts.map +0 -1
package/dist/dom.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { _ as _DOMRenderer } from './internals/common-
|
|
1
|
+
import { _ as _DOMRenderer } from './internals/common-Dgt9gkTj.js';
|
|
2
2
|
import './internals/common-CUIKizze.js';
|
|
3
3
|
import '@o2ter/utils-js';
|
|
4
4
|
import 'lodash';
|
|
5
5
|
import 'csstype';
|
|
6
6
|
import './internals/renderer-DPoACdip.js';
|
|
7
|
+
import 'jsdom';
|
|
7
8
|
|
|
8
9
|
declare class DOMRenderer extends _DOMRenderer {
|
|
9
10
|
static default: DOMRenderer;
|
package/dist/dom.js
CHANGED
package/dist/dom.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { N as NativeElementType, b as ComponentNode } from './common-CUIKizze.js';
|
|
2
2
|
import { _ as _Renderer } from './renderer-DPoACdip.js';
|
|
3
|
+
import { DOMWindow } from 'jsdom';
|
|
3
4
|
|
|
4
5
|
declare abstract class DOMNativeNode extends NativeElementType {
|
|
5
6
|
static createElement: (doc: Document, renderer: _DOMRenderer) => DOMNativeNode;
|
|
@@ -12,15 +13,16 @@ declare abstract class DOMNativeNode extends NativeElementType {
|
|
|
12
13
|
abstract destroy(): void;
|
|
13
14
|
}
|
|
14
15
|
declare abstract class _DOMRenderer extends _Renderer<Element | DOMNativeNode> {
|
|
15
|
-
private
|
|
16
|
+
private _window?;
|
|
16
17
|
private _namespace_map;
|
|
17
18
|
private _tracked_props;
|
|
18
19
|
private _tracked_listener;
|
|
19
20
|
private _tracked_head_children;
|
|
20
21
|
private _tracked_style;
|
|
21
22
|
private _tracked_style_names;
|
|
22
|
-
constructor(
|
|
23
|
-
get
|
|
23
|
+
constructor(window?: Window | DOMWindow);
|
|
24
|
+
get document(): Document;
|
|
25
|
+
get window(): Window | DOMWindow;
|
|
24
26
|
private __createBuiltClassName;
|
|
25
27
|
private __updateEventListener;
|
|
26
28
|
__replaceChildren(element: Element, children: (string | Element | DOMNativeNode)[]): void;
|
|
@@ -28,4 +30,4 @@ declare abstract class _DOMRenderer extends _Renderer<Element | DOMNativeNode> {
|
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
export { DOMNativeNode as D, _DOMRenderer as _ };
|
|
31
|
-
//# sourceMappingURL=common-
|
|
33
|
+
//# sourceMappingURL=common-Dgt9gkTj.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common-Dgt9gkTj.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -3892,19 +3892,22 @@ class DOMNativeNode extends NativeElementType {
|
|
|
3892
3892
|
static createElement;
|
|
3893
3893
|
}
|
|
3894
3894
|
class _DOMRenderer extends _Renderer {
|
|
3895
|
-
|
|
3895
|
+
_window;
|
|
3896
3896
|
_namespace_map = new WeakMap();
|
|
3897
3897
|
_tracked_props = new WeakMap();
|
|
3898
3898
|
_tracked_listener = new WeakMap();
|
|
3899
3899
|
_tracked_head_children = [];
|
|
3900
3900
|
_tracked_style = new StyleBuilder();
|
|
3901
3901
|
_tracked_style_names = [];
|
|
3902
|
-
constructor(
|
|
3902
|
+
constructor(window) {
|
|
3903
3903
|
super();
|
|
3904
|
-
this.
|
|
3904
|
+
this._window = window;
|
|
3905
3905
|
}
|
|
3906
|
-
get
|
|
3907
|
-
return this.
|
|
3906
|
+
get document() {
|
|
3907
|
+
return this.window.document;
|
|
3908
|
+
}
|
|
3909
|
+
get window() {
|
|
3910
|
+
return this._window ?? window;
|
|
3908
3911
|
}
|
|
3909
3912
|
/** @internal */
|
|
3910
3913
|
_beforeUpdate() {
|
|
@@ -3918,18 +3921,18 @@ class _DOMRenderer extends _Renderer {
|
|
|
3918
3921
|
this._tracked_style.select(this._tracked_style_names);
|
|
3919
3922
|
if (this._tracked_style.isEmpty) {
|
|
3920
3923
|
if (this._server) {
|
|
3921
|
-
this.__replaceChildren(this.
|
|
3924
|
+
this.__replaceChildren(this.document.head, this._tracked_head_children);
|
|
3922
3925
|
}
|
|
3923
3926
|
}
|
|
3924
3927
|
else {
|
|
3925
|
-
const styleElem = this.
|
|
3928
|
+
const styleElem = this.document.querySelector('style[data-frosty-style]') ?? this.document.createElementNS(HTML_NS, 'style');
|
|
3926
3929
|
styleElem.setAttribute('data-frosty-style', '');
|
|
3927
3930
|
styleElem.textContent = this._tracked_style.css;
|
|
3928
3931
|
if (this._server) {
|
|
3929
|
-
this.__replaceChildren(this.
|
|
3932
|
+
this.__replaceChildren(this.document.head, [...this._tracked_head_children, styleElem]);
|
|
3930
3933
|
}
|
|
3931
|
-
else if (styleElem.parentNode !== this.
|
|
3932
|
-
this.
|
|
3934
|
+
else if (styleElem.parentNode !== this.document.head) {
|
|
3935
|
+
this.document.head.appendChild(styleElem);
|
|
3933
3936
|
}
|
|
3934
3937
|
}
|
|
3935
3938
|
}
|
|
@@ -3938,16 +3941,16 @@ class _DOMRenderer extends _Renderer {
|
|
|
3938
3941
|
const { type } = node;
|
|
3939
3942
|
if (!_.isString(type) && type.prototype instanceof DOMNativeNode) {
|
|
3940
3943
|
const ElementType = type;
|
|
3941
|
-
const elem = ElementType.createElement(this.
|
|
3944
|
+
const elem = ElementType.createElement(this.document, this);
|
|
3942
3945
|
this._updateElement(node, elem, stack);
|
|
3943
3946
|
return elem;
|
|
3944
3947
|
}
|
|
3945
3948
|
if (!_.isString(type))
|
|
3946
3949
|
throw Error('Invalid type');
|
|
3947
3950
|
switch (type) {
|
|
3948
|
-
case 'html': return this.
|
|
3949
|
-
case 'head': return this.
|
|
3950
|
-
case 'body': return this.
|
|
3951
|
+
case 'html': return this.document.documentElement;
|
|
3952
|
+
case 'head': return this.document.head ?? this.document.createElementNS(HTML_NS, 'head');
|
|
3953
|
+
case 'body': return this.document.body ?? this.document.createElementNS(HTML_NS, 'body');
|
|
3951
3954
|
}
|
|
3952
3955
|
const _ns_list = _.compact([
|
|
3953
3956
|
_.includes(tags.svg, type) && SVG_NS,
|
|
@@ -3956,7 +3959,7 @@ class _DOMRenderer extends _Renderer {
|
|
|
3956
3959
|
]);
|
|
3957
3960
|
const parent = _.last(stack);
|
|
3958
3961
|
const ns = _ns_list.length > 1 ? parent && _.first(_.intersection([this._namespace_map.get(parent)], _ns_list)) : _.first(_ns_list);
|
|
3959
|
-
const elem = ns ? this.
|
|
3962
|
+
const elem = ns ? this.document.createElementNS(ns, type) : this.document.createElement(type);
|
|
3960
3963
|
this._namespace_map.set(node, ns);
|
|
3961
3964
|
this._updateElement(node, elem, stack);
|
|
3962
3965
|
return elem;
|
|
@@ -4096,7 +4099,7 @@ class _DOMRenderer extends _Renderer {
|
|
|
4096
4099
|
}
|
|
4097
4100
|
}
|
|
4098
4101
|
__replaceChildren(element, children) {
|
|
4099
|
-
const diff = myersSync(_.map(element.childNodes, x => x.nodeType === this.
|
|
4102
|
+
const diff = myersSync(_.map(element.childNodes, x => x.nodeType === this.document.TEXT_NODE ? x.textContent ?? '' : x), _.map(children, x => x instanceof DOMNativeNode ? x.target : x), { compare: (a, b) => a === b });
|
|
4100
4103
|
let i = 0;
|
|
4101
4104
|
for (const { remove, insert, equivalent } of diff) {
|
|
4102
4105
|
if (equivalent) {
|
|
@@ -4109,7 +4112,7 @@ class _DOMRenderer extends _Renderer {
|
|
|
4109
4112
|
}
|
|
4110
4113
|
if (insert) {
|
|
4111
4114
|
for (const child of insert) {
|
|
4112
|
-
const node = _.isString(child) ? this.
|
|
4115
|
+
const node = _.isString(child) ? this.document.createTextNode(child) : child;
|
|
4113
4116
|
element.insertBefore(node, element.childNodes[i++]);
|
|
4114
4117
|
}
|
|
4115
4118
|
}
|
|
@@ -4129,4 +4132,4 @@ class _DOMRenderer extends _Renderer {
|
|
|
4129
4132
|
}
|
|
4130
4133
|
|
|
4131
4134
|
export { DOMNativeNode as D, _DOMRenderer as _ };
|
|
4132
|
-
//# sourceMappingURL=common-
|
|
4135
|
+
//# sourceMappingURL=common-Dz0g-ZKV.mjs.map
|