@ue-too/board 0.12.0 → 0.13.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.
@@ -101,6 +101,7 @@ export declare class InputOrchestrator {
101
101
  * ```
102
102
  */
103
103
  processInputEventOutput(output: any): void;
104
+ processInputEvent(input: OutputEvent): void;
104
105
  /**
105
106
  * Type guard to check if an output value is a valid OutputEvent.
106
107
  *
@@ -116,6 +116,17 @@ export declare class CanvasCacheInWebWorker implements Canvas {
116
116
  setCursor(style: "grab" | "default" | "grabbing"): void;
117
117
  get detached(): boolean;
118
118
  }
119
+ /**
120
+ * A proxy for the canvas element to prevent constant invoking of the getBoundingClientRect method.
121
+ * @remarks This is mainly used as a proxy to the canvas to prevent invoking the getBoundingClientRect method on the canvas every time a pointer event is triggered or a coordinate conversion is needed. Also to autoscale the canvas buffer depending on the device pixel ratio. It's important to note that in normal circumstances, you would not need to set the size of the canvas manually; you should use the css style width and height to set the size of the canvas.
122
+ * @category Input State Machine
123
+ * @see {@link Canvas} for the interface that this class implements
124
+ * @see {@link Observable} for the observable that this class emits
125
+ * @see {@link Observer} for the observer that can subscribe to the observable
126
+ * @see {@link SubscriptionOptions} for the options that can be passed to the subscribe method
127
+ * @see {@link SynchronousObservable} for the synchronous observable that this class emits
128
+ * @see {@link CanvasPositionDimensionPublisher} for the publisher that is used to publish the canvas dimensions
129
+ */
119
130
  export declare class CanvasProxy implements Canvas, Observable<[CanvasDimensions]> {
120
131
  private _width;
121
132
  private _height;
@@ -138,11 +149,13 @@ export declare class CanvasProxy implements Canvas, Observable<[CanvasDimensions
138
149
  * the width is synonymous with the canvas style width not the canvas width
139
150
  */
140
151
  setWidth(width: number): void;
152
+ setCanvasWidth(width: number): void;
141
153
  /**
142
154
  * set the height of the canvas
143
155
  * the height is synonymous with the canvas style height not the canvas height
144
156
  */
145
157
  setHeight(height: number): void;
158
+ setCanvasHeight(height: number): void;
146
159
  get height(): number;
147
160
  get position(): Point;
148
161
  setCursor(style: "grab" | "default" | "grabbing"): void;
@@ -231,7 +244,7 @@ export declare class WorkerRelayCanvas implements Canvas {
231
244
  * - `true`: Standard screen coordinates (Y increases downward)
232
245
  * - `false`: Inverted coordinates (Y increases upward)
233
246
  *
234
- * This interface extends BaseContext from the @ue-too/being state machine library,
247
+ * This interface extends BaseContext from the \@ue-too/being state machine library,
235
248
  * inheriting setup() and cleanup() lifecycle methods.
236
249
  *
237
250
  * @category Input State Machine
@@ -332,9 +345,11 @@ export declare class ObservableInputTracker implements KmtInputContext {
332
345
  private _initialCursorPosition;
333
346
  private _kmtTrackpadTrackScore;
334
347
  private _mode;
348
+ private _deciding;
335
349
  constructor(canvasOperator: Canvas);
336
350
  get mode(): 'kmt' | 'trackpad' | 'TBD';
337
351
  setMode(mode: 'kmt' | 'trackpad' | 'TBD'): void;
352
+ enableInputModeDetection(): void;
338
353
  get kmtTrackpadTrackScore(): number;
339
354
  subtractKmtTrackpadTrackScore(): void;
340
355
  addKmtTrackpadTrackScore(): void;
@@ -1,6 +1,6 @@
1
1
  import { EventReactions, EventGuards, Guard, TemplateState, TemplateStateMachine, EventArgs, EventResult, CreateStateType } from "@ue-too/being";
2
2
  import type { Point } from "@ue-too/math";
3
- import { CursorStyle, KmtInputContext } from "./kmt-input-context";
3
+ import { Canvas, CursorStyle, KmtInputContext } from "./kmt-input-context";
4
4
  declare const KMT_INPUT_STATES: readonly ["IDLE", "READY_TO_PAN_VIA_SPACEBAR", "READY_TO_PAN_VIA_SCROLL_WHEEL", "PAN", "INITIAL_PAN", "PAN_VIA_SCROLL_WHEEL", "DISABLED"];
5
5
  /**
6
6
  * Possible states of the Keyboard/Mouse/Trackpad input state machine.
@@ -185,7 +185,6 @@ export declare class KmtIdleState extends TemplateState<KmtInputEventMapping, Km
185
185
  scrollZoom: (context: KmtInputContext, payload: ScrollWithCtrlEventPayload) => KmtOutputEvent;
186
186
  scrollHandler: (context: KmtInputContext, payload: ScrollWithCtrlEventPayload) => KmtOutputEvent;
187
187
  scrollWithCtrlHandler: (context: KmtInputContext, payload: ScrollWithCtrlEventPayload) => KmtOutputEvent;
188
- get eventReactions(): EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates, KmtInputEventOutputMapping>;
189
188
  protected _eventReactions: EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates, KmtInputEventOutputMapping>;
190
189
  uponEnter(context: KmtInputContext): void;
191
190
  spacebarDownHandler(context: KmtInputContext, payload: EmptyPayload): number;
@@ -195,7 +194,7 @@ export declare class DisabledState extends TemplateState<KmtInputEventMapping, K
195
194
  constructor();
196
195
  uponEnter(context: KmtInputContext): void;
197
196
  beforeExit(context: KmtInputContext): void;
198
- get eventReactions(): EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates, KmtInputEventOutputMapping>;
197
+ protected _eventReactions: EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates, KmtInputEventOutputMapping>;
199
198
  }
200
199
  /**
201
200
  * @description The ready to pan via space bar state of the keyboard mouse and trackpad input state machine.
@@ -206,7 +205,6 @@ export declare class ReadyToPanViaSpaceBarState extends TemplateState<KmtInputEv
206
205
  constructor();
207
206
  protected _eventReactions: EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates, KmtInputEventOutputMapping>;
208
207
  uponEnter(context: KmtInputContext): void;
209
- get eventReactions(): EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates, KmtInputEventOutputMapping>;
210
208
  leftPointerDownHandler(context: KmtInputContext, payload: PointerEventPayload): void;
211
209
  }
212
210
  /**
@@ -217,7 +215,6 @@ export declare class ReadyToPanViaSpaceBarState extends TemplateState<KmtInputEv
217
215
  export declare class InitialPanState extends TemplateState<KmtInputEventMapping, KmtInputContext, KmtInputStates, KmtInputEventOutputMapping> {
218
216
  constructor();
219
217
  protected _eventReactions: EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates, KmtInputEventOutputMapping>;
220
- get eventReactions(): EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates, KmtInputEventOutputMapping>;
221
218
  uponEnter(context: KmtInputContext): void;
222
219
  leftPointerMoveHandler(context: KmtInputContext, payload: PointerEventPayload): KmtOutputEvent;
223
220
  }
@@ -229,7 +226,6 @@ export declare class InitialPanState extends TemplateState<KmtInputEventMapping,
229
226
  export declare class ReadyToPanViaScrollWheelState extends TemplateState<KmtInputEventMapping, KmtInputContext, KmtInputStates, KmtInputEventOutputMapping> {
230
227
  constructor();
231
228
  protected _eventReactions: EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates, KmtInputEventOutputMapping>;
232
- get eventReactions(): EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates, KmtInputEventOutputMapping>;
233
229
  uponEnter(context: KmtInputContext): void;
234
230
  }
235
231
  /**
@@ -240,7 +236,6 @@ export declare class ReadyToPanViaScrollWheelState extends TemplateState<KmtInpu
240
236
  export declare class PanState extends TemplateState<KmtInputEventMapping, KmtInputContext, KmtInputStates, KmtInputEventOutputMapping> {
241
237
  constructor();
242
238
  protected _eventReactions: EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates, KmtInputEventOutputMapping>;
243
- get eventReactions(): EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates, KmtInputEventOutputMapping>;
244
239
  uponEnter(context: KmtInputContext): void;
245
240
  beforeExit(context: KmtInputContext): void;
246
241
  leftPointerMoveHandler(context: KmtInputContext, payload: PointerEventPayload): KmtOutputEvent;
@@ -252,13 +247,11 @@ export declare class PanState extends TemplateState<KmtInputEventMapping, KmtInp
252
247
  */
253
248
  export declare class PanViaScrollWheelState extends TemplateState<KmtInputEventMapping, KmtInputContext, KmtInputStates, KmtInputEventOutputMapping> {
254
249
  protected _eventReactions: EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates, KmtInputEventOutputMapping>;
255
- get eventReactions(): EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates, KmtInputEventOutputMapping>;
256
250
  middlePointerMoveHandler(context: KmtInputContext, payload: PointerEventPayload): KmtOutputEvent;
257
251
  uponEnter(context: KmtInputContext): void;
258
252
  }
259
253
  export declare class KmtEmptyState extends TemplateState<KmtInputEventMapping, KmtInputContext, KmtInputStates, KmtInputEventOutputMapping> {
260
254
  constructor();
261
- get eventReactions(): EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates, KmtInputEventOutputMapping>;
262
255
  }
263
256
  /**
264
257
  * Type alias for the KMT input state machine.
@@ -313,6 +306,7 @@ export type KmtInputStateMachine = TemplateStateMachine<KmtInputEventMapping, Km
313
306
  * ```
314
307
  */
315
308
  export declare function createKmtInputStateMachine(context: KmtInputContext): KmtInputStateMachine;
309
+ export declare function createKmtInputStateMachineWithCanvas(canvas: Canvas): KmtInputStateMachine;
316
310
  export declare class KmtInputStateMachineWebWorkerProxy extends TemplateStateMachine<KmtInputEventMapping, KmtInputContext, KmtInputStates, KmtInputEventOutputMapping> {
317
311
  private _webworker;
318
312
  constructor(webworker: Worker);
@@ -99,10 +99,9 @@ export type TouchInputEventOutputMapping = {
99
99
  * @category Input State Machine - Touch
100
100
  */
101
101
  export declare class IdleState extends TemplateState<TouchEventMapping, TouchContext, TouchStates, TouchInputEventOutputMapping> {
102
- private _eventReactions;
102
+ protected _eventReactions: EventReactions<TouchEventMapping, TouchContext, TouchStates, TouchInputEventOutputMapping>;
103
103
  protected _guards: Guard<TouchContext, "touchPointsCount">;
104
104
  protected _eventGuards: Partial<EventGuards<TouchEventMapping, TouchStates, TouchContext, typeof this._guards>>;
105
- get eventReactions(): EventReactions<TouchEventMapping, TouchContext, TouchStates, TouchInputEventOutputMapping>;
106
105
  touchstart(context: TouchContext, payload: TouchEventPayload): void;
107
106
  touchend(context: TouchContext, payload: TouchEventPayload): void;
108
107
  }
@@ -112,8 +111,7 @@ export declare class IdleState extends TemplateState<TouchEventMapping, TouchCon
112
111
  * @category Input State Machine
113
112
  */
114
113
  export declare class PendingState extends TemplateState<TouchEventMapping, TouchContext, TouchStates, TouchInputEventOutputMapping> {
115
- private _eventReactions;
116
- get eventReactions(): EventReactions<TouchEventMapping, TouchContext, TouchStates, TouchInputEventOutputMapping>;
114
+ protected _eventReactions: EventReactions<TouchEventMapping, TouchContext, TouchStates, TouchInputEventOutputMapping>;
117
115
  touchstart(context: TouchContext, payload: TouchEventPayload): void;
118
116
  touchend(context: TouchContext, payload: TouchEventPayload): void;
119
117
  touchmove(context: TouchContext, payload: TouchEventPayload): TouchOutputEvent;
@@ -124,8 +122,7 @@ export declare class PendingState extends TemplateState<TouchEventMapping, Touch
124
122
  * @category Input State Machine
125
123
  */
126
124
  export declare class InProgressState extends TemplateState<TouchEventMapping, TouchContext, TouchStates, TouchInputEventOutputMapping> {
127
- private _eventReactions;
128
- get eventReactions(): EventReactions<TouchEventMapping, TouchContext, TouchStates, TouchInputEventOutputMapping>;
125
+ protected _eventReactions: EventReactions<TouchEventMapping, TouchContext, TouchStates, TouchInputEventOutputMapping>;
129
126
  touchmove(context: TouchContext, payload: TouchEventPayload): TouchOutputEvent;
130
127
  touchend(context: TouchContext, payload: TouchEventPayload): void;
131
128
  }
@@ -19,10 +19,10 @@ export interface KMTEventParser {
19
19
  tearDown(): void;
20
20
  /** Attaches to a new canvas element */
21
21
  attach(canvas: HTMLCanvasElement): void;
22
- /** The state machine that processes parsed events */
23
- stateMachine: KmtInputStateMachine;
24
- /** The orchestrator that handles state machine outputs */
25
- orchestrator: InputOrchestrator;
22
+ /** Disables the parser; the event listeners are still attached just not processing any events*/
23
+ disable(): void;
24
+ /** Enables the parser */
25
+ enable(): void;
26
26
  }
27
27
  /**
28
28
  * Minimal pointer event interface for framework interoperability.
@@ -156,9 +156,8 @@ export declare class VanillaKMTEventParser implements KMTEventParser {
156
156
  private _canvas?;
157
157
  constructor(kmtInputStateMachine: KmtInputStateMachine, orchestrator: InputOrchestrator, canvas?: HTMLCanvasElement | SVGSVGElement);
158
158
  get disabled(): boolean;
159
- set disabled(value: boolean);
160
- get stateMachine(): KmtInputStateMachine;
161
- get orchestrator(): InputOrchestrator;
159
+ disable(): void;
160
+ enable(): void;
162
161
  addEventListeners(signal: AbortSignal): void;
163
162
  setUp(): void;
164
163
  tearDown(): void;
@@ -12,22 +12,16 @@ import type { InputOrchestrator } from "../input-orchestrator";
12
12
  export interface TouchEventParser {
13
13
  /** Whether all touch input is disabled */
14
14
  disabled: boolean;
15
- /** Whether pan gestures are disabled */
16
- panDisabled: boolean;
17
- /** Whether zoom gestures are disabled */
18
- zoomDisabled: boolean;
19
- /** Whether rotation gestures are disabled (currently unused) */
20
- rotateDisabled: boolean;
21
15
  /** Initializes event listeners */
22
16
  setUp(): void;
23
17
  /** Removes event listeners and cleans up */
24
18
  tearDown(): void;
25
19
  /** Attaches to a new canvas element */
26
20
  attach(canvas: HTMLCanvasElement): void;
27
- /** The state machine that processes parsed events */
28
- stateMachine: TouchInputStateMachine;
29
- /** The orchestrator that handles state machine outputs */
30
- orchestrator: InputOrchestrator;
21
+ /** Disables the parser; the event listeners are still attached just not processing any events*/
22
+ disable(): void;
23
+ /** Enables the parser */
24
+ enable(): void;
31
25
  }
32
26
  /**
33
27
  * DOM event parser for touch input.
@@ -88,22 +82,16 @@ export declare class VanillaTouchEventParser implements TouchEventParser {
88
82
  private _stateMachine;
89
83
  private _orchestrator;
90
84
  private _abortController;
91
- constructor(touchInputStateMachine: TouchInputStateMachine, orchestrator: InputOrchestrator, canvas?: HTMLCanvasElement);
92
- get stateMachine(): TouchInputStateMachine;
85
+ constructor(touchInputStateMachine: TouchInputStateMachine, orchestrator: InputOrchestrator, canvas?: HTMLCanvasElement | SVGSVGElement);
93
86
  get orchestrator(): InputOrchestrator;
94
- get touchStateMachine(): TouchInputStateMachine;
95
87
  bindListeners(): void;
96
88
  enableStrategy(): void;
97
89
  disableStrategy(): void;
98
90
  setUp(): void;
99
91
  tearDown(): void;
100
92
  get disabled(): boolean;
101
- get panDisabled(): boolean;
102
- set panDisabled(panDisabled: boolean);
103
- get zoomDisabled(): boolean;
104
- set zoomDisabled(zoomDisabled: boolean);
105
- get rotateDisabled(): boolean;
106
- set rotateDisabled(rotateDisabled: boolean);
93
+ disable(): void;
94
+ enable(): void;
107
95
  private processEvent;
108
96
  touchstartHandler(e: TouchEvent): void;
109
97
  touchcancelHandler(e: TouchEvent): void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ue-too/board",
3
3
  "type": "module",
4
- "version": "0.12.0",
4
+ "version": "0.13.0",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./index.d.ts",
@@ -14,8 +14,8 @@
14
14
  "types": "./index.d.ts",
15
15
  "module": "./index.js",
16
16
  "dependencies": {
17
- "@ue-too/being": "^0.12.0",
18
- "@ue-too/math": "^0.12.0"
17
+ "@ue-too/being": "^0.13.0",
18
+ "@ue-too/math": "^0.13.0"
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",
@@ -143,6 +143,8 @@ export declare class CanvasPositionDimensionPublisher {
143
143
  private scrollHandler?;
144
144
  private resizeHandler?;
145
145
  private _observers;
146
+ private _abortController;
147
+ private _pixelRatioAbortController;
146
148
  /**
147
149
  * Creates a new Canvas position/dimension publisher.
148
150
  *