@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/dom/filter-groups.ts
|
|
2
2
|
function e(e, t) {
|
|
3
3
|
return e.x - 2 < t.x + t.w + 2 && t.x - 2 < e.x + e.w + 2 && e.y - 2 < t.y + t.h + 2 && t.y - 2 < e.y + e.h + 2;
|
|
4
4
|
}
|
|
@@ -12,27 +12,46 @@ function n(e, t) {
|
|
|
12
12
|
height: Math.max(e.y + e.height, t.y + t.height) - r
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
function r(e, r, i) {
|
|
16
|
-
let
|
|
15
|
+
function r(e, r, i, a = Infinity) {
|
|
16
|
+
let o = [], s = (e) => t(e.crop) + i.sampled * t(e.sampled) + (i.output + (e.members.length > 1 ? 4 : 0)) * t(e.output) + e.images;
|
|
17
17
|
for (let i of e) {
|
|
18
|
-
let e = r(i),
|
|
18
|
+
let e = r(i), a = {
|
|
19
19
|
...e,
|
|
20
20
|
members: [i],
|
|
21
21
|
images: 4 * t(e.output)
|
|
22
22
|
}, c = -1, l = 0, u;
|
|
23
|
-
for (let [e, t] of
|
|
23
|
+
for (let [e, t] of o.entries()) {
|
|
24
24
|
let r = {
|
|
25
|
-
output: n(t.output,
|
|
26
|
-
crop: n(t.crop,
|
|
27
|
-
sampled: n(t.sampled,
|
|
25
|
+
output: n(t.output, a.output),
|
|
26
|
+
crop: n(t.crop, a.crop),
|
|
27
|
+
sampled: n(t.sampled, a.sampled),
|
|
28
28
|
members: [...t.members, i],
|
|
29
|
-
images: t.images +
|
|
30
|
-
},
|
|
31
|
-
|
|
29
|
+
images: t.images + a.images
|
|
30
|
+
}, o = s(t) + s(a) - s(r);
|
|
31
|
+
o > l && (c = e, l = o, u = r);
|
|
32
32
|
}
|
|
33
|
-
u ?
|
|
33
|
+
u ? o[c] = u : o.push(a);
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
let c = (e, t) => ({
|
|
36
|
+
output: n(e.output, t.output),
|
|
37
|
+
crop: n(e.crop, t.crop),
|
|
38
|
+
sampled: n(e.sampled, t.sampled),
|
|
39
|
+
members: [...e.members, ...t.members],
|
|
40
|
+
images: e.images + t.images
|
|
41
|
+
});
|
|
42
|
+
for (; o.length > Math.max(1, a);) {
|
|
43
|
+
let e, t = Infinity;
|
|
44
|
+
for (let n = 0; n < o.length; n++) for (let r = n + 1; r < o.length; r++) {
|
|
45
|
+
let i = c(o[n], o[r]), a = s(i) - s(o[n]) - s(o[r]);
|
|
46
|
+
a < t && (t = a, e = [
|
|
47
|
+
n,
|
|
48
|
+
r,
|
|
49
|
+
i
|
|
50
|
+
]);
|
|
51
|
+
}
|
|
52
|
+
let [n, r, i] = e;
|
|
53
|
+
o[n] = i, o.splice(r, 1);
|
|
54
|
+
}
|
|
55
|
+
return o.map((e) => e.members);
|
|
36
56
|
}
|
|
37
|
-
//#endregion
|
|
38
57
|
export { r as clusterFilterBranches, e as mapBoxesOverlap };
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
// src/dom/filter-paint-root.ts
|
|
2
2
|
var e = /* @__PURE__ */ new WeakMap();
|
|
3
3
|
function t(e) {
|
|
4
|
-
return
|
|
4
|
+
return i(e, "transform");
|
|
5
5
|
}
|
|
6
6
|
function n(e) {
|
|
7
|
-
return
|
|
7
|
+
return i(e, "opacity");
|
|
8
8
|
}
|
|
9
|
-
function r(
|
|
9
|
+
function r(e) {
|
|
10
|
+
return i(e, "transform");
|
|
11
|
+
}
|
|
12
|
+
function i(t, n) {
|
|
10
13
|
let r = e.get(t);
|
|
11
14
|
if (!r) {
|
|
12
15
|
let n = t.style, i = t.ownerDocument.defaultView?.getComputedStyle(t).willChange ?? n.getPropertyValue("will-change");
|
|
@@ -37,5 +40,4 @@ function r(t, n) {
|
|
|
37
40
|
o ? r.hints.set(n, o) : r.hints.delete(n), i(), r.hints.size || e.delete(t);
|
|
38
41
|
};
|
|
39
42
|
}
|
|
40
|
-
|
|
41
|
-
export { t as acquireFilterPaintRoot, n as acquireSceneCompositingLayer };
|
|
43
|
+
export { t as acquireFilterPaintRoot, r as acquireRepaintLayer, n as acquireSceneCompositingLayer };
|
package/dist/dom/filter-patch.js
CHANGED
|
@@ -1,43 +1,63 @@
|
|
|
1
|
-
import { chromium as e } from "./engine.js";
|
|
2
|
-
import { pageZoom as
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { chromium as e, webkit as t } from "./engine.js";
|
|
2
|
+
import { pageZoom as n, zoomFilterMarkup as r } from "./page-zoom.js";
|
|
3
|
+
// src/dom/filter-patch.ts
|
|
4
|
+
var i = /* @__PURE__ */ new WeakMap(), a = "http://www.w3.org/2000/svg", o = 0, s = /* @__PURE__ */ new Set([
|
|
5
|
+
"k1",
|
|
6
|
+
"k2",
|
|
7
|
+
"k3",
|
|
8
|
+
"k4",
|
|
9
|
+
"slope",
|
|
10
|
+
"intercept",
|
|
11
|
+
"flood-opacity"
|
|
12
|
+
]);
|
|
13
|
+
function c(e) {
|
|
14
|
+
return e.includes("primitiveUnits=\"userSpaceOnUse\"") ? e.replace(/<fe\w+\b[^>]*>/g, (e) => e.replace(/\s(x|y|width|height|dx|dy|scale|k1|k2|k3|k4|slope|intercept|flood-opacity)="(-?[\d.]+(?:e-?\d+)?)"/g, (e, t, n) => {
|
|
15
|
+
let r = s.has(t) ? 1024 : 16, i = Math.round(Number(n) * r) / r;
|
|
16
|
+
return (t === "width" || t === "height") && Number(n) > 0 && (i = Math.max(i, 1 / r)), ` ${t}="${Object.is(i, -0) ? 0 : i}"`;
|
|
17
|
+
})) : e;
|
|
18
|
+
}
|
|
19
|
+
function l(a, s, l) {
|
|
20
|
+
let d = i.get(a);
|
|
21
|
+
d || (d = /* @__PURE__ */ new Map(), i.set(a, d));
|
|
22
|
+
let h = new Set(d.keys()), _ = /* @__PURE__ */ new Map(), y = [], b = n();
|
|
23
|
+
for (let n of s) {
|
|
24
|
+
let i = r(c(n), b), s = /\bid="([^"]+)"/.exec(i)?.[1];
|
|
25
|
+
if (!s) throw Error("A glass filter must have an id.");
|
|
26
|
+
h.delete(s);
|
|
27
|
+
let l = d.get(s);
|
|
28
|
+
if (l?.element.parentElement !== a && (l = void 0), l?.markup === i) {
|
|
29
|
+
_.set(s, l.id);
|
|
16
30
|
continue;
|
|
17
31
|
}
|
|
18
|
-
let
|
|
19
|
-
if (
|
|
20
|
-
let
|
|
21
|
-
|
|
32
|
+
let g = u(i);
|
|
33
|
+
if (l) {
|
|
34
|
+
let n = t && f(l.description, g), r = l.element.nextSibling;
|
|
35
|
+
n && l.element.remove();
|
|
36
|
+
let o = m(l, g, y);
|
|
37
|
+
n && a.insertBefore(l.element, r), l.markup = i, o && e && l.element.setAttribute("x", g.attributes.x);
|
|
22
38
|
} else {
|
|
23
|
-
let e = `${
|
|
24
|
-
t.element.setAttribute("data-filter",
|
|
39
|
+
let e = `${s}-${++o}`, t = p(a.ownerDocument, g, y);
|
|
40
|
+
t.element.setAttribute("data-filter", s), t.element.id = e, a.append(t.element), l = {
|
|
25
41
|
...t,
|
|
26
|
-
markup:
|
|
42
|
+
markup: i,
|
|
27
43
|
id: e
|
|
28
|
-
}, d.set(
|
|
44
|
+
}, d.set(s, l);
|
|
29
45
|
}
|
|
30
|
-
|
|
46
|
+
_.set(s, l.id);
|
|
31
47
|
}
|
|
32
|
-
for (let e of
|
|
33
|
-
let
|
|
34
|
-
for (let e of
|
|
35
|
-
let t =
|
|
36
|
-
t
|
|
48
|
+
for (let e of h) d.get(e).element.remove(), d.delete(e);
|
|
49
|
+
let x = !1, S = /* @__PURE__ */ new Set();
|
|
50
|
+
for (let e of y) {
|
|
51
|
+
let t = l(e.getAttribute("data-map"));
|
|
52
|
+
if (!t || e.getAttribute("href") === t) continue;
|
|
53
|
+
e.setAttribute("href", t), x = !0;
|
|
54
|
+
let n = e.parentElement;
|
|
55
|
+
for (; n && n.localName !== "filter";) n = n.parentElement;
|
|
56
|
+
n && S.add(n);
|
|
37
57
|
}
|
|
38
|
-
return
|
|
58
|
+
return x && e && v(a, [...S]), S.size && t && g([...d.values()].filter((e) => S.has(e.element))), (e) => _.get(e) ?? e;
|
|
39
59
|
}
|
|
40
|
-
function
|
|
60
|
+
function u(e) {
|
|
41
61
|
let t = [], n;
|
|
42
62
|
for (let r of e.matchAll(/<(\/?)([\w:-]+)([^>]*?)(\/?)>/g)) {
|
|
43
63
|
let [, e, i, a, o] = r;
|
|
@@ -80,39 +100,58 @@ function s(e) {
|
|
|
80
100
|
}
|
|
81
101
|
return n;
|
|
82
102
|
}
|
|
83
|
-
var
|
|
84
|
-
function
|
|
85
|
-
|
|
103
|
+
var d = (e, t) => e.attributes.result ?? `${e.tag}#${t}`;
|
|
104
|
+
function f(e, t) {
|
|
105
|
+
return e.tag !== t.tag || e.children.length !== t.children.length || e.attributes.in !== t.attributes.in || e.attributes.in2 !== t.attributes.in2 || e.children.some((e, n) => d(e, n) !== d(t.children[n], n) || f(e, t.children[n]));
|
|
106
|
+
}
|
|
107
|
+
function p(e, t, n) {
|
|
108
|
+
let r = e.createElementNS(a, t.tag);
|
|
86
109
|
for (let [e, n] of Object.entries(t.attributes)) r.setAttribute(e, n);
|
|
87
|
-
let
|
|
88
|
-
return t.children.forEach((t,
|
|
89
|
-
let o =
|
|
90
|
-
|
|
110
|
+
let i = /* @__PURE__ */ new Map();
|
|
111
|
+
return t.children.forEach((t, a) => {
|
|
112
|
+
let o = p(e, t, n);
|
|
113
|
+
i.set(d(t, a), o), r.append(o.element);
|
|
91
114
|
}), t.attributes["data-map"] && n.push(r), {
|
|
92
115
|
element: r,
|
|
93
116
|
description: t,
|
|
94
|
-
children:
|
|
117
|
+
children: i
|
|
95
118
|
};
|
|
96
119
|
}
|
|
97
|
-
function
|
|
120
|
+
function m(e, t, n) {
|
|
98
121
|
let r = e.description.attributes;
|
|
99
122
|
for (let [i, a] of Object.entries(t.attributes)) i !== "id" && r[i] !== a && (e.element.setAttribute(i, a), i === "data-map" && n.push(e.element));
|
|
100
123
|
for (let n of Object.keys(r)) n !== "id" && !(n in t.attributes) && e.element.removeAttribute(n);
|
|
101
|
-
let i = new Map(e.children), a = /* @__PURE__ */ new Map(), o = !1, s = new Map(t.children.map((e, t) => [
|
|
124
|
+
let i = new Map(e.children), a = /* @__PURE__ */ new Map(), o = !1, s = new Map(t.children.map((e, t) => [d(e, t), e.tag]));
|
|
102
125
|
for (let [e, t] of i) s.get(e) !== t.description.tag && (t.element.remove(), i.delete(e), o = !0);
|
|
103
|
-
let
|
|
126
|
+
let c = e.element.firstElementChild;
|
|
104
127
|
t.children.forEach((t, r) => {
|
|
105
|
-
let s =
|
|
106
|
-
|
|
128
|
+
let s = d(t, r), l = i.get(s);
|
|
129
|
+
l?.description.tag === t.tag ? (i.delete(s), o = m(l, t, n) || o) : (l = p(e.element.ownerDocument, t, n), o = !0), l.element !== c && (e.element.insertBefore(l.element, c), o = !0), c = l.element.nextElementSibling, a.set(s, l);
|
|
107
130
|
});
|
|
108
131
|
for (let e of i.values()) e.element.remove(), o = !0;
|
|
109
132
|
return e.description = t, e.children = a, o;
|
|
110
133
|
}
|
|
111
|
-
var
|
|
112
|
-
function
|
|
113
|
-
let t
|
|
114
|
-
|
|
115
|
-
|
|
134
|
+
var h = /* @__PURE__ */ new WeakMap();
|
|
135
|
+
function g(e) {
|
|
136
|
+
for (let t of e) {
|
|
137
|
+
let { element: e } = t, n = (h.get(e) ?? 0) + 1;
|
|
138
|
+
h.set(e, n);
|
|
139
|
+
let r = e.ownerDocument.defaultView, i = () => h.get(e) === n && e.isConnected, a = (n) => {
|
|
140
|
+
let r = t.description.attributes.x ?? "0";
|
|
141
|
+
e.setAttribute("x", n ? String(Number(r) + 1e-6) : r);
|
|
142
|
+
};
|
|
143
|
+
for (let e of [100, 250]) setTimeout(() => {
|
|
144
|
+
i() && (a(!0), r?.requestAnimationFrame(() => {
|
|
145
|
+
i() && a(!1);
|
|
146
|
+
}));
|
|
147
|
+
}, e);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
var _ = /* @__PURE__ */ new WeakMap();
|
|
151
|
+
function v(e, t) {
|
|
152
|
+
let n = (_.get(e) ?? 0) + 1;
|
|
153
|
+
_.set(e, n);
|
|
154
|
+
for (let r of [
|
|
116
155
|
16,
|
|
117
156
|
100,
|
|
118
157
|
300,
|
|
@@ -120,10 +159,10 @@ function f(e) {
|
|
|
120
159
|
1500,
|
|
121
160
|
3e3
|
|
122
161
|
]) setTimeout(() => {
|
|
123
|
-
if (
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
162
|
+
if (_.get(e) === n && e.isConnected) for (let e of t) {
|
|
163
|
+
let t = e.isConnected ? e.querySelector("feImage") : null;
|
|
164
|
+
t?.setAttribute("x", t.getAttribute("x"));
|
|
165
|
+
}
|
|
166
|
+
}, r);
|
|
127
167
|
}
|
|
128
|
-
|
|
129
|
-
export { o as patchFilters };
|
|
168
|
+
export { l as patchFilters, c as quantizeFilterMarkup };
|
package/dist/dom/filter-reach.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { filterGraphOutsets as e } from "./filter-budget.js";
|
|
2
|
+
// src/dom/filter-reach.ts
|
|
3
|
+
function t(e, t, n, r = []) {
|
|
3
4
|
let i = 0, a = (e) => {
|
|
4
5
|
i = Math.max(i, e.x, t - e.x - e.width, e.y, n - e.y - e.height);
|
|
5
6
|
};
|
|
@@ -14,23 +15,35 @@ function e(e, t, n, r = []) {
|
|
|
14
15
|
}
|
|
15
16
|
return r.forEach(a), i > 0 ? Math.ceil((i / 2 + 2) / 16) * 16 : 0;
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
-
let
|
|
19
|
-
if (
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
function n(t, n, i, a, o) {
|
|
19
|
+
let s = [...t.matchAll(/<feMerge[\s>]/g)].at(-1)?.index ?? -1;
|
|
20
|
+
if (s < 0 || n <= 0) return t;
|
|
21
|
+
let c = t.indexOf(">", s) + 1, l = o ?? e(t), u = r(t, i, a) ?? (2 * n >= Math.max(i, a) / 2 + 1 ? {
|
|
22
|
+
x: Math.floor(Math.max(0, i - 1) / 2),
|
|
23
|
+
y: Math.floor(Math.max(0, a - 1) / 2)
|
|
24
|
+
} : void 0), d = (e) => {
|
|
25
|
+
let n = 2 * Math.ceil(e);
|
|
26
|
+
if (!u) {
|
|
27
|
+
let n = `x="0" y="0" width="${i}" height="${a}"`, r = Math.min(e, Math.floor(i / 2)), o = Math.min(e, Math.floor(a / 2));
|
|
28
|
+
return t.slice(0, s) + `<feFlood flood-opacity="0" ${n} result="reach-seed"/><feOffset in="reach-seed" dx="${r}" dy="${o}" ${n} result="reach-after"/><feOffset in="reach-seed" dx="${-r}" dy="${-o}" ${n} result="reach-before"/>` + t.slice(s, c) + "<feMergeNode in=\"reach-after\"/><feMergeNode in=\"reach-before\"/>" + t.slice(c);
|
|
26
29
|
}
|
|
27
|
-
u =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
let r = `<feFlood flood-opacity="0" x="${u.x}" y="${u.y}" width="1" height="1" result="reach-seed"/><feDisplacementMap in="reach-seed" in2="reach-seed" scale="${n}" x="${u.x}" y="${u.y}" width="1" height="1" result="reach"/>`;
|
|
31
|
+
return t.slice(0, s) + r + t.slice(s, c) + "<feMergeNode in=\"reach\"/>" + t.slice(c);
|
|
32
|
+
}, f = l > 0 && l < n ? d(n - l) : void 0;
|
|
33
|
+
return f && e(f) >= n ? f : d(n);
|
|
34
|
+
}
|
|
35
|
+
function r(e, t, n) {
|
|
36
|
+
for (let [r] of e.matchAll(/<fe\w+\b[^>]*>/g)) {
|
|
37
|
+
let e = (e) => Number(RegExp(`\\s${e}="([-\\d.e]+)"`).exec(r)?.[1] ?? NaN), i = e("x"), a = e("y"), o = e("width"), s = e("height");
|
|
38
|
+
if (!(![
|
|
39
|
+
i,
|
|
40
|
+
a,
|
|
41
|
+
o,
|
|
42
|
+
s
|
|
43
|
+
].every(Number.isFinite) || o <= 0 || s <= 0) && !(i < 0 || a < 0 || i + o > t || a + s > n)) return {
|
|
44
|
+
x: Math.floor(i + Math.min(o, 1) / 2),
|
|
45
|
+
y: Math.floor(a + Math.min(s, 1) / 2)
|
|
46
|
+
};
|
|
31
47
|
}
|
|
32
|
-
return e.slice(0, o) + l + e.slice(o, s) + u.map((e) => `<feMergeNode in="${e}"/>`).join("") + e.slice(s);
|
|
33
48
|
}
|
|
34
|
-
|
|
35
|
-
//#endregion
|
|
36
|
-
export { t as padRepaintReach, e as repaintReach };
|
|
49
|
+
export { n as padRepaintReach, t as repaintReach };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { gecko as e } from "./engine.js";
|
|
2
|
-
|
|
2
|
+
// src/dom/filter-stages.ts
|
|
3
3
|
function t(e) {
|
|
4
4
|
return [...e.matchAll(/<fe(?!Func[RGBA]\b|MergeNode\b)[A-Z][\w]*\b/g)].length;
|
|
5
5
|
}
|
|
6
|
-
//#endregion
|
|
7
6
|
export { t as filterPrimitiveCount, e as gecko };
|
package/dist/dom/fixed-shape.js
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
|
-
import { cornerOptions as e
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { cornerOptions as e } from "../core/corner-options.js";
|
|
2
|
+
import { observeLayoutSize as t } from "./layout-size.js";
|
|
3
|
+
import { shapeClip as n } from "../core/shape.js";
|
|
4
|
+
// src/dom/fixed-shape.ts
|
|
5
|
+
function r(e) {
|
|
6
|
+
let t = getComputedStyle(e);
|
|
7
|
+
return t.borderTopStyle !== "none" && t.borderTopStyle !== "hidden" && parseFloat(t.borderTopWidth) > 0 || !!t.boxShadow && t.boxShadow !== "none";
|
|
8
|
+
}
|
|
9
|
+
function i(i, a) {
|
|
10
|
+
let o = e(a), s = i.style.clipPath, c, l, u = () => ({
|
|
11
|
+
x: i.offsetLeft,
|
|
12
|
+
y: i.offsetTop
|
|
13
|
+
}), d = !1;
|
|
14
|
+
r(i) && import("./shape-effects.js").then(({ createShapeEffects: e }) => {
|
|
15
|
+
d || (c = e(i), l && c.update(o, l.width, l.height, u()));
|
|
16
|
+
}, () => void 0);
|
|
17
|
+
let f = t(i, ({ width: e, height: t }) => {
|
|
18
|
+
e <= 0 || t <= 0 || (i.style.clipPath = n(e, t, a), l = {
|
|
19
|
+
width: e,
|
|
20
|
+
height: t
|
|
21
|
+
}, c?.update(o, e, t, u()));
|
|
14
22
|
});
|
|
15
23
|
return () => {
|
|
16
|
-
|
|
24
|
+
d = !0, f(), c?.dispose(), i.style.clipPath = s;
|
|
17
25
|
};
|
|
18
26
|
}
|
|
19
|
-
|
|
20
|
-
export { f as observeFixedShape };
|
|
27
|
+
export { i as observeFixedShape };
|
package/dist/dom/foreground.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { mapImage as
|
|
3
|
-
|
|
4
|
-
function
|
|
1
|
+
import { glassRecipe as e, glassSize as t, refractionFor as n } from "../core/materials.js";
|
|
2
|
+
import { mapImage as r } from "./map-image.js";
|
|
3
|
+
// src/dom/foreground.ts
|
|
4
|
+
function i(e, t) {
|
|
5
5
|
if (e === t) return 0;
|
|
6
6
|
let n = (e) => {
|
|
7
7
|
let t = [];
|
|
@@ -18,19 +18,18 @@ function n(e, t) {
|
|
|
18
18
|
};
|
|
19
19
|
return o(r) - o(i) || (e.compareDocumentPosition(t) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1);
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
return e.x < t.x + t.w && t.x < e.x + e.w && e.y < t.y + t.h && t.y < e.y + e.h;
|
|
21
|
+
function a(e, t, n = 0) {
|
|
22
|
+
return e.x < t.x + t.w + n && t.x - n < e.x + e.w && e.y < t.y + t.h + n && t.y - n < e.y + e.h;
|
|
23
23
|
}
|
|
24
|
-
function i
|
|
25
|
-
let
|
|
26
|
-
for (let [
|
|
27
|
-
if (!
|
|
28
|
-
let
|
|
29
|
-
|
|
30
|
-
let
|
|
31
|
-
|
|
24
|
+
function o(i, a, o) {
|
|
25
|
+
let s = a.w > 0 ? (a.element?.offsetWidth || a.w) / a.w : 1, c = a.h > 0 ? (a.element?.offsetHeight || a.h) / a.h : 1, l = Math.max(s, c), u = Math.abs(s - c) > 1e-6, d = [], f = "SourceGraphic";
|
|
26
|
+
for (let [i, p] of o.entries()) {
|
|
27
|
+
if (!p.maps) continue;
|
|
28
|
+
let o = `f${i}`, m = p.x - a.x - 2, h = p.y - a.y - 2, g = (e, t) => r(p.maps, e, t, m, h, p.w + 4, p.h + 4, 1 / s, 1 / c), _ = (e = 0) => `x="${(m - e) * s}" y="${(h - e) * c}" width="${(p.w + 4 + 2 * e) * s}" height="${(p.h + 4 + 2 * e) * c}"`, v = _(), y = p.opacity >= 1;
|
|
29
|
+
d.push(g("field", `${o}raw`)), u && d.push(`<feComponentTransfer in="${o}raw" ${v} result="${o}map"><feFuncR type="linear" slope="${s / l}" intercept="${(1 - s / l) / 2}"/><feFuncG type="linear" slope="${c / l}" intercept="${(1 - c / l) / 2}"/></feComponentTransfer>`), y || d.push(`<feComponentTransfer in="${o}raw" ${v} result="${o}mask"><feFuncA type="linear" slope="${p.opacity}"/></feComponentTransfer>`);
|
|
30
|
+
let b = u ? `${o}map` : `${o}raw`, x = y ? `${o}raw` : `${o}mask`, S = t(p.options, p.w, p.h), C = e(p.options, S).blur, w = p.options.refraction ?? n(p.options.material ?? "regular", S).amount;
|
|
31
|
+
C > 0 && d.push(`<feGaussianBlur in="${f}" ${_(Math.ceil(3 * C + Math.abs(w) + 2))} stdDeviation="${C * s} ${C * c}" result="${o}blur"/>`), d.push(`<feDisplacementMap in="${C > 0 ? `${o}blur` : f}" in2="${b}" ${v} scale="${w * 2 * l}" xChannelSelector="R" yChannelSelector="G" result="${o}refracted"/>`), d.push(`<feComposite in="${o}refracted" in2="${x}" operator="in" ${v} result="${o}inside"/><feComposite in="${f}" in2="${x}" operator="out" result="${o}outside"/><feMerge result="${o}result"><feMergeNode in="${o}outside"/><feMergeNode in="${o}inside"/></feMerge>`), f = `${o}result`;
|
|
32
32
|
}
|
|
33
|
-
return `<filter id="${
|
|
33
|
+
return `<filter id="${i}" x="-1" y="-1" width="3" height="3" filterUnits="objectBoundingBox" primitiveUnits="userSpaceOnUse" color-interpolation-filters="sRGB">${d.join("")}</filter>`;
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
export { n as comparePaintOrder, i as foregroundFilter, r as overlaps };
|
|
35
|
+
export { i as comparePaintOrder, o as foregroundFilter, a as overlaps };
|