@signosoft/signpad-js 0.5.3 → 0.7.0
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 +884 -639
- package/dist/index.d.ts +88 -471
- package/dist/signosoft-signpad.js +2221 -2110
- package/dist/signosoft-signpad.umd.cjs +73 -43
- package/package.json +15 -4
- package/presentation.gif +0 -0
- package/src/i18n/cs.json +38 -0
- package/src/i18n/en.json +38 -0
- package/src/i18n/pt.json +38 -0
- package/src/styles/primitive.css +292 -0
- package/src/styles/semantic-dark.css +82 -0
- package/src/styles/semantic.css +144 -0
- package/src/styles/signosoft-signpad.css +116 -36
- package/src/styles/styles-variables.css +61 -55
- package/docsVideo.gif +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,266 +1,7 @@
|
|
|
1
|
-
import { ConnectionMode } from '@signosoft/tablet-driver';
|
|
2
1
|
import { CSSResult } from 'lit';
|
|
3
2
|
import { LitElement } from 'lit';
|
|
4
3
|
import { TemplateResult } from 'lit-html';
|
|
5
4
|
|
|
6
|
-
declare class ButtonManager {
|
|
7
|
-
private component;
|
|
8
|
-
constructor(component: SignosoftSignpad);
|
|
9
|
-
/**
|
|
10
|
-
* Clears the current signature on device and UI, then dispatches SIGN_CLEAR.
|
|
11
|
-
* @returns Resolves when the clear flow completes.
|
|
12
|
-
*/
|
|
13
|
-
handleClear(): Promise<void>;
|
|
14
|
-
/**
|
|
15
|
-
* Finalizes the signature, dispatches SIGN_OK, and returns captured data.
|
|
16
|
-
* @returns Captured signature payload from the driver.
|
|
17
|
-
*/
|
|
18
|
-
handleOk(): Promise<ISignatureConfirmationData | undefined>;
|
|
19
|
-
/**
|
|
20
|
-
* Cancels the signature without collecting data, dispatches SIGN_CANCEL.
|
|
21
|
-
* @returns Resolves when the cancel flow completes.
|
|
22
|
-
*/
|
|
23
|
-
handleCancel(): Promise<void>;
|
|
24
|
-
/**
|
|
25
|
-
* Starts a new signing session and transitions to the ready state.
|
|
26
|
-
* @param drawingOptions - Optional line thickness and color settings.
|
|
27
|
-
* @returns Resolves when the session is ready.
|
|
28
|
-
*/
|
|
29
|
-
startSigning(drawingOptions?: IDrawingOptions): Promise<void>;
|
|
30
|
-
/**
|
|
31
|
-
* Stops the current signing session and returns captured data.
|
|
32
|
-
* @returns Captured signature payload from the driver.
|
|
33
|
-
*/
|
|
34
|
-
stopSigning(): Promise<any>;
|
|
35
|
-
/**
|
|
36
|
-
* Shared template for OK, Cancel, and Clear actions.
|
|
37
|
-
* @param processingState - State used while processing the action.
|
|
38
|
-
* @param actionLogic - Action-specific logic to execute.
|
|
39
|
-
* @returns Result produced by the action logic.
|
|
40
|
-
*/
|
|
41
|
-
private executeAction;
|
|
42
|
-
/**
|
|
43
|
-
* Resolves the ready state based on current connection type.
|
|
44
|
-
* @returns The next ready state (physical or fallback).
|
|
45
|
-
*/
|
|
46
|
-
private getReadyState;
|
|
47
|
-
/**
|
|
48
|
-
* Fallback handling when startSigning cannot proceed.
|
|
49
|
-
*/
|
|
50
|
-
private handleStartSigningError;
|
|
51
|
-
/**
|
|
52
|
-
* Centralized error handling for button actions.
|
|
53
|
-
* @param message - Human-readable error description.
|
|
54
|
-
* @param error - Original error instance.
|
|
55
|
-
*/
|
|
56
|
-
private handleError;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* `CanvasManager` is a lightweight canvas utility.
|
|
61
|
-
* Drawing is handled by SignatureLayer from `@signosoft/tablet-driver`.
|
|
62
|
-
*/
|
|
63
|
-
declare class CanvasManager {
|
|
64
|
-
/** @private The target canvas element */
|
|
65
|
-
private canvas;
|
|
66
|
-
/** @private The 2D rendering context */
|
|
67
|
-
private ctx;
|
|
68
|
-
/** @private The active configuration for line styles */
|
|
69
|
-
private currentDrawingOptions;
|
|
70
|
-
/**
|
|
71
|
-
* Creates an instance of CanvasManager.
|
|
72
|
-
* @param canvas - The HTMLCanvasElement to draw on.
|
|
73
|
-
* @param initialDrawingOptions - Configuration for colors and line thickness.
|
|
74
|
-
*/
|
|
75
|
-
constructor(canvas: HTMLCanvasElement, initialDrawingOptions?: IDrawingOptions);
|
|
76
|
-
/**
|
|
77
|
-
* Returns the currently active drawing configuration.
|
|
78
|
-
* @returns A copy of the current drawing options.
|
|
79
|
-
*/
|
|
80
|
-
get drawingOptions(): IDrawingOptions;
|
|
81
|
-
/**
|
|
82
|
-
* Updates the drawing options and immediately applies them to the context.
|
|
83
|
-
* @param options - The new drawing configuration.
|
|
84
|
-
*/
|
|
85
|
-
updateDrawingOptions(options: IDrawingOptions): void;
|
|
86
|
-
/**
|
|
87
|
-
* Wipes the canvas clean and resets the drawing state.
|
|
88
|
-
*/
|
|
89
|
-
clear(): void;
|
|
90
|
-
/**
|
|
91
|
-
* Adjusts the canvas internal resolution to match high-DPI (Retina) screens.
|
|
92
|
-
* Prevents signatures from appearing blurry.
|
|
93
|
-
* @private
|
|
94
|
-
*/
|
|
95
|
-
configureCanvasForDPI(): void;
|
|
96
|
-
/**
|
|
97
|
-
* Applies line caps, joins, and composite operations to the rendering context.
|
|
98
|
-
* @param options - The style options to apply.
|
|
99
|
-
* @private
|
|
100
|
-
*/
|
|
101
|
-
private applyDrawingStyles;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Handles config-driven side effects for the signpad component.
|
|
106
|
-
*/
|
|
107
|
-
declare class ConfigManager {
|
|
108
|
-
private component;
|
|
109
|
-
private configEventHandlers;
|
|
110
|
-
private customEventListenerCache;
|
|
111
|
-
/**
|
|
112
|
-
* @param component - The host SignosoftSignpad instance.
|
|
113
|
-
*/
|
|
114
|
-
constructor(component: SignosoftSignpad);
|
|
115
|
-
/**
|
|
116
|
-
* Applies config-driven side effects (localization, drawing, callbacks).
|
|
117
|
-
* @param prevConfig - Optional previous config for diffing.
|
|
118
|
-
*/
|
|
119
|
-
apply(prevConfig?: SignpadConfig): void;
|
|
120
|
-
/**
|
|
121
|
-
* Returns resolved UI visibility options with defaults applied.
|
|
122
|
-
* @returns UI visibility options.
|
|
123
|
-
*/
|
|
124
|
-
getUiVisibilityOptions(): IUIVisibilityOptions;
|
|
125
|
-
/**
|
|
126
|
-
* Returns resolved drawing options with defaults applied.
|
|
127
|
-
* @returns Drawing options for the canvas.
|
|
128
|
-
*/
|
|
129
|
-
getDrawingOptions(): IDrawingOptions;
|
|
130
|
-
/**
|
|
131
|
-
* Applies localization updates when language configuration changes.
|
|
132
|
-
* @param prevConfig - Previous configuration.
|
|
133
|
-
* @param currentConfig - Current configuration.
|
|
134
|
-
*/
|
|
135
|
-
private applyLocalization;
|
|
136
|
-
/**
|
|
137
|
-
* Applies drawing option updates when configuration changes.
|
|
138
|
-
* @param prevConfig - Previous configuration.
|
|
139
|
-
* @param currentConfig - Current configuration.
|
|
140
|
-
*/
|
|
141
|
-
private applyDrawingOptions;
|
|
142
|
-
/**
|
|
143
|
-
* Syncs config-provided event handlers with component listeners,
|
|
144
|
-
* adding, replacing, or removing them as needed.
|
|
145
|
-
* @param config - Current signpad configuration.
|
|
146
|
-
*/
|
|
147
|
-
private syncConfigEventHandlers;
|
|
148
|
-
/**
|
|
149
|
-
* Removes all config-based event handlers from the component.
|
|
150
|
-
*/
|
|
151
|
-
private clearConfigEventHandlers;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* `ConnectionManager` handles the lifecycle of the signature pad connection.
|
|
156
|
-
* It manages driver initialization, license authentication, device handshaking,
|
|
157
|
-
* and event forwarding from the physical driver to the component.
|
|
158
|
-
*/
|
|
159
|
-
declare class ConnectionManager {
|
|
160
|
-
/** @private Reference to the parent component */
|
|
161
|
-
private component;
|
|
162
|
-
/** @private The low-level driver instance */
|
|
163
|
-
private sigLayer;
|
|
164
|
-
/** @private Cached device info from the last successful connect */
|
|
165
|
-
private cachedDeviceInfo;
|
|
166
|
-
/** @private Timestamp of the last pen event dispatch */
|
|
167
|
-
private lastPenDispatchTime;
|
|
168
|
-
/** @private Buffered pen data for throttling */
|
|
169
|
-
private penDataToDispatch;
|
|
170
|
-
/** @private Minimum delay between pen events (approx 60fps) */
|
|
171
|
-
private throttleDelayMs;
|
|
172
|
-
private static readonly POINTER_FALLBACK_DEVICE_NAME;
|
|
173
|
-
/**
|
|
174
|
-
* @param component - The host SignosoftSignpad instance.
|
|
175
|
-
*/
|
|
176
|
-
constructor(component: SignosoftSignpad);
|
|
177
|
-
/**
|
|
178
|
-
* Initiates the connection process to a physical device or a mouse fallback.
|
|
179
|
-
*
|
|
180
|
-
* @param autoConnect - Connect mode: "manual" opens the browser device selection
|
|
181
|
-
* dialog; "auto"/"hotplug" attempt already-authorized devices silently.
|
|
182
|
-
* @param allowFallback - If true, enables mouse/pointer input if no physical device is found.
|
|
183
|
-
* @returns A promise resolving to true if connection (or fallback) was successful.
|
|
184
|
-
*/
|
|
185
|
-
connect(autoConnect?: ConnectionMode, allowFallback?: boolean): Promise<boolean>;
|
|
186
|
-
/**
|
|
187
|
-
* Terminates the connection with the device and cleans up the driver instance.
|
|
188
|
-
* @returns Resolves when disconnection completes.
|
|
189
|
-
*/
|
|
190
|
-
disconnect(): Promise<void>;
|
|
191
|
-
/**
|
|
192
|
-
* Returns true when a SignatureLayer instance exists.
|
|
193
|
-
* @returns True if the driver instance is available.
|
|
194
|
-
*/
|
|
195
|
-
hasSignatureLayer(): boolean;
|
|
196
|
-
/**
|
|
197
|
-
* Returns the device info from SignatureLayer if available.
|
|
198
|
-
* @returns Device info or null if unavailable.
|
|
199
|
-
*/
|
|
200
|
-
getDeviceInfo(): Promise<any | null>;
|
|
201
|
-
/**
|
|
202
|
-
* Returns true if the SignatureLayer reports an active connection.
|
|
203
|
-
* @returns True if a device is connected.
|
|
204
|
-
*/
|
|
205
|
-
isDeviceConnected(): boolean;
|
|
206
|
-
/**
|
|
207
|
-
* Starts a signing session on the provided canvas.
|
|
208
|
-
* @param canvasElement - Optional canvas reference.
|
|
209
|
-
* @param drawingOptions - Optional drawing options.
|
|
210
|
-
* @returns A promise resolving to true if the session started successfully.
|
|
211
|
-
*/
|
|
212
|
-
startSigning(canvas: HTMLCanvasElement, drawingOptions?: IDrawingOptions): Promise<boolean>;
|
|
213
|
-
/**
|
|
214
|
-
* Stops the current signing session if active.
|
|
215
|
-
* @returns Signature data if available.
|
|
216
|
-
*/
|
|
217
|
-
stopSigning(): Promise<any>;
|
|
218
|
-
/**
|
|
219
|
-
* Clears the signature on the device if a signing session is active.
|
|
220
|
-
* Silently does nothing if no session is active.
|
|
221
|
-
* @returns Resolves when the clear completes.
|
|
222
|
-
*/
|
|
223
|
-
clearSignature(): Promise<void>;
|
|
224
|
-
/**
|
|
225
|
-
* Instantiates the SignatureLayer if it doesn't exist and attaches listeners.
|
|
226
|
-
* @returns Resolves when the driver is ready.
|
|
227
|
-
*/
|
|
228
|
-
private ensureSignatureLayer;
|
|
229
|
-
/**
|
|
230
|
-
* Configures driver event listeners (OK, Clear, Cancel, Pen events).
|
|
231
|
-
* @returns void
|
|
232
|
-
*/
|
|
233
|
-
private setupCallbacks;
|
|
234
|
-
/**
|
|
235
|
-
* Throttles pen data dispatches to optimize event bus performance.
|
|
236
|
-
* @param data - The IPenData received from the driver.
|
|
237
|
-
*/
|
|
238
|
-
private runThrottledPenDispatch;
|
|
239
|
-
/**
|
|
240
|
-
* Fetches a lease from the license server and initializes the driver.
|
|
241
|
-
* @returns Resolves when the driver is initialized.
|
|
242
|
-
*/
|
|
243
|
-
initWithLease(lease: any): Promise<void>;
|
|
244
|
-
isFallback(deviceInfo: any | null, isDeviceConnected: boolean, includeDisconnected: boolean): boolean;
|
|
245
|
-
/**
|
|
246
|
-
* Normalizes device info to always include deviceName.
|
|
247
|
-
* @param deviceInfo - Raw device info.
|
|
248
|
-
* @returns Normalized device info or null.
|
|
249
|
-
*/
|
|
250
|
-
private normalizeDeviceInfo;
|
|
251
|
-
/**
|
|
252
|
-
* Driver connect step (this is where interactive vs silent HID behavior happens).
|
|
253
|
-
* `autoConnect = false` may open the browser HID picker.
|
|
254
|
-
* `autoConnect = true` tries reconnecting already-authorized devices silently.
|
|
255
|
-
*/
|
|
256
|
-
private runDriverConnectAttempt;
|
|
257
|
-
/**
|
|
258
|
-
* Chooses whether the component should finish in physical mode or mouse fallback.
|
|
259
|
-
* This step only decides state; it does not trigger HID dialog itself.
|
|
260
|
-
*/
|
|
261
|
-
private resolveConnectionTarget;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
5
|
export declare enum DeviceStatusText {
|
|
265
6
|
MOUSE = "MOUSE",
|
|
266
7
|
CONNECTED_UNKNOWN = "CONNECTED_UNKNOWN_DEVICE"
|
|
@@ -288,7 +29,7 @@ export declare interface IEventCallbacks {
|
|
|
288
29
|
onOk?: (event: CustomEvent<ISignatureConfirmationData>) => void;
|
|
289
30
|
onClear?: (event: CustomEvent<void>) => void;
|
|
290
31
|
onCancel?: (event: CustomEvent<void>) => void;
|
|
291
|
-
onError?: (event: CustomEvent<
|
|
32
|
+
onError?: (event: CustomEvent<ISignpadErrorDetail>) => void;
|
|
292
33
|
}
|
|
293
34
|
|
|
294
35
|
export declare interface ILanguageOptions {
|
|
@@ -360,6 +101,12 @@ export declare interface ISignatureTabletMeta {
|
|
|
360
101
|
[key: string]: any;
|
|
361
102
|
}
|
|
362
103
|
|
|
104
|
+
export declare interface ISignpadErrorDetail {
|
|
105
|
+
code: SignpadErrorCode;
|
|
106
|
+
message: string;
|
|
107
|
+
error: Error;
|
|
108
|
+
}
|
|
109
|
+
|
|
363
110
|
export declare interface ITranslationSet {
|
|
364
111
|
[key: string]: string;
|
|
365
112
|
}
|
|
@@ -375,80 +122,11 @@ export declare interface IUIVisibilityOptions {
|
|
|
375
122
|
canvasLineVisible?: boolean;
|
|
376
123
|
deviceStatusTextVisible?: boolean;
|
|
377
124
|
additionalTextVisible?: boolean;
|
|
125
|
+
startNewSignatureButtonVisible?: boolean;
|
|
378
126
|
}
|
|
379
127
|
|
|
380
128
|
export declare type LanguageCode = "en" | "cs" | "pt" | (string & {});
|
|
381
129
|
|
|
382
|
-
/**
|
|
383
|
-
* Manages localization for the signpad component.
|
|
384
|
-
*
|
|
385
|
-
* This manager supports:
|
|
386
|
-
* 1. Built-in translations (English as default fallback).
|
|
387
|
-
* 2. External translation overrides via remote JSON files.
|
|
388
|
-
* 3. Dynamic parameter interpolation in strings.
|
|
389
|
-
*/
|
|
390
|
-
declare class LocalizationManager {
|
|
391
|
-
/** @private Reference to the parent component to trigger updates */
|
|
392
|
-
private component;
|
|
393
|
-
/** @private The currently active translation dictionary */
|
|
394
|
-
private translations;
|
|
395
|
-
/** @private The ISO code of the currently loaded language */
|
|
396
|
-
private currentLang;
|
|
397
|
-
/** @private The last used path for external translations */
|
|
398
|
-
private currentPath;
|
|
399
|
-
/**
|
|
400
|
-
* @param component - The LitElement instance that uses this manager.
|
|
401
|
-
*/
|
|
402
|
-
constructor(component: LitElement);
|
|
403
|
-
/**
|
|
404
|
-
* Translates a key based on the loaded dictionary.
|
|
405
|
-
* Supports parameter interpolation using the `{key}` syntax.
|
|
406
|
-
*
|
|
407
|
-
* @param key - The translation key (e.g., "CONNECT_DEVICE").
|
|
408
|
-
* @param params - Key-value pairs to replace placeholders in the string.
|
|
409
|
-
* @returns The translated string, or the raw key if no translation exists.
|
|
410
|
-
*/
|
|
411
|
-
t(key: string, params?: Record<string, string>): string;
|
|
412
|
-
/**
|
|
413
|
-
* Loads and merges translations for the specified language.
|
|
414
|
-
*
|
|
415
|
-
* Strategy:
|
|
416
|
-
* 1. Check for redundancy: If lang and path haven't changed, skip.
|
|
417
|
-
* 2. Baseline: Start with built-in translations (merged with English as fallback).
|
|
418
|
-
* 3. Fetch: If a path is provided, attempt to fetch an external JSON file.
|
|
419
|
-
* 4. Merge: External translations override built-in ones.
|
|
420
|
-
*
|
|
421
|
-
* @param langCode - ISO language code (e.g., 'en', 'cs', 'de').
|
|
422
|
-
* @param basePath - Optional path/URL to fetch external translation files.
|
|
423
|
-
* @param inlineTranslations - Optional inline translations to apply.
|
|
424
|
-
* @returns Resolves when translations are loaded and applied.
|
|
425
|
-
*/
|
|
426
|
-
loadLanguage(langCode: string, basePath?: string, inlineTranslations?: ITranslationSet | Record<string, ITranslationSet>): Promise<void>;
|
|
427
|
-
/**
|
|
428
|
-
* Determines the initial translation set.
|
|
429
|
-
* If the language is built-in, it merges it with English to ensure no missing keys.
|
|
430
|
-
*
|
|
431
|
-
* @param langCode - The target language code.
|
|
432
|
-
* @returns Baseline translations for the language.
|
|
433
|
-
*/
|
|
434
|
-
private getBaselineTranslations;
|
|
435
|
-
/**
|
|
436
|
-
* Resolves inline translations for the requested language, if provided.
|
|
437
|
-
* @param langCode - The target language code.
|
|
438
|
-
* @param inline - Inline translation map or set.
|
|
439
|
-
* @returns Inline translations for the language if found.
|
|
440
|
-
*/
|
|
441
|
-
private resolveInlineTranslations;
|
|
442
|
-
/**
|
|
443
|
-
* Constructs the full URL for the translation JSON file.
|
|
444
|
-
*
|
|
445
|
-
* @param langCode - The language code.
|
|
446
|
-
* @param basePath - The directory path.
|
|
447
|
-
* @returns Resolved translation file URL.
|
|
448
|
-
*/
|
|
449
|
-
private constructUrl;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
130
|
/**
|
|
453
131
|
* SignosoftSignpad Web Component.
|
|
454
132
|
* A professional signature capture component supporting physical tablets and mouse fallback.
|
|
@@ -465,25 +143,16 @@ export declare class SignosoftSignpad extends LitElement {
|
|
|
465
143
|
* @private
|
|
466
144
|
*/
|
|
467
145
|
canvasRef: HTMLCanvasElement;
|
|
468
|
-
/** Current state of the signpad machine. */
|
|
469
|
-
|
|
146
|
+
/** Current state of the signpad machine. Starts as CONNECTING: waiting for the lease before the first connect. */
|
|
147
|
+
currentState: SignpadState;
|
|
470
148
|
/** Current status message key for localization. */
|
|
471
|
-
|
|
149
|
+
statusMessage: string;
|
|
150
|
+
/** Code of the current ERROR, or null outside ERROR. */
|
|
151
|
+
errorCode: SignpadErrorCode | null;
|
|
472
152
|
/** Boolean flag indicating if the user has started drawing. */
|
|
473
|
-
|
|
153
|
+
hasStartedDrawing: boolean;
|
|
474
154
|
/** Text representation of the current device status. */
|
|
475
|
-
|
|
476
|
-
setCurrentState(value: SignpadState): void;
|
|
477
|
-
setStatusMessage(value: string): void;
|
|
478
|
-
setHasStartedDrawing(value: boolean): void;
|
|
479
|
-
setDeviceStatusText(value: string): void;
|
|
480
|
-
canvasManager: CanvasManager | null;
|
|
481
|
-
connectionManager: ConnectionManager;
|
|
482
|
-
stateManager: StateManager;
|
|
483
|
-
buttonManager: ButtonManager;
|
|
484
|
-
localizationManager: LocalizationManager;
|
|
485
|
-
configManager: ConfigManager;
|
|
486
|
-
webHIDAPI: any;
|
|
155
|
+
deviceStatusText: string;
|
|
487
156
|
clear: () => Promise<void>;
|
|
488
157
|
ok: () => Promise<ISignatureConfirmationData | undefined>;
|
|
489
158
|
cancel: () => Promise<void>;
|
|
@@ -508,18 +177,16 @@ export declare class SignosoftSignpad extends LitElement {
|
|
|
508
177
|
* @protected
|
|
509
178
|
*/
|
|
510
179
|
protected updated(changedProperties: Map<PropertyKey, unknown>): void;
|
|
180
|
+
/**
|
|
181
|
+
* Moves focus to the restart button when an error appears, but only if
|
|
182
|
+
* focus is already inside the component so host-page focus isn't stolen.
|
|
183
|
+
*/
|
|
184
|
+
private focusRestartButtonOnError;
|
|
511
185
|
/**
|
|
512
186
|
* Component constructor.
|
|
513
187
|
* Initializes all sub-managers.
|
|
514
188
|
*/
|
|
515
189
|
constructor();
|
|
516
|
-
/**
|
|
517
|
-
* Dispatches a custom event from the component.
|
|
518
|
-
* @param name - The name of the event.
|
|
519
|
-
* @param detail - Optional data payload for the event.
|
|
520
|
-
* @returns void
|
|
521
|
-
*/
|
|
522
|
-
dispatch(name: string, detail?: any): void;
|
|
523
190
|
/**
|
|
524
191
|
* Attempts to establish a connection with a signature tablet.
|
|
525
192
|
* @param autoConnect - Connect mode: "manual" opens the browser HID picker;
|
|
@@ -528,27 +195,36 @@ export declare class SignosoftSignpad extends LitElement {
|
|
|
528
195
|
* @returns A promise resolving to true if connection (or fallback) succeeded.
|
|
529
196
|
*/
|
|
530
197
|
private connectWith;
|
|
198
|
+
/** True until the first connect attempt starts (waiting for the lease). */
|
|
199
|
+
private get isInitializing();
|
|
200
|
+
/** Moves to ERROR with `error`'s own code, or `fallback` if it has none. */
|
|
201
|
+
private reportError;
|
|
202
|
+
/**
|
|
203
|
+
* Resolves once `config.lease` is available. Waits up to LEASE_WAIT_ATTEMPTS
|
|
204
|
+
* times LEASE_WAIT_TIMEOUT_MS; after that the wait is spent and LICENSE_MISSING
|
|
205
|
+
* is reported immediately until a lease arrives (config change re-runs auto-connect).
|
|
206
|
+
* @returns True when a lease is present.
|
|
207
|
+
*/
|
|
208
|
+
private requireLease;
|
|
209
|
+
private waitForLease;
|
|
531
210
|
/**
|
|
532
211
|
* Closes the active tablet connection and switches to mouse fallback mode.
|
|
533
212
|
* @returns A promise that resolves when disconnection is complete.
|
|
534
213
|
*/
|
|
535
214
|
disconnect(): Promise<void>;
|
|
536
|
-
/**
|
|
537
|
-
* Resets the UI canvas and internal drawing flags.
|
|
538
|
-
* @returns void
|
|
539
|
-
*/
|
|
540
|
-
resetDrawingState(): void;
|
|
541
|
-
/**
|
|
542
|
-
* Enables or disables browser pointer interaction on the drawing canvas.
|
|
543
|
-
* Physical tablet mode disables browser pointer input to prevent mouse drawing.
|
|
544
|
-
*/
|
|
545
|
-
setCanvasPointerInputEnabled(enabled: boolean): void;
|
|
546
215
|
/**
|
|
547
216
|
* Lit lifecycle: Invoked when the component is removed from the document's DOM.
|
|
548
217
|
* Performs necessary cleanup of listeners and connections.
|
|
549
218
|
* @returns void
|
|
550
219
|
*/
|
|
220
|
+
connectedCallback(): void;
|
|
551
221
|
disconnectedCallback(): void;
|
|
222
|
+
/**
|
|
223
|
+
* Ends the driver session after the element was removed from the DOM. Unlike `disconnect()`
|
|
224
|
+
* it does not start a mouse fallback session (that would re-initialize the driver on a
|
|
225
|
+
* detached element).
|
|
226
|
+
*/
|
|
227
|
+
private releaseDriver;
|
|
552
228
|
/**
|
|
553
229
|
* Keeps canvas internal size in sync with responsive layout changes.
|
|
554
230
|
* @private
|
|
@@ -565,7 +241,7 @@ export declare class SignosoftSignpad extends LitElement {
|
|
|
565
241
|
connect: () => Promise<void>;
|
|
566
242
|
/**
|
|
567
243
|
* If currently in mouse fallback, tears that session down seamlessly
|
|
568
|
-
* (no
|
|
244
|
+
* (no intermediate UI flash) so a physical-device connect attempt can
|
|
569
245
|
* proceed cleanly.
|
|
570
246
|
*/
|
|
571
247
|
private prepareForManualConnect;
|
|
@@ -623,6 +299,7 @@ export declare class SignosoftSignpad extends LitElement {
|
|
|
623
299
|
*/
|
|
624
300
|
private initializeFromConfigLeaseIfNeeded;
|
|
625
301
|
private autoConnectIfConfigured;
|
|
302
|
+
private runAutoConnect;
|
|
626
303
|
private ensureSignatureLayerReady;
|
|
627
304
|
private deferAutoConnectForState;
|
|
628
305
|
private clearPendingAutoConnectTimeout;
|
|
@@ -630,9 +307,22 @@ export declare class SignosoftSignpad extends LitElement {
|
|
|
630
307
|
private shouldScheduleImmediateRetry;
|
|
631
308
|
private scheduleAutoConnectRetry;
|
|
632
309
|
private clearAutoConnectQueue;
|
|
310
|
+
/**
|
|
311
|
+
* Restarts the signing session after an error (restart button), respecting
|
|
312
|
+
* the connect/disconnect reentrancy lock so it never races a concurrent
|
|
313
|
+
* manual connect/disconnect or hotplug transition.
|
|
314
|
+
*/
|
|
315
|
+
private restartSigningAfterError;
|
|
316
|
+
/**
|
|
317
|
+
* Runs `action` as the only connect/disconnect transition. Other transitions wait for it
|
|
318
|
+
* instead of interleaving (or being dropped), so state changes stay serialized.
|
|
319
|
+
*/
|
|
320
|
+
private withTransitionLock;
|
|
321
|
+
/** Restart button in the error overlay. */
|
|
322
|
+
private handleRestartSessionClick;
|
|
633
323
|
private delay;
|
|
634
324
|
/**
|
|
635
|
-
* Disconnects current session without
|
|
325
|
+
* Disconnects current session without an intermediate UI state.
|
|
636
326
|
* Used for smooth mode switching (mouse <-> physical).
|
|
637
327
|
*/
|
|
638
328
|
private disconnectForSeamlessSwitch;
|
|
@@ -646,10 +336,6 @@ export declare class SignosoftSignpad extends LitElement {
|
|
|
646
336
|
* stays physically plugged in.
|
|
647
337
|
*/
|
|
648
338
|
private startMouseFallbackSigningSession;
|
|
649
|
-
/**
|
|
650
|
-
* Switches from physical tablet mode to mouse fallback after disconnect.
|
|
651
|
-
*/
|
|
652
|
-
recoverToMouseFallback(messageKey?: string, minLoadingMs?: number): Promise<void>;
|
|
653
339
|
/**
|
|
654
340
|
* Promotes active mouse fallback session to a physical tablet when one is plugged in.
|
|
655
341
|
*/
|
|
@@ -669,6 +355,8 @@ export declare type SignosoftSignpadProps = {
|
|
|
669
355
|
|
|
670
356
|
export declare interface SignpadConfig {
|
|
671
357
|
lease?: {};
|
|
358
|
+
/** `"light"` (default), `"dark"`, or `"auto"` to follow the OS `prefers-color-scheme`. */
|
|
359
|
+
theme?: SignpadTheme;
|
|
672
360
|
languageOptions?: ILanguageOptions;
|
|
673
361
|
uiVisibilityOptions?: IUIVisibilityOptions;
|
|
674
362
|
canvasAndDrawingOptions?: IDrawingOptions;
|
|
@@ -676,6 +364,22 @@ export declare interface SignpadConfig {
|
|
|
676
364
|
eventCallbacks?: IEventCallbacks;
|
|
677
365
|
}
|
|
678
366
|
|
|
367
|
+
/**
|
|
368
|
+
* Error identifiers delivered in `onError` (`detail.code`), formatted `AREA-NN`:
|
|
369
|
+
* LIC license, DRV driver, CON connection, NET network, BIL billing,
|
|
370
|
+
* SES signing session, ACT signing actions (OK/Clear/Cancel).
|
|
371
|
+
*/
|
|
372
|
+
export declare enum SignpadErrorCode {
|
|
373
|
+
LICENSE_MISSING = "LIC-01",
|
|
374
|
+
LICENSE_INVALID = "LIC-02",
|
|
375
|
+
DRIVER_INIT_FAILED = "DRV-01",
|
|
376
|
+
CONNECT_FAILED = "CON-01",
|
|
377
|
+
NETWORK_ERROR = "NET-01",
|
|
378
|
+
BILLING_DENIED = "BIL-01",
|
|
379
|
+
START_SIGNING_FAILED = "SES-01",
|
|
380
|
+
ACTION_FAILED = "ACT-01"
|
|
381
|
+
}
|
|
382
|
+
|
|
679
383
|
export declare enum SignpadEventType {
|
|
680
384
|
SIGN_PEN = "sign-pen",
|
|
681
385
|
SIGN_OK = "sign-ok",
|
|
@@ -692,31 +396,34 @@ export declare enum SignpadMessage {
|
|
|
692
396
|
CONNECTING_TO_DEVICE = "CONNECTING_TO_DEVICE",
|
|
693
397
|
REVERTING_TO_DEFAULT = "REVERTING_TO_DEFAULT",
|
|
694
398
|
DISCONNECTING_DEVICE = "DISCONNECTING_DEVICE",
|
|
695
|
-
|
|
399
|
+
PREPARING_SESSION = "PREPARING_SESSION",
|
|
400
|
+
RESTART_SESSION = "RESTART_SESSION",
|
|
401
|
+
PROCESSING_OK = "PROCESSING_OK",
|
|
402
|
+
PROCESSING_CLEAR = "PROCESSING_CLEAR",
|
|
403
|
+
PROCESSING_CANCEL = "PROCESSING_CANCEL",
|
|
404
|
+
INITIALIZING = "INITIALIZING",
|
|
696
405
|
TEXT_START_SIGNING = "TEXT_START_SIGNING",
|
|
697
406
|
TEXT_SIGN_WITH_PHYSICAL = "TEXT_SIGN_WITH_PHYSICAL",
|
|
698
407
|
TEXT_SIGN_WITH_MOUSE = "TEXT_SIGN_WITH_MOUSE",
|
|
699
408
|
TEXT_SIGN_GENERIC = "TEXT_SIGN_GENERIC",
|
|
700
409
|
TEXT_SIGNING_WITH_DEVICE = "TEXT_SIGNING_WITH_DEVICE",
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
ERROR_DISCONNECTION = "ERROR_DISCONNECTION",
|
|
704
|
-
ERROR_INSTANTIATING_DRIVER = "ERROR_INSTANTIATING_DRIVER",
|
|
410
|
+
TEXT_PRESS_START_SIGNING = "TEXT_PRESS_START_SIGNING",
|
|
411
|
+
LICENSE_MISSING = "LICENSE_MISSING",
|
|
705
412
|
INVALID_LICENSE_KEY = "INVALID_LICENSE_KEY",
|
|
706
|
-
|
|
707
|
-
|
|
413
|
+
ERROR_DRIVER_INIT = "ERROR_DRIVER_INIT",
|
|
414
|
+
CONNECTION_ERROR = "CONNECTION_ERROR",
|
|
415
|
+
NETWORK_ERROR = "NETWORK_ERROR",
|
|
416
|
+
INSUFFICIENT_TOKENS = "INSUFFICIENT_TOKENS",
|
|
417
|
+
ERROR_STARTING_SIGNING = "ERROR_STARTING_SIGNING",
|
|
418
|
+
ERROR_PROCESSING_ACTION = "ERROR_PROCESSING_ACTION",
|
|
708
419
|
READY_TO_SIGN_MOUSE = "READY_TO_SIGN_MOUSE",
|
|
709
420
|
READY_TO_SIGN_PHYSICAL = "READY_TO_SIGN_PHYSICAL"
|
|
710
421
|
}
|
|
711
422
|
|
|
712
423
|
export declare enum SignpadState {
|
|
713
|
-
INITIAL = "initial",
|
|
714
|
-
DISCONNECTED = "disconnected",
|
|
715
424
|
CONNECTING = "connecting",
|
|
716
|
-
WAITING_FOR_DEVICE_SELECTION = "waiting_for_device_selection",
|
|
717
425
|
CONNECTED_PHYSICAL = "connected_physical",
|
|
718
426
|
CONNECTED_MOUSE_FALLBACK = "connected_mouse_fallback",
|
|
719
|
-
SIGNING_ACTIVE = "signing_active",
|
|
720
427
|
PROCESSING_OK = "processing_ok",
|
|
721
428
|
PROCESSING_CLEAR = "processing_clear",
|
|
722
429
|
PROCESSING_CANCEL = "processing_cancel",
|
|
@@ -724,97 +431,7 @@ export declare enum SignpadState {
|
|
|
724
431
|
ERROR = "error"
|
|
725
432
|
}
|
|
726
433
|
|
|
727
|
-
|
|
728
|
-
* Manages the finite state machine and UI logic for the Signpad component.
|
|
729
|
-
* It handles state transitions, side effects (like adding/removing listeners),
|
|
730
|
-
* and provides computed properties for the UI (button states, visibility, etc.).
|
|
731
|
-
*/
|
|
732
|
-
declare class StateManager {
|
|
733
|
-
/**
|
|
734
|
-
* Reference to the parent component.
|
|
735
|
-
* @private
|
|
736
|
-
*/
|
|
737
|
-
private component;
|
|
738
|
-
/**
|
|
739
|
-
* @param component - The host SignosoftSignpad instance.
|
|
740
|
-
*/
|
|
741
|
-
constructor(component: SignosoftSignpad);
|
|
742
|
-
/**
|
|
743
|
-
* Returns the localization key or device name for the current status.
|
|
744
|
-
* @returns Localization key or device name.
|
|
745
|
-
*/
|
|
746
|
-
get deviceStatusKey(): string;
|
|
747
|
-
/**
|
|
748
|
-
* Returns the current status message key.
|
|
749
|
-
* @returns Status message key.
|
|
750
|
-
*/
|
|
751
|
-
get statusMessageKey(): string;
|
|
752
|
-
/**
|
|
753
|
-
* Computes the localization key for instructions based on current state.
|
|
754
|
-
* Returns null if custom additionalText is provided by the user.
|
|
755
|
-
* @returns Localization key for additional text.
|
|
756
|
-
*/
|
|
757
|
-
get additionalTextKey(): string;
|
|
758
|
-
/**
|
|
759
|
-
* Returns true if the component is in any connected state (Physical or Fallback).
|
|
760
|
-
* @returns True when connected or signing.
|
|
761
|
-
*/
|
|
762
|
-
get isConnected(): boolean;
|
|
763
|
-
/**
|
|
764
|
-
* Returns true only for a physical device connection lifecycle.
|
|
765
|
-
* Mouse fallback is intentionally excluded.
|
|
766
|
-
* @returns True when a physical device is connected/signing/processing.
|
|
767
|
-
*/
|
|
768
|
-
get isPhysicalConnected(): boolean;
|
|
769
|
-
/**
|
|
770
|
-
* Returns true if the component is performing an asynchronous operation.
|
|
771
|
-
* @returns True when busy.
|
|
772
|
-
*/
|
|
773
|
-
get isBusy(): boolean;
|
|
774
|
-
/**
|
|
775
|
-
* Returns true if the component is in an ERROR state.
|
|
776
|
-
* @returns True when in error state.
|
|
777
|
-
*/
|
|
778
|
-
get isError(): boolean;
|
|
779
|
-
/**
|
|
780
|
-
* Logic for disabling primary action buttons (OK, Clear, Cancel).
|
|
781
|
-
* Buttons are disabled if not connected, if no drawing has occurred, or if busy.
|
|
782
|
-
* @returns True if action buttons should be disabled.
|
|
783
|
-
*/
|
|
784
|
-
get actionButtonsDisabled(): boolean;
|
|
785
|
-
/**
|
|
786
|
-
* Logic for disabling the Connect button.
|
|
787
|
-
* @returns True if the connect button should be disabled.
|
|
788
|
-
*/
|
|
789
|
-
get connectButtonDisabled(): boolean;
|
|
790
|
-
/**
|
|
791
|
-
* Logic for disabling the Disconnect button.
|
|
792
|
-
* @returns True if the disconnect button should be disabled.
|
|
793
|
-
*/
|
|
794
|
-
get disconnectButtonDisabled(): boolean;
|
|
795
|
-
/**
|
|
796
|
-
* Transitions the component to a new state and triggers side effects.
|
|
797
|
-
*
|
|
798
|
-
* @param newState - The target SignpadState.
|
|
799
|
-
* @param messageKey - An optional localization key for status messages.
|
|
800
|
-
* @param error - Optional error object if transitioning to an ERROR state.
|
|
801
|
-
* @returns void
|
|
802
|
-
*/
|
|
803
|
-
transitionTo(newState: SignpadState, messageKey?: string, error?: Error): void;
|
|
804
|
-
/**
|
|
805
|
-
* Updates the internal drawing flag. Triggers a UI update if the value changes.
|
|
806
|
-
* @param started - Boolean indicating if the user has started drawing.
|
|
807
|
-
*/
|
|
808
|
-
setDrawingStarted(started: boolean): void;
|
|
809
|
-
/**
|
|
810
|
-
* Handles side effects triggered by state transitions, such as
|
|
811
|
-
* initializing mouse listeners or clearing the canvas.
|
|
812
|
-
* @param newState - The state being transitioned to.
|
|
813
|
-
* @param oldState - The previous state.
|
|
814
|
-
* @private
|
|
815
|
-
*/
|
|
816
|
-
private handleSideEffects;
|
|
817
|
-
}
|
|
434
|
+
export declare type SignpadTheme = "light" | "dark" | "auto";
|
|
818
435
|
|
|
819
436
|
export { }
|
|
820
437
|
|