@weasel-js/labkit 1.3.0 → 1.4.0-pre.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/README.md +226 -55
- package/dist/_dts/CanvasStackContext-LnCfqNBA.d.ts +42 -0
- package/dist/_dts/DrawCommand-B3bskUsC.d.ts +564 -0
- package/dist/_dts/{PrefsForm-BYa6cWnO.d.ts → PrefsForm-BkUJZx0A.d.ts} +4 -1
- package/dist/_dts/fitViewToBounds-dZ2UDB6e.d.ts +21 -0
- package/dist/_dts/frac-C-2c72Ij.d.ts +735 -0
- package/dist/_dts/index-BDVzvRzQ.d.ts +236 -0
- package/dist/_dts/shapeKinds-Cx_rxwsa.d.ts +87 -0
- package/dist/_dts/{DrawCommand-DBB45NfN.d.ts → types-C-gh9Ap-.d.ts} +1 -582
- package/dist/_dts/{types-DCGEcMO_.d.ts → types-D6s4b7if.d.ts} +1 -1
- package/dist/_dts/{types-1Sdxy_Pv.d.ts → types-DYMaEvM5.d.ts} +26 -1
- package/dist/_dts/{useTrialState-CsGMjhu9.d.ts → useTrialState-gmMvZqPc.d.ts} +7 -2
- package/dist/canvas/index.d.ts +110 -26
- package/dist/canvas/index.js +5 -4
- package/dist/chrome/index.d.ts +9 -6
- package/dist/chrome/index.js +6 -6
- package/dist/chunk-2AYGEN57.js +32 -0
- package/dist/chunk-2AYGEN57.js.map +1 -0
- package/dist/chunk-6OEYTYML.js +669 -0
- package/dist/chunk-6OEYTYML.js.map +1 -0
- package/dist/{chunk-BMW4TDP5.js → chunk-AE5CNVRU.js} +3 -3
- package/dist/{chunk-BMW4TDP5.js.map → chunk-AE5CNVRU.js.map} +1 -1
- package/dist/{chunk-CPUJ3QXL.js → chunk-CQLQPQ4P.js} +2 -2
- package/dist/chunk-CQLQPQ4P.js.map +1 -0
- package/dist/chunk-CTRKTLYZ.js +33 -0
- package/dist/chunk-CTRKTLYZ.js.map +1 -0
- package/dist/chunk-E2UQVZ44.js +458 -0
- package/dist/chunk-E2UQVZ44.js.map +1 -0
- package/dist/{chunk-LGKRIUSW.js → chunk-ESIQNQ6K.js} +32 -7
- package/dist/chunk-ESIQNQ6K.js.map +1 -0
- package/dist/{chunk-JDROYQM3.js → chunk-HHGVISVZ.js} +130 -131
- package/dist/chunk-HHGVISVZ.js.map +1 -0
- package/dist/{chunk-BDJXIBRZ.js → chunk-HMFODCOX.js} +126 -29
- package/dist/chunk-HMFODCOX.js.map +1 -0
- package/dist/{chunk-QCICIHEO.js → chunk-L5QJOOLV.js} +839 -320
- package/dist/chunk-L5QJOOLV.js.map +1 -0
- package/dist/{chunk-3XXPU73K.js → chunk-M75ZU6ZZ.js} +9 -7
- package/dist/chunk-M75ZU6ZZ.js.map +1 -0
- package/dist/{chunk-QRYPXSGP.js → chunk-QB5SM4BM.js} +16 -8
- package/dist/chunk-QB5SM4BM.js.map +1 -0
- package/dist/chunk-RBGKL7NF.js +7128 -0
- package/dist/chunk-RBGKL7NF.js.map +1 -0
- package/dist/{chunk-WTI26YTM.js → chunk-TO2FUOKF.js} +40 -13
- package/dist/chunk-TO2FUOKF.js.map +1 -0
- package/dist/{chunk-4TMMVIDM.js → chunk-XJ6N32QP.js} +50 -6
- package/dist/chunk-XJ6N32QP.js.map +1 -0
- package/dist/controls/index.d.ts +4 -28
- package/dist/controls/index.js +3 -3
- package/dist/dragdrop/index.d.ts +9 -5
- package/dist/dragdrop/index.js +3 -3
- package/dist/index.d.ts +517 -234
- package/dist/index.js +1769 -143
- package/dist/index.js.map +1 -1
- package/dist/layers/index.d.ts +6 -5
- package/dist/layers/index.js +3 -3
- package/dist/loupe/index.d.ts +187 -0
- package/dist/loupe/index.js +7 -0
- package/dist/loupe/index.js.map +1 -0
- package/dist/passthrough/weasel-canvas.d.ts +3 -1
- package/dist/passthrough/weasel-canvas.js +1 -1
- package/dist/passthrough/weasel-ui.d.ts +138 -91
- package/dist/passthrough/weasel-ui.js +2 -2
- package/dist/primitives/index.d.ts +3 -1
- package/dist/primitives/index.js +5 -5
- package/dist/state/index.d.ts +3 -3
- package/dist/state/index.js +2 -2
- package/dist/styles.css +229 -1
- package/dist/surface/index.d.ts +18 -2
- package/dist/surface/index.js +2 -2
- package/dist/ui/layers/index.js +2 -2
- package/dist/undo/index.d.ts +5 -4
- package/package.json +14 -7
- package/src/annotations/AnnotationOverlay.tsx +205 -0
- package/src/annotations/AnnotationTargets.tsx +37 -0
- package/src/annotations/Annotations.less +129 -0
- package/src/annotations/Annotations.meaning.test.tsx +111 -0
- package/src/annotations/Annotations.overlay.test.tsx +142 -0
- package/src/annotations/AnnotationsContext.ts +49 -0
- package/src/annotations/ExportMenu.test.tsx +86 -0
- package/src/annotations/ExportMenu.tsx +182 -0
- package/src/annotations/MarkList.tsx +75 -0
- package/src/annotations/capture.test.ts +140 -0
- package/src/annotations/capture.ts +237 -0
- package/src/annotations/drawOne.test.ts +56 -0
- package/src/annotations/drawOne.ts +47 -0
- package/src/annotations/frac.test.ts +59 -0
- package/src/annotations/frac.ts +66 -0
- package/src/annotations/history.test.ts +82 -0
- package/src/annotations/history.ts +118 -0
- package/src/annotations/index.ts +37 -0
- package/src/annotations/paint.test.ts +125 -0
- package/src/annotations/paint.ts +130 -0
- package/src/annotations/staleness.test.ts +56 -0
- package/src/annotations/staleness.ts +41 -0
- package/src/annotations/store.test.ts +247 -0
- package/src/annotations/store.ts +347 -0
- package/src/annotations/svgNodes.test.ts +77 -0
- package/src/annotations/svgNodes.ts +74 -0
- package/src/annotations/toolMap.test.ts +36 -0
- package/src/annotations/toolMap.ts +54 -0
- package/src/annotations/types.ts +229 -0
- package/src/annotations/view.test.ts +37 -0
- package/src/annotations/view.ts +40 -0
- package/src/canvas/AGENTS.md +55 -5
- package/src/canvas/CanvasStack.test.tsx +27 -1
- package/src/canvas/CanvasStack.tsx +29 -4
- package/src/canvas/CanvasStackContext.ts +23 -4
- package/src/canvas/camera.test.ts +78 -0
- package/src/canvas/camera.ts +62 -0
- package/src/canvas/canvasCoords.test.ts +26 -0
- package/src/canvas/canvasCoords.ts +20 -7
- package/src/canvas/index.ts +16 -1
- package/src/canvas/useLayerScheduler.ts +7 -3
- package/src/canvas/usePanZoom.test.ts +36 -5
- package/src/canvas/usePanZoom.ts +20 -15
- package/src/canvas/worldSpec.test.ts +63 -0
- package/src/canvas/worldSpec.ts +48 -0
- package/src/chrome/builtins.test.ts +31 -1
- package/src/chrome/builtins.tsx +63 -19
- package/src/chrome/regions/PaletteRegion.test.tsx +22 -1
- package/src/chrome/regions/PaletteRegion.tsx +4 -0
- package/src/chrome/regions/SidebarRegion.tsx +37 -13
- package/src/chrome/regions/ToolbarRegion.tsx +2 -1
- package/src/chrome/regions/ViewportRegion.tsx +9 -1
- package/src/chrome/regions/regions.test.tsx +6 -1
- package/src/chrome/types.ts +20 -0
- package/src/controls/ControlPanel.test.tsx +38 -0
- package/src/controls/ControlPanel.tsx +50 -3
- package/src/dragdrop/DragDropRuntime.tsx +8 -2
- package/src/dragdrop/dragDrop.test.tsx +29 -2
- package/src/index.test.ts +23 -0
- package/src/index.ts +93 -4
- package/src/instrument/SineWave.smoke.test.tsx +1 -0
- package/src/instrument/types.ts +24 -1
- package/src/lab/Lab.surface.test.tsx +162 -0
- package/src/lab/Lab.tsx +102 -17
- package/src/lab/Lab.undock.test.tsx +85 -0
- package/src/lab/LabFullChrome.stories.tsx +20 -0
- package/src/lab/LabShell.less +11 -0
- package/src/lab/Workspace.less +73 -0
- package/src/lab/Workspace.surface.test.tsx +2 -0
- package/src/lab/Workspace.tsx +97 -8
- package/src/lab/index.ts +1 -1
- package/src/lab/panelHost.ts +37 -0
- package/src/loupe/AGENTS.md +49 -0
- package/src/loupe/CanvasLoupe.tsx +83 -0
- package/src/loupe/DomLoupe.tsx +62 -0
- package/src/loupe/Loupe.less +38 -0
- package/src/loupe/LoupeBubble.tsx +32 -0
- package/src/loupe/TrialLoupe.tsx +93 -0
- package/src/loupe/canvasLens.test.ts +205 -0
- package/src/loupe/canvasLens.ts +141 -0
- package/src/loupe/index.ts +19 -0
- package/src/loupe/types.test.ts +29 -0
- package/src/loupe/types.ts +90 -0
- package/src/loupe/useHostSize.ts +30 -0
- package/src/loupe/useLoupe.test.tsx +197 -0
- package/src/loupe/useLoupe.ts +189 -0
- package/src/passthrough/weasel-ui.ts +3 -0
- package/src/primitives/FloatingPanel.test.tsx +76 -1
- package/src/primitives/FloatingPanel.tsx +19 -3
- package/src/primitives/ScaleIndicator.test.tsx +7 -2
- package/src/primitives/Sidebar.less +18 -0
- package/src/primitives/Toolbar.less +8 -0
- package/src/primitives/Toolbar.tsx +5 -0
- package/src/primitives/useRovingTabIndex.test.ts +21 -0
- package/src/primitives/useRovingTabIndex.ts +26 -17
- package/src/state/document.test.ts +23 -0
- package/src/state/document.ts +14 -2
- package/src/state/index.ts +2 -0
- package/src/state/store.test.ts +24 -0
- package/src/state/store.ts +35 -1
- package/src/state/types.ts +11 -0
- package/src/state/undock.test.ts +40 -0
- package/src/state/undock.ts +39 -0
- package/src/styles.less +2 -0
- package/src/surface/SurfaceContext.ts +4 -0
- package/src/surface/index.ts +8 -3
- package/src/surface/useSurfaceTile.test.tsx +2 -0
- package/src/surface/useSurfaceTile.ts +7 -1
- package/src/surface/useTiledSurface.test.tsx +58 -0
- package/src/surface/useTiledSurface.ts +38 -3
- package/src/trial/Trial.annotations.persist.test.tsx +166 -0
- package/src/trial/Trial.annotations.test.tsx +121 -0
- package/src/trial/Trial.canvas.test.tsx +76 -1
- package/src/trial/Trial.less +19 -0
- package/src/trial/Trial.loupe.test.tsx +128 -0
- package/src/trial/Trial.stories.tsx +1 -0
- package/src/trial/Trial.test.tsx +12 -0
- package/src/trial/Trial.trialId.test.tsx +36 -0
- package/src/trial/Trial.tsx +215 -40
- package/src/trial/TrialChrome.tsx +35 -0
- package/src/trial/UndockedSections.tsx +65 -0
- package/src/trial/trialOps.test.ts +21 -0
- package/src/trial/trialOps.ts +5 -3
- package/dist/_dts/types-BttTIent.d.ts +0 -314
- package/dist/chunk-3XXPU73K.js.map +0 -1
- package/dist/chunk-4TMMVIDM.js.map +0 -1
- package/dist/chunk-6X5RBC6G.js +0 -366
- package/dist/chunk-6X5RBC6G.js.map +0 -1
- package/dist/chunk-BDJXIBRZ.js.map +0 -1
- package/dist/chunk-CPUJ3QXL.js.map +0 -1
- package/dist/chunk-JDROYQM3.js.map +0 -1
- package/dist/chunk-LGKRIUSW.js.map +0 -1
- package/dist/chunk-QCICIHEO.js.map +0 -1
- package/dist/chunk-QRYPXSGP.js.map +0 -1
- package/dist/chunk-RGT4EJIB.js +0 -6961
- package/dist/chunk-RGT4EJIB.js.map +0 -1
- package/dist/chunk-T66HU3HX.js +0 -17
- package/dist/chunk-T66HU3HX.js.map +0 -1
- package/dist/chunk-WTI26YTM.js.map +0 -1
package/dist/canvas/index.d.ts
CHANGED
|
@@ -1,50 +1,134 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import '../_dts/
|
|
6
|
-
|
|
7
|
-
import '../_dts/types-
|
|
2
|
+
import { ReactNode, WheelEvent, PointerEvent } from 'react';
|
|
3
|
+
import { V as ViewTransform, c as WorldSpec, a2 as ViewportSize, a as Point, W as WorldFrame } from '../_dts/frac-C-2c72Ij.js';
|
|
4
|
+
export { x as DEFAULT_FRAME, a4 as applyCamera, aa as resolveFrame } from '../_dts/frac-C-2c72Ij.js';
|
|
5
|
+
import { C as CanvasLayerDescriptor } from '../_dts/CanvasStackContext-LnCfqNBA.js';
|
|
6
|
+
export { a as CanvasStackContext, b as CanvasStackContextValue, c as CanvasStackSurface } from '../_dts/CanvasStackContext-LnCfqNBA.js';
|
|
7
|
+
import '../_dts/types-D6s4b7if.js';
|
|
8
|
+
import '../_dts/PrefsForm-BkUJZx0A.js';
|
|
9
|
+
import '../_dts/types-DYMaEvM5.js';
|
|
8
10
|
import '../_dts/types-DJ79Tg5J.js';
|
|
9
|
-
|
|
10
|
-
/** One layer of a canvas stack: its id, whether it is currently shown, and how
|
|
11
|
-
* it paints itself. */
|
|
12
|
-
interface CanvasLayerDescriptor {
|
|
13
|
-
id: string;
|
|
14
|
-
visible: boolean;
|
|
15
|
-
render: (ctx: CanvasRenderingContext2D, view: ViewTransform) => void;
|
|
16
|
-
}
|
|
11
|
+
import '../_dts/types-C-gh9Ap-.js';
|
|
17
12
|
|
|
18
13
|
/** Props for `<CanvasStack>`. */
|
|
19
14
|
interface CanvasStackProps {
|
|
20
15
|
layers: CanvasLayerDescriptor[];
|
|
21
16
|
view: ViewTransform;
|
|
22
17
|
onViewChange: (v: ViewTransform) => void;
|
|
18
|
+
/** The instrument's coordinate system. Omitted, world (0,0) sits at the
|
|
19
|
+
* element's top-left with y running down. */
|
|
20
|
+
worldSpec?: WorldSpec;
|
|
23
21
|
minZoom?: number;
|
|
24
22
|
maxZoom?: number;
|
|
25
23
|
width?: number | string;
|
|
26
24
|
height?: number | string;
|
|
27
25
|
className?: string;
|
|
26
|
+
/** Fired whenever the stack is measured, so a consumer can place a view that
|
|
27
|
+
* only makes sense in terms of the viewport. */
|
|
28
|
+
onResize?: (size: ViewportSize) => void;
|
|
28
29
|
onHitTest?: (worldPos: Point) => void;
|
|
29
30
|
children?: ReactNode;
|
|
30
31
|
}
|
|
31
32
|
/** Stacks one `<canvas>` per layer and drives them from a shared view, so a
|
|
32
33
|
* layer that changes rarely is not redrawn with one that changes every frame.
|
|
33
34
|
* Handles sizing, device pixel ratio, and pan/zoom. */
|
|
34
|
-
declare function CanvasStack({ layers, view, onViewChange, minZoom, maxZoom, width, height, className, onHitTest, children, }: CanvasStackProps): react_jsx_runtime.JSX.Element;
|
|
35
|
+
declare function CanvasStack({ layers, view, onViewChange, worldSpec, minZoom, maxZoom, width, height, className, onResize, onHitTest, children, }: CanvasStackProps): react_jsx_runtime.JSX.Element;
|
|
35
36
|
|
|
36
|
-
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
/** Bounds and coordinate system a {@link zoomAt} works in. */
|
|
38
|
+
interface ZoomAtOptions {
|
|
39
|
+
/** The instrument's coordinate system, resolved against the viewport.
|
|
40
|
+
* Omitted, `at` is measured from the element's top-left. */
|
|
41
|
+
frame?: WorldFrame;
|
|
42
|
+
min?: number;
|
|
43
|
+
max?: number;
|
|
40
44
|
}
|
|
41
|
-
/**
|
|
42
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Zoom a view by `factor` about a fixed point, so whatever world coordinate
|
|
47
|
+
* `at` was over stays under it.
|
|
48
|
+
*
|
|
49
|
+
* `at` is in the element's own pixels — a cursor position, or the centre of a
|
|
50
|
+
* lens. The clamp is applied before the pan is solved, so a zoom that hits a
|
|
51
|
+
* bound still anchors on the zoom it actually reached.
|
|
52
|
+
*/
|
|
53
|
+
declare function zoomAt(view: ViewTransform, factor: number, at: Point, { frame, min, max }?: ZoomAtOptions): ViewTransform;
|
|
54
|
+
/** The view that puts a world point at the centre of a `size` viewport, at
|
|
55
|
+
* `zoom`. What a lens showing a region around one point renders through. */
|
|
56
|
+
declare function centerOn(world: Point, zoom: number, size: ViewportSize, frame?: WorldFrame): ViewTransform;
|
|
43
57
|
|
|
44
|
-
/** Project a world point into screen coordinates under a view.
|
|
45
|
-
|
|
58
|
+
/** Project a world point into screen coordinates under a view.
|
|
59
|
+
*
|
|
60
|
+
* `frame` is the instrument's declared coordinate system, resolved against the
|
|
61
|
+
* viewport; omitting it gives labkit's original one — origin at the top-left,
|
|
62
|
+
* y downward. */
|
|
63
|
+
declare function worldToScreen(world: Point, view: ViewTransform, frame?: WorldFrame): Point;
|
|
46
64
|
/** Unproject a screen point back to world coordinates under a view. */
|
|
47
|
-
declare function screenToWorld(screen: Point, view: ViewTransform): Point;
|
|
65
|
+
declare function screenToWorld(screen: Point, view: ViewTransform, frame?: WorldFrame): Point;
|
|
66
|
+
|
|
67
|
+
/** A point in the space the instrument works in. */
|
|
68
|
+
interface Vec3 {
|
|
69
|
+
x: number;
|
|
70
|
+
y: number;
|
|
71
|
+
z: number;
|
|
72
|
+
}
|
|
73
|
+
/** An orbit camera as a trial view: where it looks from, and what it looks at.
|
|
74
|
+
* labkit does not turn this into a matrix — the host's renderer does. */
|
|
75
|
+
interface OrbitView {
|
|
76
|
+
yaw: number;
|
|
77
|
+
pitch: number;
|
|
78
|
+
distance: number;
|
|
79
|
+
target: Vec3;
|
|
80
|
+
}
|
|
81
|
+
/** Just short of the pole. At exactly ±PI/2 the azimuth is undefined and the
|
|
82
|
+
* camera rolls, which reads as the model jumping rather than as a limit. */
|
|
83
|
+
declare const PITCH_LIMIT: number;
|
|
84
|
+
declare function clampPitch(pitch: number): number;
|
|
85
|
+
declare function wrapYaw(yaw: number): number;
|
|
86
|
+
/** The view a drag of (dx, dy) from `start` produces. Absolute against the drag
|
|
87
|
+
* start, so it can be re-applied any number of times without compounding. */
|
|
88
|
+
declare function orbitAfterDrag(start: OrbitView, dx: number, dy: number): OrbitView;
|
|
89
|
+
/** Multiplicative, so one notch covers the same proportion of the distance
|
|
90
|
+
* whether the camera is near or far. */
|
|
91
|
+
declare function orbitAfterWheel(view: OrbitView, deltaY: number, minDistance: number, maxDistance: number): OrbitView;
|
|
92
|
+
interface UseOrbitOptions {
|
|
93
|
+
view: OrbitView;
|
|
94
|
+
onViewChange: (v: OrbitView) => void;
|
|
95
|
+
/** Restored on double-click. Defaults to the view the hook first saw. */
|
|
96
|
+
home?: OrbitView;
|
|
97
|
+
minDistance?: number;
|
|
98
|
+
maxDistance?: number;
|
|
99
|
+
}
|
|
100
|
+
interface OrbitHandlers {
|
|
101
|
+
onWheel: (e: WheelEvent<HTMLElement>) => void;
|
|
102
|
+
onPointerDown: (e: PointerEvent<HTMLElement>) => void;
|
|
103
|
+
onPointerMove: (e: PointerEvent<HTMLElement>) => void;
|
|
104
|
+
onPointerUp: (e: PointerEvent<HTMLElement>) => void;
|
|
105
|
+
onDoubleClick: () => void;
|
|
106
|
+
isDragging: () => boolean;
|
|
107
|
+
}
|
|
108
|
+
/** Pointer gestures over an orbit view: drag to turn, wheel or pinch to dolly,
|
|
109
|
+
* double-click to go home. The 3D peer of `usePanZoom`. */
|
|
110
|
+
declare function useOrbit({ view, onViewChange, home, minDistance, maxDistance, }: UseOrbitOptions): OrbitHandlers;
|
|
111
|
+
|
|
112
|
+
interface UsePanZoomOptions {
|
|
113
|
+
view: ViewTransform;
|
|
114
|
+
onViewChange: (v: ViewTransform) => void;
|
|
115
|
+
/** The opening `view.zoom` always stays reachable, widening these past
|
|
116
|
+
* whatever is passed here if it would otherwise exclude it. */
|
|
117
|
+
minZoom?: number;
|
|
118
|
+
maxZoom?: number;
|
|
119
|
+
/** The instrument's coordinate system, resolved against the viewport. The
|
|
120
|
+
* wheel anchors in this frame; omitting it anchors at the element's
|
|
121
|
+
* top-left, which is what labkit did before a frame could be declared. */
|
|
122
|
+
frame?: WorldFrame;
|
|
123
|
+
}
|
|
124
|
+
interface PanZoomHandlers {
|
|
125
|
+
onWheel: (e: WheelEvent<HTMLElement>) => void;
|
|
126
|
+
onPointerDown: (e: PointerEvent<HTMLElement>) => void;
|
|
127
|
+
onPointerMove: (e: PointerEvent<HTMLElement>) => void;
|
|
128
|
+
onPointerUp: (e: PointerEvent<HTMLElement>) => void;
|
|
129
|
+
isDragging: () => boolean;
|
|
130
|
+
}
|
|
131
|
+
declare function usePanZoom({ view, onViewChange, minZoom, maxZoom, frame, }: UsePanZoomOptions): PanZoomHandlers;
|
|
48
132
|
|
|
49
|
-
export { CanvasStack,
|
|
50
|
-
export type {
|
|
133
|
+
export { CanvasLayerDescriptor, CanvasStack, PITCH_LIMIT, ViewportSize, WorldFrame, WorldSpec, centerOn, clampPitch, orbitAfterDrag, orbitAfterWheel, screenToWorld, useOrbit, usePanZoom, worldToScreen, wrapYaw, zoomAt };
|
|
134
|
+
export type { CanvasStackProps, OrbitHandlers, OrbitView, PanZoomHandlers, UseOrbitOptions, UsePanZoomOptions, Vec3, ZoomAtOptions };
|
package/dist/canvas/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { CanvasStack } from '../chunk-
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
|
|
1
|
+
export { CanvasStack, PITCH_LIMIT, clampPitch, orbitAfterDrag, orbitAfterWheel, useOrbit, usePanZoom, wrapYaw } from '../chunk-HMFODCOX.js';
|
|
2
|
+
export { centerOn, zoomAt } from '../chunk-CTRKTLYZ.js';
|
|
3
|
+
export { DEFAULT_FRAME, applyCamera, resolveFrame, screenToWorld, worldToScreen } from '../chunk-2AYGEN57.js';
|
|
4
|
+
export { CanvasStackContext } from '../chunk-CQLQPQ4P.js';
|
|
5
|
+
import '../chunk-L5QJOOLV.js';
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
package/dist/chrome/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { c as ControlRenderer } from '../_dts/types-
|
|
2
|
-
import { I as Instrument,
|
|
3
|
-
export {
|
|
1
|
+
import { c as ControlRenderer } from '../_dts/types-D6s4b7if.js';
|
|
2
|
+
import { I as Instrument, _ as TrialChromeContext, m as TrialContribution } from '../_dts/frac-C-2c72Ij.js';
|
|
3
|
+
export { z as IconComponent, O as SidebarSection, Q as StatusReadout, Y as ToolItem, Z as ToolbarItem, $ as TrialRegion, a1 as ViewportControl } from '../_dts/frac-C-2c72Ij.js';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
-
import '../_dts/PrefsForm-
|
|
5
|
+
import '../_dts/PrefsForm-BkUJZx0A.js';
|
|
6
6
|
import 'react';
|
|
7
|
-
import '../_dts/types-
|
|
7
|
+
import '../_dts/types-DYMaEvM5.js';
|
|
8
8
|
import '../_dts/types-DJ79Tg5J.js';
|
|
9
|
+
import '../_dts/types-C-gh9Ap-.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* The contributions a trial gets from what its instrument declared. This is
|
|
@@ -44,7 +45,9 @@ interface SidebarRegionProps {
|
|
|
44
45
|
contributions: readonly TrialContribution[];
|
|
45
46
|
ctx: TrialChromeContext;
|
|
46
47
|
}
|
|
47
|
-
/** Lays a trial's `sidebar` contributions out as titled, collapsible sections.
|
|
48
|
+
/** Lays a trial's `sidebar` contributions out as titled, collapsible sections.
|
|
49
|
+
* A section the trial has torn out is not rendered here — `Trial` portals its
|
|
50
|
+
* body into the workspace instead. */
|
|
48
51
|
declare function SidebarRegion({ contributions, ctx }: SidebarRegionProps): react_jsx_runtime.JSX.Element | null;
|
|
49
52
|
|
|
50
53
|
/** Props for `<StatusRegion>`. */
|
package/dist/chrome/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { PaletteRegion, SidebarRegion, StatusRegion, TitleBarRegion, ToolbarRegion, ViewportRegion, builtinContributions, mergeContributions, suppressContributions } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-CPUJ3QXL.js';
|
|
1
|
+
export { PaletteRegion, SidebarRegion, StatusRegion, TitleBarRegion, ToolbarRegion, ViewportRegion, builtinContributions, mergeContributions, suppressContributions } from '../chunk-6OEYTYML.js';
|
|
2
|
+
import '../chunk-HHGVISVZ.js';
|
|
3
|
+
import '../chunk-TO2FUOKF.js';
|
|
5
4
|
import '../chunk-SBXNQW4G.js';
|
|
6
|
-
import '../chunk-
|
|
7
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-RBGKL7NF.js';
|
|
6
|
+
import '../chunk-CQLQPQ4P.js';
|
|
7
|
+
import '../chunk-L5QJOOLV.js';
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// src/canvas/worldSpec.ts
|
|
2
|
+
var DEFAULT_FRAME = { originPx: { x: 0, y: 0 }, yDir: 1 };
|
|
3
|
+
function resolveFrame(spec, size) {
|
|
4
|
+
if (!spec) return DEFAULT_FRAME;
|
|
5
|
+
const origin = spec.origin ?? { x: 0, y: 0 };
|
|
6
|
+
return {
|
|
7
|
+
originPx: { x: origin.x * size.width, y: origin.y * size.height },
|
|
8
|
+
yDir: spec.yAxis === "up" ? -1 : 1
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function applyCamera(ctx, view, frame = DEFAULT_FRAME) {
|
|
12
|
+
ctx.translate(frame.originPx.x + view.pan.x, frame.originPx.y + view.pan.y);
|
|
13
|
+
ctx.scale(view.zoom, view.zoom * frame.yDir);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// src/canvas/canvasCoords.ts
|
|
17
|
+
function worldToScreen(world, view, frame = DEFAULT_FRAME) {
|
|
18
|
+
return {
|
|
19
|
+
x: frame.originPx.x + view.pan.x + world.x * view.zoom,
|
|
20
|
+
y: frame.originPx.y + view.pan.y + world.y * view.zoom * frame.yDir
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function screenToWorld(screen, view, frame = DEFAULT_FRAME) {
|
|
24
|
+
return {
|
|
25
|
+
x: (screen.x - frame.originPx.x - view.pan.x) / view.zoom,
|
|
26
|
+
y: (screen.y - frame.originPx.y - view.pan.y) / (view.zoom * frame.yDir)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { DEFAULT_FRAME, applyCamera, resolveFrame, screenToWorld, worldToScreen };
|
|
31
|
+
//# sourceMappingURL=chunk-2AYGEN57.js.map
|
|
32
|
+
//# sourceMappingURL=chunk-2AYGEN57.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/canvas/worldSpec.ts","../src/canvas/canvasCoords.ts"],"names":[],"mappings":";AA2BO,IAAM,aAAA,GAA4B,EAAE,QAAA,EAAU,EAAE,CAAA,EAAG,GAAG,CAAA,EAAG,CAAA,EAAE,EAAG,IAAA,EAAM,CAAA;AAEpE,SAAS,YAAA,CAAa,MAA6B,IAAA,EAAgC;AACxF,EAAA,IAAI,CAAC,MAAM,OAAO,aAAA;AAClB,EAAA,MAAM,SAAS,IAAA,CAAK,MAAA,IAAU,EAAE,CAAA,EAAG,CAAA,EAAG,GAAG,CAAA,EAAE;AAC3C,EAAA,OAAO;AAAA,IACL,QAAA,EAAU,EAAE,CAAA,EAAG,MAAA,CAAO,CAAA,GAAI,IAAA,CAAK,KAAA,EAAO,CAAA,EAAG,MAAA,CAAO,CAAA,GAAI,IAAA,CAAK,MAAA,EAAO;AAAA,IAChE,IAAA,EAAM,IAAA,CAAK,KAAA,KAAU,IAAA,GAAO,EAAA,GAAK;AAAA,GACnC;AACF;AAIO,SAAS,WAAA,CACd,GAAA,EACA,IAAA,EACA,KAAA,GAAoB,aAAA,EACd;AACN,EAAA,GAAA,CAAI,SAAA,CAAU,KAAA,CAAM,QAAA,CAAS,CAAA,GAAI,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,KAAA,CAAM,QAAA,CAAS,CAAA,GAAI,IAAA,CAAK,GAAA,CAAI,CAAC,CAAA;AAC1E,EAAA,GAAA,CAAI,MAAM,IAAA,CAAK,IAAA,EAAM,IAAA,CAAK,IAAA,GAAO,MAAM,IAAI,CAAA;AAC7C;;;ACvCO,SAAS,aAAA,CACd,KAAA,EACA,IAAA,EACA,KAAA,GAAoB,aAAA,EACb;AACP,EAAA,OAAO;AAAA,IACL,CAAA,EAAG,MAAM,QAAA,CAAS,CAAA,GAAI,KAAK,GAAA,CAAI,CAAA,GAAI,KAAA,CAAM,CAAA,GAAI,IAAA,CAAK,IAAA;AAAA,IAClD,CAAA,EAAG,KAAA,CAAM,QAAA,CAAS,CAAA,GAAI,IAAA,CAAK,GAAA,CAAI,CAAA,GAAI,KAAA,CAAM,CAAA,GAAI,IAAA,CAAK,IAAA,GAAO,KAAA,CAAM;AAAA,GACjE;AACF;AAGO,SAAS,aAAA,CACd,MAAA,EACA,IAAA,EACA,KAAA,GAAoB,aAAA,EACb;AACP,EAAA,OAAO;AAAA,IACL,CAAA,EAAA,CAAI,OAAO,CAAA,GAAI,KAAA,CAAM,SAAS,CAAA,GAAI,IAAA,CAAK,GAAA,CAAI,CAAA,IAAK,IAAA,CAAK,IAAA;AAAA,IACrD,CAAA,EAAA,CAAI,MAAA,CAAO,CAAA,GAAI,KAAA,CAAM,QAAA,CAAS,CAAA,GAAI,IAAA,CAAK,GAAA,CAAI,CAAA,KAAM,IAAA,CAAK,IAAA,GAAO,KAAA,CAAM,IAAA;AAAA,GACrE;AACF","file":"chunk-2AYGEN57.js","sourcesContent":["import type { Point, ViewTransform } from '../instrument/types';\n\n/** How an instrument's world sits on the canvas, independent of the camera.\n * The defaults reproduce the convention labkit shipped before this existed:\n * world (0,0) at the element's top-left, y growing downward. */\nexport interface WorldSpec {\n /** Where world (0,0) sits at `pan` zero, as a fraction of the viewport.\n * `{x:0,y:0}` top-left (default); `{x:0.5,y:0.5}` centre. */\n origin?: Point;\n /** Which way the world y axis runs on screen. Default `'down'`. */\n yAxis?: 'down' | 'up';\n}\n\n/** A viewport's CSS-pixel size. */\nexport interface ViewportSize {\n width: number;\n height: number;\n}\n\n/** A `WorldSpec` resolved against a viewport: what the coordinate helpers,\n * the camera and the wheel all read. */\nexport interface WorldFrame {\n /** Screen position of world (0,0) at `pan` zero. */\n originPx: Point;\n yDir: 1 | -1;\n}\n\nexport const DEFAULT_FRAME: WorldFrame = { originPx: { x: 0, y: 0 }, yDir: 1 };\n\nexport function resolveFrame(spec: WorldSpec | undefined, size: ViewportSize): WorldFrame {\n if (!spec) return DEFAULT_FRAME;\n const origin = spec.origin ?? { x: 0, y: 0 };\n return {\n originPx: { x: origin.x * size.width, y: origin.y * size.height },\n yDir: spec.yAxis === 'up' ? -1 : 1,\n };\n}\n\n/** Put a 2D context into the instrument's world coordinates, so a layer's\n * `draw` works in them. Must stay the exact inverse of `screenToWorld`. */\nexport function applyCamera(\n ctx: CanvasRenderingContext2D,\n view: ViewTransform,\n frame: WorldFrame = DEFAULT_FRAME,\n): void {\n ctx.translate(frame.originPx.x + view.pan.x, frame.originPx.y + view.pan.y);\n ctx.scale(view.zoom, view.zoom * frame.yDir);\n}\n","import type { Point, ViewTransform } from '../instrument/types';\nimport { DEFAULT_FRAME, type WorldFrame } from './worldSpec';\n\n/** Project a world point into screen coordinates under a view.\n *\n * `frame` is the instrument's declared coordinate system, resolved against the\n * viewport; omitting it gives labkit's original one — origin at the top-left,\n * y downward. */\nexport function worldToScreen(\n world: Point,\n view: ViewTransform,\n frame: WorldFrame = DEFAULT_FRAME,\n): Point {\n return {\n x: frame.originPx.x + view.pan.x + world.x * view.zoom,\n y: frame.originPx.y + view.pan.y + world.y * view.zoom * frame.yDir,\n };\n}\n\n/** Unproject a screen point back to world coordinates under a view. */\nexport function screenToWorld(\n screen: Point,\n view: ViewTransform,\n frame: WorldFrame = DEFAULT_FRAME,\n): Point {\n return {\n x: (screen.x - frame.originPx.x - view.pan.x) / view.zoom,\n y: (screen.y - frame.originPx.y - view.pan.y) / (view.zoom * frame.yDir),\n };\n}\n"]}
|