@weasel-js/hud 1.10.1 → 1.11.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/dist/accessibleMirror.d.ts +10 -0
- package/dist/accessibleMirror.d.ts.map +1 -0
- package/dist/attach.d.ts.map +1 -1
- package/dist/boxShadow.d.ts +14 -0
- package/dist/boxShadow.d.ts.map +1 -0
- package/dist/glyph.d.ts +19 -0
- package/dist/glyph.d.ts.map +1 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +847 -80
- package/dist/index.js.map +1 -1
- package/dist/loupe/createLoupe.d.ts +5 -3
- package/dist/loupe/createLoupe.d.ts.map +1 -1
- package/dist/menu/accessibleMenu.d.ts +6 -0
- package/dist/menu/accessibleMenu.d.ts.map +1 -0
- package/dist/menu/attachMenuHost.d.ts +11 -0
- package/dist/menu/attachMenuHost.d.ts.map +1 -0
- package/dist/menu/drawPanel.d.ts +35 -0
- package/dist/menu/drawPanel.d.ts.map +1 -0
- package/dist/menu/measureLabel.d.ts +7 -0
- package/dist/menu/measureLabel.d.ts.map +1 -0
- package/dist/menu/menuWidget.d.ts +26 -0
- package/dist/menu/menuWidget.d.ts.map +1 -0
- package/dist/menu/placePanels.d.ts +28 -0
- package/dist/menu/placePanels.d.ts.map +1 -0
- package/dist/menu/valueRows.d.ts +49 -0
- package/dist/menu/valueRows.d.ts.map +1 -0
- package/dist/react/index.js +1 -1
- package/dist/{tool-Dq_D9qpD.js → tool-B5AjewKP.js} +147 -94
- package/dist/tool-B5AjewKP.js.map +1 -0
- package/dist/widget.d.ts +28 -0
- package/dist/widget.d.ts.map +1 -1
- package/package.json +14 -8
- package/dist/tool-Dq_D9qpD.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,769 @@
|
|
|
1
|
-
import { a as e, c as t, d as n,
|
|
2
|
-
import { createViewportLayer as
|
|
3
|
-
import { clamp as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "./tool-B5AjewKP.js";
|
|
2
|
+
import { createViewportLayer as f, pathFromD as p, screenToWorld as m, textCommandFromRuns as h, viewToTransform as g } from "@weasel-js/core";
|
|
3
|
+
import { clamp as _, identity as v, mat3 as y, multiply as b, pathFromD as x, rotateAboutPoint as S, roundRectPath as C, scale as w, translate as T } from "@weasel-js/geom";
|
|
4
|
+
import { expandVars as E, parseBoxShadow as D, resolveCurrentColor as O, tokenPx as k } from "@weasel-js/theme";
|
|
5
|
+
import { faceGeneration as A, metricsOf as j, resolveFontVariant as M } from "@weasel-js/font";
|
|
6
|
+
import { createMenuController as N, menuNumberCanStep as P, menuNumberText as ee, placeMenu as te, placeMenuUnder as ne, placeSubmenu as re, withLinks as ie } from "@weasel-js/menu";
|
|
7
|
+
import { formatShortcut as ae } from "@weasel-js/gestures";
|
|
8
|
+
import { toIconRef as oe } from "@weasel-js/icons";
|
|
9
|
+
import { releaseImageSource as se } from "@weasel-js/core/renderer";
|
|
10
|
+
import { createLoupeModel as ce, loupeInnerView as le, loupeInnerView as F } from "@weasel-js/loupe";
|
|
11
|
+
//#region src/menu/accessibleMenu.ts
|
|
12
|
+
function ue(e, t) {
|
|
13
|
+
return t.kind === "number" ? `${t.label}: ${ee(e.numberValue(t), t)}` : t.kind === "color" ? `${t.label}: ${t.value ?? "—"}` : t.kind === "text" ? `${t.label}: ${e.textValue(t) ?? "—"}` : t.label;
|
|
14
|
+
}
|
|
15
|
+
function I(e, t) {
|
|
16
|
+
let n = e.stack(), r = t === n.length - 1;
|
|
17
|
+
return e.entriesAt(t).map((i, a) => {
|
|
18
|
+
if (i.kind === "separator") return {
|
|
19
|
+
role: "separator",
|
|
20
|
+
key: i.key
|
|
21
|
+
};
|
|
22
|
+
let o = i.kind === "item" && i.checked !== void 0, s = i.kind === "submenu" && n[t] === a && n.length > t + 1;
|
|
23
|
+
return {
|
|
24
|
+
role: o ? "menuitemcheckbox" : "menuitem",
|
|
25
|
+
key: i.key,
|
|
26
|
+
label: ue(e, i),
|
|
27
|
+
...r && n[t] === a ? { active: !0 } : {},
|
|
28
|
+
...i.kind === "item" && i.checked !== void 0 ? { checked: i.checked } : {},
|
|
29
|
+
...i.disabled || i.kind === "color" || i.kind === "text" ? { disabled: !0 } : {},
|
|
30
|
+
...i.kind === "submenu" ? { expanded: s } : {},
|
|
31
|
+
...s ? { children: [{
|
|
32
|
+
role: "menu",
|
|
33
|
+
key: "menu",
|
|
34
|
+
label: i.label,
|
|
35
|
+
children: I(e, t + 1)
|
|
36
|
+
}] } : {}
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function de(e) {
|
|
41
|
+
return {
|
|
42
|
+
role: "menu",
|
|
43
|
+
key: "menu",
|
|
44
|
+
label: "Context menu",
|
|
45
|
+
children: I(e, 0)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/boxShadow.ts
|
|
50
|
+
var fe = 7, pe = .16, L = (e) => ({ paint: {
|
|
51
|
+
kind: "solid",
|
|
52
|
+
color: e
|
|
53
|
+
} });
|
|
54
|
+
function R(e, t, n, r, i) {
|
|
55
|
+
let a = Math.max(0, Math.min(i, n / 2, r / 2));
|
|
56
|
+
return a === 0 ? `M ${e} ${t} H ${e + n} V ${t + r} H ${e} Z` : `M ${e + a} ${t} H ${e + n - a} A ${a} ${a} 0 0 1 ${e + n} ${t + a} V ${t + r - a} A ${a} ${a} 0 0 1 ${e + n - a} ${t + r} H ${e + a} A ${a} ${a} 0 0 1 ${e} ${t + r - a} V ${t + a} A ${a} ${a} 0 0 1 ${e + a} ${t} Z`;
|
|
57
|
+
}
|
|
58
|
+
function me(e, t, n, r) {
|
|
59
|
+
let i = (r) => {
|
|
60
|
+
let i = e.w + r * 2, a = e.h + r * 2;
|
|
61
|
+
return i > 0 && a > 0 ? C(e.x + n.x - r, e.y + n.y - r, i, a, Math.max(0, t + r)) : null;
|
|
62
|
+
};
|
|
63
|
+
if (n.blur <= 0) {
|
|
64
|
+
let e = i(n.spread);
|
|
65
|
+
return {
|
|
66
|
+
kind: "group",
|
|
67
|
+
children: e ? [{
|
|
68
|
+
kind: "path",
|
|
69
|
+
path: e,
|
|
70
|
+
fill: L(r)
|
|
71
|
+
}] : []
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
let a = [], o = n.blur / 6;
|
|
75
|
+
for (let e = 0; e < fe; e++) {
|
|
76
|
+
let t = i(n.spread + n.blur / 2 - e * o);
|
|
77
|
+
t && a.push({
|
|
78
|
+
kind: "path",
|
|
79
|
+
path: t,
|
|
80
|
+
fill: L(r)
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
kind: "group",
|
|
85
|
+
alpha: pe,
|
|
86
|
+
children: a
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function he(e, t, n, r) {
|
|
90
|
+
let i = Math.abs(n.x) + Math.abs(n.y) + Math.abs(n.spread) + 1, a = R(e.x + n.x + n.spread, e.y + n.y + n.spread, e.w - n.spread * 2, e.h - n.spread * 2, Math.max(0, t - n.spread)), o = x(`${R(e.x - i, e.y - i, e.w + i * 2, e.h + i * 2, 0)} ${a}`);
|
|
91
|
+
return {
|
|
92
|
+
kind: "group",
|
|
93
|
+
clip: C(e.x, e.y, e.w, e.h, t),
|
|
94
|
+
children: [{
|
|
95
|
+
kind: "path",
|
|
96
|
+
path: o.kind === "polygon" ? {
|
|
97
|
+
...o,
|
|
98
|
+
fillRule: "evenodd"
|
|
99
|
+
} : o,
|
|
100
|
+
fill: L(r)
|
|
101
|
+
}]
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function z(e, t, n, r, i = e) {
|
|
105
|
+
let a = [], o = [], s = Math.max(0, t - (i.x - e.x));
|
|
106
|
+
for (let c of [...n].reverse()) {
|
|
107
|
+
let n = O(c.color, r);
|
|
108
|
+
c.inset ? o.push(he(i, s, c, n)) : a.push(me(e, t, c, n));
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
under: a,
|
|
112
|
+
over: o
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/glyph.ts
|
|
117
|
+
var ge = {
|
|
118
|
+
fill: "none",
|
|
119
|
+
stroke: "currentColor",
|
|
120
|
+
"stroke-width": "1.5",
|
|
121
|
+
"stroke-linecap": "round",
|
|
122
|
+
"stroke-linejoin": "round"
|
|
123
|
+
}, _e = /* @__PURE__ */ new Set([
|
|
124
|
+
"fill",
|
|
125
|
+
"fill-opacity",
|
|
126
|
+
"fill-rule",
|
|
127
|
+
"stroke",
|
|
128
|
+
"stroke-width",
|
|
129
|
+
"stroke-opacity",
|
|
130
|
+
"stroke-linecap",
|
|
131
|
+
"stroke-linejoin",
|
|
132
|
+
"stroke-dasharray"
|
|
133
|
+
]);
|
|
134
|
+
function* ve(e) {
|
|
135
|
+
for (let t of e.matchAll(/<(\/?)([a-zA-Z]+)((?:\s+[\w:-]+="[^"]*")*)\s*(\/?)>/g)) {
|
|
136
|
+
let e = {};
|
|
137
|
+
for (let n of t[3].matchAll(/([\w:-]+)="([^"]*)"/g)) e[n[1]] = n[2];
|
|
138
|
+
yield {
|
|
139
|
+
close: t[1] === "/",
|
|
140
|
+
name: t[2],
|
|
141
|
+
attrs: e,
|
|
142
|
+
selfClosing: t[4] === "/"
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
var B = (e, t = 0) => e === void 0 || e === "" ? t : Number(e), V = (e) => e.trim().split(/[\s,]+/).filter((e) => e !== "").map(Number);
|
|
147
|
+
function ye(e) {
|
|
148
|
+
let t = v();
|
|
149
|
+
if (!e) return t;
|
|
150
|
+
for (let [, n, r] of e.matchAll(/(\w+)\s*\(([^)]*)\)/g)) {
|
|
151
|
+
let e = V(r), i = n === "translate" ? T(e[0] ?? 0, e[1] ?? 0) : n === "scale" ? w(e[0] ?? 1, e[1] ?? e[0] ?? 1) : n === "rotate" ? S(e[1] ?? 0, e[2] ?? 0, (e[0] ?? 0) * Math.PI / 180) : n === "matrix" && e.length === 6 ? e : null;
|
|
152
|
+
i && (t = b(t, i));
|
|
153
|
+
}
|
|
154
|
+
return t;
|
|
155
|
+
}
|
|
156
|
+
function be(e, t, n, r, i, a) {
|
|
157
|
+
return i <= 0 || a <= 0 ? `M ${e} ${t} H ${e + n} V ${t + r} H ${e} Z` : `M ${e + i} ${t} H ${e + n - i} A ${i} ${a} 0 0 1 ${e + n} ${t + a} V ${t + r - a} A ${i} ${a} 0 0 1 ${e + n - i} ${t + r} H ${e + i} A ${i} ${a} 0 0 1 ${e} ${t + r - a} V ${t + a} A ${i} ${a} 0 0 1 ${e + i} ${t} Z`;
|
|
158
|
+
}
|
|
159
|
+
var H = (e, t, n, r) => `M ${e - n} ${t} A ${n} ${r} 0 1 0 ${e + n} ${t} A ${n} ${r} 0 1 0 ${e - n} ${t} Z`;
|
|
160
|
+
function xe(e, t) {
|
|
161
|
+
switch (e) {
|
|
162
|
+
case "path": return t.d;
|
|
163
|
+
case "rect": {
|
|
164
|
+
let e = B(t.width), n = B(t.height), r = Math.min(B(t.rx, B(t.ry)), e / 2), i = Math.min(B(t.ry, B(t.rx)), n / 2);
|
|
165
|
+
return be(B(t.x), B(t.y), e, n, r, i);
|
|
166
|
+
}
|
|
167
|
+
case "circle": return H(B(t.cx), B(t.cy), B(t.r), B(t.r));
|
|
168
|
+
case "ellipse": return H(B(t.cx), B(t.cy), B(t.rx), B(t.ry));
|
|
169
|
+
case "line": return `M ${B(t.x1)} ${B(t.y1)} L ${B(t.x2)} ${B(t.y2)}`;
|
|
170
|
+
case "polygon":
|
|
171
|
+
case "polyline": {
|
|
172
|
+
let n = V(t.points ?? "");
|
|
173
|
+
if (n.length < 4) return;
|
|
174
|
+
let r = [];
|
|
175
|
+
for (let e = 0; e + 1 < n.length; e += 2) r.push(`${n[e]} ${n[e + 1]}`);
|
|
176
|
+
return `M ${r.join(" L ")}${e === "polygon" ? " Z" : ""}`;
|
|
177
|
+
}
|
|
178
|
+
default: return;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
var U = (e, t) => e === void 0 || e === "none" ? null : /^currentcolor$/i.test(e) ? t : e;
|
|
182
|
+
function Se(e, t, n) {
|
|
183
|
+
let r = [], i = U(t.fill, n);
|
|
184
|
+
if (i) {
|
|
185
|
+
let n = {
|
|
186
|
+
kind: "path",
|
|
187
|
+
path: e.kind === "polygon" && t["fill-rule"] === "evenodd" ? {
|
|
188
|
+
...e,
|
|
189
|
+
fillRule: "evenodd"
|
|
190
|
+
} : e,
|
|
191
|
+
fill: { paint: {
|
|
192
|
+
kind: "solid",
|
|
193
|
+
color: i
|
|
194
|
+
} }
|
|
195
|
+
}, a = B(t["fill-opacity"], 1);
|
|
196
|
+
r.push(a < 1 ? {
|
|
197
|
+
kind: "group",
|
|
198
|
+
alpha: a,
|
|
199
|
+
children: [n]
|
|
200
|
+
} : n);
|
|
201
|
+
}
|
|
202
|
+
let a = U(t.stroke, n);
|
|
203
|
+
if (a) {
|
|
204
|
+
let n = t["stroke-dasharray"] && t["stroke-dasharray"] !== "none" ? V(t["stroke-dasharray"]) : void 0, i = {
|
|
205
|
+
kind: "path",
|
|
206
|
+
path: e,
|
|
207
|
+
stroke: {
|
|
208
|
+
paint: {
|
|
209
|
+
kind: "solid",
|
|
210
|
+
color: a
|
|
211
|
+
},
|
|
212
|
+
width: B(t["stroke-width"], 1),
|
|
213
|
+
cap: t["stroke-linecap"],
|
|
214
|
+
join: t["stroke-linejoin"],
|
|
215
|
+
...n ? { dash: n } : {}
|
|
216
|
+
}
|
|
217
|
+
}, o = B(t["stroke-opacity"], 1);
|
|
218
|
+
r.push(o < 1 ? {
|
|
219
|
+
kind: "group",
|
|
220
|
+
alpha: o,
|
|
221
|
+
children: [i]
|
|
222
|
+
} : i);
|
|
223
|
+
}
|
|
224
|
+
return r;
|
|
225
|
+
}
|
|
226
|
+
function W(e, t) {
|
|
227
|
+
let n = { ...t };
|
|
228
|
+
for (let [t, r] of Object.entries(e.attrs)) _e.has(t) && (n[t] = r);
|
|
229
|
+
let r = [], i = {
|
|
230
|
+
kind: "group",
|
|
231
|
+
children: r
|
|
232
|
+
}, a = ye(e.attrs.transform);
|
|
233
|
+
return a.some((e, t) => e !== v()[t]) && (i.transform = y.fromAffine(a)), e.name === "svg" && (i.clip = {
|
|
234
|
+
kind: "rect",
|
|
235
|
+
x: B(e.attrs.x),
|
|
236
|
+
y: B(e.attrs.y),
|
|
237
|
+
width: B(e.attrs.width),
|
|
238
|
+
height: B(e.attrs.height)
|
|
239
|
+
}), {
|
|
240
|
+
attrs: n,
|
|
241
|
+
children: r,
|
|
242
|
+
group: i
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function G(e, t) {
|
|
246
|
+
let n = t.size / 20, r = {
|
|
247
|
+
attrs: ge,
|
|
248
|
+
children: [],
|
|
249
|
+
group: {
|
|
250
|
+
kind: "group",
|
|
251
|
+
transform: y.fromAffine([
|
|
252
|
+
n,
|
|
253
|
+
0,
|
|
254
|
+
0,
|
|
255
|
+
n,
|
|
256
|
+
t.x,
|
|
257
|
+
t.y
|
|
258
|
+
]),
|
|
259
|
+
children: []
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
r.group.children = r.children;
|
|
263
|
+
let i = [r], a = 0;
|
|
264
|
+
for (let n of ve(e.body)) {
|
|
265
|
+
let e = i.at(-1);
|
|
266
|
+
if (a > 0 || n.name === "defs" || n.name === "clipPath") {
|
|
267
|
+
n.selfClosing || (a += n.close ? -1 : 1);
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
if (n.close) {
|
|
271
|
+
(n.name === "g" || n.name === "svg") && i.length > 1 && i.pop();
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
if (n.name === "g" || n.name === "svg") {
|
|
275
|
+
let t = W(n, e.attrs);
|
|
276
|
+
e.children.push(t.group), n.selfClosing || i.push(t);
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
let r = xe(n.name, n.attrs);
|
|
280
|
+
if (r === void 0) continue;
|
|
281
|
+
let o = W(n, e.attrs), s = Se(x(r), o.attrs, t.color);
|
|
282
|
+
o.group.transform ? e.children.push({
|
|
283
|
+
kind: "group",
|
|
284
|
+
transform: o.group.transform,
|
|
285
|
+
children: s
|
|
286
|
+
}) : e.children.push(...s);
|
|
287
|
+
}
|
|
288
|
+
return [r.group];
|
|
289
|
+
}
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region src/menu/valueRows.ts
|
|
292
|
+
function K(e, t) {
|
|
293
|
+
let n = t.rowHeight, r = e - t.padX;
|
|
294
|
+
return {
|
|
295
|
+
minus: {
|
|
296
|
+
x: r - 4 * n,
|
|
297
|
+
w: n
|
|
298
|
+
},
|
|
299
|
+
value: {
|
|
300
|
+
x: r - 3 * n,
|
|
301
|
+
w: 2 * n
|
|
302
|
+
},
|
|
303
|
+
plus: {
|
|
304
|
+
x: r - n,
|
|
305
|
+
w: n
|
|
306
|
+
},
|
|
307
|
+
width: 4 * n
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
function Ce(e, t, n) {
|
|
311
|
+
let { minus: r, plus: i } = K(e, t), a = (e) => n >= e.x && n < e.x + e.w;
|
|
312
|
+
return a(i) ? 1 : a(r) ? -1 : null;
|
|
313
|
+
}
|
|
314
|
+
function we(e, t, n) {
|
|
315
|
+
if (e.kind === "number") return t.padX + K(0, t).width;
|
|
316
|
+
if (e.kind === "color") return Math.max(t.rowHeight, t.padX + n(e.value ?? "—", t.fontSize));
|
|
317
|
+
if (e.kind === "text") return t.padX + n(e.value ?? "—", t.fontSize);
|
|
318
|
+
}
|
|
319
|
+
var q = (e) => ({ paint: {
|
|
320
|
+
kind: "solid",
|
|
321
|
+
color: e
|
|
322
|
+
} }), J = (e, t) => ({
|
|
323
|
+
kind: "path",
|
|
324
|
+
path: p(e),
|
|
325
|
+
stroke: {
|
|
326
|
+
paint: {
|
|
327
|
+
kind: "solid",
|
|
328
|
+
color: t
|
|
329
|
+
},
|
|
330
|
+
width: 1.5,
|
|
331
|
+
cap: "round"
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
function Te(e, t, n, r, i, a) {
|
|
335
|
+
let { minus: o, value: s, plus: c } = K(e.w, i), l = e.y + t.y + t.h / 2, u = (e) => e && !n.disabled ? a.fg : a.muted, d = (t) => e.x + t.x + t.w / 2, f = r !== void 0 && !P(n, r, -1), p = r !== void 0 && !P(n, r, 1);
|
|
336
|
+
return [
|
|
337
|
+
J(`M ${d(o) - 4} ${l} L ${d(o) + 4} ${l}`, u(!f)),
|
|
338
|
+
h(e.x + s.x, e.y + t.y, [{
|
|
339
|
+
text: ee(r, n),
|
|
340
|
+
fill: q(u(!0))
|
|
341
|
+
}], {
|
|
342
|
+
...a.font,
|
|
343
|
+
align: "center"
|
|
344
|
+
}, void 0, t.h, "center", void 0, s.w),
|
|
345
|
+
J(`M ${d(c) - 4} ${l} L ${d(c) + 4} ${l} M ${d(c)} ${l - 4} L ${d(c)} ${l + 4}`, u(!p))
|
|
346
|
+
];
|
|
347
|
+
}
|
|
348
|
+
function Ee(e, t, n, r, i) {
|
|
349
|
+
return [h(e.x + r.padX, e.y + t.y, [{
|
|
350
|
+
text: n ?? "—",
|
|
351
|
+
fill: q(i.muted)
|
|
352
|
+
}], {
|
|
353
|
+
...i.font,
|
|
354
|
+
align: "right"
|
|
355
|
+
}, void 0, t.h, "center", void 0, e.w - r.padX * 2)];
|
|
356
|
+
}
|
|
357
|
+
function De(e, t, n, r, i) {
|
|
358
|
+
let a = [];
|
|
359
|
+
if (n.value !== void 0) {
|
|
360
|
+
let o = e.x + r.padX + (r.rowHeight - 12) / 2, s = e.y + t.y + (t.h - 12) / 2;
|
|
361
|
+
a.push({
|
|
362
|
+
kind: "path",
|
|
363
|
+
path: {
|
|
364
|
+
kind: "rect",
|
|
365
|
+
x: o,
|
|
366
|
+
y: s,
|
|
367
|
+
width: 12,
|
|
368
|
+
height: 12
|
|
369
|
+
},
|
|
370
|
+
fill: q(n.value),
|
|
371
|
+
stroke: {
|
|
372
|
+
paint: {
|
|
373
|
+
kind: "solid",
|
|
374
|
+
color: i.border
|
|
375
|
+
},
|
|
376
|
+
width: 1
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
return a.push(h(e.x + r.padX, e.y + t.y, [{
|
|
381
|
+
text: n.value ?? "—",
|
|
382
|
+
fill: q(i.muted)
|
|
383
|
+
}], {
|
|
384
|
+
...i.font,
|
|
385
|
+
align: "right"
|
|
386
|
+
}, void 0, t.h, "center", void 0, e.w - r.padX * 2)), a;
|
|
387
|
+
}
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region src/menu/drawPanel.ts
|
|
390
|
+
var Y = {
|
|
391
|
+
rowHeight: 24,
|
|
392
|
+
padX: 8,
|
|
393
|
+
padY: 4,
|
|
394
|
+
separatorHeight: 9,
|
|
395
|
+
minWidth: 180,
|
|
396
|
+
fontSize: 13
|
|
397
|
+
};
|
|
398
|
+
function X(e, t) {
|
|
399
|
+
let n = t.padY;
|
|
400
|
+
return e.map((e) => {
|
|
401
|
+
let r = e.kind === "separator" ? t.separatorHeight : t.rowHeight, i = {
|
|
402
|
+
y: n,
|
|
403
|
+
h: r
|
|
404
|
+
};
|
|
405
|
+
return n += r, i;
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
var Oe = (e) => e.kind === "item" ? ae(e.shortcut) : void 0;
|
|
409
|
+
function ke(e, t, n) {
|
|
410
|
+
let r = X(e, t).at(-1), i = Math.max(0, ...e.map((e) => {
|
|
411
|
+
if (e.kind === "separator") return 0;
|
|
412
|
+
let r = we(e, t, n);
|
|
413
|
+
if (r !== void 0) return n(e.label, t.fontSize) + r;
|
|
414
|
+
let i = Oe(e);
|
|
415
|
+
return n(e.label, t.fontSize) + Math.max(t.rowHeight, i ? t.padX + n(i, t.fontSize) : 0);
|
|
416
|
+
}));
|
|
417
|
+
return {
|
|
418
|
+
w: Math.max(t.minWidth, Math.ceil(i) + t.padX * 2 + t.rowHeight),
|
|
419
|
+
h: (r ? r.y + r.h : 0) + t.padY
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
var Z = (e) => ({ paint: {
|
|
423
|
+
kind: "solid",
|
|
424
|
+
color: e
|
|
425
|
+
} }), Ae = (e, t, n, r, i) => ({
|
|
426
|
+
kind: "path",
|
|
427
|
+
path: {
|
|
428
|
+
kind: "rect",
|
|
429
|
+
x: e,
|
|
430
|
+
y: t,
|
|
431
|
+
width: n,
|
|
432
|
+
height: r
|
|
433
|
+
},
|
|
434
|
+
fill: Z(i)
|
|
435
|
+
});
|
|
436
|
+
function je(e, t, n) {
|
|
437
|
+
return {
|
|
438
|
+
kind: "path",
|
|
439
|
+
path: p(`M ${e - 3 / 2} ${t - 3} L ${e + 3 / 2} ${t} L ${e - 3 / 2} ${t + 3}`),
|
|
440
|
+
stroke: {
|
|
441
|
+
paint: {
|
|
442
|
+
kind: "solid",
|
|
443
|
+
color: n
|
|
444
|
+
},
|
|
445
|
+
width: 1.5,
|
|
446
|
+
cap: "round"
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
function Me(e, t, n) {
|
|
451
|
+
return {
|
|
452
|
+
kind: "path",
|
|
453
|
+
path: p(`M ${e - 4} ${t} L ${e - 1.5} ${t + 2.5} L ${e + 4} ${t - 3}`),
|
|
454
|
+
stroke: {
|
|
455
|
+
paint: {
|
|
456
|
+
kind: "solid",
|
|
457
|
+
color: n
|
|
458
|
+
},
|
|
459
|
+
width: 1.5,
|
|
460
|
+
cap: "round",
|
|
461
|
+
join: "round"
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
var Q = 16, Ne = "var(--wzl-bevel-raised, 0 8px 24px var(--wzl-shadow))";
|
|
466
|
+
function Pe(e, t, n, r, i, a, o = (e) => e.value) {
|
|
467
|
+
let s = e.tokens, c = s["--wzl-fg"], l = O(s["--wzl-fg-muted"], c), u = k("--wzl-radius-md", s), d = {
|
|
468
|
+
fontFamily: e.defaultFont,
|
|
469
|
+
fontSize: i.fontSize
|
|
470
|
+
}, f = z(t, u, D(E(Ne, s)), c, {
|
|
471
|
+
x: t.x + 1,
|
|
472
|
+
y: t.y + 1,
|
|
473
|
+
w: t.w - 2,
|
|
474
|
+
h: t.h - 2
|
|
475
|
+
}), p = [
|
|
476
|
+
...f.under,
|
|
477
|
+
{
|
|
478
|
+
kind: "path",
|
|
479
|
+
path: C(t.x, t.y, t.w, t.h, u),
|
|
480
|
+
fill: Z(s["--wzl-surface-popover"]),
|
|
481
|
+
stroke: {
|
|
482
|
+
paint: {
|
|
483
|
+
kind: "solid",
|
|
484
|
+
color: s["--wzl-border"]
|
|
485
|
+
},
|
|
486
|
+
width: 1
|
|
487
|
+
}
|
|
488
|
+
},
|
|
489
|
+
...f.over
|
|
490
|
+
], m = X(n, i);
|
|
491
|
+
return n.forEach((e, n) => {
|
|
492
|
+
let u = m[n];
|
|
493
|
+
if (e.kind === "separator") {
|
|
494
|
+
p.push(Ae(t.x + i.padX, t.y + u.y + Math.floor(u.h / 2), t.w - i.padX * 2, 1, s["--wzl-border"]));
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
n === r && p.push(Ae(t.x + 2, t.y + u.y, t.w - 4, u.h, s["--wzl-surface-hover"]));
|
|
498
|
+
let f = e.disabled || e.kind === "color" || e.kind === "text" ? l : c;
|
|
499
|
+
p.push(h(t.x + i.padX + i.rowHeight, t.y + u.y, [{
|
|
500
|
+
text: e.label,
|
|
501
|
+
fill: Z(f)
|
|
502
|
+
}], d, void 0, u.h, "center"));
|
|
503
|
+
let g = t.x + i.padX + i.rowHeight / 2, _ = t.y + u.y + u.h / 2, v = e.kind !== "color" && typeof e.icon == "string" ? oe(e.icon) : void 0, y = v ? a?.get(v) : void 0;
|
|
504
|
+
e.kind === "item" && e.checked ? p.push(Me(g, _, f)) : y && p.push(...G(y, {
|
|
505
|
+
x: g - Q / 2,
|
|
506
|
+
y: _ - Q / 2,
|
|
507
|
+
size: Q,
|
|
508
|
+
color: f
|
|
509
|
+
}));
|
|
510
|
+
let b = Oe(e);
|
|
511
|
+
b && p.push(h(t.x + i.padX, t.y + u.y, [{
|
|
512
|
+
text: b,
|
|
513
|
+
fill: Z(l)
|
|
514
|
+
}], {
|
|
515
|
+
...d,
|
|
516
|
+
align: "right"
|
|
517
|
+
}, void 0, u.h, "center", void 0, t.w - i.padX * 2));
|
|
518
|
+
let x = {
|
|
519
|
+
fg: c,
|
|
520
|
+
muted: l,
|
|
521
|
+
border: s["--wzl-border"],
|
|
522
|
+
font: d
|
|
523
|
+
};
|
|
524
|
+
e.kind === "number" && p.push(...Te(t, u, e, o(e), i, x)), e.kind === "color" && p.push(...De(t, u, e, i, x)), e.kind === "text" && p.push(...Ee(t, u, e.value, i, x)), e.kind === "submenu" && p.push(je(t.x + t.w - i.padX - i.rowHeight / 2, t.y + u.y + u.h / 2, f));
|
|
525
|
+
}), p;
|
|
526
|
+
}
|
|
527
|
+
function Fe(e, t, n) {
|
|
528
|
+
let r = X(e, t).findIndex((e) => n >= e.y && n < e.y + e.h);
|
|
529
|
+
return r < 0 ? null : r;
|
|
530
|
+
}
|
|
531
|
+
//#endregion
|
|
532
|
+
//#region src/menu/measureLabel.ts
|
|
533
|
+
function Ie(e, t) {
|
|
534
|
+
return e.length * t * .55;
|
|
535
|
+
}
|
|
536
|
+
function Le(e, t, n) {
|
|
537
|
+
let r = j(M(n, 400, "normal"));
|
|
538
|
+
if (!r) return Ie(e, t);
|
|
539
|
+
let i = 0, a = null;
|
|
540
|
+
for (let t of e) {
|
|
541
|
+
let e = t.codePointAt(0);
|
|
542
|
+
i += r.advanceOf(e) ?? r.size * .55, a !== null && (i += r.kernOf(a, e)), a = e;
|
|
543
|
+
}
|
|
544
|
+
return i * t / r.size;
|
|
545
|
+
}
|
|
546
|
+
//#endregion
|
|
547
|
+
//#region src/menu/placePanels.ts
|
|
548
|
+
function Re(e) {
|
|
549
|
+
let t = [], n = null;
|
|
550
|
+
return (r, i) => {
|
|
551
|
+
let a = A();
|
|
552
|
+
(n?.family !== i || n.faces !== a) && (t = [], n = {
|
|
553
|
+
family: i,
|
|
554
|
+
faces: a
|
|
555
|
+
});
|
|
556
|
+
let { width: o, height: s } = e.canvasSize(), c = {
|
|
557
|
+
x: 0,
|
|
558
|
+
y: 0,
|
|
559
|
+
w: o,
|
|
560
|
+
h: s
|
|
561
|
+
}, l = e.metrics, u = r.stack(), d = [], f = !0;
|
|
562
|
+
for (let n = 0; n < u.length; n++) {
|
|
563
|
+
let a = r.entriesAt(n), o = n === 0 ? null : u[n - 1] ?? null, s = t[n];
|
|
564
|
+
if (f && s && s.entries === a && s.parentRow === o) {
|
|
565
|
+
d.push(s);
|
|
566
|
+
continue;
|
|
567
|
+
}
|
|
568
|
+
f = !1;
|
|
569
|
+
let p = ke(a, l, (t, n) => i === null ? Ie(t, n) : e.measure(t, n, i)), m;
|
|
570
|
+
if (n === 0) m = e.under ? ne(p, e.under, c) : te(p, e.anchor, c);
|
|
571
|
+
else {
|
|
572
|
+
let e = d[n - 1].rect, t = X(r.entriesAt(n - 1), l)[o];
|
|
573
|
+
m = re(p, {
|
|
574
|
+
x: e.x,
|
|
575
|
+
y: e.y + t.y,
|
|
576
|
+
w: e.w,
|
|
577
|
+
h: t.h
|
|
578
|
+
}, c);
|
|
579
|
+
}
|
|
580
|
+
let h = {
|
|
581
|
+
x: m.x,
|
|
582
|
+
y: m.y,
|
|
583
|
+
w: p.w,
|
|
584
|
+
h: p.h
|
|
585
|
+
};
|
|
586
|
+
d.push({
|
|
587
|
+
entries: a,
|
|
588
|
+
parentRow: o,
|
|
589
|
+
rect: h
|
|
590
|
+
}), r.setPanel(n, h);
|
|
591
|
+
}
|
|
592
|
+
return t = d, d.map((e) => e.rect);
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
//#endregion
|
|
596
|
+
//#region src/menu/menuWidget.ts
|
|
597
|
+
var ze = [
|
|
598
|
+
"pointer",
|
|
599
|
+
"doubleClick",
|
|
600
|
+
"contextMenu",
|
|
601
|
+
"longPress",
|
|
602
|
+
"wheel"
|
|
603
|
+
];
|
|
604
|
+
function Be(e, t) {
|
|
605
|
+
let n = t({
|
|
606
|
+
x: e.x,
|
|
607
|
+
y: e.y
|
|
608
|
+
}), r = t({
|
|
609
|
+
x: e.x + e.w,
|
|
610
|
+
y: e.y + e.h
|
|
611
|
+
});
|
|
612
|
+
return {
|
|
613
|
+
x: n.x,
|
|
614
|
+
y: n.y,
|
|
615
|
+
w: r.x - n.x,
|
|
616
|
+
h: r.y - n.y
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
function Ve(e) {
|
|
620
|
+
let t = e.metrics ?? Y, r = n(e.onChange), i = N({
|
|
621
|
+
entries: ie(e.open.entries, (e) => window.location.assign(e)),
|
|
622
|
+
highlightFirst: e.open.source === "keyboard",
|
|
623
|
+
onClose: e.close
|
|
624
|
+
}), a = Re({
|
|
625
|
+
anchor: e.toCanvas(e.open.client),
|
|
626
|
+
...e.open.under ? { under: Be(e.open.under, e.toCanvas) } : {},
|
|
627
|
+
canvasSize: e.canvasSize,
|
|
628
|
+
measure: e.measure ?? Le,
|
|
629
|
+
metrics: t
|
|
630
|
+
}), o = null, s = a(i, o), c = !1, l = !1, u = null;
|
|
631
|
+
i.subscribe(() => {
|
|
632
|
+
s = a(i, o), r.changed();
|
|
633
|
+
});
|
|
634
|
+
let d = (e, t) => {
|
|
635
|
+
for (let n = s.length - 1; n >= 0; n--) {
|
|
636
|
+
let r = s[n];
|
|
637
|
+
if (e >= r.x && e < r.x + r.w && t >= r.y && t < r.y + r.h) return n;
|
|
638
|
+
}
|
|
639
|
+
return -1;
|
|
640
|
+
}, f = () => {
|
|
641
|
+
let e = Math.min(...s.map((e) => e.x)), t = Math.min(...s.map((e) => e.y)), n = Math.max(...s.map((e) => e.x + e.w)), r = Math.max(...s.map((e) => e.y + e.h));
|
|
642
|
+
return {
|
|
643
|
+
x: e,
|
|
644
|
+
y: t,
|
|
645
|
+
w: n - e,
|
|
646
|
+
h: r - t
|
|
647
|
+
};
|
|
648
|
+
}, p = (e) => {
|
|
649
|
+
u !== null && u !== e && i.hover(u, null), u = e;
|
|
650
|
+
}, m = (e) => {
|
|
651
|
+
if (e.type === "hoverleave") {
|
|
652
|
+
p(null);
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
if (e.type === "cancel") {
|
|
656
|
+
l = !1;
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
if (e.type === "down") {
|
|
660
|
+
l = !0;
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
if (e.type !== "hovermove" && e.type !== "move" && e.type !== "up") return;
|
|
664
|
+
let n = d(e.x, e.y), r = e.type === "up" && l;
|
|
665
|
+
if (e.type === "up" && (l = !1), r || p(n < 0 ? null : n), n < 0) return;
|
|
666
|
+
let a = i.entriesAt(n), o = Fe(a, t, e.y - s[n].y);
|
|
667
|
+
if (!r) i.hover(n, o, {
|
|
668
|
+
x: e.x,
|
|
669
|
+
y: e.y
|
|
670
|
+
});
|
|
671
|
+
else if (o !== null) {
|
|
672
|
+
i.press(n, o);
|
|
673
|
+
let r = a[o], c = r?.kind === "number" ? Ce(s[n].w, t, e.x - s[n].x) : null;
|
|
674
|
+
r?.kind === "number" && c !== null && i.spin(r, c > 0 ? "ArrowUp" : "ArrowDown");
|
|
675
|
+
}
|
|
676
|
+
}, h = (e) => e.type === "keydown" && (!e.ctrlKey && !e.metaKey && !e.altKey && i.key(e.key), !0), g = {
|
|
677
|
+
read: () => de(i),
|
|
678
|
+
subscribe: i.subscribe
|
|
679
|
+
};
|
|
680
|
+
return {
|
|
681
|
+
id: `weasel-menu-${e.open.seq}`,
|
|
682
|
+
get bounds() {
|
|
683
|
+
return f();
|
|
684
|
+
},
|
|
685
|
+
hidden: !1,
|
|
686
|
+
get disposed() {
|
|
687
|
+
return c;
|
|
688
|
+
},
|
|
689
|
+
claims: ze,
|
|
690
|
+
focusable: !0,
|
|
691
|
+
focusRing: !1,
|
|
692
|
+
accessibleName: "Context menu",
|
|
693
|
+
accessibleTree: g,
|
|
694
|
+
deps: (t) => [
|
|
695
|
+
...r.deps(),
|
|
696
|
+
t.defaultFont,
|
|
697
|
+
A(),
|
|
698
|
+
e.icons?.getVersion()
|
|
699
|
+
],
|
|
700
|
+
draw: (n) => (o = n.defaultFont, s = a(i, o), s.flatMap((r, a) => Pe(n, r, i.entriesAt(a), i.stack()[a] ?? null, t, e.icons, i.numberValue))),
|
|
701
|
+
hitTest: (e, t) => d(e, t) >= 0,
|
|
702
|
+
cursorAt: () => "default",
|
|
703
|
+
onPointer: m,
|
|
704
|
+
onKey: h,
|
|
705
|
+
dispose() {
|
|
706
|
+
c = !0, i.dispose();
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
//#endregion
|
|
711
|
+
//#region src/menu/attachMenuHost.ts
|
|
712
|
+
function He(e, t, n) {
|
|
713
|
+
let r = null, i = {
|
|
714
|
+
widget: null,
|
|
715
|
+
visible: !1
|
|
716
|
+
}, a = () => {
|
|
717
|
+
let t = r;
|
|
718
|
+
r = null, t && (e.remove(t), t.disposed || t.dispose());
|
|
719
|
+
}, o = () => {
|
|
720
|
+
let { widget: t, visible: n } = i;
|
|
721
|
+
i = {
|
|
722
|
+
widget: null,
|
|
723
|
+
visible: !1
|
|
724
|
+
}, t && e.focus(t, { visible: n });
|
|
725
|
+
}, s = () => {
|
|
726
|
+
let s = t.current();
|
|
727
|
+
r || (i = {
|
|
728
|
+
widget: e.focused,
|
|
729
|
+
visible: e.focusVisible
|
|
730
|
+
});
|
|
731
|
+
let c = r !== null && e.focused === r;
|
|
732
|
+
if (a(), !s) {
|
|
733
|
+
c && o();
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
736
|
+
let l = Ve({
|
|
737
|
+
...n,
|
|
738
|
+
open: s,
|
|
739
|
+
close: () => {
|
|
740
|
+
t.current() === s && t.close();
|
|
741
|
+
},
|
|
742
|
+
onChange: () => e.markDirty()
|
|
743
|
+
});
|
|
744
|
+
r = l, e.add(l), e.focus(l) || (a(), t.close());
|
|
745
|
+
}, c = () => {
|
|
746
|
+
r && t.close();
|
|
747
|
+
}, l = (e) => {
|
|
748
|
+
if (!r) return;
|
|
749
|
+
let i = n.toCanvas({
|
|
750
|
+
x: e.clientX,
|
|
751
|
+
y: e.clientY
|
|
752
|
+
});
|
|
753
|
+
r.hitTest(i.x, i.y) || t.close();
|
|
754
|
+
}, u = t.subscribe(s), d = e.subscribeFocus((e) => {
|
|
755
|
+
r && e !== r && t.close();
|
|
756
|
+
});
|
|
757
|
+
return window.addEventListener("wheel", l, {
|
|
758
|
+
capture: !0,
|
|
759
|
+
passive: !0
|
|
760
|
+
}), window.addEventListener("blur", c), window.addEventListener("resize", c), s(), () => {
|
|
761
|
+
u(), d(), window.removeEventListener("wheel", l, !0), window.removeEventListener("blur", c), window.removeEventListener("resize", c), a();
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
//#endregion
|
|
6
765
|
//#region src/loupe/contentWatch.ts
|
|
7
|
-
function
|
|
766
|
+
function Ue(e) {
|
|
8
767
|
let t = "", n = null;
|
|
9
768
|
return {
|
|
10
769
|
drew(e) {
|
|
@@ -21,12 +780,12 @@ function y(e) {
|
|
|
21
780
|
}
|
|
22
781
|
//#endregion
|
|
23
782
|
//#region src/loupe/pointerAim.ts
|
|
24
|
-
var
|
|
783
|
+
var We = [
|
|
25
784
|
"pointerup",
|
|
26
785
|
"pointercancel",
|
|
27
786
|
"lostpointercapture"
|
|
28
787
|
];
|
|
29
|
-
function
|
|
788
|
+
function Ge(e, t) {
|
|
30
789
|
let n = !1, r = (t) => {
|
|
31
790
|
let n = e.getBoundingClientRect();
|
|
32
791
|
return {
|
|
@@ -41,16 +800,16 @@ function x(e, t) {
|
|
|
41
800
|
n = !1;
|
|
42
801
|
};
|
|
43
802
|
e.addEventListener("pointermove", i), e.addEventListener("pointerdown", a);
|
|
44
|
-
for (let t of
|
|
803
|
+
for (let t of We) e.addEventListener(t, o);
|
|
45
804
|
return () => {
|
|
46
805
|
e.removeEventListener("pointermove", i), e.removeEventListener("pointerdown", a);
|
|
47
|
-
for (let t of
|
|
806
|
+
for (let t of We) e.removeEventListener(t, o);
|
|
48
807
|
};
|
|
49
808
|
}
|
|
50
809
|
//#endregion
|
|
51
810
|
//#region src/loupe/readback.ts
|
|
52
|
-
function
|
|
53
|
-
let s = n.x + Math.round(r.x * i), c = n.y + Math.round(r.y * i), l =
|
|
811
|
+
function Ke(e, t, n, r, i, a, o) {
|
|
812
|
+
let s = n.x + Math.round(r.x * i), c = n.y + Math.round(r.y * i), l = _(s - Math.floor(a / 2), n.x, n.x + Math.max(0, n.width - a)), u = t - _(c - Math.floor(o / 2), n.y, n.y + Math.max(0, n.height - o)) - o, d = new Uint8Array(a * o * 4);
|
|
54
813
|
e.readPixels(l, u, a, o, e.RGBA, e.UNSIGNED_BYTE, d);
|
|
55
814
|
let f = new Uint8ClampedArray(a * o * 4), p = a * 4;
|
|
56
815
|
for (let e = 0; e < o; e++) {
|
|
@@ -61,7 +820,7 @@ function S(e, t, n, r, i, a, o) {
|
|
|
61
820
|
}
|
|
62
821
|
//#endregion
|
|
63
822
|
//#region src/loupe/createLoupe.ts
|
|
64
|
-
var
|
|
823
|
+
var qe = (e, t) => ({
|
|
65
824
|
kind: "path",
|
|
66
825
|
path: {
|
|
67
826
|
kind: "rect",
|
|
@@ -74,35 +833,43 @@ var C = (e, t) => ({
|
|
|
74
833
|
kind: "solid",
|
|
75
834
|
color: t
|
|
76
835
|
} }
|
|
77
|
-
}),
|
|
836
|
+
}), $ = "weasel-loupe:lens", Je = {
|
|
78
837
|
x: 0,
|
|
79
838
|
y: 0,
|
|
80
839
|
w: 0,
|
|
81
840
|
h: 0
|
|
82
841
|
};
|
|
83
|
-
function
|
|
842
|
+
function Ye(e, t, n, r, i) {
|
|
843
|
+
if (t && t.id !== null) {
|
|
844
|
+
let n = {
|
|
845
|
+
x: (e.x - t.rect.x) / t.view.scale.x + t.view.x,
|
|
846
|
+
y: (e.y - t.rect.y) / t.view.scale.y + t.view.y
|
|
847
|
+
};
|
|
848
|
+
return F(n, t.view, r, i);
|
|
849
|
+
}
|
|
850
|
+
let a = m(e.x, e.y, g(n));
|
|
851
|
+
return F({
|
|
852
|
+
x: a[0],
|
|
853
|
+
y: a[1]
|
|
854
|
+
}, n, r, i);
|
|
855
|
+
}
|
|
856
|
+
function Xe(e) {
|
|
84
857
|
let { hud: t, canvas: n, requestRedraw: r } = e, i = e.views, a = i !== void 0 && e.interactive === !0, o = e.input ?? n, s = null, c = null, l = () => {
|
|
85
|
-
c &&= (
|
|
86
|
-
}, u = !1,
|
|
858
|
+
c &&= (se(c), c.close(), null);
|
|
859
|
+
}, u = !1, d = !1, p = !1, m = !1, h = e.bounds ?? {
|
|
87
860
|
x: 24,
|
|
88
861
|
y: 24,
|
|
89
862
|
w: 220,
|
|
90
863
|
h: 200
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
return v({
|
|
94
|
-
x: n[0],
|
|
95
|
-
y: n[1]
|
|
96
|
-
}, e, t, V.factor);
|
|
97
|
-
}, M = (t) => i ? s ? [A(t), ...s.draw(t.data, t.view, t.dims)] : [A(t)] : d({
|
|
98
|
-
id: `${R.id}:lens`,
|
|
864
|
+
}, g = Ue(e.contentVersion ?? i?.getPaintedVersion), _ = !1, v = (e) => (g.drew(e.view), j.mode === "vector" ? S(e) : C(e)), y = (t) => e.background ?? t.tokens["--wzl-surface"], b = (e) => qe(e, y(e)), x = (e, t) => Ye(j.aim, i?.viewAt?.(j.aim, { except: $ }) ?? null, e, t, j.factor), S = (t) => i ? s ? [b(t), ...s.draw(t.data, t.view, t.dims)] : [b(t)] : f({
|
|
865
|
+
id: `${O.id}:lens`,
|
|
99
866
|
label: "Loupe content",
|
|
100
867
|
source: e.source ?? [],
|
|
101
|
-
view:
|
|
868
|
+
view: x(t.view, t.rect),
|
|
102
869
|
bounds: () => t.rect,
|
|
103
|
-
background:
|
|
104
|
-
}).draw(t.data, t.view, t.dims),
|
|
105
|
-
let t = [
|
|
870
|
+
background: y(t)
|
|
871
|
+
}).draw(t.data, t.view, t.dims), C = (e) => {
|
|
872
|
+
let t = [b(e)];
|
|
106
873
|
return c && t.push({
|
|
107
874
|
kind: "image",
|
|
108
875
|
image: c,
|
|
@@ -112,10 +879,10 @@ function T(e) {
|
|
|
112
879
|
h: e.rect.h,
|
|
113
880
|
sampling: "nearest"
|
|
114
881
|
}), t;
|
|
115
|
-
},
|
|
116
|
-
|
|
117
|
-
},
|
|
118
|
-
if (!
|
|
882
|
+
}, w = () => {
|
|
883
|
+
p || j.mode !== "pixel" || (d = !0);
|
|
884
|
+
}, T = (t, r, a) => {
|
|
885
|
+
if (!m) return null;
|
|
119
886
|
let o = n.getContext("webgl2");
|
|
120
887
|
if (!o) return null;
|
|
121
888
|
let s = n.getBoundingClientRect();
|
|
@@ -131,12 +898,12 @@ function T(e) {
|
|
|
131
898
|
width: n.width,
|
|
132
899
|
height: n.height
|
|
133
900
|
};
|
|
134
|
-
return
|
|
135
|
-
},
|
|
136
|
-
if (
|
|
137
|
-
let e =
|
|
901
|
+
return Ke(o, n.height, u, t, c, r(c), a(c));
|
|
902
|
+
}, E = () => {
|
|
903
|
+
if (p || j.mode !== "pixel") return;
|
|
904
|
+
let e = O.contentRect, t = T(j.aim, (t) => Math.max(1, Math.round(e.w * t / j.factor)), (t) => Math.max(1, Math.round(e.h * t / j.factor)));
|
|
138
905
|
t && (u = !0, createImageBitmap(t).then((e) => {
|
|
139
|
-
if (
|
|
906
|
+
if (p) {
|
|
140
907
|
e.close();
|
|
141
908
|
return;
|
|
142
909
|
}
|
|
@@ -144,92 +911,92 @@ function T(e) {
|
|
|
144
911
|
}).catch(() => {
|
|
145
912
|
u = !1, r();
|
|
146
913
|
}));
|
|
147
|
-
},
|
|
148
|
-
let t =
|
|
914
|
+
}, D = (e) => {
|
|
915
|
+
let t = T(e, () => 1, () => 1);
|
|
149
916
|
return !t || t.data[3] === 0 ? null : "#" + [
|
|
150
917
|
t.data[0],
|
|
151
918
|
t.data[1],
|
|
152
919
|
t.data[2]
|
|
153
920
|
].map((e) => e.toString(16).padStart(2, "0")).join("");
|
|
154
|
-
},
|
|
921
|
+
}, O = t.window({
|
|
155
922
|
id: "weasel-loupe",
|
|
156
|
-
x:
|
|
157
|
-
y:
|
|
158
|
-
w:
|
|
159
|
-
h:
|
|
923
|
+
x: h.x,
|
|
924
|
+
y: h.y,
|
|
925
|
+
w: h.w,
|
|
926
|
+
h: h.h,
|
|
160
927
|
title: e.title ?? "Loupe",
|
|
161
928
|
titlebar: e.titlebar,
|
|
162
|
-
content:
|
|
929
|
+
content: v,
|
|
163
930
|
interior: a ? "pass" : "claim",
|
|
164
931
|
onResize: () => {
|
|
165
|
-
|
|
932
|
+
w();
|
|
166
933
|
},
|
|
167
934
|
...a ? {} : { onContentClick: (e) => {
|
|
168
|
-
|
|
935
|
+
j.pick(e);
|
|
169
936
|
} },
|
|
170
937
|
...e.onClose ? { onClose: e.onClose } : {}
|
|
171
|
-
}),
|
|
172
|
-
lens: () =>
|
|
173
|
-
covers: (e) =>
|
|
174
|
-
sample:
|
|
175
|
-
hidden: () =>
|
|
176
|
-
gone: () =>
|
|
938
|
+
}), k = {
|
|
939
|
+
lens: () => O.contentRect,
|
|
940
|
+
covers: (e) => O.hitTest(e.x, e.y) || (O.passes?.(e.x, e.y) ?? !1),
|
|
941
|
+
sample: D,
|
|
942
|
+
hidden: () => O.hidden,
|
|
943
|
+
gone: () => O.disposed === !0,
|
|
177
944
|
changed: () => {
|
|
178
|
-
|
|
945
|
+
w(), r();
|
|
179
946
|
},
|
|
180
947
|
subscribeFrame: t.subscribeFrame
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
}),
|
|
184
|
-
surface:
|
|
948
|
+
}, A = t.subscribeFrame(() => {
|
|
949
|
+
m = !0, (g.changed() || _) && (_ = !1, w(), j.resample()), d && !u && (d = !1, E());
|
|
950
|
+
}), j = ce({
|
|
951
|
+
surface: k,
|
|
185
952
|
...e.mode ? { mode: e.mode } : {},
|
|
186
953
|
...e.factor === void 0 ? {} : { factor: e.factor },
|
|
187
954
|
...e.onColorChange ? { onColorChange: e.onColorChange } : {},
|
|
188
955
|
...e.onPick ? { onPick: e.onPick } : {},
|
|
189
|
-
onDispose: () =>
|
|
956
|
+
onDispose: () => N()
|
|
190
957
|
});
|
|
191
958
|
i && (s = i.addView({
|
|
192
|
-
id:
|
|
959
|
+
id: $,
|
|
193
960
|
label: "Loupe",
|
|
194
|
-
bounds: () =>
|
|
195
|
-
view: (e) =>
|
|
961
|
+
bounds: () => O.hidden ? Je : O.contentRect,
|
|
962
|
+
view: (e) => x(e, O.contentRect),
|
|
196
963
|
paint: !1,
|
|
197
964
|
interactive: a,
|
|
198
965
|
...e.source ? { layers: () => e.source } : {}
|
|
199
966
|
}));
|
|
200
|
-
let
|
|
201
|
-
aimAt: (e) =>
|
|
202
|
-
holds: (e) => a &&
|
|
203
|
-
}),
|
|
204
|
-
|
|
967
|
+
let M = Ge(o, {
|
|
968
|
+
aimAt: (e) => j.aimAt(e),
|
|
969
|
+
holds: (e) => a && k.covers(e)
|
|
970
|
+
}), N = () => {
|
|
971
|
+
p = !0, A(), M(), s?.remove(), s = null, l();
|
|
205
972
|
};
|
|
206
973
|
return {
|
|
207
|
-
window:
|
|
974
|
+
window: O,
|
|
208
975
|
get mode() {
|
|
209
|
-
return
|
|
976
|
+
return j.mode;
|
|
210
977
|
},
|
|
211
978
|
get factor() {
|
|
212
|
-
return
|
|
979
|
+
return j.factor;
|
|
213
980
|
},
|
|
214
981
|
get aim() {
|
|
215
|
-
return
|
|
982
|
+
return j.aim;
|
|
216
983
|
},
|
|
217
984
|
get color() {
|
|
218
|
-
return
|
|
985
|
+
return j.color;
|
|
219
986
|
},
|
|
220
|
-
setMode:
|
|
221
|
-
setFactor:
|
|
222
|
-
aimAt:
|
|
223
|
-
pick:
|
|
987
|
+
setMode: j.setMode,
|
|
988
|
+
setFactor: j.setFactor,
|
|
989
|
+
aimAt: j.aimAt,
|
|
990
|
+
pick: j.pick,
|
|
224
991
|
refresh() {
|
|
225
|
-
|
|
992
|
+
p || (_ = !0, r());
|
|
226
993
|
},
|
|
227
994
|
dispose() {
|
|
228
|
-
|
|
995
|
+
j.dispose(), O.dispose();
|
|
229
996
|
}
|
|
230
997
|
};
|
|
231
998
|
}
|
|
232
999
|
//#endregion
|
|
233
|
-
export {
|
|
1000
|
+
export { i as DEFAULT_FONT_FAMILY, Y as DEFAULT_MENU_METRICS, a as DEFAULT_WIDGET_CLAIMS, l as DEFAULT_WINDOW_METRICS, u as HUD_AFFORDANCE_KIND, c as attachHud, He as attachMenuHost, z as boxShadowCommands, d as claimsOf, s as createHud, o as createHudContribution, Xe as createLoupe, Ve as createMenuWidget, t as cursorForZone, G as glyphCommands, r as isFocusable, le as loupeInnerView, Le as measureLabel, e as registerDefaultFont };
|
|
234
1001
|
|
|
235
1002
|
//# sourceMappingURL=index.js.map
|