@edv4h/usketch-plugin-mode7 0.2.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.
Files changed (42) hide show
  1. package/README.md +102 -0
  2. package/dist/index.d.ts +7 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +5 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/mode7-camera.d.ts +32 -0
  7. package/dist/mode7-camera.d.ts.map +1 -0
  8. package/dist/mode7-camera.js +56 -0
  9. package/dist/mode7-camera.js.map +1 -0
  10. package/dist/mode7-layers.d.ts +45 -0
  11. package/dist/mode7-layers.d.ts.map +1 -0
  12. package/dist/mode7-layers.js +112 -0
  13. package/dist/mode7-layers.js.map +1 -0
  14. package/dist/mode7-runtime.d.ts +14 -0
  15. package/dist/mode7-runtime.d.ts.map +1 -0
  16. package/dist/mode7-runtime.js +220 -0
  17. package/dist/mode7-runtime.js.map +1 -0
  18. package/dist/mode7-service.d.ts +50 -0
  19. package/dist/mode7-service.d.ts.map +1 -0
  20. package/dist/mode7-service.js +39 -0
  21. package/dist/mode7-service.js.map +1 -0
  22. package/dist/mode7-store.d.ts +74 -0
  23. package/dist/mode7-store.d.ts.map +1 -0
  24. package/dist/mode7-store.js +143 -0
  25. package/dist/mode7-store.js.map +1 -0
  26. package/dist/mode7-transform.d.ts +56 -0
  27. package/dist/mode7-transform.d.ts.map +1 -0
  28. package/dist/mode7-transform.js +123 -0
  29. package/dist/mode7-transform.js.map +1 -0
  30. package/dist/plugin.d.ts +27 -0
  31. package/dist/plugin.d.ts.map +1 -0
  32. package/dist/plugin.js +44 -0
  33. package/dist/plugin.js.map +1 -0
  34. package/dist/register-mode7-actions.d.ts +8 -0
  35. package/dist/register-mode7-actions.d.ts.map +1 -0
  36. package/dist/register-mode7-actions.js +88 -0
  37. package/dist/register-mode7-actions.js.map +1 -0
  38. package/dist/register-mode7-hud.d.ts +6 -0
  39. package/dist/register-mode7-hud.d.ts.map +1 -0
  40. package/dist/register-mode7-hud.js +130 -0
  41. package/dist/register-mode7-hud.js.map +1 -0
  42. package/package.json +49 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mode7-runtime.js","sourceRoot":"","sources":["../src/mode7-runtime.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAExF,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE/F,iDAAiD;AACjD,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAC;AACxC,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAC;AACxC,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAChD,MAAM,CAAC,MAAM,sBAAsB,GAAG,qBAAqB,CAAC;AAE5D,gFAAgF;AAChF,MAAM,UAAU,GAAG,MAAM,CAAC;AAE1B,6FAA6F;AAC7F,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B;;;;;;;;GAQG;AACH,SAAS,aAAa;IACrB,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IACjD,IAAI,IAAI,GAAuB,IAAI,CAAC;IACpC,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAe,CAAC;IACpC,KAAK,MAAM,EAAE,IAAI,QAAQ,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAC/D,MAAM,MAAM,GAAI,EAAkB,CAAC,aAAa,CAAC;QACjD,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;YAAE,SAAS;QAC1C,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACjB,MAAM,CAAC,GAAG,MAAM,CAAC,qBAAqB,EAAE,CAAC;QACzC,MAAM,IAAI,GAAG,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C;IACxE,IAAI,QAAQ;QAAE,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAE1D,2CAA2C;IAC3C,IAAI,EAAE,CAAC;IAEP,OAAO,GAAG,EAAE;QACX,QAAQ,EAAE,CAAC;QACX,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,OAAO,GAAG,IAAI,CAAC;QACf,WAAW,EAAE,CAAC;QACd,WAAW,EAAE,CAAC;QACd,IAAI,QAAQ;YAAE,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC7D,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;QACpC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;QACpC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;QACxC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,sBAAsB,CAAC,CAAC;IAC/C,CAAC,CAAC;AACH,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { type BoundingBox, type ServiceRegistry } from "@edv4h/usketch-shared";
2
+ import type { Camera } from "./mode7-camera.js";
3
+ import type { Look, Mode7Store } from "./mode7-store.js";
4
+ export interface Mode7Api {
5
+ /** Whether the 3D view is currently on. */
6
+ isActive(): boolean;
7
+ enable(): void;
8
+ disable(): void;
9
+ toggle(): void;
10
+ /** The current camera geometry. */
11
+ getCamera(): Camera;
12
+ setPitch(deg: number): void;
13
+ setYaw(deg: number): void;
14
+ setFov(px: number): void;
15
+ setHorizon(fraction: number): void;
16
+ /** Nudge camera fields by deltas (re-clamped). */
17
+ adjust(delta: Partial<Camera>): void;
18
+ /** The current appearance (sky / fog). */
19
+ getLook(): Look;
20
+ setSky(color: string): void;
21
+ setFog(density: number): void;
22
+ setFogColor(color: string): void;
23
+ /** Restore the camera + look to the plugin's configured defaults. */
24
+ reset(): void;
25
+ /** The layer ids currently rendered in 3D. */
26
+ getTiltLayers(): readonly string[];
27
+ /** Replace the whole set of tilted layer ids. */
28
+ setTiltLayers(ids: readonly string[]): void;
29
+ /** Add/remove one layer id from the tilted set. */
30
+ toggleTiltLayer(id: string): void;
31
+ /** Ground draw distance in canvas (world) units (`0` = unlimited). */
32
+ getDrawDistance(): number;
33
+ /** Set the ground draw distance in canvas units (`0` = unlimited; hides content beyond). */
34
+ setDrawDistance(distance: number): void;
35
+ /** Whether the flat-mode capture-frame overlay is shown. */
36
+ isCaptureFrameVisible(): boolean;
37
+ /** Show/hide the capture-frame overlay. */
38
+ setCaptureFrameVisible(show: boolean): void;
39
+ /** Flip the capture-frame overlay visibility. */
40
+ toggleCaptureFrame(): void;
41
+ /** The world rect captured at the last switch-on, or `null`. */
42
+ getCaptureRect(): BoundingBox | null;
43
+ /** Fire on any active/camera/look/tilt-layer/frame change. Returns an unsubscribe. */
44
+ onChange(listener: () => void): () => void;
45
+ }
46
+ export declare const mode7Service: import("@edv4h/usketch-shared").ServiceHandle<Mode7Api>;
47
+ export declare function createMode7Api(store: Mode7Store): Mode7Api;
48
+ /** Host accessor: `getMode7Api(app.services)?.toggle()`. Undefined when inactive. */
49
+ export declare function getMode7Api(services: ServiceRegistry): Mode7Api | undefined;
50
+ //# sourceMappingURL=mode7-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mode7-service.d.ts","sourceRoot":"","sources":["../src/mode7-service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,WAAW,EAAiB,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC9F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEzD,MAAM,WAAW,QAAQ;IACxB,2CAA2C;IAC3C,QAAQ,IAAI,OAAO,CAAC;IACpB,MAAM,IAAI,IAAI,CAAC;IACf,OAAO,IAAI,IAAI,CAAC;IA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AAM,IAAI,GAAG,MAAM,IAAI,CAAC;CAC3C;AAED,eAAO,MAAM,YAAY,yDAAkD,CAAC;AAE5E,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,QAAQ,CA4B1D;AAED,qFAAqF;AACrF,wBAAgB,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,QAAQ,GAAG,SAAS,CAE3E"}
@@ -0,0 +1,39 @@
1
+ // Host-facing API on the `ctx.services` seam (same convention as dashboard/window-
2
+ // system): thin, typed delegation to the reactive store so a host or another plugin
3
+ // can drive the Mode 7 view without the HUD.
4
+ import { defineService } from "@edv4h/usketch-shared";
5
+ export const mode7Service = defineService("usketch-plugin-mode7");
6
+ export function createMode7Api(store) {
7
+ return {
8
+ isActive: () => store.getState().active,
9
+ enable: () => store.setActive(true),
10
+ disable: () => store.setActive(false),
11
+ toggle: () => store.toggle(),
12
+ getCamera: () => store.getState().camera,
13
+ setPitch: (deg) => store.setCamera({ pitch: deg }),
14
+ setYaw: (deg) => store.setCamera({ yaw: deg }),
15
+ setFov: (px) => store.setCamera({ fov: px }),
16
+ setHorizon: (fraction) => store.setCamera({ horizon: fraction }),
17
+ adjust: (delta) => store.adjustCamera(delta),
18
+ getLook: () => store.getState().look,
19
+ setSky: (color) => store.setLook({ sky: color }),
20
+ setFog: (density) => store.setLook({ fog: density }),
21
+ setFogColor: (color) => store.setLook({ fogColor: color }),
22
+ reset: () => store.reset(),
23
+ getTiltLayers: () => store.getState().tiltLayers,
24
+ setTiltLayers: (ids) => store.setTiltLayers(ids),
25
+ toggleTiltLayer: (id) => store.toggleTiltLayer(id),
26
+ getDrawDistance: () => store.getState().drawDistance,
27
+ setDrawDistance: (distance) => store.setDrawDistance(distance),
28
+ isCaptureFrameVisible: () => store.getState().showCaptureFrame,
29
+ setCaptureFrameVisible: (show) => store.setCaptureFrame(show),
30
+ toggleCaptureFrame: () => store.toggleCaptureFrame(),
31
+ getCaptureRect: () => store.getState().captureRect,
32
+ onChange: (listener) => store.subscribe(listener),
33
+ };
34
+ }
35
+ /** Host accessor: `getMode7Api(app.services)?.toggle()`. Undefined when inactive. */
36
+ export function getMode7Api(services) {
37
+ return mode7Service.get(services);
38
+ }
39
+ //# sourceMappingURL=mode7-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mode7-service.js","sourceRoot":"","sources":["../src/mode7-service.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,oFAAoF;AACpF,6CAA6C;AAC7C,OAAO,EAAoB,aAAa,EAAwB,MAAM,uBAAuB,CAAC;AA+C9F,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAW,sBAAsB,CAAC,CAAC;AAE5E,MAAM,UAAU,cAAc,CAAC,KAAiB;IAC/C,OAAO;QACN,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,MAAM;QACvC,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC;QACnC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC;QACrC,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE;QAC5B,SAAS,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,MAAM;QACxC,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;QAClD,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;QAC9C,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;QAC5C,UAAU,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,OAAO,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EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,WAAW;QAClD,QAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC;KACjD,CAAC;AACH,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,WAAW,CAAC,QAAyB;IACpD,OAAO,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,74 @@
1
+ import type { BoundingBox } from "@edv4h/usketch-shared";
2
+ import { type Camera } from "./mode7-camera.js";
3
+ /** Appearance settings, independent of the camera geometry. */
4
+ export interface Look {
5
+ /** Sky backdrop color (CSS) painted behind the tilted plane. */
6
+ sky: string;
7
+ /** Fog density near the horizon, 0..1 (0 = no fog). */
8
+ fog: number;
9
+ /** Fog color (CSS). */
10
+ fogColor: string;
11
+ }
12
+ export declare const DEFAULT_LOOK: Look;
13
+ /** Default ground draw distance in canvas units: extends the ground a bit past the
14
+ * viewport so the 3D view opens on a proper receding plane (not just the box). */
15
+ export declare const DEFAULT_DRAW_DISTANCE = 1500;
16
+ /**
17
+ * Layers tilted by default: essentially everything on the board EXCEPT the persistent
18
+ * UI chrome that must stay flat/readable (vim status line / which-key / help, the side
19
+ * panel, the presentation overlay) — plus the plugin's own overlays + the HUD, which
20
+ * are always excluded from the picker. The set is runtime-selectable via the HUD, so
21
+ * this is only the starting selection. Ids not present on a given board are ignored.
22
+ */
23
+ export declare const DEFAULT_TILT_LAYER_IDS: readonly string[];
24
+ export interface Mode7State {
25
+ active: boolean;
26
+ camera: Camera;
27
+ look: Look;
28
+ /** Layer ids currently rendered in 3D (user-selectable at runtime). */
29
+ tiltLayers: string[];
30
+ /** How far the ground is drawn, in **canvas (world) units** measured forward from the
31
+ * near edge (`0` = unlimited / no clip; a positive value hides content beyond it). */
32
+ drawDistance: number;
33
+ /** Whether to draw the "capture frame" overlay in flat mode (HUD toggle). */
34
+ showCaptureFrame: boolean;
35
+ /**
36
+ * The world-space rectangle the 3D ground plane covers, snapshotted at the moment
37
+ * the view was last switched on (`null` before the first switch / seed). Shapes
38
+ * outside it don't appear in the initial 3D view — the frame makes that visible.
39
+ * The runtime sets this (it needs the canvas pixel size); the store only holds it.
40
+ */
41
+ captureRect: BoundingBox | null;
42
+ }
43
+ export interface Mode7Init {
44
+ active?: boolean;
45
+ camera?: Partial<Camera>;
46
+ look?: Partial<Look>;
47
+ tiltLayers?: readonly string[];
48
+ drawDistance?: number;
49
+ showCaptureFrame?: boolean;
50
+ }
51
+ export interface Mode7Store {
52
+ getState(): Mode7State;
53
+ subscribe(cb: () => void): () => void;
54
+ setActive(active: boolean): void;
55
+ toggle(): void;
56
+ setCamera(patch: Partial<Camera>): void;
57
+ adjustCamera(delta: Partial<Camera>): void;
58
+ setLook(patch: Partial<Look>): void;
59
+ /** Replace the whole set of tilted layer ids. */
60
+ setTiltLayers(ids: readonly string[]): void;
61
+ /** Add/remove one layer id from the tilted set. */
62
+ toggleTiltLayer(id: string): void;
63
+ /** Set the ground draw distance in canvas units (`0` = unlimited; clamped `>= 0`). */
64
+ setDrawDistance(distance: number): void;
65
+ /** Show/hide the flat-mode capture-frame overlay. */
66
+ setCaptureFrame(show: boolean): void;
67
+ /** Flip the capture-frame overlay visibility. */
68
+ toggleCaptureFrame(): void;
69
+ /** Store the captured world rect (called by the runtime; `null` clears it). */
70
+ setCaptureRect(rect: BoundingBox | null): void;
71
+ reset(): void;
72
+ }
73
+ export declare function createMode7Store(init?: Mode7Init): Mode7Store;
74
+ //# sourceMappingURL=mode7-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mode7-store.d.ts","sourceRoot":"","sources":["../src/mode7-store.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,KAAK,MAAM,EAA6C,MAAM,mBAAmB,CAAC;AAE3F,+DAA+D;AAC/D,MAAM,WAAW,IAAI;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EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAC3C,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACpC,iDAAiD;IACjD,aAAa,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IAC5C,mDAAmD;IACnD,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,sFAAsF;IACtF,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,qDAAqD;IACrD,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IACrC,iDAAiD;IACjD,kBAAkB,IAAI,IAAI,CAAC;IAC3B,+EAA+E;IAC/E,cAAc,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,IAAI,CAAC;IAC/C,KAAK,IAAI,IAAI,CAAC;CACd;AAED,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,SAAc,GAAG,UAAU,CA2FjE"}
@@ -0,0 +1,143 @@
1
+ import { clampCamera, DEFAULT_CAMERA, updateCamera } from "./mode7-camera.js";
2
+ export const DEFAULT_LOOK = { sky: "#0b1026", fog: 0.35, fogColor: "#0b1026" };
3
+ /** Default ground draw distance in canvas units: extends the ground a bit past the
4
+ * viewport so the 3D view opens on a proper receding plane (not just the box). */
5
+ export const DEFAULT_DRAW_DISTANCE = 1500;
6
+ /** Clamp a draw distance (canvas units, `>= 0`; non-finite / negative → 0 = unlimited). */
7
+ function clampDistance(n) {
8
+ if (!Number.isFinite(n) || n < 0)
9
+ return 0;
10
+ return n;
11
+ }
12
+ /**
13
+ * Layers tilted by default: essentially everything on the board EXCEPT the persistent
14
+ * UI chrome that must stay flat/readable (vim status line / which-key / help, the side
15
+ * panel, the presentation overlay) — plus the plugin's own overlays + the HUD, which
16
+ * are always excluded from the picker. The set is runtime-selectable via the HUD, so
17
+ * this is only the starting selection. Ids not present on a given board are ignored.
18
+ */
19
+ export const DEFAULT_TILT_LAYER_IDS = [
20
+ // backgrounds / content
21
+ "bg-grid",
22
+ "bg-dots",
23
+ "island-metaball",
24
+ "gpu-shapes",
25
+ "dom-shapes",
26
+ "usketch-plugin-dashboard:grid-overlay",
27
+ // shape-attached overlays (selection, connectors, editors) — follow the shapes
28
+ "comment-badges",
29
+ "connector-anchor-handles",
30
+ "__selection-foreground",
31
+ "connector-endpoints",
32
+ "connector-label-editor",
33
+ "usketch-plugin-shape-frame:title-editor",
34
+ "domain-connector-properties",
35
+ "unconfirmed-shapes-overlay",
36
+ // interaction / presence overlays anchored to the board
37
+ "vim-overlay",
38
+ "snap-guides",
39
+ "laser",
40
+ "freedraw-cursor",
41
+ "spotlight",
42
+ "follow-banner",
43
+ "whistle-indicator",
44
+ "voice-notes-indicator",
45
+ "transient",
46
+ "portal",
47
+ "usketch-presence-activity",
48
+ ];
49
+ export function createMode7Store(init = {}) {
50
+ const baseCamera = clampCamera({ ...DEFAULT_CAMERA, ...init.camera });
51
+ const baseLook = { ...DEFAULT_LOOK, ...init.look };
52
+ let state = {
53
+ active: init.active ?? false,
54
+ camera: baseCamera,
55
+ look: baseLook,
56
+ tiltLayers: [...(init.tiltLayers ?? DEFAULT_TILT_LAYER_IDS)],
57
+ drawDistance: clampDistance(init.drawDistance ?? DEFAULT_DRAW_DISTANCE),
58
+ showCaptureFrame: init.showCaptureFrame ?? false,
59
+ captureRect: null,
60
+ };
61
+ const listeners = new Set();
62
+ const notify = () => {
63
+ for (const l of listeners)
64
+ l();
65
+ };
66
+ return {
67
+ getState: () => state,
68
+ subscribe(cb) {
69
+ listeners.add(cb);
70
+ return () => {
71
+ listeners.delete(cb);
72
+ };
73
+ },
74
+ setActive(active) {
75
+ if (state.active === active)
76
+ return;
77
+ state = { ...state, active };
78
+ notify();
79
+ },
80
+ toggle() {
81
+ state = { ...state, active: !state.active };
82
+ notify();
83
+ },
84
+ setCamera(patch) {
85
+ state = { ...state, camera: updateCamera(state.camera, patch) };
86
+ notify();
87
+ },
88
+ adjustCamera(delta) {
89
+ state = {
90
+ ...state,
91
+ camera: updateCamera(state.camera, {
92
+ pitch: state.camera.pitch + (delta.pitch ?? 0),
93
+ yaw: state.camera.yaw + (delta.yaw ?? 0),
94
+ fov: state.camera.fov + (delta.fov ?? 0),
95
+ horizon: state.camera.horizon + (delta.horizon ?? 0),
96
+ }),
97
+ };
98
+ notify();
99
+ },
100
+ setLook(patch) {
101
+ state = { ...state, look: { ...state.look, ...patch } };
102
+ notify();
103
+ },
104
+ setTiltLayers(ids) {
105
+ state = { ...state, tiltLayers: [...new Set(ids)] };
106
+ notify();
107
+ },
108
+ toggleTiltLayer(id) {
109
+ const has = state.tiltLayers.includes(id);
110
+ state = {
111
+ ...state,
112
+ tiltLayers: has ? state.tiltLayers.filter((x) => x !== id) : [...state.tiltLayers, id],
113
+ };
114
+ notify();
115
+ },
116
+ setDrawDistance(distance) {
117
+ const d = clampDistance(distance);
118
+ if (state.drawDistance === d)
119
+ return;
120
+ state = { ...state, drawDistance: d };
121
+ notify();
122
+ },
123
+ setCaptureFrame(show) {
124
+ if (state.showCaptureFrame === show)
125
+ return;
126
+ state = { ...state, showCaptureFrame: show };
127
+ notify();
128
+ },
129
+ toggleCaptureFrame() {
130
+ state = { ...state, showCaptureFrame: !state.showCaptureFrame };
131
+ notify();
132
+ },
133
+ setCaptureRect(rect) {
134
+ state = { ...state, captureRect: rect };
135
+ notify();
136
+ },
137
+ reset() {
138
+ state = { ...state, camera: baseCamera, look: baseLook };
139
+ notify();
140
+ },
141
+ };
142
+ }
143
+ //# sourceMappingURL=mode7-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mode7-store.js","sourceRoot":"","sources":["../src/mode7-store.ts"],"names":[],"mappings":"AAKA,OAAO,EAAe,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAY3F,MAAM,CAAC,MAAM,YAAY,GAAS,EAAE,GAAG,EAAE,SAAS,EAAE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,EAAE,CAAC,EAAE,CAAC;YACtC,MAAM,EAAE,CAAC;QACV,CAAC;QACD,eAAe,CAAC,IAAI;YACnB,IAAI,KAAK,CAAC,gBAAgB,KAAK,IAAI;gBAAE,OAAO;YAC5C,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC;YAC7C,MAAM,EAAE,CAAC;QACV,CAAC;QACD,kBAAkB;YACjB,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,gBAAgB,EAAE,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC;YAChE,MAAM,EAAE,CAAC;QACV,CAAC;QACD,cAAc,CAAC,IAAI;YAClB,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;YACxC,MAAM,EAAE,CAAC;QACV,CAAC;QACD,KAAK;YACJ,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;YACzD,MAAM,EAAE,CAAC;QACV,CAAC;KACD,CAAC;AACH,CAAC"}
@@ -0,0 +1,56 @@
1
+ import type { Camera } from "./mode7-camera.js";
2
+ export interface TiltTransform {
3
+ /** `transform` for a tilted layer wrapper (includes its own perspective). */
4
+ transform: string;
5
+ /** `transform-origin` — pivots the tilt about the horizon line. */
6
+ transformOrigin: string;
7
+ }
8
+ /** The full CSS transform (perspective + rotate) for a tilted layer wrapper. */
9
+ export declare function tiltTransform(cam: Camera): TiltTransform;
10
+ /**
11
+ * Sky backdrop (painted behind the tilted plane): a vertical gradient from the sky
12
+ * color at the top down to a paler haze that fades out smoothly ACROSS the horizon,
13
+ * so the ground appears to dissolve into a hazy sky rather than meeting a hard line.
14
+ * Fully transparent a little below the horizon (the near ground shows through).
15
+ */
16
+ export declare function skyBackground(sky: string, horizon: number): string;
17
+ /**
18
+ * Fog overlay (painted in front of the plane): a haze that FADES IN from a little
19
+ * above the horizon, peaks right at it, and clears toward the bottom (the camera).
20
+ * The soft top edge (above the horizon) is what covers the ground plane's far edge,
21
+ * hiding the seam; the fade to the bottom sells atmospheric depth. `density` 0..1
22
+ * scales the peak alpha; 0 disables it entirely.
23
+ */
24
+ export declare function fogBackground(color: string, density: number, horizon: number): string;
25
+ /** Peak fog opacity for the overlay element (kept separate so 0 density → no paint). */
26
+ export declare function fogOpacity(density: number): number;
27
+ /**
28
+ * The `clip-path` for the tilted layer wrappers. The tilt uses `overflow:visible` to
29
+ * keep the 3D intact, which would otherwise let content float PAST the grid; the clip
30
+ * bounds the tilted content instead.
31
+ *
32
+ * `distance` is the draw distance in **canvas/world units** measured forward from the
33
+ * near edge (bottom of the viewport). `distance <= 0` means "auto": clip exactly to the
34
+ * box (`inset(0)` — nothing floats past the grid, no overscan). A positive `distance`
35
+ * maps to `distance * zoom` screen px at the bottom of the wrapper box:
36
+ * - within the box (`distance*zoom < height`) → positive inset (a closer cutoff);
37
+ * - beyond the box (`distance*zoom > height`) → NEGATIVE inset, i.e. the clip extends
38
+ * above the box so content farther than the viewport is drawn. The background grid
39
+ * must be extended to match (see {@link drawDistanceOverscanPx}) or that far content
40
+ * would float; `clip-path` keeps the 3D tilt intact (unlike `overflow`, flattening).
41
+ */
42
+ export declare function drawDistanceClip(distance: number, zoom: number, viewportHeightPx: number): string;
43
+ /**
44
+ * The px the background grid must extend ABOVE/BEYOND the viewport box to stay under the
45
+ * content that {@link drawDistanceClip} reveals for a draw `distance` larger than the
46
+ * viewport. `0` when the distance is auto/within the box (no extension needed). This is
47
+ * driven into the grid via the `bg-grid:set-overscan` event so grid + shapes end together.
48
+ */
49
+ export declare function drawDistanceOverscanPx(distance: number, zoom: number, viewportHeightPx: number): number;
50
+ /**
51
+ * Wrap a CSS color into an rgba() with the given alpha. Handles #rgb/#rrggbb; any
52
+ * other color string is passed through `color-mix` with transparent so named/hsl
53
+ * colors still fade (falls back to the raw color if color-mix is unsupported).
54
+ */
55
+ export declare function rgba(color: string, alpha: number): string;
56
+ //# sourceMappingURL=mode7-transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mode7-transform.d.ts","sourceRoot":"","sources":["../src/mode7-transform.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,WAAW,aAAa;IAC7B,6EAA6E;IAC7E,SAAS,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,eAAe,EAAE,MAAM,CAAC;CACxB;AAED,gFAAgF;AAChF,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAKxD;AAUD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAMlE;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAKrF;AAED,wFAAwF;AACxF,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAcjG;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACrC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,MAAM,GACtB,MAAM,CAIR;AAuBD;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAYzD"}
@@ -0,0 +1,123 @@
1
+ /** The full CSS transform (perspective + rotate) for a tilted layer wrapper. */
2
+ export function tiltTransform(cam) {
3
+ return {
4
+ transform: `perspective(${round(cam.fov)}px) rotateX(${round(cam.pitch)}deg) rotateZ(${round(cam.yaw)}deg)`,
5
+ transformOrigin: `50% ${round(cam.horizon * 100)}%`,
6
+ };
7
+ }
8
+ /**
9
+ * Vertical blend band (in % of viewport height) straddling the horizon. The sky and
10
+ * fog gradients fade THROUGH the horizon over this band instead of stopping hard at
11
+ * it — otherwise the tilted plane's far edge (layers only paint the finite 2D
12
+ * viewport rect) shows as a crisp horizontal seam. A soft band hazes that edge away.
13
+ */
14
+ const HORIZON_SOFT = 8;
15
+ /**
16
+ * Sky backdrop (painted behind the tilted plane): a vertical gradient from the sky
17
+ * color at the top down to a paler haze that fades out smoothly ACROSS the horizon,
18
+ * so the ground appears to dissolve into a hazy sky rather than meeting a hard line.
19
+ * Fully transparent a little below the horizon (the near ground shows through).
20
+ */
21
+ export function skyBackground(sky, horizon) {
22
+ const h = round(clamp01(horizon) * 100);
23
+ const mid = round(Math.min(h * 0.5, h - HORIZON_SOFT));
24
+ const hazeTop = round(clamp(h - HORIZON_SOFT, 0, 100));
25
+ const clearBottom = round(clamp(h + HORIZON_SOFT, 0, 100));
26
+ return `linear-gradient(to bottom, ${sky} 0%, ${sky} ${mid}%, ${haze(sky)} ${hazeTop}%, transparent ${clearBottom}%)`;
27
+ }
28
+ /**
29
+ * Fog overlay (painted in front of the plane): a haze that FADES IN from a little
30
+ * above the horizon, peaks right at it, and clears toward the bottom (the camera).
31
+ * The soft top edge (above the horizon) is what covers the ground plane's far edge,
32
+ * hiding the seam; the fade to the bottom sells atmospheric depth. `density` 0..1
33
+ * scales the peak alpha; 0 disables it entirely.
34
+ */
35
+ export function fogBackground(color, density, horizon) {
36
+ const h = round(clamp01(horizon) * 100);
37
+ const a = clamp01(density);
38
+ const fadeInTop = round(clamp(h - HORIZON_SOFT, 0, 100));
39
+ return `linear-gradient(to bottom, transparent ${fadeInTop}%, ${rgba(color, a)} ${h}%, transparent 100%)`;
40
+ }
41
+ /** Peak fog opacity for the overlay element (kept separate so 0 density → no paint). */
42
+ export function fogOpacity(density) {
43
+ return clamp01(density);
44
+ }
45
+ /**
46
+ * The `clip-path` for the tilted layer wrappers. The tilt uses `overflow:visible` to
47
+ * keep the 3D intact, which would otherwise let content float PAST the grid; the clip
48
+ * bounds the tilted content instead.
49
+ *
50
+ * `distance` is the draw distance in **canvas/world units** measured forward from the
51
+ * near edge (bottom of the viewport). `distance <= 0` means "auto": clip exactly to the
52
+ * box (`inset(0)` — nothing floats past the grid, no overscan). A positive `distance`
53
+ * maps to `distance * zoom` screen px at the bottom of the wrapper box:
54
+ * - within the box (`distance*zoom < height`) → positive inset (a closer cutoff);
55
+ * - beyond the box (`distance*zoom > height`) → NEGATIVE inset, i.e. the clip extends
56
+ * above the box so content farther than the viewport is drawn. The background grid
57
+ * must be extended to match (see {@link drawDistanceOverscanPx}) or that far content
58
+ * would float; `clip-path` keeps the 3D tilt intact (unlike `overflow`, flattening).
59
+ */
60
+ export function drawDistanceClip(distance, zoom, viewportHeightPx) {
61
+ if (!(distance > 0) || !(zoom > 0) || !(viewportHeightPx > 0)) {
62
+ return "inset(0% 0% 0% 0%)"; // auto → clip to the box
63
+ }
64
+ const bandPx = distance * zoom;
65
+ if (bandPx <= viewportHeightPx) {
66
+ // Within the viewport: keep only the near band; sides stay at the box.
67
+ return `inset(${round((1 - bandPx / viewportHeightPx) * 100)}% 0% 0% 0%)`;
68
+ }
69
+ // Beyond the viewport: extend equally on ALL sides so the far ground fans out
70
+ // (not just a box-wide strip). The grid overscans to match; the canvas container
71
+ // clips whatever runs off-screen. Negative inset grows the clip region past the box.
72
+ const over = round(bandPx - viewportHeightPx);
73
+ return `inset(${-over}px ${-over}px ${-over}px ${-over}px)`;
74
+ }
75
+ /**
76
+ * The px the background grid must extend ABOVE/BEYOND the viewport box to stay under the
77
+ * content that {@link drawDistanceClip} reveals for a draw `distance` larger than the
78
+ * viewport. `0` when the distance is auto/within the box (no extension needed). This is
79
+ * driven into the grid via the `bg-grid:set-overscan` event so grid + shapes end together.
80
+ */
81
+ export function drawDistanceOverscanPx(distance, zoom, viewportHeightPx) {
82
+ if (!(distance > 0) || !(zoom > 0) || !(viewportHeightPx > 0))
83
+ return 0;
84
+ const bandPx = distance * zoom;
85
+ return bandPx > viewportHeightPx ? Math.ceil(bandPx - viewportHeightPx) : 0;
86
+ }
87
+ // ── helpers ──
88
+ function round(n) {
89
+ return Math.round(n * 1000) / 1000;
90
+ }
91
+ function clamp01(n) {
92
+ if (!Number.isFinite(n))
93
+ return 0;
94
+ return Math.min(1, Math.max(0, n));
95
+ }
96
+ function clamp(n, lo, hi) {
97
+ if (!Number.isFinite(n))
98
+ return lo;
99
+ return Math.min(hi, Math.max(lo, n));
100
+ }
101
+ /** A translucent version of the sky color for the horizon haze band. */
102
+ function haze(sky) {
103
+ return rgba(sky, 0.35);
104
+ }
105
+ /**
106
+ * Wrap a CSS color into an rgba() with the given alpha. Handles #rgb/#rrggbb; any
107
+ * other color string is passed through `color-mix` with transparent so named/hsl
108
+ * colors still fade (falls back to the raw color if color-mix is unsupported).
109
+ */
110
+ export function rgba(color, alpha) {
111
+ const a = clamp01(alpha);
112
+ const hex = color.trim().match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/);
113
+ if (hex) {
114
+ const h = hex[1];
115
+ const full = h.length === 3 ? h.replace(/(.)/g, "$1$1") : h;
116
+ const r = Number.parseInt(full.slice(0, 2), 16);
117
+ const g = Number.parseInt(full.slice(2, 4), 16);
118
+ const b = Number.parseInt(full.slice(4, 6), 16);
119
+ return `rgba(${r}, ${g}, ${b}, ${a})`;
120
+ }
121
+ return `color-mix(in srgb, ${color} ${round(a * 100)}%, transparent)`;
122
+ }
123
+ //# sourceMappingURL=mode7-transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mode7-transform.js","sourceRoot":"","sources":["../src/mode7-transform.ts"],"names":[],"mappings":"AAsBA,gFAAgF;AAChF,MAAM,UAAU,aAAa,CAAC,GAAW;IACxC,OAAO;QACN,SAAS,EAAE,eAAe,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,eAAe,KA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,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5D,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAChD,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAChD,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAChD,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;IACvC,CAAC;IACD,OAAO,sBAAsB,KAAK,IAAI,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,iBAAiB,CAAC;AACvE,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { UsketchPlugin } from "@edv4h/usketch-shared";
2
+ import type { Camera } from "./mode7-camera.js";
3
+ import { type Look } from "./mode7-store.js";
4
+ import { type Mode7Shortcuts } from "./register-mode7-actions.js";
5
+ export interface Mode7PluginOptions {
6
+ /** Start with the 3D view already on (default `false`). */
7
+ enabledInitially?: boolean;
8
+ /** Initial camera geometry (merged over the defaults). */
9
+ camera?: Partial<Camera>;
10
+ /** Initial appearance (sky / fog). */
11
+ look?: Partial<Look>;
12
+ /** Initial set of tilted layer ids (default: Shapes + backgrounds). The set is
13
+ * also selectable at runtime via the HUD layer picker. */
14
+ tiltLayerIds?: string[];
15
+ /** Layer ids the runtime picker must never offer (in addition to the plugin's own
16
+ * overlays and the HUD, which are always excluded). */
17
+ skipLayerIds?: string[];
18
+ /** Ground draw distance in canvas (world) units (`0` = auto / clip to the viewport;
19
+ * larger values extend the ground past it; default `1500`). */
20
+ drawDistance?: number;
21
+ /** Start with the flat-mode capture-frame overlay shown (default `false`). */
22
+ showCaptureFrame?: boolean;
23
+ /** Keyboard shortcut bindings (opt-in; no defaults). */
24
+ shortcuts?: Mode7Shortcuts;
25
+ }
26
+ export declare function createMode7Plugin(options?: Mode7PluginOptions): UsketchPlugin;
27
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAiB,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAShD,OAAO,EAAoB,KAAK,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,6BAA6B,CAAC;AAGxF,MAAM,WAAW,kBAAkB;IAClC,2DAA2D;IAC3D,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,0DAA0D;IAC1D,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,sCAAsC;IACtC,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB;+DAC2D;IAC3D,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB;4DACwD;IACxD,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB;oEACgE;IAChE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8EAA8E;IAC9E,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,wDAAwD;IACxD,SAAS,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,kBAAuB,GAAG,aAAa,CAuCjF"}
package/dist/plugin.js ADDED
@@ -0,0 +1,44 @@
1
+ import { CAPTURE_FRAME_LAYER_ID, CAPTURE_LAYER_ID, FOG_LAYER_ID, SKY_LAYER_ID, setupMode7Runtime, } from "./mode7-runtime.js";
2
+ import { createMode7Api, mode7Service } from "./mode7-service.js";
3
+ import { createMode7Store } from "./mode7-store.js";
4
+ import { registerMode7Actions } from "./register-mode7-actions.js";
5
+ import { registerMode7Hud } from "./register-mode7-hud.js";
6
+ export function createMode7Plugin(options = {}) {
7
+ const store = createMode7Store({
8
+ active: options.enabledInitially ?? false,
9
+ camera: options.camera,
10
+ look: options.look,
11
+ tiltLayers: options.tiltLayerIds,
12
+ drawDistance: options.drawDistance,
13
+ showCaptureFrame: options.showCaptureFrame,
14
+ });
15
+ const api = createMode7Api(store);
16
+ // Layers the picker must never tilt (tilting the HUD or our own overlays makes
17
+ // no sense and could hide the very controls used to turn the view off).
18
+ const excludedLayerIds = [
19
+ SKY_LAYER_ID,
20
+ FOG_LAYER_ID,
21
+ CAPTURE_LAYER_ID,
22
+ CAPTURE_FRAME_LAYER_ID,
23
+ "debug-hud",
24
+ ...(options.skipLayerIds ?? []),
25
+ ];
26
+ return {
27
+ id: "usketch-plugin-mode7",
28
+ name: "Mode 7 (3D ビュー)",
29
+ setup(ctx) {
30
+ const stopRuntime = setupMode7Runtime(ctx, store);
31
+ const stopActions = registerMode7Actions(ctx, api, options.shortcuts);
32
+ const stopHud = registerMode7Hud(ctx, api, store, excludedLayerIds);
33
+ // Provide the service LAST so a failed earlier step can't leak it.
34
+ const unprovideService = mode7Service.provide(ctx.services, api);
35
+ return () => {
36
+ unprovideService();
37
+ stopHud();
38
+ stopActions();
39
+ stopRuntime();
40
+ };
41
+ },
42
+ };
43
+ }
44
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAQA,OAAO,EACN,sBAAsB,EACtB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,iBAAiB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAa,MAAM,kBAAkB,CAAC;A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V,WAAW,EAAE,CAAC;gBACd,WAAW,EAAE,CAAC;YACf,CAAC,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { PluginContext } from "@edv4h/usketch-shared";
2
+ import type { Mode7Api } from "./mode7-service.js";
3
+ export type Mode7ActionKey = "toggle" | "pitch-up" | "pitch-down" | "yaw-left" | "yaw-right" | "fov-narrow" | "fov-wide" | "reset" | "capture-frame";
4
+ /** Host shortcut overrides: a combo string binds the action; omitting a key leaves
5
+ * it unbound (there are no built-in defaults). `null` is also treated as unbound. */
6
+ export type Mode7Shortcuts = Partial<Record<Mode7ActionKey, string | null>>;
7
+ export declare function registerMode7Actions(ctx: PluginContext, api: Mode7Api, shortcuts?: Mode7Shortcuts): () => void;
8
+ //# sourceMappingURL=register-mode7-actions.d.ts.map