@signosoft/signpad-js 0.4.9 → 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 +11 -10
- package/dist/signosoft-signpad.js +438 -388
- package/dist/signosoft-signpad.umd.cjs +22 -22
- 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
|
@@ -88,7 +88,7 @@ declare class CanvasManager {
|
|
|
88
88
|
* Draws a stroke segment for mouse/touch fallback input.
|
|
89
89
|
* Physical tablet strokes are rendered by SignatureLayer/SignatureCapture.
|
|
90
90
|
*/
|
|
91
|
-
drawSegment(penData:
|
|
91
|
+
drawSegment(penData: IPenData): void;
|
|
92
92
|
/**
|
|
93
93
|
* Wipes the canvas clean and resets the drawing state.
|
|
94
94
|
*/
|
|
@@ -183,8 +183,7 @@ declare class ConnectionManager {
|
|
|
183
183
|
private penDataToDispatch;
|
|
184
184
|
/** @private Minimum delay between pen events (approx 60fps) */
|
|
185
185
|
private throttleDelayMs;
|
|
186
|
-
|
|
187
|
-
private mouseFallbackPenLog;
|
|
186
|
+
private penDataLog;
|
|
188
187
|
private static readonly POINTER_FALLBACK_DEVICE_NAME;
|
|
189
188
|
/**
|
|
190
189
|
* @param component - The host SignosoftSignpad instance.
|
|
@@ -230,7 +229,8 @@ declare class ConnectionManager {
|
|
|
230
229
|
* @returns A promise resolving to true if the session started successfully.
|
|
231
230
|
*/
|
|
232
231
|
startSigning(canvas: HTMLCanvasElement, drawingOptions?: IDrawingOptions): Promise<boolean>;
|
|
233
|
-
|
|
232
|
+
logPenData(data: IPenData): void;
|
|
233
|
+
private buildConfirmationData;
|
|
234
234
|
/**
|
|
235
235
|
* Stops the current signing session if active.
|
|
236
236
|
* @returns Signature data if available.
|
|
@@ -322,7 +322,7 @@ export declare interface IEventCallbacks {
|
|
|
322
322
|
}>) => void;
|
|
323
323
|
onConnecting?: (event: CustomEvent<void>) => void;
|
|
324
324
|
onDisconnect?: (event: CustomEvent<void>) => void;
|
|
325
|
-
onPen?: (event: CustomEvent<
|
|
325
|
+
onPen?: (event: CustomEvent<IPenData>) => void;
|
|
326
326
|
onOk?: (event: CustomEvent<ISignatureConfirmationData>) => void;
|
|
327
327
|
onClear?: (event: CustomEvent<void>) => void;
|
|
328
328
|
onCancel?: (event: CustomEvent<void>) => void;
|
|
@@ -432,7 +432,7 @@ declare class IosTouchManager {
|
|
|
432
432
|
private timestampToSeconds;
|
|
433
433
|
}
|
|
434
434
|
|
|
435
|
-
declare interface
|
|
435
|
+
export declare interface IPenData {
|
|
436
436
|
relativeX: number;
|
|
437
437
|
relativeY: number;
|
|
438
438
|
absoluteX?: number;
|
|
@@ -440,14 +440,14 @@ declare interface IPenData_2 {
|
|
|
440
440
|
pressure?: number;
|
|
441
441
|
ready?: boolean;
|
|
442
442
|
sequence?: number;
|
|
443
|
-
timestamp?: number
|
|
443
|
+
timestamp?: number;
|
|
444
|
+
timestampInSeconds?: number;
|
|
444
445
|
inContact: boolean;
|
|
445
446
|
[key: string]: any;
|
|
446
447
|
}
|
|
447
|
-
export { IPenData_2 as IPenData }
|
|
448
448
|
|
|
449
449
|
export declare interface IPenDataCallback {
|
|
450
|
-
(penData:
|
|
450
|
+
(penData: IPenData): void;
|
|
451
451
|
}
|
|
452
452
|
|
|
453
453
|
export declare interface ISignatureCanvasMeta {
|
|
@@ -464,7 +464,7 @@ export declare interface ISignatureCanvasMeta {
|
|
|
464
464
|
}
|
|
465
465
|
|
|
466
466
|
export declare type ISignatureConfirmationData = [
|
|
467
|
-
points:
|
|
467
|
+
points: IPenData[],
|
|
468
468
|
imageBase64: string,
|
|
469
469
|
metadata: ISignatureResultMeta
|
|
470
470
|
];
|
|
@@ -472,6 +472,7 @@ metadata: ISignatureResultMeta
|
|
|
472
472
|
export declare interface ISignatureResultMeta {
|
|
473
473
|
canvas?: ISignatureCanvasMeta;
|
|
474
474
|
tablet?: ISignatureTabletMeta;
|
|
475
|
+
duration?: number;
|
|
475
476
|
[key: string]: any;
|
|
476
477
|
}
|
|
477
478
|
|