@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/lens-layers.js
CHANGED
|
@@ -1,163 +1,277 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
function
|
|
10
|
-
let
|
|
11
|
-
|
|
12
|
-
let
|
|
13
|
-
|
|
14
|
-
let
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { aberrationFor as e, glassRecipe as t, glassSize as n, outlineFor as r } from "../core/materials.js";
|
|
2
|
+
import { patchFilters as i } from "./filter-patch.js";
|
|
3
|
+
import { mapImage as a, mapUrl as o } from "./map-image.js";
|
|
4
|
+
import { touchMaps as s } from "./maps.js";
|
|
5
|
+
import { backdropColor as c, fillMarkup as l, frostMarkup as u, lightMarkup as d, outlineMarkup as f, overlayTintMarkup as p, refractMarkup as m, tintChannels as h, tintMarkup as g, toneMarkup as _ } from "./material-graph.js";
|
|
6
|
+
import { progressiveGraph as v } from "./progressive.js";
|
|
7
|
+
// src/dom/lens-layers.ts
|
|
8
|
+
var y = 0, b = "http://www.w3.org/2000/svg", x = /^(area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)$/i;
|
|
9
|
+
function S(S) {
|
|
10
|
+
let C = ++y, w = S.ownerDocument, T = w.createElementNS(b, "svg");
|
|
11
|
+
T.setAttribute("aria-hidden", "true"), T.setAttribute("width", "0"), T.setAttribute("height", "0"), T.style.position = "absolute", T.style.pointerEvents = "none";
|
|
12
|
+
let E = w.createElementNS(b, "defs");
|
|
13
|
+
T.append(E), w.body.append(T);
|
|
14
|
+
let D = /* @__PURE__ */ new Map(), O, k = (e, t, n, r) => {
|
|
15
|
+
let i = r ? `${r} ${t}` : t;
|
|
16
|
+
e.written.get(i) !== n && (e.written.set(i, n), (r ? e.split[r] : e.element).style.setProperty(t, n));
|
|
17
|
+
}, ee = (e) => {
|
|
18
|
+
if (e.split) return e.split;
|
|
19
|
+
let t = Object.fromEntries([
|
|
20
|
+
"glass",
|
|
21
|
+
"source",
|
|
22
|
+
"refracted",
|
|
23
|
+
"light",
|
|
24
|
+
"rim"
|
|
25
|
+
].map((e) => {
|
|
26
|
+
let t = w.createElement("div");
|
|
27
|
+
return Object.assign(t.style, {
|
|
28
|
+
position: "absolute",
|
|
29
|
+
inset: "0",
|
|
30
|
+
pointerEvents: "none",
|
|
31
|
+
backgroundRepeat: "no-repeat",
|
|
32
|
+
maskRepeat: "no-repeat"
|
|
33
|
+
}), [e, t];
|
|
34
|
+
}));
|
|
35
|
+
return t.refracted.style.inset = "auto", t.light.style.mixBlendMode = "plus-lighter", t.glass.append(t.source, t.refracted), e.element.append(t.glass, t.light, t.rim), e.split = t;
|
|
36
|
+
}, A = (e, t, n) => {
|
|
37
|
+
s(e);
|
|
38
|
+
let r = e.capsule, i = r ? r.cap * n.height / r.height : 0;
|
|
39
|
+
if (!r || n.width < i * 2) return [{
|
|
40
|
+
url: e[t],
|
|
41
|
+
left: n.left,
|
|
42
|
+
width: n.width
|
|
43
|
+
}];
|
|
44
|
+
let [a, o, c] = r.planes[t];
|
|
45
|
+
return [
|
|
46
|
+
{
|
|
47
|
+
url: c,
|
|
48
|
+
left: n.left + n.width - i,
|
|
49
|
+
width: i
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
url: a,
|
|
53
|
+
left: n.left,
|
|
54
|
+
width: i
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
url: o,
|
|
58
|
+
left: n.left + i - .5,
|
|
59
|
+
width: n.width - i * 2 + 1
|
|
60
|
+
}
|
|
61
|
+
];
|
|
62
|
+
}, j = (e) => {
|
|
63
|
+
let t = e.backdrop;
|
|
64
|
+
t && (e.backdrop = void 0, t.value ? e.host.style.setProperty("backdrop-filter", t.value, t.priority) : e.host.style.removeProperty("backdrop-filter"));
|
|
65
|
+
}, M = (e, t) => {
|
|
66
|
+
j(t), t.element.remove(), t.hostId && t.host.id === t.hostId && t.host.removeAttribute("id"), t.isolation ? t.host.style.isolation = t.isolation : t.host.style.removeProperty("isolation"), D.delete(e);
|
|
67
|
+
}, N = (e) => `-moz-element(#${CSS.escape(e.id)})`, P = (e, t, n, r, i) => {
|
|
68
|
+
k(e, `${n}-image`, r.length ? r.map((e) => `url("${e.url}")`).join(", ") : "none", t), k(e, `${n}-position`, r.map((e) => `${e.left}px ${i.top}px`).join(", "), t), k(e, `${n}-size`, r.map((e) => `${e.width}px ${i.height}px`).join(", "), t);
|
|
69
|
+
}, F = (e) => `<filter id="${e}" x="0" y="0" width="1" height="1" filterUnits="objectBoundingBox" primitiveUnits="userSpaceOnUse" color-interpolation-filters="sRGB">`, te = (e, t, r, i, a) => {
|
|
70
|
+
let o = e.options, s = e.frame, d = h(o);
|
|
71
|
+
k(t, "left", `${r.left}px`), k(t, "top", `${r.top}px`), k(t, "width", `${r.width}px`), k(t, "height", `${r.height}px`), k(t, "opacity", "1");
|
|
72
|
+
let f = n(e.options, e.w, e.h), m = (e, t) => {
|
|
73
|
+
let n = [], r = e;
|
|
74
|
+
if (t) {
|
|
75
|
+
let t = u("l", r, o, f, 1 / Math.max(s.sx, s.sy));
|
|
76
|
+
n.push(t.markup), r = t.result;
|
|
77
|
+
let i = l("l", r, e, o, f, 1 / Math.max(s.sx, s.sy));
|
|
78
|
+
n.push(i.markup), r = i.result;
|
|
79
|
+
}
|
|
80
|
+
return n.push(_("l", o, f, r)), d && n.push(g("l", o, d).markup), n.join("");
|
|
81
|
+
}, v = [];
|
|
82
|
+
if (e.mode === "backdrop") {
|
|
83
|
+
let n = a ? `<feFlood flood-color="${a}" result="lback"/><feMerge result="lbacked"><feMergeNode in="lback"/><feMergeNode in="SourceGraphic"/></feMerge>` : "";
|
|
84
|
+
v.push(`${F(`${t.base}-backdrop`)}${n}${m(a ? "lbacked" : "SourceGraphic", !0)}</filter>`), P(t, void 0, "background", [...A(e.maps, "light", i), ...A(e.maps, "rim", i)], i);
|
|
85
|
+
} else ee(t), k(t, "display", "block", "glass"), k(t, "display", "none", "source"), k(t, "display", "none", "refracted"), k(t, "display", "block", "light"), k(t, "display", "block", "rim"), k(t, "background-color", c, "glass"), P(t, "glass", "mask", A(e.maps, "field", i), i), P(t, "light", "background", A(e.maps, "light", i), i), P(t, "rim", "background", A(e.maps, "rim", i), i), v.push(`${F(`${t.base}-material`)}${m("SourceGraphic", !1)}</filter>`);
|
|
86
|
+
return d && v.push(`${F(`${t.base}-light`)}${p("SourceGraphic", "llight", d)}</filter>`), v;
|
|
87
|
+
}, I = (e, t, n) => {
|
|
88
|
+
let r = (e) => `url("#${t(e)}")`, i = n.has(`${e.base}-light`) ? r(`${e.base}-light`) : "none";
|
|
89
|
+
if (e.mode === "flat") {
|
|
90
|
+
k(e, "filter", "none"), k(e, "filter", r(`${e.base}-material`), "glass"), k(e, "filter", i, "light");
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
let a = e.host.style;
|
|
94
|
+
e.backdrop ??= {
|
|
95
|
+
value: a.getPropertyValue("backdrop-filter"),
|
|
96
|
+
priority: a.getPropertyPriority("backdrop-filter")
|
|
97
|
+
};
|
|
98
|
+
let o = r(`${e.base}-backdrop`);
|
|
99
|
+
a.getPropertyValue("backdrop-filter") !== o && a.setProperty("backdrop-filter", o), k(e, "filter", i);
|
|
100
|
+
};
|
|
19
101
|
return {
|
|
20
|
-
update(
|
|
21
|
-
|
|
22
|
-
element:
|
|
23
|
-
original:
|
|
24
|
-
id:
|
|
25
|
-
},
|
|
26
|
-
let
|
|
27
|
-
for (let
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
let
|
|
31
|
-
if (
|
|
32
|
-
let
|
|
33
|
-
|
|
34
|
-
element:
|
|
35
|
-
host:
|
|
36
|
-
base: `lg-lens-${
|
|
37
|
-
isolation:
|
|
38
|
-
written: /* @__PURE__ */ new Map()
|
|
39
|
-
|
|
102
|
+
update(s, y, b, S, T = !1, j = "") {
|
|
103
|
+
y && O?.element !== y && (O && L(), O = {
|
|
104
|
+
element: y,
|
|
105
|
+
original: y.getAttribute("id"),
|
|
106
|
+
id: y.id || `lg-content-${C}`
|
|
107
|
+
}, y.id ||= O.id);
|
|
108
|
+
let F = /* @__PURE__ */ new Set(), R = [], z = [];
|
|
109
|
+
for (let e of s) {
|
|
110
|
+
if (x.test(e.element.tagName)) continue;
|
|
111
|
+
F.add(e.serial);
|
|
112
|
+
let r = D.get(e.serial);
|
|
113
|
+
if (r && (r.host !== e.element || r.mode !== e.mode) && (M(e.serial, r), r = void 0), !r) {
|
|
114
|
+
let t = w.createElement("div");
|
|
115
|
+
t.className = "lg-glass-layer", t.setAttribute("aria-hidden", "true"), t.id = `lg-layer-${C}-${e.serial}`, r = {
|
|
116
|
+
element: t,
|
|
117
|
+
host: e.element,
|
|
118
|
+
base: `lg-lens-${C}-${e.serial}`,
|
|
119
|
+
isolation: e.element.style.isolation,
|
|
120
|
+
written: /* @__PURE__ */ new Map(),
|
|
121
|
+
mode: e.mode
|
|
122
|
+
}, e.element.style.isolation = "isolate", e.element.append(t), D.set(e.serial, r);
|
|
40
123
|
}
|
|
41
|
-
let
|
|
42
|
-
left:
|
|
43
|
-
top:
|
|
44
|
-
width:
|
|
45
|
-
height:
|
|
46
|
-
},
|
|
47
|
-
left:
|
|
48
|
-
top:
|
|
49
|
-
width:
|
|
50
|
-
height:
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
width: c.width / i.sx,
|
|
57
|
-
height: c.height / i.sy
|
|
58
|
-
}, u = {
|
|
59
|
-
left: o / i.sx,
|
|
60
|
-
top: o / i.sy,
|
|
61
|
-
width: s.width / i.sx,
|
|
62
|
-
height: s.height / i.sy
|
|
124
|
+
let i = e.options, a = e.frame, o = t(i, n(e.options, e.w, e.h)), s = Math.max(o.blur, o.fill), c = e.mode === "copy" ? Math.ceil(3 * s + e.refraction + 4) : 0, l = (e) => Math.round(e * 16) / 16, u = Math.ceil(c / Math.max(a.sx, a.sy)), d = {
|
|
125
|
+
left: u,
|
|
126
|
+
top: u,
|
|
127
|
+
width: l((e.layoutWidth ?? e.w / a.sx) + 4),
|
|
128
|
+
height: l((e.layoutHeight ?? e.h / a.sy) + 4)
|
|
129
|
+
}, f = {
|
|
130
|
+
left: (b.left + e.x - a.left) / a.sx - a.clientLeft - 2 - u,
|
|
131
|
+
top: (b.top + e.y - a.top) / a.sy - a.clientTop - 2 - u,
|
|
132
|
+
width: d.width + 2 * u,
|
|
133
|
+
height: d.height + 2 * u
|
|
134
|
+
}, p = {
|
|
135
|
+
left: a.left + (f.left + a.clientLeft) * a.sx,
|
|
136
|
+
top: a.top + (f.top + a.clientTop) * a.sy,
|
|
137
|
+
width: f.width * a.sx,
|
|
138
|
+
height: f.height * a.sy
|
|
63
139
|
};
|
|
64
|
-
|
|
65
|
-
lens:
|
|
66
|
-
layer:
|
|
67
|
-
screen:
|
|
68
|
-
local:
|
|
69
|
-
lens_:
|
|
140
|
+
r.screen = p, z.push({
|
|
141
|
+
lens: e,
|
|
142
|
+
layer: r,
|
|
143
|
+
screen: p,
|
|
144
|
+
local: f,
|
|
145
|
+
lens_: d
|
|
70
146
|
});
|
|
71
147
|
}
|
|
72
|
-
for (let [e, t] of
|
|
73
|
-
for (let { lens:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
148
|
+
for (let [e, t] of D) F.has(e) || M(e, t);
|
|
149
|
+
for (let { lens: i, layer: o, screen: s, local: x, lens_: w } of z) {
|
|
150
|
+
if (i.mode !== "copy") {
|
|
151
|
+
R.push(...te(i, o, x, w, j));
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (!y) continue;
|
|
155
|
+
let E = i.frame, O = i.options, M = (e, t) => [(e - s.left) / E.sx, (t - s.top) / E.sy], F = [];
|
|
156
|
+
for (let e of [...i.parents, ...[...i.beneath].reverse()]) {
|
|
157
|
+
let t = D.get(e.serial);
|
|
158
|
+
if (!t?.screen || t === o) continue;
|
|
159
|
+
if (i.parents.includes(e)) {
|
|
160
|
+
F.push({
|
|
161
|
+
image: N(t.element),
|
|
162
|
+
box: t.screen
|
|
163
|
+
});
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
let n = t.host;
|
|
167
|
+
if (i.beneath.some((t) => t !== e && t.element.contains(n))) continue;
|
|
168
|
+
n.id ||= t.hostId = `lg-surface-${C}-${e.serial}`;
|
|
169
|
+
let r = n.getBoundingClientRect(), a = y.getBoundingClientRect();
|
|
170
|
+
F.push({
|
|
171
|
+
image: N(n),
|
|
172
|
+
box: {
|
|
173
|
+
left: r.left - a.left,
|
|
174
|
+
top: r.top - a.top,
|
|
175
|
+
width: r.width,
|
|
176
|
+
height: r.height
|
|
177
|
+
}
|
|
80
178
|
});
|
|
81
179
|
}
|
|
82
|
-
let
|
|
83
|
-
|
|
84
|
-
image:
|
|
85
|
-
box:
|
|
180
|
+
let I = i.parents[0], L = I && D.get(I.serial)?.screen, z = I && L && I.opacity >= .999 && L.left <= s.left && L.top <= s.top && L.left + L.width >= s.left + s.width && L.top + L.height >= s.top + s.height;
|
|
181
|
+
z || F.push({
|
|
182
|
+
image: N(y),
|
|
183
|
+
box: b
|
|
86
184
|
});
|
|
87
|
-
let
|
|
88
|
-
let [t, n] =
|
|
185
|
+
let B = z || !S ? [] : S.regions.flatMap((e) => {
|
|
186
|
+
let [t, n] = M(b.left + S.left + e.x, b.top + S.top + e.y), r = {
|
|
89
187
|
...e,
|
|
90
188
|
x: t,
|
|
91
189
|
y: n,
|
|
92
|
-
width: e.width /
|
|
93
|
-
height: e.height /
|
|
94
|
-
blur: e.blur / Math.max(
|
|
95
|
-
refraction: e.refraction / Math.max(
|
|
190
|
+
width: e.width / E.sx,
|
|
191
|
+
height: e.height / E.sy,
|
|
192
|
+
blur: e.blur / Math.max(E.sx, E.sy),
|
|
193
|
+
refraction: e.refraction / Math.max(E.sx, E.sy)
|
|
96
194
|
}, i = 3 * r.blur + r.refraction;
|
|
97
|
-
return r.x <
|
|
195
|
+
return r.x < x.width + i && r.x + r.width > -i && r.y < x.height + i && r.y + r.height > -i ? [r] : [];
|
|
98
196
|
});
|
|
99
|
-
|
|
100
|
-
|
|
197
|
+
B.length && R.push(v(`${o.base}-blur`, B, x.width, x.height, "gecko"));
|
|
198
|
+
let V = n(i.options, i.w, i.h), ne = t(O, V), H = ne.blur > 0 || ne.fill > 0, U = H ? "source" : void 0;
|
|
199
|
+
H && ee(o), o.split && (k(o, "display", H ? "block" : "none", "glass"), k(o, "display", H ? "block" : "none", "light"), k(o, "display", H ? "block" : "none", "rim")), k(o, "left", `${x.left}px`), k(o, "top", `${x.top}px`), k(o, "width", `${x.width}px`), k(o, "height", `${x.height}px`), k(o, "opacity", String(Math.round(i.opacity * 1e3) / 1e3)), o.split && k(o, "background-image", H ? "none" : F.map((e) => e.image).join(", ")), k(o, "background-image", F.map((e) => e.image).join(", "), U);
|
|
200
|
+
let W = T ? c : "", G = (e, t) => {
|
|
201
|
+
(e || o.written.has(t ? `${t} background-color` : "background-color")) && k(o, "background-color", e, t);
|
|
202
|
+
};
|
|
203
|
+
G(H ? "" : W), o.split && G(H ? W : "", "source"), k(o, "background-position", F.map((e) => {
|
|
204
|
+
let [t, n] = M(e.box.left, e.box.top);
|
|
101
205
|
return `${t}px ${n}px`;
|
|
102
|
-
}).join(", ")),
|
|
103
|
-
let
|
|
104
|
-
|
|
105
|
-
let
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
206
|
+
}).join(", "), U), k(o, "background-size", F.map((e) => `${e.box.width / E.sx}px ${e.box.height / E.sy}px`).join(", "), U);
|
|
207
|
+
let K = `x="${w.left}" y="${w.top}" width="${w.width}" height="${w.height}"`, q = (e, t) => a(i.maps, e, t, w.left, w.top, w.width, w.height), J = Math.max(E.sx, E.sy), Y = (e) => `<filter id="${e}" x="0" y="0" width="1" height="1" filterUnits="objectBoundingBox" primitiveUnits="userSpaceOnUse" color-interpolation-filters="sRGB">`;
|
|
208
|
+
if (H) {
|
|
209
|
+
let e = h(O), t = u("l", "SourceGraphic", O, V, 1 / J), n = l("l", t.result, "SourceGraphic", O, V, 1 / J), r = Math.ceil(i.refraction / J) + 2, s = B.length > 0 ? {
|
|
210
|
+
left: 0,
|
|
211
|
+
top: 0,
|
|
212
|
+
width: x.width,
|
|
213
|
+
height: x.height
|
|
214
|
+
} : {
|
|
215
|
+
left: Math.max(0, w.left - r),
|
|
216
|
+
top: Math.max(0, w.top - r),
|
|
217
|
+
width: Math.min(x.width, w.left + w.width + r) - Math.max(0, w.left - r),
|
|
218
|
+
height: Math.min(x.height, w.top + w.height + r) - Math.max(0, w.top - r)
|
|
219
|
+
}, c = {
|
|
220
|
+
left: w.left - s.left,
|
|
221
|
+
top: w.top - s.top,
|
|
222
|
+
width: w.width,
|
|
223
|
+
height: w.height
|
|
224
|
+
}, d = `x="${c.left}" y="${c.top}" width="${c.width}" height="${c.height}"`, f = `<feDisplacementMap in="SourceGraphic" in2="lfield" scale="${2 * i.refraction / J}" xChannelSelector="R" yChannelSelector="G" ${d}`;
|
|
225
|
+
R.push(`${Y(o.base)}${a(i.maps, "field", "lfield", c.left, c.top, c.width, c.height)}${f}/></filter>`, `${Y(`${o.base}-material`)}${t.markup}${n.markup}${_("l", O, V, n.result)}${e ? g("l", O, e).markup : ""}</filter>`, ...e ? [`${Y(`${o.base}-light`)}${p("SourceGraphic", "llight", e)}</filter>`] : []);
|
|
226
|
+
for (let [e, t] of Object.entries({
|
|
227
|
+
left: s.left,
|
|
228
|
+
top: s.top,
|
|
229
|
+
width: s.width,
|
|
230
|
+
height: s.height
|
|
231
|
+
})) k(o, e, `${t}px`, "refracted");
|
|
232
|
+
k(o, "background-image", F.map((e) => e.image).join(", "), "refracted"), G(W, "refracted"), k(o, "background-position", F.map((e) => {
|
|
233
|
+
let [t, n] = M(e.box.left, e.box.top);
|
|
234
|
+
return `${t - s.left}px ${n - s.top}px`;
|
|
235
|
+
}).join(", "), "refracted"), k(o, "background-size", F.map((e) => `${e.box.width / E.sx}px ${e.box.height / E.sy}px`).join(", "), "refracted"), P(o, "refracted", "mask", A(i.maps, "field", c), c), P(o, "glass", "mask", A(i.maps, "field", w), w), P(o, "light", "background", A(i.maps, "light", w), w), P(o, "rim", "background", A(i.maps, "rim", w), w);
|
|
236
|
+
continue;
|
|
129
237
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
238
|
+
let X = "SourceGraphic", Z = [q("field", "lfield")], re = u("l", X, O, V, 1 / J);
|
|
239
|
+
Z.push(re.markup), X = re.result, Z.push(m("l", X, i.refraction / J, e(O, V) / J).replace(/<feDisplacementMap\b/g, `<feDisplacementMap ${K}`));
|
|
240
|
+
let ie = l("l", "lrefracted", "SourceGraphic", O, V, 1 / J);
|
|
241
|
+
Z.push(ie.markup, _("l", O, V, ie.result));
|
|
242
|
+
let ae = "lcolor", Q = "llight", $ = h(O);
|
|
243
|
+
if ($) {
|
|
244
|
+
let e = g("l", O, $);
|
|
245
|
+
Z.push(e.markup), ae = e.color, Q = "ltintLight";
|
|
135
246
|
}
|
|
136
|
-
|
|
137
|
-
let
|
|
138
|
-
|
|
247
|
+
Z.push(q("light", "llight"), ...$ ? [p("llight", Q, $)] : [], d("l", ae, Q, "lfield", O.material).replace(/<feComposite\b/g, `<feComposite ${K}`), q("rim", "lrim"), f("l", "SourceGraphic", "lrim", 1, r(O, V)), `<feComposite in="lrim" in2="lfield" operator="in" ${K} result="lring"/>`, `<feMerge ${K} result="lglass"><feMergeNode in="loutline"/><feMergeNode in="llitInside"/><feMergeNode in="lring"/></feMerge>`);
|
|
248
|
+
let oe = Z.join("").replace(/<(feComponentTransfer|feColorMatrix)\b(?![^>]*\sx=")([^>]*?)(\/?)>/g, `<$1$2 ${K}$3>`);
|
|
249
|
+
R.push(`${Y(o.base)}${oe}</filter>`);
|
|
139
250
|
}
|
|
140
|
-
let
|
|
141
|
-
for (let {
|
|
142
|
-
|
|
143
|
-
|
|
251
|
+
let B = i(E, R, o), V = new Set(R.map((e) => /id="([^"]+)"/.exec(e)[1]));
|
|
252
|
+
for (let { lens: e, layer: t } of z) {
|
|
253
|
+
if (e.mode !== "copy") {
|
|
254
|
+
I(t, B, V);
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
let n = `${t.base}-blur`, r = [V.has(n) ? `url("#${B(n)}")` : "", `url("#${B(t.base)}")`].filter(Boolean).join(" "), i = t.split && t.written.get("glass display") === "block";
|
|
258
|
+
t.split && k(t, "filter", i ? "none" : r), i ? (k(t, "filter", r, "refracted"), k(t, "filter", V.has(n) ? `url("#${B(n)}")` : "none", "source"), k(t, "filter", `url("#${B(`${t.base}-material`)}")`, "glass"), k(t, "filter", V.has(`${t.base}-light`) ? `url("#${B(`${t.base}-light`)}")` : "none", "light")) : k(t, "filter", r);
|
|
144
259
|
}
|
|
145
260
|
},
|
|
146
261
|
owns(e) {
|
|
147
|
-
if (
|
|
148
|
-
for (let t of
|
|
262
|
+
if (T.contains(e)) return !0;
|
|
263
|
+
for (let t of D.values()) if (t.element.contains(e)) return !0;
|
|
149
264
|
return !1;
|
|
150
265
|
},
|
|
151
266
|
dispose() {
|
|
152
|
-
for (let [e, t] of
|
|
153
|
-
|
|
267
|
+
for (let [e, t] of D) M(e, t);
|
|
268
|
+
T.remove(), L();
|
|
154
269
|
}
|
|
155
270
|
};
|
|
156
|
-
function
|
|
157
|
-
if (!
|
|
158
|
-
let { element: e, original: t, id: n } =
|
|
159
|
-
e.id === n && t === null && e.removeAttribute("id"),
|
|
271
|
+
function L() {
|
|
272
|
+
if (!O) return;
|
|
273
|
+
let { element: e, original: t, id: n } = O;
|
|
274
|
+
e.id === n && t === null && e.removeAttribute("id"), O = void 0;
|
|
160
275
|
}
|
|
161
276
|
}
|
|
162
|
-
|
|
163
|
-
export { m as createLensLayers };
|
|
277
|
+
export { S as createLensLayers };
|
package/dist/dom/map-encoder.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { encodeMapPixels as e } from "./map-encoding.js";
|
|
2
|
-
|
|
2
|
+
// src/dom/map-encoder.ts
|
|
3
3
|
var t, n = !1, r, i = 0, a = /* @__PURE__ */ new Map();
|
|
4
4
|
async function o() {
|
|
5
5
|
if (!n) return t || (r ??= import("./map-encoder.worker.js").then(({ default: e }) => {
|
|
@@ -19,29 +19,32 @@ async function o() {
|
|
|
19
19
|
n = !0;
|
|
20
20
|
}));
|
|
21
21
|
}
|
|
22
|
-
async function s(t, n, r, s) {
|
|
23
|
-
let
|
|
24
|
-
if (
|
|
22
|
+
async function s(t, n, r, s, c) {
|
|
23
|
+
let l = await o();
|
|
24
|
+
if (l) try {
|
|
25
25
|
return await new Promise((e, o) => {
|
|
26
|
-
let
|
|
27
|
-
a.set(
|
|
26
|
+
let u = ++i;
|
|
27
|
+
a.set(u, {
|
|
28
28
|
resolve: e,
|
|
29
29
|
reject: o
|
|
30
30
|
});
|
|
31
31
|
try {
|
|
32
|
-
|
|
33
|
-
id:
|
|
32
|
+
l.postMessage({
|
|
33
|
+
id: u,
|
|
34
34
|
pixels: t,
|
|
35
35
|
width: n,
|
|
36
36
|
height: r,
|
|
37
|
-
cap: s
|
|
37
|
+
cap: s,
|
|
38
|
+
nine: c
|
|
38
39
|
});
|
|
39
40
|
} catch (e) {
|
|
40
|
-
a.delete(
|
|
41
|
+
a.delete(u), o(e);
|
|
41
42
|
}
|
|
42
43
|
});
|
|
43
44
|
} catch {}
|
|
44
|
-
return e(t, n, r, s);
|
|
45
|
+
return e(t, n, r, s, c);
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
function c() {
|
|
48
|
+
o();
|
|
49
|
+
}
|
|
50
|
+
export { s as encodeMaterialPixels, c as warmMapEncoder };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
var e = "(function(){let e=/* @__PURE__ */ new Int32Array(256);for(let t=0;t<256;t++){let n=t;for(let e=0;e<8;e++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n}function t(t,n=0,r=t.length){let i=-1;for(let a=n;a<r;a++)i=e[(i^t[a])&255]^i>>>8;return(i^-1)>>>0}function n(e){let t=1,n=0;for(let r=0;r<e.length;){let i=Math.min(e.length,r+3800);for(;r<i;r++)t+=e[r],n+=t;t%=65521,n%=65521}return(n<<16|t)>>>0}function r(e){let t=Math.max(1,Math.ceil(e.length/65535)),r=new Uint8Array(2+e.length+t*5+4);r[0]=120,r[1]=1;let i=2;for(let n=0;n<t;n++){let a=n*65535,o=Math.min(65535,e.length-a);r[i++]=+(n===t-1),r[i++]=o&255,r[i++]=o>>>8,r[i++]=~o&255,r[i++]=~o>>>8&255,r.set(e.subarray(a,a+o),i),i+=o}let a=n(e);return r[i++]=a>>>24,r[i++]=a>>>16&255,r[i++]=a>>>8&255,r[i++]=a&255,r}async function i(e){if(typeof CompressionStream>`u`)return r(e);try{let t=new Blob([e]).stream().pipeThrough(new CompressionStream(`deflate`));return new Uint8Array(await new Response(t).arrayBuffer())}catch{return r(e)}}function a(e,n){let r=new Uint8Array(12+n.length),i=new DataView(r.buffer);i.setUint32(0,n.length);for(let t=0;t<4;t++)r[4+t]=e.charCodeAt(t);return r.set(n,8),i.setUint32(8+n.length,t(r,4,8+n.length)),r}function o(e,t,n,r){let i=e*4,a=new Uint8Array((i+1)*t);for(let e=0;e<t;e++){let t=e*r,o=e*(i+1);a[o]=1;for(let e=0;e<4;e++)a[o+1+e]=n[t+e];for(let e=4;e<i;e++)a[o+1+e]=n[t+e]-n[t+e-4]&255}return a}function s(e,t,n){let r=/* @__PURE__ */ new Uint8Array(13),i=new DataView(r.buffer);i.setUint32(0,e),i.setUint32(4,t),r[8]=8,r[9]=6,r[10]=0,r[11]=0,r[12]=0;let o=[new Uint8Array([137,80,78,71,13,10,26,10]),a(`IHDR`,r),a(`IDAT`,n),a(`IEND`,/* @__PURE__ */ new Uint8Array)],s=new Uint8Array(o.reduce((e,t)=>e+t.length,0)),c=0;for(let e of o)s.set(e,c),c+=e.length;return s}async function c(e,t,n,r=e*4){return s(e,t,await i(o(e,t,n,r)))}let l=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;function u(e){let t=``,n=e.length-e.length%3;for(let r=0;r<n;r+=3){let n=e[r]<<16|e[r+1]<<8|e[r+2];t+=l[n>>>18]+l[n>>>12&63]+l[n>>>6&63]+l[n&63]}if(e.length-n===1){let r=e[n]<<16;t+=l[r>>>18]+l[r>>>12&63]+`==`}else if(e.length-n===2){let r=e[n]<<16|e[n+1]<<8;t+=l[r>>>18]+l[r>>>12&63]+l[r>>>6&63]+`=`}return t}async function d(e,t,n,r){return`data:image/png;base64,${u(await c(e,t,n,r))}`}function f(e,t,n,r){let
|
|
1
|
+
// src/dom/map-encoder.worker.ts?worker&inline
|
|
2
|
+
var e = "(function(){let e=/* @__PURE__ */ new Int32Array(256);for(let t=0;t<256;t++){let n=t;for(let e=0;e<8;e++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n}function t(t,n=0,r=t.length){let i=-1;for(let a=n;a<r;a++)i=e[(i^t[a])&255]^i>>>8;return(i^-1)>>>0}function n(e){let t=1,n=0;for(let r=0;r<e.length;){let i=Math.min(e.length,r+3800);for(;r<i;r++)t+=e[r],n+=t;t%=65521,n%=65521}return(n<<16|t)>>>0}function r(e){let t=Math.max(1,Math.ceil(e.length/65535)),r=new Uint8Array(2+e.length+t*5+4);r[0]=120,r[1]=1;let i=2;for(let n=0;n<t;n++){let a=n*65535,o=Math.min(65535,e.length-a);r[i++]=+(n===t-1),r[i++]=o&255,r[i++]=o>>>8,r[i++]=~o&255,r[i++]=~o>>>8&255,r.set(e.subarray(a,a+o),i),i+=o}let a=n(e);return r[i++]=a>>>24,r[i++]=a>>>16&255,r[i++]=a>>>8&255,r[i++]=a&255,r}async function i(e){if(typeof CompressionStream>`u`)return r(e);try{let t=new Blob([e]).stream().pipeThrough(new CompressionStream(`deflate`));return new Uint8Array(await new Response(t).arrayBuffer())}catch{return r(e)}}function a(e,n){let r=new Uint8Array(12+n.length),i=new DataView(r.buffer);i.setUint32(0,n.length);for(let t=0;t<4;t++)r[4+t]=e.charCodeAt(t);return r.set(n,8),i.setUint32(8+n.length,t(r,4,8+n.length)),r}function o(e,t,n,r){let i=e*4,a=new Uint8Array((i+1)*t);for(let e=0;e<t;e++){let t=e*r,o=e*(i+1);a[o]=1;for(let e=0;e<4;e++)a[o+1+e]=n[t+e];for(let e=4;e<i;e++)a[o+1+e]=n[t+e]-n[t+e-4]&255}return a}function s(e,t,n){let r=/* @__PURE__ */ new Uint8Array(13),i=new DataView(r.buffer);i.setUint32(0,e),i.setUint32(4,t),r[8]=8,r[9]=6,r[10]=0,r[11]=0,r[12]=0;let o=[new Uint8Array([137,80,78,71,13,10,26,10]),a(`IHDR`,r),a(`IDAT`,n),a(`IEND`,/* @__PURE__ */ new Uint8Array)],s=new Uint8Array(o.reduce((e,t)=>e+t.length,0)),c=0;for(let e of o)s.set(e,c),c+=e.length;return s}async function c(e,t,n,r=e*4){return s(e,t,await i(o(e,t,n,r)))}let l=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;function u(e){let t=``,n=e.length-e.length%3;for(let r=0;r<n;r+=3){let n=e[r]<<16|e[r+1]<<8|e[r+2];t+=l[n>>>18]+l[n>>>12&63]+l[n>>>6&63]+l[n&63]}if(e.length-n===1){let r=e[n]<<16;t+=l[r>>>18]+l[r>>>12&63]+`==`}else if(e.length-n===2){let r=e[n]<<16|e[n+1]<<8;t+=l[r>>>18]+l[r>>>12&63]+l[r>>>6&63]+`=`}return t}async function d(e,t,n,r){return`data:image/png;base64,${u(await c(e,t,n,r))}`}function f(e,t,n,r,i){let a=t*4,o=[[0,0,t,n]];if(r!==void 0&&o.push([0,0,r,n],[r,0,t-2*r,n],[t-r,0,r,n]),i){let e=Math.max(1,Math.min(i.x,Math.ceil(t/2))),r=Math.max(1,Math.min(i.y,Math.ceil(n/2))),a=Math.floor(t/2),s=Math.floor(n/2);for(let[i,c]of[[0,r],[s,1],[n-r,r]])o.push([0,i,e,c],[a,i,1,c],[t-e,i,e,c])}return Promise.all(Array.from({length:3},(t,r)=>{let i=r*n*a;return Promise.all(o.map(([t,n,r,o])=>d(r,o,e.subarray(i+n*a+t*4,i+(n+o)*a),a)))}))}let p=Promise.resolve();self.onmessage=({data:{id:e,pixels:t,width:n,height:r,cap:i,nine:a}})=>{p=p.then(async()=>{try{self.postMessage({id:e,planes:await f(t,n,r,i,a)})}catch(t){self.postMessage({id:e,error:String(t)})}})}})();", t = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", e], { type: "text/javascript;charset=utf-8" });
|
|
3
3
|
function n(n) {
|
|
4
4
|
let r;
|
|
5
5
|
try {
|
|
@@ -12,5 +12,4 @@ function n(n) {
|
|
|
12
12
|
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(e), { name: n?.name });
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
//#endregion
|
|
16
15
|
export { n as default };
|
package/dist/dom/map-encoding.js
CHANGED
|
@@ -1,17 +1,54 @@
|
|
|
1
1
|
import { pngDataUrl as e } from "./png.js";
|
|
2
2
|
import "../gpu/planes.js";
|
|
3
|
-
|
|
4
|
-
function t(t, n, r, i) {
|
|
5
|
-
let
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
];
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
// src/dom/map-encoding.ts
|
|
4
|
+
function t(t, n, r, i, a) {
|
|
5
|
+
let o = n * 4, s = [[
|
|
6
|
+
0,
|
|
7
|
+
0,
|
|
8
|
+
n,
|
|
9
|
+
r
|
|
10
|
+
]];
|
|
11
|
+
if (i !== void 0 && s.push([
|
|
12
|
+
0,
|
|
13
|
+
0,
|
|
14
|
+
i,
|
|
15
|
+
r
|
|
16
|
+
], [
|
|
17
|
+
i,
|
|
18
|
+
0,
|
|
19
|
+
n - 2 * i,
|
|
20
|
+
r
|
|
21
|
+
], [
|
|
22
|
+
n - i,
|
|
23
|
+
0,
|
|
24
|
+
i,
|
|
25
|
+
r
|
|
26
|
+
]), a) {
|
|
27
|
+
let e = Math.max(1, Math.min(a.x, Math.ceil(n / 2))), t = Math.max(1, Math.min(a.y, Math.ceil(r / 2))), i = Math.floor(n / 2), o = Math.floor(r / 2);
|
|
28
|
+
for (let [a, c] of [
|
|
29
|
+
[0, t],
|
|
30
|
+
[o, 1],
|
|
31
|
+
[r - t, t]
|
|
32
|
+
]) s.push([
|
|
33
|
+
0,
|
|
34
|
+
a,
|
|
35
|
+
e,
|
|
36
|
+
c
|
|
37
|
+
], [
|
|
38
|
+
i,
|
|
39
|
+
a,
|
|
40
|
+
1,
|
|
41
|
+
c
|
|
42
|
+
], [
|
|
43
|
+
n - e,
|
|
44
|
+
a,
|
|
45
|
+
e,
|
|
46
|
+
c
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
return Promise.all(Array.from({ length: 3 }, (n, i) => {
|
|
50
|
+
let a = i * r * o;
|
|
51
|
+
return Promise.all(s.map(([n, r, i, s]) => e(i, s, t.subarray(a + r * o + n * 4, a + (r + s) * o), o)));
|
|
14
52
|
}));
|
|
15
53
|
}
|
|
16
|
-
//#endregion
|
|
17
54
|
export { t as encodeMapPixels };
|
package/dist/dom/map-image.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { touchMaps as e } from "./maps.js";
|
|
2
|
-
|
|
2
|
+
// src/dom/map-image.ts
|
|
3
3
|
var t = {
|
|
4
4
|
field: "field",
|
|
5
|
-
|
|
5
|
+
rim: "rim",
|
|
6
|
+
light: "light"
|
|
6
7
|
}, n = (e, n) => `s${e}${t[n]}`;
|
|
7
8
|
function r(e) {
|
|
8
|
-
if (!(e.outline || e.radius !== "capsule" || !Number.isFinite(e.width) || !Number.isFinite(e.height) || e.height <= 0 || e.width < e.height * 2)) return {
|
|
9
|
+
if (!(e.outline || e.radius !== "capsule" || !Number.isFinite(e.width) || !Number.isFinite(e.height) || e.height <= 0 || e.width < (e.material === "lens" ? 0 : e.height * 2))) return {
|
|
9
10
|
...e,
|
|
10
11
|
width: e.height * 3
|
|
11
12
|
};
|
|
@@ -23,12 +24,33 @@ function l(e) {
|
|
|
23
24
|
t && (i.delete(e), a.delete(t));
|
|
24
25
|
}
|
|
25
26
|
function u(t, n, r, i, a, o, c, l = 1, u = 1) {
|
|
26
|
-
let d = (e, t, n, r) => `<feImage data-map="${s(e)}" x="${t / l}" y="${a / u}" width="${n / l}" height="${c / u}" preserveAspectRatio="
|
|
27
|
+
let d = (e, t, n, r, i = "none") => `<feImage data-map="${s(e)}" x="${t / l}" y="${a / u}" width="${n / l}" height="${c / u}" preserveAspectRatio="${i}" result="${r}"/>`;
|
|
27
28
|
e(t);
|
|
28
29
|
let f = t.capsule, p = f ? f.cap * c / f.height : 0;
|
|
29
|
-
if (!f
|
|
30
|
+
if (!f) return d(t[n], i, o, r);
|
|
30
31
|
let [m, h, g] = f.planes[n];
|
|
32
|
+
if (o < p * 2) {
|
|
33
|
+
let e = o / 2;
|
|
34
|
+
return d(m, i, e + .5, `${r}L`, "xMinYMid slice") + d(g, i + e - .5, e + .5, `${r}R`, "xMaxYMid slice") + `<feMerge result="${r}" x="${i / l}" y="${a / u}" width="${o / l}" height="${c / u}"><feMergeNode in="${r}L"/><feMergeNode in="${r}R"/></feMerge>`;
|
|
35
|
+
}
|
|
31
36
|
return d(h, i + p - .5, o - p * 2 + 1, `${r}M`) + d(m, i, p, `${r}L`) + d(g, i + o - p, p, `${r}R`) + `<feMerge result="${r}" x="${i / l}" y="${a / u}" width="${o / l}" height="${c / u}"><feMergeNode in="${r}M"/><feMergeNode in="${r}L"/><feMergeNode in="${r}R"/></feMerge>`;
|
|
32
37
|
}
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
function d(t, n, r, i, a, o, c, l = 1) {
|
|
39
|
+
let d = t.nine;
|
|
40
|
+
if (!d) return u(t, n, r, i, a, o, c);
|
|
41
|
+
e(t);
|
|
42
|
+
let f = d.planes[n], p = (e) => Math.round(e / l) * l, m = (e, t, n) => {
|
|
43
|
+
let r = p(e), i = p(e + t), a = Math.min(p(n), p((i - r) / 2));
|
|
44
|
+
return [
|
|
45
|
+
[r, a],
|
|
46
|
+
[r + a, i - r - 2 * a],
|
|
47
|
+
[i - a, a]
|
|
48
|
+
];
|
|
49
|
+
}, h = m(i, o, d.x), g = m(a, c, d.y), _ = [], v = "";
|
|
50
|
+
return g.forEach(([e, t], n) => h.forEach(([i, a], o) => {
|
|
51
|
+
if (a < .01 || t < .01) return;
|
|
52
|
+
let c = `${r}${n}${o}`;
|
|
53
|
+
_.push(c), v += `<feImage data-map="${s(f[n * 3 + o])}" x="${i}" y="${e}" width="${a}" height="${t}" preserveAspectRatio="none" result="${c}"/>`;
|
|
54
|
+
})), `${v}<feMerge result="${r}" x="${i}" y="${a}" width="${o}" height="${c}">${_.map((e) => `<feMergeNode in="${e}"/>`).join("")}</feMerge>`;
|
|
55
|
+
}
|
|
56
|
+
export { r as capsuleMapGeometry, u as mapImage, s as mapToken, c as mapUrl, d as nineMapImage, l as releaseMapToken, n as surfaceMapResult };
|