@weasel-js/hud 1.11.1 → 1.13.0-rc.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/attach.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/react/index.js +2 -2
- package/dist/react/index.js.map +1 -1
- package/dist/{tool-B5AjewKP.js → tool-8LVUdM5S.js} +232 -202
- package/dist/tool-8LVUdM5S.js.map +1 -0
- package/dist/widget.d.ts +1 -1
- package/dist/widgets/window/window.d.ts +13 -5
- package/dist/widgets/window/window.d.ts.map +1 -1
- package/dist/widgets/window/windowLook.d.ts +12 -0
- package/dist/widgets/window/windowLook.d.ts.map +1 -0
- package/package.json +11 -11
- package/dist/tool-B5AjewKP.js.map +0 -1
package/dist/attach.d.ts
CHANGED
|
@@ -7,10 +7,10 @@ export interface AttachHudOptions {
|
|
|
7
7
|
/** Resolved theme the widgets draw with. Defaults to the built-in theme's
|
|
8
8
|
* default mode; pass `useTheme().resolved` to follow a live theme. */
|
|
9
9
|
readonly theme?: ResolvedTheme;
|
|
10
|
-
/** What a widget's color sources resolve against: a theme, the
|
|
11
|
-
* numeric `
|
|
10
|
+
/** What a widget's color sources resolve against: a theme, the tint list a
|
|
11
|
+
* numeric `tint` indexes, and a palette — `useTheme()`'s value is one.
|
|
12
12
|
* Defaults to the built-in theme and its list, resolved against `theme`. */
|
|
13
|
-
readonly
|
|
13
|
+
readonly tints?: ColorSourceContext;
|
|
14
14
|
/**
|
|
15
15
|
* Where the text a widget draws without naming a family comes from.
|
|
16
16
|
*
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "./tool-
|
|
1
|
+
import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "./tool-8LVUdM5S.js";
|
|
2
2
|
import { createViewportLayer as f, pathFromD as p, screenToWorld as m, textCommandFromRuns as h, viewToTransform as g } from "@weasel-js/core";
|
|
3
3
|
import { clamp as _, identity as v, mat3 as y, multiply as b, pathFromD as x, rotateAboutPoint as S, roundRectPath as C, scale as w, translate as T } from "@weasel-js/geom";
|
|
4
4
|
import { expandVars as E, parseBoxShadow as D, resolveCurrentColor as O, tokenPx as k } from "@weasel-js/theme";
|
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-8LVUdM5S.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";
|
|
@@ -21,7 +21,7 @@ function u(e) {
|
|
|
21
21
|
} : void 0);
|
|
22
22
|
return {
|
|
23
23
|
theme: t?.resolved ?? r(i),
|
|
24
|
-
...t ? {
|
|
24
|
+
...t ? { tints: t } : {},
|
|
25
25
|
...e === void 0 ? {} : { font: e }
|
|
26
26
|
};
|
|
27
27
|
}, [
|
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","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.\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 ? {
|
|
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.\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 ? { tints: 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;CAanD,OAXAC,QAAgB;EACd,IAAMC,IAAMC,GAAW;EACvB,IAAI,CAACD,GAAK;EACV,IAAME,IAASV,EAAUQ,GAAKN,GAAKE,CAAa;EAEhD,OADAI,EAAI,cAAc,GACXE;CAIT,GAAG,CAACR,GAAKE,CAAa,CAAC,GAEhBF;AACT;AAKA,SAASG,EAAiB,GAAkD;CAC1E,IAAMM,IAAWC,EAAiB,GAE5BC,IAAS,OAAOC,KAAS,WAAWA,IAAO,KAAA,GAC3CC,IAAa,OAAOD,KAAS,WAAWA,EAAK,aAAa,KAAA,GAC1DE,IAAW,OAAOF,KAAS,WAAWA,EAAK,WAAW,KAAA;CAC5D,OAAOG,QAAc;EACnB,IAAMC,IAASL,MAAWE,MAAe,KAAA,KAAaC,MAAa,KAAA,IAAY;GAAE;GAAY;EAAS,IAAI,KAAA;EAC1G,OAAO;GACL,OAAOL,GAAU,YAAYQ,EAAaC,CAAW;GACrD,GAAIT,IAAW,EAAE,OAAOA,EAAS,IAAI,CAAC;GACtC,GAAIO,MAAW,KAAA,IAA+B,CAAC,IAApB,EAAE,MAAMA,EAAO;EAC5C;CACF,GAAG;EAACP;EAAUE;EAAQE;EAAYC;CAAQ,CAAC;AAC7C;AAiBA,SAAgBK,EACd,GACA,IAA0C,CAAC,GACtB;CACrB,IAAMjB,IAAgBC,EAAiBC,EAAQ,IAAI;CACnD,OAAOW,QACCnB,EAAsBI,GAAKE,CAAa,GAC9C,CAACF,GAAKE,CAAa,CACrB;AACF"}
|