@signosoft/signpad-js 0.4.10 → 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 +44 -31
- package/dist/index.d.ts +17 -272
- package/dist/signosoft-signpad.js +3020 -3811
- package/dist/signosoft-signpad.umd.cjs +33 -33
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -603,7 +603,7 @@ The component is primarily configured through a single `config` property. This o
|
|
|
603
603
|
|
|
604
604
|
| Option | Type | Required | Description |
|
|
605
605
|
| :---------- | :------- | :------- | :---------------------------------------------------------------------------- |
|
|
606
|
-
| **`lease`** | `object` |
|
|
606
|
+
| **`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
607
|
|
|
608
608
|
### 👁️ uiVisibilityOptions
|
|
609
609
|
|
|
@@ -640,7 +640,7 @@ Handles component localization. It can load external files or use inline definit
|
|
|
640
640
|
|
|
641
641
|
| Field | Type | Description |
|
|
642
642
|
| :------------- | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
643
|
-
| `lang` | `string` | The active language code. Built-in translations are bundled for `'en'
|
|
643
|
+
| `lang` | `string` | The active language code. Built-in translations are bundled for `'en'` and `'cs'`; other languages (including `'pt'`) require `langPath` or `translations`. |
|
|
644
644
|
| `langPath` | `string` | URL path to fetch translation files. Expects files in `[path]/[lang].json` format. |
|
|
645
645
|
| `translations` | `object` | An inline object containing key-value pairs (e.g., `{ "OK": "Confirm signature" }`). Overrides files. |
|
|
646
646
|
|
|
@@ -648,7 +648,7 @@ Handles component localization. It can load external files or use inline definit
|
|
|
648
648
|
|
|
649
649
|
Localization is driven from `languageOptions`, but you can also provide overrides at runtime:
|
|
650
650
|
|
|
651
|
-
1. **Set the language code** in `config.languageOptions.lang`. English (`en`) is the fallback, Czech (`cs`)
|
|
651
|
+
1. **Set the language code** in `config.languageOptions.lang`. English (`en`) is the fallback, and Czech (`cs`) is bundled alongside it. Other languages, including Portuguese (`pt`), must be supplied via `langPath` or `translations` — they are not bundled.
|
|
652
652
|
2. **Load a hosted file** by pointing `languageOptions.langPath` to the directory that contains `[lang].json`. The loader will fetch `${langPath}/${lang}.json` (or the exact file if you include the `.json` suffix).
|
|
653
653
|
3. **Override only specific phrases** by passing a `translations` object—either a flat key map or a per-language map (`{ en: {...}, cs: {...} }`). Inline values take precedence over both built-in and fetched files.
|
|
654
654
|
4. **Dynamic placeholders** (for example, `{device}` in `TEXT_SIGNING_WITH_DEVICE`) are replaced using the `LocalizationManager.t` helper. Keep the braces intact if you expect runtime interpolation.
|
|
@@ -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. |
|
|
@@ -751,7 +750,7 @@ The following methods are available on the component instance to control the sig
|
|
|
751
750
|
| `connect()` | `Promise<void>` | Connects device to component |
|
|
752
751
|
| `disconnect()` | `Promise<void>` | Disconnects device from component |
|
|
753
752
|
| `startSigning()` | `Promise<void>` | Initializes a new signing session on the canvas and hardware. |
|
|
754
|
-
| `stopSigning()` | `Promise<any>` | Low-level session stop that returns the
|
|
753
|
+
| `stopSigning()` | `Promise<any>` | Low-level session stop that returns the signature payload. |
|
|
755
754
|
| `ok()` | `Promise<ISignatureConfirmationData \| undefined>` | Finalizes the session, cleans the device screen, and returns the signature data. |
|
|
756
755
|
| `clear()` | `Promise<void>` | Wipes the signature from the UI and hardware without ending the session. |
|
|
757
756
|
| `cancel()` | `Promise<void>` | Aborts the current session and resets the component state. |
|
|
@@ -818,40 +817,50 @@ This is the standard way to confirm a signature. It:
|
|
|
818
817
|
```
|
|
819
818
|
|
|
820
819
|
```js
|
|
821
|
-
// [0] Points structure
|
|
820
|
+
// [0] Points structure — same IPenData shape documented under onPen below
|
|
822
821
|
{
|
|
823
|
-
absoluteX: number,
|
|
824
|
-
absoluteY: number,
|
|
825
|
-
inContact: boolean,
|
|
826
|
-
pressure: number,
|
|
827
|
-
ready: boolean,
|
|
828
822
|
relativeX: number, // normalized 0..1
|
|
829
823
|
relativeY: number, // normalized 0..1
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
824
|
+
pressure: number,
|
|
825
|
+
inContact: boolean,
|
|
826
|
+
timestamp: number, // Unix ms (Date.now()) at the time of capture
|
|
827
|
+
timestampInSeconds: number // seconds elapsed since the start of the signing session
|
|
833
828
|
}
|
|
834
829
|
```
|
|
835
830
|
|
|
836
831
|
```js
|
|
837
|
-
// [1] imageBase64 —
|
|
832
|
+
// [1] imageBase64 — base64 PNG data URL, or null if no image could be captured
|
|
838
833
|
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
|
|
839
834
|
```
|
|
840
835
|
|
|
841
836
|
```js
|
|
842
837
|
// [2] Metadata structure
|
|
838
|
+
// The exact shape depends on whether a physical tablet or the mouse/touch
|
|
839
|
+
// fallback produced the signature — the two paths report different fields.
|
|
840
|
+
|
|
841
|
+
// Mouse / touch fallback:
|
|
843
842
|
{
|
|
844
843
|
canvas: {
|
|
845
|
-
top: number,
|
|
846
|
-
left: number,
|
|
847
|
-
right: number,
|
|
848
|
-
bottom: number,
|
|
849
844
|
width: number,
|
|
850
845
|
height: number,
|
|
851
846
|
cssWidth: number,
|
|
852
847
|
cssHeight: number,
|
|
853
848
|
dpr: number
|
|
854
849
|
},
|
|
850
|
+
tablet: undefined,
|
|
851
|
+
duration: number // seconds elapsed between the first and last recorded pen sample
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
// Physical tablet (driver-reported):
|
|
855
|
+
{
|
|
856
|
+
canvas: {
|
|
857
|
+
top?: number,
|
|
858
|
+
left?: number,
|
|
859
|
+
right?: number,
|
|
860
|
+
bottom?: number,
|
|
861
|
+
width: number,
|
|
862
|
+
height: number
|
|
863
|
+
},
|
|
855
864
|
tablet: {
|
|
856
865
|
name: string,
|
|
857
866
|
aspectRatio: number,
|
|
@@ -862,8 +871,8 @@ This is the standard way to confirm a signature. It:
|
|
|
862
871
|
serialNumber: Promise<string> | string,
|
|
863
872
|
vendorId: number | null,
|
|
864
873
|
productId: number | null
|
|
865
|
-
}
|
|
866
|
-
|
|
874
|
+
}
|
|
875
|
+
// no `duration` field is reported for the physical-tablet path
|
|
867
876
|
}
|
|
868
877
|
```
|
|
869
878
|
|
|
@@ -875,22 +884,20 @@ This is the standard way to confirm a signature. It:
|
|
|
875
884
|
|
|
876
885
|
```js
|
|
877
886
|
{
|
|
878
|
-
absoluteX: number,
|
|
879
|
-
absoluteY: number,
|
|
880
|
-
inContact: boolean,
|
|
881
|
-
pressure: number,
|
|
882
|
-
ready: boolean,
|
|
883
887
|
relativeX: number, // normalized 0..1
|
|
884
888
|
relativeY: number, // normalized 0..1
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
889
|
+
pressure: number,
|
|
890
|
+
inContact: boolean,
|
|
891
|
+
timestamp: number, // Unix ms (Date.now()) at the time of capture
|
|
892
|
+
timestampInSeconds: number // seconds elapsed since the start of the signing session
|
|
888
893
|
}
|
|
889
894
|
```
|
|
890
895
|
|
|
896
|
+
> The `IPenData` type also allows optional `absoluteX`, `absoluteY`, `ready`, and `sequence` fields for forward compatibility with the underlying driver, but the component does not currently populate them.
|
|
897
|
+
|
|
891
898
|
#### 📜 `stopSigning()`
|
|
892
899
|
|
|
893
|
-
A low-level method that forces the driver to stop capturing data and returns the
|
|
900
|
+
A low-level method that forces the driver to stop capturing data and returns the signature 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).
|
|
894
901
|
|
|
895
902
|
- `penDataBatch` — array of `IPenData` points collected during the session
|
|
896
903
|
- `imageBase64` — PNG data URL of the signature drawn on canvas, or `null` if unavailable
|
|
@@ -915,7 +922,7 @@ The component progresses through a finite set of states, exposed via the `Signpa
|
|
|
915
922
|
| `WAITING_FOR_DEVICE_SELECTION` | `"waiting_for_device_selection"` | Browser HID picker is open, waiting for user selection. |
|
|
916
923
|
| `CONNECTED_PHYSICAL` | `"connected_physical"` | Physical tablet connected and ready. |
|
|
917
924
|
| `CONNECTED_MOUSE_FALLBACK` | `"connected_mouse_fallback"` | No tablet found; mouse/touch fallback is active. |
|
|
918
|
-
| `SIGNING_ACTIVE` | `"signing_active"` |
|
|
925
|
+
| `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`. |
|
|
919
926
|
| `PROCESSING_OK` | `"processing_ok"` | OK action is being processed (finalizing signature). |
|
|
920
927
|
| `PROCESSING_CLEAR` | `"processing_clear"` | Clear action is being processed. |
|
|
921
928
|
| `PROCESSING_CANCEL` | `"processing_cancel"` | Cancel action is being processed. |
|
|
@@ -1011,6 +1018,9 @@ signosoft-signpad {
|
|
|
1011
1018
|
--sign-button-primary-text-base: var(--white-color);
|
|
1012
1019
|
--sign-button-primary-text-hover: var(--white-color);
|
|
1013
1020
|
--sign-button-primary-text-disabled: var(--white-color);
|
|
1021
|
+
--sign-button-primary-border-base: 1px solid var(--primary-color-0);
|
|
1022
|
+
--sign-button-primary-border-hover: 1px solid var(--primary-color-10);
|
|
1023
|
+
--sign-button-primary-border-disabled: 1px solid var(--grey-color);
|
|
1014
1024
|
|
|
1015
1025
|
/* Link Buttons (Connect signpad) */
|
|
1016
1026
|
--sign-button-link-bg-base: transparent;
|
|
@@ -1122,6 +1132,9 @@ signosoft-signpad {
|
|
|
1122
1132
|
| `--sign-button-primary-text-base` | Text color for primary buttons. |
|
|
1123
1133
|
| `--sign-button-primary-text-hover` | Hover text color. |
|
|
1124
1134
|
| `--sign-button-primary-text-disabled` | Disabled text color. |
|
|
1135
|
+
| `--sign-button-primary-border-base` | Border of primary buttons. |
|
|
1136
|
+
| `--sign-button-primary-border-hover` | Hover border color. |
|
|
1137
|
+
| `--sign-button-primary-border-disabled` | Disabled border color. |
|
|
1125
1138
|
|
|
1126
1139
|
#### Link/Connect Buttons
|
|
1127
1140
|
|
package/dist/index.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ declare class ButtonManager {
|
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
59
|
* `CanvasManager` is a lightweight canvas utility.
|
|
60
|
-
* Drawing is handled by SignatureLayer
|
|
60
|
+
* Drawing is handled by SignatureLayer from `@signosoft/tablet-driver`.
|
|
61
61
|
*/
|
|
62
62
|
declare class CanvasManager {
|
|
63
63
|
/** @private The target canvas element */
|
|
@@ -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/SignatureCapture.
|
|
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,8 @@ declare class ConnectionManager {
|
|
|
183
168
|
private penDataToDispatch;
|
|
184
169
|
/** @private Minimum delay between pen events (approx 60fps) */
|
|
185
170
|
private throttleDelayMs;
|
|
186
|
-
private
|
|
171
|
+
/** @private Wall-clock time when the current signing session started, for timestampInSeconds */
|
|
172
|
+
private sessionStartTime;
|
|
187
173
|
private static readonly POINTER_FALLBACK_DEVICE_NAME;
|
|
188
174
|
/**
|
|
189
175
|
* @param component - The host SignosoftSignpad instance.
|
|
@@ -217,11 +203,6 @@ declare class ConnectionManager {
|
|
|
217
203
|
* @returns True if a device is connected.
|
|
218
204
|
*/
|
|
219
205
|
isDeviceConnected(): boolean;
|
|
220
|
-
/**
|
|
221
|
-
* Returns true if the SignatureLayer is in signing mode.
|
|
222
|
-
* @returns True if a signing session is active.
|
|
223
|
-
*/
|
|
224
|
-
isSigningActive(): boolean;
|
|
225
206
|
/**
|
|
226
207
|
* Starts a signing session on the provided canvas.
|
|
227
208
|
* @param canvasElement - Optional canvas reference.
|
|
@@ -229,8 +210,11 @@ declare class ConnectionManager {
|
|
|
229
210
|
* @returns A promise resolving to true if the session started successfully.
|
|
230
211
|
*/
|
|
231
212
|
startSigning(canvas: HTMLCanvasElement, drawingOptions?: IDrawingOptions): Promise<boolean>;
|
|
232
|
-
|
|
233
|
-
|
|
213
|
+
/**
|
|
214
|
+
* Calculates the seconds elapsed since the start of the signing session.
|
|
215
|
+
* @private
|
|
216
|
+
*/
|
|
217
|
+
private timestampToSeconds;
|
|
234
218
|
/**
|
|
235
219
|
* Stops the current signing session if active.
|
|
236
220
|
* @returns Signature data if available.
|
|
@@ -280,15 +264,6 @@ declare class ConnectionManager {
|
|
|
280
264
|
* This step only decides state; it does not trigger HID dialog itself.
|
|
281
265
|
*/
|
|
282
266
|
private resolveConnectionTarget;
|
|
283
|
-
/**
|
|
284
|
-
* Starts a fresh signing session for whichever target mode was selected.
|
|
285
|
-
*/
|
|
286
|
-
private prepareSigningSession;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
export declare interface ConnectionTarget {
|
|
290
|
-
targetState: SignpadState;
|
|
291
|
-
statusMessageKey: string;
|
|
292
267
|
}
|
|
293
268
|
|
|
294
269
|
export declare enum DeviceStatusText {
|
|
@@ -308,14 +283,6 @@ export declare interface IDrawingOptions {
|
|
|
308
283
|
color?: string;
|
|
309
284
|
}
|
|
310
285
|
|
|
311
|
-
export declare interface IDriverInfo {
|
|
312
|
-
name: string;
|
|
313
|
-
ready: boolean;
|
|
314
|
-
aspectRatio: number;
|
|
315
|
-
isCanvasStyleTablet: boolean;
|
|
316
|
-
supportedCommands: string[];
|
|
317
|
-
}
|
|
318
|
-
|
|
319
286
|
export declare interface IEventCallbacks {
|
|
320
287
|
onConnect?: (event: CustomEvent<{
|
|
321
288
|
deviceInfo: any;
|
|
@@ -335,119 +302,24 @@ export declare interface ILanguageOptions {
|
|
|
335
302
|
translations?: ITranslationSet | Record<string, ITranslationSet>;
|
|
336
303
|
}
|
|
337
304
|
|
|
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
|
-
|
|
435
305
|
export declare interface IPenData {
|
|
436
306
|
relativeX: number;
|
|
437
307
|
relativeY: number;
|
|
438
|
-
absoluteX?: number;
|
|
439
|
-
absoluteY?: number;
|
|
440
308
|
pressure?: number;
|
|
441
|
-
ready?: boolean;
|
|
442
|
-
sequence?: number;
|
|
443
309
|
timestamp?: number;
|
|
444
310
|
timestampInSeconds?: number;
|
|
445
311
|
inContact: boolean;
|
|
446
312
|
[key: string]: any;
|
|
447
313
|
}
|
|
448
314
|
|
|
449
|
-
export declare interface
|
|
450
|
-
|
|
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;
|
|
451
323
|
}
|
|
452
324
|
|
|
453
325
|
export declare interface ISignatureCanvasMeta {
|
|
@@ -464,7 +336,7 @@ export declare interface ISignatureCanvasMeta {
|
|
|
464
336
|
}
|
|
465
337
|
|
|
466
338
|
export declare type ISignatureConfirmationData = [
|
|
467
|
-
points:
|
|
339
|
+
points: IPenDataPoint[],
|
|
468
340
|
imageBase64: string,
|
|
469
341
|
metadata: ISignatureResultMeta
|
|
470
342
|
];
|
|
@@ -583,110 +455,6 @@ declare class LocalizationManager {
|
|
|
583
455
|
private constructUrl;
|
|
584
456
|
}
|
|
585
457
|
|
|
586
|
-
/**
|
|
587
|
-
* `PointerManager` handles pointer interactions on a canvas element and converts them
|
|
588
|
-
* into standardized `IPenData`. This serves as a fallback mechanism for
|
|
589
|
-
* signature capture when a physical signature tablet is not available.
|
|
590
|
-
* Uses the Pointer Events API to support mouse, touch, and Apple Pencil uniformly.
|
|
591
|
-
*/
|
|
592
|
-
declare class PointerManager {
|
|
593
|
-
/** @private */
|
|
594
|
-
private canvas;
|
|
595
|
-
/** @private */
|
|
596
|
-
private onPenData;
|
|
597
|
-
/** @private */
|
|
598
|
-
private isDrawing;
|
|
599
|
-
/** @private */
|
|
600
|
-
private sequenceCounter;
|
|
601
|
-
/** @private */
|
|
602
|
-
private sessionStartTime;
|
|
603
|
-
/** @private Debug counter for listener registrations */
|
|
604
|
-
private debugListenerRegistrationCount;
|
|
605
|
-
/** @private */
|
|
606
|
-
private listenersAttached;
|
|
607
|
-
private boundHandlePointerDown;
|
|
608
|
-
private boundHandlePointerMove;
|
|
609
|
-
private boundHandlePointerUp;
|
|
610
|
-
private boundHandlePointerLeave;
|
|
611
|
-
private boundHandlePointerCancel;
|
|
612
|
-
/**
|
|
613
|
-
* Creates an instance of PointerManager.
|
|
614
|
-
* @param canvas - The HTMLCanvasElement to attach pointer listeners to.
|
|
615
|
-
* @param onPenDataCallback - The callback function that receives generated IPenData.
|
|
616
|
-
*/
|
|
617
|
-
constructor(canvas: HTMLCanvasElement, onPenDataCallback: IPenDataCallback);
|
|
618
|
-
/**
|
|
619
|
-
* Returns whether the user is currently in the middle of a drawing stroke.
|
|
620
|
-
*/
|
|
621
|
-
get isCurrentlyDrawing(): boolean;
|
|
622
|
-
/**
|
|
623
|
-
* Attaches pointer event listeners to the canvas to enable signature capture.
|
|
624
|
-
*/
|
|
625
|
-
addListeners(): void;
|
|
626
|
-
/**
|
|
627
|
-
* Removes pointer event listeners from the canvas and stops active drawing.
|
|
628
|
-
*/
|
|
629
|
-
removeListeners(): void;
|
|
630
|
-
/**
|
|
631
|
-
* Returns true if pointer listeners are currently attached.
|
|
632
|
-
*/
|
|
633
|
-
areListenersAttached(): boolean;
|
|
634
|
-
/**
|
|
635
|
-
* Resets the internal session state, including sequence counters and start time.
|
|
636
|
-
*/
|
|
637
|
-
resetSession(): void;
|
|
638
|
-
/**
|
|
639
|
-
* Handles the 'pointerdown' event: starts a stroke and initializes the session time.
|
|
640
|
-
* @private
|
|
641
|
-
*/
|
|
642
|
-
private handlePointerDown;
|
|
643
|
-
/**
|
|
644
|
-
* Handles the 'pointermove' event: continues the stroke if pointer is down.
|
|
645
|
-
* @private
|
|
646
|
-
*/
|
|
647
|
-
private handlePointerMove;
|
|
648
|
-
/**
|
|
649
|
-
* Handles the 'pointerup' event: ends the stroke.
|
|
650
|
-
* @private
|
|
651
|
-
*/
|
|
652
|
-
private handlePointerUp;
|
|
653
|
-
/**
|
|
654
|
-
* Handles the 'pointerleave' event: ends the stroke if the pointer leaves the canvas area.
|
|
655
|
-
* @private
|
|
656
|
-
*/
|
|
657
|
-
private handlePointerLeave;
|
|
658
|
-
/**
|
|
659
|
-
* Handles the 'pointercancel' event: terminates a stroke interrupted by the browser
|
|
660
|
-
* (e.g. iOS scroll taking over, incoming call, screen lock).
|
|
661
|
-
* @private
|
|
662
|
-
*/
|
|
663
|
-
private handlePointerCancel;
|
|
664
|
-
/**
|
|
665
|
-
* Core logic to transform a PointerEvent into IPenData.
|
|
666
|
-
* @param event - The raw browser PointerEvent.
|
|
667
|
-
* @param inContact - Whether the pointer is actively drawing on the surface.
|
|
668
|
-
* @private
|
|
669
|
-
*/
|
|
670
|
-
private processPointerEvent;
|
|
671
|
-
/**
|
|
672
|
-
* Returns the pressure value for a pointer event.
|
|
673
|
-
* Pen devices (Apple Pencil, stylus) report real pressure in the 0–1 range.
|
|
674
|
-
* Mouse and touch devices fall back to 0.5 (in contact) / 0 (not in contact).
|
|
675
|
-
* @private
|
|
676
|
-
*/
|
|
677
|
-
private getPressure;
|
|
678
|
-
/**
|
|
679
|
-
* Converts absolute pointer coordinates into a normalized 0-1 range relative to canvas size.
|
|
680
|
-
* @private
|
|
681
|
-
*/
|
|
682
|
-
private getNormalizedCoordinates;
|
|
683
|
-
/**
|
|
684
|
-
* Calculates the seconds elapsed since the start of the signature session.
|
|
685
|
-
* @private
|
|
686
|
-
*/
|
|
687
|
-
private timestampToSeconds;
|
|
688
|
-
}
|
|
689
|
-
|
|
690
458
|
/**
|
|
691
459
|
* SignosoftSignpad Web Component.
|
|
692
460
|
* A professional signature capture component supporting physical tablets and mouse fallback.
|
|
@@ -716,7 +484,6 @@ export declare class SignosoftSignpad extends LitElement {
|
|
|
716
484
|
setHasStartedDrawing(value: boolean): void;
|
|
717
485
|
setDeviceStatusText(value: string): void;
|
|
718
486
|
canvasManager: CanvasManager | null;
|
|
719
|
-
pointerManager: PointerManager | IosTouchManager | null;
|
|
720
487
|
connectionManager: ConnectionManager;
|
|
721
488
|
stateManager: StateManager;
|
|
722
489
|
buttonManager: ButtonManager;
|
|
@@ -839,24 +606,12 @@ export declare class SignosoftSignpad extends LitElement {
|
|
|
839
606
|
* @returns void
|
|
840
607
|
*/
|
|
841
608
|
private initializeCanvasManager;
|
|
842
|
-
/**
|
|
843
|
-
* Initializes the PointerManager for pointer/touch fallback.
|
|
844
|
-
* @private
|
|
845
|
-
* @returns void
|
|
846
|
-
*/
|
|
847
|
-
private initializePointerManager;
|
|
848
|
-
/**
|
|
849
|
-
* Throttles pen event dispatch to avoid excessive callback pressure.
|
|
850
|
-
* Drawing is still processed for every sample; only event emission is throttled.
|
|
851
|
-
*/
|
|
852
|
-
private dispatchPenEventThrottled;
|
|
853
609
|
/**
|
|
854
610
|
* Initializes the driver once a lease is provided via config.
|
|
855
611
|
* Safe to call repeatedly; initialization is performed at most once.
|
|
856
612
|
*/
|
|
857
613
|
private initializeFromConfigLeaseIfNeeded;
|
|
858
614
|
private autoConnectIfConfigured;
|
|
859
|
-
private canAttemptAutoConnect;
|
|
860
615
|
private ensureSignatureLayerReady;
|
|
861
616
|
private deferAutoConnectForState;
|
|
862
617
|
private clearPendingAutoConnectTimeout;
|
|
@@ -936,7 +691,6 @@ export declare enum SignpadMessage {
|
|
|
936
691
|
CONNECTION_ERROR = "CONNECTION_ERROR",
|
|
937
692
|
ERROR_DISCONNECTION = "ERROR_DISCONNECTION",
|
|
938
693
|
ERROR_INSTANTIATING_DRIVER = "ERROR_INSTANTIATING_DRIVER",
|
|
939
|
-
SIGNPAD_DISCONNECTED = "SIGNPAD_DISCONNECTED",
|
|
940
694
|
INVALID_LICENSE_KEY = "INVALID_LICENSE_KEY",
|
|
941
695
|
READY_TO_CONNECT = "READY_TO_CONNECT",
|
|
942
696
|
SIGNPAD_DETECTED = "SIGNPAD_DETECTED",
|
|
@@ -959,15 +713,6 @@ export declare enum SignpadState {
|
|
|
959
713
|
ERROR = "error"
|
|
960
714
|
}
|
|
961
715
|
|
|
962
|
-
export declare enum SignpadUI {
|
|
963
|
-
OK = "OK",
|
|
964
|
-
CLEAR = "CLEAR",
|
|
965
|
-
CANCEL = "CANCEL",
|
|
966
|
-
CLEAR_SIGNATURE = "CLEAR_SIGNATURE",
|
|
967
|
-
DISCONNECT = "DISCONNECT",
|
|
968
|
-
CONNECT_SIGNPAD = "CONNECT_SIGNPAD"
|
|
969
|
-
}
|
|
970
|
-
|
|
971
716
|
/**
|
|
972
717
|
* Manages the finite state machine and UI logic for the Signpad component.
|
|
973
718
|
* It handles state transitions, side effects (like adding/removing listeners),
|