@signosoft/signpad-js 0.4.7 → 0.4.9

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/dist/index.d.ts CHANGED
@@ -66,6 +66,8 @@ declare class CanvasManager {
66
66
  private ctx;
67
67
  /** @private The active configuration for line styles */
68
68
  private currentDrawingOptions;
69
+ /** @private Last drawn point for mouse-fallback stroke continuity */
70
+ private lastDrawPoint;
69
71
  /**
70
72
  * Creates an instance of CanvasManager.
71
73
  * @param canvas - The HTMLCanvasElement to draw on.
@@ -83,9 +85,8 @@ declare class CanvasManager {
83
85
  */
84
86
  updateDrawingOptions(options: IDrawingOptions): void;
85
87
  /**
86
- * Kept for backward compatibility with callers that may still invoke it.
87
- * The actual stroke rendering is done in `src/lib/SignatureCapture.js`.
88
- * @param penData - Ignored.
88
+ * Draws a stroke segment for mouse/touch fallback input.
89
+ * Physical tablet strokes are rendered by SignatureLayer/SignatureCapture.
89
90
  */
90
91
  drawSegment(penData: IPenData_2): void;
91
92
  /**
@@ -182,6 +183,8 @@ declare class ConnectionManager {
182
183
  private penDataToDispatch;
183
184
  /** @private Minimum delay between pen events (approx 60fps) */
184
185
  private throttleDelayMs;
186
+ /** @private Pen data accumulated during a mouse-fallback signing session */
187
+ private mouseFallbackPenLog;
185
188
  private static readonly POINTER_FALLBACK_DEVICE_NAME;
186
189
  /**
187
190
  * @param component - The host SignosoftSignpad instance.
@@ -227,6 +230,7 @@ declare class ConnectionManager {
227
230
  * @returns A promise resolving to true if the session started successfully.
228
231
  */
229
232
  startSigning(canvas: HTMLCanvasElement, drawingOptions?: IDrawingOptions): Promise<boolean>;
233
+ logMouseFallbackPenData(data: IPenData_2): void;
230
234
  /**
231
235
  * Stops the current signing session if active.
232
236
  * @returns Signature data if available.
@@ -331,6 +335,103 @@ export declare interface ILanguageOptions {
331
335
  translations?: ITranslationSet | Record<string, ITranslationSet>;
332
336
  }
333
337
 
338
+ /**
339
+ * `IosTouchManager` handles touch interactions on iOS devices and converts them
340
+ * into standardized `IPenData`. Uses the Touch Events API and reads `Touch.force`
341
+ * for real pressure data on devices that support 3D Touch / Haptic Touch.
342
+ * Falls back to 0.5 pressure on hardware without force sensing.
343
+ */
344
+ declare class IosTouchManager {
345
+ /** @private */
346
+ private canvas;
347
+ /** @private */
348
+ private onPenData;
349
+ /** @private */
350
+ private isDrawing;
351
+ /** @private */
352
+ private sequenceCounter;
353
+ /** @private */
354
+ private sessionStartTime;
355
+ /** @private Debug counter for listener registrations */
356
+ private debugListenerRegistrationCount;
357
+ /** @private */
358
+ private listenersAttached;
359
+ private boundHandleTouchStart;
360
+ private boundHandleTouchMove;
361
+ private boundHandleTouchEnd;
362
+ private boundHandleTouchCancel;
363
+ /**
364
+ * Creates an instance of IosTouchManager.
365
+ * @param canvas - The HTMLCanvasElement to attach touch listeners to.
366
+ * @param onPenDataCallback - The callback function that receives generated IPenData.
367
+ */
368
+ constructor(canvas: HTMLCanvasElement, onPenDataCallback: IPenDataCallback);
369
+ /**
370
+ * Returns whether the user is currently in the middle of a drawing stroke.
371
+ */
372
+ get isCurrentlyDrawing(): boolean;
373
+ /**
374
+ * Attaches touch event listeners to the canvas to enable signature capture.
375
+ */
376
+ addListeners(): void;
377
+ /**
378
+ * Removes touch event listeners from the canvas and stops active drawing.
379
+ */
380
+ removeListeners(): void;
381
+ /**
382
+ * Returns true if touch listeners are currently attached.
383
+ */
384
+ areListenersAttached(): boolean;
385
+ /**
386
+ * Resets the internal session state, including sequence counters and start time.
387
+ */
388
+ resetSession(): void;
389
+ /**
390
+ * Handles the 'touchstart' event: starts a stroke and initializes the session time.
391
+ * @private
392
+ */
393
+ private handleTouchStart;
394
+ /**
395
+ * Handles the 'touchmove' event: continues the stroke.
396
+ * @private
397
+ */
398
+ private handleTouchMove;
399
+ /**
400
+ * Handles the 'touchend' event: ends the stroke.
401
+ * @private
402
+ */
403
+ private handleTouchEnd;
404
+ /**
405
+ * Handles the 'touchcancel' event: terminates a stroke interrupted by the OS.
406
+ * @private
407
+ */
408
+ private handleTouchCancel;
409
+ /**
410
+ * Core logic to transform a Touch into IPenData.
411
+ * @param touch - The raw browser Touch object.
412
+ * @param inContact - Whether the finger is actively drawing on the surface.
413
+ * @private
414
+ */
415
+ private processTouchEvent;
416
+ /**
417
+ * Returns the pressure value from a Touch event.
418
+ * Reads Touch.force (0–1) on devices with 3D Touch / Haptic Touch.
419
+ * Falls back to 0.5 when force is unavailable or zero (non-force hardware).
420
+ * @private
421
+ */
422
+ private getPressure;
423
+ /**
424
+ * Converts absolute touch coordinates into a normalized 0-1 range relative to canvas size.
425
+ * @private
426
+ */
427
+ private getNormalizedCoordinates;
428
+ /**
429
+ * Calculates the seconds elapsed since the start of the signature session.
430
+ * @private
431
+ */
432
+ private timestampToSeconds;
433
+ }
434
+
334
435
  declare interface IPenData_2 {
335
436
  relativeX: number;
336
437
  relativeY: number;
@@ -614,7 +715,7 @@ export declare class SignosoftSignpad extends LitElement {
614
715
  setHasStartedDrawing(value: boolean): void;
615
716
  setDeviceStatusText(value: string): void;
616
717
  canvasManager: CanvasManager | null;
617
- pointerManager: PointerManager | null;
718
+ pointerManager: PointerManager | IosTouchManager | null;
618
719
  connectionManager: ConnectionManager;
619
720
  stateManager: StateManager;
620
721
  buttonManager: ButtonManager;