frosty 0.0.92 → 0.0.94

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.
@@ -1,137 +1,12 @@
1
1
  import _ from 'lodash';
2
- import { myersSync } from 'myers.js';
3
- import { N as NativeElementType } from './component-BzurKp_J.mjs';
4
2
  import { _ as _Renderer } from './renderer-C3Lq-xHV.mjs';
5
3
  import postcss from 'postcss';
6
4
  import { parse } from 'postcss-js';
7
5
  import nested from 'postcss-nested';
8
6
  import autoprefixer from 'autoprefixer';
9
7
  import { a as uniqueId, m as mergeRefs } from './state-BRL-17Kd.mjs';
10
-
11
- //
12
- // event.ts
13
- //
14
- // The MIT License
15
- // Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
16
- //
17
- // Permission is hereby granted, free of charge, to any person obtaining a copy
18
- // of this software and associated documentation files (the "Software"), to deal
19
- // in the Software without restriction, including without limitation the rights
20
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21
- // copies of the Software, and to permit persons to whom the Software is
22
- // furnished to do so, subject to the following conditions:
23
- //
24
- // The above copyright notice and this permission notice shall be included in
25
- // all copies or substantial portions of the Software.
26
- //
27
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
33
- // THE SOFTWARE.
34
- //
35
- const globalEvents = [
36
- // Clipboard Events
37
- "onCopy",
38
- "onCut",
39
- "onPaste",
40
- // Composition Events
41
- "onCompositionEnd",
42
- "onCompositionStart",
43
- "onCompositionUpdate",
44
- // Focus Events
45
- "onFocus",
46
- "onBlur",
47
- // Form Events
48
- "onFormData",
49
- "onChange",
50
- "onBeforeInput",
51
- "onInput",
52
- "onReset",
53
- "onSubmit",
54
- "onInvalid",
55
- // Image Events
56
- "onLoad",
57
- "onError",
58
- // Keyboard Events
59
- "onKeyDown",
60
- /** @deprecated */
61
- "onKeyPress",
62
- /** @deprecated */
63
- "onKeyUp",
64
- // Media Events
65
- "onAbort",
66
- "onCanPlay",
67
- "onCanPlayThrough",
68
- "onDurationChange",
69
- "onEmptied",
70
- "onEncrypted",
71
- "onEnded",
72
- "onLoadedData",
73
- "onLoadedMetadata",
74
- "onLoadStart",
75
- "onPause",
76
- "onPlay",
77
- "onPlaying",
78
- "onProgress",
79
- "onRateChange",
80
- "onResize",
81
- "onSeeked",
82
- "onSeeking",
83
- "onStalled",
84
- "onSuspend",
85
- "onTimeUpdate",
86
- "onVolumeChange",
87
- "onWaiting",
88
- // MouseEvents
89
- "onAuxClick",
90
- "onClick",
91
- "onContextMenu",
92
- "onDoubleClick",
93
- "onDrag",
94
- "onDragEnd",
95
- "onDragEnter",
96
- "onDragExit",
97
- "onDragLeave",
98
- "onDragOver",
99
- "onDragStart",
100
- "onDrop",
101
- "onMouseDown",
102
- "onMouseEnter",
103
- "onMouseLeave",
104
- "onMouseMove",
105
- "onMouseOut",
106
- "onMouseOver",
107
- "onMouseUp",
108
- // Selection Events
109
- "onSelect",
110
- // Touch Events
111
- "onTouchCancel",
112
- "onTouchEnd",
113
- "onTouchMove",
114
- "onTouchStart",
115
- // Pointer Events
116
- "onPointerDown",
117
- "onPointerMove",
118
- "onPointerUp",
119
- "onPointerCancel",
120
- "onPointerEnter",
121
- "onPointerLeave",
122
- "onPointerOver",
123
- "onPointerOut",
124
- // UI Events
125
- "onScroll",
126
- // Wheel Events
127
- "onWheel",
128
- // Animation Events
129
- "onAnimationStart",
130
- "onAnimationEnd",
131
- "onAnimationIteration",
132
- // Transition Events
133
- "onTransitionEnd",
134
- ];
8
+ import { myersSync } from 'myers.js';
9
+ import { N as NativeElementType } from './component-BzurKp_J.mjs';
135
10
 
136
11
  const svgProps = {
137
12
  "*": {
@@ -3672,57 +3547,6 @@ const tags = {
3672
3547
  ]
3673
3548
  };
3674
3549
 
3675
- //
3676
- // props.ts
3677
- //
3678
- // The MIT License
3679
- // Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
3680
- //
3681
- // Permission is hereby granted, free of charge, to any person obtaining a copy
3682
- // of this software and associated documentation files (the "Software"), to deal
3683
- // in the Software without restriction, including without limitation the rights
3684
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3685
- // copies of the Software, and to permit persons to whom the Software is
3686
- // furnished to do so, subject to the following conditions:
3687
- //
3688
- // The above copyright notice and this permission notice shall be included in
3689
- // all copies or substantial portions of the Software.
3690
- //
3691
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3692
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3693
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3694
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3695
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3696
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3697
- // THE SOFTWARE.
3698
- //
3699
- const _propValue = {
3700
- 'DOMString': 'string',
3701
- 'SVGAnimatedTransformList': 'string',
3702
- 'SVGStringList': 'string',
3703
- 'SVGAnimatedRect': 'string',
3704
- 'SVGAnimatedPreserveAspectRatio': 'string',
3705
- 'SVGAnimatedString': 'string',
3706
- 'SVGPointList': 'string',
3707
- 'SVGAnimatedLengthList': 'string',
3708
- 'SVGAnimatedNumberList': 'string',
3709
- 'SVGAnimatedEnumeration': 'string',
3710
- 'USVString': 'string',
3711
- 'DOMTokenList': 'string',
3712
- 'TrustedHTML': 'string',
3713
- 'HTMLFormElement': 'string',
3714
- 'HTMLDataListElement': 'string',
3715
- 'SVGAnimatedLength': 'length',
3716
- 'SVGAnimatedNumber': 'number',
3717
- 'SVGAnimatedInteger': 'number',
3718
- 'unrestricted double': 'number',
3719
- 'double': 'number',
3720
- 'unsigned long': 'number',
3721
- 'long': 'number',
3722
- 'SVGAnimatedBoolean': 'boolean',
3723
- 'boolean': 'boolean',
3724
- };
3725
-
3726
3550
  //
3727
3551
  // process.ts
3728
3552
  //
@@ -3930,7 +3754,7 @@ const altAlpha = ":;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwx
3930
3754
  const compress = (r) => _compress(r, 6, r => altAlpha.charAt(r));
3931
3755
 
3932
3756
  //
3933
- // common.ts
3757
+ // event.ts
3934
3758
  //
3935
3759
  // The MIT License
3936
3760
  // Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
@@ -3953,82 +3777,406 @@ const compress = (r) => _compress(r, 6, r => altAlpha.charAt(r));
3953
3777
  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3954
3778
  // THE SOFTWARE.
3955
3779
  //
3956
- const SVG_NS = 'http://www.w3.org/2000/svg';
3957
- const HTML_NS = 'http://www.w3.org/1999/xhtml';
3958
- const MATHML_NS = 'http://www.w3.org/1998/Math/MathML';
3959
- const findPrototypeProperty = (object, propertyName) => {
3960
- while (object && object.constructor && object.constructor.name !== 'Object') {
3961
- let desc = Object.getOwnPropertyDescriptor(object, propertyName);
3962
- if (desc)
3963
- return desc;
3964
- object = Object.getPrototypeOf(object);
3965
- }
3966
- return null;
3967
- };
3968
- const isWriteable = (object, propertyName) => {
3969
- let desc = findPrototypeProperty(object, propertyName);
3970
- if (!desc) {
3971
- return false;
3972
- }
3973
- if (desc.writable && typeof desc.value !== 'function') {
3974
- return true;
3975
- }
3976
- return !!desc.set;
3977
- };
3978
- class DOMNativeNode extends NativeElementType {
3979
- static createElement;
3980
- }
3981
- class _DOMRenderer extends _Renderer {
3982
- _window;
3983
- _namespace_map = new WeakMap();
3984
- _tracked_head_children = [];
3985
- _tracked_style = new StyleBuilder();
3986
- /** @internal */
3987
- _tracked_server_resource = new Map();
3988
- _tracked_elements = new Map();
3989
- constructor(window) {
3990
- super();
3991
- this._window = window;
3992
- }
3993
- get document() {
3994
- return this.window.document;
3995
- }
3996
- get window() {
3997
- return this._window;
3998
- }
3999
- /** @internal */
4000
- _beforeUpdate() {
4001
- if (this._server) {
4002
- this._tracked_head_children = [];
4003
- this._tracked_server_resource = new Map();
4004
- }
4005
- }
4006
- /** @internal */
4007
- _afterUpdate() {
4008
- this._tracked_style.select([...this._tracked_elements.values().flatMap(({ className }) => className)]);
4009
- const head = this.document.head ?? this.document.createElementNS(HTML_NS, 'head');
4010
- const styleElem = this.document.querySelector('style[data-frosty-style]') ?? this.document.createElementNS(HTML_NS, 'style');
4011
- styleElem.setAttribute('data-frosty-style', '');
4012
- if (styleElem.textContent !== this._tracked_style.css)
4013
- styleElem.textContent = this._tracked_style.css;
4014
- if (this._server) {
4015
- const ssrData = this._tracked_server_resource.size ? this.document.createElementNS(HTML_NS, 'script') : undefined;
4016
- if (ssrData) {
4017
- ssrData.setAttribute('data-frosty-ssr-data', '');
4018
- ssrData.setAttribute('type', 'text/plain');
4019
- ssrData.innerHTML = compress(JSON.stringify(Object.fromEntries(this._tracked_server_resource)));
4020
- }
4021
- this.__replaceChildren(head, _.compact([...this._tracked_head_children, styleElem, ssrData]));
4022
- }
4023
- else if (styleElem.parentNode !== head) {
4024
- head.appendChild(styleElem);
4025
- }
4026
- if (!this.document.head) {
4027
- this.document.documentElement.insertBefore(head, this.document.body);
4028
- }
4029
- }
4030
- /** @internal */
4031
- _createElement(node, stack) {
3780
+ const globalEvents = [
3781
+ // Clipboard Events
3782
+ "onCopy",
3783
+ "onCut",
3784
+ "onPaste",
3785
+ // Composition Events
3786
+ "onCompositionEnd",
3787
+ "onCompositionStart",
3788
+ "onCompositionUpdate",
3789
+ // Focus Events
3790
+ "onFocus",
3791
+ "onBlur",
3792
+ // Form Events
3793
+ "onFormData",
3794
+ "onChange",
3795
+ "onBeforeInput",
3796
+ "onInput",
3797
+ "onReset",
3798
+ "onSubmit",
3799
+ "onInvalid",
3800
+ // Image Events
3801
+ "onLoad",
3802
+ "onError",
3803
+ // Keyboard Events
3804
+ "onKeyDown",
3805
+ /** @deprecated */
3806
+ "onKeyPress",
3807
+ /** @deprecated */
3808
+ "onKeyUp",
3809
+ // Media Events
3810
+ "onAbort",
3811
+ "onCanPlay",
3812
+ "onCanPlayThrough",
3813
+ "onDurationChange",
3814
+ "onEmptied",
3815
+ "onEncrypted",
3816
+ "onEnded",
3817
+ "onLoadedData",
3818
+ "onLoadedMetadata",
3819
+ "onLoadStart",
3820
+ "onPause",
3821
+ "onPlay",
3822
+ "onPlaying",
3823
+ "onProgress",
3824
+ "onRateChange",
3825
+ "onResize",
3826
+ "onSeeked",
3827
+ "onSeeking",
3828
+ "onStalled",
3829
+ "onSuspend",
3830
+ "onTimeUpdate",
3831
+ "onVolumeChange",
3832
+ "onWaiting",
3833
+ // MouseEvents
3834
+ "onAuxClick",
3835
+ "onClick",
3836
+ "onContextMenu",
3837
+ "onDoubleClick",
3838
+ "onDrag",
3839
+ "onDragEnd",
3840
+ "onDragEnter",
3841
+ "onDragExit",
3842
+ "onDragLeave",
3843
+ "onDragOver",
3844
+ "onDragStart",
3845
+ "onDrop",
3846
+ "onMouseDown",
3847
+ "onMouseEnter",
3848
+ "onMouseLeave",
3849
+ "onMouseMove",
3850
+ "onMouseOut",
3851
+ "onMouseOver",
3852
+ "onMouseUp",
3853
+ // Selection Events
3854
+ "onSelect",
3855
+ // Touch Events
3856
+ "onTouchCancel",
3857
+ "onTouchEnd",
3858
+ "onTouchMove",
3859
+ "onTouchStart",
3860
+ // Pointer Events
3861
+ "onPointerDown",
3862
+ "onPointerMove",
3863
+ "onPointerUp",
3864
+ "onPointerCancel",
3865
+ "onPointerEnter",
3866
+ "onPointerLeave",
3867
+ "onPointerOver",
3868
+ "onPointerOut",
3869
+ // UI Events
3870
+ "onScroll",
3871
+ // Wheel Events
3872
+ "onWheel",
3873
+ // Animation Events
3874
+ "onAnimationStart",
3875
+ "onAnimationEnd",
3876
+ "onAnimationIteration",
3877
+ // Transition Events
3878
+ "onTransitionEnd",
3879
+ ];
3880
+
3881
+ //
3882
+ // props.ts
3883
+ //
3884
+ // The MIT License
3885
+ // Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
3886
+ //
3887
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
3888
+ // of this software and associated documentation files (the "Software"), to deal
3889
+ // in the Software without restriction, including without limitation the rights
3890
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3891
+ // copies of the Software, and to permit persons to whom the Software is
3892
+ // furnished to do so, subject to the following conditions:
3893
+ //
3894
+ // The above copyright notice and this permission notice shall be included in
3895
+ // all copies or substantial portions of the Software.
3896
+ //
3897
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3898
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3899
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3900
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3901
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3902
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3903
+ // THE SOFTWARE.
3904
+ //
3905
+ const _propValue = {
3906
+ 'DOMString': 'string',
3907
+ 'SVGAnimatedTransformList': 'string',
3908
+ 'SVGStringList': 'string',
3909
+ 'SVGAnimatedRect': 'string',
3910
+ 'SVGAnimatedPreserveAspectRatio': 'string',
3911
+ 'SVGAnimatedString': 'string',
3912
+ 'SVGPointList': 'string',
3913
+ 'SVGAnimatedLengthList': 'string',
3914
+ 'SVGAnimatedNumberList': 'string',
3915
+ 'SVGAnimatedEnumeration': 'string',
3916
+ 'USVString': 'string',
3917
+ 'DOMTokenList': 'string',
3918
+ 'TrustedHTML': 'string',
3919
+ 'HTMLFormElement': 'string',
3920
+ 'HTMLDataListElement': 'string',
3921
+ 'SVGAnimatedLength': 'length',
3922
+ 'SVGAnimatedNumber': 'number',
3923
+ 'SVGAnimatedInteger': 'number',
3924
+ 'unrestricted double': 'number',
3925
+ 'double': 'number',
3926
+ 'unsigned long': 'number',
3927
+ 'long': 'number',
3928
+ 'SVGAnimatedBoolean': 'boolean',
3929
+ 'boolean': 'boolean',
3930
+ };
3931
+
3932
+ //
3933
+ // common.ts
3934
+ //
3935
+ // The MIT License
3936
+ // Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
3937
+ //
3938
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
3939
+ // of this software and associated documentation files (the "Software"), to deal
3940
+ // in the Software without restriction, including without limitation the rights
3941
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3942
+ // copies of the Software, and to permit persons to whom the Software is
3943
+ // furnished to do so, subject to the following conditions:
3944
+ //
3945
+ // The above copyright notice and this permission notice shall be included in
3946
+ // all copies or substantial portions of the Software.
3947
+ //
3948
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3949
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3950
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3951
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3952
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3953
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3954
+ // THE SOFTWARE.
3955
+ //
3956
+ const findPrototypeProperty = (object, propertyName) => {
3957
+ while (object && object.constructor && object.constructor.name !== 'Object') {
3958
+ let desc = Object.getOwnPropertyDescriptor(object, propertyName);
3959
+ if (desc)
3960
+ return desc;
3961
+ object = Object.getPrototypeOf(object);
3962
+ }
3963
+ return null;
3964
+ };
3965
+ const isWriteable = (object, propertyName) => {
3966
+ let desc = findPrototypeProperty(object, propertyName);
3967
+ if (!desc) {
3968
+ return false;
3969
+ }
3970
+ if (desc.writable && typeof desc.value !== 'function') {
3971
+ return true;
3972
+ }
3973
+ return !!desc.set;
3974
+ };
3975
+ const tracked_listeners = new WeakMap();
3976
+ const _updateEventListener = (element, key, listener) => {
3977
+ const event = key.endsWith('Capture') ? key.slice(2, -7).toLowerCase() : key.slice(2).toLowerCase();
3978
+ const listeners = tracked_listeners.get(element) ?? {};
3979
+ if (!tracked_listeners.has(element))
3980
+ tracked_listeners.set(element, listeners);
3981
+ if (listeners[key] !== listener) {
3982
+ const options = { capture: key.endsWith('Capture') };
3983
+ if (_.isFunction(listeners[key]))
3984
+ element.removeEventListener(event, listeners[key], options);
3985
+ if (_.isFunction(listener))
3986
+ element.addEventListener(event, listener, options);
3987
+ }
3988
+ listeners[key] = listener;
3989
+ };
3990
+ const DOMUtils = new class {
3991
+ update(element, { className, style, ...props }) {
3992
+ if (className) {
3993
+ if (element.className !== className)
3994
+ element.className = className;
3995
+ }
3996
+ else if (!_.isNil(element.getAttribute('class'))) {
3997
+ element.removeAttribute('class');
3998
+ }
3999
+ if (style) {
4000
+ const oldValue = element.getAttribute('style');
4001
+ if (oldValue !== style)
4002
+ element.setAttribute('style', style);
4003
+ }
4004
+ else if (!_.isNil(element.getAttribute('style'))) {
4005
+ element.removeAttribute('style');
4006
+ }
4007
+ for (const [key, value] of _.entries(props)) {
4008
+ if (_.includes(globalEvents, key)) {
4009
+ _updateEventListener(element, key, value);
4010
+ }
4011
+ else if (key.endsWith('Capture') && _.includes(globalEvents, key.slice(0, -7))) {
4012
+ _updateEventListener(element, key, value);
4013
+ }
4014
+ else if (key.startsWith('data-')) {
4015
+ const oldValue = element.getAttribute(key);
4016
+ if (value === false || _.isNil(value)) {
4017
+ if (!_.isNil(oldValue))
4018
+ element.removeAttribute(key);
4019
+ }
4020
+ else {
4021
+ const newValue = value === true ? '' : `${value}`;
4022
+ if (oldValue !== newValue)
4023
+ element.setAttribute(key, newValue);
4024
+ }
4025
+ }
4026
+ else {
4027
+ const { type: _type, attr } = htmlProps['*'][key]
4028
+ ?? htmlProps[element.tagName]?.[key]
4029
+ ?? svgProps['*'][key]
4030
+ ?? svgProps[element.tagName]?.[key]
4031
+ ?? {};
4032
+ const writeable = isWriteable(element, key);
4033
+ if (writeable && !_.isNil(value)) {
4034
+ if (element[key] !== value)
4035
+ element[key] = value;
4036
+ }
4037
+ else if (_type && attr && _propValue[_type]) {
4038
+ const oldValue = element.getAttribute(key);
4039
+ if (value === false || _.isNil(value)) {
4040
+ if (!_.isNil(oldValue))
4041
+ element.removeAttribute(key);
4042
+ }
4043
+ else {
4044
+ const newValue = value === true ? '' : `${value}`;
4045
+ if (oldValue !== newValue)
4046
+ element.setAttribute(key, newValue);
4047
+ }
4048
+ }
4049
+ else if (writeable) {
4050
+ if (element[key] !== value)
4051
+ element[key] = value;
4052
+ }
4053
+ }
4054
+ }
4055
+ }
4056
+ replaceChildren(element, children, shouldRemove = () => true) {
4057
+ const document = element.ownerDocument;
4058
+ const diff = myersSync(_.map(element.childNodes, x => x.nodeType === document.TEXT_NODE ? x.textContent ?? '' : x), _.flatMap(children, x => x instanceof DOMNativeNode ? x.target : x), { compare: (a, b) => a === b });
4059
+ let i = 0;
4060
+ for (const { remove, insert, equivalent } of diff) {
4061
+ if (equivalent) {
4062
+ i += equivalent.length;
4063
+ }
4064
+ else if (remove) {
4065
+ for (const child of remove) {
4066
+ if (_.isString(child) || shouldRemove(child)) {
4067
+ element.removeChild(element.childNodes[i]);
4068
+ }
4069
+ else {
4070
+ i++;
4071
+ }
4072
+ }
4073
+ }
4074
+ if (insert) {
4075
+ for (const child of insert) {
4076
+ const node = _.isString(child) ? document.createTextNode(child) : child;
4077
+ element.insertBefore(node, element.childNodes[i++]);
4078
+ }
4079
+ }
4080
+ }
4081
+ }
4082
+ destroyElement(element) {
4083
+ const listeners = tracked_listeners.get(element);
4084
+ for (const [key, listener] of _.entries(listeners)) {
4085
+ const event = key.endsWith('Capture') ? key.slice(2, -7).toLowerCase() : key.slice(2).toLowerCase();
4086
+ if (_.isFunction(listener)) {
4087
+ element.removeEventListener(event, listener, { capture: key.endsWith('Capture') });
4088
+ }
4089
+ }
4090
+ tracked_listeners.delete(element);
4091
+ }
4092
+ };
4093
+ class DOMNativeNode extends NativeElementType {
4094
+ static get Utils() { return DOMUtils; }
4095
+ static createElement;
4096
+ }
4097
+
4098
+ //
4099
+ // renderer.ts
4100
+ //
4101
+ // The MIT License
4102
+ // Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
4103
+ //
4104
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4105
+ // of this software and associated documentation files (the "Software"), to deal
4106
+ // in the Software without restriction, including without limitation the rights
4107
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4108
+ // copies of the Software, and to permit persons to whom the Software is
4109
+ // furnished to do so, subject to the following conditions:
4110
+ //
4111
+ // The above copyright notice and this permission notice shall be included in
4112
+ // all copies or substantial portions of the Software.
4113
+ //
4114
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4115
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4116
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4117
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4118
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4119
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
4120
+ // THE SOFTWARE.
4121
+ //
4122
+ const SVG_NS = 'http://www.w3.org/2000/svg';
4123
+ const HTML_NS = 'http://www.w3.org/1999/xhtml';
4124
+ const MATHML_NS = 'http://www.w3.org/1998/Math/MathML';
4125
+ class _DOMRenderer extends _Renderer {
4126
+ _window;
4127
+ _namespace_map = new WeakMap();
4128
+ _tracked_head_children = [];
4129
+ _tracked_style = new StyleBuilder();
4130
+ /** @internal */
4131
+ _tracked_server_resource = new Map();
4132
+ _tracked_elements = new Map();
4133
+ constructor(window) {
4134
+ super();
4135
+ this._window = window;
4136
+ }
4137
+ get document() {
4138
+ return this.window.document;
4139
+ }
4140
+ get window() {
4141
+ return this._window;
4142
+ }
4143
+ /** @internal */
4144
+ _beforeUpdate() {
4145
+ if (this._server) {
4146
+ this._tracked_head_children = [];
4147
+ this._tracked_server_resource = new Map();
4148
+ }
4149
+ }
4150
+ /** @internal */
4151
+ _afterUpdate() {
4152
+ this._tracked_style.select([...this._tracked_elements.values().flatMap(({ className }) => className)]);
4153
+ const head = this.document.head ?? this.document.createElementNS(HTML_NS, 'head');
4154
+ const styleElem = this.document.querySelector('style[data-frosty-style]') ?? this.document.createElementNS(HTML_NS, 'style');
4155
+ styleElem.setAttribute('data-frosty-style', '');
4156
+ if (styleElem.textContent !== this._tracked_style.css)
4157
+ styleElem.textContent = this._tracked_style.css;
4158
+ if (this._server) {
4159
+ const ssrData = this._tracked_server_resource.size ? this.document.createElementNS(HTML_NS, 'script') : undefined;
4160
+ if (ssrData) {
4161
+ ssrData.setAttribute('data-frosty-ssr-data', '');
4162
+ ssrData.setAttribute('type', 'text/plain');
4163
+ ssrData.innerHTML = compress(JSON.stringify(Object.fromEntries(this._tracked_server_resource)));
4164
+ }
4165
+ DOMNativeNode.Utils.replaceChildren(head, _.compact([
4166
+ ...this._tracked_head_children,
4167
+ styleElem.textContent && styleElem,
4168
+ ssrData,
4169
+ ]), (x) => this._tracked_elements.has(x));
4170
+ }
4171
+ else if (styleElem.parentNode !== head && styleElem.textContent) {
4172
+ head.appendChild(styleElem);
4173
+ }
4174
+ if (!this.document.head) {
4175
+ this.document.documentElement.insertBefore(head, this.document.body);
4176
+ }
4177
+ }
4178
+ /** @internal */
4179
+ _createElement(node, stack) {
4032
4180
  const { type } = node;
4033
4181
  if (!_.isString(type) && type.prototype instanceof DOMNativeNode) {
4034
4182
  const ElementType = type;
@@ -4036,7 +4184,6 @@ class _DOMRenderer extends _Renderer {
4036
4184
  this._tracked_elements.set(elem, {
4037
4185
  props: [],
4038
4186
  className: [],
4039
- listener: {},
4040
4187
  });
4041
4188
  this._updateElement(node, elem, stack);
4042
4189
  return elem;
@@ -4060,7 +4207,6 @@ class _DOMRenderer extends _Renderer {
4060
4207
  this._tracked_elements.set(elem, {
4061
4208
  props: [],
4062
4209
  className: [],
4063
- listener: {},
4064
4210
  });
4065
4211
  this._updateElement(node, elem, stack);
4066
4212
  return elem;
@@ -4073,20 +4219,6 @@ class _DOMRenderer extends _Renderer {
4073
4219
  tracked.className = built;
4074
4220
  return [..._className, ...built].join(' ');
4075
4221
  }
4076
- __updateEventListener(element, key, listener) {
4077
- const event = key.endsWith('Capture') ? key.slice(2, -7).toLowerCase() : key.slice(2).toLowerCase();
4078
- const tracked_listener = this._tracked_elements.get(element)?.listener;
4079
- if (!tracked_listener)
4080
- return;
4081
- if (tracked_listener[key] !== listener) {
4082
- const options = { capture: key.endsWith('Capture') };
4083
- if (_.isFunction(tracked_listener[key]))
4084
- element.removeEventListener(event, tracked_listener[key], options);
4085
- if (_.isFunction(listener))
4086
- element.addEventListener(event, listener, options);
4087
- }
4088
- tracked_listener[key] = listener;
4089
- }
4090
4222
  /** @internal */
4091
4223
  _updateElement(node, element, stack) {
4092
4224
  if (element instanceof DOMNativeNode) {
@@ -4112,26 +4244,6 @@ class _DOMRenderer extends _Renderer {
4112
4244
  }
4113
4245
  if (ref)
4114
4246
  mergeRefs(ref)(element);
4115
- const builtClassName = this.__createBuiltClassName(element, className, style);
4116
- if (_.isEmpty(builtClassName)) {
4117
- if (!_.isNil(element.getAttribute('class')))
4118
- element.removeAttribute('class');
4119
- }
4120
- else if (element.className !== builtClassName) {
4121
- element.className = builtClassName;
4122
- }
4123
- if (!_.isEmpty(innerHTML) && element.innerHTML !== innerHTML)
4124
- element.innerHTML = innerHTML;
4125
- if (inlineStyle) {
4126
- const { css } = processCss(inlineStyle);
4127
- const oldValue = element.getAttribute('style');
4128
- const newValue = css.split('\n').join('');
4129
- if (oldValue !== newValue)
4130
- element.setAttribute('style', newValue);
4131
- }
4132
- else if (!_.isNil(element.getAttribute('style'))) {
4133
- element.removeAttribute('style');
4134
- }
4135
4247
  const tracked = this._tracked_elements.get(element);
4136
4248
  if (!tracked)
4137
4249
  return;
@@ -4141,54 +4253,14 @@ class _DOMRenderer extends _Renderer {
4141
4253
  ..._.fromPairs(_.map(removed, x => [x, undefined])),
4142
4254
  };
4143
4255
  tracked.props = _.keys(_props);
4144
- for (const [key, value] of _.entries(props)) {
4145
- if (_.includes(globalEvents, key)) {
4146
- this.__updateEventListener(element, key, value);
4147
- }
4148
- else if (key.endsWith('Capture') && _.includes(globalEvents, key.slice(0, -7))) {
4149
- this.__updateEventListener(element, key, value);
4150
- }
4151
- else if (key.startsWith('data-')) {
4152
- const oldValue = element.getAttribute(key);
4153
- if (value === false || _.isNil(value)) {
4154
- if (!_.isNil(oldValue))
4155
- element.removeAttribute(key);
4156
- }
4157
- else {
4158
- const newValue = value === true ? '' : `${value}`;
4159
- if (oldValue !== newValue)
4160
- element.setAttribute(key, newValue);
4161
- }
4162
- }
4163
- else {
4164
- const { type: _type, attr } = htmlProps['*'][key]
4165
- ?? htmlProps[type]?.[key]
4166
- ?? svgProps['*'][key]
4167
- ?? svgProps[type]?.[key]
4168
- ?? {};
4169
- const writeable = isWriteable(element, key);
4170
- if (writeable && !_.isNil(value)) {
4171
- if (element[key] !== value)
4172
- element[key] = value;
4173
- }
4174
- else if (_type && attr && _propValue[_type]) {
4175
- const oldValue = element.getAttribute(key);
4176
- if (value === false || _.isNil(value)) {
4177
- if (!_.isNil(oldValue))
4178
- element.removeAttribute(key);
4179
- }
4180
- else {
4181
- const newValue = value === true ? '' : `${value}`;
4182
- if (oldValue !== newValue)
4183
- element.setAttribute(key, newValue);
4184
- }
4185
- }
4186
- else if (writeable) {
4187
- if (element[key] !== value)
4188
- element[key] = value;
4189
- }
4190
- }
4191
- }
4256
+ const builtClassName = this.__createBuiltClassName(element, className, style);
4257
+ if (!_.isEmpty(innerHTML) && element.innerHTML !== innerHTML)
4258
+ element.innerHTML = innerHTML;
4259
+ DOMNativeNode.Utils.update(element, {
4260
+ className: builtClassName,
4261
+ style: inlineStyle ? processCss(inlineStyle).css : undefined,
4262
+ ...props,
4263
+ });
4192
4264
  }
4193
4265
  /** @internal */
4194
4266
  _replaceChildren(node, element, children, stack, force) {
@@ -4201,7 +4273,7 @@ class _DOMRenderer extends _Renderer {
4201
4273
  this._tracked_head_children.push(...children);
4202
4274
  }
4203
4275
  else if (_.isEmpty(innerHTML)) {
4204
- this.__replaceChildren(element, children, force);
4276
+ DOMNativeNode.Utils.replaceChildren(element, children, (x) => !!force || this._tracked_elements.has(x));
4205
4277
  }
4206
4278
  }
4207
4279
  }
@@ -4211,39 +4283,7 @@ class _DOMRenderer extends _Renderer {
4211
4283
  element.destroy();
4212
4284
  }
4213
4285
  else {
4214
- const tracked_listener = this._tracked_elements.get(element)?.listener;
4215
- for (const [key, listener] of _.entries(tracked_listener)) {
4216
- const event = key.endsWith('Capture') ? key.slice(2, -7).toLowerCase() : key.slice(2).toLowerCase();
4217
- if (_.isFunction(listener)) {
4218
- element.removeEventListener(event, listener, { capture: key.endsWith('Capture') });
4219
- }
4220
- }
4221
- }
4222
- this._tracked_elements.delete(element);
4223
- }
4224
- __replaceChildren(element, children, force) {
4225
- const diff = myersSync(_.map(element.childNodes, x => x.nodeType === this.document.TEXT_NODE ? x.textContent ?? '' : x), _.flatMap(children, x => x instanceof DOMNativeNode ? x.target : x), { compare: (a, b) => a === b });
4226
- let i = 0;
4227
- for (const { remove, insert, equivalent } of diff) {
4228
- if (equivalent) {
4229
- i += equivalent.length;
4230
- }
4231
- else if (remove) {
4232
- for (const child of remove) {
4233
- if (force || _.isString(child) || this._tracked_elements.has(child)) {
4234
- element.removeChild(element.childNodes[i]);
4235
- }
4236
- else {
4237
- i++;
4238
- }
4239
- }
4240
- }
4241
- if (insert) {
4242
- for (const child of insert) {
4243
- const node = _.isString(child) ? this.document.createTextNode(child) : child;
4244
- element.insertBefore(node, element.childNodes[i++]);
4245
- }
4246
- }
4286
+ DOMNativeNode.Utils.destroyElement(element);
4247
4287
  }
4248
4288
  }
4249
4289
  async renderToString(component) {
@@ -4261,4 +4301,4 @@ class _DOMRenderer extends _Renderer {
4261
4301
  }
4262
4302
 
4263
4303
  export { DOMNativeNode as D, _DOMRenderer as _ };
4264
- //# sourceMappingURL=common-8aOatOjL.mjs.map
4304
+ //# sourceMappingURL=renderer-4YHvu-zN.mjs.map