@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.
- package/README.md +21 -10
- package/boardify/index.d.ts +7 -8
- package/camera/base.d.ts +14 -14
- package/camera/camera-edge-auto-input.d.ts +1 -1
- package/camera/camera-mux/animation-and-lock/animation-and-lock.d.ts +6 -6
- package/camera/camera-mux/animation-and-lock/index.d.ts +4 -4
- package/camera/camera-mux/animation-and-lock/pan-control-state-machine.d.ts +21 -21
- package/camera/camera-mux/animation-and-lock/rotation-control-state-machine.d.ts +20 -20
- package/camera/camera-mux/animation-and-lock/zoom-control-state-machine.d.ts +46 -46
- package/camera/camera-mux/index.d.ts +3 -3
- package/camera/camera-mux/interface.d.ts +5 -1
- package/camera/camera-mux/relay.d.ts +2 -2
- package/camera/camera-rig/camera-rig.d.ts +6 -6
- package/camera/camera-rig/index.d.ts +4 -4
- package/camera/camera-rig/pan-handler.d.ts +2 -2
- package/camera/camera-rig/rotation-handler.d.ts +3 -1
- package/camera/camera-rig/zoom-handler.d.ts +1 -1
- package/camera/default-camera.d.ts +9 -7
- package/camera/index.d.ts +1 -1
- package/camera/interface.d.ts +7 -15
- package/camera/update-publisher.d.ts +16 -16
- package/camera/utils/coordinate-conversion.d.ts +4 -4
- package/camera/utils/index.d.ts +5 -5
- package/camera/utils/position.d.ts +11 -2
- package/index.d.ts +5 -5
- package/index.js +5261 -2
- package/index.js.map +65 -63
- package/input-interpretation/index.d.ts +4 -4
- package/input-interpretation/input-orchestrator.d.ts +5 -5
- package/input-interpretation/input-state-machine/index.d.ts +4 -4
- package/input-interpretation/input-state-machine/kmt-input-context.d.ts +7 -7
- package/input-interpretation/input-state-machine/kmt-input-state-machine.d.ts +16 -11
- package/input-interpretation/input-state-machine/touch-input-context.d.ts +2 -2
- package/input-interpretation/input-state-machine/touch-input-state-machine.d.ts +8 -8
- package/input-interpretation/raw-input-parser/index.d.ts +2 -2
- package/input-interpretation/raw-input-parser/vanilla-kmt-event-parser.d.ts +7 -3
- package/input-interpretation/raw-input-parser/vanilla-touch-event-parser.d.ts +2 -2
- package/input-interpretation/raw-input-publisher/index.d.ts +1 -1
- package/input-interpretation/raw-input-publisher/raw-input-publisher.d.ts +8 -8
- package/package.json +3 -3
- package/utils/canvas-position-dimension.d.ts +2 -1
- package/utils/coordinate-conversions/canvas-viewport.d.ts +1 -1
- package/utils/coordinate-conversions/index.d.ts +3 -0
- package/utils/coordinate-conversions/viewport-world.d.ts +1 -1
- package/utils/coordinate-conversions/window-canvas.d.ts +2 -2
- package/utils/coorindate-conversion.d.ts +2 -2
- package/utils/drawing-utils.d.ts +2 -2
- package/utils/drawing.d.ts +1 -1
- package/utils/index.d.ts +10 -8
- package/utils/scrollbar/index.d.ts +1 -0
- package/utils/scrollbar/scrollbar.d.ts +20 -0
- package/utils/zoomlevel-adjustment.d.ts +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Point } from
|
|
2
|
-
import { BoardCamera } from
|
|
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 {
|
|
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,12 +1,13 @@
|
|
|
1
1
|
import { Point } from '@ue-too/math';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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 {
|
|
9
|
-
import {
|
|
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(
|
|
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
package/camera/interface.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Point } from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { Boundaries } from
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
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
|
|
2
|
-
import { SubscriptionOptions } from
|
|
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
|
-
|
|
44
|
+
pan: CameraPanEventPayload;
|
|
45
45
|
/** Zoom level change event */
|
|
46
|
-
|
|
46
|
+
zoom: CameraZoomEventPayload;
|
|
47
47
|
/** Rotation change event */
|
|
48
|
-
|
|
48
|
+
rotate: CameraRotateEventPayload;
|
|
49
49
|
/** Any camera change event (union of pan, zoom, rotate) */
|
|
50
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
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<
|
|
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<
|
|
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<
|
|
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<
|
|
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[
|
|
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[
|
|
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[
|
|
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
|
|
2
|
-
import { TransformationMatrix } from
|
|
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
|
|
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:
|
|
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
|
package/camera/utils/index.d.ts
CHANGED
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
*
|
|
21
21
|
* @module
|
|
22
22
|
*/
|
|
23
|
-
export * from
|
|
24
|
-
export * from
|
|
25
|
-
export * from
|
|
26
|
-
export * from
|
|
27
|
-
export * from
|
|
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
|
|
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):
|
|
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
|
|
39
|
-
export * from
|
|
40
|
-
export * from
|
|
41
|
-
export * from
|
|
42
|
-
export { default as Board } from
|
|
38
|
+
export * from './boardify';
|
|
39
|
+
export * from './camera';
|
|
40
|
+
export * from './input-interpretation';
|
|
41
|
+
export * from './utils';
|
|
42
|
+
export { default as Board } from './boardify';
|