@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.
- package/CHANGELOG.md +124 -0
- package/README.md +66 -149
- package/dist/core/concentric.js +20 -3
- package/dist/core/corner-options.js +12 -0
- package/dist/core/corner-path.js +118 -0
- package/dist/core/materials.js +264 -32
- package/dist/core/optics.js +1 -2
- package/dist/core/progressive.js +1 -2
- package/dist/core/shape.js +18 -28
- package/dist/core/spring.js +5 -10
- package/dist/core.js +5 -6
- package/dist/dom/backdrop-glass.js +46 -0
- package/dist/dom/compose-layers.js +42 -31
- package/dist/dom/composited.js +136 -0
- package/dist/dom/control-motion.js +58 -47
- package/dist/dom/engine.js +1 -2
- package/dist/dom/escaped-layers.js +179 -0
- package/dist/dom/filter-bounds.js +42 -13
- package/dist/dom/filter-budget.js +1 -2
- package/dist/dom/filter-chain.js +40 -0
- package/dist/dom/filter-groups.js +33 -14
- package/dist/dom/filter-paint-root.js +8 -6
- package/dist/dom/filter-patch.js +94 -55
- package/dist/dom/filter-reach.js +32 -19
- package/dist/dom/filter-stages.js +1 -2
- package/dist/dom/fixed-shape.js +23 -16
- package/dist/dom/foreground.js +16 -17
- package/dist/dom/interaction.js +65 -92
- package/dist/dom/layout-rect.js +42 -0
- package/dist/dom/layout-size.js +28 -0
- package/dist/dom/lens-layers.js +250 -136
- package/dist/dom/map-encoder.js +16 -13
- package/dist/dom/map-encoder.worker.js +2 -3
- package/dist/dom/map-encoding.js +49 -12
- package/dist/dom/map-image.js +29 -7
- package/dist/dom/map-store.js +1 -2
- package/dist/dom/maps.js +133 -83
- package/dist/dom/material-graph.js +108 -29
- package/dist/dom/media-mirror.js +244 -0
- package/dist/dom/page-zoom.js +19 -18
- package/dist/dom/png.js +1 -2
- package/dist/dom/progressive.js +152 -147
- package/dist/dom/renderer.js +1 -2
- package/dist/dom/sampling-bounds.js +1 -2
- package/dist/dom/selection.js +133 -79
- package/dist/dom/shape-attributes.js +9 -0
- package/dist/dom/shape-effects.js +14 -0
- package/dist/dom/shape-geometry.js +3 -0
- package/dist/dom/shape-layout.js +115 -116
- package/dist/dom/shared-backdrop.js +33 -25
- package/dist/dom/specular.js +116 -0
- package/dist/dom/ticker.js +28 -19
- package/dist/dom/tint-color.js +24 -0
- package/dist/dom/warm.js +63 -59
- package/dist/dom.js +591 -505
- package/dist/gpu/geometry.js +2 -3
- package/dist/gpu/maps.js +1109 -7
- package/dist/gpu/planes.js +2 -3
- package/dist/gpu.js +66 -64
- package/dist/index.js +12 -10
- package/dist/react/button.js +12 -11
- package/dist/react/color-picker.js +199 -0
- package/dist/react/control-thumb.js +4 -5
- package/dist/react/menu.js +82 -111
- package/dist/react/merged-ref.js +1 -2
- package/dist/react/progressive.js +1 -2
- package/dist/react/scene.js +71 -55
- package/dist/react/shape.js +67 -47
- package/dist/react/slider.js +81 -0
- package/dist/react/surface.js +90 -56
- package/dist/react/switch.js +101 -0
- package/dist/react/tabs.js +85 -63
- package/dist/react/toolbar.js +38 -123
- package/dist/react/value-control-motion.js +1 -2
- package/dist/styles.css +517 -111
- package/dist/types/core/concentric.d.ts +8 -0
- package/dist/types/core/corner-options.d.ts +4 -0
- package/dist/types/core/corner-path.d.ts +8 -0
- package/dist/types/core/index.d.ts +3 -5
- package/dist/types/core/materials.d.ts +100 -28
- package/dist/types/core/shape.d.ts +4 -6
- package/dist/types/core/spring.d.ts +8 -12
- package/dist/types/dom/backdrop-glass.d.ts +38 -0
- package/dist/types/dom/compose-layers.d.ts +4 -0
- package/dist/types/dom/composited.d.ts +61 -0
- package/dist/types/dom/escaped-layers.d.ts +32 -0
- package/dist/types/dom/filter-bounds.d.ts +4 -0
- package/dist/types/dom/filter-chain.d.ts +6 -0
- package/dist/types/dom/filter-groups.d.ts +1 -1
- package/dist/types/dom/filter-paint-root.d.ts +3 -0
- package/dist/types/dom/filter-patch.d.ts +5 -0
- package/dist/types/dom/filter-reach.d.ts +9 -9
- package/dist/types/dom/foreground.d.ts +2 -1
- package/dist/types/dom/index.d.ts +8 -19
- package/dist/types/dom/interaction.d.ts +8 -8
- package/dist/types/dom/layout-rect.d.ts +17 -0
- package/dist/types/dom/layout-size.d.ts +11 -0
- package/dist/types/dom/lens-layers.d.ts +18 -10
- package/dist/types/dom/map-encoder.d.ts +5 -2
- package/dist/types/dom/map-encoding.d.ts +12 -3
- package/dist/types/dom/map-image.d.ts +7 -1
- package/dist/types/dom/maps.d.ts +25 -7
- package/dist/types/dom/material-graph.d.ts +73 -10
- package/dist/types/dom/media-mirror.d.ts +49 -0
- package/dist/types/dom/progressive.d.ts +2 -5
- package/dist/types/dom/sampling-bounds.d.ts +1 -3
- package/dist/types/dom/selection.d.ts +29 -4
- package/dist/types/dom/shape-attributes.d.ts +6 -0
- package/dist/types/dom/shape-effects.d.ts +10 -0
- package/dist/types/dom/shape-geometry.d.ts +6 -0
- package/dist/types/dom/shape-layout.d.ts +2 -4
- package/dist/types/dom/shared-backdrop.d.ts +7 -3
- package/dist/types/dom/specular.d.ts +50 -0
- package/dist/types/dom/ticker.d.ts +4 -1
- package/dist/types/dom/tint-color.d.ts +11 -0
- package/dist/types/dom/warm.d.ts +8 -2
- package/dist/types/gpu/geometry.d.ts +2 -0
- package/dist/types/gpu/planes.d.ts +3 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/react/button.d.ts +1 -1
- package/dist/types/react/color-picker.d.ts +26 -0
- package/dist/types/react/index.d.ts +14 -10
- package/dist/types/react/menu.d.ts +4 -5
- package/dist/types/react/progressive.d.ts +1 -1
- package/dist/types/react/scene.d.ts +4 -2
- package/dist/types/react/shape.d.ts +11 -1
- package/dist/types/react/slider.d.ts +14 -0
- package/dist/types/react/surface.d.ts +11 -22
- package/dist/types/react/switch.d.ts +9 -0
- package/dist/types/react/tabs.d.ts +3 -3
- package/dist/types/react/toolbar.d.ts +1 -1
- package/package.json +46 -40
- package/dist/core/morph-path.js +0 -206
- package/dist/core/union.js +0 -117
- package/dist/dom/compound-field.js +0 -23
- package/dist/dom/exit-handoff.js +0 -14
- package/dist/dom/map-blend.js +0 -8
- package/dist/dom/morph.js +0 -296
- package/dist/react/value-controls.js +0 -176
- package/dist/types/core/morph-path.d.ts +0 -110
- package/dist/types/core/union.d.ts +0 -20
- package/dist/types/dom/compound-field.d.ts +0 -35
- package/dist/types/dom/exit-handoff.d.ts +0 -7
- package/dist/types/dom/map-blend.d.ts +0 -22
- package/dist/types/dom/morph.d.ts +0 -78
- package/dist/types/react/value-controls.d.ts +0 -20
package/dist/dom/progressive.js
CHANGED
|
@@ -1,50 +1,51 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { physicalEdge as e, scrollEdgeStrength as t, validateProgressive as n } from "../core/progressive.js";
|
|
2
|
+
import { boundsMeet as r } from "./filter-bounds.js";
|
|
3
|
+
import { filterBudgetFactor as i, filterGraphOutsets as a, outsetBudget as o } from "./filter-budget.js";
|
|
4
|
+
import { padRepaintReach as s, repaintReach as c } from "./filter-reach.js";
|
|
5
|
+
import { filterPixelRatio as l, pageZoom as u, untiledOutsets as d } from "./page-zoom.js";
|
|
6
|
+
import { filterPrimitiveCount as f } from "./filter-stages.js";
|
|
7
|
+
import { gecko as p, webkit as m } from "./engine.js";
|
|
8
|
+
import { acquireFilterPaintRoot as h } from "./filter-paint-root.js";
|
|
9
|
+
import { patchFilters as g } from "./filter-patch.js";
|
|
10
|
+
import { pngDataUrlSync as _ } from "./png.js";
|
|
11
|
+
// src/dom/progressive.ts
|
|
12
|
+
var v = m ? "webkit" : p ? "gecko" : "chromium", y = 0, b = "http://www.w3.org/2000/svg", x = 6, S = (e) => e * e * (3 - 2 * e), C = (e) => .5 - Math.sin(Math.asin(1 - 2 * Math.max(0, Math.min(1, e))) / 3), w = (e, t) => Math.max(0, 1 - Math.abs(x * S(Math.max(0, Math.min(1, t))) - e)), T = (e, t) => Math.min(1, Math.max(0, e + 1 - x * S(Math.max(0, Math.min(1, t))))), E = Array.from({ length: 7 }, (e, t) => [C((t - 1) / x), C((t + 1) / x)]), D = (e) => {
|
|
13
|
+
let t = e / x;
|
|
13
14
|
return 3.92 * t * (1 - t);
|
|
14
15
|
};
|
|
15
|
-
function
|
|
16
|
+
function O(e) {
|
|
16
17
|
let t = 1 / (1 + .3275911 * Math.abs(e) / Math.SQRT2), n = 1 - ((((1.061405429 * t - 1.453152027) * t + 1.421413741) * t - .284496736) * t + .254829592) * t * Math.exp(-e * e / 2);
|
|
17
18
|
return e < 0 ? (1 - n) / 2 : (1 + n) / 2;
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
+
function k(e) {
|
|
20
21
|
let t = -8, n = 8;
|
|
21
22
|
for (let r = 0; r < 48; r++) {
|
|
22
23
|
let r = (t + n) / 2;
|
|
23
|
-
|
|
24
|
+
O(r) < e ? t = r : n = r;
|
|
24
25
|
}
|
|
25
26
|
return (t + n) / 2;
|
|
26
27
|
}
|
|
27
|
-
var
|
|
28
|
-
let
|
|
29
|
-
return Number(
|
|
30
|
-
}).join(" ")),
|
|
31
|
-
function
|
|
32
|
-
let t =
|
|
28
|
+
var A = (e) => Array.from({ length: 7 }, (t, n) => Array.from({ length: 65 }, (t, r) => {
|
|
29
|
+
let i = r / 64, a = i <= 0 ? 0 : i >= 1 ? 1 : .5 + k(i) / 6;
|
|
30
|
+
return Number(e(n, a).toFixed(4));
|
|
31
|
+
}).join(" ")), j = A(w), M = A(T), N = 64, P = /* @__PURE__ */ new Map();
|
|
32
|
+
function F(e) {
|
|
33
|
+
let t = P.get(e);
|
|
33
34
|
if (t) return t;
|
|
34
|
-
let [, n, r] = e.split(":"), i = Number(r), [
|
|
35
|
-
for (let e = 0; e <
|
|
36
|
-
let t = (e + .5) /
|
|
37
|
-
|
|
35
|
+
let [, n, r] = e.split(":"), i = Number(r), [a, o] = E[i], s = n === "top" || n === "bottom", c = n === "top" || n === "left", l = /* @__PURE__ */ new Uint8Array(256);
|
|
36
|
+
for (let e = 0; e < N; e++) {
|
|
37
|
+
let t = (e + .5) / N, n = c ? o - t * (o - a) : a + t * (o - a);
|
|
38
|
+
l.set([
|
|
38
39
|
255,
|
|
39
40
|
255,
|
|
40
41
|
255,
|
|
41
|
-
Math.round(255 *
|
|
42
|
+
Math.round(255 * T(i, n))
|
|
42
43
|
], e * 4);
|
|
43
44
|
}
|
|
44
|
-
let
|
|
45
|
-
return
|
|
45
|
+
let u = _(s ? 1 : N, s ? N : 1, l);
|
|
46
|
+
return P.set(e, u), u;
|
|
46
47
|
}
|
|
47
|
-
var
|
|
48
|
+
var I = (e) => {
|
|
48
49
|
let t = Math.floor(e.x), n = Math.floor(e.y);
|
|
49
50
|
return {
|
|
50
51
|
x: t,
|
|
@@ -52,33 +53,33 @@ var M = (e) => {
|
|
|
52
53
|
width: Math.ceil(e.x + e.width) - t,
|
|
53
54
|
height: Math.ceil(e.y + e.height) - n
|
|
54
55
|
};
|
|
55
|
-
},
|
|
56
|
+
}, L = (e) => `x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}"`, R = (e, t) => ({
|
|
56
57
|
x: e.x - t,
|
|
57
58
|
y: e.y - t,
|
|
58
59
|
width: e.width + 2 * t,
|
|
59
60
|
height: e.height + 2 * t
|
|
60
61
|
});
|
|
61
|
-
function
|
|
62
|
+
function z(e, t, n) {
|
|
62
63
|
switch (e.edge) {
|
|
63
|
-
case "bottom": return
|
|
64
|
+
case "bottom": return I({
|
|
64
65
|
x: e.x,
|
|
65
66
|
y: e.y + t * e.height,
|
|
66
67
|
width: e.width,
|
|
67
68
|
height: (n - t) * e.height
|
|
68
69
|
});
|
|
69
|
-
case "top": return
|
|
70
|
+
case "top": return I({
|
|
70
71
|
x: e.x,
|
|
71
72
|
y: e.y + (1 - n) * e.height,
|
|
72
73
|
width: e.width,
|
|
73
74
|
height: (n - t) * e.height
|
|
74
75
|
});
|
|
75
|
-
case "right": return
|
|
76
|
+
case "right": return I({
|
|
76
77
|
x: e.x + t * e.width,
|
|
77
78
|
y: e.y,
|
|
78
79
|
width: (n - t) * e.width,
|
|
79
80
|
height: e.height
|
|
80
81
|
});
|
|
81
|
-
case "left": return
|
|
82
|
+
case "left": return I({
|
|
82
83
|
x: e.x + (1 - n) * e.width,
|
|
83
84
|
y: e.y,
|
|
84
85
|
width: (n - t) * e.width,
|
|
@@ -86,100 +87,105 @@ function F(e, t, n) {
|
|
|
86
87
|
});
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
a.push(`<feFlood flood-color="#fff" ${N(F(e, .5, 1.5))} result="${t}step"/>`, `<feGaussianBlur in="${t}step" stdDeviation="${o ? `0 ${n}` : `${n} 0`}" ${N(M(e))} result="${t}ramp"/>`);
|
|
90
|
+
function B(e, t, n, r, i) {
|
|
91
|
+
let a = r === "webkit", o = r !== "gecko", s = [], c = e.edge === "top" || e.edge === "bottom", l = e.edge === "bottom" || e.edge === "right" ? -1 : 1, u = c ? e.height : e.width;
|
|
92
|
+
if (!a) {
|
|
93
|
+
let n = u / 6;
|
|
94
|
+
s.push(`<feFlood flood-color="#fff" ${L(z(e, .5, 1.5))} result="${t}step"/>`, `<feGaussianBlur in="${t}step" stdDeviation="${c ? `0 ${n}` : `${n} 0`}" ${L(I(e))} result="${t}ramp"/>`);
|
|
95
95
|
}
|
|
96
|
-
let
|
|
97
|
-
for (let
|
|
98
|
-
let
|
|
99
|
-
if (
|
|
100
|
-
let e = (
|
|
101
|
-
|
|
96
|
+
let d = [], f = [];
|
|
97
|
+
for (let r = 0; r <= x; r++) {
|
|
98
|
+
let u = z(e, E[r][0], E[r][1]), p = ` ${L(r === 0 && i ? i : u)}`, m = e.blur * (r / x) ** 2, h = n, g = e.refraction * D(r);
|
|
99
|
+
if (g > .01) {
|
|
100
|
+
let e = (g * l).toFixed(3);
|
|
101
|
+
s.push(`<feOffset in="${n}" dx="${c ? 0 : e}" dy="${c ? e : 0}" ${L(R(u, Math.ceil(3 * m) + 1))} result="${t}shift${r}"/>`), h = `${t}shift${r}`;
|
|
102
102
|
}
|
|
103
|
-
|
|
103
|
+
r && (s.push(`<feGaussianBlur in="${h}" stdDeviation="${m}" ${L(u)} result="${t}blur${r}"/>`), h = `${t}blur${r}`);
|
|
104
|
+
let _ = !o || r < x;
|
|
105
|
+
if (_ && s.push(a ? `<feImage data-map="pg:${e.edge}:${r}" preserveAspectRatio="none" ${L(u)} result="${t}weight${r}"/>` : `<feComponentTransfer in="${t}ramp"${p} result="${t}weight${r}"><feFuncA type="table" tableValues="${(o ? M : j)[r]}"/></feComponentTransfer>`), _) {
|
|
106
|
+
let e = `${t}${o && r ? "covered" : "part"}${r}`;
|
|
107
|
+
s.push(`<feComposite in="${h}" in2="${t}weight${r}" operator="in"${p} result="${e}"/>`), h = e;
|
|
108
|
+
}
|
|
109
|
+
o && r && s.push(`<feComposite in="${h}" in2="${t}weight${r - 1}" operator="out"${p} result="${t}part${r}"/>`), (r % 2 ? f : d).push(`${t}part${r}`);
|
|
104
110
|
}
|
|
105
111
|
return {
|
|
106
|
-
markup:
|
|
107
|
-
even:
|
|
108
|
-
odd:
|
|
112
|
+
markup: s,
|
|
113
|
+
even: d,
|
|
114
|
+
odd: f
|
|
109
115
|
};
|
|
110
116
|
}
|
|
111
|
-
function
|
|
112
|
-
let
|
|
113
|
-
x: -
|
|
114
|
-
y: -
|
|
115
|
-
width: n + 2 *
|
|
116
|
-
height:
|
|
117
|
-
},
|
|
118
|
-
if (
|
|
117
|
+
function V(e, t, n, i, a = v) {
|
|
118
|
+
let o = Math.max(256, ...t.map((e) => Math.ceil((e.edge === "top" || e.edge === "bottom" ? e.height : e.width) / 2 + 3 * e.blur + e.refraction + 8))), s = {
|
|
119
|
+
x: -o,
|
|
120
|
+
y: -o,
|
|
121
|
+
width: n + 2 * o,
|
|
122
|
+
height: i + 2 * o
|
|
123
|
+
}, c = [], l = (e, t, n) => `<feMerge result="${t}"${n ? ` ${L(n)}` : ""}>${e.map((e) => `<feMergeNode in="${e}"/>`).join("")}</feMerge>`, u = (e, t, n, r) => a === "gecko" ? `<feComposite in="${e}" in2="${t}" operator="arithmetic" k2="1" k3="1"${r ? ` ${L(r)}` : ""} result="${n}"/>` : `<feComposite in="${e}" in2="${t}" operator="lighter"${r ? ` ${L(r)}` : ""} result="${n}"/>`;
|
|
124
|
+
if (a === "gecko") {
|
|
119
125
|
let e = "SourceGraphic";
|
|
120
126
|
t.forEach((t, n) => {
|
|
121
|
-
let r = `e${n}`, { markup: i, even:
|
|
122
|
-
|
|
127
|
+
let r = `e${n}`, { markup: i, even: o, odd: d } = B(t, r, e, a, s);
|
|
128
|
+
c.push(...i, l(o, `${r}even`, s), l(d, `${r}odd`, I(t)), u(`${r}even`, `${r}odd`, `${r}result`, s)), e = `${r}result`;
|
|
123
129
|
});
|
|
124
130
|
} else {
|
|
125
|
-
let e = t.every((e, n) => t.every((t,
|
|
131
|
+
let e = t.every((e, n) => t.every((t, i) => n === i || !r(I(e), I(t)))) ? [t] : t.map((e) => [e]), n = "SourceGraphic";
|
|
126
132
|
e.forEach((e, r) => {
|
|
127
|
-
let
|
|
133
|
+
let i = [], o = [];
|
|
128
134
|
e.forEach((e) => {
|
|
129
|
-
let r = `e${t.indexOf(e)}`, { markup:
|
|
130
|
-
|
|
135
|
+
let r = `e${t.indexOf(e)}`, { markup: s, even: d, odd: f } = B(e, r, n, a);
|
|
136
|
+
c.push(...s, `<feFlood flood-color="#fff" ${L(I(e))} result="${r}area"/>`, l(d, `${r}even`, I(e)), l(f, `${r}odd`, I(e)), u(`${r}even`, `${r}odd`, `${r}result`, I(e))), i.push(`${r}result`), o.push(`${r}area`);
|
|
131
137
|
});
|
|
132
|
-
let
|
|
133
|
-
o.length > 1 &&
|
|
138
|
+
let s = `g${r}`;
|
|
139
|
+
o.length > 1 && c.push(l(o, `${s}areas`)), c.push(`<feComposite in="${n}" in2="${o.length > 1 ? `${s}areas` : o[0]}" operator="out" result="${s}outside"/>`, l([`${s}outside`, ...i], `${s}result`)), n = `${s}result`;
|
|
134
140
|
});
|
|
135
141
|
}
|
|
136
|
-
return `<filter id="${e}" x="${-
|
|
142
|
+
return `<filter id="${e}" x="${-o / n}" y="${-o / i}" width="${1 + 2 * o / n}" height="${1 + 2 * o / i}" filterUnits="objectBoundingBox" primitiveUnits="userSpaceOnUse" color-interpolation-filters="sRGB">${c.join("")}</filter>`;
|
|
137
143
|
}
|
|
138
|
-
function
|
|
139
|
-
let x = document.createElementNS(
|
|
144
|
+
function H(r, _, v = !1) {
|
|
145
|
+
let x = document.createElementNS(b, "svg");
|
|
140
146
|
x.setAttribute("aria-hidden", "true"), x.setAttribute("width", "0"), x.setAttribute("height", "0"), x.style.cssText = "position:absolute;pointer-events:none;overflow:hidden";
|
|
141
|
-
let S = document.createElementNS(
|
|
142
|
-
x.append(S),
|
|
143
|
-
let C = `lg-progressive-${++
|
|
144
|
-
function
|
|
145
|
-
e.style.filter === t.applied && (e.style.filter = t.original), t.layer.dispose(), t.releasePaint?.(),
|
|
147
|
+
let S = document.createElementNS(b, "defs");
|
|
148
|
+
x.append(S), r.ownerDocument.body.append(x);
|
|
149
|
+
let C = `lg-progressive-${++y}`, w = /* @__PURE__ */ new Set(), T = /* @__PURE__ */ new Set(), E = 0, D = 1, O = !1, k = "", A = 0, j = /* @__PURE__ */ new Map();
|
|
150
|
+
function M(e, t) {
|
|
151
|
+
e.style.filter === t.applied && (e.style.filter = t.original), t.layer.dispose(), t.releasePaint?.(), j.delete(e);
|
|
146
152
|
}
|
|
147
|
-
function
|
|
148
|
-
let
|
|
149
|
-
for (let
|
|
150
|
-
let r = typeof
|
|
153
|
+
function N(e) {
|
|
154
|
+
let t = /* @__PURE__ */ new Map();
|
|
155
|
+
for (let n of T) {
|
|
156
|
+
let r = typeof n.target == "function" ? n.target() : n.target;
|
|
151
157
|
if (r === e) continue;
|
|
152
158
|
let i = r;
|
|
153
159
|
if (!i) continue;
|
|
154
|
-
let a =
|
|
155
|
-
a.push(
|
|
160
|
+
let a = t.get(i) ?? [];
|
|
161
|
+
a.push(n), t.set(i, a);
|
|
156
162
|
}
|
|
157
|
-
for (let [e,
|
|
158
|
-
let
|
|
159
|
-
for (let [e, i] of
|
|
160
|
-
let
|
|
161
|
-
|
|
162
|
-
layer:
|
|
163
|
+
for (let [e, n] of j) t.has(e) || M(e, n);
|
|
164
|
+
let n = 0;
|
|
165
|
+
for (let [e, i] of t) {
|
|
166
|
+
let t = j.get(e);
|
|
167
|
+
t || (t = {
|
|
168
|
+
layer: H(r, _, !0),
|
|
163
169
|
options: [],
|
|
164
170
|
remove: [],
|
|
165
171
|
original: e.style.filter,
|
|
166
|
-
releasePaint:
|
|
172
|
+
releasePaint: m ? h(e) : void 0,
|
|
167
173
|
applied: e.style.filter
|
|
168
|
-
},
|
|
169
|
-
let
|
|
170
|
-
e.style.filter !==
|
|
174
|
+
}, j.set(e, t)), (i.length !== t.options.length || i.some((e, n) => e !== t.options[n])) && (t.remove.forEach((e) => e()), t.remove = i.map((e) => t.layer.addScroll(e)), t.options = i);
|
|
175
|
+
let a = t.layer.update(e), o = [t.original, a].filter(Boolean).join(" ");
|
|
176
|
+
e.style.filter !== o && (e.style.filter = o), t.applied = o, n += t.layer.count();
|
|
171
177
|
}
|
|
172
|
-
return
|
|
178
|
+
return n;
|
|
173
179
|
}
|
|
174
|
-
let
|
|
175
|
-
|
|
180
|
+
let P = matchMedia("(prefers-reduced-transparency: reduce)"), I = matchMedia("(forced-colors: active)"), L = "", R = "", z = 0, B = [], U, W = 0, G = (e) => {
|
|
181
|
+
r.dataset.glassBlurEdges !== e && (r.dataset.glassBlurEdges = e);
|
|
176
182
|
};
|
|
177
183
|
function K() {
|
|
178
|
-
|
|
184
|
+
B = [], L && g(S, [], F), L = "", R = "", z = 0, U = void 0, W = 0, v || G("0");
|
|
179
185
|
}
|
|
180
186
|
let q = () => w.size + [...T].reduce((e, t) => e + new Set(t.edges ?? ["top", "bottom"]).size, 0);
|
|
181
187
|
function J(e) {
|
|
182
|
-
if (
|
|
188
|
+
if (n(e.options), q() >= 64) throw RangeError("A GlassScene supports at most 64 progressive blur regions.");
|
|
183
189
|
return w.add(e), () => {
|
|
184
190
|
w.delete(e);
|
|
185
191
|
};
|
|
@@ -193,24 +199,24 @@ function z(a, _, b = !1) {
|
|
|
193
199
|
},
|
|
194
200
|
addScroll(e) {
|
|
195
201
|
let t = [...new Set(e.edges ?? ["top", "bottom"])];
|
|
196
|
-
if (
|
|
197
|
-
if (!
|
|
202
|
+
if (n(e), t.forEach((e) => n({ edge: e })), q() + t.length > 64) throw RangeError("A GlassScene supports at most 64 progressive blur regions.");
|
|
203
|
+
if (!v) return T.add(e), () => {
|
|
198
204
|
T.delete(e);
|
|
199
205
|
};
|
|
200
|
-
let
|
|
206
|
+
let r = t.map((t) => J({
|
|
201
207
|
options: {
|
|
202
208
|
...e,
|
|
203
209
|
edge: t
|
|
204
210
|
},
|
|
205
211
|
target: e.target
|
|
206
212
|
}));
|
|
207
|
-
return () =>
|
|
213
|
+
return () => r.forEach((e) => e());
|
|
208
214
|
},
|
|
209
215
|
count() {
|
|
210
|
-
return
|
|
216
|
+
return z;
|
|
211
217
|
},
|
|
212
218
|
regions() {
|
|
213
|
-
return
|
|
219
|
+
return B;
|
|
214
220
|
},
|
|
215
221
|
operations() {
|
|
216
222
|
return W;
|
|
@@ -222,13 +228,13 @@ function z(a, _, b = !1) {
|
|
|
222
228
|
return O;
|
|
223
229
|
},
|
|
224
230
|
error() {
|
|
225
|
-
return U ?? [...
|
|
231
|
+
return U ?? [...j.values()].map((e) => e.layer.error()).find(Boolean);
|
|
226
232
|
},
|
|
227
|
-
update(
|
|
233
|
+
update(n) {
|
|
228
234
|
E = 0;
|
|
229
|
-
let
|
|
230
|
-
|
|
231
|
-
let _ = [...T].filter((e) => (typeof e.target == "function" ? e.target() : e.target) ===
|
|
235
|
+
let h = v ? 0 : N(n);
|
|
236
|
+
v || G(String(h));
|
|
237
|
+
let _ = [...T].filter((e) => (typeof e.target == "function" ? e.target() : e.target) === n).flatMap((e) => [...new Set(e.edges ?? ["top", "bottom"])].map((t) => ({
|
|
232
238
|
options: {
|
|
233
239
|
...e,
|
|
234
240
|
edge: t
|
|
@@ -236,38 +242,38 @@ function z(a, _, b = !1) {
|
|
|
236
242
|
target: e.target
|
|
237
243
|
})));
|
|
238
244
|
O = _.length > 0;
|
|
239
|
-
let
|
|
240
|
-
if (!
|
|
241
|
-
let
|
|
242
|
-
if (!x || !
|
|
243
|
-
let
|
|
244
|
-
for (let { element:
|
|
245
|
-
if (
|
|
246
|
-
let
|
|
247
|
-
if (
|
|
248
|
-
let
|
|
249
|
-
if (
|
|
250
|
-
let e =
|
|
251
|
-
|
|
245
|
+
let y = [...w, ..._];
|
|
246
|
+
if (!n || P.matches || I.matches || !y.length) return (L || R) && K(), v || G(String(h)), "";
|
|
247
|
+
let b = n.getBoundingClientRect(), x = n.offsetWidth, j = n.offsetHeight;
|
|
248
|
+
if (!x || !j || !b.width || !b.height) return K(), "";
|
|
249
|
+
let M = x / b.width, H = j / b.height, q = [];
|
|
250
|
+
for (let { element: n, options: i, target: a } of y) {
|
|
251
|
+
if (i.disabled || !(i.size ?? 80) || !(i.blur ?? 20) && !(i.refraction ?? 0)) continue;
|
|
252
|
+
let o = typeof a == "function" ? a() : a;
|
|
253
|
+
if (a && !o) continue;
|
|
254
|
+
let s = getComputedStyle(o ?? r).direction === "rtl", c = e(i.edge ?? "bottom", s), l = c === "top" || c === "bottom", u = n?.getBoundingClientRect(), d = 1;
|
|
255
|
+
if (o) {
|
|
256
|
+
let e = o.clientWidth, n = o.clientHeight, r = o.getBoundingClientRect(), a = r.width / (o.offsetWidth || 1), f = r.height / (o.offsetHeight || 1), p = r.left + o.clientLeft * a, m = r.top + o.clientTop * f, h = Math.min(i.size ?? 80, (l ? n : e) / 2);
|
|
257
|
+
d = t(c, o.scrollLeft, o.scrollTop, Math.max(0, o.scrollWidth - e), Math.max(0, o.scrollHeight - n), s, h), u = new DOMRect(c === "right" ? p + (e - h) * a : p, c === "bottom" ? m + (n - h) * f : m, (l ? e : h) * a, (l ? h : n) * f);
|
|
252
258
|
}
|
|
253
|
-
if (!
|
|
254
|
-
let f =
|
|
255
|
-
m <= f || h <= p ||
|
|
256
|
-
edge:
|
|
257
|
-
x: (f -
|
|
258
|
-
y: (p -
|
|
259
|
-
width: (m - f) *
|
|
260
|
-
height: (h - p) *
|
|
261
|
-
blur: (
|
|
262
|
-
refraction: (
|
|
259
|
+
if (!u || !d || u.bottom < 0 || u.top > innerHeight || u.right < 0 || u.left > innerWidth) continue;
|
|
260
|
+
let f = l ? Math.max(u.left, b.left) : u.left, p = l ? u.top : Math.max(u.top, b.top), m = l ? Math.min(u.right, b.right) : u.right, h = l ? u.bottom : Math.min(u.bottom, b.bottom);
|
|
261
|
+
m <= f || h <= p || u.bottom <= b.top || u.top >= b.bottom || u.right <= b.left || u.left >= b.right || q.push({
|
|
262
|
+
edge: c,
|
|
263
|
+
x: (f - b.left) * M,
|
|
264
|
+
y: (p - b.top) * H,
|
|
265
|
+
width: (m - f) * M,
|
|
266
|
+
height: (h - p) * H,
|
|
267
|
+
blur: (i.blur ?? 20) * d,
|
|
268
|
+
refraction: (i.refraction ?? 0) * d
|
|
263
269
|
});
|
|
264
270
|
}
|
|
265
|
-
if (
|
|
266
|
-
let J =
|
|
267
|
-
if (
|
|
271
|
+
if (B = q, !q.length) return (L || R) && K(), v || G(String(h)), "";
|
|
272
|
+
let J = l();
|
|
273
|
+
if (m) {
|
|
268
274
|
let e = JSON.stringify([
|
|
269
275
|
x,
|
|
270
|
-
|
|
276
|
+
j,
|
|
271
277
|
...q.map((e) => [
|
|
272
278
|
e.edge,
|
|
273
279
|
e.width,
|
|
@@ -276,24 +282,23 @@ function z(a, _, b = !1) {
|
|
|
276
282
|
e.refraction
|
|
277
283
|
])
|
|
278
284
|
]);
|
|
279
|
-
e !== k && (k = e, A =
|
|
280
|
-
let t = A * J,
|
|
281
|
-
if (E = t *
|
|
285
|
+
e !== k && (k = e, A = a(V(C, q, x, j)));
|
|
286
|
+
let t = A * J, n = i(x * J, j * J, t);
|
|
287
|
+
if (E = t * n / J, n < 1) for (let e of q) e.blur *= n, e.refraction *= n;
|
|
282
288
|
}
|
|
283
|
-
let Y =
|
|
284
|
-
if (
|
|
285
|
-
let e = E >
|
|
286
|
-
t > E && (Y =
|
|
289
|
+
let Y = V(C, q, x, j);
|
|
290
|
+
if (m) {
|
|
291
|
+
let e = E > d(x, j) / 2, t = Math.min((e ? 2 : 1) * c(Y, x, j), o(x * J, j * J) / J / 2, e ? Infinity : d(x, j, .85) / 2);
|
|
292
|
+
t > E && (Y = s(Y, Math.floor(t), x, j, E === A ? A : void 0), E = a(Y));
|
|
287
293
|
}
|
|
288
|
-
let X =
|
|
289
|
-
return (Y !== L || X !== D) && (L = Y, D = X,
|
|
294
|
+
let X = u();
|
|
295
|
+
return (Y !== L || X !== D) && (L = Y, D = X, z = q.length, W = p ? f(Y) : 0, U = W > 64 ? /* @__PURE__ */ RangeError(`Progressive blur requires ${W} filter operations; this browser supports 64 per element.`) : void 0, R = `url("#${g(S, [Y], F)(C)}")`), v || G(String(h + q.length)), R;
|
|
290
296
|
},
|
|
291
297
|
dispose() {
|
|
292
298
|
w.clear(), T.clear();
|
|
293
|
-
for (let [e, t] of
|
|
294
|
-
x.remove(),
|
|
299
|
+
for (let [e, t] of j) M(e, t);
|
|
300
|
+
x.remove(), v || delete r.dataset.glassBlurEdges;
|
|
295
301
|
}
|
|
296
302
|
};
|
|
297
303
|
}
|
|
298
|
-
|
|
299
|
-
export { z as createProgressiveLayer, j as maskUrl, R as progressiveGraph, O as rampTables };
|
|
304
|
+
export { M as coverTables, H as createProgressiveLayer, F as maskUrl, V as progressiveGraph, j as rampTables };
|
package/dist/dom/renderer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/dom/sampling-bounds.ts
|
|
2
2
|
function e(e, t, n = !1) {
|
|
3
3
|
let r = Math.abs(t), i = (e) => !n || t < 0 ? r + 3 : Math.min(r, Math.max(0, r - e / 2) + r / 255) + 3, a = i(e.width), o = i(e.height);
|
|
4
4
|
return {
|
|
@@ -18,5 +18,4 @@ function t(e) {
|
|
|
18
18
|
height: Math.max(...e.map((e) => e.y + e.height)) - n
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
//#endregion
|
|
22
21
|
export { e as refractionSamplingBounds, t as unionSamplingBounds };
|