@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,41 +1,49 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { glassRecipe as e } from "../core/materials.js";
|
|
2
2
|
import { unionSamplingBounds as t } from "./sampling-bounds.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
n.
|
|
3
|
+
import { backdropMarkup as n } from "./material-graph.js";
|
|
4
|
+
// src/dom/shared-backdrop.ts
|
|
5
|
+
function r(r, i, a = !1) {
|
|
6
|
+
let o = /* @__PURE__ */ new Map();
|
|
7
|
+
for (let t of r) {
|
|
8
|
+
if (t.inputs.length) continue;
|
|
9
|
+
let n = t.options, r = `${n.material ?? "regular"}-${n.appearance ?? "light"}-${n.frost ?? 0}-${e(n, t.size).blur}`, i = o.get(r) ?? [];
|
|
10
|
+
i.push(t), o.set(r, i);
|
|
10
11
|
}
|
|
11
|
-
let
|
|
12
|
-
for (let [
|
|
13
|
-
let
|
|
12
|
+
let s = /* @__PURE__ */ new Map(), c = (e) => `x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}"`;
|
|
13
|
+
for (let [r, l] of o) {
|
|
14
|
+
let o = e(l[0].options, l[0].size).blur * i, u = Math.ceil(3 * o) + 2, d = (e, t) => ({
|
|
14
15
|
x: e.x - t,
|
|
15
16
|
y: e.y - t,
|
|
16
17
|
width: e.width + 2 * t,
|
|
17
18
|
height: e.height + 2 * t
|
|
18
|
-
}),
|
|
19
|
-
for (let e of
|
|
19
|
+
}), f = (e) => e.width * e.height, p = (e) => 3 * f(d(e, u)), m = [];
|
|
20
|
+
for (let e of l) {
|
|
20
21
|
let n = -1, r = 0, i = e.bounds;
|
|
21
|
-
for (let [a, o] of
|
|
22
|
-
let s = t([o.bounds, e.bounds]), c =
|
|
22
|
+
for (let [a, o] of m.entries()) {
|
|
23
|
+
let s = t([o.bounds, e.bounds]), c = p(o.bounds) + p(e.bounds) - p(s);
|
|
23
24
|
c > r && (n = a, r = c, i = s);
|
|
24
25
|
}
|
|
25
|
-
n < 0 ?
|
|
26
|
+
n < 0 ? m.push({
|
|
26
27
|
members: [e],
|
|
27
28
|
bounds: e.bounds
|
|
28
|
-
}) : (
|
|
29
|
+
}) : (m[n].members.push(e), m[n].bounds = i);
|
|
29
30
|
}
|
|
30
|
-
for (let { members: e, bounds: t } of
|
|
31
|
-
let
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
for (let { members: e, bounds: t } of m) {
|
|
32
|
+
let i = e.length === 1 ? e[0].id : `shared-${r.replace(/[^a-z0-9]/gi, "")}-${e.map((e) => e.id).sort().join("-")}`, l = d(t, u), f = a ? `${i}backed` : "SourceGraphic", p = a ? `${n(`${i}frostBackdrop`, l)}<feMerge result="${f}" ${c(l)}><feMergeNode in="${i}frostBackdrop"/><feMergeNode in="SourceGraphic"/></feMerge>` : "";
|
|
33
|
+
if (o < .05) {
|
|
34
|
+
for (let t of e) s.set(t.key, {
|
|
35
|
+
result: f,
|
|
36
|
+
markup: p
|
|
37
|
+
});
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
let m = {
|
|
41
|
+
result: `${i}mix`,
|
|
42
|
+
markup: `${p}<feGaussianBlur in="${f}" stdDeviation="${o}" result="${i}mix" ${c(l)}/>`
|
|
34
43
|
};
|
|
35
|
-
for (let t of e)
|
|
44
|
+
for (let t of e) s.set(t.key, m);
|
|
36
45
|
}
|
|
37
46
|
}
|
|
38
|
-
return
|
|
47
|
+
return s;
|
|
39
48
|
}
|
|
40
|
-
|
|
41
|
-
export { n as sharedBackdropMaterials };
|
|
49
|
+
export { r as sharedBackdropMaterials };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { touchMaps as e } from "./maps.js";
|
|
2
|
+
// src/dom/specular.ts
|
|
3
|
+
var t = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
function n(e, n) {
|
|
5
|
+
let r = t.get(e);
|
|
6
|
+
if (!r) {
|
|
7
|
+
let n = {}, i = /* @__PURE__ */ new Set(), a = () => i.forEach((e) => e()), o = (e) => {
|
|
8
|
+
(e.pointerType !== "touch" || e.type !== "pointermove" || e.buttons) && (n.pointer = {
|
|
9
|
+
x: e.clientX,
|
|
10
|
+
y: e.clientY
|
|
11
|
+
}, a());
|
|
12
|
+
}, s = () => {
|
|
13
|
+
n.pointer = void 0, a();
|
|
14
|
+
}, c = (e) => {
|
|
15
|
+
e.pointerType === "touch" && (n.pointer = void 0, a());
|
|
16
|
+
}, l, u = (e) => {
|
|
17
|
+
e.beta !== null && e.gamma !== null && (l ??= {
|
|
18
|
+
beta: e.beta,
|
|
19
|
+
gamma: e.gamma
|
|
20
|
+
}, l.beta += (e.beta - l.beta) * .02, l.gamma += (e.gamma - l.gamma) * .02, n.tilt = {
|
|
21
|
+
x: e.gamma - l.gamma,
|
|
22
|
+
y: e.beta - l.beta
|
|
23
|
+
}, a());
|
|
24
|
+
}, d = (e) => {
|
|
25
|
+
e.relatedTarget || s();
|
|
26
|
+
}, f = {
|
|
27
|
+
capture: !0,
|
|
28
|
+
passive: !0
|
|
29
|
+
};
|
|
30
|
+
e.addEventListener("pointermove", o, f), e.addEventListener("pointerdown", o, f), e.addEventListener("pointerup", c, f), e.addEventListener("pointercancel", c, f), e.document.addEventListener("mouseout", d, f), e.addEventListener("blur", s);
|
|
31
|
+
let p = typeof e.DeviceOrientationEvent?.requestPermission != "function" && "DeviceOrientationEvent" in e;
|
|
32
|
+
p && e.addEventListener("deviceorientation", u, { passive: !0 }), r = {
|
|
33
|
+
light: n,
|
|
34
|
+
wakes: i,
|
|
35
|
+
dispose() {
|
|
36
|
+
e.removeEventListener("pointermove", o, f), e.removeEventListener("pointerdown", o, f), e.removeEventListener("pointerup", c, f), e.removeEventListener("pointercancel", c, f), e.document.removeEventListener("mouseout", d, f), e.removeEventListener("blur", s), p && e.removeEventListener("deviceorientation", u);
|
|
37
|
+
}
|
|
38
|
+
}, t.set(e, r);
|
|
39
|
+
}
|
|
40
|
+
let i = r;
|
|
41
|
+
return i.wakes.add(n), {
|
|
42
|
+
light: i.light,
|
|
43
|
+
release() {
|
|
44
|
+
i.wakes.delete(n), i.wakes.size || (i.dispose(), t.delete(e));
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
var r = -3 * Math.PI / 4;
|
|
49
|
+
function i(e, t, n) {
|
|
50
|
+
if (e.pointer) {
|
|
51
|
+
let r = e.pointer.x - t, i = e.pointer.y - n;
|
|
52
|
+
if (Math.hypot(r, i) > 1) return Math.atan2(i, r);
|
|
53
|
+
}
|
|
54
|
+
if (e.tilt) {
|
|
55
|
+
let t = -Math.SQRT1_2 + e.tilt.x / 40, n = -Math.SQRT1_2 + e.tilt.y / 40;
|
|
56
|
+
if (Math.hypot(t, n) > .05) return Math.atan2(n, t);
|
|
57
|
+
}
|
|
58
|
+
return r;
|
|
59
|
+
}
|
|
60
|
+
function a(e, t, n, r = .09) {
|
|
61
|
+
let i = (t - e) % Math.PI;
|
|
62
|
+
return i > Math.PI / 2 && (i -= Math.PI), i < -Math.PI / 2 && (i += Math.PI), Math.abs(i) < .002 ? e : e + i * (1 - Math.exp(-n / r));
|
|
63
|
+
}
|
|
64
|
+
function o(e) {
|
|
65
|
+
let t = Math.max(0, Math.min(1, (Math.abs(e) - .12) / .68));
|
|
66
|
+
return (t * t * (3 - 2 * t)) ** 1.3;
|
|
67
|
+
}
|
|
68
|
+
var s = Array.from({ length: 33 }, (e, t) => o(t / 32 * 2 - 1).toFixed(4));
|
|
69
|
+
function c(e) {
|
|
70
|
+
let t = Math.cos(e), n = Math.sin(e), r = (e) => Math.abs(e) < 1e-5 ? "0" : e.toFixed(4);
|
|
71
|
+
return `0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 ${r(-t)} ${r(-n)} 0 0 ${r(.5 + .5 * t + .5 * n)}`;
|
|
72
|
+
}
|
|
73
|
+
function l(e) {
|
|
74
|
+
return `<filter id="${e}" x="0" y="0" width="1" height="1" color-interpolation-filters="sRGB"><feColorMatrix in="SourceGraphic" type="matrix" values="${c(r)}" result="facing"/><feComponentTransfer in="facing" result="lit"><feFuncA type="table" tableValues="${s.join(" ")}"/></feComponentTransfer><feComposite in="lit" in2="SourceAlpha" operator="in"/></filter>`;
|
|
75
|
+
}
|
|
76
|
+
var u = "http://www.w3.org/2000/svg", d = /^(area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)$/i, f = /* @__PURE__ */ new WeakSet(), p = (e) => f.has(e);
|
|
77
|
+
function m(t, n, r) {
|
|
78
|
+
if (d.test(t.tagName)) return;
|
|
79
|
+
let i = t.ownerDocument, a = i.createElementNS(u, "g");
|
|
80
|
+
a.innerHTML = l(r);
|
|
81
|
+
let o = a.firstElementChild, s = o.querySelector("feColorMatrix");
|
|
82
|
+
n.append(o);
|
|
83
|
+
let p = i.createElement("span");
|
|
84
|
+
p.className = "lg-specular", p.setAttribute("aria-hidden", "true"), p.style.filter = `url("#${r}")`, f.add(p), f.add(o), t.append(p);
|
|
85
|
+
let m = "", h, g = "", _ = "";
|
|
86
|
+
return {
|
|
87
|
+
place(n, r, i) {
|
|
88
|
+
let a = `${r},${i},${t.clientLeft},${t.clientTop}`;
|
|
89
|
+
if (n === h && a === g) return;
|
|
90
|
+
if (h = n, g = a, !n) {
|
|
91
|
+
p.style.display = "none";
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
e(n), p.style.removeProperty("display");
|
|
95
|
+
let o = r + 4, s = i + 4;
|
|
96
|
+
p.style.left = `${-2 - t.clientLeft}px`, p.style.top = `${-2 - t.clientTop}px`, p.style.width = `${o}px`, p.style.height = `${s}px`;
|
|
97
|
+
let c = n.capsule, l = c ? c.cap * s / c.height : 0;
|
|
98
|
+
if (!c) {
|
|
99
|
+
p.style.backgroundImage = `url("${n.field}")`, p.style.backgroundPosition = "0 0", p.style.backgroundSize = `${o}px ${s}px`;
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
let [u, d, f] = c.planes.field;
|
|
103
|
+
o < l * 2 ? (p.style.backgroundImage = `url("${f}"), url("${u}")`, p.style.backgroundPosition = `${o - l}px 0, 0 0`, p.style.backgroundSize = `${l}px ${s}px, ${l}px ${s}px`) : (p.style.backgroundImage = `url("${f}"), url("${u}"), url("${d}")`, p.style.backgroundPosition = `${o - l}px 0, 0 0, ${l - .5}px 0`, p.style.backgroundSize = `${l}px ${s}px, ${l}px ${s}px, ${o - l * 2 + 1}px ${s}px`);
|
|
104
|
+
},
|
|
105
|
+
aim(e, t) {
|
|
106
|
+
let n = c(e);
|
|
107
|
+
n !== m && (m = n, s.setAttribute("values", n));
|
|
108
|
+
let r = t.toFixed(3);
|
|
109
|
+
r !== _ && (_ = r, p.style.opacity = r);
|
|
110
|
+
},
|
|
111
|
+
dispose() {
|
|
112
|
+
p.remove(), o.remove();
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export { a as approachAngle, m as createSpecularLayer, i as lightAngle, p as ownsSpecular, r as restingAngle, l as specularFilterMarkup, c as specularMatrix, o as specularResponse, n as subscribeLight };
|
package/dist/dom/ticker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/dom/ticker.ts
|
|
2
2
|
var e = [
|
|
3
3
|
"pointerdown",
|
|
4
4
|
"pointerup",
|
|
@@ -29,24 +29,29 @@ var e = [
|
|
|
29
29
|
schedule(e) {
|
|
30
30
|
e.disposed || (this.pending.add(e), this.raf ||= this.view.requestAnimationFrame((e) => this.frame(e)));
|
|
31
31
|
}
|
|
32
|
+
run(e) {
|
|
33
|
+
e.disposed || (this.step([e], this.view.performance.now()), this.schedule(e));
|
|
34
|
+
}
|
|
32
35
|
frame(e) {
|
|
33
36
|
this.raf = 0;
|
|
34
37
|
let t = [...this.pending];
|
|
35
|
-
this.pending.clear();
|
|
38
|
+
this.pending.clear(), this.step(t, e);
|
|
39
|
+
}
|
|
40
|
+
step(e, t) {
|
|
36
41
|
let n = [];
|
|
37
|
-
for (let r of
|
|
42
|
+
for (let r of e) {
|
|
38
43
|
if (r.disposed) continue;
|
|
39
|
-
let
|
|
44
|
+
let e;
|
|
40
45
|
try {
|
|
41
|
-
|
|
46
|
+
e = r.step(t);
|
|
42
47
|
} catch (e) {
|
|
43
48
|
queueMicrotask(() => {
|
|
44
49
|
throw e;
|
|
45
50
|
});
|
|
46
51
|
continue;
|
|
47
52
|
}
|
|
48
|
-
let i = typeof
|
|
49
|
-
typeof
|
|
53
|
+
let i = typeof e == "boolean" ? e : e.active;
|
|
54
|
+
typeof e != "boolean" && e.write && n.push(e.write), r.idle = i ? 0 : r.idle + 1, r.idle < 3 && this.schedule(r);
|
|
50
55
|
}
|
|
51
56
|
for (let e of n) try {
|
|
52
57
|
e();
|
|
@@ -65,17 +70,21 @@ function i(i, a) {
|
|
|
65
70
|
step: i,
|
|
66
71
|
idle: 0,
|
|
67
72
|
disposed: !1
|
|
68
|
-
}, f = () => u.schedule(d), p =
|
|
69
|
-
|
|
73
|
+
}, f = () => u.schedule(d), p = !1, m = () => {
|
|
74
|
+
p || (p = !0, queueMicrotask(() => {
|
|
75
|
+
p = !1, u.run(d);
|
|
76
|
+
}));
|
|
77
|
+
}, h = typeof ResizeObserver == "function" ? new ResizeObserver(f) : void 0, g = typeof MutationObserver == "function" ? new MutationObserver((e) => {
|
|
78
|
+
(!s || e.some((e) => !s(e.target, e))) && (c?.(), f());
|
|
70
79
|
}) : void 0;
|
|
71
|
-
|
|
80
|
+
g?.observe(o, {
|
|
72
81
|
subtree: !0,
|
|
73
82
|
attributes: !0,
|
|
74
83
|
childList: !0,
|
|
75
84
|
characterData: !1
|
|
76
85
|
});
|
|
77
|
-
let
|
|
78
|
-
for (let n of [...e, ...t])
|
|
86
|
+
let _ = o;
|
|
87
|
+
for (let n of [...e, ...t]) _.addEventListener(n, f, {
|
|
79
88
|
capture: !0,
|
|
80
89
|
passive: !0
|
|
81
90
|
});
|
|
@@ -83,21 +92,21 @@ function i(i, a) {
|
|
|
83
92
|
capture: !0,
|
|
84
93
|
passive: !0
|
|
85
94
|
}), l.addEventListener("resize", f, { passive: !0 }), l.document.addEventListener("visibilitychange", f);
|
|
86
|
-
let
|
|
95
|
+
let v = l.setInterval(f, a.heartbeat ?? 1e3);
|
|
87
96
|
return f(), {
|
|
88
97
|
wake: f,
|
|
98
|
+
flush: m,
|
|
89
99
|
observe(e) {
|
|
90
|
-
|
|
100
|
+
h?.observe(e);
|
|
91
101
|
},
|
|
92
102
|
unobserve(e) {
|
|
93
|
-
|
|
103
|
+
h?.unobserve(e);
|
|
94
104
|
},
|
|
95
105
|
dispose() {
|
|
96
|
-
d.disposed = !0,
|
|
97
|
-
for (let n of [...e, ...t])
|
|
98
|
-
l.removeEventListener("scroll", f, { capture: !0 }), l.removeEventListener("resize", f), l.document.removeEventListener("visibilitychange", f), l.clearInterval(
|
|
106
|
+
d.disposed = !0, h?.disconnect(), g?.disconnect();
|
|
107
|
+
for (let n of [...e, ...t]) _.removeEventListener(n, f, { capture: !0 });
|
|
108
|
+
l.removeEventListener("scroll", f, { capture: !0 }), l.removeEventListener("resize", f), l.document.removeEventListener("visibilitychange", f), l.clearInterval(v);
|
|
99
109
|
}
|
|
100
110
|
};
|
|
101
111
|
}
|
|
102
|
-
//#endregion
|
|
103
112
|
export { i as createTicker };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/dom/tint-color.ts
|
|
2
|
+
var e = /^#[\da-f]{6}$/i, t = /* @__PURE__ */ new Map(), n;
|
|
3
|
+
function r(r) {
|
|
4
|
+
let i = r.trim();
|
|
5
|
+
if (e.test(i)) return i.toLowerCase();
|
|
6
|
+
if (!i) return;
|
|
7
|
+
if (t.has(i)) return t.get(i);
|
|
8
|
+
n ??= typeof document > "u" ? null : document.createElement("canvas").getContext("2d", { willReadFrequently: !0 });
|
|
9
|
+
let a;
|
|
10
|
+
if (n) {
|
|
11
|
+
n.canvas.width = n.canvas.height = 1, n.clearRect(0, 0, 1, 1), n.fillStyle = "#000000", n.fillStyle = i, n.fillRect(0, 0, 1, 1);
|
|
12
|
+
let [e, t, r, o] = n.getImageData(0, 0, 1, 1).data;
|
|
13
|
+
a = o === 0 ? void 0 : `#${[
|
|
14
|
+
e,
|
|
15
|
+
t,
|
|
16
|
+
r
|
|
17
|
+
].map((e) => e.toString(16).padStart(2, "0")).join("")}`;
|
|
18
|
+
}
|
|
19
|
+
return t.set(i, a), a;
|
|
20
|
+
}
|
|
21
|
+
function i(t, n) {
|
|
22
|
+
return e.test(n) ? n : (t.style.getPropertyValue("--lg-tint") !== n && t.style.setProperty("--lg-tint", n), r(getComputedStyle(t).getPropertyValue("--lg-tint")));
|
|
23
|
+
}
|
|
24
|
+
export { r as colorToHex, e as hexTint, i as resolveTint };
|
package/dist/dom/warm.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
let o =
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { webkit as e } from "./engine.js";
|
|
2
|
+
import { drawnMapUrls as t } from "./maps.js";
|
|
3
|
+
// src/dom/warm.ts
|
|
4
|
+
var n = "http://www.w3.org/2000/svg", r = 48, i = 96, a = e ? 16 : 50, o = 0;
|
|
5
|
+
function s(e) {
|
|
6
|
+
let s = `lg-warm-${++o}`, c = e.ownerDocument, l = c.createElementNS(n, "svg");
|
|
7
|
+
l.setAttribute("aria-hidden", "true"), l.setAttribute("width", "0"), l.setAttribute("height", "0"), l.style.position = "absolute", e.append(l);
|
|
8
|
+
let u = [], d = () => {
|
|
9
|
+
let t = c.createElementNS(n, "filter");
|
|
10
|
+
t.id = `${s}-${u.length}`;
|
|
9
11
|
for (let [e, n] of Object.entries({
|
|
10
12
|
x: "0",
|
|
11
13
|
y: "0",
|
|
@@ -14,9 +16,9 @@ function n(n) {
|
|
|
14
16
|
filterUnits: "objectBoundingBox",
|
|
15
17
|
primitiveUnits: "objectBoundingBox"
|
|
16
18
|
})) t.setAttribute(e, n);
|
|
17
|
-
|
|
18
|
-
let
|
|
19
|
-
|
|
19
|
+
l.append(t);
|
|
20
|
+
let r = c.createElement("div");
|
|
21
|
+
r.setAttribute("aria-hidden", "true"), Object.assign(r.style, {
|
|
20
22
|
position: "absolute",
|
|
21
23
|
left: "0",
|
|
22
24
|
top: "0",
|
|
@@ -25,84 +27,86 @@ function n(n) {
|
|
|
25
27
|
opacity: "0.004",
|
|
26
28
|
pointerEvents: "none",
|
|
27
29
|
filter: `url("#${t.id}")`
|
|
28
|
-
}),
|
|
29
|
-
let
|
|
30
|
-
t.append(
|
|
31
|
-
let
|
|
30
|
+
}), e.append(r);
|
|
31
|
+
let i = c.createElementNS(n, "feMerge");
|
|
32
|
+
t.append(i);
|
|
33
|
+
let a = {
|
|
32
34
|
filter: t,
|
|
33
|
-
merge:
|
|
34
|
-
element:
|
|
35
|
+
merge: i,
|
|
36
|
+
element: r,
|
|
35
37
|
count: 0
|
|
36
38
|
};
|
|
37
|
-
return
|
|
39
|
+
return u.push(a), a;
|
|
38
40
|
};
|
|
39
|
-
|
|
40
|
-
let
|
|
41
|
-
if (
|
|
42
|
-
if (
|
|
43
|
-
let [e, t] =
|
|
44
|
-
t.image.remove(), t.node.remove(), t.probe.count--,
|
|
41
|
+
d();
|
|
42
|
+
let f = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new WeakSet(), m = /* @__PURE__ */ new Map(), h, g = 0, _ = (e) => {
|
|
43
|
+
if (f.has(e)) return;
|
|
44
|
+
if (f.size >= i) {
|
|
45
|
+
let [e, t] = f.entries().next().value;
|
|
46
|
+
t.image.remove(), t.node.remove(), t.probe.count--, f.delete(e);
|
|
45
47
|
}
|
|
46
|
-
let
|
|
48
|
+
let t = u.find((e) => e.count < r) ?? d(), a = `w${++g}`, o = c.createElementNS(n, "feImage");
|
|
47
49
|
for (let [e, t] of Object.entries({
|
|
48
50
|
x: "0",
|
|
49
51
|
y: "0",
|
|
50
52
|
width: "1",
|
|
51
53
|
height: "1",
|
|
52
54
|
preserveAspectRatio: "none",
|
|
53
|
-
result:
|
|
54
|
-
}))
|
|
55
|
-
let
|
|
56
|
-
|
|
57
|
-
image:
|
|
58
|
-
node:
|
|
59
|
-
probe:
|
|
55
|
+
result: a
|
|
56
|
+
})) o.setAttribute(e, t);
|
|
57
|
+
let s = c.createElementNS(n, "feMergeNode");
|
|
58
|
+
s.setAttribute("in", a), t.filter.insertBefore(o, t.merge), t.merge.append(s), o.setAttribute("href", e), t.count++, f.set(e, {
|
|
59
|
+
image: o,
|
|
60
|
+
node: s,
|
|
61
|
+
probe: t
|
|
60
62
|
});
|
|
61
|
-
},
|
|
62
|
-
let e = ++
|
|
63
|
-
|
|
63
|
+
}, v = 0, y = !1, b = [], x = () => {
|
|
64
|
+
let e = ++v;
|
|
65
|
+
b.forEach(clearTimeout), b = [
|
|
64
66
|
16,
|
|
65
67
|
60,
|
|
66
68
|
150
|
|
67
69
|
].map((t) => setTimeout(() => {
|
|
68
|
-
if (
|
|
70
|
+
if (v === e && !y) for (let { filter: e } of u) e.setAttribute("x", e.getAttribute("x") === "0" ? "0.000001" : "0");
|
|
69
71
|
}, t));
|
|
70
|
-
},
|
|
71
|
-
e.field,
|
|
72
|
-
e.overlay,
|
|
73
|
-
...Object.values(e.capsule?.planes ?? {}).flat()
|
|
74
|
-
], y = () => {
|
|
72
|
+
}, S = t, C = () => {
|
|
75
73
|
let e = performance.now();
|
|
76
|
-
for (let [t, n] of
|
|
77
|
-
},
|
|
78
|
-
if (
|
|
79
|
-
let e = Math.min(...
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
for (let [t, n] of m) n <= e && (S(t).every((e) => f.has(e)) && p.add(t), m.delete(t));
|
|
75
|
+
}, w = () => {
|
|
76
|
+
if (h !== void 0 || !m.size) return;
|
|
77
|
+
let e = Math.min(...m.values());
|
|
78
|
+
h = setTimeout(() => {
|
|
79
|
+
h = void 0, y || (C(), w());
|
|
82
80
|
}, Math.max(0, e - performance.now()));
|
|
83
81
|
};
|
|
84
82
|
return {
|
|
85
83
|
warm(e) {
|
|
86
|
-
if (
|
|
87
|
-
let t =
|
|
84
|
+
if (y || (C(), p.has(e))) return;
|
|
85
|
+
let t = S(e).filter((e) => !f.has(e));
|
|
88
86
|
if (t.length) {
|
|
89
|
-
for (let e of t)
|
|
90
|
-
|
|
87
|
+
for (let e of t) _(e);
|
|
88
|
+
x();
|
|
91
89
|
}
|
|
92
|
-
(t.length || !
|
|
90
|
+
(t.length || !m.has(e)) && m.set(e, performance.now() + a), w();
|
|
93
91
|
},
|
|
94
92
|
has(e) {
|
|
95
|
-
return !
|
|
93
|
+
return !y && (C(), p.has(e));
|
|
96
94
|
},
|
|
97
95
|
owns(e) {
|
|
98
|
-
return
|
|
96
|
+
return l.contains(e) || u.some((t) => t.element.contains(e));
|
|
99
97
|
},
|
|
100
98
|
dispose() {
|
|
101
|
-
|
|
102
|
-
for (let { element: e } of
|
|
103
|
-
|
|
99
|
+
y = !0, b.forEach(clearTimeout), b = [], h !== void 0 && clearTimeout(h), h = void 0, m.clear(), l.remove();
|
|
100
|
+
for (let { element: e } of u) e.remove();
|
|
101
|
+
f.clear();
|
|
104
102
|
}
|
|
105
103
|
};
|
|
106
104
|
}
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
var c = /* @__PURE__ */ new WeakSet();
|
|
106
|
+
function l(t) {
|
|
107
|
+
if (!e || c.has(t)) return;
|
|
108
|
+
c.add(t);
|
|
109
|
+
let n = t.documentElement;
|
|
110
|
+
n.style.setProperty("--lg-warm", "0"), getComputedStyle(n).color, n.style.removeProperty("--lg-warm"), n.style.length || n.removeAttribute("style");
|
|
111
|
+
}
|
|
112
|
+
export { s as createMapWarmer, a as mapWarmup, l as warmDocumentStyle };
|