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 CHANGED
@@ -1,9 +1,10 @@
1
- import { _ as _DOMRenderer } from './internals/common-D44KuOmi.js';
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
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var common = require('./internals/common-CRYEvU6P.js');
3
+ var common = require('./internals/common-Q9Xz4i4m.js');
4
4
  require('lodash');
5
5
  require('myers.js');
6
6
  require('./internals/component-BiP3XIPe.js');
package/dist/dom.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as _DOMRenderer } from './internals/common-BoxPKJqo.mjs';
1
+ import { _ as _DOMRenderer } from './internals/common-Dz0g-ZKV.mjs';
2
2
  import 'lodash';
3
3
  import 'myers.js';
4
4
  import './internals/component-BzurKp_J.mjs';
@@ -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 _doc?;
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(doc?: Document);
23
- get doc(): Document;
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-D44KuOmi.d.ts.map
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
- _doc;
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(doc) {
3902
+ constructor(window) {
3903
3903
  super();
3904
- this._doc = doc;
3904
+ this._window = window;
3905
3905
  }
3906
- get doc() {
3907
- return this._doc ?? document;
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.doc.head, this._tracked_head_children);
3924
+ this.__replaceChildren(this.document.head, this._tracked_head_children);
3922
3925
  }
3923
3926
  }
3924
3927
  else {
3925
- const styleElem = this.doc.querySelector('style[data-frosty-style]') ?? this.doc.createElementNS(HTML_NS, 'style');
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.doc.head, [...this._tracked_head_children, styleElem]);
3932
+ this.__replaceChildren(this.document.head, [...this._tracked_head_children, styleElem]);
3930
3933
  }
3931
- else if (styleElem.parentNode !== this.doc.head) {
3932
- this.doc.head.appendChild(styleElem);
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.doc, 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.doc.documentElement;
3949
- case 'head': return this.doc.head ?? this.doc.createElementNS(HTML_NS, 'head');
3950
- case 'body': return this.doc.body ?? this.doc.createElementNS(HTML_NS, 'body');
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.doc.createElementNS(ns, type) : this.doc.createElement(type);
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.doc.TEXT_NODE ? x.textContent ?? '' : x), _.map(children, x => x instanceof DOMNativeNode ? x.target : x), { compare: (a, b) => a === b });
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.doc.createTextNode(child) : child;
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-BoxPKJqo.mjs.map
4135
+ //# sourceMappingURL=common-Dz0g-ZKV.mjs.map