@weasel-js/hud 0.5.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/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import { a as e, i as t, n, r, t as i } from "./attach-VLoZGx-n.js";
2
+ export { r as DEFAULT_FONT_FAMILY, i as attachHud, e as createHud, n as readTokens, t as registerDefaultFont };
@@ -0,0 +1,14 @@
1
+ import { a as e, t } from "../attach-VLoZGx-n.js";
2
+ import { useEffect as n, useState as r } from "react";
3
+ //#region src/react/useHud.ts
4
+ function i(i) {
5
+ let [a] = r(() => e());
6
+ return n(() => {
7
+ let e = i.current;
8
+ if (e) return t(e, a);
9
+ }, [a]), a;
10
+ }
11
+ //#endregion
12
+ export { i as useHud };
13
+
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/react/useHud.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { createHud, type Hud } from '../hud';\nimport { attachHud } from '../attach';\nimport type { CanvasExtensionApi } from '@weasel-js/core';\n\n/**\n * Create a HUD and attach it to a Canvas via its imperative ref handle.\n * Returns the Hud immediately (unbound); attaches in an effect after the\n * canvas ref populates. Cleans up on unmount.\n *\n * Usage:\n * const ref = useRef<CanvasExtensionApi>(null);\n * const hud = useHud(ref);\n * // ... later\n * const btn = hud.button({ ... });\n */\nexport function useHud(canvasRef: { current: CanvasExtensionApi | null }): Hud {\n const [hud] = useState(() => createHud());\n\n useEffect(() => {\n const api = canvasRef.current;\n if (!api) return;\n const detach = attachHud(api, hud);\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]);\n\n return hud;\n}\n"],"mappings":";;;AAgBA,SAAgB,EAAO,GAAwD;CAC7E,IAAM,CAAC,KAAO,QAAe,GAAW,CAAC;AAazC,QAXA,QAAgB;EACd,IAAM,IAAM,EAAU;AACjB,QAEL,QADe,EAAU,GAAK,EACvB;IAKN,CAAC,EAAI,CAAC,EAEF"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@weasel-js/hud",
3
+ "version": "0.5.0",
4
+ "description": "WebGL-rendered UI widgets that composite into a weasel canvas",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/index.js",
13
+ "types": "./dist/index.d.ts"
14
+ },
15
+ "./react": {
16
+ "import": "./dist/react/index.js",
17
+ "types": "./dist/react/index.d.ts"
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
21
+ "peerDependencies": {
22
+ "react": ">=18",
23
+ "@weasel-js/core": ">=0.4.0"
24
+ },
25
+ "dependencies": {
26
+ "@weasel-js/theme": "0.5.0"
27
+ },
28
+ "author": "orochi235",
29
+ "homepage": "https://orochi235.github.io/weasel/",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/orochi235/weasel.git",
33
+ "directory": "packages/hud"
34
+ },
35
+ "bugs": {
36
+ "url": "https://github.com/orochi235/weasel/issues"
37
+ },
38
+ "engines": {
39
+ "node": ">=20"
40
+ },
41
+ "files": [
42
+ "dist",
43
+ "README.md",
44
+ "LICENSE"
45
+ ],
46
+ "publishConfig": {
47
+ "access": "public"
48
+ },
49
+ "scripts": {
50
+ "build": "vite build && tsc -p tsconfig.build.json"
51
+ }
52
+ }