@signosoft/signpad-js 0.5.0 → 0.5.1
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 +0 -1
- package/dist/index.d.ts +9 -271
- package/dist/signosoft-signpad.js +1263 -1621
- package/dist/signosoft-signpad.umd.cjs +33 -33
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -679,7 +679,6 @@ The complete list of keys that can be translated is maintained in `src/i18n/en.j
|
|
|
679
679
|
| `CONNECTION_ERROR` | Connection error. |
|
|
680
680
|
| `ERROR_DISCONNECTION` | Error during disconnection. |
|
|
681
681
|
| `ERROR_INSTANTIATING_DRIVER` | Error instantiating driver. |
|
|
682
|
-
| `SIGNPAD_DISCONNECTED` | Signpad disconnected. |
|
|
683
682
|
| `INVALID_LICENSE_KEY` | Invalid license key. |
|
|
684
683
|
| `READY_TO_CONNECT` | Ready to connect. |
|
|
685
684
|
| `SIGNPAD_DETECTED` | Signpad detected. Click 'Connect Signpad' to begin. |
|
package/dist/index.d.ts
CHANGED
|
@@ -66,8 +66,6 @@ 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;
|
|
71
69
|
/**
|
|
72
70
|
* Creates an instance of CanvasManager.
|
|
73
71
|
* @param canvas - The HTMLCanvasElement to draw on.
|
|
@@ -84,11 +82,6 @@ declare class CanvasManager {
|
|
|
84
82
|
* @param options - The new drawing configuration.
|
|
85
83
|
*/
|
|
86
84
|
updateDrawingOptions(options: IDrawingOptions): void;
|
|
87
|
-
/**
|
|
88
|
-
* Draws a stroke segment for mouse/touch fallback input.
|
|
89
|
-
* Physical tablet strokes are rendered by SignatureLayer.
|
|
90
|
-
*/
|
|
91
|
-
drawSegment(penData: IPenData): void;
|
|
92
85
|
/**
|
|
93
86
|
* Wipes the canvas clean and resets the drawing state.
|
|
94
87
|
*/
|
|
@@ -157,12 +150,6 @@ declare class ConfigManager {
|
|
|
157
150
|
private clearConfigEventHandlers;
|
|
158
151
|
}
|
|
159
152
|
|
|
160
|
-
export declare interface ConnectAttempt {
|
|
161
|
-
connected: boolean;
|
|
162
|
-
deviceInfo: any | null;
|
|
163
|
-
isPointerFallback: boolean;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
153
|
/**
|
|
167
154
|
* `ConnectionManager` handles the lifecycle of the signature pad connection.
|
|
168
155
|
* It manages driver initialization, license authentication, device handshaking,
|
|
@@ -173,8 +160,6 @@ declare class ConnectionManager {
|
|
|
173
160
|
private component;
|
|
174
161
|
/** @private The low-level driver instance */
|
|
175
162
|
private sigLayer;
|
|
176
|
-
/** @private Debug counter for callback registrations */
|
|
177
|
-
private debugCallbackRegistrationCount;
|
|
178
163
|
/** @private Cached device info from the last successful connect */
|
|
179
164
|
private cachedDeviceInfo;
|
|
180
165
|
/** @private Timestamp of the last pen event dispatch */
|
|
@@ -183,7 +168,6 @@ declare class ConnectionManager {
|
|
|
183
168
|
private penDataToDispatch;
|
|
184
169
|
/** @private Minimum delay between pen events (approx 60fps) */
|
|
185
170
|
private throttleDelayMs;
|
|
186
|
-
private penDataLog;
|
|
187
171
|
/** @private Wall-clock time when the current signing session started, for timestampInSeconds */
|
|
188
172
|
private sessionStartTime;
|
|
189
173
|
private static readonly POINTER_FALLBACK_DEVICE_NAME;
|
|
@@ -219,11 +203,6 @@ declare class ConnectionManager {
|
|
|
219
203
|
* @returns True if a device is connected.
|
|
220
204
|
*/
|
|
221
205
|
isDeviceConnected(): boolean;
|
|
222
|
-
/**
|
|
223
|
-
* Returns true if the SignatureLayer is in signing mode.
|
|
224
|
-
* @returns True if a signing session is active.
|
|
225
|
-
*/
|
|
226
|
-
isSigningActive(): boolean;
|
|
227
206
|
/**
|
|
228
207
|
* Starts a signing session on the provided canvas.
|
|
229
208
|
* @param canvasElement - Optional canvas reference.
|
|
@@ -231,13 +210,11 @@ declare class ConnectionManager {
|
|
|
231
210
|
* @returns A promise resolving to true if the session started successfully.
|
|
232
211
|
*/
|
|
233
212
|
startSigning(canvas: HTMLCanvasElement, drawingOptions?: IDrawingOptions): Promise<boolean>;
|
|
234
|
-
logPenData(data: IPenData): void;
|
|
235
213
|
/**
|
|
236
214
|
* Calculates the seconds elapsed since the start of the signing session.
|
|
237
215
|
* @private
|
|
238
216
|
*/
|
|
239
217
|
private timestampToSeconds;
|
|
240
|
-
private buildConfirmationData;
|
|
241
218
|
/**
|
|
242
219
|
* Stops the current signing session if active.
|
|
243
220
|
* @returns Signature data if available.
|
|
@@ -287,15 +264,6 @@ declare class ConnectionManager {
|
|
|
287
264
|
* This step only decides state; it does not trigger HID dialog itself.
|
|
288
265
|
*/
|
|
289
266
|
private resolveConnectionTarget;
|
|
290
|
-
/**
|
|
291
|
-
* Starts a fresh signing session for whichever target mode was selected.
|
|
292
|
-
*/
|
|
293
|
-
private prepareSigningSession;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
export declare interface ConnectionTarget {
|
|
297
|
-
targetState: SignpadState;
|
|
298
|
-
statusMessageKey: string;
|
|
299
267
|
}
|
|
300
268
|
|
|
301
269
|
export declare enum DeviceStatusText {
|
|
@@ -315,14 +283,6 @@ export declare interface IDrawingOptions {
|
|
|
315
283
|
color?: string;
|
|
316
284
|
}
|
|
317
285
|
|
|
318
|
-
export declare interface IDriverInfo {
|
|
319
|
-
name: string;
|
|
320
|
-
ready: boolean;
|
|
321
|
-
aspectRatio: number;
|
|
322
|
-
isCanvasStyleTablet: boolean;
|
|
323
|
-
supportedCommands: string[];
|
|
324
|
-
}
|
|
325
|
-
|
|
326
286
|
export declare interface IEventCallbacks {
|
|
327
287
|
onConnect?: (event: CustomEvent<{
|
|
328
288
|
deviceInfo: any;
|
|
@@ -342,119 +302,24 @@ export declare interface ILanguageOptions {
|
|
|
342
302
|
translations?: ITranslationSet | Record<string, ITranslationSet>;
|
|
343
303
|
}
|
|
344
304
|
|
|
345
|
-
/**
|
|
346
|
-
* `IosTouchManager` handles touch interactions on iOS devices and converts them
|
|
347
|
-
* into standardized `IPenData`. Uses the Touch Events API and reads `Touch.force`
|
|
348
|
-
* for real pressure data on devices that support 3D Touch / Haptic Touch.
|
|
349
|
-
* Falls back to 0.5 pressure on hardware without force sensing.
|
|
350
|
-
*/
|
|
351
|
-
declare class IosTouchManager {
|
|
352
|
-
/** @private */
|
|
353
|
-
private canvas;
|
|
354
|
-
/** @private */
|
|
355
|
-
private onPenData;
|
|
356
|
-
/** @private */
|
|
357
|
-
private isDrawing;
|
|
358
|
-
/** @private */
|
|
359
|
-
private sequenceCounter;
|
|
360
|
-
/** @private */
|
|
361
|
-
private sessionStartTime;
|
|
362
|
-
/** @private Debug counter for listener registrations */
|
|
363
|
-
private debugListenerRegistrationCount;
|
|
364
|
-
/** @private */
|
|
365
|
-
private listenersAttached;
|
|
366
|
-
private boundHandleTouchStart;
|
|
367
|
-
private boundHandleTouchMove;
|
|
368
|
-
private boundHandleTouchEnd;
|
|
369
|
-
private boundHandleTouchCancel;
|
|
370
|
-
/**
|
|
371
|
-
* Creates an instance of IosTouchManager.
|
|
372
|
-
* @param canvas - The HTMLCanvasElement to attach touch listeners to.
|
|
373
|
-
* @param onPenDataCallback - The callback function that receives generated IPenData.
|
|
374
|
-
*/
|
|
375
|
-
constructor(canvas: HTMLCanvasElement, onPenDataCallback: IPenDataCallback);
|
|
376
|
-
/**
|
|
377
|
-
* Returns whether the user is currently in the middle of a drawing stroke.
|
|
378
|
-
*/
|
|
379
|
-
get isCurrentlyDrawing(): boolean;
|
|
380
|
-
/**
|
|
381
|
-
* Attaches touch event listeners to the canvas to enable signature capture.
|
|
382
|
-
*/
|
|
383
|
-
addListeners(): void;
|
|
384
|
-
/**
|
|
385
|
-
* Removes touch event listeners from the canvas and stops active drawing.
|
|
386
|
-
*/
|
|
387
|
-
removeListeners(): void;
|
|
388
|
-
/**
|
|
389
|
-
* Returns true if touch listeners are currently attached.
|
|
390
|
-
*/
|
|
391
|
-
areListenersAttached(): boolean;
|
|
392
|
-
/**
|
|
393
|
-
* Resets the internal session state, including sequence counters and start time.
|
|
394
|
-
*/
|
|
395
|
-
resetSession(): void;
|
|
396
|
-
/**
|
|
397
|
-
* Handles the 'touchstart' event: starts a stroke and initializes the session time.
|
|
398
|
-
* @private
|
|
399
|
-
*/
|
|
400
|
-
private handleTouchStart;
|
|
401
|
-
/**
|
|
402
|
-
* Handles the 'touchmove' event: continues the stroke.
|
|
403
|
-
* @private
|
|
404
|
-
*/
|
|
405
|
-
private handleTouchMove;
|
|
406
|
-
/**
|
|
407
|
-
* Handles the 'touchend' event: ends the stroke.
|
|
408
|
-
* @private
|
|
409
|
-
*/
|
|
410
|
-
private handleTouchEnd;
|
|
411
|
-
/**
|
|
412
|
-
* Handles the 'touchcancel' event: terminates a stroke interrupted by the OS.
|
|
413
|
-
* @private
|
|
414
|
-
*/
|
|
415
|
-
private handleTouchCancel;
|
|
416
|
-
/**
|
|
417
|
-
* Core logic to transform a Touch into IPenData.
|
|
418
|
-
* @param touch - The raw browser Touch object.
|
|
419
|
-
* @param inContact - Whether the finger is actively drawing on the surface.
|
|
420
|
-
* @private
|
|
421
|
-
*/
|
|
422
|
-
private processTouchEvent;
|
|
423
|
-
/**
|
|
424
|
-
* Returns the pressure value from a Touch event.
|
|
425
|
-
* Reads Touch.force (0–1) on devices with 3D Touch / Haptic Touch.
|
|
426
|
-
* Falls back to 0.5 when force is unavailable or zero (non-force hardware).
|
|
427
|
-
* @private
|
|
428
|
-
*/
|
|
429
|
-
private getPressure;
|
|
430
|
-
/**
|
|
431
|
-
* Converts absolute touch coordinates into a normalized 0-1 range relative to canvas size.
|
|
432
|
-
* @private
|
|
433
|
-
*/
|
|
434
|
-
private getNormalizedCoordinates;
|
|
435
|
-
/**
|
|
436
|
-
* Calculates the seconds elapsed since the start of the signature session.
|
|
437
|
-
* @private
|
|
438
|
-
*/
|
|
439
|
-
private timestampToSeconds;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
305
|
export declare interface IPenData {
|
|
443
306
|
relativeX: number;
|
|
444
307
|
relativeY: number;
|
|
445
|
-
absoluteX?: number;
|
|
446
|
-
absoluteY?: number;
|
|
447
308
|
pressure?: number;
|
|
448
|
-
ready?: boolean;
|
|
449
|
-
sequence?: number;
|
|
450
309
|
timestamp?: number;
|
|
451
310
|
timestampInSeconds?: number;
|
|
452
311
|
inContact: boolean;
|
|
453
312
|
[key: string]: any;
|
|
454
313
|
}
|
|
455
314
|
|
|
456
|
-
export declare interface
|
|
457
|
-
|
|
315
|
+
export declare interface IPenDataPoint {
|
|
316
|
+
relativeX: number;
|
|
317
|
+
relativeY: number;
|
|
318
|
+
absoluteX?: number;
|
|
319
|
+
absoluteY?: number;
|
|
320
|
+
pressure: number;
|
|
321
|
+
timestamp: number;
|
|
322
|
+
inContact: boolean;
|
|
458
323
|
}
|
|
459
324
|
|
|
460
325
|
export declare interface ISignatureCanvasMeta {
|
|
@@ -471,7 +336,7 @@ export declare interface ISignatureCanvasMeta {
|
|
|
471
336
|
}
|
|
472
337
|
|
|
473
338
|
export declare type ISignatureConfirmationData = [
|
|
474
|
-
points:
|
|
339
|
+
points: IPenDataPoint[],
|
|
475
340
|
imageBase64: string,
|
|
476
341
|
metadata: ISignatureResultMeta
|
|
477
342
|
];
|
|
@@ -590,110 +455,6 @@ declare class LocalizationManager {
|
|
|
590
455
|
private constructUrl;
|
|
591
456
|
}
|
|
592
457
|
|
|
593
|
-
/**
|
|
594
|
-
* `PointerManager` handles pointer interactions on a canvas element and converts them
|
|
595
|
-
* into standardized `IPenData`. This serves as a fallback mechanism for
|
|
596
|
-
* signature capture when a physical signature tablet is not available.
|
|
597
|
-
* Uses the Pointer Events API to support mouse, touch, and Apple Pencil uniformly.
|
|
598
|
-
*/
|
|
599
|
-
declare class PointerManager {
|
|
600
|
-
/** @private */
|
|
601
|
-
private canvas;
|
|
602
|
-
/** @private */
|
|
603
|
-
private onPenData;
|
|
604
|
-
/** @private */
|
|
605
|
-
private isDrawing;
|
|
606
|
-
/** @private */
|
|
607
|
-
private sequenceCounter;
|
|
608
|
-
/** @private */
|
|
609
|
-
private sessionStartTime;
|
|
610
|
-
/** @private Debug counter for listener registrations */
|
|
611
|
-
private debugListenerRegistrationCount;
|
|
612
|
-
/** @private */
|
|
613
|
-
private listenersAttached;
|
|
614
|
-
private boundHandlePointerDown;
|
|
615
|
-
private boundHandlePointerMove;
|
|
616
|
-
private boundHandlePointerUp;
|
|
617
|
-
private boundHandlePointerLeave;
|
|
618
|
-
private boundHandlePointerCancel;
|
|
619
|
-
/**
|
|
620
|
-
* Creates an instance of PointerManager.
|
|
621
|
-
* @param canvas - The HTMLCanvasElement to attach pointer listeners to.
|
|
622
|
-
* @param onPenDataCallback - The callback function that receives generated IPenData.
|
|
623
|
-
*/
|
|
624
|
-
constructor(canvas: HTMLCanvasElement, onPenDataCallback: IPenDataCallback);
|
|
625
|
-
/**
|
|
626
|
-
* Returns whether the user is currently in the middle of a drawing stroke.
|
|
627
|
-
*/
|
|
628
|
-
get isCurrentlyDrawing(): boolean;
|
|
629
|
-
/**
|
|
630
|
-
* Attaches pointer event listeners to the canvas to enable signature capture.
|
|
631
|
-
*/
|
|
632
|
-
addListeners(): void;
|
|
633
|
-
/**
|
|
634
|
-
* Removes pointer event listeners from the canvas and stops active drawing.
|
|
635
|
-
*/
|
|
636
|
-
removeListeners(): void;
|
|
637
|
-
/**
|
|
638
|
-
* Returns true if pointer listeners are currently attached.
|
|
639
|
-
*/
|
|
640
|
-
areListenersAttached(): boolean;
|
|
641
|
-
/**
|
|
642
|
-
* Resets the internal session state, including sequence counters and start time.
|
|
643
|
-
*/
|
|
644
|
-
resetSession(): void;
|
|
645
|
-
/**
|
|
646
|
-
* Handles the 'pointerdown' event: starts a stroke and initializes the session time.
|
|
647
|
-
* @private
|
|
648
|
-
*/
|
|
649
|
-
private handlePointerDown;
|
|
650
|
-
/**
|
|
651
|
-
* Handles the 'pointermove' event: continues the stroke if pointer is down.
|
|
652
|
-
* @private
|
|
653
|
-
*/
|
|
654
|
-
private handlePointerMove;
|
|
655
|
-
/**
|
|
656
|
-
* Handles the 'pointerup' event: ends the stroke.
|
|
657
|
-
* @private
|
|
658
|
-
*/
|
|
659
|
-
private handlePointerUp;
|
|
660
|
-
/**
|
|
661
|
-
* Handles the 'pointerleave' event: ends the stroke if the pointer leaves the canvas area.
|
|
662
|
-
* @private
|
|
663
|
-
*/
|
|
664
|
-
private handlePointerLeave;
|
|
665
|
-
/**
|
|
666
|
-
* Handles the 'pointercancel' event: terminates a stroke interrupted by the browser
|
|
667
|
-
* (e.g. iOS scroll taking over, incoming call, screen lock).
|
|
668
|
-
* @private
|
|
669
|
-
*/
|
|
670
|
-
private handlePointerCancel;
|
|
671
|
-
/**
|
|
672
|
-
* Core logic to transform a PointerEvent into IPenData.
|
|
673
|
-
* @param event - The raw browser PointerEvent.
|
|
674
|
-
* @param inContact - Whether the pointer is actively drawing on the surface.
|
|
675
|
-
* @private
|
|
676
|
-
*/
|
|
677
|
-
private processPointerEvent;
|
|
678
|
-
/**
|
|
679
|
-
* Returns the pressure value for a pointer event.
|
|
680
|
-
* Pen devices (Apple Pencil, stylus) report real pressure in the 0–1 range.
|
|
681
|
-
* Mouse and touch devices fall back to 0.5 (in contact) / 0 (not in contact).
|
|
682
|
-
* @private
|
|
683
|
-
*/
|
|
684
|
-
private getPressure;
|
|
685
|
-
/**
|
|
686
|
-
* Converts absolute pointer coordinates into a normalized 0-1 range relative to canvas size.
|
|
687
|
-
* @private
|
|
688
|
-
*/
|
|
689
|
-
private getNormalizedCoordinates;
|
|
690
|
-
/**
|
|
691
|
-
* Calculates the seconds elapsed since the start of the signature session.
|
|
692
|
-
* @private
|
|
693
|
-
*/
|
|
694
|
-
private timestampToSeconds;
|
|
695
|
-
}
|
|
696
|
-
|
|
697
458
|
/**
|
|
698
459
|
* SignosoftSignpad Web Component.
|
|
699
460
|
* A professional signature capture component supporting physical tablets and mouse fallback.
|
|
@@ -723,7 +484,6 @@ export declare class SignosoftSignpad extends LitElement {
|
|
|
723
484
|
setHasStartedDrawing(value: boolean): void;
|
|
724
485
|
setDeviceStatusText(value: string): void;
|
|
725
486
|
canvasManager: CanvasManager | null;
|
|
726
|
-
pointerManager: PointerManager | IosTouchManager | null;
|
|
727
487
|
connectionManager: ConnectionManager;
|
|
728
488
|
stateManager: StateManager;
|
|
729
489
|
buttonManager: ButtonManager;
|
|
@@ -846,24 +606,12 @@ export declare class SignosoftSignpad extends LitElement {
|
|
|
846
606
|
* @returns void
|
|
847
607
|
*/
|
|
848
608
|
private initializeCanvasManager;
|
|
849
|
-
/**
|
|
850
|
-
* Initializes the PointerManager for pointer/touch fallback.
|
|
851
|
-
* @private
|
|
852
|
-
* @returns void
|
|
853
|
-
*/
|
|
854
|
-
private initializePointerManager;
|
|
855
|
-
/**
|
|
856
|
-
* Throttles pen event dispatch to avoid excessive callback pressure.
|
|
857
|
-
* Drawing is still processed for every sample; only event emission is throttled.
|
|
858
|
-
*/
|
|
859
|
-
private dispatchPenEventThrottled;
|
|
860
609
|
/**
|
|
861
610
|
* Initializes the driver once a lease is provided via config.
|
|
862
611
|
* Safe to call repeatedly; initialization is performed at most once.
|
|
863
612
|
*/
|
|
864
613
|
private initializeFromConfigLeaseIfNeeded;
|
|
865
614
|
private autoConnectIfConfigured;
|
|
866
|
-
private canAttemptAutoConnect;
|
|
867
615
|
private ensureSignatureLayerReady;
|
|
868
616
|
private deferAutoConnectForState;
|
|
869
617
|
private clearPendingAutoConnectTimeout;
|
|
@@ -943,7 +691,6 @@ export declare enum SignpadMessage {
|
|
|
943
691
|
CONNECTION_ERROR = "CONNECTION_ERROR",
|
|
944
692
|
ERROR_DISCONNECTION = "ERROR_DISCONNECTION",
|
|
945
693
|
ERROR_INSTANTIATING_DRIVER = "ERROR_INSTANTIATING_DRIVER",
|
|
946
|
-
SIGNPAD_DISCONNECTED = "SIGNPAD_DISCONNECTED",
|
|
947
694
|
INVALID_LICENSE_KEY = "INVALID_LICENSE_KEY",
|
|
948
695
|
READY_TO_CONNECT = "READY_TO_CONNECT",
|
|
949
696
|
SIGNPAD_DETECTED = "SIGNPAD_DETECTED",
|
|
@@ -966,15 +713,6 @@ export declare enum SignpadState {
|
|
|
966
713
|
ERROR = "error"
|
|
967
714
|
}
|
|
968
715
|
|
|
969
|
-
export declare enum SignpadUI {
|
|
970
|
-
OK = "OK",
|
|
971
|
-
CLEAR = "CLEAR",
|
|
972
|
-
CANCEL = "CANCEL",
|
|
973
|
-
CLEAR_SIGNATURE = "CLEAR_SIGNATURE",
|
|
974
|
-
DISCONNECT = "DISCONNECT",
|
|
975
|
-
CONNECT_SIGNPAD = "CONNECT_SIGNPAD"
|
|
976
|
-
}
|
|
977
|
-
|
|
978
716
|
/**
|
|
979
717
|
* Manages the finite state machine and UI logic for the Signpad component.
|
|
980
718
|
* It handles state transitions, side effects (like adding/removing listeners),
|