@signosoft/signpad-js 0.5.0 → 0.5.2
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 +33 -39
- package/dist/index.d.ts +9 -279
- package/dist/signosoft-signpad.js +1258 -1626
- package/dist/signosoft-signpad.umd.cjs +33 -33
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
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
|
-
| 🖊️ [Devices](#️-device-compatibility)
|
|
10
|
+
| 🖊️ [Devices](#️-device-compatibility) | 📋 [Properties](#-properties) | |
|
|
11
11
|
| | 🧩 [Methods](#-methods) | |
|
|
12
12
|
| | 🔄 [States](#-component-states) | |
|
|
13
13
|
| | 🎨 [Styling](#-styling--theming) | |
|
|
@@ -23,9 +23,6 @@ This component **works effortlessly** with any modern stack:
|
|
|
23
23
|
|:-:|:-:|:-:|:-:|
|
|
24
24
|
| <img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/javascript/javascript-original.svg" alt="JS" width="35" height="35"> | <img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/react/react-original.svg" alt="React" width="35" height="35"> | <img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/angularjs/angularjs-original.svg" alt="Angular" width="35" height="35"> | <img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/vuejs/vuejs-original.svg" alt="Vue" width="35" height="35"> ||
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
26
|
It expertly handles the complexities of **WebHID device connections**, signature session lifecycles, and high-fidelity stroke rendering.
|
|
30
27
|
<br/>
|
|
31
28
|
|
|
@@ -103,8 +100,8 @@ async function applyLeaseToConfig(currentConfig) {
|
|
|
103
100
|
|
|
104
101
|
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
102
|
|
|
106
|
-
| Manufacturer | Models | Notes
|
|
107
|
-
| :----------- | :---------------------------------- |
|
|
103
|
+
| Manufacturer | Models | Notes |
|
|
104
|
+
| :----------- | :---------------------------------- | :---------------------------------------------------------------------------------------- |
|
|
108
105
|
| **Wacom** | STU series (STU-520, STU-530, etc.) | Fully supported; STU-520/530 require a pre-clear screen wipe before each signing session. |
|
|
109
106
|
| **Ugee** | UG05 and compatible models | Supported via device config; firmware variations may affect button behavior. |
|
|
110
107
|
| **XP-Pen** | Canvas-style tablets | Supported; uses canvas-area coordinate mapping. |
|
|
@@ -601,8 +598,8 @@ The component is primarily configured through a single `config` property. This o
|
|
|
601
598
|
|
|
602
599
|
### 🔑 Core Options
|
|
603
600
|
|
|
604
|
-
| Option | Type | Required
|
|
605
|
-
| :---------- | :------- |
|
|
601
|
+
| Option | Type | Required | Description |
|
|
602
|
+
| :---------- | :------- | :------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
606
603
|
| **`lease`** | `object` | Required for hardware mode | Lease payload returned from the lease API call. The component still renders without it, but driver initialization and hardware communication are disabled (see [Lease Setup](#-lease-setup)). |
|
|
607
604
|
|
|
608
605
|
### 👁️ uiVisibilityOptions
|
|
@@ -638,11 +635,11 @@ Adjusts the visual appearance of the digital ink.
|
|
|
638
635
|
|
|
639
636
|
Handles component localization. It can load external files or use inline definitions.
|
|
640
637
|
|
|
641
|
-
| Field | Type | Description
|
|
642
|
-
| :------------- | :------- |
|
|
638
|
+
| Field | Type | Description |
|
|
639
|
+
| :------------- | :------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
643
640
|
| `lang` | `string` | The active language code. Built-in translations are bundled for `'en'` and `'cs'`; other languages (including `'pt'`) require `langPath` or `translations`. |
|
|
644
|
-
| `langPath` | `string` | URL path to fetch translation files. Expects files in `[path]/[lang].json` format.
|
|
645
|
-
| `translations` | `object` | An inline object containing key-value pairs (e.g., `{ "OK": "Confirm signature" }`). Overrides files.
|
|
641
|
+
| `langPath` | `string` | URL path to fetch translation files. Expects files in `[path]/[lang].json` format. |
|
|
642
|
+
| `translations` | `object` | An inline object containing key-value pairs (e.g., `{ "OK": "Confirm signature" }`). Overrides files. |
|
|
646
643
|
|
|
647
644
|
## 🌐 Localization & Translation Keys
|
|
648
645
|
|
|
@@ -679,7 +676,6 @@ The complete list of keys that can be translated is maintained in `src/i18n/en.j
|
|
|
679
676
|
| `CONNECTION_ERROR` | Connection error. |
|
|
680
677
|
| `ERROR_DISCONNECTION` | Error during disconnection. |
|
|
681
678
|
| `ERROR_INSTANTIATING_DRIVER` | Error instantiating driver. |
|
|
682
|
-
| `SIGNPAD_DISCONNECTED` | Signpad disconnected. |
|
|
683
679
|
| `INVALID_LICENSE_KEY` | Invalid license key. |
|
|
684
680
|
| `READY_TO_CONNECT` | Ready to connect. |
|
|
685
681
|
| `SIGNPAD_DETECTED` | Signpad detected. Click 'Connect Signpad' to begin. |
|
|
@@ -751,7 +747,7 @@ The following methods are available on the component instance to control the sig
|
|
|
751
747
|
| `connect()` | `Promise<void>` | Connects device to component |
|
|
752
748
|
| `disconnect()` | `Promise<void>` | Disconnects device from component |
|
|
753
749
|
| `startSigning()` | `Promise<void>` | Initializes a new signing session on the canvas and hardware. |
|
|
754
|
-
| `stopSigning()` | `Promise<any>` | Low-level session stop that returns the signature payload.
|
|
750
|
+
| `stopSigning()` | `Promise<any>` | Low-level session stop that returns the signature payload. |
|
|
755
751
|
| `ok()` | `Promise<ISignatureConfirmationData \| undefined>` | Finalizes the session, cleans the device screen, and returns the signature data. |
|
|
756
752
|
| `clear()` | `Promise<void>` | Wipes the signature from the UI and hardware without ending the session. |
|
|
757
753
|
| `cancel()` | `Promise<void>` | Aborts the current session and resets the component state. |
|
|
@@ -825,13 +821,12 @@ This is the standard way to confirm a signature. It:
|
|
|
825
821
|
pressure: number,
|
|
826
822
|
inContact: boolean,
|
|
827
823
|
timestamp: number, // Unix ms (Date.now()) at the time of capture
|
|
828
|
-
timestampInSeconds: number // seconds elapsed since the start of the signing session
|
|
829
824
|
}
|
|
830
825
|
```
|
|
831
826
|
|
|
832
827
|
```js
|
|
833
828
|
// [1] imageBase64 — base64 PNG data URL, or null if no image could be captured
|
|
834
|
-
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
|
|
829
|
+
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA...";
|
|
835
830
|
```
|
|
836
831
|
|
|
837
832
|
```js
|
|
@@ -890,7 +885,6 @@ This is the standard way to confirm a signature. It:
|
|
|
890
885
|
pressure: number,
|
|
891
886
|
inContact: boolean,
|
|
892
887
|
timestamp: number, // Unix ms (Date.now()) at the time of capture
|
|
893
|
-
timestampInSeconds: number // seconds elapsed since the start of the signing session
|
|
894
888
|
}
|
|
895
889
|
```
|
|
896
890
|
|
|
@@ -916,20 +910,20 @@ Stops the session immediately. It does not collect any signature data and resets
|
|
|
916
910
|
|
|
917
911
|
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.
|
|
918
912
|
|
|
919
|
-
| State
|
|
920
|
-
|
|
|
921
|
-
| `INITIAL`
|
|
922
|
-
| `CONNECTING`
|
|
923
|
-
| `WAITING_FOR_DEVICE_SELECTION` | `"waiting_for_device_selection"` | Browser HID picker is open, waiting for user selection.
|
|
924
|
-
| `CONNECTED_PHYSICAL`
|
|
925
|
-
| `CONNECTED_MOUSE_FALLBACK`
|
|
926
|
-
| `SIGNING_ACTIVE`
|
|
927
|
-
| `PROCESSING_OK`
|
|
928
|
-
| `PROCESSING_CLEAR`
|
|
929
|
-
| `PROCESSING_CANCEL`
|
|
930
|
-
| `DISCONNECTING`
|
|
931
|
-
| `DISCONNECTED`
|
|
932
|
-
| `ERROR`
|
|
913
|
+
| State | Value | Description |
|
|
914
|
+
| :----------------------------- | :------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
915
|
+
| `INITIAL` | `"initial"` | Component just mounted, no initialization yet. |
|
|
916
|
+
| `CONNECTING` | `"connecting"` | Connection attempt in progress. |
|
|
917
|
+
| `WAITING_FOR_DEVICE_SELECTION` | `"waiting_for_device_selection"` | Browser HID picker is open, waiting for user selection. |
|
|
918
|
+
| `CONNECTED_PHYSICAL` | `"connected_physical"` | Physical tablet connected and ready. |
|
|
919
|
+
| `CONNECTED_MOUSE_FALLBACK` | `"connected_mouse_fallback"` | No tablet found; mouse/touch fallback is active. |
|
|
920
|
+
| `SIGNING_ACTIVE` | `"signing_active"` | Defined for future use; the component does not currently transition to this state — drawing happens while still in `CONNECTED_PHYSICAL`/`CONNECTED_MOUSE_FALLBACK`. |
|
|
921
|
+
| `PROCESSING_OK` | `"processing_ok"` | OK action is being processed (finalizing signature). |
|
|
922
|
+
| `PROCESSING_CLEAR` | `"processing_clear"` | Clear action is being processed. |
|
|
923
|
+
| `PROCESSING_CANCEL` | `"processing_cancel"` | Cancel action is being processed. |
|
|
924
|
+
| `DISCONNECTING` | `"disconnecting"` | Disconnect in progress. |
|
|
925
|
+
| `DISCONNECTED` | `"disconnected"` | Component is idle and disconnected. |
|
|
926
|
+
| `ERROR` | `"error"` | An unrecoverable error occurred (see `onError` callback). |
|
|
933
927
|
|
|
934
928
|
---
|
|
935
929
|
|
|
@@ -1125,14 +1119,14 @@ signosoft-signpad {
|
|
|
1125
1119
|
|
|
1126
1120
|
#### Primary Buttons (OK, Clear, Cancel)
|
|
1127
1121
|
|
|
1128
|
-
| Variable
|
|
1129
|
-
|
|
|
1130
|
-
| `--sign-button-primary-bg-base`
|
|
1131
|
-
| `--sign-button-primary-bg-hover`
|
|
1132
|
-
| `--sign-button-primary-bg-disabled`
|
|
1133
|
-
| `--sign-button-primary-text-base`
|
|
1134
|
-
| `--sign-button-primary-text-hover`
|
|
1135
|
-
| `--sign-button-primary-text-disabled`
|
|
1122
|
+
| Variable | Description |
|
|
1123
|
+
| :-------------------------------------- | :----------------------------------- |
|
|
1124
|
+
| `--sign-button-primary-bg-base` | Background color of primary buttons. |
|
|
1125
|
+
| `--sign-button-primary-bg-hover` | Hover background color. |
|
|
1126
|
+
| `--sign-button-primary-bg-disabled` | Disabled background color. |
|
|
1127
|
+
| `--sign-button-primary-text-base` | Text color for primary buttons. |
|
|
1128
|
+
| `--sign-button-primary-text-hover` | Hover text color. |
|
|
1129
|
+
| `--sign-button-primary-text-disabled` | Disabled text color. |
|
|
1136
1130
|
| `--sign-button-primary-border-base` | Border of primary buttons. |
|
|
1137
1131
|
| `--sign-button-primary-border-hover` | Hover border color. |
|
|
1138
1132
|
| `--sign-button-primary-border-disabled` | Disabled border color. |
|
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,9 +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
|
-
/** @private Wall-clock time when the current signing session started, for timestampInSeconds */
|
|
188
|
-
private sessionStartTime;
|
|
189
171
|
private static readonly POINTER_FALLBACK_DEVICE_NAME;
|
|
190
172
|
/**
|
|
191
173
|
* @param component - The host SignosoftSignpad instance.
|
|
@@ -219,11 +201,6 @@ declare class ConnectionManager {
|
|
|
219
201
|
* @returns True if a device is connected.
|
|
220
202
|
*/
|
|
221
203
|
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
204
|
/**
|
|
228
205
|
* Starts a signing session on the provided canvas.
|
|
229
206
|
* @param canvasElement - Optional canvas reference.
|
|
@@ -231,13 +208,6 @@ declare class ConnectionManager {
|
|
|
231
208
|
* @returns A promise resolving to true if the session started successfully.
|
|
232
209
|
*/
|
|
233
210
|
startSigning(canvas: HTMLCanvasElement, drawingOptions?: IDrawingOptions): Promise<boolean>;
|
|
234
|
-
logPenData(data: IPenData): void;
|
|
235
|
-
/**
|
|
236
|
-
* Calculates the seconds elapsed since the start of the signing session.
|
|
237
|
-
* @private
|
|
238
|
-
*/
|
|
239
|
-
private timestampToSeconds;
|
|
240
|
-
private buildConfirmationData;
|
|
241
211
|
/**
|
|
242
212
|
* Stops the current signing session if active.
|
|
243
213
|
* @returns Signature data if available.
|
|
@@ -287,15 +257,6 @@ declare class ConnectionManager {
|
|
|
287
257
|
* This step only decides state; it does not trigger HID dialog itself.
|
|
288
258
|
*/
|
|
289
259
|
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
260
|
}
|
|
300
261
|
|
|
301
262
|
export declare enum DeviceStatusText {
|
|
@@ -315,14 +276,6 @@ export declare interface IDrawingOptions {
|
|
|
315
276
|
color?: string;
|
|
316
277
|
}
|
|
317
278
|
|
|
318
|
-
export declare interface IDriverInfo {
|
|
319
|
-
name: string;
|
|
320
|
-
ready: boolean;
|
|
321
|
-
aspectRatio: number;
|
|
322
|
-
isCanvasStyleTablet: boolean;
|
|
323
|
-
supportedCommands: string[];
|
|
324
|
-
}
|
|
325
|
-
|
|
326
279
|
export declare interface IEventCallbacks {
|
|
327
280
|
onConnect?: (event: CustomEvent<{
|
|
328
281
|
deviceInfo: any;
|
|
@@ -342,119 +295,23 @@ export declare interface ILanguageOptions {
|
|
|
342
295
|
translations?: ITranslationSet | Record<string, ITranslationSet>;
|
|
343
296
|
}
|
|
344
297
|
|
|
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
298
|
export declare interface IPenData {
|
|
443
299
|
relativeX: number;
|
|
444
300
|
relativeY: number;
|
|
445
|
-
absoluteX?: number;
|
|
446
|
-
absoluteY?: number;
|
|
447
301
|
pressure?: number;
|
|
448
|
-
ready?: boolean;
|
|
449
|
-
sequence?: number;
|
|
450
302
|
timestamp?: number;
|
|
451
|
-
timestampInSeconds?: number;
|
|
452
303
|
inContact: boolean;
|
|
453
304
|
[key: string]: any;
|
|
454
305
|
}
|
|
455
306
|
|
|
456
|
-
export declare interface
|
|
457
|
-
|
|
307
|
+
export declare interface IPenDataPoint {
|
|
308
|
+
relativeX: number;
|
|
309
|
+
relativeY: number;
|
|
310
|
+
absoluteX?: number;
|
|
311
|
+
absoluteY?: number;
|
|
312
|
+
pressure: number;
|
|
313
|
+
timestamp: number;
|
|
314
|
+
inContact: boolean;
|
|
458
315
|
}
|
|
459
316
|
|
|
460
317
|
export declare interface ISignatureCanvasMeta {
|
|
@@ -471,7 +328,7 @@ export declare interface ISignatureCanvasMeta {
|
|
|
471
328
|
}
|
|
472
329
|
|
|
473
330
|
export declare type ISignatureConfirmationData = [
|
|
474
|
-
points:
|
|
331
|
+
points: IPenDataPoint[],
|
|
475
332
|
imageBase64: string,
|
|
476
333
|
metadata: ISignatureResultMeta
|
|
477
334
|
];
|
|
@@ -590,110 +447,6 @@ declare class LocalizationManager {
|
|
|
590
447
|
private constructUrl;
|
|
591
448
|
}
|
|
592
449
|
|
|
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
450
|
/**
|
|
698
451
|
* SignosoftSignpad Web Component.
|
|
699
452
|
* A professional signature capture component supporting physical tablets and mouse fallback.
|
|
@@ -723,7 +476,6 @@ export declare class SignosoftSignpad extends LitElement {
|
|
|
723
476
|
setHasStartedDrawing(value: boolean): void;
|
|
724
477
|
setDeviceStatusText(value: string): void;
|
|
725
478
|
canvasManager: CanvasManager | null;
|
|
726
|
-
pointerManager: PointerManager | IosTouchManager | null;
|
|
727
479
|
connectionManager: ConnectionManager;
|
|
728
480
|
stateManager: StateManager;
|
|
729
481
|
buttonManager: ButtonManager;
|
|
@@ -846,24 +598,12 @@ export declare class SignosoftSignpad extends LitElement {
|
|
|
846
598
|
* @returns void
|
|
847
599
|
*/
|
|
848
600
|
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
601
|
/**
|
|
861
602
|
* Initializes the driver once a lease is provided via config.
|
|
862
603
|
* Safe to call repeatedly; initialization is performed at most once.
|
|
863
604
|
*/
|
|
864
605
|
private initializeFromConfigLeaseIfNeeded;
|
|
865
606
|
private autoConnectIfConfigured;
|
|
866
|
-
private canAttemptAutoConnect;
|
|
867
607
|
private ensureSignatureLayerReady;
|
|
868
608
|
private deferAutoConnectForState;
|
|
869
609
|
private clearPendingAutoConnectTimeout;
|
|
@@ -943,7 +683,6 @@ export declare enum SignpadMessage {
|
|
|
943
683
|
CONNECTION_ERROR = "CONNECTION_ERROR",
|
|
944
684
|
ERROR_DISCONNECTION = "ERROR_DISCONNECTION",
|
|
945
685
|
ERROR_INSTANTIATING_DRIVER = "ERROR_INSTANTIATING_DRIVER",
|
|
946
|
-
SIGNPAD_DISCONNECTED = "SIGNPAD_DISCONNECTED",
|
|
947
686
|
INVALID_LICENSE_KEY = "INVALID_LICENSE_KEY",
|
|
948
687
|
READY_TO_CONNECT = "READY_TO_CONNECT",
|
|
949
688
|
SIGNPAD_DETECTED = "SIGNPAD_DETECTED",
|
|
@@ -966,15 +705,6 @@ export declare enum SignpadState {
|
|
|
966
705
|
ERROR = "error"
|
|
967
706
|
}
|
|
968
707
|
|
|
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
708
|
/**
|
|
979
709
|
* Manages the finite state machine and UI logic for the Signpad component.
|
|
980
710
|
* It handles state transitions, side effects (like adding/removing listeners),
|