@weasel-js/hud 0.6.0 → 0.7.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.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +12 -9
- package/dist/react/index.js.map +1 -1
- package/dist/react/useHud.d.ts +9 -1
- package/dist/react/useHud.d.ts.map +1 -1
- package/dist/{attach-VLoZGx-n.js → tool-D2HHqsdo.js} +140 -41
- package/dist/tool-D2HHqsdo.js.map +1 -0
- package/dist/tool.d.ts +40 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/widget.d.ts +16 -5
- package/dist/widget.d.ts.map +1 -1
- package/package.json +3 -2
- package/dist/attach-VLoZGx-n.js.map +0 -1
package/dist/tool.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Tool } from '@weasel-js/core';
|
|
2
|
+
import type { Widget } from './widget';
|
|
3
|
+
/** What the HUD layer's `hitTest` resolves and hands to the actions below. */
|
|
4
|
+
export interface HudHitPayload {
|
|
5
|
+
widget: Widget;
|
|
6
|
+
}
|
|
7
|
+
/** Affordance kind `<SceneCanvas>` stamps on a hit from the HUD's layer:
|
|
8
|
+
* `layer:<RenderLayer.id>`, and the HUD's layer id is `weasel-hud`. */
|
|
9
|
+
export declare const HUD_AFFORDANCE_KIND = "layer:weasel-hud";
|
|
10
|
+
/**
|
|
11
|
+
* A `Tool` carrying the HUD's input routing. Pass it to the canvas as an
|
|
12
|
+
* AMBIENT tool — the HUD is chrome floating over whatever tool is active, so
|
|
13
|
+
* it must not occupy the active slot:
|
|
14
|
+
*
|
|
15
|
+
* ```tsx
|
|
16
|
+
* const hud = useHud(ref);
|
|
17
|
+
* const hudTool = useHudTool();
|
|
18
|
+
* <SceneCanvas ref={ref} ambient={[hudTool]} … />
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Three bindings, because the widget protocol (`down` / `move` / `up`) spans
|
|
22
|
+
* two gesture kinds:
|
|
23
|
+
*
|
|
24
|
+
* - `pointerDown` sends `down` at press time, before the dispatcher knows
|
|
25
|
+
* whether this becomes a click or a drag. A button that highlights on press
|
|
26
|
+
* has to know then, not on release.
|
|
27
|
+
* - `click` sends the `up` for a press that never crossed the drag threshold —
|
|
28
|
+
* the common case for a button.
|
|
29
|
+
* - `drag` pumps `move` and closes with `up` / `cancel`.
|
|
30
|
+
*
|
|
31
|
+
* All three gate on the affordance kind, so they fire only for presses the
|
|
32
|
+
* HUD's own layer hit-test claimed. That gate is also why ambient scope is
|
|
33
|
+
* safe: nothing else produces a `layer:weasel-hud` hit, and kit tools decline
|
|
34
|
+
* presses that landed on chrome.
|
|
35
|
+
*
|
|
36
|
+
* This replaces a `DragChannel` the HUD's `hitTest` used to hand back for the
|
|
37
|
+
* tool-routing dispatcher to drive. That dispatcher is gone.
|
|
38
|
+
*/
|
|
39
|
+
export declare function createHudTool(): Tool<null>;
|
|
40
|
+
//# sourceMappingURL=tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqC,IAAI,EAAQ,MAAM,iBAAiB,CAAC;AAErF,OAAO,KAAK,EAAE,MAAM,EAAmB,MAAM,UAAU,CAAC;AAExD,8EAA8E;AAC9E,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;wEACwE;AACxE,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AAgGtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAAC,IAAI,CAAC,CAU1C"}
|
package/dist/widget.d.ts
CHANGED
|
@@ -19,29 +19,40 @@ export interface HudDrawCtx {
|
|
|
19
19
|
* take effect on the next state-driven redraw. */
|
|
20
20
|
tokens: ResolvedTokens;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Input handed to a widget, in screen space.
|
|
24
|
+
*
|
|
25
|
+
* `native` is the originating DOM event when there is one, and `null`
|
|
26
|
+
* otherwise — it is **not** guaranteed. Hover is driven by a direct DOM
|
|
27
|
+
* listener in `attachHud`, so `hovermove` carries the real `PointerEvent`.
|
|
28
|
+
* Press / move / release arrive through the gesture dispatcher, which hands
|
|
29
|
+
* actions normalized input rather than the event that produced it, so those
|
|
30
|
+
* arms carry `null`. A widget that needs `native` must handle its absence;
|
|
31
|
+
* prefer the normalized `x` / `y` and the event `type`.
|
|
32
|
+
*/
|
|
22
33
|
export type HudPointerEvent = {
|
|
23
34
|
type: 'down';
|
|
24
35
|
x: number;
|
|
25
36
|
y: number;
|
|
26
|
-
native: PointerEvent;
|
|
37
|
+
native: PointerEvent | null;
|
|
27
38
|
} | {
|
|
28
39
|
type: 'move';
|
|
29
40
|
x: number;
|
|
30
41
|
y: number;
|
|
31
|
-
native: PointerEvent;
|
|
42
|
+
native: PointerEvent | null;
|
|
32
43
|
} | {
|
|
33
44
|
type: 'up';
|
|
34
45
|
x: number;
|
|
35
46
|
y: number;
|
|
36
|
-
native: PointerEvent;
|
|
47
|
+
native: PointerEvent | null;
|
|
37
48
|
} | {
|
|
38
49
|
type: 'cancel';
|
|
39
|
-
native: PointerEvent;
|
|
50
|
+
native: PointerEvent | null;
|
|
40
51
|
} | {
|
|
41
52
|
type: 'hovermove';
|
|
42
53
|
x: number;
|
|
43
54
|
y: number;
|
|
44
|
-
native: PointerEvent;
|
|
55
|
+
native: PointerEvent | null;
|
|
45
56
|
} | {
|
|
46
57
|
type: 'hoverleave';
|
|
47
58
|
native: PointerEvent | null;
|
package/dist/widget.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../src/widget.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CACjB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weasel-js/hud",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "WebGL-rendered UI widgets that composite into a weasel canvas",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"@weasel-js/core": ">=0.4.0"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@weasel-js/
|
|
26
|
+
"@weasel-js/font": "0.7.1",
|
|
27
|
+
"@weasel-js/theme": "0.7.1"
|
|
27
28
|
},
|
|
28
29
|
"author": "orochi235",
|
|
29
30
|
"homepage": "https://orochi235.github.io/weasel/",
|