@weasel-js/hud 0.5.0 → 0.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 +4 -0
- package/dist/attach.d.ts.map +1 -0
- package/dist/fonts/registerDefaultFont.d.ts +3 -0
- package/dist/fonts/registerDefaultFont.d.ts.map +1 -0
- package/dist/host.d.ts +6 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/hud.d.ts +29 -0
- package/dist/hud.d.ts.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/useHud.d.ts +17 -0
- package/dist/react/useHud.d.ts.map +1 -0
- package/dist/theme.d.ts +30 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/widget.d.ts +60 -0
- package/dist/widget.d.ts.map +1 -0
- package/dist/widgets/button.d.ts +32 -0
- package/dist/widgets/button.d.ts.map +1 -0
- package/dist/widgets/image.d.ts +23 -0
- package/dist/widgets/image.d.ts.map +1 -0
- package/dist/widgets/label.d.ts +17 -0
- package/dist/widgets/label.d.ts.map +1 -0
- package/dist/widgets/rect.d.ts +24 -0
- package/dist/widgets/rect.d.ts.map +1 -0
- package/dist/widgets/text.d.ts +24 -0
- package/dist/widgets/text.d.ts.map +1 -0
- package/package.json +2 -2
package/dist/attach.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attach.d.ts","sourceRoot":"","sources":["../src/attach.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAE,kBAAkB,EAAqD,MAAM,iBAAiB,CAAC;AAY7G,wBAAgB,SAAS,CAAC,GAAG,EAAE,kBAAkB,EAAE,GAAG,EAAE,GAAG,GAAG,MAAM,IAAI,CA+GvE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerDefaultFont.d.ts","sourceRoot":"","sources":["../../src/fonts/registerDefaultFont.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AAExD,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAEzD"}
|
package/dist/host.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,WAAW,OAAO;IACtB,aAAa,IAAI,IAAI,CAAC;IACtB,aAAa,CAAC,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,MAAM,IAAI,CAAC;CACxD"}
|
package/dist/hud.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Widget } from './widget';
|
|
2
|
+
import type { HudHost } from './host';
|
|
3
|
+
import { type RectOptions, type RectWidget } from './widgets/rect';
|
|
4
|
+
import { type TextOptions, type TextWidget } from './widgets/text';
|
|
5
|
+
import { type ImageOptions, type ImageWidget } from './widgets/image';
|
|
6
|
+
import { type LabelOptions, type LabelWidget } from './widgets/label';
|
|
7
|
+
import { type ButtonOptions, type ButtonWidget } from './widgets/button';
|
|
8
|
+
export interface Hud {
|
|
9
|
+
add(widget: Widget): void;
|
|
10
|
+
remove(widget: Widget): void;
|
|
11
|
+
widgets(): readonly Widget[];
|
|
12
|
+
markDirty(): void;
|
|
13
|
+
bind(host: HudHost): void;
|
|
14
|
+
unbind(): void;
|
|
15
|
+
/** True after bind() and before unbind(). */
|
|
16
|
+
readonly attached: boolean;
|
|
17
|
+
/** Create a rect widget, add it to the HUD, and wire onChange → markDirty. */
|
|
18
|
+
rect(opts: RectOptions): RectWidget;
|
|
19
|
+
/** Create a text widget, add it to the HUD, and wire onChange → markDirty. */
|
|
20
|
+
text(opts: TextOptions): TextWidget;
|
|
21
|
+
/** Create an image widget, add it to the HUD, and wire onChange → markDirty. */
|
|
22
|
+
image(opts: ImageOptions): ImageWidget;
|
|
23
|
+
/** Create a label widget, add it to the HUD, and wire onChange → markDirty. */
|
|
24
|
+
label(opts: LabelOptions): LabelWidget;
|
|
25
|
+
/** Create a button widget, add it to the HUD, and wire onChange → markDirty. */
|
|
26
|
+
button(opts: ButtonOptions): ButtonWidget;
|
|
27
|
+
}
|
|
28
|
+
export declare function createHud(): Hud;
|
|
29
|
+
//# sourceMappingURL=hud.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hud.d.ts","sourceRoot":"","sources":["../src/hud.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAc,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAc,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAe,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,EAAe,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,EAAgB,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEvF,MAAM,WAAW,GAAG;IAClB,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,OAAO,IAAI,SAAS,MAAM,EAAE,CAAC;IAC7B,SAAS,IAAI,IAAI,CAAC;IAClB,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1B,MAAM,IAAI,IAAI,CAAC;IACf,6CAA6C;IAC7C,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,8EAA8E;IAC9E,IAAI,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,CAAC;IACpC,8EAA8E;IAC9E,IAAI,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,CAAC;IACpC,gFAAgF;IAChF,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,WAAW,CAAC;IACvC,+EAA+E;IAC/E,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,WAAW,CAAC;IACvC,gFAAgF;IAChF,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,YAAY,CAAC;CAC3C;AAED,wBAAgB,SAAS,IAAI,GAAG,CAkG/B"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { createHud, type Hud } from './hud';
|
|
2
|
+
export { attachHud } from './attach';
|
|
3
|
+
export type { Widget, WidgetBounds, HudDrawCtx, HudPointerEvent, PointerClaim, } from './widget';
|
|
4
|
+
export type { HudHost } from './host';
|
|
5
|
+
export { DEFAULT_FONT_FAMILY, registerDefaultFont } from './fonts/registerDefaultFont';
|
|
6
|
+
export type { RectOptions, RectWidget } from './widgets/rect';
|
|
7
|
+
export type { TextOptions, TextWidget } from './widgets/text';
|
|
8
|
+
export type { ImageOptions, ImageWidget } from './widgets/image';
|
|
9
|
+
export type { LabelOptions, LabelWidget } from './widgets/label';
|
|
10
|
+
export type { ButtonOptions, ButtonWidget, ButtonEvent, ButtonHandler } from './widgets/button';
|
|
11
|
+
export { readTokens, type ResolvedTokens } from './theme';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,YAAY,EACV,MAAM,EACN,YAAY,EACZ,UAAU,EACV,eAAe,EACf,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvF,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC9D,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC9D,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACjE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACjE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Hud } from '../hud';
|
|
2
|
+
import type { CanvasExtensionApi } from '@weasel-js/core';
|
|
3
|
+
/**
|
|
4
|
+
* Create a HUD and attach it to a Canvas via its imperative ref handle.
|
|
5
|
+
* Returns the Hud immediately (unbound); attaches in an effect after the
|
|
6
|
+
* canvas ref populates. Cleans up on unmount.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* const ref = useRef<CanvasExtensionApi>(null);
|
|
10
|
+
* const hud = useHud(ref);
|
|
11
|
+
* // ... later
|
|
12
|
+
* const btn = hud.button({ ... });
|
|
13
|
+
*/
|
|
14
|
+
export declare function useHud(canvasRef: {
|
|
15
|
+
current: CanvasExtensionApi | null;
|
|
16
|
+
}): Hud;
|
|
17
|
+
//# sourceMappingURL=useHud.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHud.d.ts","sourceRoot":"","sources":["../../src/react/useHud.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,KAAK,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,SAAS,EAAE;IAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAAA;CAAE,GAAG,GAAG,CAe7E"}
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
package/dist/widget.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { DrawCommand } from '@weasel-js/core/renderer';
|
|
2
|
+
import type { ResolvedTokens } from './theme';
|
|
3
|
+
export interface WidgetBounds {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
w: number;
|
|
7
|
+
h: number;
|
|
8
|
+
}
|
|
9
|
+
export interface HudDrawCtx {
|
|
10
|
+
/** Canvas size in CSS pixels. */
|
|
11
|
+
dims: {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
};
|
|
15
|
+
/** Family name of the auto-registered default font. */
|
|
16
|
+
defaultFont: string;
|
|
17
|
+
/** Resolved design tokens from the canvas element's computed style.
|
|
18
|
+
* Re-read on every draw, so live CSS changes (dark-mode toggle, etc.)
|
|
19
|
+
* take effect on the next state-driven redraw. */
|
|
20
|
+
tokens: ResolvedTokens;
|
|
21
|
+
}
|
|
22
|
+
export type HudPointerEvent = {
|
|
23
|
+
type: 'down';
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
native: PointerEvent;
|
|
27
|
+
} | {
|
|
28
|
+
type: 'move';
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
native: PointerEvent;
|
|
32
|
+
} | {
|
|
33
|
+
type: 'up';
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
native: PointerEvent;
|
|
37
|
+
} | {
|
|
38
|
+
type: 'cancel';
|
|
39
|
+
native: PointerEvent;
|
|
40
|
+
} | {
|
|
41
|
+
type: 'hovermove';
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
native: PointerEvent;
|
|
45
|
+
} | {
|
|
46
|
+
type: 'hoverleave';
|
|
47
|
+
native: PointerEvent | null;
|
|
48
|
+
};
|
|
49
|
+
export type PointerClaim = 'claim' | 'pass';
|
|
50
|
+
export interface Widget {
|
|
51
|
+
readonly id: string;
|
|
52
|
+
readonly bounds: WidgetBounds;
|
|
53
|
+
readonly hidden: boolean;
|
|
54
|
+
draw(ctx: HudDrawCtx): DrawCommand[];
|
|
55
|
+
hitTest(x: number, y: number): boolean;
|
|
56
|
+
onPointer(evt: HudPointerEvent): PointerClaim;
|
|
57
|
+
/** Called by Hud.remove or widget.dispose. Detach event listeners, etc. */
|
|
58
|
+
dispose(): void;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=widget.d.ts.map
|
|
@@ -0,0 +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,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,WAAW,Y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AAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,GAAG,EAAE,UAAU,GAAG,WAAW,EAAE,CAAC;IACrC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACvC,SAAS,CAAC,GAAG,EAAE,eAAe,GAAG,YAAY,CAAC;IAC9C,2EAA2E;IAC3E,OAAO,IAAI,IAAI,CAAC;CACjB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Widget, WidgetBounds } from '../widget';
|
|
2
|
+
export type ButtonEvent = 'press' | 'hover' | 'leave';
|
|
3
|
+
export type ButtonHandler = () => void;
|
|
4
|
+
export interface ButtonOptions {
|
|
5
|
+
id: string;
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
w: number;
|
|
9
|
+
h: number;
|
|
10
|
+
label: string;
|
|
11
|
+
fill?: string;
|
|
12
|
+
pressedFill?: string;
|
|
13
|
+
hoverFill?: string;
|
|
14
|
+
textColor?: string;
|
|
15
|
+
fontSize?: number;
|
|
16
|
+
fontFamily?: string;
|
|
17
|
+
/** Injected by Hud factories to trigger redraw on mutation. */
|
|
18
|
+
onChange?: () => void;
|
|
19
|
+
/** Injected by Hud factories. Called from dispose() to remove this widget
|
|
20
|
+
* from its HUD's list. No-op for bare-factory consumers. */
|
|
21
|
+
removeFromHud?: () => void;
|
|
22
|
+
}
|
|
23
|
+
export interface ButtonWidget extends Widget {
|
|
24
|
+
setLabel(label: string): void;
|
|
25
|
+
setBounds(b: WidgetBounds): void;
|
|
26
|
+
setHidden(hidden: boolean): void;
|
|
27
|
+
on(event: ButtonEvent, handler: ButtonHandler): void;
|
|
28
|
+
off(event: ButtonEvent, handler: ButtonHandler): void;
|
|
29
|
+
dispose(): void;
|
|
30
|
+
}
|
|
31
|
+
export declare function createButton(opts: ButtonOptions): ButtonWidget;
|
|
32
|
+
//# sourceMappingURL=button.d.ts.map
|
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AgB,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,YAAY,CAgG9D"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Widget, WidgetBounds } from '../widget';
|
|
2
|
+
export interface ImageOptions {
|
|
3
|
+
id: string;
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
w: number;
|
|
7
|
+
h: number;
|
|
8
|
+
image: ImageBitmap;
|
|
9
|
+
opacity?: number;
|
|
10
|
+
/** Injected by Hud factories to trigger redraw on mutation. */
|
|
11
|
+
onChange?: () => void;
|
|
12
|
+
/** Injected by Hud factories. Called from dispose() to remove this widget
|
|
13
|
+
* from its HUD's list. No-op for bare-factory consumers. */
|
|
14
|
+
removeFromHud?: () => void;
|
|
15
|
+
}
|
|
16
|
+
export interface ImageWidget extends Widget {
|
|
17
|
+
setImage(image: ImageBitmap): void;
|
|
18
|
+
setBounds(b: WidgetBounds): void;
|
|
19
|
+
setHidden(hidden: boolean): void;
|
|
20
|
+
dispose(): void;
|
|
21
|
+
}
|
|
22
|
+
export declare function createImage(opts: ImageOptions): ImageWidget;
|
|
23
|
+
//# sourceMappingURL=image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/widgets/image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAA6C,MAAM,WAAW,CAAC;AAGjG,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,+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,CAuC3D"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type TextWidget } from './text';
|
|
2
|
+
export interface LabelOptions {
|
|
3
|
+
id: string;
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
text: string;
|
|
7
|
+
fontSize?: number;
|
|
8
|
+
color?: string;
|
|
9
|
+
/** Injected by Hud factories to trigger redraw on mutation. */
|
|
10
|
+
onChange?: () => void;
|
|
11
|
+
/** Injected by Hud factories. Called from dispose() to remove this widget
|
|
12
|
+
* from its HUD's list. No-op for bare-factory consumers. */
|
|
13
|
+
removeFromHud?: () => void;
|
|
14
|
+
}
|
|
15
|
+
export type LabelWidget = TextWidget;
|
|
16
|
+
export declare function createLabel(opts: LabelOptions): LabelWidget;
|
|
17
|
+
//# sourceMappingURL=label.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.d.ts","sourceRoot":"","sources":["../../src/widgets/label.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAC;AAErD,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB;iEAC6D;IAC7D,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC;AAErC,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,WAAW,CAY3D"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Widget, WidgetBounds } from '../widget';
|
|
2
|
+
export interface RectOptions {
|
|
3
|
+
id: string;
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
w: number;
|
|
7
|
+
h: number;
|
|
8
|
+
fill: string;
|
|
9
|
+
/** Called whenever a setter mutates state. The Hud's `rect()` factory
|
|
10
|
+
* injects this so mutations trigger `requestRedraw`. Direct callers of
|
|
11
|
+
* `createRect` may set it themselves or omit it (no auto-redraw). */
|
|
12
|
+
onChange?: () => void;
|
|
13
|
+
/** Injected by Hud factories. Called from dispose() to remove this widget
|
|
14
|
+
* from its HUD's list. No-op for bare-factory consumers. */
|
|
15
|
+
removeFromHud?: () => void;
|
|
16
|
+
}
|
|
17
|
+
export interface RectWidget extends Widget {
|
|
18
|
+
setBounds(b: WidgetBounds): void;
|
|
19
|
+
setHidden(hidden: boolean): void;
|
|
20
|
+
setFill(color: string): void;
|
|
21
|
+
dispose(): void;
|
|
22
|
+
}
|
|
23
|
+
export declare function createRect(opts: RectOptions): RectWidget;
|
|
24
|
+
//# sourceMappingURL=rect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rect.d.ts","sourceRoot":"","sources":["../../src/widgets/rect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAA6C,YAAY,EAAE,MAAM,WAAW,CAAC;AAIjG,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,CAyCxD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Widget, WidgetBounds } from '../widget';
|
|
2
|
+
export interface TextOptions {
|
|
3
|
+
id: string;
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
text: string;
|
|
7
|
+
fontSize: number;
|
|
8
|
+
color?: string;
|
|
9
|
+
/** Optional; falls back to the HUD default font from HudDrawCtx. */
|
|
10
|
+
fontFamily?: string;
|
|
11
|
+
/** Injected by Hud factories to trigger redraw on mutation. */
|
|
12
|
+
onChange?: () => void;
|
|
13
|
+
/** Injected by Hud factories. Called from dispose() to remove this widget
|
|
14
|
+
* from its HUD's list. No-op for bare-factory consumers. */
|
|
15
|
+
removeFromHud?: () => void;
|
|
16
|
+
}
|
|
17
|
+
export interface TextWidget extends Widget {
|
|
18
|
+
setText(text: string): void;
|
|
19
|
+
setHidden(hidden: boolean): void;
|
|
20
|
+
setBounds(b: WidgetBounds): void;
|
|
21
|
+
dispose(): void;
|
|
22
|
+
}
|
|
23
|
+
export declare function createText(opts: TextOptions): TextWidget;
|
|
24
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/widgets/text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAA6C,MAAM,WAAW,CAAC;AAIjG,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,CAsCxD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weasel-js/hud",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.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,7 @@
|
|
|
23
23
|
"@weasel-js/core": ">=0.4.0"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@weasel-js/theme": "0.5.
|
|
26
|
+
"@weasel-js/theme": "0.5.1"
|
|
27
27
|
},
|
|
28
28
|
"author": "orochi235",
|
|
29
29
|
"homepage": "https://orochi235.github.io/weasel/",
|