@signosoft/signpad-js 0.4.8 → 0.4.10
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 +47 -7
- package/dist/index.d.ts +15 -10
- package/dist/signosoft-signpad.js +1110 -1467
- package/dist/signosoft-signpad.umd.cjs +26 -26
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
| 📜 [Description](#-description) | 📦 [Installation](#-installation) | 💬 [Feedback](#-feedback--support) |
|
|
8
8
|
| 🎬 [Demo](#-demo) | 🔐 [Licensing](#-lease-setup) | 🛠️ [Contributing](#-contributing) |
|
|
9
9
|
| ⚙️ [Tech stack](#-tech-stack--built-with) | 🚀 [Quick Start](#-quick-start) | 📄 [License](#-license) |
|
|
10
|
-
|
|
|
10
|
+
| 🖊️ [Devices](#️-device-compatibility) | 📋 [Properties](#-properties) | |
|
|
11
11
|
| | 🧩 [Methods](#-methods) | |
|
|
12
|
+
| | 🔄 [States](#-component-states) | |
|
|
12
13
|
| | 🎨 [Styling](#-styling--theming) | |
|
|
13
14
|
| | 🌐 [Localization](#-localization--translation-keys) |
|
|
14
15
|
| | |
|
|
@@ -98,6 +99,19 @@ async function applyLeaseToConfig(currentConfig) {
|
|
|
98
99
|
|
|
99
100
|
<br/>
|
|
100
101
|
|
|
102
|
+
## 🖊️ Device Compatibility
|
|
103
|
+
|
|
104
|
+
The component communicates with signature tablets via the **WebHID API**. Devices are matched against a built-in configuration database; unrecognized devices fall back to a generic driver.
|
|
105
|
+
|
|
106
|
+
| Manufacturer | Models | Notes |
|
|
107
|
+
| :----------- | :---------------------------------- | :----------------------------------------- |
|
|
108
|
+
| **Wacom** | STU series (STU-520, STU-530, etc.) | Fully supported; STU-520/530 require a pre-clear screen wipe before each signing session. |
|
|
109
|
+
| **Ugee** | UG05 and compatible models | Supported via device config; firmware variations may affect button behavior. |
|
|
110
|
+
| **XP-Pen** | Canvas-style tablets | Supported; uses canvas-area coordinate mapping. |
|
|
111
|
+
| **Others** | — | Fall back to `DefaultDriver`; basic pen capture works, hotspot buttons may not. |
|
|
112
|
+
|
|
113
|
+
> **Mouse fallback:** If no supported device is connected (or the user dismisses the HID picker), the component automatically activates mouse/touch input so signing can still proceed in the browser.
|
|
114
|
+
|
|
101
115
|
## 📦 Installation
|
|
102
116
|
|
|
103
117
|
Install the library via npm:
|
|
@@ -737,7 +751,7 @@ The following methods are available on the component instance to control the sig
|
|
|
737
751
|
| `connect()` | `Promise<void>` | Connects device to component |
|
|
738
752
|
| `disconnect()` | `Promise<void>` | Disconnects device from component |
|
|
739
753
|
| `startSigning()` | `Promise<void>` | Initializes a new signing session on the canvas and hardware. |
|
|
740
|
-
| `stopSigning()` | `Promise<
|
|
754
|
+
| `stopSigning()` | `Promise<any>` | Low-level session stop that returns the raw driver payload. |
|
|
741
755
|
| `ok()` | `Promise<ISignatureConfirmationData \| undefined>` | Finalizes the session, cleans the device screen, and returns the signature data. |
|
|
742
756
|
| `clear()` | `Promise<void>` | Wipes the signature from the UI and hardware without ending the session. |
|
|
743
757
|
| `cancel()` | `Promise<void>` | Aborts the current session and resets the component state. |
|
|
@@ -814,7 +828,8 @@ This is the standard way to confirm a signature. It:
|
|
|
814
828
|
relativeX: number, // normalized 0..1
|
|
815
829
|
relativeY: number, // normalized 0..1
|
|
816
830
|
sequence: number,
|
|
817
|
-
timestamp: number
|
|
831
|
+
timestamp: number, // Unix ms (Date.now()) at the time of capture
|
|
832
|
+
timestampInSeconds: number // seconds elapsed since the start of the signing session
|
|
818
833
|
}
|
|
819
834
|
```
|
|
820
835
|
|
|
@@ -847,7 +862,8 @@ This is the standard way to confirm a signature. It:
|
|
|
847
862
|
serialNumber: Promise<string> | string,
|
|
848
863
|
vendorId: number | null,
|
|
849
864
|
productId: number | null
|
|
850
|
-
}
|
|
865
|
+
},
|
|
866
|
+
duration: number // seconds elapsed from startSigning() (or last clear) to stopSigning()
|
|
851
867
|
}
|
|
852
868
|
```
|
|
853
869
|
|
|
@@ -867,15 +883,18 @@ This is the standard way to confirm a signature. It:
|
|
|
867
883
|
relativeX: number, // normalized 0..1
|
|
868
884
|
relativeY: number, // normalized 0..1
|
|
869
885
|
sequence: number,
|
|
870
|
-
timestamp: number
|
|
886
|
+
timestamp: number, // Unix ms (Date.now()) at the time of capture
|
|
887
|
+
timestampInSeconds: number // seconds elapsed since the start of the signing session
|
|
871
888
|
}
|
|
872
889
|
```
|
|
873
890
|
|
|
874
891
|
#### 📜 `stopSigning()`
|
|
875
892
|
|
|
876
|
-
A low-level method that forces the driver to stop capturing data and returns the raw driver payload
|
|
893
|
+
A low-level method that forces the driver to stop capturing data and returns the raw driver payload as a 3-element tuple `[penDataBatch, imageBase64, metadata]`. Unlike `ok()`, it does not trigger the full "Finalization" flow (UI transitions or device screen clearing).
|
|
877
894
|
|
|
878
|
-
|
|
895
|
+
- `penDataBatch` — array of `IPenData` points collected during the session
|
|
896
|
+
- `imageBase64` — PNG data URL of the signature drawn on canvas, or `null` if unavailable
|
|
897
|
+
- `metadata` — object with `canvas` (dimensions, DPR) and `tablet` (device info) fields
|
|
879
898
|
|
|
880
899
|
#### 📜 `clear()`
|
|
881
900
|
|
|
@@ -885,6 +904,27 @@ Resets the drawing state on both the web canvas and the physical tablet's displa
|
|
|
885
904
|
|
|
886
905
|
Stops the session immediately. It does not collect any signature data and resets the component to its ready state. This method dispatches the `SIGN_CANCEL` event.
|
|
887
906
|
|
|
907
|
+
## 🔄 Component States
|
|
908
|
+
|
|
909
|
+
The component progresses through a finite set of states, exposed via the `SignpadState` enum (importable from `@signosoft/signpad-js`). Useful for observing the component lifecycle in your application.
|
|
910
|
+
|
|
911
|
+
| State | Value | Description |
|
|
912
|
+
| :--------------------------- | :----------------------------- | :------------------------------------------------------------- |
|
|
913
|
+
| `INITIAL` | `"initial"` | Component just mounted, no initialization yet. |
|
|
914
|
+
| `CONNECTING` | `"connecting"` | Connection attempt in progress. |
|
|
915
|
+
| `WAITING_FOR_DEVICE_SELECTION` | `"waiting_for_device_selection"` | Browser HID picker is open, waiting for user selection. |
|
|
916
|
+
| `CONNECTED_PHYSICAL` | `"connected_physical"` | Physical tablet connected and ready. |
|
|
917
|
+
| `CONNECTED_MOUSE_FALLBACK` | `"connected_mouse_fallback"` | No tablet found; mouse/touch fallback is active. |
|
|
918
|
+
| `SIGNING_ACTIVE` | `"signing_active"` | Pen input is live; user is drawing. |
|
|
919
|
+
| `PROCESSING_OK` | `"processing_ok"` | OK action is being processed (finalizing signature). |
|
|
920
|
+
| `PROCESSING_CLEAR` | `"processing_clear"` | Clear action is being processed. |
|
|
921
|
+
| `PROCESSING_CANCEL` | `"processing_cancel"` | Cancel action is being processed. |
|
|
922
|
+
| `DISCONNECTING` | `"disconnecting"` | Disconnect in progress. |
|
|
923
|
+
| `DISCONNECTED` | `"disconnected"` | Component is idle and disconnected. |
|
|
924
|
+
| `ERROR` | `"error"` | An unrecoverable error occurred (see `onError` callback). |
|
|
925
|
+
|
|
926
|
+
---
|
|
927
|
+
|
|
888
928
|
## 🎨 Styling & Theming
|
|
889
929
|
|
|
890
930
|
The component uses a hybrid theming model:
|
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,11 +85,10 @@ declare class CanvasManager {
|
|
|
83
85
|
*/
|
|
84
86
|
updateDrawingOptions(options: IDrawingOptions): void;
|
|
85
87
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
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
|
-
drawSegment(penData:
|
|
91
|
+
drawSegment(penData: IPenData): void;
|
|
91
92
|
/**
|
|
92
93
|
* Wipes the canvas clean and resets the drawing state.
|
|
93
94
|
*/
|
|
@@ -182,6 +183,7 @@ declare class ConnectionManager {
|
|
|
182
183
|
private penDataToDispatch;
|
|
183
184
|
/** @private Minimum delay between pen events (approx 60fps) */
|
|
184
185
|
private throttleDelayMs;
|
|
186
|
+
private penDataLog;
|
|
185
187
|
private static readonly POINTER_FALLBACK_DEVICE_NAME;
|
|
186
188
|
/**
|
|
187
189
|
* @param component - The host SignosoftSignpad instance.
|
|
@@ -227,6 +229,8 @@ declare class ConnectionManager {
|
|
|
227
229
|
* @returns A promise resolving to true if the session started successfully.
|
|
228
230
|
*/
|
|
229
231
|
startSigning(canvas: HTMLCanvasElement, drawingOptions?: IDrawingOptions): Promise<boolean>;
|
|
232
|
+
logPenData(data: IPenData): void;
|
|
233
|
+
private buildConfirmationData;
|
|
230
234
|
/**
|
|
231
235
|
* Stops the current signing session if active.
|
|
232
236
|
* @returns Signature data if available.
|
|
@@ -318,7 +322,7 @@ export declare interface IEventCallbacks {
|
|
|
318
322
|
}>) => void;
|
|
319
323
|
onConnecting?: (event: CustomEvent<void>) => void;
|
|
320
324
|
onDisconnect?: (event: CustomEvent<void>) => void;
|
|
321
|
-
onPen?: (event: CustomEvent<
|
|
325
|
+
onPen?: (event: CustomEvent<IPenData>) => void;
|
|
322
326
|
onOk?: (event: CustomEvent<ISignatureConfirmationData>) => void;
|
|
323
327
|
onClear?: (event: CustomEvent<void>) => void;
|
|
324
328
|
onCancel?: (event: CustomEvent<void>) => void;
|
|
@@ -428,7 +432,7 @@ declare class IosTouchManager {
|
|
|
428
432
|
private timestampToSeconds;
|
|
429
433
|
}
|
|
430
434
|
|
|
431
|
-
declare interface
|
|
435
|
+
export declare interface IPenData {
|
|
432
436
|
relativeX: number;
|
|
433
437
|
relativeY: number;
|
|
434
438
|
absoluteX?: number;
|
|
@@ -436,14 +440,14 @@ declare interface IPenData_2 {
|
|
|
436
440
|
pressure?: number;
|
|
437
441
|
ready?: boolean;
|
|
438
442
|
sequence?: number;
|
|
439
|
-
timestamp?: number
|
|
443
|
+
timestamp?: number;
|
|
444
|
+
timestampInSeconds?: number;
|
|
440
445
|
inContact: boolean;
|
|
441
446
|
[key: string]: any;
|
|
442
447
|
}
|
|
443
|
-
export { IPenData_2 as IPenData }
|
|
444
448
|
|
|
445
449
|
export declare interface IPenDataCallback {
|
|
446
|
-
(penData:
|
|
450
|
+
(penData: IPenData): void;
|
|
447
451
|
}
|
|
448
452
|
|
|
449
453
|
export declare interface ISignatureCanvasMeta {
|
|
@@ -460,7 +464,7 @@ export declare interface ISignatureCanvasMeta {
|
|
|
460
464
|
}
|
|
461
465
|
|
|
462
466
|
export declare type ISignatureConfirmationData = [
|
|
463
|
-
points:
|
|
467
|
+
points: IPenData[],
|
|
464
468
|
imageBase64: string,
|
|
465
469
|
metadata: ISignatureResultMeta
|
|
466
470
|
];
|
|
@@ -468,6 +472,7 @@ metadata: ISignatureResultMeta
|
|
|
468
472
|
export declare interface ISignatureResultMeta {
|
|
469
473
|
canvas?: ISignatureCanvasMeta;
|
|
470
474
|
tablet?: ISignatureTabletMeta;
|
|
475
|
+
duration?: number;
|
|
471
476
|
[key: string]: any;
|
|
472
477
|
}
|
|
473
478
|
|