@weasel-js/hud 1.4.4 → 1.5.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/index.js +146 -110
- package/dist/index.js.map +1 -1
- package/dist/loupe/createLoupe.d.ts +44 -9
- package/dist/loupe/createLoupe.d.ts.map +1 -1
- package/dist/loupe/readback.d.ts +6 -2
- package/dist/loupe/readback.d.ts.map +1 -1
- package/dist/react/index.js +2 -2
- package/dist/react/index.js.map +1 -1
- package/dist/{tool-ahNtvOfu.js → tool-D-WiQSIl.js} +64 -58
- package/dist/{tool-ahNtvOfu.js.map → tool-D-WiQSIl.js.map} +1 -1
- package/dist/widget.d.ts +5 -0
- package/dist/widget.d.ts.map +1 -1
- package/dist/widgets/window/window.d.ts +9 -0
- package/dist/widgets/window/window.d.ts.map +1 -1
- package/package.json +6 -6
|
@@ -353,19 +353,19 @@ function _(e) {
|
|
|
353
353
|
//#region src/widgets/window/window.ts
|
|
354
354
|
var v = 3;
|
|
355
355
|
function y(n) {
|
|
356
|
-
let r = n.titlebar ?? !0, a = {
|
|
356
|
+
let r = n.titlebar ?? !0, a = n.interior === "pass", o = {
|
|
357
357
|
...p,
|
|
358
358
|
...n.metrics
|
|
359
|
-
},
|
|
360
|
-
...
|
|
361
|
-
titleH:
|
|
362
|
-
},
|
|
359
|
+
}, s = r ? o : {
|
|
360
|
+
...o,
|
|
361
|
+
titleH: o.edge
|
|
362
|
+
}, c = n.minW ?? 80, l = n.minH ?? s.titleH + s.edge + 40, u = (e) => ({
|
|
363
363
|
x: e.x,
|
|
364
364
|
y: e.y,
|
|
365
|
-
w: Math.max(
|
|
366
|
-
h: Math.max(
|
|
367
|
-
}),
|
|
368
|
-
if (!
|
|
365
|
+
w: Math.max(c, e.w),
|
|
366
|
+
h: Math.max(l, e.h)
|
|
367
|
+
}), d = null, f = (e) => {
|
|
368
|
+
if (!d) return e;
|
|
369
369
|
let t = i({
|
|
370
370
|
x: e.x,
|
|
371
371
|
y: e.y,
|
|
@@ -374,84 +374,84 @@ function y(n) {
|
|
|
374
374
|
}, {
|
|
375
375
|
x: 0,
|
|
376
376
|
y: 0,
|
|
377
|
-
width:
|
|
378
|
-
height:
|
|
377
|
+
width: d.width,
|
|
378
|
+
height: d.height
|
|
379
379
|
});
|
|
380
380
|
return {
|
|
381
381
|
...e,
|
|
382
382
|
x: t.x,
|
|
383
383
|
y: t.y
|
|
384
384
|
};
|
|
385
|
-
},
|
|
385
|
+
}, y = !1, b = !1, x = n.title, S = u({
|
|
386
386
|
x: n.x,
|
|
387
387
|
y: n.y,
|
|
388
388
|
w: n.w,
|
|
389
389
|
h: n.h
|
|
390
|
-
}),
|
|
390
|
+
}), C = null, w = S, T = {
|
|
391
391
|
x: 0,
|
|
392
392
|
y: 0
|
|
393
|
-
},
|
|
394
|
-
if (
|
|
395
|
-
},
|
|
396
|
-
x:
|
|
397
|
-
y:
|
|
398
|
-
w:
|
|
399
|
-
h:
|
|
393
|
+
}, E = null, D = !1, O = () => {
|
|
394
|
+
if (y) throw Error("weasel-hud: cannot mutate a disposed widget.");
|
|
395
|
+
}, k = (e) => !r && !a && e === "content" ? "title" : e, A = () => ({
|
|
396
|
+
x: S.x + S.w - s.edge - s.closeSize,
|
|
397
|
+
y: S.y + (s.titleH - s.closeSize) / 2,
|
|
398
|
+
w: s.closeSize,
|
|
399
|
+
h: s.closeSize
|
|
400
400
|
});
|
|
401
401
|
return {
|
|
402
402
|
id: n.id,
|
|
403
403
|
get bounds() {
|
|
404
|
-
return
|
|
404
|
+
return S;
|
|
405
405
|
},
|
|
406
406
|
get hidden() {
|
|
407
|
-
return
|
|
407
|
+
return b;
|
|
408
408
|
},
|
|
409
409
|
get disposed() {
|
|
410
|
-
return
|
|
410
|
+
return y;
|
|
411
411
|
},
|
|
412
412
|
get contentRect() {
|
|
413
|
-
return h(
|
|
413
|
+
return h(S, s);
|
|
414
414
|
},
|
|
415
415
|
cursorAt(e, t) {
|
|
416
|
-
let n =
|
|
416
|
+
let n = k(m(S, s, e, t));
|
|
417
417
|
return n ? _(n) : "default";
|
|
418
418
|
},
|
|
419
419
|
content: n.content,
|
|
420
420
|
setBounds(e) {
|
|
421
|
-
|
|
421
|
+
O(), S = f(u(e)), C = null, E = null, n.onChange?.();
|
|
422
422
|
},
|
|
423
423
|
setHidden(e) {
|
|
424
|
-
|
|
424
|
+
O(), b = e, n.onChange?.();
|
|
425
425
|
},
|
|
426
426
|
setTitle(e) {
|
|
427
|
-
|
|
427
|
+
O(), x = e, n.onChange?.();
|
|
428
428
|
},
|
|
429
429
|
draw(n) {
|
|
430
|
-
|
|
431
|
-
let { x: i, y: a, w:
|
|
430
|
+
d = n.dims;
|
|
431
|
+
let { x: i, y: a, w: o, h: c } = S, l = [], u = n.tokens["--wzl-surface-raised"], f = a + s.titleH, p = c - s.titleH, m = [
|
|
432
432
|
{
|
|
433
433
|
x: i,
|
|
434
434
|
y: a,
|
|
435
|
-
width:
|
|
436
|
-
height:
|
|
435
|
+
width: o,
|
|
436
|
+
height: s.titleH
|
|
437
437
|
},
|
|
438
438
|
{
|
|
439
439
|
x: i,
|
|
440
440
|
y: f,
|
|
441
|
-
width:
|
|
441
|
+
width: s.edge,
|
|
442
442
|
height: p
|
|
443
443
|
},
|
|
444
444
|
{
|
|
445
|
-
x: i +
|
|
445
|
+
x: i + o - s.edge,
|
|
446
446
|
y: f,
|
|
447
|
-
width:
|
|
447
|
+
width: s.edge,
|
|
448
448
|
height: p
|
|
449
449
|
},
|
|
450
450
|
{
|
|
451
|
-
x: i +
|
|
452
|
-
y: a + c -
|
|
453
|
-
width:
|
|
454
|
-
height:
|
|
451
|
+
x: i + s.edge,
|
|
452
|
+
y: a + c - s.edge,
|
|
453
|
+
width: o - s.edge * 2,
|
|
454
|
+
height: s.edge
|
|
455
455
|
}
|
|
456
456
|
];
|
|
457
457
|
for (let e of m) l.push({
|
|
@@ -462,7 +462,7 @@ function y(n) {
|
|
|
462
462
|
},
|
|
463
463
|
fill: {
|
|
464
464
|
fill: "solid",
|
|
465
|
-
color:
|
|
465
|
+
color: u
|
|
466
466
|
}
|
|
467
467
|
});
|
|
468
468
|
let h = {
|
|
@@ -471,7 +471,7 @@ function y(n) {
|
|
|
471
471
|
kind: "rect",
|
|
472
472
|
x: i,
|
|
473
473
|
y: a,
|
|
474
|
-
width:
|
|
474
|
+
width: o,
|
|
475
475
|
height: c
|
|
476
476
|
},
|
|
477
477
|
stroke: {
|
|
@@ -483,8 +483,8 @@ function y(n) {
|
|
|
483
483
|
}
|
|
484
484
|
};
|
|
485
485
|
if (l.push(h), !r) return l;
|
|
486
|
-
l.push(t(i +
|
|
487
|
-
text:
|
|
486
|
+
l.push(t(i + s.edge + 2, a, [{
|
|
487
|
+
text: x,
|
|
488
488
|
fill: {
|
|
489
489
|
fill: "solid",
|
|
490
490
|
color: n.tokens["--wzl-fg-muted"]
|
|
@@ -492,11 +492,11 @@ function y(n) {
|
|
|
492
492
|
}], {
|
|
493
493
|
fontFamily: n.defaultFont,
|
|
494
494
|
fontSize: 12
|
|
495
|
-
},
|
|
496
|
-
let g =
|
|
495
|
+
}, o - s.edge * 2 - s.closeSize - 4, s.titleH, "center"));
|
|
496
|
+
let g = A(), _ = g.x + 3, v = g.y + 3, y = g.x + g.w - 3, b = g.y + g.h - 3;
|
|
497
497
|
return l.push({
|
|
498
498
|
kind: "path",
|
|
499
|
-
path: e(`M ${_} ${v} L ${y} ${
|
|
499
|
+
path: e(`M ${_} ${v} L ${y} ${b} M ${y} ${v} L ${_} ${b}`),
|
|
500
500
|
stroke: {
|
|
501
501
|
paint: {
|
|
502
502
|
fill: "solid",
|
|
@@ -508,37 +508,42 @@ function y(n) {
|
|
|
508
508
|
}), l;
|
|
509
509
|
},
|
|
510
510
|
hitTest(e, t) {
|
|
511
|
-
|
|
511
|
+
if (b) return !1;
|
|
512
|
+
let n = m(S, s, e, t);
|
|
513
|
+
return n !== null && !(a && n === "content");
|
|
514
|
+
},
|
|
515
|
+
passes(e, t) {
|
|
516
|
+
return a && !b && m(S, s, e, t) === "content";
|
|
512
517
|
},
|
|
513
518
|
onPointer(e) {
|
|
514
519
|
switch (e.type) {
|
|
515
520
|
case "down":
|
|
516
|
-
|
|
521
|
+
E = m(S, s, e.x, e.y), D = !1, C = k(E), w = S, T = {
|
|
517
522
|
x: e.x,
|
|
518
523
|
y: e.y
|
|
519
524
|
};
|
|
520
525
|
break;
|
|
521
526
|
case "move": {
|
|
522
|
-
if (!
|
|
523
|
-
Math.hypot(e.x -
|
|
524
|
-
let t = g(
|
|
525
|
-
(r.x !==
|
|
527
|
+
if (!C) break;
|
|
528
|
+
Math.hypot(e.x - T.x, e.y - T.y) > v && (D = !0);
|
|
529
|
+
let t = g(w, C, e.x - T.x, e.y - T.y, c, l), r = C === "title" ? f(t) : t;
|
|
530
|
+
(r.x !== S.x || r.y !== S.y || r.w !== S.w || r.h !== S.h) && (S = r, (C === "title" ? n.onMove : n.onResize)?.(S), n.onChange?.());
|
|
526
531
|
break;
|
|
527
532
|
}
|
|
528
533
|
case "up":
|
|
529
|
-
|
|
534
|
+
C === "close" && m(S, s, e.x, e.y) === "close" ? n.onClose?.() : E === "content" && !D && n.onContentClick?.({
|
|
530
535
|
x: e.x,
|
|
531
536
|
y: e.y
|
|
532
|
-
}),
|
|
537
|
+
}), C = null, E = null;
|
|
533
538
|
break;
|
|
534
539
|
case "cancel":
|
|
535
|
-
|
|
540
|
+
C && (S = w, C = null, n.onChange?.()), E = null;
|
|
536
541
|
break;
|
|
537
542
|
default: break;
|
|
538
543
|
}
|
|
539
544
|
},
|
|
540
545
|
dispose() {
|
|
541
|
-
|
|
546
|
+
y || (y = !0, n.removeFromHud?.());
|
|
542
547
|
}
|
|
543
548
|
};
|
|
544
549
|
}
|
|
@@ -673,7 +678,7 @@ function T(e, t, n) {
|
|
|
673
678
|
//#endregion
|
|
674
679
|
//#region src/attach.ts
|
|
675
680
|
function E(e, t, i = {}) {
|
|
676
|
-
let a = i.theme ?? o(s
|
|
681
|
+
let a = i.theme ?? o(s);
|
|
677
682
|
if (t.attached) throw Error("weasel-hud: this HUD is already attached to a canvas.");
|
|
678
683
|
let c = i.font, l = typeof c == "string" ? c : x;
|
|
679
684
|
typeof c != "string" && S(c).then(() => e.requestRedraw()).catch((e) => {
|
|
@@ -683,6 +688,7 @@ function E(e, t, i = {}) {
|
|
|
683
688
|
let r = t.widgets();
|
|
684
689
|
for (let t = r.length - 1; t >= 0; t--) {
|
|
685
690
|
let i = r[t];
|
|
691
|
+
if (!i.hidden && i.passes?.(e, n)) return null;
|
|
686
692
|
if (w(i).length !== 0 && !i.hidden && i.hitTest(e, n)) return i;
|
|
687
693
|
}
|
|
688
694
|
return null;
|
|
@@ -990,4 +996,4 @@ function R() {
|
|
|
990
996
|
//#endregion
|
|
991
997
|
export { w as a, b as c, C as i, p as l, R as n, x as o, E as r, S as s, D as t, _ as u };
|
|
992
998
|
|
|
993
|
-
//# sourceMappingURL=tool-
|
|
999
|
+
//# sourceMappingURL=tool-D-WiQSIl.js.map
|