@weasel-js/hud 1.13.0 → 1.14.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/attach.d.ts.map +1 -1
- package/dist/hud.d.ts +6 -16
- package/dist/hud.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +665 -332
- package/dist/index.js.map +1 -1
- package/dist/layerDeps.d.ts +14 -0
- package/dist/layerDeps.d.ts.map +1 -0
- package/dist/loupe/createLoupe.d.ts +4 -2
- package/dist/loupe/createLoupe.d.ts.map +1 -1
- package/dist/menu/accessibleMenu.d.ts +3 -3
- package/dist/menu/accessibleMenu.d.ts.map +1 -1
- package/dist/menu/attachMenuHost.d.ts +1 -1
- package/dist/menu/attachMenuHost.d.ts.map +1 -1
- package/dist/menu/chipRepeat.d.ts +27 -0
- package/dist/menu/chipRepeat.d.ts.map +1 -0
- package/dist/menu/colorPicker.d.ts +20 -0
- package/dist/menu/colorPicker.d.ts.map +1 -0
- package/dist/menu/drawPanel.d.ts +17 -4
- package/dist/menu/drawPanel.d.ts.map +1 -1
- package/dist/menu/menuWidget.d.ts +6 -0
- package/dist/menu/menuWidget.d.ts.map +1 -1
- package/dist/menu/textEdit.d.ts +70 -0
- package/dist/menu/textEdit.d.ts.map +1 -0
- package/dist/menu/valueRows.d.ts +20 -2
- package/dist/menu/valueRows.d.ts.map +1 -1
- package/dist/react/index.js +1 -1
- package/dist/textInputHost.d.ts +19 -0
- package/dist/textInputHost.d.ts.map +1 -0
- package/dist/{tool-8LVUdM5S.js → tool-DELNnWid.js} +460 -351
- package/dist/tool-DELNnWid.js.map +1 -0
- package/dist/tool.d.ts.map +1 -1
- package/dist/widget.d.ts +20 -0
- package/dist/widget.d.ts.map +1 -1
- package/dist/widgets/text.d.ts.map +1 -1
- package/package.json +12 -11
- package/dist/tool-8LVUdM5S.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,64 +1,67 @@
|
|
|
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-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
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-DELNnWid.js";
|
|
2
|
+
import { createStepRepeat as f, editEnd as p } from "@weasel-js/headless";
|
|
3
|
+
import { createEmitter as m } from "@weasel-js/registry";
|
|
4
|
+
import { createViewportLayer as h, pathFromD as g, screenToWorld as _, textCommandFromRuns as v, viewToTransform as y } from "@weasel-js/core";
|
|
5
|
+
import { clamp as b, identity as x, mat3 as S, multiply as C, pathFromD as w, rotateAboutPoint as T, roundRectPath as E, scale as ee, translate as te } from "@weasel-js/geom";
|
|
6
|
+
import { tryNormalizeHex as D } from "@weasel-js/paint";
|
|
7
|
+
import { expandVars as O, parseBoxShadow as ne, resolveCurrentColor as k, tokenPx as re } from "@weasel-js/theme";
|
|
8
|
+
import { faceGeneration as A, metricsOf as ie, resolveFontVariant as ae } from "@weasel-js/font";
|
|
9
|
+
import { attachMenuDismiss as oe, createMenuController as se, menuNumberCanStep as j, menuNumberText as ce, placeMenu as le, placeMenuUnder as ue, placeSubmenu as de, withLinks as fe } from "@weasel-js/menu";
|
|
10
|
+
import { formatShortcut as pe, isApplePlatform as me } from "@weasel-js/gestures";
|
|
11
|
+
import { toIconRef as he } from "@weasel-js/icons";
|
|
12
|
+
import { releaseImageSource as ge } from "@weasel-js/core/renderer";
|
|
13
|
+
import { createLoupeModel as _e, loupeInnerView as ve, loupeInnerView as M } from "@weasel-js/loupe";
|
|
11
14
|
//#region src/menu/accessibleMenu.ts
|
|
12
|
-
function
|
|
13
|
-
return t.kind === "number" ? `${t.label}: ${
|
|
15
|
+
function ye(e, t, n) {
|
|
16
|
+
return t.kind === "number" ? `${t.label}: ${ce(e.numberValue(t), t)}` : t.kind === "color" ? `${t.label}: ${t.value ?? "—"}` : t.kind === "text" ? `${t.label}: ${e.textValue(t) ?? "—"}` : t.kind === "submenu" && n?.(t) !== void 0 ? `${t.label}: ${n(t)}` : t.label;
|
|
14
17
|
}
|
|
15
|
-
function
|
|
16
|
-
let
|
|
17
|
-
return e.entriesAt(t).map((
|
|
18
|
-
if (
|
|
18
|
+
function N(e, t, n) {
|
|
19
|
+
let r = e.stack(), i = t === r.length - 1;
|
|
20
|
+
return e.entriesAt(t).map((a, o) => {
|
|
21
|
+
if (a.kind === "separator") return {
|
|
19
22
|
role: "separator",
|
|
20
|
-
key:
|
|
23
|
+
key: a.key
|
|
21
24
|
};
|
|
22
|
-
let
|
|
25
|
+
let s = a.kind === "item" && a.checked !== void 0, c = a.kind === "submenu" && r[t] === o && r.length > t + 1;
|
|
23
26
|
return {
|
|
24
|
-
role:
|
|
25
|
-
key:
|
|
26
|
-
label:
|
|
27
|
-
...
|
|
28
|
-
...
|
|
29
|
-
...
|
|
30
|
-
...
|
|
31
|
-
...
|
|
27
|
+
role: s ? "menuitemcheckbox" : "menuitem",
|
|
28
|
+
key: a.key,
|
|
29
|
+
label: ye(e, a, n),
|
|
30
|
+
...i && r[t] === o ? { active: !0 } : {},
|
|
31
|
+
...a.kind === "item" && a.checked !== void 0 ? { checked: a.checked } : {},
|
|
32
|
+
...a.disabled || a.kind === "color" ? { disabled: !0 } : {},
|
|
33
|
+
...a.kind === "submenu" ? { expanded: c } : {},
|
|
34
|
+
...c ? { children: [{
|
|
32
35
|
role: "menu",
|
|
33
36
|
key: "menu",
|
|
34
|
-
label:
|
|
35
|
-
children:
|
|
37
|
+
label: a.label,
|
|
38
|
+
children: N(e, t + 1, n)
|
|
36
39
|
}] } : {}
|
|
37
40
|
};
|
|
38
41
|
});
|
|
39
42
|
}
|
|
40
|
-
function
|
|
43
|
+
function be(e, t) {
|
|
41
44
|
return {
|
|
42
45
|
role: "menu",
|
|
43
46
|
key: "menu",
|
|
44
47
|
label: "Context menu",
|
|
45
|
-
children:
|
|
48
|
+
children: N(e, 0, t)
|
|
46
49
|
};
|
|
47
50
|
}
|
|
48
51
|
//#endregion
|
|
49
52
|
//#region src/boxShadow.ts
|
|
50
|
-
var
|
|
53
|
+
var xe = 7, Se = .16, P = (e) => ({ paint: {
|
|
51
54
|
kind: "solid",
|
|
52
55
|
color: e
|
|
53
56
|
} });
|
|
54
|
-
function
|
|
57
|
+
function Ce(e, t, n, r, i) {
|
|
55
58
|
let a = Math.max(0, Math.min(i, n / 2, r / 2));
|
|
56
59
|
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
60
|
}
|
|
58
|
-
function
|
|
61
|
+
function we(e, t, n, r) {
|
|
59
62
|
let i = (r) => {
|
|
60
63
|
let i = e.w + r * 2, a = e.h + r * 2;
|
|
61
|
-
return i > 0 && a > 0 ?
|
|
64
|
+
return i > 0 && a > 0 ? E(e.x + n.x - r, e.y + n.y - r, i, a, Math.max(0, t + r)) : null;
|
|
62
65
|
};
|
|
63
66
|
if (n.blur <= 0) {
|
|
64
67
|
let e = i(n.spread);
|
|
@@ -67,45 +70,45 @@ function me(e, t, n, r) {
|
|
|
67
70
|
children: e ? [{
|
|
68
71
|
kind: "path",
|
|
69
72
|
path: e,
|
|
70
|
-
fill:
|
|
73
|
+
fill: P(r)
|
|
71
74
|
}] : []
|
|
72
75
|
};
|
|
73
76
|
}
|
|
74
77
|
let a = [], o = n.blur / 6;
|
|
75
|
-
for (let e = 0; e <
|
|
78
|
+
for (let e = 0; e < xe; e++) {
|
|
76
79
|
let t = i(n.spread + n.blur / 2 - e * o);
|
|
77
80
|
t && a.push({
|
|
78
81
|
kind: "path",
|
|
79
82
|
path: t,
|
|
80
|
-
fill:
|
|
83
|
+
fill: P(r)
|
|
81
84
|
});
|
|
82
85
|
}
|
|
83
86
|
return {
|
|
84
87
|
kind: "group",
|
|
85
|
-
alpha:
|
|
88
|
+
alpha: Se,
|
|
86
89
|
children: a
|
|
87
90
|
};
|
|
88
91
|
}
|
|
89
|
-
function
|
|
90
|
-
let i = Math.abs(n.x) + Math.abs(n.y) + Math.abs(n.spread) + 1, a =
|
|
92
|
+
function Te(e, t, n, r) {
|
|
93
|
+
let i = Math.abs(n.x) + Math.abs(n.y) + Math.abs(n.spread) + 1, a = Ce(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 = w(`${Ce(e.x - i, e.y - i, e.w + i * 2, e.h + i * 2, 0)} ${a}`);
|
|
91
94
|
return {
|
|
92
95
|
kind: "group",
|
|
93
|
-
clip:
|
|
96
|
+
clip: E(e.x, e.y, e.w, e.h, t),
|
|
94
97
|
children: [{
|
|
95
98
|
kind: "path",
|
|
96
99
|
path: o.kind === "polygon" ? {
|
|
97
100
|
...o,
|
|
98
101
|
fillRule: "evenodd"
|
|
99
102
|
} : o,
|
|
100
|
-
fill:
|
|
103
|
+
fill: P(r)
|
|
101
104
|
}]
|
|
102
105
|
};
|
|
103
106
|
}
|
|
104
|
-
function
|
|
107
|
+
function Ee(e, t, n, r, i = e) {
|
|
105
108
|
let a = [], o = [], s = Math.max(0, t - (i.x - e.x));
|
|
106
109
|
for (let c of [...n].reverse()) {
|
|
107
|
-
let n =
|
|
108
|
-
c.inset ? o.push(
|
|
110
|
+
let n = k(c.color, r);
|
|
111
|
+
c.inset ? o.push(Te(i, s, c, n)) : a.push(we(e, t, c, n));
|
|
109
112
|
}
|
|
110
113
|
return {
|
|
111
114
|
under: a,
|
|
@@ -114,13 +117,13 @@ function z(e, t, n, r, i = e) {
|
|
|
114
117
|
}
|
|
115
118
|
//#endregion
|
|
116
119
|
//#region src/glyph.ts
|
|
117
|
-
var
|
|
120
|
+
var De = {
|
|
118
121
|
fill: "none",
|
|
119
122
|
stroke: "currentColor",
|
|
120
123
|
"stroke-width": "1.5",
|
|
121
124
|
"stroke-linecap": "round",
|
|
122
125
|
"stroke-linejoin": "round"
|
|
123
|
-
},
|
|
126
|
+
}, Oe = /* @__PURE__ */ new Set([
|
|
124
127
|
"fill",
|
|
125
128
|
"fill-opacity",
|
|
126
129
|
"fill-rule",
|
|
@@ -131,7 +134,7 @@ var ge = {
|
|
|
131
134
|
"stroke-linejoin",
|
|
132
135
|
"stroke-dasharray"
|
|
133
136
|
]);
|
|
134
|
-
function*
|
|
137
|
+
function* ke(e) {
|
|
135
138
|
for (let t of e.matchAll(/<(\/?)([a-zA-Z]+)((?:\s+[\w:-]+="[^"]*")*)\s*(\/?)>/g)) {
|
|
136
139
|
let e = {};
|
|
137
140
|
for (let n of t[3].matchAll(/([\w:-]+)="([^"]*)"/g)) e[n[1]] = n[2];
|
|
@@ -143,33 +146,33 @@ function* ve(e) {
|
|
|
143
146
|
};
|
|
144
147
|
}
|
|
145
148
|
}
|
|
146
|
-
var
|
|
147
|
-
function
|
|
148
|
-
let t =
|
|
149
|
+
var F = (e, t = 0) => e === void 0 || e === "" ? t : Number(e), I = (e) => e.trim().split(/[\s,]+/).filter((e) => e !== "").map(Number);
|
|
150
|
+
function Ae(e) {
|
|
151
|
+
let t = x();
|
|
149
152
|
if (!e) return t;
|
|
150
153
|
for (let [, n, r] of e.matchAll(/(\w+)\s*\(([^)]*)\)/g)) {
|
|
151
|
-
let e =
|
|
152
|
-
i && (t =
|
|
154
|
+
let e = I(r), i = n === "translate" ? te(e[0] ?? 0, e[1] ?? 0) : n === "scale" ? ee(e[0] ?? 1, e[1] ?? e[0] ?? 1) : n === "rotate" ? T(e[1] ?? 0, e[2] ?? 0, (e[0] ?? 0) * Math.PI / 180) : n === "matrix" && e.length === 6 ? e : null;
|
|
155
|
+
i && (t = C(t, i));
|
|
153
156
|
}
|
|
154
157
|
return t;
|
|
155
158
|
}
|
|
156
|
-
function
|
|
159
|
+
function je(e, t, n, r, i, a) {
|
|
157
160
|
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
161
|
}
|
|
159
|
-
var
|
|
160
|
-
function
|
|
162
|
+
var Me = (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`;
|
|
163
|
+
function Ne(e, t) {
|
|
161
164
|
switch (e) {
|
|
162
165
|
case "path": return t.d;
|
|
163
166
|
case "rect": {
|
|
164
|
-
let e =
|
|
165
|
-
return
|
|
167
|
+
let e = F(t.width), n = F(t.height), r = Math.min(F(t.rx, F(t.ry)), e / 2), i = Math.min(F(t.ry, F(t.rx)), n / 2);
|
|
168
|
+
return je(F(t.x), F(t.y), e, n, r, i);
|
|
166
169
|
}
|
|
167
|
-
case "circle": return
|
|
168
|
-
case "ellipse": return
|
|
169
|
-
case "line": return `M ${
|
|
170
|
+
case "circle": return Me(F(t.cx), F(t.cy), F(t.r), F(t.r));
|
|
171
|
+
case "ellipse": return Me(F(t.cx), F(t.cy), F(t.rx), F(t.ry));
|
|
172
|
+
case "line": return `M ${F(t.x1)} ${F(t.y1)} L ${F(t.x2)} ${F(t.y2)}`;
|
|
170
173
|
case "polygon":
|
|
171
174
|
case "polyline": {
|
|
172
|
-
let n =
|
|
175
|
+
let n = I(t.points ?? "");
|
|
173
176
|
if (n.length < 4) return;
|
|
174
177
|
let r = [];
|
|
175
178
|
for (let e = 0; e + 1 < n.length; e += 2) r.push(`${n[e]} ${n[e + 1]}`);
|
|
@@ -178,9 +181,9 @@ function xe(e, t) {
|
|
|
178
181
|
default: return;
|
|
179
182
|
}
|
|
180
183
|
}
|
|
181
|
-
var
|
|
182
|
-
function
|
|
183
|
-
let r = [], i =
|
|
184
|
+
var Pe = (e, t) => e === void 0 || e === "none" ? null : /^currentcolor$/i.test(e) ? t : e;
|
|
185
|
+
function Fe(e, t, n) {
|
|
186
|
+
let r = [], i = Pe(t.fill, n);
|
|
184
187
|
if (i) {
|
|
185
188
|
let n = {
|
|
186
189
|
kind: "path",
|
|
@@ -192,16 +195,16 @@ function Se(e, t, n) {
|
|
|
192
195
|
kind: "solid",
|
|
193
196
|
color: i
|
|
194
197
|
} }
|
|
195
|
-
}, a =
|
|
198
|
+
}, a = F(t["fill-opacity"], 1);
|
|
196
199
|
r.push(a < 1 ? {
|
|
197
200
|
kind: "group",
|
|
198
201
|
alpha: a,
|
|
199
202
|
children: [n]
|
|
200
203
|
} : n);
|
|
201
204
|
}
|
|
202
|
-
let a =
|
|
205
|
+
let a = Pe(t.stroke, n);
|
|
203
206
|
if (a) {
|
|
204
|
-
let n = t["stroke-dasharray"] && t["stroke-dasharray"] !== "none" ?
|
|
207
|
+
let n = t["stroke-dasharray"] && t["stroke-dasharray"] !== "none" ? I(t["stroke-dasharray"]) : void 0, i = {
|
|
205
208
|
kind: "path",
|
|
206
209
|
path: e,
|
|
207
210
|
stroke: {
|
|
@@ -209,12 +212,12 @@ function Se(e, t, n) {
|
|
|
209
212
|
kind: "solid",
|
|
210
213
|
color: a
|
|
211
214
|
},
|
|
212
|
-
width:
|
|
215
|
+
width: F(t["stroke-width"], 1),
|
|
213
216
|
cap: t["stroke-linecap"],
|
|
214
217
|
join: t["stroke-linejoin"],
|
|
215
218
|
...n ? { dash: n } : {}
|
|
216
219
|
}
|
|
217
|
-
}, o =
|
|
220
|
+
}, o = F(t["stroke-opacity"], 1);
|
|
218
221
|
r.push(o < 1 ? {
|
|
219
222
|
kind: "group",
|
|
220
223
|
alpha: o,
|
|
@@ -223,32 +226,32 @@ function Se(e, t, n) {
|
|
|
223
226
|
}
|
|
224
227
|
return r;
|
|
225
228
|
}
|
|
226
|
-
function
|
|
229
|
+
function Ie(e, t) {
|
|
227
230
|
let n = { ...t };
|
|
228
|
-
for (let [t, r] of Object.entries(e.attrs))
|
|
231
|
+
for (let [t, r] of Object.entries(e.attrs)) Oe.has(t) && (n[t] = r);
|
|
229
232
|
let r = [], i = {
|
|
230
233
|
kind: "group",
|
|
231
234
|
children: r
|
|
232
|
-
}, a =
|
|
233
|
-
return a.some((e, t) => e !==
|
|
235
|
+
}, a = Ae(e.attrs.transform);
|
|
236
|
+
return a.some((e, t) => e !== x()[t]) && (i.transform = S.fromAffine(a)), e.name === "svg" && (i.clip = {
|
|
234
237
|
kind: "rect",
|
|
235
|
-
x:
|
|
236
|
-
y:
|
|
237
|
-
width:
|
|
238
|
-
height:
|
|
238
|
+
x: F(e.attrs.x),
|
|
239
|
+
y: F(e.attrs.y),
|
|
240
|
+
width: F(e.attrs.width),
|
|
241
|
+
height: F(e.attrs.height)
|
|
239
242
|
}), {
|
|
240
243
|
attrs: n,
|
|
241
244
|
children: r,
|
|
242
245
|
group: i
|
|
243
246
|
};
|
|
244
247
|
}
|
|
245
|
-
function
|
|
248
|
+
function Le(e, t) {
|
|
246
249
|
let n = t.size / 20, r = {
|
|
247
|
-
attrs:
|
|
250
|
+
attrs: De,
|
|
248
251
|
children: [],
|
|
249
252
|
group: {
|
|
250
253
|
kind: "group",
|
|
251
|
-
transform:
|
|
254
|
+
transform: S.fromAffine([
|
|
252
255
|
n,
|
|
253
256
|
0,
|
|
254
257
|
0,
|
|
@@ -261,7 +264,7 @@ function G(e, t) {
|
|
|
261
264
|
};
|
|
262
265
|
r.group.children = r.children;
|
|
263
266
|
let i = [r], a = 0;
|
|
264
|
-
for (let n of
|
|
267
|
+
for (let n of ke(e.body)) {
|
|
265
268
|
let e = i.at(-1);
|
|
266
269
|
if (a > 0 || n.name === "defs" || n.name === "clipPath") {
|
|
267
270
|
n.selfClosing || (a += n.close ? -1 : 1);
|
|
@@ -272,13 +275,13 @@ function G(e, t) {
|
|
|
272
275
|
continue;
|
|
273
276
|
}
|
|
274
277
|
if (n.name === "g" || n.name === "svg") {
|
|
275
|
-
let t =
|
|
278
|
+
let t = Ie(n, e.attrs);
|
|
276
279
|
e.children.push(t.group), n.selfClosing || i.push(t);
|
|
277
280
|
continue;
|
|
278
281
|
}
|
|
279
|
-
let r =
|
|
282
|
+
let r = Ne(n.name, n.attrs);
|
|
280
283
|
if (r === void 0) continue;
|
|
281
|
-
let o =
|
|
284
|
+
let o = Ie(n, e.attrs), s = Fe(w(r), o.attrs, t.color);
|
|
282
285
|
o.group.transform ? e.children.push({
|
|
283
286
|
kind: "group",
|
|
284
287
|
transform: o.group.transform,
|
|
@@ -288,8 +291,143 @@ function G(e, t) {
|
|
|
288
291
|
return [r.group];
|
|
289
292
|
}
|
|
290
293
|
//#endregion
|
|
294
|
+
//#region src/menu/textEdit.ts
|
|
295
|
+
function Re(e, t = me()) {
|
|
296
|
+
let n = e.shiftKey;
|
|
297
|
+
return t ? {
|
|
298
|
+
shift: n,
|
|
299
|
+
mod: e.ctrlKey || e.metaKey,
|
|
300
|
+
line: e.metaKey,
|
|
301
|
+
word: e.altKey
|
|
302
|
+
} : e.ctrlKey && e.altKey ? { shift: n } : {
|
|
303
|
+
shift: n,
|
|
304
|
+
mod: e.ctrlKey || e.metaKey,
|
|
305
|
+
word: e.ctrlKey
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
var ze = /[\p{L}\p{N}\p{M}_]/u;
|
|
309
|
+
function L(e, t, n) {
|
|
310
|
+
let r = (t) => ze.test(e[n < 0 ? t - 1 : t] ?? ""), i = (t) => n < 0 ? t > 0 : t < e.length, a = t;
|
|
311
|
+
for (; i(a) && !r(a);) a += n;
|
|
312
|
+
for (; i(a) && r(a);) a += n;
|
|
313
|
+
return a;
|
|
314
|
+
}
|
|
315
|
+
function Be(e, t) {
|
|
316
|
+
let n = Array.from(t).length;
|
|
317
|
+
return {
|
|
318
|
+
entry: e,
|
|
319
|
+
draft: t,
|
|
320
|
+
caret: n,
|
|
321
|
+
anchor: n
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
function R(e) {
|
|
325
|
+
return e.caret < e.anchor ? [e.caret, e.anchor] : [e.anchor, e.caret];
|
|
326
|
+
}
|
|
327
|
+
function z(e, t, n, r) {
|
|
328
|
+
let i = Array.from(e.draft), a = t + Array.from(r).length, { preedit: o, ...s } = e;
|
|
329
|
+
return {
|
|
330
|
+
...s,
|
|
331
|
+
draft: [
|
|
332
|
+
...i.slice(0, t),
|
|
333
|
+
r,
|
|
334
|
+
...i.slice(n)
|
|
335
|
+
].join(""),
|
|
336
|
+
caret: a,
|
|
337
|
+
anchor: a
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
function Ve(e, t) {
|
|
341
|
+
let { preedit: n, ...r } = e;
|
|
342
|
+
return t ? {
|
|
343
|
+
...r,
|
|
344
|
+
preedit: t
|
|
345
|
+
} : r;
|
|
346
|
+
}
|
|
347
|
+
function B(e, t) {
|
|
348
|
+
let [n, r] = R(e);
|
|
349
|
+
return z(e, n, r, t);
|
|
350
|
+
}
|
|
351
|
+
function V(e) {
|
|
352
|
+
if (!e.preedit) return { edit: e };
|
|
353
|
+
let [t] = R(e), n = B(e, e.preedit);
|
|
354
|
+
return {
|
|
355
|
+
edit: n,
|
|
356
|
+
preedit: [t, n.caret]
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
function H(e, t, n) {
|
|
360
|
+
let r = Array.from(e.draft).length, i = Math.max(0, Math.min(r, t));
|
|
361
|
+
return {
|
|
362
|
+
...e,
|
|
363
|
+
caret: i,
|
|
364
|
+
anchor: n ? e.anchor : i
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
function He(e, t, n) {
|
|
368
|
+
let r = Array.from(e.draft).length, [i, a] = R(e);
|
|
369
|
+
if (t === "Home" || t === "ArrowLeft" && n.line) return 0;
|
|
370
|
+
if (t === "End" || t === "ArrowRight" && n.line) return r;
|
|
371
|
+
if (n.word && (t === "ArrowLeft" || t === "ArrowRight")) {
|
|
372
|
+
let r = t === "ArrowLeft" ? -1 : 1, o = n.shift ? e.caret : r < 0 ? i : a;
|
|
373
|
+
return L(Array.from(e.draft), o, r);
|
|
374
|
+
}
|
|
375
|
+
if (t === "ArrowLeft") return !n.shift && i !== a ? i : e.caret - 1;
|
|
376
|
+
if (t === "ArrowRight") return !n.shift && i !== a ? a : e.caret + 1;
|
|
377
|
+
}
|
|
378
|
+
function Ue(e, t, n = {}) {
|
|
379
|
+
let r = p({
|
|
380
|
+
key: t,
|
|
381
|
+
shift: n.shift === !0
|
|
382
|
+
});
|
|
383
|
+
if (r) return r === "commit" ? {
|
|
384
|
+
edit: null,
|
|
385
|
+
commit: e.draft
|
|
386
|
+
} : { edit: null };
|
|
387
|
+
let i = He(e, t, n);
|
|
388
|
+
if (i !== void 0) return { edit: H(e, i, n.shift === !0) };
|
|
389
|
+
let [a, o] = R(e);
|
|
390
|
+
if ((t === "Backspace" || t === "Delete") && a !== o) return { edit: z(e, a, o, "") };
|
|
391
|
+
let s = Array.from(e.draft);
|
|
392
|
+
return t === "Backspace" ? { edit: z(e, n.line ? 0 : n.word ? L(s, a, -1) : Math.max(0, a - 1), a, "") } : t === "Delete" ? { edit: z(e, a, n.line ? s.length : n.word ? L(s, a, 1) : a + 1, "") } : n.mod ? { edit: t.toLowerCase() === "a" ? {
|
|
393
|
+
...e,
|
|
394
|
+
anchor: 0,
|
|
395
|
+
caret: s.length
|
|
396
|
+
} : e } : Array.from(t).length === 1 ? { edit: z(e, a, o, t) } : { edit: e };
|
|
397
|
+
}
|
|
398
|
+
function We(e, t) {
|
|
399
|
+
let n = null, r = (r) => {
|
|
400
|
+
let i = n;
|
|
401
|
+
n = null, i && r !== void 0 && e.setText(i.entry, r), t();
|
|
402
|
+
};
|
|
403
|
+
return {
|
|
404
|
+
current: () => n,
|
|
405
|
+
start(r) {
|
|
406
|
+
r?.kind !== "text" || r.disabled || n?.entry === r || (n = Be(r, e.textValue(r) ?? ""), t());
|
|
407
|
+
},
|
|
408
|
+
place(e, r) {
|
|
409
|
+
let i = n && n.entry === e ? r(n.draft) : void 0;
|
|
410
|
+
n && i !== void 0 && (n = H(n, i, !1), t());
|
|
411
|
+
},
|
|
412
|
+
leave(e) {
|
|
413
|
+
n && n.entry !== e && r(p("blur") === "commit" ? n.draft : void 0);
|
|
414
|
+
},
|
|
415
|
+
compose(e) {
|
|
416
|
+
n && (n.preedit ?? "") !== e && (n = Ve(n, e), t());
|
|
417
|
+
},
|
|
418
|
+
insert(e) {
|
|
419
|
+
n && (n = B(n, e), t());
|
|
420
|
+
},
|
|
421
|
+
key(e, i = {}) {
|
|
422
|
+
if (!n) return !1;
|
|
423
|
+
let a = Ue(n, e, i);
|
|
424
|
+
return a.edit ? (n = a.edit, t()) : r(a.commit), !0;
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
//#endregion
|
|
291
429
|
//#region src/menu/valueRows.ts
|
|
292
|
-
function
|
|
430
|
+
function U(e, t) {
|
|
293
431
|
let n = t.rowHeight, r = e - t.padX;
|
|
294
432
|
return {
|
|
295
433
|
minus: {
|
|
@@ -307,21 +445,21 @@ function K(e, t) {
|
|
|
307
445
|
width: 4 * n
|
|
308
446
|
};
|
|
309
447
|
}
|
|
310
|
-
function
|
|
311
|
-
let { minus: r, plus: i } =
|
|
448
|
+
function Ge(e, t, n) {
|
|
449
|
+
let { minus: r, plus: i } = U(e, t), a = (e) => n >= e.x && n < e.x + e.w;
|
|
312
450
|
return a(i) ? 1 : a(r) ? -1 : null;
|
|
313
451
|
}
|
|
314
|
-
function
|
|
315
|
-
if (e.kind === "number") return t.padX +
|
|
452
|
+
function Ke(e, t, n) {
|
|
453
|
+
if (e.kind === "number") return t.padX + U(0, t).width;
|
|
316
454
|
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);
|
|
455
|
+
if (e.kind === "text") return t.padX + Math.max(n(e.value ?? "—", t.fontSize), t.fontSize * 7);
|
|
318
456
|
}
|
|
319
|
-
var
|
|
457
|
+
var W = (e) => ({ paint: {
|
|
320
458
|
kind: "solid",
|
|
321
459
|
color: e
|
|
322
|
-
} }),
|
|
460
|
+
} }), G = (e, t) => ({
|
|
323
461
|
kind: "path",
|
|
324
|
-
path:
|
|
462
|
+
path: g(e),
|
|
325
463
|
stroke: {
|
|
326
464
|
paint: {
|
|
327
465
|
kind: "solid",
|
|
@@ -331,63 +469,115 @@ var q = (e) => ({ paint: {
|
|
|
331
469
|
cap: "round"
|
|
332
470
|
}
|
|
333
471
|
});
|
|
334
|
-
function
|
|
335
|
-
let { minus: o, value: s, plus: c } =
|
|
472
|
+
function qe(e, t, n, r, i, a) {
|
|
473
|
+
let { minus: o, value: s, plus: c } = U(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 && !j(n, r, -1), p = r !== void 0 && !j(n, r, 1);
|
|
336
474
|
return [
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
text:
|
|
340
|
-
fill:
|
|
475
|
+
G(`M ${d(o) - 4} ${l} L ${d(o) + 4} ${l}`, u(!f)),
|
|
476
|
+
v(e.x + s.x, e.y + t.y, [{
|
|
477
|
+
text: ce(r, n),
|
|
478
|
+
fill: W(u(!0))
|
|
341
479
|
}], {
|
|
342
480
|
...a.font,
|
|
343
481
|
align: "center"
|
|
344
482
|
}, void 0, t.h, "center", void 0, s.w),
|
|
345
|
-
|
|
483
|
+
G(`M ${d(c) - 4} ${l} L ${d(c) + 4} ${l} M ${d(c)} ${l - 4} L ${d(c)} ${l + 4}`, u(!p))
|
|
346
484
|
];
|
|
347
485
|
}
|
|
348
|
-
function
|
|
349
|
-
return [
|
|
486
|
+
function Je(e, t, n, r, i, a = "live") {
|
|
487
|
+
return [v(e.x + r.padX, e.y + t.y, [{
|
|
350
488
|
text: n ?? "—",
|
|
351
|
-
fill:
|
|
489
|
+
fill: W(a === "off" ? i.muted : i.fg)
|
|
352
490
|
}], {
|
|
353
491
|
...i.font,
|
|
354
492
|
align: "right"
|
|
355
493
|
}, void 0, t.h, "center", void 0, e.w - r.padX * 2)];
|
|
356
494
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
495
|
+
var Ye = (e, t) => e - t.padX - 3;
|
|
496
|
+
function Xe(e, t, n, r, i) {
|
|
497
|
+
let a = Array.from(e), o = K(e, t, n, i);
|
|
498
|
+
if (r < o(0) - n.padX) return;
|
|
499
|
+
let s = 0;
|
|
500
|
+
for (let e = 1; e <= a.length; e++) Math.abs(o(e) - r) < Math.abs(o(s) - r) && (s = e);
|
|
501
|
+
return s;
|
|
502
|
+
}
|
|
503
|
+
function K(e, t, n, r) {
|
|
504
|
+
let i = Ye(t, n), a = Array.from(e);
|
|
505
|
+
return (e) => i - r(a.slice(e).join(""));
|
|
506
|
+
}
|
|
507
|
+
function Ze(e, t, n, r) {
|
|
508
|
+
let i = V(e).edit;
|
|
509
|
+
return K(i.draft, t, n, r)(i.caret) + 1;
|
|
510
|
+
}
|
|
511
|
+
function Qe(e, t, n, r, i, a, o) {
|
|
512
|
+
let { edit: s, preedit: c } = V(n), l = K(s.draft, e.w, r, o), u = (t) => e.x + l(t), d = e.x + Ye(e.w, r), f = i.font.fontSize * .6, p = e.y + t.y + t.h / 2, m = [], [h, g] = R(s);
|
|
513
|
+
h !== g && m.push({
|
|
514
|
+
kind: "path",
|
|
515
|
+
path: {
|
|
516
|
+
kind: "rect",
|
|
517
|
+
x: u(h),
|
|
518
|
+
y: p - f,
|
|
519
|
+
width: u(g) - u(h),
|
|
520
|
+
height: f * 2
|
|
521
|
+
},
|
|
522
|
+
fill: W(a)
|
|
523
|
+
}), m.push(v(e.x + r.padX, e.y + t.y, [{
|
|
524
|
+
text: s.draft,
|
|
525
|
+
fill: W(i.fg)
|
|
526
|
+
}], {
|
|
527
|
+
...i.font,
|
|
528
|
+
align: "right"
|
|
529
|
+
}, void 0, t.h, "center", void 0, d - e.x - r.padX)), c && m.push(G(`M ${u(c[0])} ${p + f} L ${u(c[1])} ${p + f}`, i.fg));
|
|
530
|
+
let _ = u(s.caret) + 1;
|
|
531
|
+
return m.push(G(`M ${_} ${p - f} L ${_} ${p + f}`, i.fg)), m;
|
|
532
|
+
}
|
|
533
|
+
function $e(e, t, n, r, i, a = 1) {
|
|
534
|
+
return {
|
|
535
|
+
kind: "path",
|
|
536
|
+
path: {
|
|
537
|
+
kind: "rect",
|
|
538
|
+
x: e.x + r.padX + (r.rowHeight - 12) / 2,
|
|
539
|
+
y: e.y + t.y + (t.h - 12) / 2,
|
|
540
|
+
width: 12,
|
|
541
|
+
height: 12
|
|
542
|
+
},
|
|
543
|
+
fill: W(n),
|
|
544
|
+
stroke: {
|
|
545
|
+
paint: {
|
|
546
|
+
kind: "solid",
|
|
547
|
+
color: i
|
|
369
548
|
},
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
return a.push(h(e.x + r.padX, e.y + t.y, [{
|
|
549
|
+
width: a
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
function et(e, t, n, r, i) {
|
|
554
|
+
let a = n.value === void 0 ? [] : [$e(e, t, n.value, r, i.border)];
|
|
555
|
+
return a.push(v(e.x + r.padX, e.y + t.y, [{
|
|
381
556
|
text: n.value ?? "—",
|
|
382
|
-
fill:
|
|
557
|
+
fill: W(i.muted)
|
|
383
558
|
}], {
|
|
384
559
|
...i.font,
|
|
385
560
|
align: "right"
|
|
386
561
|
}, void 0, t.h, "center", void 0, e.w - r.padX * 2)), a;
|
|
387
562
|
}
|
|
388
563
|
//#endregion
|
|
564
|
+
//#region src/menu/measureLabel.ts
|
|
565
|
+
function tt(e, t) {
|
|
566
|
+
return e.length * t * .55;
|
|
567
|
+
}
|
|
568
|
+
function q(e, t, n) {
|
|
569
|
+
let r = ie(ae(n, 400, "normal"));
|
|
570
|
+
if (!r) return tt(e, t);
|
|
571
|
+
let i = 0, a = null;
|
|
572
|
+
for (let t of e) {
|
|
573
|
+
let e = t.codePointAt(0);
|
|
574
|
+
i += r.advanceOf(e) ?? r.size * .55, a !== null && (i += r.kernOf(a, e)), a = e;
|
|
575
|
+
}
|
|
576
|
+
return i * t / r.size;
|
|
577
|
+
}
|
|
578
|
+
//#endregion
|
|
389
579
|
//#region src/menu/drawPanel.ts
|
|
390
|
-
var
|
|
580
|
+
var nt = {
|
|
391
581
|
rowHeight: 24,
|
|
392
582
|
padX: 8,
|
|
393
583
|
padY: 4,
|
|
@@ -395,7 +585,7 @@ var Y = {
|
|
|
395
585
|
minWidth: 180,
|
|
396
586
|
fontSize: 13
|
|
397
587
|
};
|
|
398
|
-
function
|
|
588
|
+
function J(e, t) {
|
|
399
589
|
let n = t.padY;
|
|
400
590
|
return e.map((e) => {
|
|
401
591
|
let r = e.kind === "separator" ? t.separatorHeight : t.rowHeight, i = {
|
|
@@ -405,13 +595,13 @@ function X(e, t) {
|
|
|
405
595
|
return n += r, i;
|
|
406
596
|
});
|
|
407
597
|
}
|
|
408
|
-
var
|
|
409
|
-
function
|
|
410
|
-
let r =
|
|
598
|
+
var rt = (e) => e.kind === "item" ? pe(e.shortcut) : void 0;
|
|
599
|
+
function it(e, t, n) {
|
|
600
|
+
let r = J(e, t).at(-1), i = Math.max(0, ...e.map((e) => {
|
|
411
601
|
if (e.kind === "separator") return 0;
|
|
412
|
-
let r =
|
|
602
|
+
let r = Ke(e, t, n);
|
|
413
603
|
if (r !== void 0) return n(e.label, t.fontSize) + r;
|
|
414
|
-
let i =
|
|
604
|
+
let i = rt(e);
|
|
415
605
|
return n(e.label, t.fontSize) + Math.max(t.rowHeight, i ? t.padX + n(i, t.fontSize) : 0);
|
|
416
606
|
}));
|
|
417
607
|
return {
|
|
@@ -419,10 +609,10 @@ function ke(e, t, n) {
|
|
|
419
609
|
h: (r ? r.y + r.h : 0) + t.padY
|
|
420
610
|
};
|
|
421
611
|
}
|
|
422
|
-
var
|
|
612
|
+
var Y = (e) => ({ paint: {
|
|
423
613
|
kind: "solid",
|
|
424
614
|
color: e
|
|
425
|
-
} }),
|
|
615
|
+
} }), at = (e, t, n, r, i) => ({
|
|
426
616
|
kind: "path",
|
|
427
617
|
path: {
|
|
428
618
|
kind: "rect",
|
|
@@ -431,12 +621,12 @@ var Z = (e) => ({ paint: {
|
|
|
431
621
|
width: n,
|
|
432
622
|
height: r
|
|
433
623
|
},
|
|
434
|
-
fill:
|
|
624
|
+
fill: Y(i)
|
|
435
625
|
});
|
|
436
|
-
function
|
|
626
|
+
function ot(e, t, n) {
|
|
437
627
|
return {
|
|
438
628
|
kind: "path",
|
|
439
|
-
path:
|
|
629
|
+
path: g(`M ${e - 3 / 2} ${t - 3} L ${e + 3 / 2} ${t} L ${e - 3 / 2} ${t + 3}`),
|
|
440
630
|
stroke: {
|
|
441
631
|
paint: {
|
|
442
632
|
kind: "solid",
|
|
@@ -447,10 +637,10 @@ function je(e, t, n) {
|
|
|
447
637
|
}
|
|
448
638
|
};
|
|
449
639
|
}
|
|
450
|
-
function
|
|
640
|
+
function st(e, t, n) {
|
|
451
641
|
return {
|
|
452
642
|
kind: "path",
|
|
453
|
-
path:
|
|
643
|
+
path: g(`M ${e - 4} ${t} L ${e - 1.5} ${t + 2.5} L ${e + 4} ${t - 3}`),
|
|
454
644
|
stroke: {
|
|
455
645
|
paint: {
|
|
456
646
|
kind: "solid",
|
|
@@ -462,12 +652,15 @@ function Me(e, t, n) {
|
|
|
462
652
|
}
|
|
463
653
|
};
|
|
464
654
|
}
|
|
465
|
-
var
|
|
466
|
-
|
|
467
|
-
|
|
655
|
+
var X = 16, ct = "var(--wzl-bevel-raised, 0 8px 24px var(--wzl-shadow))", lt = {
|
|
656
|
+
number: (e) => e.value,
|
|
657
|
+
text: (e) => e.value
|
|
658
|
+
};
|
|
659
|
+
function ut(e, t, n, r, i, a, o = lt) {
|
|
660
|
+
let s = e.tokens, c = s["--wzl-fg"], l = k(s["--wzl-fg-muted"], c), u = re("--wzl-radius-md", s), d = {
|
|
468
661
|
fontFamily: e.defaultFont,
|
|
469
662
|
fontSize: i.fontSize
|
|
470
|
-
}, f =
|
|
663
|
+
}, f = Ee(t, u, ne(O(ct, s)), c, {
|
|
471
664
|
x: t.x + 1,
|
|
472
665
|
y: t.y + 1,
|
|
473
666
|
w: t.w - 2,
|
|
@@ -476,8 +669,8 @@ function Pe(e, t, n, r, i, a, o = (e) => e.value) {
|
|
|
476
669
|
...f.under,
|
|
477
670
|
{
|
|
478
671
|
kind: "path",
|
|
479
|
-
path:
|
|
480
|
-
fill:
|
|
672
|
+
path: E(t.x, t.y, t.w, t.h, u),
|
|
673
|
+
fill: Y(s["--wzl-surface-popover"]),
|
|
481
674
|
stroke: {
|
|
482
675
|
paint: {
|
|
483
676
|
kind: "solid",
|
|
@@ -487,65 +680,57 @@ function Pe(e, t, n, r, i, a, o = (e) => e.value) {
|
|
|
487
680
|
}
|
|
488
681
|
},
|
|
489
682
|
...f.over
|
|
490
|
-
], m =
|
|
491
|
-
return n.forEach((
|
|
492
|
-
let
|
|
493
|
-
if (
|
|
494
|
-
p.push(
|
|
683
|
+
], m = J(n, i), h = o.measure ?? q, g = s["--wzl-accent-soft"] ?? s["--wzl-surface-pressed"] ?? l;
|
|
684
|
+
return n.forEach((n, u) => {
|
|
685
|
+
let f = m[u];
|
|
686
|
+
if (n.kind === "separator") {
|
|
687
|
+
p.push(at(t.x + i.padX, t.y + f.y + Math.floor(f.h / 2), t.w - i.padX * 2, 1, s["--wzl-border"]));
|
|
495
688
|
return;
|
|
496
689
|
}
|
|
497
|
-
|
|
498
|
-
let
|
|
499
|
-
p.push(
|
|
500
|
-
text:
|
|
501
|
-
fill:
|
|
502
|
-
}], d, void 0,
|
|
503
|
-
let
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
690
|
+
u === r && p.push(at(t.x + 2, t.y + f.y, t.w - 4, f.h, s["--wzl-surface-hover"]));
|
|
691
|
+
let _ = n.disabled || n.kind === "color" ? l : c;
|
|
692
|
+
p.push(v(t.x + i.padX + i.rowHeight, t.y + f.y, [{
|
|
693
|
+
text: n.label,
|
|
694
|
+
fill: Y(_)
|
|
695
|
+
}], d, void 0, f.h, "center"));
|
|
696
|
+
let y = t.x + i.padX + i.rowHeight / 2, b = t.y + f.y + f.h / 2, x = n.kind !== "color" && typeof n.icon == "string" ? he(n.icon) : void 0, S = x ? a?.get(x) : void 0, C = o.swatch?.(n);
|
|
697
|
+
if (C !== void 0) {
|
|
698
|
+
let e = n.kind === "item" && n.checked;
|
|
699
|
+
p.push($e(t, f, C, i, e ? c : s["--wzl-border"], e ? 2 : 1));
|
|
700
|
+
} else n.kind === "item" && n.checked ? p.push(st(y, b, _)) : S && p.push(...Le(S, {
|
|
701
|
+
x: y - X / 2,
|
|
702
|
+
y: b - X / 2,
|
|
703
|
+
size: X,
|
|
704
|
+
color: _
|
|
509
705
|
}));
|
|
510
|
-
let
|
|
511
|
-
|
|
512
|
-
text:
|
|
513
|
-
fill:
|
|
706
|
+
let w = rt(n);
|
|
707
|
+
w && p.push(v(t.x + i.padX, t.y + f.y, [{
|
|
708
|
+
text: w,
|
|
709
|
+
fill: Y(l)
|
|
514
710
|
}], {
|
|
515
711
|
...d,
|
|
516
712
|
align: "right"
|
|
517
|
-
}, void 0,
|
|
518
|
-
let
|
|
713
|
+
}, void 0, f.h, "center", void 0, t.w - i.padX * 2));
|
|
714
|
+
let T = {
|
|
519
715
|
fg: c,
|
|
520
716
|
muted: l,
|
|
521
717
|
border: s["--wzl-border"],
|
|
522
718
|
font: d
|
|
523
719
|
};
|
|
524
|
-
|
|
720
|
+
if (n.kind === "number" && p.push(...qe(t, f, n, o.number(n), i, T)), n.kind === "color" && p.push(...et(t, f, n, i, T)), n.kind === "text") {
|
|
721
|
+
let r = o.editing?.entry === n ? o.editing : void 0;
|
|
722
|
+
p.push(...r ? Qe(t, f, r, i, T, g, (t) => h(t, i.fontSize, e.defaultFont)) : Je(t, f, o.text(n), i, T, n.disabled ? "off" : "live"));
|
|
723
|
+
}
|
|
724
|
+
n.kind === "submenu" && p.push(ot(t.x + t.w - i.padX - i.rowHeight / 2, t.y + f.y + f.h / 2, _));
|
|
525
725
|
}), p;
|
|
526
726
|
}
|
|
527
|
-
function
|
|
528
|
-
let r =
|
|
727
|
+
function Z(e, t, n) {
|
|
728
|
+
let r = J(e, t).findIndex((e) => n >= e.y && n < e.y + e.h);
|
|
529
729
|
return r < 0 ? null : r;
|
|
530
730
|
}
|
|
531
731
|
//#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
732
|
//#region src/menu/placePanels.ts
|
|
548
|
-
function
|
|
733
|
+
function dt(e) {
|
|
549
734
|
let t = [], n = null;
|
|
550
735
|
return (r, i) => {
|
|
551
736
|
let a = A();
|
|
@@ -566,11 +751,11 @@ function Re(e) {
|
|
|
566
751
|
continue;
|
|
567
752
|
}
|
|
568
753
|
f = !1;
|
|
569
|
-
let p =
|
|
570
|
-
if (n === 0) m = e.under ?
|
|
754
|
+
let p = it(a, l, (t, n) => i === null ? tt(t, n) : e.measure(t, n, i)), m;
|
|
755
|
+
if (n === 0) m = e.under ? ue(p, e.under, c) : le(p, e.anchor, c);
|
|
571
756
|
else {
|
|
572
|
-
let e = d[n - 1].rect, t =
|
|
573
|
-
m =
|
|
757
|
+
let e = d[n - 1].rect, t = J(r.entriesAt(n - 1), l)[o];
|
|
758
|
+
m = de(p, {
|
|
574
759
|
x: e.x,
|
|
575
760
|
y: e.y + t.y,
|
|
576
761
|
w: e.w,
|
|
@@ -593,15 +778,122 @@ function Re(e) {
|
|
|
593
778
|
};
|
|
594
779
|
}
|
|
595
780
|
//#endregion
|
|
781
|
+
//#region src/menu/colorPicker.ts
|
|
782
|
+
var ft = [
|
|
783
|
+
"#000000",
|
|
784
|
+
"#595959",
|
|
785
|
+
"#a6a6a6",
|
|
786
|
+
"#ffffff",
|
|
787
|
+
"#e53935",
|
|
788
|
+
"#fb8c00",
|
|
789
|
+
"#fdd835",
|
|
790
|
+
"#43a047",
|
|
791
|
+
"#00acc1",
|
|
792
|
+
"#1e88e5",
|
|
793
|
+
"#8e24aa",
|
|
794
|
+
"#d81b60"
|
|
795
|
+
];
|
|
796
|
+
function Q(e, t, n) {
|
|
797
|
+
let r = D(e);
|
|
798
|
+
if (r !== void 0) return t ? r.length === 9 ? r : `${r}${n && D(n, "rgba")?.slice(7) || "ff"}` : r.slice(0, 7);
|
|
799
|
+
}
|
|
800
|
+
function pt(e, t, n) {
|
|
801
|
+
let r = /* @__PURE__ */ new Map(), i = (e) => {
|
|
802
|
+
let i = () => n().colorValue(e), a = e.alpha === !0, o = t.map((t) => {
|
|
803
|
+
let o = Q(t, a, e.value) ?? t, s = {
|
|
804
|
+
kind: "item",
|
|
805
|
+
key: `${e.key}/${t}`,
|
|
806
|
+
label: t,
|
|
807
|
+
keepOpen: !0,
|
|
808
|
+
get checked() {
|
|
809
|
+
return Q(i() ?? "", a) === Q(o, a);
|
|
810
|
+
},
|
|
811
|
+
run: () => n().setColor(e, Q(t, a, i()) ?? t)
|
|
812
|
+
};
|
|
813
|
+
return r.set(s, () => o), s;
|
|
814
|
+
}), s = {
|
|
815
|
+
kind: "text",
|
|
816
|
+
key: `${e.key}/#`,
|
|
817
|
+
label: "Hex",
|
|
818
|
+
get value() {
|
|
819
|
+
return i();
|
|
820
|
+
},
|
|
821
|
+
set: (t) => {
|
|
822
|
+
let r = Q(t, a, i());
|
|
823
|
+
r !== void 0 && n().setColor(e, r);
|
|
824
|
+
}
|
|
825
|
+
}, c = {
|
|
826
|
+
kind: "submenu",
|
|
827
|
+
key: e.key,
|
|
828
|
+
label: e.label,
|
|
829
|
+
...e.access ? { access: e.access } : {},
|
|
830
|
+
entries: [
|
|
831
|
+
...o,
|
|
832
|
+
{
|
|
833
|
+
kind: "separator",
|
|
834
|
+
key: `${e.key}/|`
|
|
835
|
+
},
|
|
836
|
+
s
|
|
837
|
+
]
|
|
838
|
+
};
|
|
839
|
+
return r.set(c, i), c;
|
|
840
|
+
}, a = (e) => e.map((e) => e.kind === "submenu" ? {
|
|
841
|
+
...e,
|
|
842
|
+
entries: a(e.entries)
|
|
843
|
+
} : e.kind === "color" && e.set && !e.disabled ? i(e) : e);
|
|
844
|
+
return {
|
|
845
|
+
entries: a(e),
|
|
846
|
+
swatchOf: (e) => r.get(e)?.()
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
//#endregion
|
|
850
|
+
//#region src/menu/chipRepeat.ts
|
|
851
|
+
function $(e, t, n) {
|
|
852
|
+
for (let r = e.length - 1; r >= 0; r--) {
|
|
853
|
+
let i = e[r];
|
|
854
|
+
if (t >= i.x && t < i.x + i.w && n >= i.y && n < i.y + i.h) return r;
|
|
855
|
+
}
|
|
856
|
+
return -1;
|
|
857
|
+
}
|
|
858
|
+
function mt(e, t, n, r, i) {
|
|
859
|
+
let a = $(t, r, i);
|
|
860
|
+
if (a < 0) return null;
|
|
861
|
+
let o = t[a], s = e.entriesAt(a), c = Z(s, n, i - o.y), l = c === null ? void 0 : s[c];
|
|
862
|
+
if (l?.kind !== "number" || l.disabled) return null;
|
|
863
|
+
let u = Ge(o.w, n, r - o.x);
|
|
864
|
+
return u === null ? null : {
|
|
865
|
+
entry: l,
|
|
866
|
+
dir: u
|
|
867
|
+
};
|
|
868
|
+
}
|
|
869
|
+
function ht(e, t, n) {
|
|
870
|
+
let r = (t) => e.numberValue(t) ?? t.min ?? 0, i = f(({ entry: t, dir: n }) => {
|
|
871
|
+
e.spin(t, n > 0 ? "ArrowUp" : "ArrowDown");
|
|
872
|
+
}, ({ entry: e, dir: t }) => e.disabled === !0 || !j(e, r(e), t), n);
|
|
873
|
+
return {
|
|
874
|
+
press(e, n) {
|
|
875
|
+
let r = t(e, n);
|
|
876
|
+
r && i.start(r);
|
|
877
|
+
},
|
|
878
|
+
follow(e) {
|
|
879
|
+
let n = i.held();
|
|
880
|
+
if (!n) return;
|
|
881
|
+
let r = e && t(e.x, e.y);
|
|
882
|
+
(r?.entry !== n.entry || r.dir !== n.dir) && i.stop();
|
|
883
|
+
},
|
|
884
|
+
stop: i.stop
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
//#endregion
|
|
596
888
|
//#region src/menu/menuWidget.ts
|
|
597
|
-
var
|
|
889
|
+
var gt = [
|
|
598
890
|
"pointer",
|
|
599
891
|
"doubleClick",
|
|
600
892
|
"contextMenu",
|
|
601
893
|
"longPress",
|
|
602
894
|
"wheel"
|
|
603
895
|
];
|
|
604
|
-
function
|
|
896
|
+
function _t(e, t) {
|
|
605
897
|
let n = t({
|
|
606
898
|
x: e.x,
|
|
607
899
|
y: e.y
|
|
@@ -616,100 +908,139 @@ function Be(e, t) {
|
|
|
616
908
|
h: r.y - n.y
|
|
617
909
|
};
|
|
618
910
|
}
|
|
619
|
-
function
|
|
620
|
-
let t = e.
|
|
621
|
-
|
|
911
|
+
function vt(e) {
|
|
912
|
+
let t = Math.min(...e.map((e) => e.x)), n = Math.min(...e.map((e) => e.y)), r = Math.max(...e.map((e) => e.x + e.w)), i = Math.max(...e.map((e) => e.y + e.h));
|
|
913
|
+
return {
|
|
914
|
+
x: t,
|
|
915
|
+
y: n,
|
|
916
|
+
w: r - t,
|
|
917
|
+
h: i - n
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
function yt(e, t, n, r, i, a) {
|
|
921
|
+
return {
|
|
922
|
+
read: () => {
|
|
923
|
+
let a = t.current(), o = n();
|
|
924
|
+
for (let t = 0; a && t < o.length; t++) {
|
|
925
|
+
let n = e.entriesAt(t), s = n.indexOf(a.entry);
|
|
926
|
+
if (s < 0) continue;
|
|
927
|
+
let c = o[t], l = J(n, r)[s], u = c.x + Ze(a, c.w, r, i);
|
|
928
|
+
return {
|
|
929
|
+
rect: {
|
|
930
|
+
x: u,
|
|
931
|
+
y: c.y + l.y,
|
|
932
|
+
w: Math.max(1, c.x + c.w - u),
|
|
933
|
+
h: l.h
|
|
934
|
+
},
|
|
935
|
+
label: a.entry.label
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
return null;
|
|
939
|
+
},
|
|
940
|
+
subscribe: a,
|
|
941
|
+
compose: t.compose,
|
|
942
|
+
insert: t.insert
|
|
943
|
+
};
|
|
944
|
+
}
|
|
945
|
+
function bt(e) {
|
|
946
|
+
let t = e.metrics ?? nt, r = e.measure ?? q, i = m(), a = n(() => {
|
|
947
|
+
e.onChange(), i.emit();
|
|
948
|
+
}), o = pt(fe(e.open.entries, (e) => window.location.assign(e)), e.palette ?? ft, () => s), s = se({
|
|
949
|
+
entries: o.entries,
|
|
622
950
|
highlightFirst: e.open.source === "keyboard",
|
|
623
951
|
onClose: e.close
|
|
624
|
-
}),
|
|
952
|
+
}), c = dt({
|
|
625
953
|
anchor: e.toCanvas(e.open.client),
|
|
626
|
-
...e.open.under ? { under:
|
|
954
|
+
...e.open.under ? { under: _t(e.open.under, e.toCanvas) } : {},
|
|
627
955
|
canvasSize: e.canvasSize,
|
|
628
|
-
measure:
|
|
956
|
+
measure: r,
|
|
629
957
|
metrics: t
|
|
630
|
-
}),
|
|
631
|
-
|
|
632
|
-
|
|
958
|
+
}), l = null, u = c(s, l), d = !1, f = !1, p = null, h = We(s, a.changed), g = ht(s, (e, n) => mt(s, u, t, e, n), e.repeat);
|
|
959
|
+
s.subscribe(() => {
|
|
960
|
+
u = c(s, l), a.changed();
|
|
633
961
|
});
|
|
634
|
-
let
|
|
635
|
-
|
|
636
|
-
|
|
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) => {
|
|
962
|
+
let _ = (e) => {
|
|
963
|
+
p !== null && p !== e && s.hover(p, null), p = e;
|
|
964
|
+
}, v = (e) => {
|
|
651
965
|
if (e.type === "hoverleave") {
|
|
652
|
-
|
|
966
|
+
_(null);
|
|
653
967
|
return;
|
|
654
968
|
}
|
|
655
969
|
if (e.type === "cancel") {
|
|
656
|
-
|
|
970
|
+
f = !1, g.stop();
|
|
657
971
|
return;
|
|
658
972
|
}
|
|
659
973
|
if (e.type === "down") {
|
|
660
|
-
|
|
974
|
+
f = !0, g.press(e.x, e.y);
|
|
661
975
|
return;
|
|
662
976
|
}
|
|
663
977
|
if (e.type !== "hovermove" && e.type !== "move" && e.type !== "up") return;
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
978
|
+
g.follow(e.type === "up" ? null : e);
|
|
979
|
+
let n = $(u, e.x, e.y), i = e.type === "up" && f;
|
|
980
|
+
if (e.type === "up" && (f = !1), i || _(n < 0 ? null : n), n < 0) return;
|
|
981
|
+
let a = s.entriesAt(n), o = Z(a, t, e.y - u[n].y);
|
|
982
|
+
if (!i) s.hover(n, o, {
|
|
668
983
|
x: e.x,
|
|
669
984
|
y: e.y
|
|
670
985
|
});
|
|
671
986
|
else if (o !== null) {
|
|
672
|
-
|
|
673
|
-
let
|
|
674
|
-
|
|
987
|
+
h.leave(a[o]), s.press(n, o), h.start(a[o]);
|
|
988
|
+
let i = a[o], { w: c } = u[n], d = e.x - u[n].x;
|
|
989
|
+
h.place(i, (e) => Xe(e, c, t, d, (e) => r(e, t.fontSize, l ?? "")));
|
|
675
990
|
}
|
|
676
|
-
},
|
|
677
|
-
|
|
678
|
-
|
|
991
|
+
}, y = (e) => {
|
|
992
|
+
if (e.type !== "keydown") return !1;
|
|
993
|
+
if (h.key(e.key, Re(e))) return !0;
|
|
994
|
+
let t = s.stack().length - 1, n = s.stack()[t], r = n == null ? void 0 : s.entriesAt(t)[n];
|
|
995
|
+
return e.key === "Enter" && r?.kind === "text" ? h.start(r) : !e.ctrlKey && !e.metaKey && !e.altKey && s.key(e.key), !0;
|
|
996
|
+
}, b = {
|
|
997
|
+
read: () => be(s, o.swatchOf),
|
|
998
|
+
subscribe: s.subscribe
|
|
679
999
|
};
|
|
680
1000
|
return {
|
|
681
1001
|
id: `weasel-menu-${e.open.seq}`,
|
|
682
1002
|
get bounds() {
|
|
683
|
-
return
|
|
1003
|
+
return vt(u);
|
|
684
1004
|
},
|
|
685
1005
|
hidden: !1,
|
|
686
1006
|
get disposed() {
|
|
687
|
-
return
|
|
1007
|
+
return d;
|
|
688
1008
|
},
|
|
689
|
-
claims:
|
|
1009
|
+
claims: gt,
|
|
690
1010
|
focusable: !0,
|
|
691
1011
|
focusRing: !1,
|
|
692
1012
|
accessibleName: "Context menu",
|
|
693
|
-
accessibleTree:
|
|
1013
|
+
accessibleTree: b,
|
|
1014
|
+
textInput: yt(s, h, () => u, t, (e) => r(e, t.fontSize, l ?? ""), i.subscribe),
|
|
694
1015
|
deps: (t) => [
|
|
695
|
-
...
|
|
1016
|
+
...a.deps(),
|
|
696
1017
|
t.defaultFont,
|
|
697
1018
|
A(),
|
|
698
1019
|
e.icons?.getVersion()
|
|
699
1020
|
],
|
|
700
|
-
draw: (n) =>
|
|
701
|
-
|
|
1021
|
+
draw: (n) => {
|
|
1022
|
+
l = n.defaultFont, u = c(s, l);
|
|
1023
|
+
let i = {
|
|
1024
|
+
number: s.numberValue,
|
|
1025
|
+
text: s.textValue,
|
|
1026
|
+
editing: h.current(),
|
|
1027
|
+
swatch: o.swatchOf,
|
|
1028
|
+
measure: r
|
|
1029
|
+
};
|
|
1030
|
+
return u.flatMap((r, a) => ut(n, r, s.entriesAt(a), s.stack()[a] ?? null, t, e.icons, i));
|
|
1031
|
+
},
|
|
1032
|
+
hitTest: (e, t) => $(u, e, t) >= 0,
|
|
702
1033
|
cursorAt: () => "default",
|
|
703
|
-
onPointer:
|
|
704
|
-
onKey:
|
|
1034
|
+
onPointer: v,
|
|
1035
|
+
onKey: y,
|
|
705
1036
|
dispose() {
|
|
706
|
-
|
|
1037
|
+
h.leave(), g.stop(), d = !0, s.dispose();
|
|
707
1038
|
}
|
|
708
1039
|
};
|
|
709
1040
|
}
|
|
710
1041
|
//#endregion
|
|
711
1042
|
//#region src/menu/attachMenuHost.ts
|
|
712
|
-
function
|
|
1043
|
+
function xt(e, t, n) {
|
|
713
1044
|
let r = null, i = {
|
|
714
1045
|
widget: null,
|
|
715
1046
|
visible: !1
|
|
@@ -733,7 +1064,7 @@ function He(e, t, n) {
|
|
|
733
1064
|
c && o();
|
|
734
1065
|
return;
|
|
735
1066
|
}
|
|
736
|
-
let l =
|
|
1067
|
+
let l = bt({
|
|
737
1068
|
...n,
|
|
738
1069
|
open: s,
|
|
739
1070
|
close: () => {
|
|
@@ -742,28 +1073,29 @@ function He(e, t, n) {
|
|
|
742
1073
|
onChange: () => e.markDirty()
|
|
743
1074
|
});
|
|
744
1075
|
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) => {
|
|
1076
|
+
}, c = t.subscribe(s), l = e.subscribeFocus((e) => {
|
|
755
1077
|
r && e !== r && t.close();
|
|
1078
|
+
}), u = oe(window, {
|
|
1079
|
+
press: !1,
|
|
1080
|
+
outside: (e) => {
|
|
1081
|
+
if (!r) return !1;
|
|
1082
|
+
let t = n.toCanvas({
|
|
1083
|
+
x: e.clientX,
|
|
1084
|
+
y: e.clientY
|
|
1085
|
+
});
|
|
1086
|
+
return !r.hitTest(t.x, t.y);
|
|
1087
|
+
},
|
|
1088
|
+
close: () => {
|
|
1089
|
+
r && t.close();
|
|
1090
|
+
}
|
|
756
1091
|
});
|
|
757
|
-
return
|
|
758
|
-
|
|
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();
|
|
1092
|
+
return s(), () => {
|
|
1093
|
+
c(), l(), u(), a();
|
|
762
1094
|
};
|
|
763
1095
|
}
|
|
764
1096
|
//#endregion
|
|
765
1097
|
//#region src/loupe/contentWatch.ts
|
|
766
|
-
function
|
|
1098
|
+
function St(e) {
|
|
767
1099
|
let t = "", n = null;
|
|
768
1100
|
return {
|
|
769
1101
|
drew(e) {
|
|
@@ -780,12 +1112,12 @@ function Ue(e) {
|
|
|
780
1112
|
}
|
|
781
1113
|
//#endregion
|
|
782
1114
|
//#region src/loupe/pointerAim.ts
|
|
783
|
-
var
|
|
1115
|
+
var Ct = [
|
|
784
1116
|
"pointerup",
|
|
785
1117
|
"pointercancel",
|
|
786
1118
|
"lostpointercapture"
|
|
787
1119
|
];
|
|
788
|
-
function
|
|
1120
|
+
function wt(e, t) {
|
|
789
1121
|
let n = !1, r = (t) => {
|
|
790
1122
|
let n = e.getBoundingClientRect();
|
|
791
1123
|
return {
|
|
@@ -800,16 +1132,16 @@ function Ge(e, t) {
|
|
|
800
1132
|
n = !1;
|
|
801
1133
|
};
|
|
802
1134
|
e.addEventListener("pointermove", i), e.addEventListener("pointerdown", a);
|
|
803
|
-
for (let t of
|
|
1135
|
+
for (let t of Ct) e.addEventListener(t, o);
|
|
804
1136
|
return () => {
|
|
805
1137
|
e.removeEventListener("pointermove", i), e.removeEventListener("pointerdown", a);
|
|
806
|
-
for (let t of
|
|
1138
|
+
for (let t of Ct) e.removeEventListener(t, o);
|
|
807
1139
|
};
|
|
808
1140
|
}
|
|
809
1141
|
//#endregion
|
|
810
1142
|
//#region src/loupe/readback.ts
|
|
811
|
-
function
|
|
812
|
-
let s = n.x + Math.round(r.x * i), c = n.y + Math.round(r.y * i), l =
|
|
1143
|
+
function Tt(e, t, n, r, i, a, o) {
|
|
1144
|
+
let s = n.x + Math.round(r.x * i), c = n.y + Math.round(r.y * i), l = b(s - Math.floor(a / 2), n.x, n.x + Math.max(0, n.width - a)), u = t - b(c - Math.floor(o / 2), n.y, n.y + Math.max(0, n.height - o)) - o, d = new Uint8Array(a * o * 4);
|
|
813
1145
|
e.readPixels(l, u, a, o, e.RGBA, e.UNSIGNED_BYTE, d);
|
|
814
1146
|
let f = new Uint8ClampedArray(a * o * 4), p = a * 4;
|
|
815
1147
|
for (let e = 0; e < o; e++) {
|
|
@@ -820,7 +1152,7 @@ function Ke(e, t, n, r, i, a, o) {
|
|
|
820
1152
|
}
|
|
821
1153
|
//#endregion
|
|
822
1154
|
//#region src/loupe/createLoupe.ts
|
|
823
|
-
var
|
|
1155
|
+
var Et = (e, t) => ({
|
|
824
1156
|
kind: "path",
|
|
825
1157
|
path: {
|
|
826
1158
|
kind: "rect",
|
|
@@ -833,42 +1165,42 @@ var qe = (e, t) => ({
|
|
|
833
1165
|
kind: "solid",
|
|
834
1166
|
color: t
|
|
835
1167
|
} }
|
|
836
|
-
}),
|
|
1168
|
+
}), Dt = "weasel-loupe:lens", Ot = {
|
|
837
1169
|
x: 0,
|
|
838
1170
|
y: 0,
|
|
839
1171
|
w: 0,
|
|
840
1172
|
h: 0
|
|
841
1173
|
};
|
|
842
|
-
function
|
|
1174
|
+
function kt(e, t, n, r, i) {
|
|
843
1175
|
if (t && t.id !== null) {
|
|
844
1176
|
let n = {
|
|
845
1177
|
x: (e.x - t.rect.x) / t.view.scale.x + t.view.x,
|
|
846
1178
|
y: (e.y - t.rect.y) / t.view.scale.y + t.view.y
|
|
847
1179
|
};
|
|
848
|
-
return
|
|
1180
|
+
return M(n, t.view, r, i);
|
|
849
1181
|
}
|
|
850
|
-
let a =
|
|
851
|
-
return
|
|
1182
|
+
let a = _(e.x, e.y, y(n));
|
|
1183
|
+
return M({
|
|
852
1184
|
x: a[0],
|
|
853
1185
|
y: a[1]
|
|
854
1186
|
}, n, r, i);
|
|
855
1187
|
}
|
|
856
|
-
function
|
|
1188
|
+
function At(e) {
|
|
857
1189
|
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 = () => {
|
|
858
|
-
c &&= (
|
|
859
|
-
}, u = !1, d = !1,
|
|
1190
|
+
c &&= (ge(c), c.close(), null);
|
|
1191
|
+
}, u = !1, d = !1, f = !1, p = !1, m = e.bounds ?? {
|
|
860
1192
|
x: 24,
|
|
861
1193
|
y: 24,
|
|
862
1194
|
w: 220,
|
|
863
1195
|
h: 200
|
|
864
|
-
}, g =
|
|
865
|
-
id: `${
|
|
1196
|
+
}, g = St(e.contentVersion ?? i?.getPaintedVersion), _ = !1, v = (e) => (g.drew(e.view), k.mode === "vector" ? C(e) : w(e)), y = (t) => e.background ?? t.tokens["--wzl-surface"], b = (e) => Et(e, y(e)), x = () => i?.viewAt?.(k.aim, { except: Dt }) ?? null, S = (e, t) => kt(k.aim, x(), e, t, k.factor), C = (t) => i ? s ? [b(t), ...s.draw(t.data, t.view, t.dims)] : [b(t)] : h({
|
|
1197
|
+
id: `${D.id}:lens`,
|
|
866
1198
|
label: "Loupe content",
|
|
867
1199
|
source: e.source ?? [],
|
|
868
|
-
view:
|
|
1200
|
+
view: S(t.view, t.rect),
|
|
869
1201
|
bounds: () => t.rect,
|
|
870
1202
|
background: y(t)
|
|
871
|
-
}).draw(t.data, t.view, t.dims),
|
|
1203
|
+
}).draw(t.data, t.view, t.dims), w = (e) => {
|
|
872
1204
|
let t = [b(e)];
|
|
873
1205
|
return c && t.push({
|
|
874
1206
|
kind: "image",
|
|
@@ -879,10 +1211,10 @@ function Xe(e) {
|
|
|
879
1211
|
h: e.rect.h,
|
|
880
1212
|
sampling: "nearest"
|
|
881
1213
|
}), t;
|
|
882
|
-
},
|
|
883
|
-
|
|
884
|
-
},
|
|
885
|
-
if (!
|
|
1214
|
+
}, T = () => {
|
|
1215
|
+
f || k.mode !== "pixel" || (d = !0);
|
|
1216
|
+
}, E = (t, r, a) => {
|
|
1217
|
+
if (!p) return null;
|
|
886
1218
|
let o = n.getContext("webgl2");
|
|
887
1219
|
if (!o) return null;
|
|
888
1220
|
let s = n.getBoundingClientRect();
|
|
@@ -898,12 +1230,12 @@ function Xe(e) {
|
|
|
898
1230
|
width: n.width,
|
|
899
1231
|
height: n.height
|
|
900
1232
|
};
|
|
901
|
-
return
|
|
902
|
-
},
|
|
903
|
-
if (
|
|
904
|
-
let e =
|
|
1233
|
+
return Tt(o, n.height, u, t, c, r(c), a(c));
|
|
1234
|
+
}, ee = () => {
|
|
1235
|
+
if (f || k.mode !== "pixel") return;
|
|
1236
|
+
let e = D.contentRect, t = E(k.aim, (t) => Math.max(1, Math.round(e.w * t / k.factor)), (t) => Math.max(1, Math.round(e.h * t / k.factor)));
|
|
905
1237
|
t && (u = !0, createImageBitmap(t).then((e) => {
|
|
906
|
-
if (
|
|
1238
|
+
if (f) {
|
|
907
1239
|
e.close();
|
|
908
1240
|
return;
|
|
909
1241
|
}
|
|
@@ -911,92 +1243,93 @@ function Xe(e) {
|
|
|
911
1243
|
}).catch(() => {
|
|
912
1244
|
u = !1, r();
|
|
913
1245
|
}));
|
|
914
|
-
},
|
|
915
|
-
let t =
|
|
1246
|
+
}, te = (e) => {
|
|
1247
|
+
let t = E(e, () => 1, () => 1);
|
|
916
1248
|
return !t || t.data[3] === 0 ? null : "#" + [
|
|
917
1249
|
t.data[0],
|
|
918
1250
|
t.data[1],
|
|
919
1251
|
t.data[2]
|
|
920
1252
|
].map((e) => e.toString(16).padStart(2, "0")).join("");
|
|
921
|
-
},
|
|
1253
|
+
}, D = t.window({
|
|
922
1254
|
id: "weasel-loupe",
|
|
923
|
-
x:
|
|
924
|
-
y:
|
|
925
|
-
w:
|
|
926
|
-
h:
|
|
1255
|
+
x: m.x,
|
|
1256
|
+
y: m.y,
|
|
1257
|
+
w: m.w,
|
|
1258
|
+
h: m.h,
|
|
927
1259
|
title: e.title ?? "Loupe",
|
|
928
1260
|
titlebar: e.titlebar,
|
|
929
1261
|
content: v,
|
|
930
1262
|
interior: a ? "pass" : "claim",
|
|
931
1263
|
onResize: () => {
|
|
932
|
-
|
|
1264
|
+
T();
|
|
933
1265
|
},
|
|
934
1266
|
...a ? {} : { onContentClick: (e) => {
|
|
935
|
-
|
|
1267
|
+
k.pick(e);
|
|
936
1268
|
} },
|
|
937
1269
|
...e.onClose ? { onClose: e.onClose } : {}
|
|
938
|
-
}),
|
|
939
|
-
lens: () =>
|
|
940
|
-
covers: (e) =>
|
|
941
|
-
sample:
|
|
942
|
-
hidden: () =>
|
|
943
|
-
gone: () =>
|
|
1270
|
+
}), O = {
|
|
1271
|
+
lens: () => D.contentRect,
|
|
1272
|
+
covers: (e) => D.hitTest(e.x, e.y) || (D.passes?.(e.x, e.y) ?? !1),
|
|
1273
|
+
sample: te,
|
|
1274
|
+
hidden: () => D.hidden,
|
|
1275
|
+
gone: () => D.disposed === !0,
|
|
944
1276
|
changed: () => {
|
|
945
|
-
|
|
1277
|
+
T(), r();
|
|
946
1278
|
},
|
|
947
1279
|
subscribeFrame: t.subscribeFrame
|
|
948
|
-
},
|
|
949
|
-
|
|
950
|
-
}),
|
|
951
|
-
surface:
|
|
1280
|
+
}, ne = t.subscribeFrame(() => {
|
|
1281
|
+
p = !0, (g.changed() || _) && (_ = !1, T(), k.resample()), d && !u && (d = !1, ee());
|
|
1282
|
+
}), k = _e({
|
|
1283
|
+
surface: O,
|
|
952
1284
|
...e.mode ? { mode: e.mode } : {},
|
|
953
1285
|
...e.factor === void 0 ? {} : { factor: e.factor },
|
|
954
1286
|
...e.onColorChange ? { onColorChange: e.onColorChange } : {},
|
|
955
1287
|
...e.onPick ? { onPick: e.onPick } : {},
|
|
956
|
-
onDispose: () =>
|
|
1288
|
+
onDispose: () => A()
|
|
957
1289
|
});
|
|
958
1290
|
i && (s = i.addView({
|
|
959
|
-
id:
|
|
1291
|
+
id: Dt,
|
|
960
1292
|
label: "Loupe",
|
|
961
|
-
bounds: () =>
|
|
962
|
-
view: (e) =>
|
|
1293
|
+
bounds: () => D.hidden ? Ot : D.contentRect,
|
|
1294
|
+
view: (e) => S(e, D.contentRect),
|
|
963
1295
|
paint: !1,
|
|
964
1296
|
interactive: a,
|
|
1297
|
+
follows: () => x()?.id ?? null,
|
|
965
1298
|
...e.source ? { layers: () => e.source } : {}
|
|
966
1299
|
}));
|
|
967
|
-
let
|
|
968
|
-
aimAt: (e) =>
|
|
969
|
-
holds: (e) => a &&
|
|
970
|
-
}),
|
|
971
|
-
|
|
1300
|
+
let re = wt(o, {
|
|
1301
|
+
aimAt: (e) => k.aimAt(e),
|
|
1302
|
+
holds: (e) => a && O.covers(e)
|
|
1303
|
+
}), A = () => {
|
|
1304
|
+
f = !0, ne(), re(), s?.remove(), s = null, l();
|
|
972
1305
|
};
|
|
973
1306
|
return {
|
|
974
|
-
window:
|
|
1307
|
+
window: D,
|
|
975
1308
|
get mode() {
|
|
976
|
-
return
|
|
1309
|
+
return k.mode;
|
|
977
1310
|
},
|
|
978
1311
|
get factor() {
|
|
979
|
-
return
|
|
1312
|
+
return k.factor;
|
|
980
1313
|
},
|
|
981
1314
|
get aim() {
|
|
982
|
-
return
|
|
1315
|
+
return k.aim;
|
|
983
1316
|
},
|
|
984
1317
|
get color() {
|
|
985
|
-
return
|
|
1318
|
+
return k.color;
|
|
986
1319
|
},
|
|
987
|
-
setMode:
|
|
988
|
-
setFactor:
|
|
989
|
-
aimAt:
|
|
990
|
-
pick:
|
|
1320
|
+
setMode: k.setMode,
|
|
1321
|
+
setFactor: k.setFactor,
|
|
1322
|
+
aimAt: k.aimAt,
|
|
1323
|
+
pick: k.pick,
|
|
991
1324
|
refresh() {
|
|
992
|
-
|
|
1325
|
+
f || (_ = !0, r());
|
|
993
1326
|
},
|
|
994
1327
|
dispose() {
|
|
995
|
-
|
|
1328
|
+
k.dispose(), D.dispose();
|
|
996
1329
|
}
|
|
997
1330
|
};
|
|
998
1331
|
}
|
|
999
1332
|
//#endregion
|
|
1000
|
-
export { i as DEFAULT_FONT_FAMILY,
|
|
1333
|
+
export { i as DEFAULT_FONT_FAMILY, nt as DEFAULT_MENU_METRICS, ft as DEFAULT_MENU_PALETTE, a as DEFAULT_WIDGET_CLAIMS, l as DEFAULT_WINDOW_METRICS, u as HUD_AFFORDANCE_KIND, c as attachHud, xt as attachMenuHost, Ee as boxShadowCommands, d as claimsOf, s as createHud, o as createHudContribution, At as createLoupe, bt as createMenuWidget, t as cursorForZone, Le as glyphCommands, r as isFocusable, ve as loupeInnerView, q as measureLabel, e as registerDefaultFont };
|
|
1001
1334
|
|
|
1002
1335
|
//# sourceMappingURL=index.js.map
|