@weasel-js/hud 1.9.3 → 1.9.4
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/README.md +1 -1
- package/dist/index.js +86 -85
- package/dist/index.js.map +1 -1
- package/dist/loupe/createLoupe.d.ts.map +1 -1
- package/dist/loupe/readback.d.ts.map +1 -1
- package/dist/react/index.js +18 -7
- package/dist/react/index.js.map +1 -1
- package/dist/react/useHud.d.ts.map +1 -1
- package/dist/{tool-DdwuyuMK.js → tool-BLDCwvTF.js} +177 -177
- package/dist/tool-BLDCwvTF.js.map +1 -0
- package/dist/tool.d.ts.map +1 -1
- package/package.json +7 -7
- package/dist/tool-DdwuyuMK.js.map +0 -1
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ import { /* … */ } from '@weasel-js/hud/react';
|
|
|
24
24
|
`rect`, `text`, `image`, `label`, `button`, and `window` — a draggable,
|
|
25
25
|
resizable frame whose interior is painted by an opt-in `content` callback. See
|
|
26
26
|
[`src/widgets/window`](src/widgets/window/README.md) for how content composes
|
|
27
|
-
with the frame, and `createLoupe` in [`src/loupe`](src/loupe) for the first
|
|
27
|
+
with the frame, and `createLoupe` in [`src/loupe`](src/loupe/createLoupe.ts) for the first
|
|
28
28
|
consumer.
|
|
29
29
|
|
|
30
30
|
Widgets draw from a data-free context (`{ dims, defaultFont, tokens }`), which
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { a as e, c as t, d as n, i as r, l as i, n as a, o, r as s, s as c, t as l, u } from "./tool-
|
|
1
|
+
import { a as e, c as t, d as n, i as r, l as i, n as a, o, r as s, s as c, t as l, u } from "./tool-BLDCwvTF.js";
|
|
2
2
|
import { createViewportLayer as d, screenToWorld as f, viewToTransform as p } from "@weasel-js/core";
|
|
3
|
-
import {
|
|
3
|
+
import { clamp as m } from "@weasel-js/geom";
|
|
4
|
+
import { releaseImageSource as h } from "@weasel-js/core/renderer";
|
|
5
|
+
import { createLoupeModel as g, loupeInnerView as _, loupeInnerView as v } from "@weasel-js/loupe";
|
|
4
6
|
//#region src/loupe/readback.ts
|
|
5
|
-
function
|
|
6
|
-
let s = n.x + Math.round(r.x * i), c = n.y + Math.round(r.y * i), l =
|
|
7
|
+
function y(e, t, n, r, i, a, o) {
|
|
8
|
+
let s = n.x + Math.round(r.x * i), c = n.y + Math.round(r.y * i), l = m(s - Math.floor(a / 2), n.x, n.x + Math.max(0, n.width - a)), u = t - m(c - Math.floor(o / 2), n.y, n.y + Math.max(0, n.height - o)) - o, d = new Uint8Array(a * o * 4);
|
|
7
9
|
e.readPixels(l, u, a, o, e.RGBA, e.UNSIGNED_BYTE, d);
|
|
8
10
|
let f = new Uint8ClampedArray(a * o * 4), p = a * 4;
|
|
9
11
|
for (let e = 0; e < o; e++) {
|
|
@@ -12,24 +14,23 @@ function _(e, t, n, r, i, a, o) {
|
|
|
12
14
|
}
|
|
13
15
|
return new ImageData(f, a, o);
|
|
14
16
|
}
|
|
15
|
-
function v(e, t, n) {
|
|
16
|
-
return e < t ? t : e > n ? n : e;
|
|
17
|
-
}
|
|
18
17
|
//#endregion
|
|
19
18
|
//#region src/loupe/createLoupe.ts
|
|
20
|
-
var
|
|
19
|
+
var b = {
|
|
21
20
|
x: 0,
|
|
22
21
|
y: 0,
|
|
23
22
|
w: 0,
|
|
24
23
|
h: 0
|
|
25
24
|
};
|
|
26
|
-
function
|
|
27
|
-
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 = !1, l = null, u =
|
|
25
|
+
function x(e) {
|
|
26
|
+
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 = !1, l = null, u = () => {
|
|
27
|
+
l &&= (h(l), l.close(), null);
|
|
28
|
+
}, m = !1, _ = !1, x = !1, S = !1, C = e.bounds ?? {
|
|
28
29
|
x: 24,
|
|
29
30
|
y: 24,
|
|
30
31
|
w: 220,
|
|
31
32
|
h: 200
|
|
32
|
-
},
|
|
33
|
+
}, w = (e) => L.mode === "vector" ? O(e) : k(e), T = (t) => e.background ?? t.tokens["--wzl-surface"], E = (e) => ({
|
|
33
34
|
kind: "path",
|
|
34
35
|
path: {
|
|
35
36
|
kind: "rect",
|
|
@@ -40,23 +41,23 @@ function b(e) {
|
|
|
40
41
|
},
|
|
41
42
|
fill: {
|
|
42
43
|
fill: "solid",
|
|
43
|
-
color:
|
|
44
|
+
color: T(e)
|
|
44
45
|
}
|
|
45
|
-
}),
|
|
46
|
-
let n = f(
|
|
47
|
-
return
|
|
46
|
+
}), D = (e, t) => {
|
|
47
|
+
let n = f(L.aim.x, L.aim.y, p(e));
|
|
48
|
+
return v({
|
|
48
49
|
x: n[0],
|
|
49
50
|
y: n[1]
|
|
50
|
-
}, e, t,
|
|
51
|
-
},
|
|
52
|
-
id: `${
|
|
51
|
+
}, e, t, L.factor);
|
|
52
|
+
}, O = (t) => i ? s ? [E(t), ...s.draw(t.data, t.view, t.dims)] : [E(t)] : d({
|
|
53
|
+
id: `${P.id}:lens`,
|
|
53
54
|
label: "Loupe content",
|
|
54
55
|
source: e.source ?? [],
|
|
55
|
-
view:
|
|
56
|
+
view: D(t.view, t.rect),
|
|
56
57
|
bounds: () => t.rect,
|
|
57
|
-
background:
|
|
58
|
-
}).draw(t.data, t.view, t.dims),
|
|
59
|
-
let t = [
|
|
58
|
+
background: T(t)
|
|
59
|
+
}).draw(t.data, t.view, t.dims), k = (e) => {
|
|
60
|
+
let t = [E(e)];
|
|
60
61
|
return l && t.push({
|
|
61
62
|
kind: "image",
|
|
62
63
|
image: l,
|
|
@@ -66,10 +67,10 @@ function b(e) {
|
|
|
66
67
|
h: e.rect.h,
|
|
67
68
|
sampling: "nearest"
|
|
68
69
|
}), t;
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
},
|
|
72
|
-
if (!
|
|
70
|
+
}, A = () => {
|
|
71
|
+
x || L.mode !== "pixel" || (_ = !0);
|
|
72
|
+
}, j = (t, r, a) => {
|
|
73
|
+
if (!S) return null;
|
|
73
74
|
let o = n.getContext("webgl2");
|
|
74
75
|
if (!o) return null;
|
|
75
76
|
let s = n.getBoundingClientRect();
|
|
@@ -85,119 +86,119 @@ function b(e) {
|
|
|
85
86
|
width: n.width,
|
|
86
87
|
height: n.height
|
|
87
88
|
};
|
|
88
|
-
return
|
|
89
|
-
},
|
|
90
|
-
if (
|
|
91
|
-
let e =
|
|
92
|
-
t && (
|
|
93
|
-
if (
|
|
89
|
+
return y(o, n.height, u, t, c, r(c), a(c));
|
|
90
|
+
}, M = () => {
|
|
91
|
+
if (x || L.mode !== "pixel") return;
|
|
92
|
+
let e = P.contentRect, t = j(L.aim, (t) => Math.max(1, Math.round(e.w * t / L.factor)), (t) => Math.max(1, Math.round(e.h * t / L.factor)));
|
|
93
|
+
t && (m = !0, createImageBitmap(t).then((e) => {
|
|
94
|
+
if (x) {
|
|
94
95
|
e.close();
|
|
95
96
|
return;
|
|
96
97
|
}
|
|
97
|
-
|
|
98
|
+
u(), l = e, m = !1, r();
|
|
98
99
|
}).catch(() => {
|
|
99
|
-
|
|
100
|
+
m = !1, r();
|
|
100
101
|
}));
|
|
101
|
-
},
|
|
102
|
-
let t =
|
|
103
|
-
return t ? "#" + [
|
|
102
|
+
}, N = (e) => {
|
|
103
|
+
let t = j(e, () => 1, () => 1);
|
|
104
|
+
return !t || t.data[3] === 0 ? null : "#" + [
|
|
104
105
|
t.data[0],
|
|
105
106
|
t.data[1],
|
|
106
107
|
t.data[2]
|
|
107
|
-
].map((e) => e.toString(16).padStart(2, "0")).join("")
|
|
108
|
-
},
|
|
108
|
+
].map((e) => e.toString(16).padStart(2, "0")).join("");
|
|
109
|
+
}, P = t.window({
|
|
109
110
|
id: "weasel-loupe",
|
|
110
|
-
x:
|
|
111
|
-
y:
|
|
112
|
-
w:
|
|
113
|
-
h:
|
|
111
|
+
x: C.x,
|
|
112
|
+
y: C.y,
|
|
113
|
+
w: C.w,
|
|
114
|
+
h: C.h,
|
|
114
115
|
title: e.title ?? "Loupe",
|
|
115
116
|
titlebar: e.titlebar,
|
|
116
|
-
content:
|
|
117
|
+
content: w,
|
|
117
118
|
interior: a ? "pass" : "claim",
|
|
118
119
|
onResize: () => {
|
|
119
|
-
|
|
120
|
+
A();
|
|
120
121
|
},
|
|
121
122
|
...a ? {} : { onContentClick: (e) => {
|
|
122
|
-
|
|
123
|
+
L.pick(e);
|
|
123
124
|
} },
|
|
124
125
|
...e.onClose ? { onClose: e.onClose } : {}
|
|
125
|
-
}),
|
|
126
|
-
lens: () =>
|
|
127
|
-
covers: (e) =>
|
|
128
|
-
sample:
|
|
129
|
-
hidden: () =>
|
|
130
|
-
gone: () =>
|
|
126
|
+
}), F = {
|
|
127
|
+
lens: () => P.contentRect,
|
|
128
|
+
covers: (e) => P.hitTest(e.x, e.y) || (P.passes?.(e.x, e.y) ?? !1),
|
|
129
|
+
sample: N,
|
|
130
|
+
hidden: () => P.hidden,
|
|
131
|
+
gone: () => P.disposed === !0,
|
|
131
132
|
changed: () => {
|
|
132
|
-
|
|
133
|
+
A(), r();
|
|
133
134
|
},
|
|
134
135
|
subscribeFrame: t.subscribeFrame
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
}),
|
|
138
|
-
surface:
|
|
136
|
+
}, I = t.subscribeFrame(() => {
|
|
137
|
+
S = !0, _ && !m && (_ = !1, M());
|
|
138
|
+
}), L = g({
|
|
139
|
+
surface: F,
|
|
139
140
|
...e.mode ? { mode: e.mode } : {},
|
|
140
141
|
...e.factor === void 0 ? {} : { factor: e.factor },
|
|
141
142
|
...e.onColorChange ? { onColorChange: e.onColorChange } : {},
|
|
142
143
|
...e.onPick ? { onPick: e.onPick } : {},
|
|
143
|
-
onDispose: () =>
|
|
144
|
+
onDispose: () => U()
|
|
144
145
|
});
|
|
145
146
|
i && (s = i.addView({
|
|
146
|
-
id: `${
|
|
147
|
+
id: `${P.id}:lens`,
|
|
147
148
|
label: "Loupe",
|
|
148
|
-
bounds: () =>
|
|
149
|
-
view: (e) =>
|
|
149
|
+
bounds: () => P.hidden ? b : P.contentRect,
|
|
150
|
+
view: (e) => D(e, P.contentRect),
|
|
150
151
|
paint: !1,
|
|
151
152
|
interactive: a,
|
|
152
153
|
...e.source ? { layers: () => e.source } : {}
|
|
153
154
|
}));
|
|
154
|
-
let
|
|
155
|
+
let R = (e) => {
|
|
155
156
|
let t = o.getBoundingClientRect();
|
|
156
157
|
return {
|
|
157
158
|
x: e.clientX - t.left,
|
|
158
159
|
y: e.clientY - t.top
|
|
159
160
|
};
|
|
160
|
-
},
|
|
161
|
-
c ||
|
|
162
|
-
},
|
|
163
|
-
a &&
|
|
164
|
-
},
|
|
161
|
+
}, z = (e) => {
|
|
162
|
+
c || L.aimAt(R(e));
|
|
163
|
+
}, B = (e) => {
|
|
164
|
+
a && F.covers(R(e)) && (c = !0);
|
|
165
|
+
}, V = () => {
|
|
165
166
|
c = !1;
|
|
166
|
-
},
|
|
167
|
+
}, H = [
|
|
167
168
|
"pointerup",
|
|
168
169
|
"pointercancel",
|
|
169
170
|
"lostpointercapture"
|
|
170
|
-
],
|
|
171
|
-
|
|
172
|
-
for (let e of
|
|
173
|
-
s?.remove(), s = null,
|
|
171
|
+
], U = () => {
|
|
172
|
+
x = !0, I(), o.removeEventListener("pointermove", z), o.removeEventListener("pointerdown", B);
|
|
173
|
+
for (let e of H) o.removeEventListener(e, V);
|
|
174
|
+
s?.remove(), s = null, u();
|
|
174
175
|
};
|
|
175
|
-
o.addEventListener("pointermove",
|
|
176
|
-
for (let e of
|
|
176
|
+
o.addEventListener("pointermove", z), o.addEventListener("pointerdown", B);
|
|
177
|
+
for (let e of H) o.addEventListener(e, V);
|
|
177
178
|
return {
|
|
178
|
-
window:
|
|
179
|
+
window: P,
|
|
179
180
|
get mode() {
|
|
180
|
-
return
|
|
181
|
+
return L.mode;
|
|
181
182
|
},
|
|
182
183
|
get factor() {
|
|
183
|
-
return
|
|
184
|
+
return L.factor;
|
|
184
185
|
},
|
|
185
186
|
get aim() {
|
|
186
|
-
return
|
|
187
|
+
return L.aim;
|
|
187
188
|
},
|
|
188
189
|
get color() {
|
|
189
|
-
return
|
|
190
|
+
return L.color;
|
|
190
191
|
},
|
|
191
|
-
setMode:
|
|
192
|
-
setFactor:
|
|
193
|
-
aimAt:
|
|
194
|
-
pick:
|
|
192
|
+
setMode: L.setMode,
|
|
193
|
+
setFactor: L.setFactor,
|
|
194
|
+
aimAt: L.aimAt,
|
|
195
|
+
pick: L.pick,
|
|
195
196
|
dispose() {
|
|
196
|
-
|
|
197
|
+
L.dispose(), P.dispose();
|
|
197
198
|
}
|
|
198
199
|
};
|
|
199
200
|
}
|
|
200
201
|
//#endregion
|
|
201
|
-
export { r as DEFAULT_FONT_FAMILY, i as DEFAULT_WIDGET_CLAIMS, c as DEFAULT_WINDOW_METRICS, l as HUD_AFFORDANCE_KIND, s as attachHud, u as claimsOf, o as createHud, a as createHudContribution,
|
|
202
|
+
export { r as DEFAULT_FONT_FAMILY, i as DEFAULT_WIDGET_CLAIMS, c as DEFAULT_WINDOW_METRICS, l as HUD_AFFORDANCE_KIND, s as attachHud, u as claimsOf, o as createHud, a as createHudContribution, x as createLoupe, t as cursorForZone, n as isFocusable, _ as loupeInnerView, e as registerDefaultFont };
|
|
202
203
|
|
|
203
204
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["loupeInnerView","registerDefaultFont","cursorForZone","isFocusable","DEFAULT_FONT_FAMILY","DEFAULT_WIDGET_CLAIMS","createHudContribution","attachHud","DEFAULT_WINDOW_METRICS","HUD_AFFORDANCE_KIND","loupeInnerView$1","readbackRegion","cx","target","pointer","dpr","cy","gx","clamp","rw","gy","bufferHeight","rh","raw","gl","flipped","stride","row","src","v","lo","hi","NO_RECT","createLoupe","element","opts","host","interactive","input","lens","holding","pixels","pixelsPending","refreshWanted","disposed","landed","b","content","model","drawVector","ctx","drawPixels","backdropColor","backdrop","innerView","world","screenToWorld","viewToTransform","outer","rect","createViewportLayer","win","out","scheduleRefresh","read","cssRect","r","at","refreshPixels","data","bmp","requestRedraw","readHex","px","c","hud","p","surface","unsubscribeFrame","createLoupeModel","teardown","local","evt","onPointerMove","onPointerDown","onPointerEnd","pointerEnds","type","claimsOf","createHud","loupeInnerView"],"sources":["../src/loupe/readback.ts","../src/loupe/createLoupe.ts"],"sourcesContent":["/**\n * Read a `rw × rh` device-pixel region of the drawing buffer centered on\n * `pointer`, returned top-down. `pointer` is in CSS px relative to `target`,\n * the rect of the buffer the canvas paints into (device px, top-left origin),\n * and the read is clamped to stay inside that rect.\n *\n * GL reports rows bottom-up; every consumer here wants top-down, so both the\n * read origin and the returned rows are flipped.\n */\nexport function readbackRegion(\n gl: WebGL2RenderingContext,\n bufferHeight: number,\n target: { x: number; y: number; width: number; height: number },\n pointer: { x: number; y: number },\n dpr: number,\n rw: number,\n rh: number,\n): ImageData {\n const cx = target.x + Math.round(pointer.x * dpr);\n const cy = target.y + Math.round(pointer.y * dpr);\n const gx = clamp(cx - Math.floor(rw / 2), target.x, target.x + Math.max(0, target.width - rw));\n const gyTop = clamp(cy - Math.floor(rh / 2), target.y, target.y + Math.max(0, target.height - rh));\n const gy = bufferHeight - gyTop - rh;\n\n const raw = new Uint8Array(rw * rh * 4);\n gl.readPixels(gx, gy, rw, rh, gl.RGBA, gl.UNSIGNED_BYTE, raw);\n\n const flipped = new Uint8ClampedArray(rw * rh * 4);\n const stride = rw * 4;\n for (let row = 0; row < rh; row++) {\n const src = (rh - 1 - row) * stride;\n flipped.set(raw.subarray(src, src + stride), row * stride);\n }\n return new ImageData(flipped, rw, rh);\n}\n\nfunction clamp(v: number, lo: number, hi: number): number {\n return v < lo ? lo : v > hi ? hi : v;\n}\n","import {\n createViewportLayer, screenToWorld, viewToTransform,\n type CanvasViewHandle, type RenderLayer, type SceneCanvasApi, type View,\n} from '@weasel-js/core';\nimport type { DrawCommand } from '@weasel-js/core/renderer';\nimport {\n createLoupeModel, loupeInnerView,\n type LoupeMode, type LoupeModel, type LoupeSurface,\n} from '@weasel-js/loupe';\nimport type { Hud } from '../hud';\nimport type { WindowWidget } from '../widgets/window/window';\nimport type { HudContentCtx, WidgetBounds } from '../widget';\nimport { readbackRegion } from './readback';\n\nexport type { LoupeMode };\n\n/** Options for `createLoupe` shared by a plain lens and an interactive one. */\nexport interface LoupeBaseOptions {\n hud: Hud;\n /** The canvas pixel mode reads back from. Supplies the GL context and the\n * drawing-buffer dimensions. */\n canvas: HTMLCanvasElement;\n /** Where the aim comes from: the element pointer events are taken from and\n * the rect client coords are measured against. Defaults to `canvas`, which\n * is right whenever the canvas is also the thing under the pointer. */\n input?: HTMLElement;\n /** The rect of `canvas` the magnified picture occupies, in its CSS px — the\n * one the aim is relative to. Pass `CanvasExtensionApi.getSurfaceRect` for\n * a pane painted into a shared canvas. Defaults to `views.getSurfaceRect`\n * when the lens is a view, and to the whole canvas otherwise. */\n region?: () => { x: number; y: number; width: number; height: number };\n requestRedraw: () => void;\n mode?: LoupeMode;\n factor?: number;\n bounds?: WidgetBounds;\n title?: string;\n /** Draw the window's titlebar and close box. Default `true`. Pass `false`\n * for a bare lens; the interior then doubles as the move handle, or, for an\n * `interactive` lens, a grip strip across its top does. */\n titlebar?: boolean;\n /** Called with the hex color under the aim point whenever it changes.\n * Sampled from the framebuffer in both modes — vector content is a\n * re-render whose edge colors differ from the screen's, so reading the\n * color off it would report something the user cannot see. */\n onColorChange?: (hex: string) => void;\n /** Fired when a click inside the lens picks a color — an eyedropper on the\n * magnified surface. Where the color goes is the consumer's: the loupe\n * reports the pick and nothing else. An `interactive` lens gives its clicks\n * to the canvas, so only `pick()` reaches this. */\n onPick?: (hex: string) => void;\n /** Fired by the window's close box. The window does not hide itself —\n * whoever owns the loupe's visibility decides what closing means. */\n onClose?: () => void;\n /** Backdrop painted behind the magnified content in both modes, so the\n * outer canvas does not show through where the lens is empty. Defaults to\n * the theme's surface color. */\n background?: string;\n}\n\n/** Options for `createLoupe`. */\nexport type LoupeOptions = LoupeBaseOptions & (\n | {\n /** Layers re-rendered through the magnified inner view in vector mode. */\n source: RenderLayer<unknown>[];\n views?: undefined;\n interactive?: false;\n }\n | {\n /**\n * The canvas, as a host for views. The lens becomes a view on it: vector\n * mode paints the canvas's own stack — scene and selection chrome — and\n * the lens can take input. It magnifies the canvas's own camera; aimed\n * over another view, it shows the canvas's world, not that view's.\n */\n views: Pick<SceneCanvasApi, 'addView' | 'getSurfaceRect'>;\n /** Narrows what vector mode paints. Defaults to the canvas's stack. */\n source?: RenderLayer<unknown>[];\n /**\n * Route input inside the lens to what it shows: a press selects the node\n * magnified under the pointer, and a drag moves it by the pointer travel\n * divided by the magnification. Default `false` — the window keeps its\n * interior, and a click there picks a color.\n */\n interactive?: boolean;\n }\n);\n\n/** Where an interactive lens routes while its window is hidden: nowhere. */\nconst NO_RECT = { x: 0, y: 0, w: 0, h: 0 };\n\n/** Control surface for a live loupe: where it is aimed, how it magnifies,\n * what color it is over, and the window it lives in. */\nexport interface LoupeHandle {\n readonly window: WindowWidget;\n readonly mode: LoupeMode;\n readonly factor: number;\n /** Last aimed point, in screen-space CSS px relative to the canvas. */\n readonly aim: { x: number; y: number };\n /** Hex color under the aim point, read off the framebuffer on the first\n * frame to land after the aim. `null` until then, or when the GL context\n * is unavailable. */\n readonly color: string | null;\n setMode(mode: LoupeMode): void;\n setFactor(factor: number): void;\n /** Aim at a screen point. Ignored while the point is over the window —\n * that is the freeze rule that makes the borders reachable. */\n aimAt(p: { x: number; y: number }): void;\n /** Sample the color the lens is showing at `p` — a screen point inside the\n * lens — and report it to `onPick`. Omit `p` to pick at the aim point.\n * Returns the hex, or `null` when the framebuffer cannot answer for that\n * point, including before any frame has landed. Leaves the aim, and\n * `color`, alone. */\n pick(p?: { x: number; y: number }): string | null;\n dispose(): void;\n}\n\n/**\n * Build a magnifier: a HUD window whose interior shows the canvas around an\n * aim point, enlarged. Adds the window to the HUD and starts following the\n * pointer; `dispose` removes it again.\n */\nexport function createLoupe(opts: LoupeOptions): LoupeHandle {\n const { hud, canvas: element, requestRedraw } = opts;\n const host = opts.views;\n const interactive = host !== undefined && opts.interactive === true;\n const input = opts.input ?? element;\n let lens: CanvasViewHandle | null = null;\n // Set while a gesture that began over the window is held: the lens camera\n // follows the aim, so re-aiming mid-drag would move the world under it.\n let holding = false;\n let pixels: ImageBitmap | null = null;\n let pixelsPending = false;\n let refreshWanted = false;\n let disposed = false;\n // Until a paint lands, the context on a shared canvas may not exist yet, and\n // opening it here would give every tenant one with no stencil buffer.\n let landed = false;\n\n const b = opts.bounds ?? { x: 24, y: 24, w: 220, h: 200 };\n\n const content = (ctx: HudContentCtx): DrawCommand[] =>\n model.mode === 'vector' ? drawVector(ctx) : drawPixels(ctx);\n\n const backdropColor = (ctx: HudContentCtx): string =>\n opts.background ?? ctx.tokens['--wzl-surface'];\n\n const backdrop = (ctx: HudContentCtx): DrawCommand => ({\n kind: 'path',\n path: { kind: 'rect', x: ctx.rect.x, y: ctx.rect.y, width: ctx.rect.w, height: ctx.rect.h },\n fill: { fill: 'solid', color: backdropColor(ctx) },\n });\n\n const innerView = (outer: View, rect: WidgetBounds): View => {\n const world = screenToWorld(model.aim.x, model.aim.y, viewToTransform(outer));\n return loupeInnerView({ x: world[0], y: world[1] }, outer, rect, model.factor);\n };\n\n const drawVector = (ctx: HudContentCtx): DrawCommand[] => {\n if (host) return lens ? [backdrop(ctx), ...lens.draw(ctx.data, ctx.view, ctx.dims)] : [backdrop(ctx)];\n // A fresh lens per frame: CreateViewportLayerOpts.view is static, and the\n // inner view moves with the pointer.\n const picture = createViewportLayer<unknown>({\n id: `${win.id}:lens`,\n label: 'Loupe content',\n source: opts.source ?? [],\n view: innerView(ctx.view, ctx.rect),\n bounds: () => ctx.rect,\n background: backdropColor(ctx),\n });\n return picture.draw(ctx.data, ctx.view, ctx.dims);\n };\n\n const drawPixels = (ctx: HudContentCtx): DrawCommand[] => {\n // The backdrop paints even with a bitmap in hand: a readback of a\n // transparent framebuffer is transparent, and before the first one\n // settles there is nothing at all, either of which leaves the lens a\n // hole onto the unmagnified canvas.\n const out: DrawCommand[] = [backdrop(ctx)];\n if (pixels) {\n out.push({\n kind: 'image',\n image: pixels,\n x: ctx.rect.x, y: ctx.rect.y, w: ctx.rect.w, h: ctx.rect.h,\n sampling: 'nearest',\n });\n }\n return out;\n };\n\n // `gl.readPixels` outside a landed paint returns the *previous* frame, so an\n // aim only marks the lens dirty; the read itself happens in the frame\n // subscriber below, on the frame that painted.\n const scheduleRefresh = () => {\n if (disposed || model.mode !== 'pixel') return;\n refreshWanted = true;\n };\n\n /** Read device px of the loupe's region around `at`, sized for the\n * canvas's pixel ratio, or `null` when the framebuffer cannot answer. */\n const read = (\n at: { x: number; y: number },\n rw: (dpr: number) => number,\n rh: (dpr: number) => number,\n ): ImageData | null => {\n if (!landed) return null;\n const gl = element.getContext('webgl2');\n if (!gl) return null;\n const cssRect = element.getBoundingClientRect();\n if (cssRect.width === 0) return null;\n const dpr = element.width / cssRect.width;\n // A view-backed lens knows its canvas, so over a detached pane it reads\n // that pane's pixels without being told where the pane is.\n const r = (opts.region ?? host?.getSurfaceRect)?.();\n const target = r\n ? {\n x: Math.round(r.x * dpr), y: Math.round(r.y * dpr),\n width: Math.round(r.width * dpr), height: Math.round(r.height * dpr),\n }\n : { x: 0, y: 0, width: element.width, height: element.height };\n return readbackRegion(gl, element.height, target, at, dpr, rw(dpr), rh(dpr));\n };\n\n const refreshPixels = () => {\n if (disposed || model.mode !== 'pixel') return;\n const rect = win.contentRect;\n const data = read(\n model.aim,\n (dpr) => Math.max(1, Math.round((rect.w * dpr) / model.factor)),\n (dpr) => Math.max(1, Math.round((rect.h * dpr) / model.factor)),\n );\n if (!data) return;\n pixelsPending = true;\n createImageBitmap(data)\n .then((bmp) => {\n if (disposed) { bmp.close(); return; }\n pixels?.close();\n pixels = bmp;\n pixelsPending = false;\n requestRedraw();\n })\n .catch(() => {\n pixelsPending = false;\n requestRedraw();\n });\n };\n\n const readHex = (at: { x: number; y: number }): string | null => {\n const px = read(at, () => 1, () => 1);\n if (!px) return null;\n return '#' + [px.data[0], px.data[1], px.data[2]]\n .map((c) => c.toString(16).padStart(2, '0')).join('');\n };\n\n const win = hud.window({\n id: 'weasel-loupe',\n x: b.x, y: b.y, w: b.w, h: b.h,\n title: opts.title ?? 'Loupe',\n titlebar: opts.titlebar,\n content,\n interior: interactive ? 'pass' : 'claim',\n onResize: () => { scheduleRefresh(); },\n ...(interactive ? {} : { onContentClick: (p: { x: number; y: number }) => { model.pick(p); } }),\n ...(opts.onClose ? { onClose: opts.onClose } : {}),\n });\n\n const surface: LoupeSurface = {\n lens: () => win.contentRect,\n covers: (p) => win.hitTest(p.x, p.y) || (win.passes?.(p.x, p.y) ?? false),\n sample: readHex,\n hidden: () => win.hidden,\n gone: () => win.disposed === true,\n changed: () => { scheduleRefresh(); requestRedraw(); },\n subscribeFrame: hud.subscribeFrame,\n };\n\n // Subscribed ahead of the model, so the frame that lands first is already\n // readable by the time the model samples on it.\n const unsubscribeFrame = hud.subscribeFrame(() => {\n landed = true;\n // A refresh wanted while a bitmap is in flight is remembered rather than\n // dropped: the flag survives until a frame finds it settled, so the aim\n // the user ends a fast drag on is the one that gets read.\n if (!refreshWanted || pixelsPending) return;\n refreshWanted = false;\n refreshPixels();\n });\n\n const model: LoupeModel = createLoupeModel({\n surface,\n ...(opts.mode ? { mode: opts.mode } : {}),\n ...(opts.factor !== undefined ? { factor: opts.factor } : {}),\n ...(opts.onColorChange ? { onColorChange: opts.onColorChange } : {}),\n ...(opts.onPick ? { onPick: opts.onPick } : {}),\n onDispose: () => teardown(),\n });\n\n if (host) {\n lens = host.addView({\n id: `${win.id}:lens`,\n label: 'Loupe',\n bounds: () => (win.hidden ? NO_RECT : win.contentRect),\n view: (outer) => innerView(outer, win.contentRect),\n paint: false,\n interactive,\n ...(opts.source ? { layers: () => opts.source! } : {}),\n });\n }\n\n const local = (evt: PointerEvent): { x: number; y: number } => {\n const r = input.getBoundingClientRect();\n return { x: evt.clientX - r.left, y: evt.clientY - r.top };\n };\n\n const onPointerMove = (evt: PointerEvent) => {\n if (holding) return;\n model.aimAt(local(evt));\n };\n const onPointerDown = (evt: PointerEvent) => {\n if (interactive && surface.covers(local(evt))) holding = true;\n };\n const onPointerEnd = () => { holding = false; };\n const pointerEnds = ['pointerup', 'pointercancel', 'lostpointercapture'] as const;\n\n const teardown = () => {\n disposed = true;\n unsubscribeFrame();\n input.removeEventListener('pointermove', onPointerMove);\n input.removeEventListener('pointerdown', onPointerDown);\n for (const type of pointerEnds) input.removeEventListener(type, onPointerEnd);\n lens?.remove();\n lens = null;\n pixels?.close();\n pixels = null;\n };\n\n input.addEventListener('pointermove', onPointerMove);\n input.addEventListener('pointerdown', onPointerDown);\n for (const type of pointerEnds) input.addEventListener(type, onPointerEnd);\n\n return {\n window: win,\n get mode() { return model.mode; },\n get factor() { return model.factor; },\n get aim() { return model.aim; },\n get color() { return model.color; },\n setMode: model.setMode,\n setFactor: model.setFactor,\n aimAt: model.aimAt,\n pick: model.pick,\n dispose() {\n model.dispose();\n win.dispose();\n },\n };\n}\n"],"mappings":";;;;AASA,SAAgBW,EACd,GACA,GACA,GACA,GACA,GACA,GACA,GACW;CACX,IAAMC,IAAKC,EAAO,IAAI,KAAK,MAAMC,EAAQ,IAAIC,CAAG,GAC1CC,IAAKH,EAAO,IAAI,KAAK,MAAMC,EAAQ,IAAIC,CAAG,GAC1CE,IAAKC,EAAMN,IAAK,KAAK,MAAMO,IAAK,CAAC,GAAGN,EAAO,GAAGA,EAAO,IAAI,KAAK,IAAI,GAAGA,EAAO,QAAQM,CAAE,CAAC,GAEvFC,IAAKC,IADGH,EAAMF,IAAK,KAAK,MAAMM,IAAK,CAAC,GAAGT,EAAO,GAAGA,EAAO,IAAI,KAAK,IAAI,GAAGA,EAAO,SAASS,CAAE,CACtE,IAAQA,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AAI,QAAQ;GAAE,OAAOA,EAAM;EAAO;EAClC,SAASA,EAAM;EACf,WAAWA,EAAM;EACjB,OAAOA,EAAM;EACb,MAAMA,EAAM;EACZ,UAAU;GAER,AADAA,EAAM,QAAQ,GACda,EAAI,QAAQ;EACd;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["loupeInnerView","registerDefaultFont","cursorForZone","isFocusable","DEFAULT_FONT_FAMILY","DEFAULT_WIDGET_CLAIMS","createHudContribution","attachHud","DEFAULT_WINDOW_METRICS","HUD_AFFORDANCE_KIND","loupeInnerView$1","readbackRegion","cx","target","pointer","dpr","cy","gx","clamp","rw","gy","bufferHeight","rh","raw","gl","flipped","stride","row","src","NO_RECT","createLoupe","element","opts","host","interactive","input","lens","holding","pixels","dropPixels","releaseImageSource","pixelsPending","refreshWanted","disposed","landed","b","content","model","drawVector","ctx","drawPixels","backdropColor","backdrop","innerView","world","screenToWorld","viewToTransform","outer","rect","createViewportLayer","win","out","scheduleRefresh","read","cssRect","r","at","refreshPixels","data","bmp","requestRedraw","readHex","px","c","hud","p","surface","unsubscribeFrame","createLoupeModel","teardown","local","evt","onPointerMove","onPointerDown","onPointerEnd","pointerEnds","type","claimsOf","createHud","loupeInnerView"],"sources":["../src/loupe/readback.ts","../src/loupe/createLoupe.ts"],"sourcesContent":["import { clamp } from '@weasel-js/geom';\n\n/**\n * Read a `rw × rh` device-pixel region of the drawing buffer centered on\n * `pointer`, returned top-down. `pointer` is in CSS px relative to `target`,\n * the rect of the buffer the canvas paints into (device px, top-left origin),\n * and the read is clamped to stay inside that rect.\n *\n * GL reports rows bottom-up; every consumer here wants top-down, so both the\n * read origin and the returned rows are flipped.\n */\nexport function readbackRegion(\n gl: WebGL2RenderingContext,\n bufferHeight: number,\n target: { x: number; y: number; width: number; height: number },\n pointer: { x: number; y: number },\n dpr: number,\n rw: number,\n rh: number,\n): ImageData {\n const cx = target.x + Math.round(pointer.x * dpr);\n const cy = target.y + Math.round(pointer.y * dpr);\n const gx = clamp(cx - Math.floor(rw / 2), target.x, target.x + Math.max(0, target.width - rw));\n const gyTop = clamp(cy - Math.floor(rh / 2), target.y, target.y + Math.max(0, target.height - rh));\n const gy = bufferHeight - gyTop - rh;\n\n const raw = new Uint8Array(rw * rh * 4);\n gl.readPixels(gx, gy, rw, rh, gl.RGBA, gl.UNSIGNED_BYTE, raw);\n\n const flipped = new Uint8ClampedArray(rw * rh * 4);\n const stride = rw * 4;\n for (let row = 0; row < rh; row++) {\n const src = (rh - 1 - row) * stride;\n flipped.set(raw.subarray(src, src + stride), row * stride);\n }\n return new ImageData(flipped, rw, rh);\n}\n","import {\n createViewportLayer, screenToWorld, viewToTransform,\n type CanvasViewHandle, type RenderLayer, type SceneCanvasApi, type View,\n} from '@weasel-js/core';\nimport { releaseImageSource, type DrawCommand } from '@weasel-js/core/renderer';\nimport {\n createLoupeModel, loupeInnerView,\n type LoupeMode, type LoupeModel, type LoupeSurface,\n} from '@weasel-js/loupe';\nimport type { Hud } from '../hud';\nimport type { WindowWidget } from '../widgets/window/window';\nimport type { HudContentCtx, WidgetBounds } from '../widget';\nimport { readbackRegion } from './readback';\n\nexport type { LoupeMode };\n\n/** Options for `createLoupe` shared by a plain lens and an interactive one. */\nexport interface LoupeBaseOptions {\n hud: Hud;\n /** The canvas pixel mode reads back from. Supplies the GL context and the\n * drawing-buffer dimensions. */\n canvas: HTMLCanvasElement;\n /** Where the aim comes from: the element pointer events are taken from and\n * the rect client coords are measured against. Defaults to `canvas`, which\n * is right whenever the canvas is also the thing under the pointer. */\n input?: HTMLElement;\n /** The rect of `canvas` the magnified picture occupies, in its CSS px — the\n * one the aim is relative to. Pass `CanvasExtensionApi.getSurfaceRect` for\n * a pane painted into a shared canvas. Defaults to `views.getSurfaceRect`\n * when the lens is a view, and to the whole canvas otherwise. */\n region?: () => { x: number; y: number; width: number; height: number };\n requestRedraw: () => void;\n mode?: LoupeMode;\n factor?: number;\n bounds?: WidgetBounds;\n title?: string;\n /** Draw the window's titlebar and close box. Default `true`. Pass `false`\n * for a bare lens; the interior then doubles as the move handle, or, for an\n * `interactive` lens, a grip strip across its top does. */\n titlebar?: boolean;\n /** Called with the hex color under the aim point whenever it changes.\n * Sampled from the framebuffer in both modes — vector content is a\n * re-render whose edge colors differ from the screen's, so reading the\n * color off it would report something the user cannot see. */\n onColorChange?: (hex: string) => void;\n /** Fired when a click inside the lens picks a color — an eyedropper on the\n * magnified surface. Where the color goes is the consumer's: the loupe\n * reports the pick and nothing else. An `interactive` lens gives its clicks\n * to the canvas, so only `pick()` reaches this. */\n onPick?: (hex: string) => void;\n /** Fired by the window's close box. The window does not hide itself —\n * whoever owns the loupe's visibility decides what closing means. */\n onClose?: () => void;\n /** Backdrop painted behind the magnified content in both modes, so the\n * outer canvas does not show through where the lens is empty. Defaults to\n * the theme's surface color. */\n background?: string;\n}\n\n/** Options for `createLoupe`. */\nexport type LoupeOptions = LoupeBaseOptions & (\n | {\n /** Layers re-rendered through the magnified inner view in vector mode. */\n source: RenderLayer<unknown>[];\n views?: undefined;\n interactive?: false;\n }\n | {\n /**\n * The canvas, as a host for views. The lens becomes a view on it: vector\n * mode paints the canvas's own stack — scene and selection chrome — and\n * the lens can take input. It magnifies the canvas's own camera; aimed\n * over another view, it shows the canvas's world, not that view's.\n */\n views: Pick<SceneCanvasApi, 'addView' | 'getSurfaceRect'>;\n /** Narrows what vector mode paints. Defaults to the canvas's stack. */\n source?: RenderLayer<unknown>[];\n /**\n * Route input inside the lens to what it shows: a press selects the node\n * magnified under the pointer, and a drag moves it by the pointer travel\n * divided by the magnification. Default `false` — the window keeps its\n * interior, and a click there picks a color.\n */\n interactive?: boolean;\n }\n);\n\n/** Where an interactive lens routes while its window is hidden: nowhere. */\nconst NO_RECT = { x: 0, y: 0, w: 0, h: 0 };\n\n/** Control surface for a live loupe: where it is aimed, how it magnifies,\n * what color it is over, and the window it lives in. */\nexport interface LoupeHandle {\n readonly window: WindowWidget;\n readonly mode: LoupeMode;\n readonly factor: number;\n /** Last aimed point, in screen-space CSS px relative to the canvas. */\n readonly aim: { x: number; y: number };\n /** Hex color under the aim point, read off the framebuffer on the first\n * frame to land after the aim. `null` until then, or when the GL context\n * is unavailable. */\n readonly color: string | null;\n setMode(mode: LoupeMode): void;\n setFactor(factor: number): void;\n /** Aim at a screen point. Ignored while the point is over the window —\n * that is the freeze rule that makes the borders reachable. */\n aimAt(p: { x: number; y: number }): void;\n /** Sample the color the lens is showing at `p` — a screen point inside the\n * lens — and report it to `onPick`. Omit `p` to pick at the aim point.\n * Returns the hex, or `null` when the framebuffer cannot answer for that\n * point, including before any frame has landed. Leaves the aim, and\n * `color`, alone. */\n pick(p?: { x: number; y: number }): string | null;\n dispose(): void;\n}\n\n/**\n * Build a magnifier: a HUD window whose interior shows the canvas around an\n * aim point, enlarged. Adds the window to the HUD and starts following the\n * pointer; `dispose` removes it again.\n */\nexport function createLoupe(opts: LoupeOptions): LoupeHandle {\n const { hud, canvas: element, requestRedraw } = opts;\n const host = opts.views;\n const interactive = host !== undefined && opts.interactive === true;\n const input = opts.input ?? element;\n let lens: CanvasViewHandle | null = null;\n // Set while a gesture that began over the window is held: the lens camera\n // follows the aim, so re-aiming mid-drag would move the world under it.\n let holding = false;\n let pixels: ImageBitmap | null = null;\n const dropPixels = () => {\n if (!pixels) return;\n releaseImageSource(pixels);\n pixels.close();\n pixels = null;\n };\n let pixelsPending = false;\n let refreshWanted = false;\n let disposed = false;\n // Until a paint lands, the context on a shared canvas may not exist yet, and\n // opening it here would give every tenant one with no stencil buffer.\n let landed = false;\n\n const b = opts.bounds ?? { x: 24, y: 24, w: 220, h: 200 };\n\n const content = (ctx: HudContentCtx): DrawCommand[] =>\n model.mode === 'vector' ? drawVector(ctx) : drawPixels(ctx);\n\n const backdropColor = (ctx: HudContentCtx): string =>\n opts.background ?? ctx.tokens['--wzl-surface'];\n\n const backdrop = (ctx: HudContentCtx): DrawCommand => ({\n kind: 'path',\n path: { kind: 'rect', x: ctx.rect.x, y: ctx.rect.y, width: ctx.rect.w, height: ctx.rect.h },\n fill: { fill: 'solid', color: backdropColor(ctx) },\n });\n\n const innerView = (outer: View, rect: WidgetBounds): View => {\n const world = screenToWorld(model.aim.x, model.aim.y, viewToTransform(outer));\n return loupeInnerView({ x: world[0], y: world[1] }, outer, rect, model.factor);\n };\n\n const drawVector = (ctx: HudContentCtx): DrawCommand[] => {\n if (host) return lens ? [backdrop(ctx), ...lens.draw(ctx.data, ctx.view, ctx.dims)] : [backdrop(ctx)];\n // A fresh lens per frame: CreateViewportLayerOpts.view is static, and the\n // inner view moves with the pointer.\n const picture = createViewportLayer<unknown>({\n id: `${win.id}:lens`,\n label: 'Loupe content',\n source: opts.source ?? [],\n view: innerView(ctx.view, ctx.rect),\n bounds: () => ctx.rect,\n background: backdropColor(ctx),\n });\n return picture.draw(ctx.data, ctx.view, ctx.dims);\n };\n\n const drawPixels = (ctx: HudContentCtx): DrawCommand[] => {\n // The backdrop paints even with a bitmap in hand: a readback of a\n // transparent framebuffer is transparent, and before the first one\n // settles there is nothing at all, either of which leaves the lens a\n // hole onto the unmagnified canvas.\n const out: DrawCommand[] = [backdrop(ctx)];\n if (pixels) {\n out.push({\n kind: 'image',\n image: pixels,\n x: ctx.rect.x, y: ctx.rect.y, w: ctx.rect.w, h: ctx.rect.h,\n sampling: 'nearest',\n });\n }\n return out;\n };\n\n // `gl.readPixels` outside a landed paint returns the *previous* frame, so an\n // aim only marks the lens dirty; the read itself happens in the frame\n // subscriber below, on the frame that painted.\n const scheduleRefresh = () => {\n if (disposed || model.mode !== 'pixel') return;\n refreshWanted = true;\n };\n\n /** Read device px of the loupe's region around `at`, sized for the\n * canvas's pixel ratio, or `null` when the framebuffer cannot answer. */\n const read = (\n at: { x: number; y: number },\n rw: (dpr: number) => number,\n rh: (dpr: number) => number,\n ): ImageData | null => {\n if (!landed) return null;\n const gl = element.getContext('webgl2');\n if (!gl) return null;\n const cssRect = element.getBoundingClientRect();\n if (cssRect.width === 0) return null;\n const dpr = element.width / cssRect.width;\n // A view-backed lens knows its canvas, so over a detached pane it reads\n // that pane's pixels without being told where the pane is.\n const r = (opts.region ?? host?.getSurfaceRect)?.();\n const target = r\n ? {\n x: Math.round(r.x * dpr), y: Math.round(r.y * dpr),\n width: Math.round(r.width * dpr), height: Math.round(r.height * dpr),\n }\n : { x: 0, y: 0, width: element.width, height: element.height };\n return readbackRegion(gl, element.height, target, at, dpr, rw(dpr), rh(dpr));\n };\n\n const refreshPixels = () => {\n if (disposed || model.mode !== 'pixel') return;\n const rect = win.contentRect;\n const data = read(\n model.aim,\n (dpr) => Math.max(1, Math.round((rect.w * dpr) / model.factor)),\n (dpr) => Math.max(1, Math.round((rect.h * dpr) / model.factor)),\n );\n if (!data) return;\n pixelsPending = true;\n createImageBitmap(data)\n .then((bmp) => {\n if (disposed) { bmp.close(); return; }\n dropPixels();\n pixels = bmp;\n pixelsPending = false;\n requestRedraw();\n })\n .catch(() => {\n pixelsPending = false;\n requestRedraw();\n });\n };\n\n const readHex = (at: { x: number; y: number }): string | null => {\n const px = read(at, () => 1, () => 1);\n if (!px || px.data[3] === 0) return null;\n return '#' + [px.data[0], px.data[1], px.data[2]]\n .map((c) => c.toString(16).padStart(2, '0')).join('');\n };\n\n const win = hud.window({\n id: 'weasel-loupe',\n x: b.x, y: b.y, w: b.w, h: b.h,\n title: opts.title ?? 'Loupe',\n titlebar: opts.titlebar,\n content,\n interior: interactive ? 'pass' : 'claim',\n onResize: () => { scheduleRefresh(); },\n ...(interactive ? {} : { onContentClick: (p: { x: number; y: number }) => { model.pick(p); } }),\n ...(opts.onClose ? { onClose: opts.onClose } : {}),\n });\n\n const surface: LoupeSurface = {\n lens: () => win.contentRect,\n covers: (p) => win.hitTest(p.x, p.y) || (win.passes?.(p.x, p.y) ?? false),\n sample: readHex,\n hidden: () => win.hidden,\n gone: () => win.disposed === true,\n changed: () => { scheduleRefresh(); requestRedraw(); },\n subscribeFrame: hud.subscribeFrame,\n };\n\n // Subscribed ahead of the model, so the frame that lands first is already\n // readable by the time the model samples on it.\n const unsubscribeFrame = hud.subscribeFrame(() => {\n landed = true;\n // A refresh wanted while a bitmap is in flight is remembered rather than\n // dropped: the flag survives until a frame finds it settled, so the aim\n // the user ends a fast drag on is the one that gets read.\n if (!refreshWanted || pixelsPending) return;\n refreshWanted = false;\n refreshPixels();\n });\n\n const model: LoupeModel = createLoupeModel({\n surface,\n ...(opts.mode ? { mode: opts.mode } : {}),\n ...(opts.factor !== undefined ? { factor: opts.factor } : {}),\n ...(opts.onColorChange ? { onColorChange: opts.onColorChange } : {}),\n ...(opts.onPick ? { onPick: opts.onPick } : {}),\n onDispose: () => teardown(),\n });\n\n if (host) {\n lens = host.addView({\n id: `${win.id}:lens`,\n label: 'Loupe',\n bounds: () => (win.hidden ? NO_RECT : win.contentRect),\n view: (outer) => innerView(outer, win.contentRect),\n paint: false,\n interactive,\n ...(opts.source ? { layers: () => opts.source! } : {}),\n });\n }\n\n const local = (evt: PointerEvent): { x: number; y: number } => {\n const r = input.getBoundingClientRect();\n return { x: evt.clientX - r.left, y: evt.clientY - r.top };\n };\n\n const onPointerMove = (evt: PointerEvent) => {\n if (holding) return;\n model.aimAt(local(evt));\n };\n const onPointerDown = (evt: PointerEvent) => {\n if (interactive && surface.covers(local(evt))) holding = true;\n };\n const onPointerEnd = () => { holding = false; };\n const pointerEnds = ['pointerup', 'pointercancel', 'lostpointercapture'] as const;\n\n const teardown = () => {\n disposed = true;\n unsubscribeFrame();\n input.removeEventListener('pointermove', onPointerMove);\n input.removeEventListener('pointerdown', onPointerDown);\n for (const type of pointerEnds) input.removeEventListener(type, onPointerEnd);\n lens?.remove();\n lens = null;\n dropPixels();\n };\n\n input.addEventListener('pointermove', onPointerMove);\n input.addEventListener('pointerdown', onPointerDown);\n for (const type of pointerEnds) input.addEventListener(type, onPointerEnd);\n\n return {\n window: win,\n get mode() { return model.mode; },\n get factor() { return model.factor; },\n get aim() { return model.aim; },\n get color() { return model.color; },\n setMode: model.setMode,\n setFactor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,CAAC,CAAC;IAC1D,uEAAuE;IACvE,MAAM,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;IAChC;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CACJ,CAAC;AAKF;yDACyD;AACzD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,uEAAuE;IACvE,QAAQ,CAAC,GAAG,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACvC;;0BAEsB;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,OAAO,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;IAC/B,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC;oEACgE;IAChE,KAAK,CAAC,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACzC;;;;0BAIsB;IACtB,IAAI,CAAC,CAAC,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,GAAG,IAAI,CAAC;IAClD,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,WAAW,CA8O3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readback.d.ts","sourceRoot":"","sources":["../../src/loupe/readback.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"readback.d.ts","sourceRoot":"","sources":["../../src/loupe/readback.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,EAAE,EAAE,sBAAsB,EAC1B,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAC/D,OAAO,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EACjC,GAAG,EAAE,MAAM,EACX,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,GACT,SAAS,CAiBX"}
|
package/dist/react/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as e, o as t, r as n } from "../tool-
|
|
1
|
+
import { n as e, o as t, r as n } from "../tool-BLDCwvTF.js";
|
|
2
2
|
import { resolveTheme as r, weaselTheme as i } from "@weasel-js/theme";
|
|
3
3
|
import { useEffect as a, useMemo as o, useState as s } from "react";
|
|
4
4
|
import { useThemeOptional as c } from "@weasel-js/theme/react";
|
|
@@ -13,12 +13,23 @@ function l(e, r = {}) {
|
|
|
13
13
|
}, [i, o]), i;
|
|
14
14
|
}
|
|
15
15
|
function u(e) {
|
|
16
|
-
let t = c();
|
|
17
|
-
return o(() =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
let t = c(), n = typeof e == "string" ? e : void 0, a = typeof e == "object" ? e.metricsUrl : void 0, s = typeof e == "object" ? e.atlasUrl : void 0;
|
|
17
|
+
return o(() => {
|
|
18
|
+
let e = n ?? (a !== void 0 && s !== void 0 ? {
|
|
19
|
+
metricsUrl: a,
|
|
20
|
+
atlasUrl: s
|
|
21
|
+
} : void 0);
|
|
22
|
+
return {
|
|
23
|
+
theme: t?.resolved ?? r(i),
|
|
24
|
+
...t ? { tones: t } : {},
|
|
25
|
+
...e === void 0 ? {} : { font: e }
|
|
26
|
+
};
|
|
27
|
+
}, [
|
|
28
|
+
t,
|
|
29
|
+
n,
|
|
30
|
+
a,
|
|
31
|
+
s
|
|
32
|
+
]);
|
|
22
33
|
}
|
|
23
34
|
function d(t, n = {}) {
|
|
24
35
|
let r = u(n.font);
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["createHudContribution","createHud","attachHud","useHud","hud","useState","attachOptions","useAttachOptions","options","useEffect","api","canvasRef","detach","provided","useThemeOptional","useMemo","
|
|
1
|
+
{"version":3,"file":"index.js","names":["createHudContribution","createHud","attachHud","useHud","hud","useState","attachOptions","useAttachOptions","options","useEffect","api","canvasRef","detach","provided","useThemeOptional","family","font","metricsUrl","atlasUrl","useMemo","stable","resolveTheme","weaselTheme","useHudContribution"],"sources":["../../src/react/useHud.ts"],"sourcesContent":["import { useEffect, useMemo, useState } from 'react';\nimport { useThemeOptional } from '@weasel-js/theme/react';\nimport { resolveTheme, weaselTheme } from '@weasel-js/theme';\nimport { createHud, type Hud } from '../hud';\nimport { attachHud, type AttachHudOptions } from '../attach';\nimport type { CanvasExtensionApi, SurfaceContribution } from '@weasel-js/core';\nimport { createHudContribution } from '../tool';\n\n/**\n * Create a HUD, and — given the canvas's ref handle — attach it to that\n * canvas. Returns the Hud immediately (unbound); attaches in an effect after\n * the canvas ref populates. Cleans up on unmount.\n *\n * Omit the ref when the HUD installs through {@link useHudContribution}\n * instead, which attaches it as part of the canvas's `ambient` entry.\n *\n * An app that has already registered a bitmap family should say so —\n * `useHud(ref, { font: 'sans-serif' })` — or the HUD fetches its own copy of\n * the same atlas.\n */\nexport function useHud(\n canvasRef?: { current: CanvasExtensionApi | null },\n options: Pick<AttachHudOptions, 'font'> = {},\n): Hud {\n const [hud] = useState(() => createHud());\n const attachOptions = useAttachOptions(options.font);\n\n useEffect(() => {\n const api = canvasRef?.current;\n if (!api) return;\n const detach = attachHud(api, hud, attachOptions);\n api.requestRedraw();\n return detach;\n // canvasRef.current changing during component lifetime is unusual for\n // canvas refs; treat as effectively-stable in v1. The dep on `hud` is\n // also stable (it comes from useState's initializer, never changes).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [hud, attachOptions]);\n\n return hud;\n}\n\n/** The attach options that follow the app's theme. Widgets are drawn into the\n * canvas, so they can't inherit the cascade — handing them the resolved\n * record is what keeps HUD chrome in step with a mode switch. */\nfunction useAttachOptions(font: AttachHudOptions['font']): AttachHudOptions {\n const provided = useThemeOptional();\n // By value: an atlas written inline is a new object every render, and a new options object re-attaches the layer.\n const family = typeof font === 'string' ? font : undefined;\n const metricsUrl = typeof font === 'object' ? font.metricsUrl : undefined;\n const atlasUrl = typeof font === 'object' ? font.atlasUrl : undefined;\n return useMemo(() => {\n const stable = family ?? (metricsUrl !== undefined && atlasUrl !== undefined ? { metricsUrl, atlasUrl } : undefined);\n return {\n theme: provided?.resolved ?? resolveTheme(weaselTheme),\n ...(provided ? { tones: provided } : {}),\n ...(stable !== undefined ? { font: stable } : {}),\n };\n }, [provided, family, metricsUrl, atlasUrl]);\n}\n\n/**\n * The HUD's canvas entry — see {@link createHudContribution} for how the\n * routing works. Given a HUD, the entry also attaches it, so one `ambient`\n * entry installs the whole HUD:\n *\n * ```tsx\n * const hud = useHud();\n * const hudEntry = useHudContribution(hud, { font: 'sans-serif' });\n * <SceneCanvas ambient={[hudEntry]} … />\n * ```\n *\n * Without one it is input routing only, stateless (its actions resolve the hit\n * widget from the gesture's affordance payload), and one instance serves any\n * number of HUDs attached some other way.\n */\nexport function useHudContribution(\n hud?: Hud,\n options: Pick<AttachHudOptions, 'font'> = {},\n): SurfaceContribution {\n const attachOptions = useAttachOptions(options.font);\n return useMemo(\n () => createHudContribution(hud, attachOptions),\n [hud, attachOptions],\n );\n}\n"],"mappings":";;;;;AAoBA,SAAgBG,EACd,GACA,IAA0C,CAAC,GACtC;CACL,IAAM,CAACC,KAAOC,QAAeJ,EAAU,CAAC,GAClCK,IAAgBC,EAAiBC,EAAQ,IAAI;CAcnD,OAZAC,QA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AgB,MAAM,CACpB,SAAS,CAAC,EAAE;IAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAAA;CAAE,EAClD,OAAO,GAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAM,GAC3C,GAAG,CAiBL;
|
|
1
|
+
{"version":3,"file":"useHud.d.ts","sourceRoot":"","sources":["../../src/react/useHud.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,KAAK,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAG/E;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CACpB,SAAS,CAAC,EAAE;IAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAAA;CAAE,EAClD,OAAO,GAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAM,GAC3C,GAAG,CAiBL;AAqBD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,CAAC,EAAE,GAAG,EACT,OAAO,GAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAM,GAC3C,mBAAmB,CAMrB"}
|