@vitavision/stage2d 0.8.1 → 0.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.
@@ -0,0 +1,81 @@
1
+ /**
2
+ * The stage's pointer gestures as pure arithmetic: which mouse buttons pan, what a
3
+ * two-finger pinch does to the view, and what counts as a tap.
4
+ *
5
+ * Points are viewport-local CSS pixels, as in `view.ts`.
6
+ */
7
+
8
+ import type { Point } from "../measureGeometry";
9
+ import { zoomAbout, type StageView } from "./view";
10
+
11
+ /** A mouse button that can pan the stage. */
12
+ export type StageMouseButton = "left" | "middle" | "right";
13
+
14
+ /** How far a touch may travel and still be a tap, in CSS pixels. */
15
+ export const TAP_SLOP = 3;
16
+ /** The longest a touch may last and still be a tap, in milliseconds. */
17
+ export const TAP_MS = 500;
18
+
19
+ const BUTTON_CODE: Record<StageMouseButton, number> = { left: 0, middle: 1, right: 2 };
20
+
21
+ /**
22
+ * The `PointerEvent.button` codes a `panButton` prop names.
23
+ *
24
+ * @param panButton - One button or a list; omitted means left and middle, the stage's
25
+ * long-standing default.
26
+ * @returns The codes: 0 left, 1 middle, 2 right.
27
+ */
28
+ export function panButtonCodes(panButton: StageMouseButton | readonly StageMouseButton[] | undefined): ReadonlySet<number> {
29
+ if (panButton === undefined) return new Set([0, 1]);
30
+ const list = typeof panButton === "string" ? [panButton] : panButton;
31
+ return new Set(list.map((button) => BUTTON_CODE[button]));
32
+ }
33
+
34
+ /**
35
+ * The midpoint of two points.
36
+ *
37
+ * @param a - One point.
38
+ * @param b - The other.
39
+ * @returns Their centroid.
40
+ */
41
+ export function centroid(a: Point, b: Point): Point {
42
+ return { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 };
43
+ }
44
+
45
+ /**
46
+ * The view a pinch has reached: scaled by how much the fingers spread, and carried by how
47
+ * far their midpoint moved. The image point under the fingers' first midpoint stays under
48
+ * their current one, so the gesture reads as holding the picture with two fingers.
49
+ *
50
+ * @param start - The view when the second finger went down.
51
+ * @param startDistance - The fingers' distance then.
52
+ * @param startCentre - Their midpoint then.
53
+ * @param distance - Their distance now.
54
+ * @param centre - Their midpoint now.
55
+ * @param range - The `[min, max]` scale to stay within.
56
+ * @returns The view; not yet clamped to the legal pan range.
57
+ */
58
+ export function pinchView(
59
+ start: StageView,
60
+ startDistance: number,
61
+ startCentre: Point,
62
+ distance: number,
63
+ centre: Point,
64
+ range: readonly [number, number],
65
+ ): StageView {
66
+ const ratio = startDistance > 0 ? distance / startDistance : 1;
67
+ const scale = Math.min(range[1], Math.max(range[0], start.scale * ratio));
68
+ const zoomed = zoomAbout(start, scale, startCentre);
69
+ return { scale: zoomed.scale, tx: zoomed.tx + centre.x - startCentre.x, ty: zoomed.ty + centre.y - startCentre.y };
70
+ }
71
+
72
+ /**
73
+ * Whether a touch that has ended was a tap.
74
+ *
75
+ * @param travel - The farthest it strayed from where it began, in CSS pixels.
76
+ * @param elapsed - How long it lasted, in milliseconds.
77
+ * @returns `true` for a short touch that stayed put.
78
+ */
79
+ export function isTap(travel: number, elapsed: number): boolean {
80
+ return travel <= TAP_SLOP && elapsed <= TAP_MS;
81
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The context an `ImageStage` provides its layers' hit registry through. Its own module so
3
+ * that `ImageStage` (which provides it) and `useStageHitTest` (which reads it, and reads
4
+ * `useStage` from `ImageStage`) do not import each other.
5
+ */
6
+
7
+ import { createContext } from "react";
8
+ import type { PointerEvent as ReactPointerEvent } from "react";
9
+
10
+ import type { HitRegistry } from "./hitTest";
11
+
12
+ /** The press event a layer's `press` handler receives. */
13
+ export type StagePointerEvent = ReactPointerEvent<Element>;
14
+
15
+ /** The enclosing stage's registry, or `null` outside a stage. */
16
+ export const StageHitContext = createContext<HitRegistry<StagePointerEvent> | null>(null);
@@ -0,0 +1,181 @@
1
+ /**
2
+ * "What is under the pointer?", answered across layers.
3
+ *
4
+ * Each layer that can be picked registers a `pick` function over its own spatial index. The
5
+ * stage asks every layer, ranks the answers and returns the best, so an app deciding what a
6
+ * press means (select, draw or pan) asks one question instead of arbitrating between layers.
7
+ * This module is the pure core: ranking, and a registry that also routes hover and presses.
8
+ * The React wiring is `useStageHitTest.ts`. It imports neither React nor the DOM.
9
+ *
10
+ * Ranking: a higher `priority` wins outright (points above lines above areas above images),
11
+ * then the smaller distance, then the layer id, so the result never depends on the order
12
+ * layers mounted in.
13
+ */
14
+
15
+ import type { Point } from "../measureGeometry";
16
+
17
+ /** What a layer is picked as, and so how it ranks against the layers around it. */
18
+ export const STAGE_HIT_PRIORITY = {
19
+ /** A raster layer: only picked when nothing else is. */
20
+ image: 0,
21
+ /** A filled region or heatmap cell. */
22
+ area: 100,
23
+ /** A line or contour. */
24
+ line: 200,
25
+ /** A marker: small, so it wins over what it sits on. */
26
+ point: 300,
27
+ } as const;
28
+
29
+ /** An item's identity within its layer. */
30
+ export type HitId = string | number;
31
+
32
+ /** What a layer's `pick` returns: the item, and how far from the pointer it is. */
33
+ export interface HitCandidate {
34
+ /** The item's id. */
35
+ id: HitId;
36
+ /** Distance from the query point, in image pixels. Compared only within one priority. */
37
+ dist: number;
38
+ }
39
+
40
+ /** One answer to a hit-test. */
41
+ export interface StageHit extends HitCandidate {
42
+ /** The layer that answered. */
43
+ layerId: string;
44
+ /** The layer's priority. */
45
+ priority: number;
46
+ }
47
+
48
+ /** What a layer registers. */
49
+ export interface StageHitLayerSpec<E = unknown> {
50
+ /** Reported as `StageHit.layerId`. */
51
+ id: string;
52
+ /** Ranks this layer against others; see `STAGE_HIT_PRIORITY`. */
53
+ priority: number;
54
+ /**
55
+ * The item under `point`, if any.
56
+ *
57
+ * @param point - The query, in image coordinates.
58
+ * @param radius - The pointer's tolerance, in image pixels.
59
+ */
60
+ pick: (point: Point, radius: number) => HitCandidate | null;
61
+ /** Whether a press on this layer's items does something (`press` is set and will claim). */
62
+ readonly pressable?: boolean | undefined;
63
+ /** The hovered item changed: an id, or `null` when the pointer left every item. */
64
+ hover?: ((id: HitId | null) => void) | undefined;
65
+ /** A press landed on an item. Return `false` to decline it. */
66
+ press?: ((id: HitId, event: E) => boolean | void) | undefined;
67
+ }
68
+
69
+ /** Options of a hit-test. */
70
+ export interface StageHitOptions {
71
+ /** Consider only layers whose presses are claimed (`pressable`). */
72
+ pressable?: boolean | undefined;
73
+ }
74
+
75
+ /**
76
+ * Order two hits, best first.
77
+ *
78
+ * @returns Negative when `a` ranks above `b`.
79
+ */
80
+ export function compareHits(a: StageHit, b: StageHit): number {
81
+ if (a.priority !== b.priority) return b.priority - a.priority;
82
+ if (a.dist !== b.dist) return a.dist - b.dist;
83
+ return a.layerId < b.layerId ? -1 : a.layerId > b.layerId ? 1 : 0;
84
+ }
85
+
86
+ /**
87
+ * Sort hits, best first.
88
+ *
89
+ * @param hits - Any hits.
90
+ * @returns A new, sorted array.
91
+ */
92
+ export function sortHits(hits: readonly StageHit[]): StageHit[] {
93
+ return [...hits].sort(compareHits);
94
+ }
95
+
96
+ /**
97
+ * The best of some hits.
98
+ *
99
+ * @param hits - Any hits.
100
+ * @returns The first by `compareHits`, or `null` when there are none.
101
+ */
102
+ export function bestHit(hits: readonly StageHit[]): StageHit | null {
103
+ let best: StageHit | null = null;
104
+ for (const hit of hits) if (best === null || compareHits(hit, best) < 0) best = hit;
105
+ return best;
106
+ }
107
+
108
+ /** The layers of one stage, and the routing of hover and presses between them. */
109
+ export interface HitRegistry<E = unknown> {
110
+ /**
111
+ * Add a layer.
112
+ *
113
+ * @returns The function that removes it.
114
+ */
115
+ register: (layer: StageHitLayerSpec<E>) => () => void;
116
+ /** Every layer's best answer at `point`, sorted best first. */
117
+ hitTestAll: (point: Point, radius: number, options?: StageHitOptions) => StageHit[];
118
+ /** The best answer at `point`, or `null`. */
119
+ hitTest: (point: Point, radius: number, options?: StageHitOptions) => StageHit | null;
120
+ /**
121
+ * Move hover to whatever is under `point`: the best hit among layers with a `hover`
122
+ * handler gets `hover(id)`, and the layer that had it before gets `hover(null)`. Calls
123
+ * nothing when the hovered item did not change.
124
+ */
125
+ routeHover: (point: Point, radius: number) => void;
126
+ /** Clear hover, e.g. when the pointer leaves the stage or starts a pan. */
127
+ clearHover: () => void;
128
+ /**
129
+ * Offer a press to the best pressable item under `point`, then the next, until one claims.
130
+ *
131
+ * @returns Whether a layer claimed it.
132
+ */
133
+ routePress: (point: Point, radius: number, event: E) => boolean;
134
+ }
135
+
136
+ /** Make an empty registry. */
137
+ export function createHitRegistry<E = unknown>(): HitRegistry<E> {
138
+ const layers = new Set<StageHitLayerSpec<E>>();
139
+ let hovered: { layer: StageHitLayerSpec<E>; id: HitId } | null = null;
140
+
141
+ const answers = (point: Point, radius: number, options?: StageHitOptions): { hit: StageHit; layer: StageHitLayerSpec<E> }[] => {
142
+ const out: { hit: StageHit; layer: StageHitLayerSpec<E> }[] = [];
143
+ for (const layer of layers) {
144
+ if (options?.pressable && layer.pressable !== true) continue;
145
+ const found = layer.pick(point, radius);
146
+ if (found) out.push({ hit: { id: found.id, dist: found.dist, layerId: layer.id, priority: layer.priority }, layer });
147
+ }
148
+ return out.sort((a, b) => compareHits(a.hit, b.hit));
149
+ };
150
+
151
+ const setHover = (next: { layer: StageHitLayerSpec<E>; id: HitId } | null) => {
152
+ const previous = hovered;
153
+ if (previous?.layer === next?.layer && previous?.id === next?.id) return;
154
+ hovered = next;
155
+ if (previous && previous.layer !== next?.layer) previous.layer.hover?.(null);
156
+ next?.layer.hover?.(next.id);
157
+ };
158
+
159
+ return {
160
+ register(layer) {
161
+ layers.add(layer);
162
+ return () => {
163
+ layers.delete(layer);
164
+ if (hovered?.layer === layer) hovered = null;
165
+ };
166
+ },
167
+ hitTestAll: (point, radius, options) => answers(point, radius, options).map((a) => a.hit),
168
+ hitTest: (point, radius, options) => answers(point, radius, options)[0]?.hit ?? null,
169
+ routeHover(point, radius) {
170
+ const best = answers(point, radius).find((a) => a.layer.hover !== undefined);
171
+ setHover(best ? { layer: best.layer, id: best.hit.id } : null);
172
+ },
173
+ clearHover: () => setHover(null),
174
+ routePress(point, radius, event) {
175
+ for (const { hit, layer } of answers(point, radius, { pressable: true })) {
176
+ if (layer.press?.(hit.id, event) !== false) return true;
177
+ }
178
+ return false;
179
+ },
180
+ };
181
+ }
@@ -0,0 +1,127 @@
1
+ /**
2
+ * React wiring for the stage's hit-test registry: `useStageHitTest` for apps that ask "what
3
+ * is under the pointer", and `useStageHitLayer` for layers that answer.
4
+ */
5
+
6
+ import { use, useId, useLayoutEffect, useMemo, useRef } from "react";
7
+
8
+ import type { Point } from "../measureGeometry";
9
+ import { useStage } from "./ImageStage";
10
+ import { StageHitContext, type StagePointerEvent } from "./hitContext";
11
+ import {
12
+ type HitCandidate,
13
+ type HitId,
14
+ type StageHit,
15
+ type StageHitLayerSpec,
16
+ type StageHitOptions,
17
+ } from "./hitTest";
18
+
19
+ /** The default pointer tolerance of `hitTest`, in screen pixels. */
20
+ const DEFAULT_RADIUS_PX = 6;
21
+
22
+ /** What `useStageHitTest` returns. */
23
+ export interface StageHitTestApi {
24
+ /**
25
+ * The best item under a point across every layer, or `null`.
26
+ *
27
+ * @param point - In image coordinates, e.g. a `StagePress.point`.
28
+ * @param radiusScreenPx - The pointer's tolerance in screen pixels. Defaults to 6.
29
+ * @param options - `pressable` limits the answer to layers that claim presses.
30
+ */
31
+ hitTest: (point: Point, radiusScreenPx?: number, options?: StageHitOptions) => StageHit | null;
32
+ /**
33
+ * Every layer's best item under a point, best first: higher priority, then nearer.
34
+ * Parameters as `hitTest`.
35
+ */
36
+ hitTestAll: (point: Point, radiusScreenPx?: number, options?: StageHitOptions) => StageHit[];
37
+ }
38
+
39
+ /**
40
+ * The stage's one hit-test, across every registered layer (`PointSet`, `PolylineSet`, and
41
+ * any layer built with `useStageHitLayer`). A press handler uses it to decide what a press
42
+ * means: an item under the pointer is selected, bare image is drawn on or panned.
43
+ *
44
+ * The answer comes from each layer's spatial index, never from the DOM, so it costs
45
+ * microseconds at any scene size.
46
+ *
47
+ * @returns `{ hitTest, hitTestAll }`.
48
+ * @throws `Error` outside an `ImageStage`, which is always a wiring bug.
49
+ */
50
+ export function useStageHitTest(): StageHitTestApi {
51
+ const registry = use(StageHitContext);
52
+ if (registry === null) throw new Error("useStageHitTest must be used inside <ImageStage>.");
53
+ const { imageLength } = useStage();
54
+ return useMemo(
55
+ () => ({
56
+ hitTest: (point, radiusScreenPx = DEFAULT_RADIUS_PX, options) =>
57
+ registry.hitTest(point, imageLength(radiusScreenPx), options),
58
+ hitTestAll: (point, radiusScreenPx = DEFAULT_RADIUS_PX, options) =>
59
+ registry.hitTestAll(point, imageLength(radiusScreenPx), options),
60
+ }),
61
+ [registry, imageLength],
62
+ );
63
+ }
64
+
65
+ /** What a layer passes `useStageHitLayer`. */
66
+ export interface StageHitLayerOptions {
67
+ /** The id hits report. Defaults to a generated, stable one; set it to tell layers apart. */
68
+ layerId?: string | undefined;
69
+ /** Rank against other layers; see `STAGE_HIT_PRIORITY`. */
70
+ priority: number;
71
+ /**
72
+ * The item under `point`, if any, within `radius` image pixels. Use the layer's index
73
+ * (`nearestPoint`, `nearestPolyline`), not the DOM.
74
+ */
75
+ pick: (point: Point, radius: number) => HitCandidate | null;
76
+ /**
77
+ * The hovered item changed. Setting this makes the stage route hover to the layer; the
78
+ * best item under the pointer across layers is the hovered one.
79
+ */
80
+ onHover?: ((id: HitId | null) => void) | undefined;
81
+ /**
82
+ * A press landed on an item and nothing above it claimed it. Setting this makes the layer
83
+ * claim presses on its items, so the stage does not pan from them. Return `false` to
84
+ * decline one. For a touch tap this is the `pointerup`.
85
+ */
86
+ onPress?: ((id: HitId, event: StagePointerEvent) => boolean | void) | undefined;
87
+ }
88
+
89
+ /**
90
+ * Register a layer with the stage's hit-test. The callbacks may change every render; the
91
+ * registration does not, so a layer is never missing from a hit-test for a frame.
92
+ *
93
+ * @param options - How the layer answers `pick`, and whether it takes hover and presses.
94
+ * @returns The layer's id, as hits report it.
95
+ * @throws `Error` outside an `ImageStage`.
96
+ */
97
+ export function useStageHitLayer(options: StageHitLayerOptions): string {
98
+ const registry = use(StageHitContext);
99
+ if (registry === null) throw new Error("useStageHitLayer must be used inside <ImageStage>.");
100
+ const generatedId = useId();
101
+ const id = options.layerId ?? generatedId;
102
+ const latestRef = useRef(options);
103
+ useLayoutEffect(() => {
104
+ latestRef.current = options;
105
+ });
106
+ const priority = options.priority;
107
+ useLayoutEffect(() => {
108
+ // Everything the registry reads goes through `latestRef`, so one registration serves the
109
+ // layer's whole life; `priority` and `id` are the only things that re-register it.
110
+ const layer: StageHitLayerSpec<StagePointerEvent> = {
111
+ id,
112
+ priority,
113
+ pick: (point, radius) => latestRef.current.pick(point, radius),
114
+ get pressable() {
115
+ return latestRef.current.onPress !== undefined;
116
+ },
117
+ get hover() {
118
+ return latestRef.current.onHover === undefined ? undefined : (hovered: HitId | null) => latestRef.current.onHover?.(hovered);
119
+ },
120
+ get press() {
121
+ return latestRef.current.onPress === undefined ? undefined : (hit: HitId, event: StagePointerEvent) => latestRef.current.onPress?.(hit, event);
122
+ },
123
+ };
124
+ return registry.register(layer);
125
+ }, [registry, id, priority]);
126
+ return id;
127
+ }
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Moving a manual shape: a press on a selected item becomes image-space displacements, with the
3
+ * click-slop handling every selection UI needs (a press that barely moves is a click, not a
4
+ * drag).
5
+ *
6
+ * The layers resolve what is under the pointer (`onItemPress`); this turns the press that
7
+ * follows into a move. The app keeps the item's geometry, shows the displaced copy while the
8
+ * drag is in flight, and commits it at the end:
9
+ *
10
+ * <AreaSet items={items} selectedIds={selected}
11
+ * onItemPress={(id, event) => {
12
+ * if (!selected.has(id)) return select(id);
13
+ * startMove(event, {
14
+ * onMove: setOffset, // preview: draw the item shifted
15
+ * onEnd: (delta, moved) => moved ? commit(id, delta) : select(id),
16
+ * onCancel: () => setOffset(null),
17
+ * });
18
+ * }} />
19
+ */
20
+
21
+ import { useCallback } from "react";
22
+
23
+ import type { Point } from "./measureGeometry";
24
+ import type { StagePointerEvent } from "./stage/hitContext";
25
+ import { useStage } from "./stage/ImageStage";
26
+ import { useStageDrag } from "./stage/StageSurface";
27
+
28
+ /** What a shape drag does as the pointer moves and when it ends. Displacements are total, from the press. */
29
+ export interface ShapeDragHandlers {
30
+ /**
31
+ * Each move of the pointer once it has left the click slop: how far it is from where the
32
+ * press landed, in image pixels. Draw the shape shifted by it.
33
+ */
34
+ onMove?: ((delta: Point, event: PointerEvent) => void) | undefined;
35
+ /**
36
+ * The release. `moved` is whether the pointer ever left the click slop; when it did not,
37
+ * `delta` is `{ x: 0, y: 0 }` and the press was a click. Commit the shape shifted by `delta`.
38
+ */
39
+ onEnd?: ((delta: Point, moved: boolean, event: PointerEvent) => void) | undefined;
40
+ /** The drag was interrupted (`pointercancel`) or the component unmounted mid-drag: drop the preview. */
41
+ onCancel?: (() => void) | undefined;
42
+ }
43
+
44
+ /** Options of the function `useShapeDrag` returns. */
45
+ export interface ShapeDragOptions {
46
+ /** How far the pointer may travel before the press is a drag, in screen pixels. Defaults to 3. */
47
+ slop?: number | undefined;
48
+ }
49
+
50
+ /** The default click slop, in screen pixels (the stage's own). */
51
+ const DEFAULT_SLOP = 3;
52
+
53
+ /**
54
+ * Start moving a shape from a press, inside an `ImageStage`.
55
+ *
56
+ * Returns `start(event, handlers, options?)`. Call it from `onItemPress` of a layer with the
57
+ * press event: the press is claimed, so the stage does not pan, and the pointer is followed on
58
+ * `window` until it is released, whether or not it leaves the canvas. A touch tap reaches
59
+ * `onItemPress` on release, so there is nothing to follow: it ends at once as a click
60
+ * (`moved` false). Move a shape on touch with `ShapeEditor`'s handles or the app's own mode.
61
+ *
62
+ * @returns `start`.
63
+ */
64
+ export function useShapeDrag(): (event: StagePointerEvent, handlers: ShapeDragHandlers, options?: ShapeDragOptions) => void {
65
+ const { toImage } = useStage();
66
+ const startDrag = useStageDrag();
67
+ return useCallback(
68
+ (event, handlers, options) => {
69
+ if (event.type !== "pointerdown") {
70
+ handlers.onEnd?.({ x: 0, y: 0 }, false, event.nativeEvent);
71
+ return;
72
+ }
73
+ const slop = options?.slop ?? DEFAULT_SLOP;
74
+ const from = { x: event.clientX, y: event.clientY };
75
+ // Where the press landed, in image pixels: displacements are measured from it.
76
+ const press = toImage(from);
77
+ const displacement = (point: Point): Point => ({ x: point.x - press.x, y: point.y - press.y });
78
+ let moved = false;
79
+ startDrag(event, {
80
+ onMove: (point, e) => {
81
+ if (!moved && Math.hypot(e.clientX - from.x, e.clientY - from.y) <= slop) return;
82
+ moved = true;
83
+ handlers.onMove?.(displacement(point), e);
84
+ },
85
+ onEnd: (point, e) => handlers.onEnd?.(moved ? displacement(point) : { x: 0, y: 0 }, moved, e),
86
+ onCancel: handlers.onCancel,
87
+ });
88
+ },
89
+ [toImage, startDrag],
90
+ );
91
+ }
92
+
93
+ /**
94
+ * Move flat points by a displacement.
95
+ *
96
+ * @param points - `[x0, y0, x1, y1, …]`.
97
+ * @param delta - The displacement, in the points' units.
98
+ * @returns A new array, `points` shifted.
99
+ */
100
+ export function translatePoints(points: ArrayLike<number>, delta: Point): number[] {
101
+ const out = new Array<number>(points.length);
102
+ for (let i = 0; i < points.length; i++) out[i] = points[i]! + (i % 2 === 0 ? delta.x : delta.y);
103
+ return out;
104
+ }
package/src/index.ts CHANGED
@@ -11,6 +11,23 @@ export {
11
11
  type StageHandle,
12
12
  } from "./components/stage/ImageStage";
13
13
 
14
+ export type { StageMouseButton } from "./components/stage/gesture";
15
+
16
+ export {
17
+ STAGE_HIT_PRIORITY,
18
+ type HitCandidate,
19
+ type HitId,
20
+ type StageHit,
21
+ type StageHitOptions,
22
+ } from "./components/stage/hitTest";
23
+ export type { StagePointerEvent } from "./components/stage/hitContext";
24
+ export {
25
+ useStageHitLayer,
26
+ useStageHitTest,
27
+ type StageHitLayerOptions,
28
+ type StageHitTestApi,
29
+ } from "./components/stage/useStageHitTest";
30
+
14
31
  export { ImageLayer, type ImageLayerProps, type ImageTier } from "./components/stage/ImageLayer";
15
32
 
16
33
  export {
@@ -127,6 +144,85 @@ export {
127
144
  type PolylineId,
128
145
  type PolylineIndex,
129
146
  } from "./components/polylineIndex";
147
+ export {
148
+ PointSet,
149
+ type PointSetItem,
150
+ type PointSetProps,
151
+ } from "./components/PointSet";
152
+ export {
153
+ buildPointIndex,
154
+ buildPointIndexFrom,
155
+ nearestPoint,
156
+ pointsInRect,
157
+ thinPoints,
158
+ type PointHit,
159
+ type PointId,
160
+ type PointIndex,
161
+ type PointIndexOptions,
162
+ type PointItem,
163
+ } from "./components/pointIndex";
164
+ export {
165
+ AreaSet,
166
+ type AreaSetItem,
167
+ type AreaSetProps,
168
+ } from "./components/AreaSet";
169
+ export {
170
+ areaCentre,
171
+ areaPath,
172
+ areasInRect,
173
+ buildAreaIndex,
174
+ nearestArea,
175
+ pointInPolygon,
176
+ type Area,
177
+ type AreaHit,
178
+ type AreaId,
179
+ type AreaIndex,
180
+ } from "./components/areaIndex";
181
+ export {
182
+ GridLayer,
183
+ type GridEdgeStyle,
184
+ type GridLayerProps,
185
+ type GridNode,
186
+ } from "./components/GridLayer";
187
+ export { latticeEdges, type LatticeAxis, type LatticeEdge, type LatticeNode } from "./components/gridEdges";
188
+ export {
189
+ HeatmapLayer,
190
+ type HeatmapLayerBaseProps,
191
+ type HeatmapLayerProps,
192
+ type HeatmapPlaneProps,
193
+ type HeatmapRgbaProps,
194
+ } from "./components/HeatmapLayer";
195
+ export { planeRange, rasterizePlane, type Colormap, type ValueRange } from "./components/heatmapRaster";
196
+ export { ShapeEditor, type ShapeEditorProps } from "./components/ShapeEditor";
197
+ export {
198
+ fromShapeFrame,
199
+ moveShape,
200
+ normalizeAngle,
201
+ resizeShape,
202
+ rotateShape,
203
+ rotationHandlePoint,
204
+ sameShape,
205
+ shapeCorner,
206
+ shapeFromCorner,
207
+ shapeHandleCursor,
208
+ shapeHandlePoint,
209
+ toShapeFrame,
210
+ type RotatedShape,
211
+ } from "./components/shapeEdit";
212
+ export {
213
+ DraftShape,
214
+ MarqueeRect,
215
+ type DraftShapeProps,
216
+ type DraftShapeSpec,
217
+ type MarqueeRectProps,
218
+ } from "./components/DraftShape";
219
+ export {
220
+ translatePoints,
221
+ useShapeDrag,
222
+ type ShapeDragHandlers,
223
+ type ShapeDragOptions,
224
+ } from "./components/useShapeDrag";
225
+ export { MARKER_SHAPES, circlePath, type BuiltinMarkerKind, type MarkerShape } from "./components/markerShapes";
130
226
  export {
131
227
  ROI_HANDLES,
132
228
  ROI_HANDLE_CURSOR,