@weasel-js/hud 0.8.0 → 1.0.0
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 +12 -0
- package/dist/attach.d.ts +7 -1
- package/dist/attach.d.ts.map +1 -1
- package/dist/hud.d.ts +3 -0
- package/dist/hud.d.ts.map +1 -1
- package/dist/index.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +142 -2
- package/dist/index.js.map +1 -0
- package/dist/loupe/createLoupe.d.ts +56 -0
- package/dist/loupe/createLoupe.d.ts.map +1 -0
- package/dist/loupe/innerView.d.ts +12 -0
- package/dist/loupe/innerView.d.ts.map +1 -0
- package/dist/loupe/readback.d.ts +15 -0
- package/dist/loupe/readback.d.ts.map +1 -0
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +15 -11
- package/dist/react/index.js.map +1 -1
- package/dist/react/useHud.d.ts +5 -5
- package/dist/react/useHud.d.ts.map +1 -1
- package/dist/{tool-D2HHqsdo.js → tool-Cvy1MwFJ.js} +498 -164
- package/dist/tool-Cvy1MwFJ.js.map +1 -0
- package/dist/tool.d.ts +12 -14
- package/dist/tool.d.ts.map +1 -1
- package/dist/widget.d.ts +77 -12
- package/dist/widget.d.ts.map +1 -1
- package/dist/widgets/button.d.ts.map +1 -1
- package/dist/widgets/image.d.ts +2 -0
- package/dist/widgets/image.d.ts.map +1 -1
- package/dist/widgets/rect.d.ts.map +1 -1
- package/dist/widgets/text.d.ts.map +1 -1
- package/dist/widgets/window/window.d.ts +38 -0
- package/dist/widgets/window/window.d.ts.map +1 -0
- package/dist/widgets/window/zones.d.ts +24 -0
- package/dist/widgets/window/zones.d.ts.map +1 -0
- package/package.json +3 -3
- package/dist/theme.d.ts +0 -30
- package/dist/theme.d.ts.map +0 -1
- package/dist/tool-D2HHqsdo.js.map +0 -1
package/dist/tool.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type
|
|
1
|
+
import type { Contribution } from '@weasel-js/core';
|
|
2
|
+
import { type Widget } from './widget';
|
|
3
3
|
/** What the HUD layer's `hitTest` resolves and hands to the actions below. */
|
|
4
4
|
export interface HudHitPayload {
|
|
5
5
|
widget: Widget;
|
|
@@ -8,18 +8,17 @@ export interface HudHitPayload {
|
|
|
8
8
|
* `layer:<RenderLayer.id>`, and the HUD's layer id is `weasel-hud`. */
|
|
9
9
|
export declare const HUD_AFFORDANCE_KIND = "layer:weasel-hud";
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* The HUD's input routing as a `Contribution` — bindings and actions, no
|
|
12
|
+
* focus. It declares `claimed` eligibility: the HUD is chrome floating over
|
|
13
|
+
* whatever tool is active, live only for input its own layer claimed.
|
|
14
14
|
*
|
|
15
15
|
* ```tsx
|
|
16
16
|
* const hud = useHud(ref);
|
|
17
|
-
* const
|
|
18
|
-
* <SceneCanvas ref={ref} ambient={[
|
|
17
|
+
* const hudContribution = useHudContribution();
|
|
18
|
+
* <SceneCanvas ref={ref} ambient={[hudContribution]} … />
|
|
19
19
|
* ```
|
|
20
20
|
*
|
|
21
|
-
*
|
|
22
|
-
* two gesture kinds:
|
|
21
|
+
* The press protocol alone spans three gesture kinds:
|
|
23
22
|
*
|
|
24
23
|
* - `pointerDown` sends `down` at press time, before the dispatcher knows
|
|
25
24
|
* whether this becomes a click or a drag. A button that highlights on press
|
|
@@ -28,13 +27,12 @@ export declare const HUD_AFFORDANCE_KIND = "layer:weasel-hud";
|
|
|
28
27
|
* the common case for a button.
|
|
29
28
|
* - `drag` pumps `move` and closes with `up` / `cancel`.
|
|
30
29
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* presses that landed on chrome.
|
|
30
|
+
* The other four are one binding each. Every binding gates on both the
|
|
31
|
+
* affordance kind and the hit widget's claim set, so it fires only for input
|
|
32
|
+
* the HUD's own layer claimed *and* the widget under it consumes.
|
|
35
33
|
*
|
|
36
34
|
* This replaces a `DragChannel` the HUD's `hitTest` used to hand back for the
|
|
37
35
|
* tool-routing dispatcher to drive. That dispatcher is gone.
|
|
38
36
|
*/
|
|
39
|
-
export declare function
|
|
37
|
+
export declare function createHudContribution(): Contribution;
|
|
40
38
|
//# sourceMappingURL=tool.d.ts.map
|
package/dist/tool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAC4B,YAAY,EACnD,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAY,KAAK,MAAM,EAAwB,MAAM,UAAU,CAAC;AAEvE,8EAA8E;AAC9E,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;wEACwE;AACxE,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AAqKtD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,qBAAqB,IAAI,YAAY,CAqBpD"}
|
package/dist/widget.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DrawCommand } from '@weasel-js/core/renderer';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ClaimableGesture, View } from '@weasel-js/core';
|
|
3
|
+
import type { ResolvedTheme } from '@weasel-js/theme';
|
|
3
4
|
export interface WidgetBounds {
|
|
4
5
|
x: number;
|
|
5
6
|
y: number;
|
|
@@ -14,20 +15,44 @@ export interface HudDrawCtx {
|
|
|
14
15
|
};
|
|
15
16
|
/** Family name of the auto-registered default font. */
|
|
16
17
|
defaultFont: string;
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
tokens:
|
|
18
|
+
/** The resolved theme, keyed by CSS custom-property name. Supplied by the
|
|
19
|
+
* caller rather than read back off the DOM, so a HUD drawn headlessly is
|
|
20
|
+
* themed the same way one drawn in a browser is. */
|
|
21
|
+
tokens: ResolvedTheme;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Input to a widget's optional `content` painter — the one place hud sees
|
|
25
|
+
* the scene. `HudDrawCtx` stays data-free so widgets stay renderable
|
|
26
|
+
* headlessly; this is an explicit opt-in on the composite instead.
|
|
27
|
+
*/
|
|
28
|
+
export interface HudContentCtx {
|
|
29
|
+
/** Scene data the hud layer was handed. Opaque here; painters that need
|
|
30
|
+
* it cast to a known shape, as tools do with `ToolCtx.adapter`. */
|
|
31
|
+
data: unknown;
|
|
32
|
+
/** The outer view. A painter deriving an inner view starts from this. */
|
|
33
|
+
view: View;
|
|
34
|
+
dims: {
|
|
35
|
+
width: number;
|
|
36
|
+
height: number;
|
|
37
|
+
};
|
|
38
|
+
/** Where the content is painted, in screen-space CSS px. The group the
|
|
39
|
+
* painter's commands land in carries a clip but no transform, so those
|
|
40
|
+
* commands are in absolute canvas coordinates — a painter that treats the
|
|
41
|
+
* rect's origin as (0,0) silently draws nothing. */
|
|
42
|
+
rect: WidgetBounds;
|
|
43
|
+
defaultFont: string;
|
|
44
|
+
tokens: ResolvedTheme;
|
|
21
45
|
}
|
|
22
46
|
/**
|
|
23
47
|
* Input handed to a widget, in screen space.
|
|
24
48
|
*
|
|
25
49
|
* `native` is the originating DOM event when there is one, and `null`
|
|
26
|
-
* otherwise — it is **not** guaranteed. Hover
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
50
|
+
* otherwise — it is **not** guaranteed. Hover arrives through the layer's
|
|
51
|
+
* `onUncapturedMove`, so `hovermove` carries the real `PointerEvent` — and,
|
|
52
|
+
* being uncaptured-only, stops for the duration of any drag.
|
|
53
|
+
* Every other arm arrives through the gesture dispatcher, which hands
|
|
54
|
+
* actions normalized input rather than the event that produced it, so they
|
|
55
|
+
* carry `null`. A widget that needs `native` must handle its absence;
|
|
31
56
|
* prefer the normalized `x` / `y` and the event `type`.
|
|
32
57
|
*/
|
|
33
58
|
export type HudPointerEvent = {
|
|
@@ -56,15 +81,55 @@ export type HudPointerEvent = {
|
|
|
56
81
|
} | {
|
|
57
82
|
type: 'hoverleave';
|
|
58
83
|
native: PointerEvent | null;
|
|
84
|
+
} | {
|
|
85
|
+
type: 'doubleclick';
|
|
86
|
+
x: number;
|
|
87
|
+
y: number;
|
|
88
|
+
native: PointerEvent | null;
|
|
89
|
+
} | {
|
|
90
|
+
type: 'contextmenu';
|
|
91
|
+
x: number;
|
|
92
|
+
y: number;
|
|
93
|
+
native: PointerEvent | null;
|
|
94
|
+
} | {
|
|
95
|
+
type: 'longpress';
|
|
96
|
+
x: number;
|
|
97
|
+
y: number;
|
|
98
|
+
native: PointerEvent | null;
|
|
99
|
+
} | {
|
|
100
|
+
type: 'wheel';
|
|
101
|
+
x: number;
|
|
102
|
+
y: number;
|
|
103
|
+
deltaX: number;
|
|
104
|
+
deltaY: number;
|
|
105
|
+
native: PointerEvent | null;
|
|
59
106
|
};
|
|
60
|
-
|
|
107
|
+
/** What a widget consumes when it declares nothing: chrome is opaque to every
|
|
108
|
+
* pointer-family gesture except the wheel, which stays with the viewport
|
|
109
|
+
* unless a widget asks for it. */
|
|
110
|
+
export declare const DEFAULT_WIDGET_CLAIMS: readonly ClaimableGesture[];
|
|
111
|
+
export declare function claimsOf(w: Widget): readonly ClaimableGesture[];
|
|
61
112
|
export interface Widget {
|
|
62
113
|
readonly id: string;
|
|
63
114
|
readonly bounds: WidgetBounds;
|
|
64
115
|
readonly hidden: boolean;
|
|
65
116
|
draw(ctx: HudDrawCtx): DrawCommand[];
|
|
117
|
+
/** Optional interior painter, drawn beneath every widget frame and
|
|
118
|
+
* clipped to `contentRect`. See {@link HudContentCtx}. */
|
|
119
|
+
content?(ctx: HudContentCtx): DrawCommand[];
|
|
120
|
+
/** Region `content` is clipped to. Required when `content` is set. */
|
|
121
|
+
readonly contentRect?: WidgetBounds;
|
|
66
122
|
hitTest(x: number, y: number): boolean;
|
|
67
|
-
|
|
123
|
+
/** Which gestures this widget consumes. Absent means
|
|
124
|
+
* {@link DEFAULT_WIDGET_CLAIMS}; `[]` is decoration, and the hit-test walk
|
|
125
|
+
* descends past it to whatever lies beneath. Anything not listed falls
|
|
126
|
+
* through to the scene. */
|
|
127
|
+
readonly claims?: readonly ClaimableGesture[];
|
|
128
|
+
/** CSS cursor for a point inside this widget, in screen space. Resolved per
|
|
129
|
+
* point rather than read off hover state, because the layer's `hitTest`
|
|
130
|
+
* runs for a point and hover state may lag it. */
|
|
131
|
+
cursorAt?(x: number, y: number): string;
|
|
132
|
+
onPointer(evt: HudPointerEvent): void;
|
|
68
133
|
/** Called by Hud.remove or widget.dispose. Detach event listeners, etc. */
|
|
69
134
|
dispose(): void;
|
|
70
135
|
}
|
package/dist/widget.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../src/widget.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../src/widget.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,MAAM,WAAW,YAAY;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,UAAU;IAC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AAE,YAAY,CAAC;IACpC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACvC;;;gCAG4B;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC9C;;uDAEmD;IACnD,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxC,SAAS,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI,CAAC;IACtC,2EAA2E;IAC3E,OAAO,IAAI,IAAI,CAAC;CACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/widgets/button.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/widgets/button.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAA+B,MAAM,WAAW,CAAC;AAInF,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AACtD,MAAM,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC;AAEvC,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB;iEAC6D;IAC7D,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,YAAa,SAAQ,MAAM;IAC1C,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,SAAS,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IACjC,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACjC,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IACrD,GAAG,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IACtD,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,YAAY,CAoG9D"}
|
package/dist/widgets/image.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export interface ImageOptions {
|
|
|
7
7
|
h: number;
|
|
8
8
|
image: ImageBitmap;
|
|
9
9
|
opacity?: number;
|
|
10
|
+
/** Magnification filter for the drawn bitmap. See `ImageDrawCommand.sampling`. */
|
|
11
|
+
sampling?: 'linear' | 'nearest';
|
|
10
12
|
/** Injected by Hud factories to trigger redraw on mutation. */
|
|
11
13
|
onChange?: () => void;
|
|
12
14
|
/** Injected by Hud factories. Called from dispose() to remove this widget
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/widgets/image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/widgets/image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAA+B,MAAM,WAAW,CAAC;AAGnF,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAC3C,KAAK,EAAE,WAAW,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kFAAkF;IAClF,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAChC,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB;iEAC6D;IAC7D,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,WAAY,SAAQ,MAAM;IACzC,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;IACnC,SAAS,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IACjC,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACjC,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,WAAW,CAyC3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rect.d.ts","sourceRoot":"","sources":["../../src/widgets/rect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"rect.d.ts","sourceRoot":"","sources":["../../src/widgets/rect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAA+B,YAAY,EAAE,MAAM,WAAW,CAAC;AAInF,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;IACb;;0EAEsE;IACtE,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB;iEAC6D;IAC7D,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,UAAW,SAAQ,MAAM;IACxC,SAAS,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IACjC,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACjC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,CA0CxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/widgets/text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/widgets/text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAA+B,MAAM,WAAW,CAAC;AAInF,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oEAAoE;IACpE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB;iEAC6D;IAC7D,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,UAAW,SAAQ,MAAM;IACxC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACjC,SAAS,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IACjC,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,CAuCxD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Widget, WidgetBounds, HudContentCtx } from '../../widget';
|
|
2
|
+
import type { DrawCommand } from '@weasel-js/core/renderer';
|
|
3
|
+
import { type WindowMetrics } from './zones';
|
|
4
|
+
export interface WindowOptions {
|
|
5
|
+
id: string;
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
w: number;
|
|
9
|
+
h: number;
|
|
10
|
+
title: string;
|
|
11
|
+
minW?: number;
|
|
12
|
+
minH?: number;
|
|
13
|
+
/** Draw a titlebar with the title and a close box. Default `true`. When
|
|
14
|
+
* `false` the window is bare — and dragging its interior moves it, since
|
|
15
|
+
* there is no bar to grab. */
|
|
16
|
+
titlebar?: boolean;
|
|
17
|
+
metrics?: Partial<WindowMetrics>;
|
|
18
|
+
/** Paints the interior. Drawn beneath every widget frame, clipped to
|
|
19
|
+
* `contentRect`. Receives the scene data and view the hud layer was
|
|
20
|
+
* handed — the one place hud sees either. */
|
|
21
|
+
content?: (ctx: HudContentCtx) => DrawCommand[];
|
|
22
|
+
onMove?: (b: WidgetBounds) => void;
|
|
23
|
+
onResize?: (b: WidgetBounds) => void;
|
|
24
|
+
onClose?: () => void;
|
|
25
|
+
/** Injected by Hud factories to trigger redraw on mutation. */
|
|
26
|
+
onChange?: () => void;
|
|
27
|
+
/** Injected by Hud factories. Called from dispose(). */
|
|
28
|
+
removeFromHud?: () => void;
|
|
29
|
+
}
|
|
30
|
+
export interface WindowWidget extends Widget {
|
|
31
|
+
readonly contentRect: WidgetBounds;
|
|
32
|
+
setBounds(b: WidgetBounds): void;
|
|
33
|
+
setHidden(hidden: boolean): void;
|
|
34
|
+
setTitle(title: string): void;
|
|
35
|
+
dispose(): void;
|
|
36
|
+
}
|
|
37
|
+
export declare function createWindow(opts: WindowOptions): WindowW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,IAAI,CAAC;IACjC,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,YAAY,CAoK9D"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { WidgetBounds } from '../../widget';
|
|
2
|
+
export type WindowZone = 'title' | 'close' | 'content' | 'n' | 's' | 'e' | 'w' | 'ne' | 'nw' | 'se' | 'sw';
|
|
3
|
+
export interface WindowMetrics {
|
|
4
|
+
/** Titlebar height in CSS px. */
|
|
5
|
+
titleH: number;
|
|
6
|
+
/** Grab-zone thickness on each side, and the frame inset, in CSS px. */
|
|
7
|
+
edge: number;
|
|
8
|
+
/** Side length of the square close box. */
|
|
9
|
+
closeSize: number;
|
|
10
|
+
}
|
|
11
|
+
export declare const DEFAULT_WINDOW_METRICS: WindowMetrics;
|
|
12
|
+
/** The eight resize zones a drag can start in, plus title/close/content. */
|
|
13
|
+
export declare function zoneAt(b: WidgetBounds, m: WindowMetrics, x: number, y: number): WindowZone | null;
|
|
14
|
+
/** Interior rect: below the titlebar, inside the frame on the other three sides. */
|
|
15
|
+
export declare function windowContentRect(b: WidgetBounds, m: WindowMetrics): WidgetBounds;
|
|
16
|
+
/**
|
|
17
|
+
* Bounds after dragging `zone` by `(dx, dy)` from `start`. West/north
|
|
18
|
+
* clamping holds the opposite edge; clamping the extent alone would walk the
|
|
19
|
+
* window sideways once it bottoms out.
|
|
20
|
+
*/
|
|
21
|
+
export declare function applyWindowDrag(start: WidgetBounds, zone: WindowZone, dx: number, dy: number, minW: number, minH: number): WidgetBounds;
|
|
22
|
+
/** CSS cursor for a zone, for the host to apply on hover. */
|
|
23
|
+
export declare function cursorForZone(zone: WindowZone): string;
|
|
24
|
+
//# sourceMappingURL=zones.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zones.d.ts","sourceRoot":"","sources":["../../../src/widgets/window/zones.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,MAAM,UAAU,GAClB,OAAO,GAAG,OAAO,GAAG,SAAS,GAC7B,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEtD,MAAM,WAAW,aAAa;IAC5B,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,sBAAsB,EAAE,aAAsD,CAAC;AAE5F,4EAA4E;AAC5E,wBAAgB,MAAM,CACpB,CAAC,EAAE,YAAY,EACf,CAAC,EAAE,aAAa,EAChB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACR,UAAU,GAAG,IAAI,CAsBnB;AAED,oFAAoF;AACpF,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,aAAa,GAAG,YAAY,CAOjF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,YAAY,EACnB,IAAI,EAAE,UAAU,EAChB,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,YAAY,CAuBd;AAED,6DAA6D;AAC7D,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAStD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weasel-js/hud",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "WebGL-rendered UI widgets that composite into a weasel canvas",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"@weasel-js/core": ">=0.4.0"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@weasel-js/font": "0.
|
|
27
|
-
"@weasel-js/theme": "0.
|
|
26
|
+
"@weasel-js/font": "1.0.0",
|
|
27
|
+
"@weasel-js/theme": "1.0.0"
|
|
28
28
|
},
|
|
29
29
|
"author": "orochi235",
|
|
30
30
|
"homepage": "https://orochi235.github.io/weasel/",
|
package/dist/theme.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export interface ResolvedTokens {
|
|
2
|
-
text: string;
|
|
3
|
-
textMuted: string;
|
|
4
|
-
panelBg: string;
|
|
5
|
-
panelBorder: string;
|
|
6
|
-
inputBg: string;
|
|
7
|
-
accent: string;
|
|
8
|
-
danger: string;
|
|
9
|
-
trackBg: string;
|
|
10
|
-
trackBorder: string;
|
|
11
|
-
thumbFill: string;
|
|
12
|
-
thumbBorder: string;
|
|
13
|
-
thumbText: string;
|
|
14
|
-
buttonFill: string;
|
|
15
|
-
buttonFillHover: string;
|
|
16
|
-
buttonFillPressed: string;
|
|
17
|
-
buttonText: string;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Resolve the current theme tokens for the canvas element.
|
|
21
|
-
*
|
|
22
|
-
* Pass `null` (or an element not yet attached to the DOM) to get the
|
|
23
|
-
* default tokens — useful during the boot window before the canvas ref
|
|
24
|
-
* has populated.
|
|
25
|
-
*
|
|
26
|
-
* Reads via `getComputedStyle`, which is cached by the browser between
|
|
27
|
-
* layouts; calling this once per draw is sub-millisecond.
|
|
28
|
-
*/
|
|
29
|
-
export declare function readTokens(canvasEl: HTMLCanvasElement | null): ResolvedTokens;
|
|
30
|
-
//# sourceMappingURL=theme.d.ts.map
|
package/dist/theme.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;CACpB;AAqBD;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,GAAG,cAAc,CAQ7E"}
|