virtual-keypad 4.0.6 → 4.0.7

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/receiver.js +11 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "virtual-keypad",
3
- "version": "4.0.6",
3
+ "version": "4.0.7",
4
4
  "description": "User response at a distance. Simple utility to summon forth a virtual keypad webapp.",
5
5
  "main": "dist/main.js",
6
6
  "directories": {
package/src/receiver.js CHANGED
@@ -6,6 +6,15 @@ import { KeypadPeer } from "./keypadPeer.js";
6
6
  const doNothing = () => undefined;
7
7
 
8
8
  class Receiver extends KeypadPeer {
9
+ /**
10
+ * @param {{alphabet: string[], font:string}} keypadParameters
11
+ * @param {(data) => void} onDataCallback
12
+ * @param {() => void} handshakeCallback
13
+ * @param {() => void} customDisonnectedCallback
14
+ * @param {(connection) => void} customConnectionCallback
15
+ * @param {() => void} customCloseCallback
16
+ * @param {(error) => void} customErrorCallback
17
+ */
9
18
  constructor(keypadParameters, onDataCallback=doNothing, handshakeCallback=doNothing, customDisonnectedCallback=doNothing, customConnectionCallback=doNothing, customCloseCallback=doNothing, customErrorCallback=doNothing) {
10
19
  super({ targetElementId: keypadParameters.targetElementId });
11
20
  keypadParameters = this.#verifyKeypadParameters(keypadParameters);
@@ -15,10 +24,10 @@ class Receiver extends KeypadPeer {
15
24
 
16
25
  this.onData = onDataCallback; // What to do on a button-press
17
26
  this.onHandshake = handshakeCallback; // What to do when the connection is established
18
- this.onConnection = () => {customConnectionCallback(); this.#onPeerConnection()};
27
+ this.onConnection = (connection) => {customConnectionCallback(connection); this.#onPeerConnection(connection)};
19
28
  this.onDisconnected = () => {customDisonnectedCallback(); this.onPeerDisconnected()};
20
29
  this.onClose = () => {customCloseCallback(); this.onPeerClose()};
21
- this.onError = () => {customErrorCallback(); this.onPeerError()};
30
+ this.onError = (err) => {customErrorCallback(err); this.onPeerError(err)};
22
31
 
23
32
  /* Set up callbacks that handle any events related to our peer object. */
24
33
  this.peer.on("open", this.#onPeerOpen); // On creation of Receiver (local) Peer object