@weasel-js/hud 1.9.4 → 1.10.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 +1 -1
- package/dist/attach.d.ts +7 -10
- package/dist/attach.d.ts.map +1 -1
- package/dist/colors.d.ts +9 -0
- package/dist/colors.d.ts.map +1 -0
- package/dist/hud.d.ts.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +131 -100
- package/dist/index.js.map +1 -1
- package/dist/loupe/contentWatch.d.ts +16 -0
- package/dist/loupe/contentWatch.d.ts.map +1 -0
- package/dist/loupe/createLoupe.d.ts +11 -1
- package/dist/loupe/createLoupe.d.ts.map +1 -1
- package/dist/loupe/pointerAim.d.ts +15 -0
- package/dist/loupe/pointerAim.d.ts.map +1 -0
- package/dist/react/index.js +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/useHud.d.ts.map +1 -1
- package/dist/{tool-BLDCwvTF.js → tool-Dq_D9qpD.js} +377 -363
- package/dist/tool-Dq_D9qpD.js.map +1 -0
- package/dist/tool.d.ts +0 -3
- package/dist/tool.d.ts.map +1 -1
- package/dist/widget.d.ts +10 -11
- package/dist/widget.d.ts.map +1 -1
- package/dist/widgets/image.d.ts +6 -0
- package/dist/widgets/image.d.ts.map +1 -1
- package/dist/widgets/rect.d.ts +6 -0
- package/dist/widgets/rect.d.ts.map +1 -1
- package/dist/widgets/window/window.d.ts +4 -3
- package/dist/widgets/window/window.d.ts.map +1 -1
- package/package.json +8 -7
- package/dist/tool-BLDCwvTF.js.map +0 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface Point {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Aims a lens from the pointer moving over `input`, in CSS px relative to it. A gesture that begins where
|
|
7
|
+
* `holds` answers true freezes the aim until it ends: the lens camera follows the aim, so re-aiming mid-drag
|
|
8
|
+
* would move the world under the pointer. Returns a detach.
|
|
9
|
+
*/
|
|
10
|
+
export declare function followPointer(input: HTMLElement, lens: {
|
|
11
|
+
aimAt(p: Point): void;
|
|
12
|
+
holds(p: Point): boolean;
|
|
13
|
+
}): () => void;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=pointerAim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointerAim.d.ts","sourceRoot":"","sources":["../../src/loupe/pointerAim.ts"],"names":[],"mappings":"AAAA,UAAU,KAAK;IAAG,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE;AAIxC;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE;IAAE,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IAAC,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,OAAO,CAAA;CAAE,GACxD,MAAM,IAAI,CAsBZ"}
|
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-Dq_D9qpD.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";
|
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
|
|
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 ? { tones: 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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHud.d.ts","sourceRoot":"","sources":["../../src/react/useHud.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,KAAK,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAG/E;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CACpB,SAAS,CAAC,EAAE;IAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAAA;CAAE,EAClD,OAAO,GAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAM,GAC3C,GAAG,
|
|
1
|
+
{"version":3,"file":"useHud.d.ts","sourceRoot":"","sources":["../../src/react/useHud.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,KAAK,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAG/E;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CACpB,SAAS,CAAC,EAAE;IAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAAA;CAAE,EAClD,OAAO,GAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAM,GAC3C,GAAG,CAgBL;AAqBD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,CAAC,EAAE,GAAG,EACT,OAAO,GAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAM,GAC3C,mBAAmB,CAMrB"}
|