@signosoft/signpad-js 0.2.2 → 0.3.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/dist/index.d.ts CHANGED
@@ -14,7 +14,7 @@ declare class ButtonManager {
14
14
  * Finalizes the signature, dispatches SIGN_OK, and returns captured data.
15
15
  * @returns Captured signature payload from the driver.
16
16
  */
17
- handleOk(): Promise<any>;
17
+ handleOk(): Promise<ISignatureConfirmationData | undefined>;
18
18
  /**
19
19
  * Cancels the signature without collecting data, dispatches SIGN_CANCEL.
20
20
  * @returns Resolves when the cancel flow completes.
@@ -105,7 +105,7 @@ declare class CanvasManager {
105
105
  * Prevents signatures from appearing blurry.
106
106
  * @private
107
107
  */
108
- private configureCanvasForDPI;
108
+ configureCanvasForDPI(): void;
109
109
  /**
110
110
  * Applies line caps, joins, and composite operations to the rendering context.
111
111
  * @param options - The style options to apply.
@@ -120,6 +120,7 @@ declare class CanvasManager {
120
120
  declare class ConfigManager {
121
121
  private component;
122
122
  private configEventHandlers;
123
+ private customEventListenerCache;
123
124
  /**
124
125
  * @param component - The host SignosoftSignpad instance.
125
126
  */
@@ -129,10 +130,6 @@ declare class ConfigManager {
129
130
  * @param prevConfig - Optional previous config for diffing.
130
131
  */
131
132
  apply(prevConfig?: SignpadConfig): void;
132
- /**
133
- * Applies custom CSS variables from the config to the host element.
134
- */
135
- applyCssVariables(): void;
136
133
  /**
137
134
  * Returns resolved UI visibility options with defaults applied.
138
135
  * @returns UI visibility options.
@@ -179,14 +176,8 @@ declare class ConnectionManager {
179
176
  private sigLayer;
180
177
  /** @private Debug counter for callback registrations */
181
178
  private debugCallbackRegistrationCount;
182
- /** @private Offscreen canvas used to capture driver input without direct UI interference */
183
- private offscreenDrawingCanvas;
184
179
  /** @private Cached device info from the last successful connect */
185
180
  private cachedDeviceInfo;
186
- /** @private Tracks SignatureLayer initialization state */
187
- private sigLayerInitialized;
188
- /** @private License server endpoint */
189
- private licenseServerUrl;
190
181
  /** @private Timestamp of the last pen event dispatch */
191
182
  private lastPenDispatchTime;
192
183
  /** @private Buffered pen data for throttling */
@@ -267,7 +258,7 @@ declare class ConnectionManager {
267
258
  * Fetches a lease from the license server and initializes the driver.
268
259
  * @returns Resolves when the driver is initialized.
269
260
  */
270
- private initializeTabletWithLicense;
261
+ initWithLease(lease: any): Promise<void>;
271
262
  isFallback(deviceInfo: any | null, isDeviceConnected: boolean, includeDisconnected: boolean): boolean;
272
263
  /**
273
264
  * Normalizes device info to always include deviceName.
@@ -286,7 +277,7 @@ export declare enum DeviceStatusText {
286
277
  }
287
278
 
288
279
  export declare interface IActionHandlers {
289
- handleOk?: () => any | Promise<any>;
280
+ handleOk?: (data?: ISignatureConfirmationData) => any | Promise<any>;
290
281
  handleClear?: () => any | Promise<any>;
291
282
  handleCancel?: () => any | Promise<any>;
292
283
  }
@@ -317,7 +308,7 @@ export declare interface IEventCallbacks {
317
308
  }>) => void;
318
309
  onDisconnect?: (event: CustomEvent<void>) => void;
319
310
  onPen?: (event: CustomEvent<IPenData_2>) => void;
320
- onOk?: (event: CustomEvent<any>) => void;
311
+ onOk?: (event: CustomEvent<ISignatureConfirmationData>) => void;
321
312
  onClear?: (event: CustomEvent<void>) => void;
322
313
  onCancel?: (event: CustomEvent<void>) => void;
323
314
  onError?: (event: CustomEvent<Error>) => void;
@@ -335,7 +326,9 @@ declare type IPenData_2 = {
335
326
  absoluteX?: number;
336
327
  absoluteY?: number;
337
328
  pressure?: number;
338
- timestamp?: number;
329
+ ready?: boolean;
330
+ sequence?: number;
331
+ timestamp?: number | bigint;
339
332
  inContact: boolean;
340
333
  [key: string]: any;
341
334
  };
@@ -345,6 +338,49 @@ export declare interface IPenDataCallback {
345
338
  (penData: IPenData_2): void;
346
339
  }
347
340
 
341
+ export declare interface ISignatureCanvasMeta {
342
+ top?: number;
343
+ left?: number;
344
+ right?: number;
345
+ bottom?: number;
346
+ width?: number;
347
+ height?: number;
348
+ cssWidth?: number;
349
+ cssHeight?: number;
350
+ dpr?: number;
351
+ [key: string]: any;
352
+ }
353
+
354
+ export declare type ISignatureConfirmationData = [
355
+ points: IPenData_2[],
356
+ imageBase64: string,
357
+ metadata: ISignatureResultMeta
358
+ ];
359
+
360
+ export declare interface ISignatureResultMeta {
361
+ canvas?: ISignatureCanvasMeta;
362
+ tablet?: ISignatureTabletMeta;
363
+ [key: string]: any;
364
+ }
365
+
366
+ export declare interface ISignatureTabletMeta {
367
+ name?: string;
368
+ aspectRatio?: number;
369
+ isCanvasStyleTablet?: boolean;
370
+ screenWidth?: number;
371
+ screenHeight?: number;
372
+ drawingArea?: {
373
+ x: number;
374
+ y: number;
375
+ width: number;
376
+ height: number;
377
+ };
378
+ serialNumber?: string | Promise<string>;
379
+ vendorId?: number | null;
380
+ productId?: number | null;
381
+ [key: string]: any;
382
+ }
383
+
348
384
  export declare interface ITranslationSet {
349
385
  [key: string]: string;
350
386
  }
@@ -352,6 +388,7 @@ export declare interface ITranslationSet {
352
388
  export declare interface IUIVisibilityOptions {
353
389
  topBarVisible?: boolean;
354
390
  topBarClearButtonVisible?: boolean;
391
+ topBarConnectButtonVisible?: boolean;
355
392
  bottomBarVisible?: boolean;
356
393
  okButtonVisible?: boolean;
357
394
  clearButtonVisible?: boolean;
@@ -558,6 +595,11 @@ export declare class SignosoftSignpad extends LitElement {
558
595
  localizationManager: LocalizationManager;
559
596
  configManager: ConfigManager;
560
597
  webHIDAPI: any;
598
+ clear: () => Promise<void>;
599
+ ok: () => Promise<ISignatureConfirmationData | undefined>;
600
+ cancel: () => Promise<void>;
601
+ startSigning: (drawingOptions?: IDrawingOptions) => Promise<void>;
602
+ stopSigning: () => Promise<void>;
561
603
  static styles: CSSResult[];
562
604
  /**
563
605
  * Lit lifecycle: Invoked after the element's DOM has been updated the first time.
@@ -601,32 +643,6 @@ export declare class SignosoftSignpad extends LitElement {
601
643
  * @returns A promise that resolves when disconnection is complete.
602
644
  */
603
645
  disconnect(): Promise<void>;
604
- /**
605
- * Clears the signature from both the UI canvas and the physical device screen.
606
- * @returns Resolves when the clear flow completes.
607
- */
608
- clear(): Promise<void>;
609
- /**
610
- * Finalizes the signature session (OK action).
611
- * @returns Captured signature payload from the driver.
612
- */
613
- ok(): Promise<any>;
614
- /**
615
- * Aborts the current signature session (Cancel action).
616
- * @returns Resolves when the cancel flow completes.
617
- */
618
- cancel(): Promise<void>;
619
- /**
620
- * Programmatically starts a new signing session.
621
- * @param drawingOptions - Optional settings for line thickness and color.
622
- * @returns Resolves when the session is ready.
623
- */
624
- startSigning(drawingOptions?: IDrawingOptions): Promise<void>;
625
- /**
626
- * Programmatically stops the current signing session.
627
- * @returns Resolves when the session stops.
628
- */
629
- stopSigning(): Promise<void>;
630
646
  /**
631
647
  * Resets the UI canvas and internal drawing flags.
632
648
  * @returns void
@@ -638,6 +654,12 @@ export declare class SignosoftSignpad extends LitElement {
638
654
  * @returns void
639
655
  */
640
656
  disconnectedCallback(): void;
657
+ /**
658
+ * Keeps canvas internal size in sync with responsive layout changes.
659
+ * @private
660
+ * @returns void
661
+ */
662
+ private handleWindowResize;
641
663
  /**
642
664
  * Attaches WebHID API event listeners for device connection and disconnection.
643
665
  * @private
@@ -674,6 +696,20 @@ export declare class SignosoftSignpad extends LitElement {
674
696
  * @returns void
675
697
  */
676
698
  private initializeMouseManager;
699
+ /**
700
+ * Throttles pen event dispatch to avoid excessive callback pressure.
701
+ * Drawing is still processed for every sample; only event emission is throttled.
702
+ */
703
+ private dispatchPenEventThrottled;
704
+ /**
705
+ * Initializes the driver once a lease is provided via config.
706
+ * Safe to call repeatedly; initialization is performed at most once.
707
+ */
708
+ private initializeFromConfigLeaseIfNeeded;
709
+ private shouldAutoConnect;
710
+ private autoConnectIfConfigured;
711
+ private scheduleAutoConnectRetry;
712
+ private clearAutoConnectQueue;
677
713
  /**
678
714
  * Renders the HTML template for the component.
679
715
  * Uses Lit's html template literal.
@@ -693,14 +729,13 @@ export declare type SignosoftSignpadProps = {
693
729
  };
694
730
 
695
731
  export declare interface SignpadConfig {
696
- licenseKey?: string;
732
+ lease?: {};
697
733
  languageOptions?: ILanguageOptions;
698
734
  autoconnectOptions?: IAutoconnectOptions;
699
735
  uiVisibilityOptions?: IUIVisibilityOptions;
700
- canvasAndDrawigOptions?: IDrawingOptions;
736
+ canvasAndDrawingOptions?: IDrawingOptions;
701
737
  actionHandlers?: IActionHandlers;
702
738
  eventCallbacks?: IEventCallbacks;
703
- customCssVariables?: Record<string, string>;
704
739
  }
705
740
 
706
741
  export declare enum SignpadEventType {