@ue-too/board 0.14.1 → 0.16.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 (52) hide show
  1. package/README.md +21 -10
  2. package/boardify/index.d.ts +7 -8
  3. package/camera/base.d.ts +14 -14
  4. package/camera/camera-edge-auto-input.d.ts +1 -1
  5. package/camera/camera-mux/animation-and-lock/animation-and-lock.d.ts +6 -6
  6. package/camera/camera-mux/animation-and-lock/index.d.ts +4 -4
  7. package/camera/camera-mux/animation-and-lock/pan-control-state-machine.d.ts +21 -21
  8. package/camera/camera-mux/animation-and-lock/rotation-control-state-machine.d.ts +20 -20
  9. package/camera/camera-mux/animation-and-lock/zoom-control-state-machine.d.ts +46 -46
  10. package/camera/camera-mux/index.d.ts +3 -3
  11. package/camera/camera-mux/interface.d.ts +5 -1
  12. package/camera/camera-mux/relay.d.ts +2 -2
  13. package/camera/camera-rig/camera-rig.d.ts +6 -6
  14. package/camera/camera-rig/index.d.ts +4 -4
  15. package/camera/camera-rig/pan-handler.d.ts +2 -2
  16. package/camera/camera-rig/rotation-handler.d.ts +3 -1
  17. package/camera/camera-rig/zoom-handler.d.ts +1 -1
  18. package/camera/default-camera.d.ts +9 -7
  19. package/camera/index.d.ts +1 -1
  20. package/camera/interface.d.ts +7 -15
  21. package/camera/update-publisher.d.ts +16 -16
  22. package/camera/utils/coordinate-conversion.d.ts +4 -4
  23. package/camera/utils/index.d.ts +5 -5
  24. package/camera/utils/position.d.ts +11 -2
  25. package/index.d.ts +5 -5
  26. package/index.js +5261 -2
  27. package/index.js.map +65 -63
  28. package/input-interpretation/index.d.ts +4 -4
  29. package/input-interpretation/input-orchestrator.d.ts +5 -5
  30. package/input-interpretation/input-state-machine/index.d.ts +4 -4
  31. package/input-interpretation/input-state-machine/kmt-input-context.d.ts +7 -7
  32. package/input-interpretation/input-state-machine/kmt-input-state-machine.d.ts +16 -11
  33. package/input-interpretation/input-state-machine/touch-input-context.d.ts +2 -2
  34. package/input-interpretation/input-state-machine/touch-input-state-machine.d.ts +8 -8
  35. package/input-interpretation/raw-input-parser/index.d.ts +2 -2
  36. package/input-interpretation/raw-input-parser/vanilla-kmt-event-parser.d.ts +7 -3
  37. package/input-interpretation/raw-input-parser/vanilla-touch-event-parser.d.ts +2 -2
  38. package/input-interpretation/raw-input-publisher/index.d.ts +1 -1
  39. package/input-interpretation/raw-input-publisher/raw-input-publisher.d.ts +8 -8
  40. package/package.json +3 -3
  41. package/utils/canvas-position-dimension.d.ts +2 -1
  42. package/utils/coordinate-conversions/canvas-viewport.d.ts +1 -1
  43. package/utils/coordinate-conversions/index.d.ts +3 -0
  44. package/utils/coordinate-conversions/viewport-world.d.ts +1 -1
  45. package/utils/coordinate-conversions/window-canvas.d.ts +2 -2
  46. package/utils/coorindate-conversion.d.ts +2 -2
  47. package/utils/drawing-utils.d.ts +2 -2
  48. package/utils/drawing.d.ts +1 -1
  49. package/utils/index.d.ts +10 -8
  50. package/utils/scrollbar/index.d.ts +1 -0
  51. package/utils/scrollbar/scrollbar.d.ts +20 -0
  52. package/utils/zoomlevel-adjustment.d.ts +2 -2
@@ -1,5 +1,5 @@
1
- import { Point } from "@ue-too/math";
2
- import { BoardCamera } from "../interface";
1
+ import { Point } from '@ue-too/math';
2
+ import { BoardCamera } from '../interface';
3
3
  /**
4
4
  * Combined configuration for pan handler behavior, merging restriction and clamping settings.
5
5
  *
@@ -1,4 +1,5 @@
1
- import { BoardCamera } from "../interface";
1
+ import type { Point } from '@ue-too/math';
2
+ import { BoardCamera } from '../interface';
2
3
  /**
3
4
  * Combined configuration for rotation handler behavior, merging restriction and clamping settings.
4
5
  *
@@ -166,6 +167,7 @@ export type RotateByHandlerFunction = (delta: number, camera: BoardCamera, confi
166
167
  * @see {@link createDefaultRotateToHandler} for the default implementation
167
168
  */
168
169
  export type RotateToHandlerFunction = (targetRotation: number, camera: BoardCamera, config: RotationHandlerConfig) => number;
170
+ export type RotateToWithAnchorPointHandlerFunction = (targetRotation: number, anchorPoint: Point, camera: BoardCamera, config: RotationHandlerConfig) => number;
169
171
  /**
170
172
  * Handler pipeline step that clamps "rotate by" deltas to prevent angular boundary violations.
171
173
  *
@@ -1,4 +1,4 @@
1
- import { BoardCamera } from "../interface";
1
+ import { BoardCamera } from '../interface';
2
2
  /**
3
3
  * Combined configuration for zoom handler behavior, merging restriction and clamping settings.
4
4
  *
@@ -1,12 +1,13 @@
1
1
  import { Point } from '@ue-too/math';
2
- import { Boundaries } from './utils/position';
3
- import { TransformationMatrix } from './utils/matrix';
2
+ import { SubscriptionOptions } from '../utils/observable';
3
+ import { CameraOptions } from './base';
4
+ import { ObservableBoardCamera } from './interface';
4
5
  import { UnSubscribe } from './update-publisher';
5
- import { ZoomLevelLimits } from './utils/zoom';
6
- import { RotationLimits } from './utils/rotation';
7
6
  import { CameraEventMap, CameraState } from './update-publisher';
8
- import { ObservableBoardCamera } from './interface';
9
- import { SubscriptionOptions } from '../utils/observable';
7
+ import { TransformationMatrix } from './utils/matrix';
8
+ import { Boundaries } from './utils/position';
9
+ import { RotationLimits } from './utils/rotation';
10
+ import { ZoomLevelLimits } from './utils/zoom';
10
11
  /** Default viewport width in CSS pixels */
11
12
  export declare const DEFAULT_BOARD_CAMERA_VIEWPORT_WIDTH = 1000;
12
13
  /** Default viewport height in CSS pixels */
@@ -17,6 +18,7 @@ export declare const DEFAULT_BOARD_CAMERA_ZOOM_BOUNDARIES: ZoomLevelLimits;
17
18
  export declare const DEFAULT_BOARD_CAMERA_BOUNDARIES: Boundaries;
18
19
  /** Default rotation boundaries (unrestricted) */
19
20
  export declare const DEFAULT_BOARD_CAMERA_ROTATION_BOUNDARIES: RotationLimits | undefined;
21
+ export declare const DEFAULT_BOARD_CAMERA_OPTIONS: CameraOptions;
20
22
  /**
21
23
  * Observable camera implementation that extends {@link BaseCamera} with event notification.
22
24
  * This is the recommended camera class for most applications.
@@ -90,7 +92,7 @@ export default class DefaultBoardCamera implements ObservableBoardCamera {
90
92
  * );
91
93
  * ```
92
94
  */
93
- constructor(viewPortWidth?: number, viewPortHeight?: number, position?: Point, rotation?: number, zoomLevel?: number, boundaries?: Boundaries, zoomLevelBoundaries?: ZoomLevelLimits, rotationBoundaries?: RotationLimits | undefined);
95
+ constructor(options?: CameraOptions);
94
96
  /**
95
97
  * @description The boundaries of the camera in the world coordinate system.
96
98
  *
package/camera/index.d.ts CHANGED
@@ -18,7 +18,7 @@
18
18
  *
19
19
  * @module
20
20
  */
21
- export * from "./base";
21
+ export * from './base';
22
22
  export * from './utils';
23
23
  export * from './default-camera';
24
24
  export * from './interface';
@@ -1,10 +1,10 @@
1
- import { Point } from "@ue-too/math";
2
- import { UnSubscribe } from "./update-publisher";
3
- import { RotationLimits } from "./utils/rotation";
4
- import { ZoomLevelLimits } from "./utils/zoom";
5
- import { Boundaries } from "./utils/position";
6
- import { CameraEventMap, CameraState } from "./update-publisher";
7
- import { SubscriptionOptions } from "../utils/observable";
1
+ import { Point } from '@ue-too/math';
2
+ import { SubscriptionOptions } from '../utils/observable';
3
+ import { UnSubscribe } from './update-publisher';
4
+ import { CameraEventMap, CameraState } from './update-publisher';
5
+ import { Boundaries } from './utils/position';
6
+ import { RotationLimits } from './utils/rotation';
7
+ import { ZoomLevelLimits } from './utils/zoom';
8
8
  /**
9
9
  * Observable camera interface that extends {@link BoardCamera} with event subscription capabilities.
10
10
  * Allows observers to subscribe to camera state changes such as pan, zoom, and rotation events.
@@ -190,14 +190,6 @@ export interface BoardCamera {
190
190
  * If min > max, values are automatically swapped.
191
191
  */
192
192
  setVerticalBoundaries(min: number, max: number): void;
193
- /**
194
- * Gets the camera origin position in window coordinates.
195
- *
196
- * @deprecated This method is deprecated and will be removed in a future version
197
- * @param centerInWindow - Center point in window coordinates
198
- * @returns The camera origin point (currently just returns the input)
199
- */
200
- getCameraOriginInWindow(centerInWindow: Point): Point;
201
193
  /**
202
194
  * Converts a point from viewport coordinates to world coordinates.
203
195
  *
@@ -1,5 +1,5 @@
1
- import { Point } from "@ue-too/math";
2
- import { SubscriptionOptions } from "../utils/observable";
1
+ import { Point } from '@ue-too/math';
2
+ import { SubscriptionOptions } from '../utils/observable';
3
3
  /**
4
4
  * Payload for camera pan (position change) events.
5
5
  *
@@ -41,13 +41,13 @@ export type CameraRotateEventPayload = {
41
41
  */
42
42
  export type CameraEventMap = {
43
43
  /** Position change event */
44
- "pan": CameraPanEventPayload;
44
+ pan: CameraPanEventPayload;
45
45
  /** Zoom level change event */
46
- "zoom": CameraZoomEventPayload;
46
+ zoom: CameraZoomEventPayload;
47
47
  /** Rotation change event */
48
- "rotate": CameraRotateEventPayload;
48
+ rotate: CameraRotateEventPayload;
49
49
  /** Any camera change event (union of pan, zoom, rotate) */
50
- "all": AllCameraEventPayload;
50
+ all: AllCameraEventPayload;
51
51
  };
52
52
  /**
53
53
  * Rotation event with discriminated type field for 'all' event handling.
@@ -57,7 +57,7 @@ export type CameraEventMap = {
57
57
  */
58
58
  export type CameraRotateEvent = {
59
59
  /** Event type discriminator */
60
- type: "rotate";
60
+ type: 'rotate';
61
61
  } & CameraRotateEventPayload;
62
62
  /**
63
63
  * Pan event with discriminated type field for 'all' event handling.
@@ -67,7 +67,7 @@ export type CameraRotateEvent = {
67
67
  */
68
68
  export type CameraPanEvent = {
69
69
  /** Event type discriminator */
70
- type: "pan";
70
+ type: 'pan';
71
71
  } & CameraPanEventPayload;
72
72
  /**
73
73
  * Zoom event with discriminated type field for 'all' event handling.
@@ -77,7 +77,7 @@ export type CameraPanEvent = {
77
77
  */
78
78
  export type CameraZoomEvent = {
79
79
  /** Event type discriminator */
80
- type: "zoom";
80
+ type: 'zoom';
81
81
  } & CameraZoomEventPayload;
82
82
  /**
83
83
  * Snapshot of camera state at the time an event occurs.
@@ -128,25 +128,25 @@ export type UnSubscribe = () => void;
128
128
  *
129
129
  * @category Camera
130
130
  */
131
- export type PanObserver = Callback<"pan">;
131
+ export type PanObserver = Callback<'pan'>;
132
132
  /**
133
133
  * Callback type for zoom (scale change) events.
134
134
  *
135
135
  * @category Camera
136
136
  */
137
- export type ZoomObserver = Callback<"zoom">;
137
+ export type ZoomObserver = Callback<'zoom'>;
138
138
  /**
139
139
  * Callback type for rotation events.
140
140
  *
141
141
  * @category Camera
142
142
  */
143
- export type RotateObserver = Callback<"rotate">;
143
+ export type RotateObserver = Callback<'rotate'>;
144
144
  /**
145
145
  * Callback type for the 'all' event that fires on any camera change.
146
146
  *
147
147
  * @category Camera
148
148
  */
149
- export type AllObserver = Callback<"all">;
149
+ export type AllObserver = Callback<'all'>;
150
150
  /**
151
151
  * Event publisher for camera state changes using the Observable pattern.
152
152
  * Manages subscriptions and notifications for pan, zoom, and rotate events.
@@ -193,7 +193,7 @@ export declare class CameraUpdatePublisher {
193
193
  * @param event - Pan event payload containing position delta
194
194
  * @param cameraState - Current camera state snapshot
195
195
  */
196
- notifyPan(event: CameraEventMap["pan"], cameraState: CameraState): void;
196
+ notifyPan(event: CameraEventMap['pan'], cameraState: CameraState): void;
197
197
  /**
198
198
  * Notifies all zoom event subscribers.
199
199
  * Also triggers the 'all' event with type discrimination.
@@ -201,7 +201,7 @@ export declare class CameraUpdatePublisher {
201
201
  * @param event - Zoom event payload containing zoom delta
202
202
  * @param cameraState - Current camera state snapshot
203
203
  */
204
- notifyZoom(event: CameraEventMap["zoom"], cameraState: CameraState): void;
204
+ notifyZoom(event: CameraEventMap['zoom'], cameraState: CameraState): void;
205
205
  /**
206
206
  * Notifies all rotation event subscribers.
207
207
  * Also triggers the 'all' event with type discrimination.
@@ -209,7 +209,7 @@ export declare class CameraUpdatePublisher {
209
209
  * @param event - Rotation event payload containing rotation delta
210
210
  * @param cameraState - Current camera state snapshot
211
211
  */
212
- notifyRotate(event: CameraEventMap["rotate"], cameraState: CameraState): void;
212
+ notifyRotate(event: CameraEventMap['rotate'], cameraState: CameraState): void;
213
213
  /**
214
214
  * Subscribes to camera events with type-safe callbacks and optional AbortController support.
215
215
  *
@@ -1,12 +1,12 @@
1
- import { Point } from "@ue-too/math";
2
- import { TransformationMatrix } from "./matrix";
1
+ import { Point } from '@ue-too/math';
2
+ import { TransformationMatrix } from './matrix';
3
3
  /**
4
4
  * Converts a viewport point to world space with respect to a hypothetical camera position.
5
5
  * "WRT" = "With Respect To" - calculates where a viewport point would be in world space
6
6
  * if the camera were at the target position.
7
7
  *
8
8
  * @param targetPosition - Hypothetical camera position in world coordinates
9
- * @param interestPoint - Point in canvas coordinates (origin at bottom-left)
9
+ * @param interestPoint - Point in canvas coordinates (origin at top-left corner of the canvas element in browser)
10
10
  * @param viewPortWidth - Viewport width in CSS pixels
11
11
  * @param viewPortHeight - Viewport height in CSS pixels
12
12
  * @param cameraZoomLevel - Zoom level to apply
@@ -26,7 +26,7 @@ import { TransformationMatrix } from "./matrix";
26
26
  * // if camera moved to (100, 100)?
27
27
  * const worldCorner = convert2WorldSpaceWRT(
28
28
  * { x: 100, y: 100 }, // target camera position
29
- * { x: 0, y: 1080 }, // top-left in canvas coords
29
+ * { x: 0, y: 0 }, // top-left in canvas coords
30
30
  * 1920, 1080, // viewport size
31
31
  * 1.0, // zoom
32
32
  * 0 // rotation
@@ -20,8 +20,8 @@
20
20
  *
21
21
  * @module
22
22
  */
23
- export * from "./coordinate-conversion";
24
- export * from "./matrix";
25
- export * from "./position";
26
- export * from "./rotation";
27
- export * from "./zoom";
23
+ export * from './coordinate-conversion';
24
+ export * from './matrix';
25
+ export * from './position';
26
+ export * from './rotation';
27
+ export * from './zoom';
@@ -1,4 +1,4 @@
1
- import { Point } from "@ue-too/math";
1
+ import { Point } from '@ue-too/math';
2
2
  /**
3
3
  * Position boundaries for camera movement in world space.
4
4
  * Allows optional constraints on x and y axes independently.
@@ -136,7 +136,16 @@ export declare function isValidBoundaries(boundaries: Boundaries | undefined): b
136
136
  *
137
137
  * @category Camera
138
138
  */
139
- export declare function boundariesFullyDefined(boundaries: Boundaries | undefined): boolean;
139
+ export declare function boundariesFullyDefined(boundaries: Boundaries | undefined): boundaries is {
140
+ min: {
141
+ x: number;
142
+ y: number;
143
+ };
144
+ max: {
145
+ x: number;
146
+ y: number;
147
+ };
148
+ };
140
149
  /**
141
150
  * Clamps a point to stay within specified boundaries.
142
151
  *
package/index.d.ts CHANGED
@@ -35,8 +35,8 @@
35
35
  * requestAnimationFrame(draw);
36
36
  * ```
37
37
  */
38
- export * from "./boardify";
39
- export * from "./camera";
40
- export * from "./input-interpretation";
41
- export * from "./utils";
42
- export { default as Board } from "./boardify";
38
+ export * from './boardify';
39
+ export * from './camera';
40
+ export * from './input-interpretation';
41
+ export * from './utils';
42
+ export { default as Board } from './boardify';