@signosoft/signpad-js 0.3.4 → 0.3.6

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 CHANGED
@@ -680,6 +680,8 @@ The complete list of keys that can be translated is maintained in `src/i18n/en.j
680
680
  | `INVALID_LICENSE_KEY` | Invalid license key. |
681
681
  | `READY_TO_CONNECT` | Ready to connect. |
682
682
  | `SIGNPAD_DETECTED` | Signpad detected. Click 'Connect Signpad' to begin. |
683
+ | `READY_TO_SIGN_MOUSE` | Ready to sign. Use your mouse. |
684
+ | `READY_TO_SIGN_PHYSICAL` | Ready to sign. Use the device pen. |
683
685
 
684
686
  If you add any new keys, mirror them in every language file you provide to guarantee they fall back gracefully to English.
685
687
 
@@ -704,6 +706,7 @@ Standard event listeners triggered _after_ specific actions. Useful for observin
704
706
  | Callback | Payload | Description |
705
707
  | :------------- | :----------------------------------------------- | :------------------------------------------------------------------------------------------------- |
706
708
  | `onPen` | `event: CustomEvent<IPenData>` | Dispatched when a device or mouse fallback are in contact with component or signature pad display. |
709
+ | `onConnecting` | `event: CustomEvent<void>` | Dispatched when a device is in loading state. |
707
710
  | `onConnect` | `event: CustomEvent<{ deviceInfo: any }>` | Dispatched when a device or mouse fallback connects. |
708
711
  | `onDisconnect` | `event: CustomEvent<void>` | Dispatched when the hardware connection is closed. |
709
712
  | `onOk` | `event: CustomEvent<ISignatureConfirmationData>` | Dispatched when signature is confirmed. |
@@ -745,7 +748,7 @@ The following methods are available on the component instance to control the sig
745
748
 
746
749
  | Method | Returns | Description |
747
750
  | :--------------- | :------------------------------------------------- | :------------------------------------------------------------------------------- |
748
- | `connect()` | `Promise<boolean>` | Connects device to component |
751
+ | `connect()` | `Promise<void>` | Connects device to component |
749
752
  | `disconnect()` | `Promise<void>` | Disconnects device from component |
750
753
  | `startSigning()` | `Promise<void>` | Initializes a new signing session on the canvas and hardware. |
751
754
  | `stopSigning()` | `Promise<any>` | Low-level session stop that returns the raw driver payload. |
@@ -755,18 +758,15 @@ The following methods are available on the component instance to control the sig
755
758
 
756
759
  ---
757
760
 
758
- #### 📜 `connect(autoConnect = false, allowFallback = false)`
761
+ #### 📜 `connect()`
759
762
 
760
- This is the primary method to start using the Signpad. Because it uses the **WebHID API**, the first time this is called (without `autoConnect`), it must be triggered by a **user gesture** (like a button click) to satisfy browser security requirements.
763
+ This is the primary method to start using the Signpad. Because it uses the **WebHID API**, this must be triggered by a **user gesture** (like a button click) to satisfy browser security requirements.
761
764
 
762
- **Parameters:**
763
-
764
- - **`autoConnect`** (`boolean`): If set to `true`, the browser will attempt to reconnect to a previously paired and authorized device without opening the device selection dialog from WebHID.
765
- - **`allowFallback`** (`boolean`): If `true` and no physical device is found or connected, the component will automatically transition to **Mouse/Touch mode**, allowing the user to sign using their cursor.
765
+ The method first attempts to silently reconnect to a previously authorized device. If that fails, it opens the browser's device selection dialog and, if no physical device is selected, falls back to mouse/touch mode automatically.
766
766
 
767
767
  **Returns:**
768
768
 
769
- - A `Promise<boolean>` that resolves to `true` if either a physical device or a fallback mode was successfully initialized.
769
+ - A `Promise<void>` that resolves once the connection attempt (or fallback) is complete.
770
770
 
771
771
  #### 📜 `disconnect()`
772
772
 
@@ -782,8 +782,8 @@ Safely terminates the communication channel with the signature tablet.
782
782
 
783
783
  #### 💡 Best Practices
784
784
 
785
- - **Initial Connection:** Always call `connect(false, true)` from a click handler the very first time so the user can select their device from the browser list.
786
- - **Auto-Reconnect:** In many workflows, you can call `connect(true, true)`. If the user has already authorized the device in a previous session, it will connect silently.
785
+ - **Initial Connection:** Always call `connect()` from a click handler so the user can select their device from the browser list.
786
+ - **Auto-Reconnect:** Use `autoconnectOptions.autoConnect: true` in the config to silently reconnect to a previously authorized device on startup without a user gesture.
787
787
  - **Cleanup:** It is good practice to call `disconnect()` when the component is being destroyed or the user navigates away from the signing page to free up the USB port.
788
788
 
789
789
  #### 📜 `startSigning(options?: IDrawingOptions)`
package/dist/index.d.ts CHANGED
@@ -338,6 +338,7 @@ export declare interface IEventCallbacks {
338
338
  onConnect?: (event: CustomEvent<{
339
339
  deviceInfo: any;
340
340
  }>) => void;
341
+ onConnecting?: (event: CustomEvent<void>) => void;
341
342
  onDisconnect?: (event: CustomEvent<void>) => void;
342
343
  onPen?: (event: CustomEvent<IPenData_2>) => void;
343
344
  onOk?: (event: CustomEvent<ISignatureConfirmationData>) => void;
@@ -669,9 +670,9 @@ export declare class SignosoftSignpad extends LitElement {
669
670
  * @param allowFallback - If true, enables mouse/touch signing if no device is found.
670
671
  * @returns A promise resolving to true if connection (or fallback) succeeded.
671
672
  */
672
- connect(autoConnect?: boolean, allowFallback?: boolean): Promise<boolean>;
673
+ private connectWith;
673
674
  /**
674
- * Closes the active tablet connection and cleans up the state.
675
+ * Closes the active tablet connection and switches to mouse fallback mode.
675
676
  * @returns A promise that resolves when disconnection is complete.
676
677
  */
677
678
  disconnect(): Promise<void>;
@@ -698,19 +699,18 @@ export declare class SignosoftSignpad extends LitElement {
698
699
  */
699
700
  private handleWindowResize;
700
701
  /**
701
- * Connect button workflow:
702
+ * Runs the full connect flow:
702
703
  * - if currently in mouse fallback, disconnect it first
703
704
  * - then silently reconnect already-authorized HID devices that are plugged in
704
705
  * - otherwise run the interactive physical-device connect flow
705
706
  * - if physical is not available, allow fallback as a secondary attempt
706
707
  */
707
- private connectFromUserAction;
708
+ connect: () => Promise<void>;
708
709
  private prepareForManualConnect;
709
710
  private tryAuthorizedManualConnect;
710
711
  private tryInteractiveManualConnectFallback;
711
712
  /**
712
- * UI disconnect action:
713
- * switches from physical device to mouse fallback without reconnecting the tablet.
713
+ * UI disconnect action: delegates to the public disconnect method.
714
714
  */
715
715
  private handleDisconnectClick;
716
716
  /**
@@ -826,7 +826,8 @@ export declare enum SignpadEventType {
826
826
  SIGN_CANCEL = "sign-cancel",
827
827
  SIGN_ERROR = "sign-error",
828
828
  SIGN_CONNECT = "sign-connect",
829
- SIGN_DISCONNECT = "sign-disconnect"
829
+ SIGN_DISCONNECT = "sign-disconnect",
830
+ SIGN_CONNECTING = "sign-connecting"
830
831
  }
831
832
 
832
833
  export declare enum SignpadMessage {
@@ -847,7 +848,9 @@ export declare enum SignpadMessage {
847
848
  SIGNPAD_DISCONNECTED = "SIGNPAD_DISCONNECTED",
848
849
  INVALID_LICENSE_KEY = "INVALID_LICENSE_KEY",
849
850
  READY_TO_CONNECT = "READY_TO_CONNECT",
850
- SIGNPAD_DETECTED = "SIGNPAD_DETECTED"
851
+ SIGNPAD_DETECTED = "SIGNPAD_DETECTED",
852
+ READY_TO_SIGN_MOUSE = "READY_TO_SIGN_MOUSE",
853
+ READY_TO_SIGN_PHYSICAL = "READY_TO_SIGN_PHYSICAL"
851
854
  }
852
855
 
853
856
  export declare enum SignpadState {