@ue-too/board 0.9.4 → 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.
Files changed (57) hide show
  1. package/README.md +66 -2
  2. package/boardify/index.d.ts +280 -9
  3. package/camera/base.d.ts +364 -68
  4. package/camera/camera-edge-auto-input.d.ts +105 -0
  5. package/camera/camera-mux/animation-and-lock/animation-and-lock.d.ts +316 -14
  6. package/camera/camera-mux/animation-and-lock/index.d.ts +27 -0
  7. package/camera/camera-mux/animation-and-lock/pan-control-state-machine.d.ts +143 -60
  8. package/camera/camera-mux/animation-and-lock/rotation-control-state-machine.d.ts +143 -55
  9. package/camera/camera-mux/animation-and-lock/zoom-control-state-machine.d.ts +205 -58
  10. package/camera/camera-mux/index.d.ts +26 -0
  11. package/camera/camera-mux/interface.d.ts +161 -5
  12. package/camera/camera-mux/relay.d.ts +79 -16
  13. package/camera/camera-rig/camera-rig.d.ts +536 -94
  14. package/camera/camera-rig/index.d.ts +26 -1
  15. package/camera/camera-rig/pan-handler.d.ts +508 -48
  16. package/camera/camera-rig/rotation-handler.d.ts +353 -31
  17. package/camera/camera-rig/zoom-handler.d.ts +369 -32
  18. package/camera/default-camera.d.ts +173 -26
  19. package/camera/index.d.ts +20 -0
  20. package/camera/interface.d.ts +202 -2
  21. package/camera/update-publisher.d.ts +128 -38
  22. package/camera/utils/coordinate-conversion.d.ts +323 -26
  23. package/camera/utils/index.d.ts +22 -0
  24. package/camera/utils/matrix.d.ts +217 -14
  25. package/camera/utils/position.d.ts +249 -11
  26. package/camera/utils/rotation.d.ts +139 -9
  27. package/camera/utils/zoom.d.ts +72 -4
  28. package/index.d.ts +37 -0
  29. package/index.js +2 -4796
  30. package/index.js.map +39 -38
  31. package/input-interpretation/index.d.ts +29 -0
  32. package/input-interpretation/input-orchestrator.d.ts +197 -0
  33. package/input-interpretation/input-state-machine/index.d.ts +18 -0
  34. package/input-interpretation/input-state-machine/kmt-input-context.d.ts +191 -38
  35. package/input-interpretation/input-state-machine/kmt-input-state-machine.d.ts +201 -85
  36. package/input-interpretation/input-state-machine/touch-input-context.d.ts +76 -10
  37. package/input-interpretation/input-state-machine/touch-input-state-machine.d.ts +138 -17
  38. package/input-interpretation/raw-input-parser/index.d.ts +19 -0
  39. package/input-interpretation/raw-input-parser/vanilla-kmt-event-parser.d.ts +107 -21
  40. package/input-interpretation/raw-input-parser/vanilla-touch-event-parser.d.ts +71 -8
  41. package/input-interpretation/raw-input-publisher/index.d.ts +18 -0
  42. package/input-interpretation/raw-input-publisher/raw-input-publisher.d.ts +133 -37
  43. package/package.json +3 -3
  44. package/utils/canvas-position-dimension.d.ts +282 -1
  45. package/utils/coordinate-conversions/canvas-viewport.d.ts +79 -0
  46. package/utils/coordinate-conversions/viewport-world.d.ts +101 -0
  47. package/utils/coordinate-conversions/window-canvas.d.ts +90 -0
  48. package/utils/coorindate-conversion.d.ts +91 -0
  49. package/utils/drawing.d.ts +151 -3
  50. package/utils/index.d.ts +21 -0
  51. package/utils/observable.d.ts +179 -0
  52. package/utils/ruler.d.ts +36 -0
  53. package/utils/zoomlevel-adjustment.d.ts +144 -8
  54. package/camera/camera-rig/update-batcher/index.d.ts +0 -3
  55. package/camera/camera-rig/update-batcher/position-update-batcher.d.ts +0 -58
  56. package/camera/camera-rig/update-batcher/rotation-update-batcher.d.ts +0 -54
  57. package/camera/camera-rig/update-batcher/zoom-udpate-batcher.d.ts +0 -60
@@ -1,172 +1,262 @@
1
1
  import { Point } from "@ue-too/math";
2
2
  import { SubscriptionOptions } from "../utils/observable";
3
3
  /**
4
- * @description The payload for the pan event.
4
+ * Payload for camera pan (position change) events.
5
+ *
6
+ * @property diff - The displacement vector from previous to new position
5
7
  *
6
8
  * @category Camera
7
9
  */
8
10
  export type CameraPanEventPayload = {
11
+ /** Movement delta in world coordinates */
9
12
  diff: Point;
10
13
  };
11
14
  /**
12
- * @description The payload for the zoom event.
15
+ * Payload for camera zoom (scale change) events.
16
+ *
17
+ * @property deltaZoomAmount - Change in zoom level (positive = zoom in, negative = zoom out)
13
18
  *
14
19
  * @category Camera
15
20
  */
16
21
  export type CameraZoomEventPayload = {
22
+ /** Change in zoom level from previous value */
17
23
  deltaZoomAmount: number;
18
24
  };
19
25
  /**
20
- * @description The payload for the rotate event.
26
+ * Payload for camera rotation events.
27
+ *
28
+ * @property deltaRotation - Change in rotation angle in radians
21
29
  *
22
30
  * @category Camera
23
31
  */
24
32
  export type CameraRotateEventPayload = {
33
+ /** Change in rotation from previous value, in radians */
25
34
  deltaRotation: number;
26
35
  };
27
36
  /**
28
- * @description The mapping of the camera events.
29
- * This is primarily used for type inference.
37
+ * Mapping of camera event names to their payload types.
38
+ * Used for type-safe event subscription.
30
39
  *
31
40
  * @category Camera
32
41
  */
33
42
  export type CameraEventMap = {
43
+ /** Position change event */
34
44
  "pan": CameraPanEventPayload;
45
+ /** Zoom level change event */
35
46
  "zoom": CameraZoomEventPayload;
47
+ /** Rotation change event */
36
48
  "rotate": CameraRotateEventPayload;
49
+ /** Any camera change event (union of pan, zoom, rotate) */
37
50
  "all": AllCameraEventPayload;
38
51
  };
39
52
  /**
40
- * @description The type of the camera rotate event.
41
- * The type is for discriminating the event type when the all event is triggered.
53
+ * Rotation event with discriminated type field for 'all' event handling.
54
+ * Includes type discriminator and rotation payload.
42
55
  *
43
56
  * @category Camera
44
57
  */
45
58
  export type CameraRotateEvent = {
59
+ /** Event type discriminator */
46
60
  type: "rotate";
47
61
  } & CameraRotateEventPayload;
48
62
  /**
49
- * @description The type of the camera pan event.
50
- * The type is for discriminating the event type when the all event is triggered.
63
+ * Pan event with discriminated type field for 'all' event handling.
64
+ * Includes type discriminator and pan payload.
51
65
  *
52
66
  * @category Camera
53
67
  */
54
68
  export type CameraPanEvent = {
69
+ /** Event type discriminator */
55
70
  type: "pan";
56
71
  } & CameraPanEventPayload;
57
72
  /**
58
- * @description The type of the camera zoom event.
59
- * The type is for discriminating the event type when the all event is triggered.
73
+ * Zoom event with discriminated type field for 'all' event handling.
74
+ * Includes type discriminator and zoom payload.
60
75
  *
61
76
  * @category Camera
62
77
  */
63
78
  export type CameraZoomEvent = {
79
+ /** Event type discriminator */
64
80
  type: "zoom";
65
81
  } & CameraZoomEventPayload;
66
82
  /**
67
- * @description The type of the camera state.
83
+ * Snapshot of camera state at the time an event occurs.
84
+ * Passed to all event callbacks alongside the event payload.
68
85
  *
69
86
  * @category Camera
70
87
  */
71
88
  export type CameraState = {
89
+ /** Camera position in world coordinates */
72
90
  position: Point;
91
+ /** Current zoom level */
73
92
  zoomLevel: number;
93
+ /** Current rotation in radians */
74
94
  rotation: number;
75
95
  };
76
96
  /**
77
- * @description The payload type of the "all" camera event payload.
97
+ * Union type of all camera event payloads with type discriminators.
98
+ * Used for the 'all' event which fires for any camera change.
78
99
  *
79
100
  * @category Camera
80
101
  */
81
102
  export type AllCameraEventPayload = CameraRotateEvent | CameraPanEvent | CameraZoomEvent;
82
103
  /**
83
- * @description The callback function type for the camera event.
104
+ * Generic callback function type for camera events.
105
+ *
106
+ * @typeParam K - The event type key from CameraEventMap
107
+ * @param event - The event payload specific to this event type
108
+ * @param cameraState - Current camera state snapshot at the time of the event
84
109
  *
85
110
  * @category Camera
86
111
  */
87
112
  export type Callback<K extends keyof CameraEventMap> = (event: CameraEventMap[K], cameraState: CameraState) => void;
88
113
  /**
89
- * @description The callback function type for the "all" camera event.
114
+ * Callback function type specifically for the 'all' camera event.
115
+ * Receives a discriminated union of all camera events.
90
116
  *
91
117
  * @category Camera
92
118
  */
93
119
  export type ConslidateCallback = (payload: AllCameraEventPayload, cameraState: CameraState) => void;
94
120
  /**
95
- * @description The type of the unsubscribe function.
121
+ * Function returned by event subscriptions that unsubscribes the callback when called.
96
122
  *
97
123
  * @category Camera
98
124
  */
99
125
  export type UnSubscribe = () => void;
100
126
  /**
101
- * @description The observer type for the pan event.
127
+ * Callback type for pan (position change) events.
102
128
  *
103
129
  * @category Camera
104
130
  */
105
131
  export type PanObserver = Callback<"pan">;
106
132
  /**
107
- * @description The observer type for the zoom event.
133
+ * Callback type for zoom (scale change) events.
108
134
  *
109
135
  * @category Camera
110
136
  */
111
137
  export type ZoomObserver = Callback<"zoom">;
112
138
  /**
113
- * @description The observer type for the rotate event.
139
+ * Callback type for rotation events.
114
140
  *
115
141
  * @category Camera
116
142
  */
117
143
  export type RotateObserver = Callback<"rotate">;
118
144
  /**
119
- * @description The observer type for the "all" camera event.
145
+ * Callback type for the 'all' event that fires on any camera change.
120
146
  *
121
147
  * @category Camera
122
148
  */
123
149
  export type AllObserver = Callback<"all">;
124
150
  /**
125
- * @description The camera update publisher.
151
+ * Event publisher for camera state changes using the Observable pattern.
152
+ * Manages subscriptions and notifications for pan, zoom, and rotate events.
153
+ *
154
+ * @remarks
155
+ * This class is used internally by {@link DefaultBoardCamera} to implement the event system.
156
+ * You typically don't instantiate this directly unless building custom camera implementations.
157
+ *
158
+ * Each specific event (pan, zoom, rotate) also triggers the 'all' event, allowing
159
+ * listeners to subscribe to any camera change with a single handler.
160
+ *
161
+ * @example
162
+ * ```typescript
163
+ * const publisher = new CameraUpdatePublisher();
164
+ *
165
+ * // Subscribe to pan events
166
+ * publisher.on('pan', (event, state) => {
167
+ * console.log('Camera panned:', event.diff);
168
+ * });
169
+ *
170
+ * // Notify subscribers of a pan event
171
+ * publisher.notifyPan(
172
+ * { diff: { x: 10, y: 20 } },
173
+ * { position: { x: 100, y: 200 }, zoomLevel: 1, rotation: 0 }
174
+ * );
175
+ * ```
126
176
  *
127
177
  * @category Camera
178
+ * @see {@link DefaultBoardCamera} for the primary consumer of this class
128
179
  */
129
180
  export declare class CameraUpdatePublisher {
130
181
  private pan;
131
182
  private zoom;
132
183
  private rotate;
133
184
  private all;
185
+ /**
186
+ * Creates a new camera event publisher with async observables for each event type.
187
+ */
134
188
  constructor();
135
189
  /**
136
- * @description Notify the pan event.
137
- * Will also notify the "all" event.
190
+ * Notifies all pan event subscribers.
191
+ * Also triggers the 'all' event with type discrimination.
138
192
  *
139
- * @category Camera
193
+ * @param event - Pan event payload containing position delta
194
+ * @param cameraState - Current camera state snapshot
140
195
  */
141
196
  notifyPan(event: CameraEventMap["pan"], cameraState: CameraState): void;
142
197
  /**
143
- * @description Notify the zoom event.
144
- * Will also notify the "all" event.
198
+ * Notifies all zoom event subscribers.
199
+ * Also triggers the 'all' event with type discrimination.
145
200
  *
146
- * @category Camera
201
+ * @param event - Zoom event payload containing zoom delta
202
+ * @param cameraState - Current camera state snapshot
147
203
  */
148
204
  notifyZoom(event: CameraEventMap["zoom"], cameraState: CameraState): void;
149
205
  /**
150
- * @description Notify the rotate event.
151
- * Will also notify the "all" event.
206
+ * Notifies all rotation event subscribers.
207
+ * Also triggers the 'all' event with type discrimination.
152
208
  *
153
- * @category Camera
209
+ * @param event - Rotation event payload containing rotation delta
210
+ * @param cameraState - Current camera state snapshot
154
211
  */
155
212
  notifyRotate(event: CameraEventMap["rotate"], cameraState: CameraState): void;
156
213
  /**
157
- * @description Subscribe to the camera event.
158
- * You can also pass in the abort controller signal within the options to cancel the subscription. Like this:
159
- * ```ts
214
+ * Subscribes to camera events with type-safe callbacks and optional AbortController support.
215
+ *
216
+ * @typeParam K - The event type key from CameraEventMap
217
+ * @param eventName - Event type to subscribe to ('pan', 'zoom', 'rotate', or 'all')
218
+ * @param callback - Function called when the event occurs
219
+ * @param options - Optional subscription options including AbortController signal
220
+ * @returns Function that unsubscribes this callback when called
221
+ *
222
+ * @throws Error if an invalid event name is provided
223
+ *
224
+ * @remarks
225
+ * Use the AbortController pattern for managing multiple subscriptions:
226
+ *
227
+ * @example
228
+ * ```typescript
229
+ * // Basic subscription
230
+ * const unsubscribe = publisher.on('pan', (event, state) => {
231
+ * console.log(`Panned by (${event.diff.x}, ${event.diff.y})`);
232
+ * });
233
+ *
234
+ * // Later: unsubscribe
235
+ * unsubscribe();
236
+ *
237
+ * // Using AbortController for batch management
160
238
  * const controller = new AbortController();
161
- * const unSubscribe = on("pan", (event, cameraState)=>{}, {signal: controller.signal});
239
+ * publisher.on('pan', handlePan, { signal: controller.signal });
240
+ * publisher.on('zoom', handleZoom, { signal: controller.signal });
162
241
  *
163
- * // later in other place where you want to unsubscribe
242
+ * // Unsubscribe all at once
164
243
  * controller.abort();
165
244
  *
245
+ * // Subscribe to all events with type discrimination
246
+ * publisher.on('all', (event, state) => {
247
+ * switch (event.type) {
248
+ * case 'pan':
249
+ * console.log('Pan:', event.diff);
250
+ * break;
251
+ * case 'zoom':
252
+ * console.log('Zoom:', event.deltaZoomAmount);
253
+ * break;
254
+ * case 'rotate':
255
+ * console.log('Rotate:', event.deltaRotation);
256
+ * break;
257
+ * }
258
+ * });
166
259
  * ```
167
- * This means you can cancel multiple subscriptions by aborting the same controller. Just like regular event listeners.
168
- *
169
- * @category Camera
170
260
  */
171
261
  on<K extends keyof CameraEventMap>(eventName: K, callback: (event: CameraEventMap[K], cameraState: CameraState) => void, options?: SubscriptionOptions): UnSubscribe;
172
262
  }