@glass-sdk/liquid-glass 0.0.2 → 0.0.3-beta.1

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.
Files changed (146) hide show
  1. package/CHANGELOG.md +124 -0
  2. package/README.md +66 -149
  3. package/dist/core/concentric.js +20 -3
  4. package/dist/core/corner-options.js +12 -0
  5. package/dist/core/corner-path.js +118 -0
  6. package/dist/core/materials.js +264 -32
  7. package/dist/core/optics.js +1 -2
  8. package/dist/core/progressive.js +1 -2
  9. package/dist/core/shape.js +18 -28
  10. package/dist/core/spring.js +5 -10
  11. package/dist/core.js +5 -6
  12. package/dist/dom/backdrop-glass.js +46 -0
  13. package/dist/dom/compose-layers.js +42 -31
  14. package/dist/dom/composited.js +136 -0
  15. package/dist/dom/control-motion.js +58 -47
  16. package/dist/dom/engine.js +1 -2
  17. package/dist/dom/escaped-layers.js +179 -0
  18. package/dist/dom/filter-bounds.js +42 -13
  19. package/dist/dom/filter-budget.js +1 -2
  20. package/dist/dom/filter-chain.js +40 -0
  21. package/dist/dom/filter-groups.js +33 -14
  22. package/dist/dom/filter-paint-root.js +8 -6
  23. package/dist/dom/filter-patch.js +94 -55
  24. package/dist/dom/filter-reach.js +32 -19
  25. package/dist/dom/filter-stages.js +1 -2
  26. package/dist/dom/fixed-shape.js +23 -16
  27. package/dist/dom/foreground.js +16 -17
  28. package/dist/dom/interaction.js +65 -92
  29. package/dist/dom/layout-rect.js +42 -0
  30. package/dist/dom/layout-size.js +28 -0
  31. package/dist/dom/lens-layers.js +250 -136
  32. package/dist/dom/map-encoder.js +16 -13
  33. package/dist/dom/map-encoder.worker.js +2 -3
  34. package/dist/dom/map-encoding.js +49 -12
  35. package/dist/dom/map-image.js +29 -7
  36. package/dist/dom/map-store.js +1 -2
  37. package/dist/dom/maps.js +133 -83
  38. package/dist/dom/material-graph.js +108 -29
  39. package/dist/dom/media-mirror.js +244 -0
  40. package/dist/dom/page-zoom.js +19 -18
  41. package/dist/dom/png.js +1 -2
  42. package/dist/dom/progressive.js +152 -147
  43. package/dist/dom/renderer.js +1 -2
  44. package/dist/dom/sampling-bounds.js +1 -2
  45. package/dist/dom/selection.js +133 -79
  46. package/dist/dom/shape-attributes.js +9 -0
  47. package/dist/dom/shape-effects.js +14 -0
  48. package/dist/dom/shape-geometry.js +3 -0
  49. package/dist/dom/shape-layout.js +115 -116
  50. package/dist/dom/shared-backdrop.js +33 -25
  51. package/dist/dom/specular.js +116 -0
  52. package/dist/dom/ticker.js +28 -19
  53. package/dist/dom/tint-color.js +24 -0
  54. package/dist/dom/warm.js +63 -59
  55. package/dist/dom.js +591 -505
  56. package/dist/gpu/geometry.js +2 -3
  57. package/dist/gpu/maps.js +1109 -7
  58. package/dist/gpu/planes.js +2 -3
  59. package/dist/gpu.js +66 -64
  60. package/dist/index.js +12 -10
  61. package/dist/react/button.js +12 -11
  62. package/dist/react/color-picker.js +199 -0
  63. package/dist/react/control-thumb.js +4 -5
  64. package/dist/react/menu.js +82 -111
  65. package/dist/react/merged-ref.js +1 -2
  66. package/dist/react/progressive.js +1 -2
  67. package/dist/react/scene.js +71 -55
  68. package/dist/react/shape.js +67 -47
  69. package/dist/react/slider.js +81 -0
  70. package/dist/react/surface.js +90 -56
  71. package/dist/react/switch.js +101 -0
  72. package/dist/react/tabs.js +85 -63
  73. package/dist/react/toolbar.js +38 -123
  74. package/dist/react/value-control-motion.js +1 -2
  75. package/dist/styles.css +517 -111
  76. package/dist/types/core/concentric.d.ts +8 -0
  77. package/dist/types/core/corner-options.d.ts +4 -0
  78. package/dist/types/core/corner-path.d.ts +8 -0
  79. package/dist/types/core/index.d.ts +3 -5
  80. package/dist/types/core/materials.d.ts +100 -28
  81. package/dist/types/core/shape.d.ts +4 -6
  82. package/dist/types/core/spring.d.ts +8 -12
  83. package/dist/types/dom/backdrop-glass.d.ts +38 -0
  84. package/dist/types/dom/compose-layers.d.ts +4 -0
  85. package/dist/types/dom/composited.d.ts +61 -0
  86. package/dist/types/dom/escaped-layers.d.ts +32 -0
  87. package/dist/types/dom/filter-bounds.d.ts +4 -0
  88. package/dist/types/dom/filter-chain.d.ts +6 -0
  89. package/dist/types/dom/filter-groups.d.ts +1 -1
  90. package/dist/types/dom/filter-paint-root.d.ts +3 -0
  91. package/dist/types/dom/filter-patch.d.ts +5 -0
  92. package/dist/types/dom/filter-reach.d.ts +9 -9
  93. package/dist/types/dom/foreground.d.ts +2 -1
  94. package/dist/types/dom/index.d.ts +8 -19
  95. package/dist/types/dom/interaction.d.ts +8 -8
  96. package/dist/types/dom/layout-rect.d.ts +17 -0
  97. package/dist/types/dom/layout-size.d.ts +11 -0
  98. package/dist/types/dom/lens-layers.d.ts +18 -10
  99. package/dist/types/dom/map-encoder.d.ts +5 -2
  100. package/dist/types/dom/map-encoding.d.ts +12 -3
  101. package/dist/types/dom/map-image.d.ts +7 -1
  102. package/dist/types/dom/maps.d.ts +25 -7
  103. package/dist/types/dom/material-graph.d.ts +73 -10
  104. package/dist/types/dom/media-mirror.d.ts +49 -0
  105. package/dist/types/dom/progressive.d.ts +2 -5
  106. package/dist/types/dom/sampling-bounds.d.ts +1 -3
  107. package/dist/types/dom/selection.d.ts +29 -4
  108. package/dist/types/dom/shape-attributes.d.ts +6 -0
  109. package/dist/types/dom/shape-effects.d.ts +10 -0
  110. package/dist/types/dom/shape-geometry.d.ts +6 -0
  111. package/dist/types/dom/shape-layout.d.ts +2 -4
  112. package/dist/types/dom/shared-backdrop.d.ts +7 -3
  113. package/dist/types/dom/specular.d.ts +50 -0
  114. package/dist/types/dom/ticker.d.ts +4 -1
  115. package/dist/types/dom/tint-color.d.ts +11 -0
  116. package/dist/types/dom/warm.d.ts +8 -2
  117. package/dist/types/gpu/geometry.d.ts +2 -0
  118. package/dist/types/gpu/planes.d.ts +3 -2
  119. package/dist/types/index.d.ts +1 -1
  120. package/dist/types/react/button.d.ts +1 -1
  121. package/dist/types/react/color-picker.d.ts +26 -0
  122. package/dist/types/react/index.d.ts +14 -10
  123. package/dist/types/react/menu.d.ts +4 -5
  124. package/dist/types/react/progressive.d.ts +1 -1
  125. package/dist/types/react/scene.d.ts +4 -2
  126. package/dist/types/react/shape.d.ts +11 -1
  127. package/dist/types/react/slider.d.ts +14 -0
  128. package/dist/types/react/surface.d.ts +11 -22
  129. package/dist/types/react/switch.d.ts +9 -0
  130. package/dist/types/react/tabs.d.ts +3 -3
  131. package/dist/types/react/toolbar.d.ts +1 -1
  132. package/package.json +46 -40
  133. package/dist/core/morph-path.js +0 -206
  134. package/dist/core/union.js +0 -117
  135. package/dist/dom/compound-field.js +0 -23
  136. package/dist/dom/exit-handoff.js +0 -14
  137. package/dist/dom/map-blend.js +0 -8
  138. package/dist/dom/morph.js +0 -296
  139. package/dist/react/value-controls.js +0 -176
  140. package/dist/types/core/morph-path.d.ts +0 -110
  141. package/dist/types/core/union.d.ts +0 -20
  142. package/dist/types/dom/compound-field.d.ts +0 -35
  143. package/dist/types/dom/exit-handoff.d.ts +0 -7
  144. package/dist/types/dom/map-blend.d.ts +0 -22
  145. package/dist/types/dom/morph.d.ts +0 -78
  146. package/dist/types/react/value-controls.d.ts +0 -20
@@ -0,0 +1,244 @@
1
+ // src/dom/media-mirror.ts
2
+ function e(e, t, n, r) {
3
+ if (!t.width || !t.height) return e;
4
+ let i = e.w, a = e.h, o = t.width / t.height, s = () => {
5
+ e.w / e.h > o ? (a = e.h, i = a * o) : (i = e.w, a = i / o);
6
+ };
7
+ n === "contain" ? s() : n === "cover" ? e.w / e.h > o ? (i = e.w, a = i / o) : (a = e.h, i = a * o) : n === "none" ? (i = t.width, a = t.height) : n === "scale-down" && (t.width > e.w || t.height > e.h ? s() : (i = t.width, a = t.height));
8
+ let [c = "50%", l = "50%"] = r.trim().split(/\s+/), u = (e, t) => e.endsWith("%") ? t * parseFloat(e) / 100 : parseFloat(e) || 0;
9
+ return {
10
+ x: e.x + u(c, e.w - i),
11
+ y: e.y + u(l, e.h - a),
12
+ w: i,
13
+ h: a
14
+ };
15
+ }
16
+ function t(e, t, n) {
17
+ let r = (e) => Math.round(e * 100) / 100, i = n.map(({ x: e, y: t, w: n, h: i, radius: a }) => {
18
+ let o = Math.max(0, Math.min(a, n / 2, i / 2));
19
+ return o ? `M${r(e + o)} ${r(t)}H${r(e + n - o)}A${r(o)} ${r(o)} 0 0 1 ${r(e + n)} ${r(t + o)}V${r(t + i - o)}A${r(o)} ${r(o)} 0 0 1 ${r(e + n - o)} ${r(t + i)}H${r(e + o)}A${r(o)} ${r(o)} 0 0 1 ${r(e)} ${r(t + i - o)}V${r(t + o)}A${r(o)} ${r(o)} 0 0 1 ${r(e + o)} ${r(t)}Z` : `M${r(e)} ${r(t)}H${r(e + n)}V${r(t + i)}H${r(e)}Z`;
20
+ });
21
+ return `path(evenodd, "M0 0H${r(e)}V${r(t)}H0Z${i.join("")}")`;
22
+ }
23
+ function n(n) {
24
+ let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new WeakSet(), a = () => Math.min(typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, 2), o = (t, n, r = !1) => {
25
+ let i = n.tiles.filter((e) => e.region);
26
+ if (!i.length) return;
27
+ let o = (t.ownerDocument.defaultView ?? window).getComputedStyle(t), s = (e) => parseFloat(e) || 0, c = {
28
+ w: t.offsetWidth,
29
+ h: t.offsetHeight
30
+ }, l = {
31
+ l: s(o.borderLeftWidth),
32
+ t: s(o.borderTopWidth),
33
+ r: s(o.borderRightWidth),
34
+ b: s(o.borderBottomWidth)
35
+ }, u = {
36
+ l: s(o.paddingLeft),
37
+ t: s(o.paddingTop),
38
+ r: s(o.paddingRight),
39
+ b: s(o.paddingBottom)
40
+ }, d = {
41
+ x: l.l + u.l,
42
+ y: l.t + u.t,
43
+ w: c.w - l.l - l.r - u.l - u.r,
44
+ h: c.h - l.t - l.b - u.t - u.b
45
+ }, f = Math.max(0, s(o.borderTopLeftRadius) - Math.max(l.l, l.t)), p = {
46
+ x: l.l,
47
+ y: l.t,
48
+ w: c.w - l.l - l.r,
49
+ h: c.h - l.t - l.b
50
+ }, m = t, h = t instanceof HTMLVideoElement ? {
51
+ width: t.videoWidth,
52
+ height: t.videoHeight
53
+ } : {
54
+ width: t.width,
55
+ height: t.height
56
+ };
57
+ if (t instanceof HTMLVideoElement && t.readyState < 2) {
58
+ let e = n.poster;
59
+ m = e?.complete && e.naturalWidth ? e : void 0, h = e ? {
60
+ width: e.naturalWidth,
61
+ height: e.naturalHeight
62
+ } : h;
63
+ }
64
+ let g = m && h.width && h.height ? e(d, h, o.objectFit, o.objectPosition) : void 0, _ = a(), v = (e, t, n, r) => {
65
+ if (e.setTransform(1, 0, 0, 1, 0, 0), e.clearRect(0, 0, n, r), !g) return;
66
+ e.setTransform(_, 0, 0, _, -t.x * _, -t.y * _), e.save(), e.beginPath(), f > 0 && typeof e.roundRect == "function" ? e.roundRect(p.x, p.y, p.w, p.h, f) : e.rect(p.x, p.y, p.w, p.h), e.clip();
67
+ let i = Math.max(g.x, p.x, t.x), a = Math.max(g.y, p.y, t.y), o = Math.min(g.x + g.w, p.x + p.w, t.x + t.w) - i, s = Math.min(g.y + g.h, p.y + p.h, t.y + t.h) - a, c = h.width / g.w, l = h.height / g.h;
68
+ if (o > 0 && s > 0) try {
69
+ e.drawImage(m, (i - g.x) * c, (a - g.y) * l, o * c, s * l, i, a, o, s);
70
+ } catch {}
71
+ e.restore();
72
+ }, y = (e) => [Math.max(1, Math.ceil(e.w * _)), Math.max(1, Math.ceil(e.h * _))], b;
73
+ if ((i.length > 1 || r) && g) {
74
+ let e = Math.min(...i.map((e) => e.region.x)), a = Math.min(...i.map((e) => e.region.y)), o = {
75
+ x: e,
76
+ y: a,
77
+ w: Math.max(...i.map((e) => e.region.x + e.region.w)) - e,
78
+ h: Math.max(...i.map((e) => e.region.y + e.region.h)) - a
79
+ }, [s, c] = y(o), l = n.frame ??= t.ownerDocument.createElement("canvas");
80
+ (l.width !== s || l.height !== c) && (l.width = s, l.height = c);
81
+ let u = l.getContext("2d", { willReadFrequently: !0 });
82
+ if (v(u, o, s, c), b = {
83
+ region: o,
84
+ canvas: l
85
+ }, r) {
86
+ let e;
87
+ try {
88
+ e = new Uint32Array(u.getImageData(0, 0, s, c).data.buffer);
89
+ } catch {}
90
+ let t = n.seen;
91
+ if (n.seen = e, e && t?.length === e.length) {
92
+ let r = e.length;
93
+ for (; r-- && e[r] === t[r];);
94
+ if (r < 0) {
95
+ n.still++;
96
+ return;
97
+ }
98
+ }
99
+ n.still = 0;
100
+ }
101
+ }
102
+ for (let e of i) {
103
+ let t = e.region, [n, r] = y(t), { canvas: i, context: a } = e;
104
+ (i.width !== n || i.height !== r) && (i.width = n, i.height = r), b ? (a.setTransform(1, 0, 0, 1, 0, 0), a.clearRect(0, 0, n, r), a.drawImage(b.canvas, Math.round((t.x - b.region.x) * _), Math.round((t.y - b.region.y) * _), n, r, 0, 0, n, r)) : v(a, t, n, r);
105
+ }
106
+ n.stale = !1;
107
+ }, s = (e) => {
108
+ let t = e.ownerDocument.createElement("canvas");
109
+ t.setAttribute("aria-hidden", "true"), t.dataset.glassMirror = "";
110
+ let n = t.getContext("2d", { willReadFrequently: !0 });
111
+ return Object.assign(t.style, {
112
+ position: "absolute",
113
+ pointerEvents: "none",
114
+ margin: "0",
115
+ padding: "0",
116
+ border: "0",
117
+ left: "0px",
118
+ top: "0px",
119
+ willChange: "transform"
120
+ }), i.add(t), e.before(t), {
121
+ canvas: t,
122
+ context: n
123
+ };
124
+ }, c = (e) => {
125
+ let t = {
126
+ tiles: [],
127
+ active: !1,
128
+ clip: {
129
+ value: "",
130
+ priority: ""
131
+ },
132
+ stale: !0,
133
+ still: 0,
134
+ listeners: []
135
+ };
136
+ if (e instanceof HTMLVideoElement) {
137
+ e.poster && (t.poster = new Image(), t.poster.src = e.poster, t.poster.decode().then(() => {
138
+ t.stale = !0, n();
139
+ }, () => void 0));
140
+ let r = () => {
141
+ t.stale = !0, n();
142
+ };
143
+ for (let n of [
144
+ "loadeddata",
145
+ "seeked",
146
+ "emptied",
147
+ "resize"
148
+ ]) e.addEventListener(n, r), t.listeners.push(() => e.removeEventListener(n, r));
149
+ }
150
+ return t;
151
+ }, l = (e, t) => {
152
+ if (!(e instanceof HTMLVideoElement) || t.callback !== void 0 || typeof e.requestVideoFrameCallback != "function") return;
153
+ let n = () => {
154
+ t.callback = e.requestVideoFrameCallback(() => {
155
+ t.callback = void 0, r.has(e) && t.active && (o(e, t), n());
156
+ });
157
+ };
158
+ n();
159
+ }, u, d = 0, f = () => {
160
+ u === void 0 && (u = setTimeout(() => {
161
+ ([...r.keys()][0]?.ownerDocument.defaultView ?? window).requestAnimationFrame(() => {
162
+ u = void 0;
163
+ let e = !1;
164
+ d = (d + 1) % 6;
165
+ for (let [t, n] of r) t instanceof HTMLCanvasElement && n.active && ((n.still < 30 || !d) && o(t, n, !0), e = !0);
166
+ e && f();
167
+ });
168
+ }, 0));
169
+ }, p = (e, t) => {
170
+ let n = t.hidden;
171
+ n && (t.hidden = void 0, e.style.getPropertyValue("opacity") === "0" && (n.value ? e.style.setProperty("opacity", n.value, n.priority) : e.style.removeProperty("opacity")));
172
+ }, m = (e, t) => {
173
+ t.hole !== void 0 && (e.style.getPropertyValue("clip-path") === t.hole && (t.clip.value ? e.style.setProperty("clip-path", t.clip.value, t.clip.priority) : e.style.removeProperty("clip-path")), t.hole = void 0);
174
+ }, h = (e, t) => {
175
+ if (t.active) {
176
+ t.active = !1, t.authored = void 0, t.callback !== void 0 && e instanceof HTMLVideoElement && e.cancelVideoFrameCallback(t.callback), t.callback = void 0, t.frame = void 0, t.seen = void 0, m(e, t), p(e, t);
177
+ for (let e of t.tiles) e.region = void 0, e.canvas.style.display = "none";
178
+ }
179
+ }, g = (e, t) => {
180
+ h(e, t), t.listeners.forEach((e) => e());
181
+ for (let e of t.tiles) e.canvas.remove();
182
+ r.delete(e);
183
+ };
184
+ return {
185
+ update(e) {
186
+ for (let [t, n] of r) t.isConnected ? e.has(t) || h(t, n) : g(t, n);
187
+ for (let [n, i] of e) {
188
+ let e = r.get(n);
189
+ if (e || (e = c(n), r.set(n, e)), !e.active) {
190
+ let t = (n.ownerDocument.defaultView ?? window).getComputedStyle(n).clipPath;
191
+ e.authored = !!t && t !== "none", e.active = !0;
192
+ }
193
+ let a = e.authored ? [{
194
+ x: 0,
195
+ y: 0,
196
+ w: n.offsetWidth,
197
+ h: n.offsetHeight
198
+ }] : i.regions;
199
+ for (; e.tiles.length < a.length;) e.tiles.push(s(n));
200
+ let u = e.stale;
201
+ if (e.tiles.forEach((e, t) => {
202
+ let r = a[t];
203
+ if ((e.canvas.parentNode !== n.parentNode || e.canvas.compareDocumentPosition(n) & Node.DOCUMENT_POSITION_PRECEDING) && n.before(e.canvas), !r) {
204
+ e.region && (e.region = void 0, e.canvas.style.display = "none");
205
+ return;
206
+ }
207
+ let o = e.left !== void 0 && e.top !== void 0 && e.region ? i.measured?.[t] : void 0, s = o ? e.left - o.x + r.x : n.offsetLeft + r.x, c = o ? e.top - o.y + r.y : n.offsetTop + r.y;
208
+ (!e.region || [
209
+ "x",
210
+ "y",
211
+ "w",
212
+ "h"
213
+ ].some((t) => Math.abs(e.region[t] - r[t]) > .01)) && (u = !0), e.left = s, e.top = c, e.region = r, Object.assign(e.canvas.style, {
214
+ display: "block",
215
+ left: `${s}px`,
216
+ top: `${c}px`,
217
+ width: `${r.w}px`,
218
+ height: `${r.h}px`
219
+ });
220
+ }), u && o(n, e), n instanceof HTMLCanvasElement && f(), l(n, e), e.authored) {
221
+ e.hidden || (e.hidden = {
222
+ value: n.style.getPropertyValue("opacity"),
223
+ priority: n.style.getPropertyPriority("opacity")
224
+ }, n.style.setProperty("opacity", "0", "important"));
225
+ continue;
226
+ }
227
+ let d = t(n.offsetWidth, n.offsetHeight, i.holes);
228
+ e.hole === void 0 && (e.clip = {
229
+ value: n.style.getPropertyValue("clip-path"),
230
+ priority: n.style.getPropertyPriority("clip-path")
231
+ }), e.hole !== d && (n.style.setProperty("clip-path", d, "important"), e.hole = n.style.getPropertyValue("clip-path"));
232
+ }
233
+ },
234
+ animating: () => [...r].some(([e, t]) => t.active && e instanceof HTMLCanvasElement && t.still < 30),
235
+ ownsCanvas: (e) => i.has(e),
236
+ canvasesOf: (e) => r.get(e)?.tiles.filter((e) => e.region).map((e) => e.canvas) ?? [],
237
+ whole: (e) => !!r.get(e)?.authored,
238
+ dispose() {
239
+ u !== void 0 && clearTimeout(u);
240
+ for (let [e, t] of r) g(e, t);
241
+ }
242
+ };
243
+ }
244
+ export { n as createMediaMirrors, t as holeClip, e as objectBox };
@@ -1,35 +1,37 @@
1
1
  import { webkit as e } from "./engine.js";
2
- //#region src/dom/page-zoom.ts
2
+ // src/dom/page-zoom.ts
3
3
  var t = {
4
4
  ratio: 0,
5
5
  pinch: 0,
6
6
  zoom: 1
7
- }, n = () => e && typeof visualViewport == "object" && visualViewport && visualViewport.scale > 0 ? visualViewport.scale : 1;
8
- function r() {
9
- return (typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1) / n();
7
+ }, n, r = !1, i = () => !e || typeof visualViewport != "object" || !visualViewport ? 1 : (n === void 0 && (n = visualViewport.scale > 0 ? visualViewport.scale : 1, !r && typeof visualViewport.addEventListener == "function" && (r = !0, visualViewport.addEventListener("resize", () => {
8
+ n = void 0;
9
+ }))), n);
10
+ function a() {
11
+ return (typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1) / i();
10
12
  }
11
- function i(t, r, i = 1) {
13
+ function o(t, n, r = 1) {
12
14
  if (!e) return Infinity;
13
- let o = (typeof navigator == "object" && navigator.maxTouchPoints > 1 ? 1024 : 2048) * i;
14
- return Math.max(0, (o / (a() * n()) - Math.max(t, r)) / 2);
15
+ let a = (typeof navigator == "object" && navigator.maxTouchPoints > 1 ? 1024 : 2048) * r;
16
+ return Math.max(0, (a / (s() * i()) - Math.max(t, n)) / 2);
15
17
  }
16
- function a() {
18
+ function s() {
17
19
  if (!e || typeof matchMedia != "function") return 1;
18
- let r = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, i = n();
19
- if (r === t.ratio && i === t.pinch) return t.zoom;
20
+ let n = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, r = i();
21
+ if (n === t.ratio && r === t.pinch) return t.zoom;
20
22
  let a = .25, o = 16;
21
23
  for (let e = 0; e < 24; e++) {
22
24
  let e = (a + o) / 2;
23
25
  matchMedia(`(min-resolution: ${e}dppx)`).matches ? a = e : o = e;
24
26
  }
25
- let s = Math.round(r / i / a * 1e3) / 1e3;
27
+ let s = Math.round(n / r / a * 1e3) / 1e3;
26
28
  return t = {
27
- ratio: r,
28
- pinch: i,
29
+ ratio: n,
30
+ pinch: r,
29
31
  zoom: Math.abs(s - 1) < .005 ? 1 : s
30
32
  }, t.zoom;
31
33
  }
32
- var o = /* @__PURE__ */ new Set([
34
+ var c = /* @__PURE__ */ new Set([
33
35
  "x",
34
36
  "y",
35
37
  "width",
@@ -39,8 +41,7 @@ var o = /* @__PURE__ */ new Set([
39
41
  "stdDeviation",
40
42
  "scale"
41
43
  ]);
42
- function s(e, t) {
43
- return t === 1 ? e : e.replace(/<(fe\w+)\b([^>]*)>/g, (e, n, r) => `<${n}${r.replace(/([\w-]+)="([^"]*)"/g, (e, n, r) => o.has(n) ? `${n}="${r.split(/[\s,]+/).filter(Boolean).map((e) => Number(e) * t).join(" ")}"` : e)}>`);
44
+ function l(e, t) {
45
+ return t === 1 ? e : e.replace(/<(fe\w+)\b([^>]*)>/g, (e, n, r) => `<${n}${r.replace(/([\w-]+)="([^"]*)"/g, (e, n, r) => c.has(n) ? `${n}="${r.split(/[\s,]+/).filter(Boolean).map((e) => Number(e) * t).join(" ")}"` : e)}>`);
44
46
  }
45
- //#endregion
46
- export { r as filterPixelRatio, a as pageZoom, i as untiledOutsets, s as zoomFilterMarkup };
47
+ export { a as filterPixelRatio, s as pageZoom, o as untiledOutsets, l as zoomFilterMarkup };
package/dist/dom/png.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/dom/png.ts
1
+ // src/dom/png.ts
2
2
  var e = /* @__PURE__ */ new Int32Array(256);
3
3
  for (let t = 0; t < 256; t++) {
4
4
  let n = t;
@@ -101,5 +101,4 @@ async function d(e, t, n, r) {
101
101
  function f(e, t, n) {
102
102
  return `data:image/png;base64,${u(s(e, t, r(o(e, t, n, e * 4))))}`;
103
103
  }
104
- //#endregion
105
104
  export { u as base64, c as encodePng, d as pngDataUrl, f as pngDataUrlSync };