@weasel-js/hud 1.14.1 → 1.14.2
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.
|
@@ -97,15 +97,22 @@ function j(e) {
|
|
|
97
97
|
}
|
|
98
98
|
//#endregion
|
|
99
99
|
//#region src/widgets/text.ts
|
|
100
|
-
|
|
100
|
+
var M = { text: "" }, N = [M];
|
|
101
|
+
function P(e) {
|
|
101
102
|
let t = !1, n = E(e.onChange), r = {
|
|
102
103
|
x: e.x,
|
|
103
104
|
y: e.y,
|
|
104
105
|
w: 0,
|
|
105
106
|
h: e.fontSize
|
|
106
|
-
}, i = e.text, o = !1, s = null, c = () => {
|
|
107
|
-
s?.
|
|
108
|
-
},
|
|
107
|
+
}, i = e.text, o = !1, s = null, c = "", l = "", d = "", f = () => {
|
|
108
|
+
s?.kind === "text" && a(s.runs);
|
|
109
|
+
}, p = null, m = 0, h = 0, g = { paint: {
|
|
110
|
+
kind: "solid",
|
|
111
|
+
color: ""
|
|
112
|
+
} }, _ = {
|
|
113
|
+
fontFamily: "",
|
|
114
|
+
fontSize: e.fontSize
|
|
115
|
+
}, v = () => {
|
|
109
116
|
if (t) throw Error("weasel-hud: cannot mutate a disposed widget.");
|
|
110
117
|
};
|
|
111
118
|
return {
|
|
@@ -121,51 +128,32 @@ function M(e) {
|
|
|
121
128
|
return t;
|
|
122
129
|
},
|
|
123
130
|
setBounds(e) {
|
|
124
|
-
|
|
131
|
+
v(), r = { ...e }, n.changed();
|
|
125
132
|
},
|
|
126
133
|
setHidden(e) {
|
|
127
|
-
|
|
134
|
+
v(), o = e, n.changed();
|
|
128
135
|
},
|
|
129
136
|
setText(e) {
|
|
130
|
-
|
|
137
|
+
v(), i = e, n.changed();
|
|
131
138
|
},
|
|
132
139
|
draw(t) {
|
|
133
140
|
let n = e.color ?? t.tokens["--wzl-fg"], a = e.fontFamily ?? t.defaultFont;
|
|
134
|
-
if (
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
color: n
|
|
140
|
-
} }
|
|
141
|
-
}], {
|
|
141
|
+
if (s === null || c !== i || l !== n || d !== a) {
|
|
142
|
+
(s === null || l !== n) && (g = { paint: {
|
|
143
|
+
kind: "solid",
|
|
144
|
+
color: n
|
|
145
|
+
} }), (s === null || d !== a) && (_ = {
|
|
142
146
|
fontFamily: a,
|
|
143
147
|
fontSize: e.fontSize
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
color: n,
|
|
148
|
-
fontFamily: a,
|
|
149
|
-
cmd: t
|
|
150
|
-
}, l = {
|
|
151
|
-
x: r.x,
|
|
152
|
-
y: r.y,
|
|
153
|
-
out: [t]
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
if (l === null || l.x !== r.x || l.y !== r.y) {
|
|
157
|
-
let e = {
|
|
158
|
-
...s.cmd,
|
|
159
|
-
x: r.x,
|
|
160
|
-
y: r.y
|
|
161
|
-
};
|
|
162
|
-
l = {
|
|
163
|
-
x: r.x,
|
|
164
|
-
y: r.y,
|
|
165
|
-
out: [e]
|
|
166
|
-
};
|
|
148
|
+
}), M.text = i, M.fill = g;
|
|
149
|
+
let t = u(r.x, r.y, N, _);
|
|
150
|
+
M.fill = void 0, f(), s = t, c = i, l = n, d = a, p = [t], m = r.x, h = r.y;
|
|
167
151
|
}
|
|
168
|
-
return
|
|
152
|
+
return (p === null || m !== r.x || h !== r.y) && (p = [{
|
|
153
|
+
...s,
|
|
154
|
+
x: r.x,
|
|
155
|
+
y: r.y
|
|
156
|
+
}], m = r.x, h = r.y), p;
|
|
169
157
|
},
|
|
170
158
|
hitTest() {
|
|
171
159
|
return !1;
|
|
@@ -173,13 +161,13 @@ function M(e) {
|
|
|
173
161
|
claims: [],
|
|
174
162
|
onPointer(e) {},
|
|
175
163
|
dispose() {
|
|
176
|
-
t || (t = !0,
|
|
164
|
+
t || (t = !0, f(), e.removeFromHud?.());
|
|
177
165
|
}
|
|
178
166
|
};
|
|
179
167
|
}
|
|
180
168
|
//#endregion
|
|
181
169
|
//#region src/widgets/image.ts
|
|
182
|
-
function
|
|
170
|
+
function te(e) {
|
|
183
171
|
if (e.w <= 0 || e.h <= 0) throw Error(`createImage: bounds must have positive w/h (got ${e.w}x${e.h})`);
|
|
184
172
|
let t = !1, n = E(e.onChange), r = {
|
|
185
173
|
x: e.x,
|
|
@@ -248,8 +236,8 @@ function N(e) {
|
|
|
248
236
|
}
|
|
249
237
|
//#endregion
|
|
250
238
|
//#region src/widgets/label.ts
|
|
251
|
-
function
|
|
252
|
-
return
|
|
239
|
+
function ne(e) {
|
|
240
|
+
return P({
|
|
253
241
|
id: e.id,
|
|
254
242
|
x: e.x,
|
|
255
243
|
y: e.y,
|
|
@@ -262,7 +250,7 @@ function te(e) {
|
|
|
262
250
|
}
|
|
263
251
|
//#endregion
|
|
264
252
|
//#region src/widgets/button.ts
|
|
265
|
-
function
|
|
253
|
+
function re(e) {
|
|
266
254
|
if (e.w <= 0 || e.h <= 0) throw Error("createButton: bounds must have positive w/h");
|
|
267
255
|
let t = !1, n = E(e.onChange), r = {
|
|
268
256
|
x: e.x,
|
|
@@ -377,11 +365,11 @@ function ne(e) {
|
|
|
377
365
|
}
|
|
378
366
|
//#endregion
|
|
379
367
|
//#region src/widgets/window/windowLook.ts
|
|
380
|
-
function
|
|
368
|
+
function ie(e, t) {
|
|
381
369
|
let n = /^var\((--[\w-]+)\)$/.exec(t)?.[1];
|
|
382
370
|
return n === void 0 ? t : e[n];
|
|
383
371
|
}
|
|
384
|
-
function
|
|
372
|
+
function ae(e, { stance: t, grade: n, emphasis: r }) {
|
|
385
373
|
let i = e["--wzl-surface-raised"], a = S(e, {
|
|
386
374
|
surface: i,
|
|
387
375
|
"border-color": e["--wzl-border"],
|
|
@@ -392,7 +380,7 @@ function ie(e, { stance: t, grade: n, emphasis: r }) {
|
|
|
392
380
|
"title-color": e["--wzl-fg-muted"],
|
|
393
381
|
"title-case": "none"
|
|
394
382
|
}, { stance: t });
|
|
395
|
-
if (r !== void 0) for (let [t, n] of Object.entries(_[r])) a[t] =
|
|
383
|
+
if (r !== void 0) for (let [t, n] of Object.entries(_[r])) a[t] = ie(e, n);
|
|
396
384
|
if (n !== void 0) {
|
|
397
385
|
let t = e[y[n]];
|
|
398
386
|
for (let e of v) a[e] = t;
|
|
@@ -401,18 +389,18 @@ function ie(e, { stance: t, grade: n, emphasis: r }) {
|
|
|
401
389
|
}
|
|
402
390
|
//#endregion
|
|
403
391
|
//#region src/widgets/window/zones.ts
|
|
404
|
-
var
|
|
392
|
+
var F = {
|
|
405
393
|
titleH: 24,
|
|
406
394
|
edge: 6,
|
|
407
395
|
closeSize: 14,
|
|
408
396
|
grip: 14
|
|
409
397
|
};
|
|
410
|
-
function
|
|
398
|
+
function I(e, t, n, r) {
|
|
411
399
|
if (n < e.x || n >= e.x + e.w || r < e.y || r >= e.y + e.h) return null;
|
|
412
400
|
let i = n < e.x + t.edge, a = n >= e.x + e.w - t.edge, o = r < e.y + t.edge, s = r >= e.y + e.h - t.edge;
|
|
413
401
|
return o && i ? "nw" : o && a ? "ne" : s && i ? "sw" : s && a ? "se" : o ? "n" : s ? "s" : i ? "w" : a ? "e" : r < e.y + t.titleH ? n >= e.x + e.w - t.edge - t.closeSize ? "close" : "title" : "content";
|
|
414
402
|
}
|
|
415
|
-
function
|
|
403
|
+
function oe(e, t) {
|
|
416
404
|
return {
|
|
417
405
|
x: e.x + t.edge,
|
|
418
406
|
y: e.y + t.titleH,
|
|
@@ -420,7 +408,7 @@ function ae(e, t) {
|
|
|
420
408
|
h: e.h - t.titleH - t.edge
|
|
421
409
|
};
|
|
422
410
|
}
|
|
423
|
-
function
|
|
411
|
+
function se(e, t, n, r, i, a) {
|
|
424
412
|
if (t === "title") return {
|
|
425
413
|
...e,
|
|
426
414
|
x: e.x + n,
|
|
@@ -451,14 +439,14 @@ function L(e) {
|
|
|
451
439
|
}
|
|
452
440
|
//#endregion
|
|
453
441
|
//#region src/widgets/window/window.ts
|
|
454
|
-
function
|
|
442
|
+
function ce(e, t, n) {
|
|
455
443
|
let [r, i, a, o] = g(s(e), s(n), Number.parseFloat(t) / 100);
|
|
456
444
|
return `rgba(${Math.round(r * 255)}, ${Math.round(i * 255)}, ${Math.round(a * 255)}, ${o})`;
|
|
457
445
|
}
|
|
458
|
-
function
|
|
446
|
+
function le(e, t) {
|
|
459
447
|
return t === "uppercase" ? e.toUpperCase() : t === "lowercase" ? e.toLowerCase() : e;
|
|
460
448
|
}
|
|
461
|
-
function
|
|
449
|
+
function ue(e, t, n) {
|
|
462
450
|
let r = 1.1, i = "";
|
|
463
451
|
for (let n of [
|
|
464
452
|
-5,
|
|
@@ -477,9 +465,9 @@ function ce(e, t, n) {
|
|
|
477
465
|
} }
|
|
478
466
|
};
|
|
479
467
|
}
|
|
480
|
-
function
|
|
468
|
+
function de(e) {
|
|
481
469
|
let t = e.titlebar ?? !0, n = e.interior === "pass", r = {
|
|
482
|
-
...
|
|
470
|
+
...F,
|
|
483
471
|
...e.metrics
|
|
484
472
|
}, i = !t && n, a = t ? r : {
|
|
485
473
|
...r,
|
|
@@ -536,10 +524,10 @@ function le(e) {
|
|
|
536
524
|
return g;
|
|
537
525
|
},
|
|
538
526
|
get contentRect() {
|
|
539
|
-
return
|
|
527
|
+
return oe(w, a);
|
|
540
528
|
},
|
|
541
529
|
cursorAt(e, t) {
|
|
542
|
-
let n = M(
|
|
530
|
+
let n = M(I(w, a, e, t));
|
|
543
531
|
return n ? L(n) : "default";
|
|
544
532
|
},
|
|
545
533
|
content: e.content,
|
|
@@ -566,14 +554,14 @@ function le(e) {
|
|
|
566
554
|
},
|
|
567
555
|
draw(e) {
|
|
568
556
|
f = e.dims;
|
|
569
|
-
let { x: n, y: r, w: o, h: s } = w, c = [], d =
|
|
557
|
+
let { x: n, y: r, w: o, h: s } = w, c = [], d = ae(e.tokens, {
|
|
570
558
|
stance: b,
|
|
571
559
|
grade: x,
|
|
572
560
|
emphasis: S
|
|
573
561
|
}), p = C === void 0 ? void 0 : e.color(typeof C == "number" ? {
|
|
574
562
|
ref: ee,
|
|
575
563
|
index: C
|
|
576
|
-
} : C), m = p === void 0 && b === void 0 && x === void 0 ? d.surface :
|
|
564
|
+
} : C), m = p === void 0 && b === void 0 && x === void 0 ? d.surface : ce(p ?? d.tint, d["tint-mix"], d.surface), g = r + a.titleH, _ = s - a.titleH, v = [
|
|
577
565
|
{
|
|
578
566
|
x: n,
|
|
579
567
|
y: r,
|
|
@@ -632,9 +620,9 @@ function le(e) {
|
|
|
632
620
|
};
|
|
633
621
|
c.push(i);
|
|
634
622
|
}
|
|
635
|
-
if (i && c.push(
|
|
623
|
+
if (i && c.push(ue(n + o / 2, r + (a.edge + a.grip) / 2, d["title-color"])), !t) return c;
|
|
636
624
|
c.push(u(n + a.edge + 2, r, [{
|
|
637
|
-
text:
|
|
625
|
+
text: le(y, d["title-case"]),
|
|
638
626
|
fill: { paint: {
|
|
639
627
|
kind: "solid",
|
|
640
628
|
color: d["title-color"]
|
|
@@ -659,16 +647,16 @@ function le(e) {
|
|
|
659
647
|
},
|
|
660
648
|
hitTest(e, t) {
|
|
661
649
|
if (v) return !1;
|
|
662
|
-
let r =
|
|
650
|
+
let r = I(w, a, e, t);
|
|
663
651
|
return r !== null && !(n && r === "content");
|
|
664
652
|
},
|
|
665
653
|
passes(e, t) {
|
|
666
|
-
return n && !v &&
|
|
654
|
+
return n && !v && I(w, a, e, t) === "content";
|
|
667
655
|
},
|
|
668
656
|
onPointer(t) {
|
|
669
657
|
switch (t.type) {
|
|
670
658
|
case "down":
|
|
671
|
-
k =
|
|
659
|
+
k = I(w, a, t.x, t.y), A = !1, T = M(k), D = w, O = {
|
|
672
660
|
x: t.x,
|
|
673
661
|
y: t.y
|
|
674
662
|
};
|
|
@@ -682,12 +670,12 @@ function le(e) {
|
|
|
682
670
|
clientX: t.x,
|
|
683
671
|
clientY: t.y
|
|
684
672
|
}) && (A = !0);
|
|
685
|
-
let n =
|
|
673
|
+
let n = se(D, T, t.x - O.x, t.y - O.y, o, s), r = T === "title" ? m(n) : n;
|
|
686
674
|
(r.x !== w.x || r.y !== w.y || r.w !== w.w || r.h !== w.h) && (w = r, (T === "title" ? e.onMove : e.onResize)?.(w), _.changed());
|
|
687
675
|
break;
|
|
688
676
|
}
|
|
689
677
|
case "up":
|
|
690
|
-
T === "close" &&
|
|
678
|
+
T === "close" && I(w, a, t.x, t.y) === "close" ? e.onClose?.() : k === "content" && !A && e.onContentClick?.({
|
|
691
679
|
x: t.x,
|
|
692
680
|
y: t.y
|
|
693
681
|
}), T = null, k = null;
|
|
@@ -702,7 +690,7 @@ function le(e) {
|
|
|
702
690
|
}
|
|
703
691
|
//#endregion
|
|
704
692
|
//#region src/hud.ts
|
|
705
|
-
function
|
|
693
|
+
function fe() {
|
|
706
694
|
let e = [], i = null, a = !1, o = r(), s = null, c = () => {
|
|
707
695
|
i?.requestRedraw();
|
|
708
696
|
}, l = null, u = !1, d = r(), f = (e, t) => {
|
|
@@ -788,7 +776,7 @@ function ue() {
|
|
|
788
776
|
},
|
|
789
777
|
text(e) {
|
|
790
778
|
let t = null, n = g(() => t);
|
|
791
|
-
return t =
|
|
779
|
+
return t = P({
|
|
792
780
|
...e,
|
|
793
781
|
onChange: () => c(),
|
|
794
782
|
removeFromHud: n
|
|
@@ -796,7 +784,7 @@ function ue() {
|
|
|
796
784
|
},
|
|
797
785
|
image(e) {
|
|
798
786
|
let t = null, n = g(() => t);
|
|
799
|
-
return t =
|
|
787
|
+
return t = te({
|
|
800
788
|
...e,
|
|
801
789
|
onChange: () => c(),
|
|
802
790
|
removeFromHud: n
|
|
@@ -804,7 +792,7 @@ function ue() {
|
|
|
804
792
|
},
|
|
805
793
|
label(e) {
|
|
806
794
|
let t = null, n = g(() => t);
|
|
807
|
-
return t =
|
|
795
|
+
return t = ne({
|
|
808
796
|
...e,
|
|
809
797
|
onChange: () => c(),
|
|
810
798
|
removeFromHud: n
|
|
@@ -812,7 +800,7 @@ function ue() {
|
|
|
812
800
|
},
|
|
813
801
|
button(e) {
|
|
814
802
|
let t = null, n = g(() => t);
|
|
815
|
-
return t =
|
|
803
|
+
return t = re({
|
|
816
804
|
...e,
|
|
817
805
|
onChange: () => c(),
|
|
818
806
|
removeFromHud: n
|
|
@@ -820,7 +808,7 @@ function ue() {
|
|
|
820
808
|
},
|
|
821
809
|
window(e) {
|
|
822
810
|
let t = null, n = g(() => t);
|
|
823
|
-
return t =
|
|
811
|
+
return t = de({
|
|
824
812
|
...e,
|
|
825
813
|
onChange: () => c(),
|
|
826
814
|
removeFromHud: n
|
|
@@ -836,7 +824,7 @@ async function z(e) {
|
|
|
836
824
|
}
|
|
837
825
|
//#endregion
|
|
838
826
|
//#region src/colors.ts
|
|
839
|
-
function
|
|
827
|
+
function B(e) {
|
|
840
828
|
return (t) => {
|
|
841
829
|
let n = b(t, e);
|
|
842
830
|
return (n && m(n)) ?? void 0;
|
|
@@ -844,7 +832,7 @@ function de(e) {
|
|
|
844
832
|
}
|
|
845
833
|
//#endregion
|
|
846
834
|
//#region src/accessibleMirror.ts
|
|
847
|
-
function
|
|
835
|
+
function V(e) {
|
|
848
836
|
Object.assign(e.style, {
|
|
849
837
|
position: "absolute",
|
|
850
838
|
width: "1px",
|
|
@@ -857,7 +845,7 @@ function B(e) {
|
|
|
857
845
|
border: "0"
|
|
858
846
|
});
|
|
859
847
|
}
|
|
860
|
-
var
|
|
848
|
+
var pe = 0, H = (e) => ({
|
|
861
849
|
...e,
|
|
862
850
|
active: void 0,
|
|
863
851
|
children: e.children?.map(H)
|
|
@@ -882,8 +870,8 @@ function W(e, t, n) {
|
|
|
882
870
|
} else t.label && (r.textContent = t.label);
|
|
883
871
|
return r;
|
|
884
872
|
}
|
|
885
|
-
function
|
|
886
|
-
let n = e.ownerDocument, r = `weasel-hud-a11y-${++
|
|
873
|
+
function me(e, t) {
|
|
874
|
+
let n = e.ownerDocument, r = `weasel-hud-a11y-${++pe}`, i = null, a = "", o = null, s = () => {
|
|
887
875
|
i?.remove(), i = null, a = "", e.removeAttribute("aria-owns"), e.removeAttribute("aria-activedescendant");
|
|
888
876
|
}, c = (t) => {
|
|
889
877
|
let o = t.accessibleTree?.read();
|
|
@@ -892,7 +880,7 @@ function G(e, t) {
|
|
|
892
880
|
return;
|
|
893
881
|
}
|
|
894
882
|
let c = JSON.stringify(H(o));
|
|
895
|
-
(!i || c !== a) && (s(), i = W(n, o, r), a = c,
|
|
883
|
+
(!i || c !== a) && (s(), i = W(n, o, r), a = c, V(i), n.body.appendChild(i), e.setAttribute("aria-owns", i.id));
|
|
896
884
|
for (let e of [i, ...i.querySelectorAll("[aria-activedescendant]")]) e.removeAttribute("aria-activedescendant");
|
|
897
885
|
let l = U(o, r);
|
|
898
886
|
l ? (n.getElementById(l.container)?.setAttribute("aria-activedescendant", l.id), e.setAttribute("aria-activedescendant", l.id)) : e.removeAttribute("aria-activedescendant");
|
|
@@ -907,7 +895,7 @@ function G(e, t) {
|
|
|
907
895
|
}
|
|
908
896
|
//#endregion
|
|
909
897
|
//#region src/layerDeps.ts
|
|
910
|
-
function
|
|
898
|
+
function he(e) {
|
|
911
899
|
let t = [0], n = [], r = [], a = [], o = [], s = null, c = !1, l = NaN, u = NaN;
|
|
912
900
|
return (d) => {
|
|
913
901
|
let f = e.widgets(), p = f.length === n.length && e.focused === s && e.focusVisible === c && d.dims.width === l && d.dims.height === u;
|
|
@@ -922,7 +910,7 @@ function fe(e) {
|
|
|
922
910
|
}
|
|
923
911
|
//#endregion
|
|
924
912
|
//#region src/textInputHost.ts
|
|
925
|
-
function
|
|
913
|
+
function ge(t, n, r) {
|
|
926
914
|
let i = t.ownerDocument, a = i.createElement("input");
|
|
927
915
|
a.type = "text", a.tabIndex = -1, a.autocomplete = "off", a.spellcheck = !1, a.setAttribute("autocapitalize", "off"), a.dataset.weaselHud = "text-input", Object.assign(a.style, {
|
|
928
916
|
position: "fixed",
|
|
@@ -991,8 +979,8 @@ function pe(t, n, r) {
|
|
|
991
979
|
}
|
|
992
980
|
//#endregion
|
|
993
981
|
//#region src/attach.ts
|
|
994
|
-
function
|
|
995
|
-
let r = n.theme ?? C(w), i =
|
|
982
|
+
function G(e, t, n = {}) {
|
|
983
|
+
let r = n.theme ?? C(w), i = B(n.tints ?? {
|
|
996
984
|
theme: w,
|
|
997
985
|
resolved: r
|
|
998
986
|
});
|
|
@@ -1009,7 +997,7 @@ function K(e, t, n = {}) {
|
|
|
1009
997
|
if (k(i).length !== 0 && !i.hidden && i.hitTest(e, n)) return i;
|
|
1010
998
|
}
|
|
1011
999
|
return null;
|
|
1012
|
-
}, l = /* @__PURE__ */ new WeakMap(), u = (e, t, n) =>
|
|
1000
|
+
}, l = /* @__PURE__ */ new WeakMap(), u = (e, t, n) => _e(l, e, t, n), p = he(t), m = {
|
|
1013
1001
|
dims: {
|
|
1014
1002
|
width: 0,
|
|
1015
1003
|
height: 0
|
|
@@ -1060,7 +1048,7 @@ function K(e, t, n = {}) {
|
|
|
1060
1048
|
let n = l === e ? t.focusVisible ? 2 : 1 : 0;
|
|
1061
1049
|
for (let t of u(e, s, n)) c.push(t);
|
|
1062
1050
|
}
|
|
1063
|
-
return l && t.focusVisible && !l.hidden && l.focusRing !== !1 && c.push(
|
|
1051
|
+
return l && t.focusVisible && !l.hidden && l.focusRing !== !1 && c.push(ye(l, r["--wzl-focus-ring"])), c;
|
|
1064
1052
|
},
|
|
1065
1053
|
hitTest: (e, t, n, r, i) => {
|
|
1066
1054
|
let a = d(r), [o, s] = f(e, t, a), l = c(o, s);
|
|
@@ -1091,7 +1079,7 @@ function K(e, t, n = {}) {
|
|
|
1091
1079
|
native: null
|
|
1092
1080
|
}), s = null, e.requestRedraw());
|
|
1093
1081
|
}
|
|
1094
|
-
}), g = e.element ?
|
|
1082
|
+
}), g = e.element ? be(e.element, t, c) : () => {};
|
|
1095
1083
|
return t.bind({
|
|
1096
1084
|
requestRedraw: e.requestRedraw,
|
|
1097
1085
|
registerLayer: () => () => {},
|
|
@@ -1103,7 +1091,7 @@ function K(e, t, n = {}) {
|
|
|
1103
1091
|
}), null), g(), h(), t.unbind();
|
|
1104
1092
|
};
|
|
1105
1093
|
}
|
|
1106
|
-
function
|
|
1094
|
+
function _e(e, t, n, r) {
|
|
1107
1095
|
if (!t.deps) return t.draw(n);
|
|
1108
1096
|
let a = t.deps(n), o = t.bounds, s = e.get(t);
|
|
1109
1097
|
if (s && s.focus === r && s.tokens === n.tokens && s.font === n.defaultFont && s.width === n.dims.width && s.height === n.dims.height && s.x === o.x && s.y === o.y && s.w === o.w && s.h === o.h && i(s.deps, a)) return s.cmds;
|
|
@@ -1122,8 +1110,8 @@ function me(e, t, n, r) {
|
|
|
1122
1110
|
h: o.h
|
|
1123
1111
|
}), c);
|
|
1124
1112
|
}
|
|
1125
|
-
var
|
|
1126
|
-
function
|
|
1113
|
+
var ve = 2;
|
|
1114
|
+
function ye(e, t) {
|
|
1127
1115
|
let { x: n, y: r, w: i, h: a } = e.bounds;
|
|
1128
1116
|
return {
|
|
1129
1117
|
kind: "path",
|
|
@@ -1139,11 +1127,11 @@ function ge(e, t) {
|
|
|
1139
1127
|
kind: "solid",
|
|
1140
1128
|
color: t
|
|
1141
1129
|
},
|
|
1142
|
-
width:
|
|
1130
|
+
width: ve
|
|
1143
1131
|
}
|
|
1144
1132
|
};
|
|
1145
1133
|
}
|
|
1146
|
-
function
|
|
1134
|
+
function K(e, t) {
|
|
1147
1135
|
return {
|
|
1148
1136
|
type: t,
|
|
1149
1137
|
key: e.key,
|
|
@@ -1156,7 +1144,7 @@ function q(e, t) {
|
|
|
1156
1144
|
native: e
|
|
1157
1145
|
};
|
|
1158
1146
|
}
|
|
1159
|
-
function
|
|
1147
|
+
function be(e, t, n) {
|
|
1160
1148
|
let r = (r) => {
|
|
1161
1149
|
let i = e.getBoundingClientRect(), a = n(r.clientX - i.left, r.clientY - i.top);
|
|
1162
1150
|
t.focus(a && D(a) ? a : null, { visible: !1 });
|
|
@@ -1166,7 +1154,7 @@ function _e(e, t, n) {
|
|
|
1166
1154
|
}, a = (e) => {
|
|
1167
1155
|
if (e.defaultPrevented) return;
|
|
1168
1156
|
let n = i();
|
|
1169
|
-
if (n && !t.focusVisible && t.focus(n, { visible: !0 }), n?.onKey?.(
|
|
1157
|
+
if (n && !t.focusVisible && t.focus(n, { visible: !0 }), n?.onKey?.(K(e, "keydown"))) {
|
|
1170
1158
|
e.preventDefault();
|
|
1171
1159
|
return;
|
|
1172
1160
|
}
|
|
@@ -1174,8 +1162,8 @@ function _e(e, t, n) {
|
|
|
1174
1162
|
let r = e.shiftKey ? "prev" : "next";
|
|
1175
1163
|
(n !== null || r !== "prev") && (t.moveFocus(r) !== null || r === "prev") && e.preventDefault();
|
|
1176
1164
|
}, o = (e) => {
|
|
1177
|
-
e.defaultPrevented || i()?.onKey?.(
|
|
1178
|
-
}, s =
|
|
1165
|
+
e.defaultPrevented || i()?.onKey?.(K(e, "keyup")) && e.preventDefault();
|
|
1166
|
+
}, s = ge(e, t, {
|
|
1179
1167
|
keydown: a,
|
|
1180
1168
|
keyup: o,
|
|
1181
1169
|
blur: () => {
|
|
@@ -1183,43 +1171,43 @@ function _e(e, t, n) {
|
|
|
1183
1171
|
}
|
|
1184
1172
|
}), c = (e) => {
|
|
1185
1173
|
e.relatedTarget !== s.input && t.focus(null);
|
|
1186
|
-
}, l =
|
|
1174
|
+
}, l = xe(e.ownerDocument), u = t.subscribeFocus((e) => {
|
|
1187
1175
|
l.textContent = e?.accessibleName ?? "";
|
|
1188
|
-
}), d =
|
|
1176
|
+
}), d = me(e, t);
|
|
1189
1177
|
return e.addEventListener("pointerdown", r), e.addEventListener("keydown", a), e.addEventListener("keyup", o), e.addEventListener("blur", c), () => {
|
|
1190
1178
|
e.removeEventListener("pointerdown", r), e.removeEventListener("keydown", a), e.removeEventListener("keyup", o), e.removeEventListener("blur", c), u(), d(), s.detach(), l.remove();
|
|
1191
1179
|
};
|
|
1192
1180
|
}
|
|
1193
|
-
function
|
|
1181
|
+
function xe(e) {
|
|
1194
1182
|
let t = e.createElement("div");
|
|
1195
|
-
return t.setAttribute("aria-live", "polite"), t.setAttribute("aria-atomic", "true"), t.dataset.weaselHud = "focus",
|
|
1183
|
+
return t.setAttribute("aria-live", "polite"), t.setAttribute("aria-atomic", "true"), t.dataset.weaselHud = "focus", V(t), e.body.appendChild(t), t;
|
|
1196
1184
|
}
|
|
1197
1185
|
//#endregion
|
|
1198
1186
|
//#region src/tool.ts
|
|
1199
|
-
var
|
|
1187
|
+
var q = "layer:weasel-hud", J = {
|
|
1200
1188
|
shift: "optional",
|
|
1201
1189
|
alt: "optional",
|
|
1202
1190
|
meta: "optional",
|
|
1203
1191
|
ctrl: "optional"
|
|
1204
1192
|
};
|
|
1205
|
-
function
|
|
1206
|
-
return e?.kind ===
|
|
1193
|
+
function Se(e) {
|
|
1194
|
+
return e?.kind === q;
|
|
1207
1195
|
}
|
|
1208
|
-
function
|
|
1196
|
+
function Y(e) {
|
|
1209
1197
|
return e?.payload?.widget ?? null;
|
|
1210
1198
|
}
|
|
1211
|
-
function
|
|
1199
|
+
function X(e) {
|
|
1212
1200
|
return o((t) => {
|
|
1213
|
-
if (!
|
|
1214
|
-
let n =
|
|
1201
|
+
if (!Se(t)) return !1;
|
|
1202
|
+
let n = Y(t);
|
|
1215
1203
|
return n !== null && k(n).includes(e);
|
|
1216
1204
|
});
|
|
1217
1205
|
}
|
|
1218
|
-
function
|
|
1206
|
+
function Z(e, t, n) {
|
|
1219
1207
|
let r = e.view?.get();
|
|
1220
1208
|
return r ? f(t, n, d(r)) : [t, n];
|
|
1221
1209
|
}
|
|
1222
|
-
function
|
|
1210
|
+
function Ce() {
|
|
1223
1211
|
return {
|
|
1224
1212
|
id: "hud.press",
|
|
1225
1213
|
label: "HUD — press widget",
|
|
@@ -1227,9 +1215,9 @@ function be() {
|
|
|
1227
1215
|
invoker: {
|
|
1228
1216
|
timing: "immediate",
|
|
1229
1217
|
run: (e, t) => {
|
|
1230
|
-
let n = t, r =
|
|
1218
|
+
let n = t, r = Y(n?.affordance);
|
|
1231
1219
|
if (!r || !n?.world) return;
|
|
1232
|
-
let [i, a] =
|
|
1220
|
+
let [i, a] = Z(e, n.world.x, n.world.y);
|
|
1233
1221
|
r.onPointer({
|
|
1234
1222
|
type: "down",
|
|
1235
1223
|
x: i,
|
|
@@ -1240,7 +1228,7 @@ function be() {
|
|
|
1240
1228
|
}
|
|
1241
1229
|
};
|
|
1242
1230
|
}
|
|
1243
|
-
function
|
|
1231
|
+
function Q() {
|
|
1244
1232
|
return {
|
|
1245
1233
|
id: "hud.release",
|
|
1246
1234
|
label: "HUD — release widget",
|
|
@@ -1248,9 +1236,9 @@ function xe() {
|
|
|
1248
1236
|
invoker: {
|
|
1249
1237
|
timing: "immediate",
|
|
1250
1238
|
run: (e, t) => {
|
|
1251
|
-
let n = t, r =
|
|
1239
|
+
let n = t, r = Y(n?.affordance);
|
|
1252
1240
|
if (!r || !n?.world) return;
|
|
1253
|
-
let [i, a] =
|
|
1241
|
+
let [i, a] = Z(e, n.world.x, n.world.y);
|
|
1254
1242
|
r.onPointer({
|
|
1255
1243
|
type: "up",
|
|
1256
1244
|
x: i,
|
|
@@ -1261,7 +1249,7 @@ function xe() {
|
|
|
1261
1249
|
}
|
|
1262
1250
|
};
|
|
1263
1251
|
}
|
|
1264
|
-
function
|
|
1252
|
+
function we() {
|
|
1265
1253
|
return {
|
|
1266
1254
|
id: "hud.drag",
|
|
1267
1255
|
label: "HUD — drag widget",
|
|
@@ -1269,12 +1257,12 @@ function Se() {
|
|
|
1269
1257
|
invoker: {
|
|
1270
1258
|
timing: "ongoing",
|
|
1271
1259
|
start: (e) => {
|
|
1272
|
-
let t =
|
|
1260
|
+
let t = Y(e.drag?.affordance);
|
|
1273
1261
|
if (!t) return {};
|
|
1274
1262
|
let n = e.deps;
|
|
1275
1263
|
return {
|
|
1276
1264
|
onMove: (e) => {
|
|
1277
|
-
let [r, i] =
|
|
1265
|
+
let [r, i] = Z(n, e.world.x, e.world.y);
|
|
1278
1266
|
t.onPointer({
|
|
1279
1267
|
type: "move",
|
|
1280
1268
|
x: r,
|
|
@@ -1290,7 +1278,7 @@ function Se() {
|
|
|
1290
1278
|
});
|
|
1291
1279
|
return;
|
|
1292
1280
|
}
|
|
1293
|
-
let [i, a] =
|
|
1281
|
+
let [i, a] = Z(n, e.world.x, e.world.y);
|
|
1294
1282
|
t.onPointer({
|
|
1295
1283
|
type: "up",
|
|
1296
1284
|
x: i,
|
|
@@ -1311,9 +1299,9 @@ function $(e, t, n) {
|
|
|
1311
1299
|
invoker: {
|
|
1312
1300
|
timing: "immediate",
|
|
1313
1301
|
run: (e, t) => {
|
|
1314
|
-
let r = t, i =
|
|
1302
|
+
let r = t, i = Y(r?.affordance);
|
|
1315
1303
|
if (!i || !r?.world) return;
|
|
1316
|
-
let [a, o] =
|
|
1304
|
+
let [a, o] = Z(e, r.world.x, r.world.y);
|
|
1317
1305
|
i.onPointer({
|
|
1318
1306
|
type: n,
|
|
1319
1307
|
x: a,
|
|
@@ -1324,14 +1312,14 @@ function $(e, t, n) {
|
|
|
1324
1312
|
}
|
|
1325
1313
|
};
|
|
1326
1314
|
}
|
|
1327
|
-
function
|
|
1315
|
+
function Te() {
|
|
1328
1316
|
return {
|
|
1329
1317
|
id: "hud.wheel",
|
|
1330
1318
|
label: "HUD — wheel over widget",
|
|
1331
1319
|
invoker: {
|
|
1332
1320
|
timing: "immediate",
|
|
1333
1321
|
run: (e, t) => {
|
|
1334
|
-
let n = t, r =
|
|
1322
|
+
let n = t, r = Y(n?.affordance);
|
|
1335
1323
|
r && n?.clientX !== void 0 && n.clientY !== void 0 && r.onPointer({
|
|
1336
1324
|
type: "wheel",
|
|
1337
1325
|
x: n.clientX,
|
|
@@ -1344,29 +1332,29 @@ function Ce() {
|
|
|
1344
1332
|
}
|
|
1345
1333
|
};
|
|
1346
1334
|
}
|
|
1347
|
-
function
|
|
1335
|
+
function Ee(e, t) {
|
|
1348
1336
|
return {
|
|
1349
1337
|
id: "weasel-hud",
|
|
1350
1338
|
...e ? { attach: (n) => {
|
|
1351
|
-
let r =
|
|
1339
|
+
let r = G(n, e, t);
|
|
1352
1340
|
return n.requestRedraw(), r;
|
|
1353
1341
|
} } : {},
|
|
1354
1342
|
eligibility: { claimed: !0 },
|
|
1355
1343
|
actions: [
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1344
|
+
Ce(),
|
|
1345
|
+
Q(),
|
|
1346
|
+
we(),
|
|
1359
1347
|
$("hud.doubleClick", "HUD — double-click widget", "doubleclick"),
|
|
1360
1348
|
$("hud.contextMenu", "HUD — right-click widget", "contextmenu"),
|
|
1361
1349
|
$("hud.longPress", "HUD — long-press widget", "longpress"),
|
|
1362
|
-
|
|
1350
|
+
Te()
|
|
1363
1351
|
],
|
|
1364
1352
|
bindings: [
|
|
1365
1353
|
{
|
|
1366
1354
|
spec: {
|
|
1367
1355
|
kind: "pointerDown",
|
|
1368
|
-
target: { kindOf:
|
|
1369
|
-
mods:
|
|
1356
|
+
target: { kindOf: X("pointer") },
|
|
1357
|
+
mods: J
|
|
1370
1358
|
},
|
|
1371
1359
|
actionId: "hud.press",
|
|
1372
1360
|
opts: { id: "weasel-hud.press" }
|
|
@@ -1374,8 +1362,8 @@ function we(e, t) {
|
|
|
1374
1362
|
{
|
|
1375
1363
|
spec: {
|
|
1376
1364
|
kind: "click",
|
|
1377
|
-
target: { kindOf:
|
|
1378
|
-
mods:
|
|
1365
|
+
target: { kindOf: X("pointer") },
|
|
1366
|
+
mods: J
|
|
1379
1367
|
},
|
|
1380
1368
|
actionId: "hud.release",
|
|
1381
1369
|
opts: { id: "weasel-hud.release" }
|
|
@@ -1383,8 +1371,8 @@ function we(e, t) {
|
|
|
1383
1371
|
{
|
|
1384
1372
|
spec: {
|
|
1385
1373
|
kind: "drag",
|
|
1386
|
-
target: { kindOf:
|
|
1387
|
-
mods:
|
|
1374
|
+
target: { kindOf: X("pointer") },
|
|
1375
|
+
mods: J
|
|
1388
1376
|
},
|
|
1389
1377
|
actionId: "hud.drag",
|
|
1390
1378
|
opts: { id: "weasel-hud.drag" }
|
|
@@ -1392,8 +1380,8 @@ function we(e, t) {
|
|
|
1392
1380
|
{
|
|
1393
1381
|
spec: {
|
|
1394
1382
|
kind: "doubleClick",
|
|
1395
|
-
target: { kindOf:
|
|
1396
|
-
mods:
|
|
1383
|
+
target: { kindOf: X("doubleClick") },
|
|
1384
|
+
mods: J
|
|
1397
1385
|
},
|
|
1398
1386
|
actionId: "hud.doubleClick",
|
|
1399
1387
|
opts: { id: "weasel-hud.doubleClick" }
|
|
@@ -1401,8 +1389,8 @@ function we(e, t) {
|
|
|
1401
1389
|
{
|
|
1402
1390
|
spec: {
|
|
1403
1391
|
kind: "contextMenu",
|
|
1404
|
-
target: { kindOf:
|
|
1405
|
-
mods:
|
|
1392
|
+
target: { kindOf: X("contextMenu") },
|
|
1393
|
+
mods: J
|
|
1406
1394
|
},
|
|
1407
1395
|
actionId: "hud.contextMenu",
|
|
1408
1396
|
opts: { id: "weasel-hud.contextMenu" }
|
|
@@ -1410,8 +1398,8 @@ function we(e, t) {
|
|
|
1410
1398
|
{
|
|
1411
1399
|
spec: {
|
|
1412
1400
|
kind: "longPress",
|
|
1413
|
-
target: { kindOf:
|
|
1414
|
-
mods:
|
|
1401
|
+
target: { kindOf: X("longPress") },
|
|
1402
|
+
mods: J
|
|
1415
1403
|
},
|
|
1416
1404
|
actionId: "hud.longPress",
|
|
1417
1405
|
opts: { id: "weasel-hud.longPress" }
|
|
@@ -1419,8 +1407,8 @@ function we(e, t) {
|
|
|
1419
1407
|
{
|
|
1420
1408
|
spec: {
|
|
1421
1409
|
kind: "wheel",
|
|
1422
|
-
target: { kindOf:
|
|
1423
|
-
mods:
|
|
1410
|
+
target: { kindOf: X("wheel") },
|
|
1411
|
+
mods: J
|
|
1424
1412
|
},
|
|
1425
1413
|
actionId: "hud.wheel",
|
|
1426
1414
|
opts: { id: "weasel-hud.wheel" }
|
|
@@ -1429,6 +1417,6 @@ function we(e, t) {
|
|
|
1429
1417
|
};
|
|
1430
1418
|
}
|
|
1431
1419
|
//#endregion
|
|
1432
|
-
export { z as a, L as c, E as d, D as f, R as i, O as l,
|
|
1420
|
+
export { z as a, L as c, E as d, D as f, R as i, O as l, Ee as n, fe as o, G as r, F as s, q as t, k as u };
|
|
1433
1421
|
|
|
1434
|
-
//# sourceMappingURL=tool-
|
|
1422
|
+
//# sourceMappingURL=tool-P3ATLOH4.js.map
|