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