frosty 0.0.85 → 0.0.87

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.
@@ -3841,6 +3841,94 @@ class StyleBuilder {
3841
3841
  }
3842
3842
  }
3843
3843
 
3844
+ //
3845
+ // compress.js
3846
+ //
3847
+ // The MIT License
3848
+ // Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
3849
+ //
3850
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
3851
+ // of this software and associated documentation files (the "Software"), to deal
3852
+ // in the Software without restriction, including without limitation the rights
3853
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3854
+ // copies of the Software, and to permit persons to whom the Software is
3855
+ // furnished to do so, subject to the following conditions:
3856
+ //
3857
+ // The above copyright notice and this permission notice shall be included in
3858
+ // all copies or substantial portions of the Software.
3859
+ //
3860
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3861
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3862
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3863
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3864
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3865
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3866
+ // THE SOFTWARE.
3867
+ //
3868
+ // @ts-nocheck
3869
+ function _compress(r, e, o) {
3870
+ if (null == r)
3871
+ return "";
3872
+ var t, a, h, f = {}, p = {}, c = "", s = "", n = "", u = 2, l = 3, i = 2, A = [], d = 0, C = 0;
3873
+ for (h = 0; h < r.length; h += 1)
3874
+ if (c = r.charAt(h), Object.prototype.hasOwnProperty.call(f, c) || (f[c] = l++, p[c] = true), s = n + c, Object.prototype.hasOwnProperty.call(f, s))
3875
+ n = s;
3876
+ else {
3877
+ if (Object.prototype.hasOwnProperty.call(p, n)) {
3878
+ if (n.charCodeAt(0) < 256) {
3879
+ for (t = 0; t < i; t++)
3880
+ d <<= 1, C == e - 1 ? (C = 0, A.push(o(d)), d = 0) : C++;
3881
+ for (a = n.charCodeAt(0), t = 0; t < 8; t++)
3882
+ d = d << 1 | 1 & a, C == e - 1 ? (C = 0, A.push(o(d)), d = 0) : C++, a >>= 1;
3883
+ }
3884
+ else {
3885
+ for (a = 1, t = 0; t < i; t++)
3886
+ d = d << 1 | a, C == e - 1 ? (C = 0, A.push(o(d)), d = 0) : C++, a = 0;
3887
+ for (a = n.charCodeAt(0), t = 0; t < 16; t++)
3888
+ d = d << 1 | 1 & a, C == e - 1 ? (C = 0, A.push(o(d)), d = 0) : C++, a >>= 1;
3889
+ }
3890
+ 0 == --u && (u = Math.pow(2, i), i++), delete p[n];
3891
+ }
3892
+ else
3893
+ for (a = f[n], t = 0; t < i; t++)
3894
+ d = d << 1 | 1 & a, C == e - 1 ? (C = 0, A.push(o(d)), d = 0) : C++, a >>= 1;
3895
+ 0 == --u && (u = Math.pow(2, i), i++), f[s] = l++, n = String(c);
3896
+ }
3897
+ if ("" !== n) {
3898
+ if (Object.prototype.hasOwnProperty.call(p, n)) {
3899
+ if (n.charCodeAt(0) < 256) {
3900
+ for (t = 0; t < i; t++)
3901
+ d <<= 1, C == e - 1 ? (C = 0, A.push(o(d)), d = 0) : C++;
3902
+ for (a = n.charCodeAt(0), t = 0; t < 8; t++)
3903
+ d = d << 1 | 1 & a, C == e - 1 ? (C = 0, A.push(o(d)), d = 0) : C++, a >>= 1;
3904
+ }
3905
+ else {
3906
+ for (a = 1, t = 0; t < i; t++)
3907
+ d = d << 1 | a, C == e - 1 ? (C = 0, A.push(o(d)), d = 0) : C++, a = 0;
3908
+ for (a = n.charCodeAt(0), t = 0; t < 16; t++)
3909
+ d = d << 1 | 1 & a, C == e - 1 ? (C = 0, A.push(o(d)), d = 0) : C++, a >>= 1;
3910
+ }
3911
+ 0 == --u && (u = Math.pow(2, i), i++), delete p[n];
3912
+ }
3913
+ else
3914
+ for (a = f[n], t = 0; t < i; t++)
3915
+ d = d << 1 | 1 & a, C == e - 1 ? (C = 0, A.push(o(d)), d = 0) : C++, a >>= 1;
3916
+ 0 == --u && (u = Math.pow(2, i), i++);
3917
+ }
3918
+ for (a = 2, t = 0; t < i; t++)
3919
+ d = d << 1 | 1 & a, C == e - 1 ? (C = 0, A.push(o(d)), d = 0) : C++, a >>= 1;
3920
+ for (;;) {
3921
+ if (d <<= 1, C == e - 1) {
3922
+ A.push(o(d));
3923
+ break;
3924
+ }
3925
+ C++;
3926
+ }
3927
+ return A.join("");
3928
+ }
3929
+ const altAlpha = ":;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz";
3930
+ const compress = (r) => _compress(r, 6, r => altAlpha.charAt(r));
3931
+
3844
3932
  //
3845
3933
  // common.ts
3846
3934
  //
@@ -3895,6 +3983,8 @@ class _DOMRenderer extends _Renderer {
3895
3983
  _namespace_map = new WeakMap();
3896
3984
  _tracked_head_children = [];
3897
3985
  _tracked_style = new StyleBuilder();
3986
+ /** @internal */
3987
+ _tracked_server_resource = new Map();
3898
3988
  _tracked_elements = new Map();
3899
3989
  constructor(window) {
3900
3990
  super();
@@ -3910,28 +4000,28 @@ class _DOMRenderer extends _Renderer {
3910
4000
  _beforeUpdate() {
3911
4001
  if (this._server) {
3912
4002
  this._tracked_head_children = [];
4003
+ this._tracked_server_resource = new Map();
3913
4004
  }
3914
4005
  }
3915
4006
  /** @internal */
3916
4007
  _afterUpdate() {
3917
4008
  this._tracked_style.select([...this._tracked_elements.values().flatMap(({ className }) => className)]);
3918
4009
  const head = this.document.head ?? this.document.createElementNS(HTML_NS, 'head');
3919
- if (this._tracked_style.isEmpty) {
3920
- if (this._server) {
3921
- this.__replaceChildren(head, this._tracked_head_children);
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)));
3922
4020
  }
4021
+ this.__replaceChildren(head, _.compact([...this._tracked_head_children, styleElem, ssrData]));
3923
4022
  }
3924
- else {
3925
- const styleElem = this.document.querySelector('style[data-frosty-style]') ?? this.document.createElementNS(HTML_NS, 'style');
3926
- styleElem.setAttribute('data-frosty-style', '');
3927
- if (styleElem.textContent !== this._tracked_style.css)
3928
- styleElem.textContent = this._tracked_style.css;
3929
- if (this._server) {
3930
- this.__replaceChildren(head, [...this._tracked_head_children, styleElem]);
3931
- }
3932
- else if (styleElem.parentNode !== head) {
3933
- head.appendChild(styleElem);
3934
- }
4023
+ else if (styleElem.parentNode !== head) {
4024
+ head.appendChild(styleElem);
3935
4025
  }
3936
4026
  if (!this.document.head) {
3937
4027
  this.document.documentElement.insertBefore(head, this.document.body);
@@ -4165,4 +4255,4 @@ class _DOMRenderer extends _Renderer {
4165
4255
  }
4166
4256
 
4167
4257
  export { DOMNativeNode as D, _DOMRenderer as _ };
4168
- //# sourceMappingURL=common-IghNU-hG.mjs.map
4258
+ //# sourceMappingURL=common-DmBH-tsg.mjs.map