@danidoble/webserial 4.6.0-beta.1 → 4.6.0-beta.2

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/jsd.js CHANGED
@@ -1,5 +1,5 @@
1
- import { v as M } from "./webserial-core-Bn6Ker2l.js";
2
- import { D as q } from "./devices-CzEcntFZ.js";
1
+ import { v as M } from "./webserial-core-Cc11wk4k.js";
2
+ import { D as q } from "./devices-52jckzh8.js";
3
3
  class N {
4
4
  /**
5
5
  * Byte order configuration
@@ -203,7 +203,7 @@ const c = {
203
203
  LICENSING: 600,
204
204
  MANIFESTS_AND_LOGS: 601,
205
205
  SIMULATOR_VISION: 1e4
206
- }, R = (m) => [I.VISION, I.SIMULATOR_VISION].includes(m), x = (m) => [I.LICENSING].includes(m), B = (m) => [I.MANIFESTS_AND_LOGS].includes(m);
206
+ }, R = (m) => [I.VISION, I.SIMULATOR_VISION].includes(m), x = (m) => [I.LICENSING].includes(m), B = (m) => [I.MANIFESTS_AND_LOGS].includes(m), $ = (m) => [I.PERIFERIC_MDB_CARD].includes(m);
207
207
  class d {
208
208
  transport;
209
209
  static APP_ID = I.VISION;
@@ -675,8 +675,8 @@ class d {
675
675
  typeAdjustElevator: o,
676
676
  timeAdjustElevator: u
677
677
  }) {
678
- const C = `${e},${t},${s},${n},${a},${i},${r ? 1 : 0},${o === "lower" ? 0 : 1},${u}`;
679
- return this.transport.buildPacket(c.dispenseFromChannelExtended, C, d.APP_ID);
678
+ const P = `${e},${t},${s},${n},${a},${i},${r ? 1 : 0},${o === "lower" ? 0 : 1},${u}`;
679
+ return this.transport.buildPacket(c.dispenseFromChannelExtended, P, d.APP_ID);
680
680
  }
681
681
  /**
682
682
  /**
@@ -700,7 +700,7 @@ class d {
700
700
  return this.transport.buildPacket(c.restartingTheJSDKnowingThatItIsDangerous, "", d.APP_ID);
701
701
  }
702
702
  }
703
- function $(m) {
703
+ function j(m) {
704
704
  if (m.length > 5)
705
705
  throw new Error(`Token must be max 5 characters, got ${m.length}`);
706
706
  return m;
@@ -711,7 +711,7 @@ function T() {
711
711
  const e = new Uint8Array(2);
712
712
  m = parseInt(crypto.getRandomValues(e).toString().replaceAll(",", "")).toString(36);
713
713
  } while (m.length > 5);
714
- return $(m);
714
+ return j(m);
715
715
  }
716
716
  const _ = {
717
717
  status: "NO-CONNECTED",
@@ -721,7 +721,7 @@ const _ = {
721
721
  hasLightsOn: !1,
722
722
  temperature: ""
723
723
  };
724
- class j {
724
+ class U {
725
725
  _commands;
726
726
  jsd;
727
727
  APP_ID = I.VISION;
@@ -1364,8 +1364,8 @@ class j {
1364
1364
  },
1365
1365
  reject: () => {
1366
1366
  }
1367
- }, new Promise((C, P) => {
1368
- this._dispensingTokens[h].resolve = C, this._dispensingTokens[h].reject = P;
1367
+ }, new Promise((P, b) => {
1368
+ this._dispensingTokens[h].resolve = P, this._dispensingTokens[h].reject = b;
1369
1369
  });
1370
1370
  }
1371
1371
  /**
@@ -1603,7 +1603,7 @@ class j {
1603
1603
  12: "DISPENSE-CANCELLED",
1604
1604
  13: "PRODUCT-EXPIRED"
1605
1605
  }, r = Object.values(i).filter(
1606
- (P) => [
1606
+ (b) => [
1607
1607
  "NO-PERFORMED",
1608
1608
  "TOKEN-NOT-FOUND",
1609
1609
  "QUEUE-FULL",
@@ -1613,7 +1613,7 @@ class j {
1613
1613
  "DISPENSE-CANCELLED",
1614
1614
  "PRODUCT-EXPIRED",
1615
1615
  "UNCOLLECTED"
1616
- ].includes(P)
1616
+ ].includes(b)
1617
1617
  ), o = {
1618
1618
  0: "NONE",
1619
1619
  1: "DOOR-OPEN",
@@ -1631,7 +1631,7 @@ class j {
1631
1631
  13: "NO-VISION",
1632
1632
  14: "PRODUCT-PERISHABLE-EXPIRED",
1633
1633
  20: "DECIDE"
1634
- }, u = i[parseInt(s, 10)] || "UNKNOWN", [l, h, g] = n && n.trim() !== "" ? n.split(".").map((P) => parseInt(P, 10)) : [null, null, null], C = a ? o[parseInt(a, 10)] || "UNKNOWN" : null;
1634
+ }, u = i[parseInt(s, 10)] || "UNKNOWN", [l, h, g] = n && n.trim() !== "" ? n.split(".").map((b) => parseInt(b, 10)) : [null, null, null], P = a ? o[parseInt(a, 10)] || "UNKNOWN" : null;
1635
1635
  this._dispensingTokens[t] && (this._dispensingTokens[t].cart === !1 && u === "WAITING-COLLECTION" ? (this._dispensingTokens[t].resolve(!0), delete this._dispensingTokens[t], this.emit("waiting-collection", { machine: l !== null ? l + 1 : null })) : this._dispensingTokens[t].cart === !0 && u === "DISPENSED-CAN-MULTIPLE" ? (this._dispensingTokens[t].resolve(!0), delete this._dispensingTokens[t]) : r.includes(u) && (this._dispensingTokens[t].resolve(!1), delete this._dispensingTokens[t])), u === "IN-PROGRESS" && this.emit("dispensing", {
1636
1636
  token: t,
1637
1637
  machine: l !== null ? l + 1 : null,
@@ -1644,7 +1644,7 @@ class j {
1644
1644
  machine: l !== null ? l + 1 : null,
1645
1645
  tray: h !== null ? h : null,
1646
1646
  channel: g !== null ? g : null,
1647
- extendedStatus: C
1647
+ extendedStatus: P
1648
1648
  });
1649
1649
  }
1650
1650
  _responseConfigurationSelectionDispense(e) {
@@ -1899,7 +1899,7 @@ const y = {
1899
1899
  responseLineLogEvent: 201,
1900
1900
  responseManifestDataBlock: 210,
1901
1901
  responseManifestCompleted: 211
1902
- }, U = (m) => Object.keys(y).find((t) => y[t] === m) || "Unknown";
1902
+ }, W = (m) => Object.keys(y).find((t) => y[t] === m) || "Unknown";
1903
1903
  class E {
1904
1904
  transport;
1905
1905
  static APP_ID = I.MANIFESTS_AND_LOGS;
@@ -1947,7 +1947,7 @@ class E {
1947
1947
  return this.transport.buildPacket(y.sendManifestDataBlock, n, E.APP_ID);
1948
1948
  }
1949
1949
  }
1950
- class W {
1950
+ class J {
1951
1951
  _commands;
1952
1952
  jsd;
1953
1953
  APP_ID = I.MANIFESTS_AND_LOGS;
@@ -2053,7 +2053,7 @@ class W {
2053
2053
  this.jsd.dispatch(`manifest:${e}`, ...t);
2054
2054
  }
2055
2055
  _responseCmdWrong(e) {
2056
- const t = parseInt(e.params[0], 10), s = e.params.slice(1), n = U(t);
2056
+ const t = parseInt(e.params[0], 10), s = e.params.slice(1), n = W(t);
2057
2057
  this.emit("wrong-cmd", {
2058
2058
  opcodeName: n,
2059
2059
  opcode: t,
@@ -2109,14 +2109,27 @@ const S = {
2109
2109
  //responseReserved204: 204,
2110
2110
  responseLicensingReport: 205,
2111
2111
  responseJsdIdentification: 206
2112
- }, J = (m) => Object.keys(S).find((t) => S[t] === m) || "Unknown";
2113
- class b {
2112
+ }, K = (m) => Object.keys(S).find((t) => S[t] === m) || "Unknown";
2113
+ class D {
2114
2114
  transport;
2115
2115
  static APP_ID = I.LICENSING;
2116
2116
  // Manifest & Logs Application ID
2117
2117
  constructor(e) {
2118
2118
  this.transport = e;
2119
2119
  }
2120
+ /**
2121
+ * Alias to Opcode 101: Connection command (no data).
2122
+ * @param options Object containing the packetId and transport protocol.
2123
+ * @param options.packetId PacketId for identification
2124
+ * @param options.transport Transport protocol instance to use.
2125
+ * @returns The generated packet as a number array.
2126
+ */
2127
+ static connection({
2128
+ transport: e,
2129
+ packetId: t
2130
+ }) {
2131
+ return e._overridePacketId(t || 255), new D(e).requestTemporaryLicenseStatus();
2132
+ }
2120
2133
  /**
2121
2134
  * Opcode 100: Request feature status.
2122
2135
  * @param feature Feature ID to check.
@@ -2124,21 +2137,21 @@ class b {
2124
2137
  */
2125
2138
  requestFeatureStatus(e) {
2126
2139
  const t = `${e}`;
2127
- return this.transport.buildPacket(S.requestFeatureStatus, t, b.APP_ID);
2140
+ return this.transport.buildPacket(S.requestFeatureStatus, t, D.APP_ID);
2128
2141
  }
2129
2142
  /**
2130
2143
  * Opcode 101: Request temporary license status.
2131
2144
  * @returns The generated packet as a number array.
2132
2145
  */
2133
2146
  requestTemporaryLicenseStatus() {
2134
- return this.transport.buildPacket(S.requestTemporaryLicenseStatus, "", b.APP_ID);
2147
+ return this.transport.buildPacket(S.requestTemporaryLicenseStatus, "", D.APP_ID);
2135
2148
  }
2136
2149
  /**
2137
2150
  * Opcode 102: Request seed data for license generation.
2138
2151
  * @returns The generated packet as a number array.
2139
2152
  */
2140
2153
  requestSeedData() {
2141
- return this.transport.buildPacket(S.requestSeedData, "", b.APP_ID);
2154
+ return this.transport.buildPacket(S.requestSeedData, "", D.APP_ID);
2142
2155
  }
2143
2156
  /**
2144
2157
  * Opcode 110: Request license activation.
@@ -2147,22 +2160,22 @@ class b {
2147
2160
  */
2148
2161
  requestLicenseActivation(e) {
2149
2162
  const t = `${e}`;
2150
- return this.transport.buildPacket(S.requestLicenseActivation, t, b.APP_ID);
2163
+ return this.transport.buildPacket(S.requestLicenseActivation, t, D.APP_ID);
2151
2164
  }
2152
2165
  /**
2153
2166
  * Opcode 104: Request JSD identification information.
2154
2167
  * @returns The generated packet as a number array.
2155
2168
  */
2156
2169
  requestJsdIdentification() {
2157
- return this.transport.buildPacket(S.requestJsdIdentification, "", b.APP_ID);
2170
+ return this.transport.buildPacket(S.requestJsdIdentification, "", D.APP_ID);
2158
2171
  }
2159
2172
  }
2160
- class K {
2173
+ class H {
2161
2174
  _commands;
2162
2175
  jsd;
2163
2176
  APP_ID = I.LICENSING;
2164
2177
  constructor(e, t) {
2165
- this._commands = new b(t), this.jsd = e;
2178
+ this._commands = new D(t), this.jsd = e;
2166
2179
  }
2167
2180
  async send(e, t) {
2168
2181
  return this.jsd._lastApplicationCode = this.APP_ID, this.jsd._toQueue(e, {
@@ -2252,7 +2265,7 @@ class K {
2252
2265
  this.jsd.dispatch(`licensing:${e}`, ...t);
2253
2266
  }
2254
2267
  _responseCmdWrong(e) {
2255
- const t = parseInt(e.params[0], 10), s = e.params.slice(1), n = J(t);
2268
+ const t = parseInt(e.params[0], 10), s = e.params.slice(1), n = K(t);
2256
2269
  this.emit("wrong-cmd", {
2257
2270
  opcodeName: n,
2258
2271
  opcode: t,
@@ -2356,7 +2369,7 @@ const p = {
2356
2369
  jsdErrorLicenseTemporarilyBlocked: 300,
2357
2370
  jsdErrorLicenseNotActive: 301,
2358
2371
  jsdErrorCommandNotExecutable: 302
2359
- }, k = (m) => Object.keys(p).find((t) => p[t] === m) || "Unknown";
2372
+ }, v = (m) => Object.keys(p).find((t) => p[t] === m) || "Unknown";
2360
2373
  class f {
2361
2374
  transport;
2362
2375
  static APP_ID = I.PERIFERIC_MDB_CARD;
@@ -2511,7 +2524,7 @@ class f {
2511
2524
  return this.transport.buildPacket(p.requestRevalue, s, f.APP_ID);
2512
2525
  }
2513
2526
  }
2514
- const D = {
2527
+ const C = {
2515
2528
  1: "inactive",
2516
2529
  2: "disabled",
2517
2530
  3: "enabled",
@@ -2841,7 +2854,7 @@ class Q {
2841
2854
  this.jsd.dispatch(`mdbCardHolder:${e}`, ...t);
2842
2855
  }
2843
2856
  _responseCmdWrong(e) {
2844
- const t = parseInt(e.params[0], 10), s = e.params.slice(1), n = k(t);
2857
+ const t = parseInt(e.params[0], 10), s = e.params.slice(1), n = v(t);
2845
2858
  this.emit("wrong-cmd", {
2846
2859
  opcodeName: n,
2847
2860
  opcode: t,
@@ -2854,7 +2867,7 @@ class Q {
2854
2867
  1: "connected",
2855
2868
  2: "loss of communication"
2856
2869
  }, i = this.config(parseInt(t, 10));
2857
- i.status = D[n], i.connectionStatus = a[s], this.emit("condition-status", {
2870
+ i.status = C[n], i.connectionStatus = a[s], this.emit("condition-status", {
2858
2871
  deviceNumber: parseInt(t, 10),
2859
2872
  connectionStatus: i.connectionStatus,
2860
2873
  cardHolderStatus: i.status
@@ -2906,7 +2919,7 @@ class Q {
2906
2919
  }
2907
2920
  _responseAuthorization(e) {
2908
2921
  const [t, s] = e.params, n = s.split("|"), [a, i] = n[0] === "0" ? [!1, n[1]] : [!0, null], r = parseInt(t, 10);
2909
- i && D[i] && (this.config(r).status = D[i]), this.emit("authorization", {
2922
+ i && C[i] && (this.config(r).status = C[i]), this.emit("authorization", {
2910
2923
  deviceNumber: r,
2911
2924
  success: a,
2912
2925
  reason: i
@@ -2936,11 +2949,11 @@ class Q {
2936
2949
  deviceNumber: i,
2937
2950
  status: a[n[0]]
2938
2951
  };
2939
- n[0] === "0" && n.length > 1 && (r.status = D[n[1]], o.currentCardHolderStatus = r.status), n[0] === "3" && n.length > 1 && (o.amountCharged = parseFloat(n[1])), this.emit("sale-approval", o);
2952
+ n[0] === "0" && n.length > 1 && (r.status = C[n[1]], o.currentCardHolderStatus = r.status), n[0] === "3" && n.length > 1 && (o.amountCharged = parseFloat(n[1])), this.emit("sale-approval", o);
2940
2953
  }
2941
2954
  _responseSaleCancellation(e) {
2942
2955
  const [t, s] = e.params, n = s.split("|"), a = parseInt(t, 10), i = this.config(a);
2943
- n[0] === "0" && n.length > 1 && (i.status = D[n[1]]), this.emit("sale-cancellation", {
2956
+ n[0] === "0" && n.length > 1 && (i.status = C[n[1]]), this.emit("sale-cancellation", {
2944
2957
  deviceNumber: a,
2945
2958
  status: n[0] === "1" ? "success" : "failure",
2946
2959
  currentCardHolderStatus: n.length > 1 ? i.status : null
@@ -2952,7 +2965,7 @@ class Q {
2952
2965
  1: "petition initiated",
2953
2966
  2: "the card has been updated"
2954
2967
  }, i = parseInt(t, 10), r = this.config(i);
2955
- n[0] === "0" && n.length > 1 && (r.status = D[n[1]]), this.emit("sale-success-confirmation", {
2968
+ n[0] === "0" && n.length > 1 && (r.status = C[n[1]]), this.emit("sale-success-confirmation", {
2956
2969
  deviceNumber: i,
2957
2970
  status: a[n[0]],
2958
2971
  currentCardHolderStatus: n.length > 1 ? r.status : null
@@ -2965,7 +2978,7 @@ class Q {
2965
2978
  2: "refund error",
2966
2979
  3: "refund made"
2967
2980
  }, i = parseInt(t, 10), r = this.config(i);
2968
- n[0] === "0" && n.length > 1 && (r.status = D[n[1]]), this.emit("sale-failure-confirmation", {
2981
+ n[0] === "0" && n.length > 1 && (r.status = C[n[1]]), this.emit("sale-failure-confirmation", {
2969
2982
  deviceNumber: i,
2970
2983
  status: a[n[0]],
2971
2984
  currentCardHolderStatus: n.length > 1 ? r.status : null
@@ -2976,7 +2989,7 @@ class Q {
2976
2989
  0: "unable to execute",
2977
2990
  1: "petition initiated"
2978
2991
  }, i = parseInt(t, 10), r = this.config(i);
2979
- n[0] === "0" && n.length > 1 && (r.status = D[n[1]]), this.emit("end-session", {
2992
+ n[0] === "0" && n.length > 1 && (r.status = C[n[1]]), this.emit("end-session", {
2980
2993
  deviceNumber: i,
2981
2994
  status: a[n[0]],
2982
2995
  currentCardHolderStatus: n.length > 1 ? r.status : null
@@ -3015,7 +3028,7 @@ class Q {
3015
3028
  2: "revalue denied",
3016
3029
  3: "revalue approved"
3017
3030
  }, i = parseInt(t, 10), r = this.config(i);
3018
- n[0] === "0" && n.length > 1 && (r.status = D[n[1]]), this.emit("revalue", {
3031
+ n[0] === "0" && n.length > 1 && (r.status = C[n[1]]), this.emit("revalue", {
3019
3032
  deviceNumber: i,
3020
3033
  status: a[n[0]],
3021
3034
  currentCardHolderStatus: n.length > 1 ? r.status : null
@@ -3037,7 +3050,7 @@ class Q {
3037
3050
  this.emit("jsd-license-error", {
3038
3051
  type: "expired-license",
3039
3052
  opcode: parseInt(t, 10),
3040
- actionName: k(parseInt(t, 10)),
3053
+ actionName: v(parseInt(t, 10)),
3041
3054
  params: s
3042
3055
  });
3043
3056
  }
@@ -3046,7 +3059,7 @@ class Q {
3046
3059
  this.emit("jsd-license-error", {
3047
3060
  type: "app-number-not-licensed",
3048
3061
  opcode: parseInt(t, 10),
3049
- actionName: k(parseInt(t, 10)),
3062
+ actionName: v(parseInt(t, 10)),
3050
3063
  params: s
3051
3064
  });
3052
3065
  }
@@ -3055,7 +3068,7 @@ class Q {
3055
3068
  this.emit("jsd-license-error", {
3056
3069
  type: "price-control-active-direct-dispense-not-allowed",
3057
3070
  opcode: parseInt(t, 10),
3058
- actionName: k(parseInt(t, 10)),
3071
+ actionName: v(parseInt(t, 10)),
3059
3072
  params: s
3060
3073
  });
3061
3074
  }
@@ -3100,19 +3113,19 @@ class G {
3100
3113
  return console.warn("Unknown code"), "Unknown code";
3101
3114
  if (i.length < 6)
3102
3115
  return console.error("JConnect header too short"), "JConnect header too short";
3103
- const g = i[0] | i[1] << 8, C = i[2] | i[3] << 8, P = i[4] | i[5] << 8, O = i.slice(6), v = String.fromCharCode(...O);
3116
+ const g = i[0] | i[1] << 8, P = i[2] | i[3] << 8, b = i[4] | i[5] << 8, O = i.slice(6), k = String.fromCharCode(...O);
3104
3117
  return {
3105
3118
  type: "DATA",
3106
- opcode: P,
3107
- appId: C,
3119
+ opcode: b,
3120
+ appId: P,
3108
3121
  noBytes: g,
3109
- params: v ? v.split(",") : [],
3122
+ params: k ? k.split(",") : [],
3110
3123
  id: a,
3111
- rawAscii: v
3124
+ rawAscii: k
3112
3125
  };
3113
3126
  }
3114
3127
  }
3115
- class H {
3128
+ class V {
3116
3129
  delimiter;
3117
3130
  buffer;
3118
3131
  /**
@@ -3163,7 +3176,7 @@ class H {
3163
3176
  this.buffer.length > 0 && (e.enqueue(this.buffer), this.buffer = new Uint8Array(0));
3164
3177
  }
3165
3178
  }
3166
- class Y extends M {
3179
+ class X extends M {
3167
3180
  _transport;
3168
3181
  vision;
3169
3182
  manifest;
@@ -3180,10 +3193,10 @@ class Y extends M {
3180
3193
  socket: n = !1,
3181
3194
  transport: a = "rs232"
3182
3195
  } = {}) {
3183
- const i = new Uint8Array([192]), r = () => new TransformStream(new H(i));
3196
+ const i = new Uint8Array([192]), r = () => new TransformStream(new V(i));
3184
3197
  if (super({ filters: e, config_port: t, no_device: s, socket: n, transformStream: r }), this.__internal__.device.type = "jsd", this.__internal__.time.response_general = 500, this.__internal__.time.response_engines = 500, q.getCustom(this.typeDevice, s))
3185
3198
  throw new Error(`Device ${this.typeDevice} ${s} already exists`);
3186
- q.add(this), this.#t(), this.getResponseAsUint8Array(), this._transport = a === "rs232" ? new w() : new L(), this.vision = new j(this, this._transport), this.manifest = new W(this, this._transport), this.licensing = new K(this, this._transport), this.mdbCardHolder = new Q(this, this._transport), this.#e();
3199
+ q.add(this), this.#t(), this.getResponseAsUint8Array(), this._transport = a === "rs232" ? new w() : new L(), this.vision = new U(this, this._transport), this.manifest = new J(this, this._transport), this.licensing = new H(this, this._transport), this.mdbCardHolder = new Q(this, this._transport), this.#e();
3187
3200
  }
3188
3201
  #e() {
3189
3202
  this.on("serial:connected", async () => {
@@ -3231,6 +3244,25 @@ class Y extends M {
3231
3244
  "vision:extended-dispense-status-data",
3232
3245
  "vision:trays-positioning-phototransistors-status",
3233
3246
  "vision:jsd-license-error",
3247
+ "vision:waiting-collection",
3248
+ "vision:door",
3249
+ "vision:connection",
3250
+ "mdbCardHolder:wrong-cmd",
3251
+ "mdbCardHolder:jsd-license-error",
3252
+ "mdbCardHolder:condition-status",
3253
+ "mdbCardHolder:identification",
3254
+ "mdbCardHolder:configuration-data",
3255
+ "mdbCardHolder:feature-configuration",
3256
+ "mdbCardHolder:authorization",
3257
+ "mdbCardHolder:balance-statement",
3258
+ "mdbCardHolder:sale-approval",
3259
+ "mdbCardHolder:sale-cancellation",
3260
+ "mdbCardHolder:sale-success-confirmation",
3261
+ "mdbCardHolder:sale-failure-confirmation",
3262
+ "mdbCardHolder:end-session",
3263
+ "mdbCardHolder:selection-request",
3264
+ "mdbCardHolder:revalue",
3265
+ "mdbCardHolder:display-message",
3234
3266
  "serial:jsd-error",
3235
3267
  "serial:jsd-ack",
3236
3268
  "serial:jsd-nack",
@@ -3243,7 +3275,7 @@ class Y extends M {
3243
3275
  const e = this._transport ? this._transport : new w();
3244
3276
  let t = 255;
3245
3277
  this._transport && (t = e.packetId, this._transport._overridePacketId(t + 1));
3246
- const { bytes: s } = d.connection({ transport: e, packetId: t });
3278
+ const { bytes: s } = D.connection({ transport: e, packetId: t });
3247
3279
  return s;
3248
3280
  }
3249
3281
  send(e, t) {
@@ -3307,7 +3339,7 @@ class Y extends M {
3307
3339
  else if (s.type === "DATA") {
3308
3340
  this.ack(s.id), typeof s.appId > "u" && (s.appId = this._lastApplicationCode);
3309
3341
  const n = s.appId;
3310
- R(n) && this.vision.serialMessage(s), B(n) && this.manifest.serialMessage(s), x(n) && this.licensing.serialMessage(s), this.dispatch("serial:jsd-data", s);
3342
+ R(n) && this.vision.serialMessage(s), B(n) && this.manifest.serialMessage(s), x(n) && this.licensing.serialMessage(s), $(n) && this.mdbCardHolder.serialMessage(s), this.dispatch("serial:jsd-data", s);
3311
3343
  }
3312
3344
  this.dispatch("serial:message", {
3313
3345
  raw: e,
@@ -3317,5 +3349,5 @@ class Y extends M {
3317
3349
  }
3318
3350
  }
3319
3351
  export {
3320
- Y as JSD
3352
+ X as JSD
3321
3353
  };
@@ -1,5 +1,5 @@
1
- import { D as o } from "./devices-CzEcntFZ.js";
2
- import { v as p } from "./webserial-core-Bn6Ker2l.js";
1
+ import { D as o } from "./devices-52jckzh8.js";
2
+ import { v as p } from "./webserial-core-Cc11wk4k.js";
3
3
  function u(d = 100) {
4
4
  return new Promise((n) => setTimeout(() => n(), d));
5
5
  }
@@ -1 +1 @@
1
- "use strict";const p=require("./devices-Be3Fj7uv.cjs"),u=require("./webserial-core-DizZyWun.cjs");function o(d=100){return new Promise(n=>setTimeout(()=>n(),d))}function b(){return"serial"in navigator}function k(){return"geolocation"in navigator}function g(){return"crypto"in window}function D(d=1){return d*1e3}function w(d){return d==null||d===""}class e{static enable=!1;static instance=null;static#t=null;static#r=1;static#d(){if(e.enable===!1)throw new Error("Emulator is disabled");return e.enable}static#h(n){return e.instance=n,e.#t=n.typeDevice,e.#r=n.deviceNumber,!0}static#n(n=null){return!e.#d()||n===null&&e.instance===null?!1:(e.instance===null&&n!==null&&e.#h(n),!0)}static#l(){if(e.#t!=="locker")throw new Error("This function is only available for Locker devices");return!0}static#i(){if(e.#t!=="boardroid")throw new Error("This function is only available for Boardroid devices");return!0}static#s(){if(e.#t!=="jofemar")throw new Error("This function is only available for Jofemar devices");return!0}static#c(){if(e.#t==="locker")throw new Error("This function is not available for Locker devices");return!0}static#e(n){e.instance!==null&&e.instance.__emulate({code:n})}static status(n=null){if(!e.#n(n))return!1;let s=[];switch(e.#t){case"locker":s=["0","8"];break;case"boardroid":s=["2",(5+e.#r).toString(16).toUpperCase()];break;case"jofemar":s=["6"];break;default:return!1}e.#e(s)}static dispensed(n=null){if(!e.#n(n))return!1;let s=[];switch(e.#t){case"locker":s=["0","7","4","4","4"];break;case"boardroid":s=["2","D7","A","0","0","0","0","0","0","0","0","0","F2"];break;case"jofemar":s=["6","30"];break;default:return!1}e.#e(s)}static notDispensed(n=null){if(!e.#n(n))return!1;let s=[];switch(e.#t){case"locker":s=["0","7","5","5","5"];break;case"boardroid":s=["2","D7","A","0","0","1","0","0","0","0","0","0","F2"];break;case"jofemar":s=["6","34"];break;default:return!1}e.#e(s)}static gateInactive(n=null){if(!e.#n(n)||!this.#l())return!1;this.#e(["0","7","5","5","5"])}static gateConfigured(n=null){if(!e.#n(n)||!this.#l())return!1;this.#e(["0","6"])}static keyPressed(n=null){if(!e.#n(n)||!e.#s())return!1;const s=["30","31","32","33","34","35","36","37","38","39","2A","23","41","42","43","44"],i=(128+e.#r).toString(16),t=Math.floor(Math.random()*15);e.#e(["2",i,"54",s[t]])}static doorOpened(n=null){if(!e.#n(n)||!this.#c())return!1;let s=[];const i=(128+e.#r).toString(16);switch(e.#t){case"boardroid":s=["2","D8","dc"];break;case"jofemar":s=["2",i,"50","4F"];break}e.#e(s)}static doorClosed(n=null){if(!e.#n(n)||!this.#c())return!1;let s=[];const i=(128+e.#r).toString(16);switch(e.#t){case"boardroid":s=["2","D8","db"];break;case"jofemar":s=["2",i,"50","43"];break}e.#e(s)}static channelDisconnected(n=null){if(!e.#n(n)||!e.#s())return!1;const s=(128+e.#r).toString(16);e.#e(["2",s,"43","43","43","FD"])}static channelConnected(n=null){if(!e.#n(n)||!e.#s())return!1;const s=(128+e.#r).toString(16);e.#e(["2",s,"43","43","43","FC"])}static channelEmpty(n=null){if(!e.#n(n)||!e.#s())return!1;const s=(128+e.#r).toString(16);e.#e(["2",s,"43","43","43","FF"])}static workingTemperature(n=null){if(!e.#n(n)||!e.#s())return!1;const s=(128+e.#r).toString(16);e.#e(["2",s,"43","54","16"])}static currentTemperature(n=null){if(!e.#n(n)||!e.#c())return!1;let s=[];const i=(128+e.#r).toString(16);switch(e.#t){case"boardroid":s=["2","D9","44","30"];break;case"jofemar":s=["2",i,"43","74","2B","30","39","2E","31","7F","43"];break}e.#e(s)}static ready(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","30"])}static busy(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","31"])}static invalidTray(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","32"])}static invalidChannel(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","33"])}static emptyChannel(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","34"])}static elevatorJam(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","35"])}static elevatorMalfunction(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","36"])}static phototransistorFailure(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","37"])}static allChannelsEmpty(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","38"])}static productDetectorFailure(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","39"])}static displayDisconnected(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","41"])}static productUnderElevator(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","42"])}static elevatorSettingAlarm(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","43"])}static buttonPanelFailure(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","44"])}static errorWritingEeprom(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","45"])}static errorControlTemperature(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","46"])}static thermometerDisconnected(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","47"])}static thermometerMisconfigured(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","48"])}static thermometerFailure(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","49"])}static errorExtractorConsumption(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","4A"])}static channelSearchError(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","4B"])}static productExitMouthSearchError(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","4C"])}static elevatorInteriorLocked(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","4D"])}static productDetectorVerifierError(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","4E"])}static waitingForProductRecall(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","4F"])}static productExpiredByTemperature(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","50"])}static faultyAutomaticDoor(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","51"])}static rejectLever(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","A0","1"])}static resetCoinPurse(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","A0","2"])}static#f(n,s=null){let i=n[Math.floor(Math.random()*5)];if(s!==null&&!isNaN(parseFloat(s)))switch(s.toString()){case"0.5":i=n[1];break;case"1":i=n[2];break;case"2":i=n[3];break;case"5":i=n[4];break;case"10":i=n[5];break}return i}static coinInsertedBox(n=null,s=null){if(!e.#n(n)||!e.#i())return!1;const i=["40","41","42","43","44","45"],t=e.#f(i,s);e.#e(["2","A0",t])}static coinInsertedTube(n=null,s=null){if(!e.#n(n)||!e.#i())return!1;const i=["50","51","52","53","54","55"],t=e.#f(i,s);e.#e(["2","A0",t])}static#a(n,s=null){let i=n[Math.floor(Math.random()*4)];if(s!==null&&!isNaN(parseFloat(s)))switch(s.toString()){case"20":i=n[0];break;case"50":i=n[1];break;case"100":i=n[2];break;case"200":i=n[3];break;case"500":i=n[4];break}return i}static banknoteInsertedStacker(n=null,s=null){if(!e.#n(n)||!e.#i())return!1;const i=["80","81","82","83","84"],t=e.#a(i,s);e.#e(["2","B0",t])}static banknoteInsertedEscrow(n=null,s=null){if(!e.#n(n)||!e.#i())return!1;const i=["90","91","92","93","94"],t=e.#a(i,s);e.#e(["2","B0",t])}static banknoteEjected(n=null,s=null){if(!e.#n(n)||!e.#i())return!1;const i=["A0","A1","A2","A3","A4"],t=e.#a(i,s);e.#e(["2","B0",t])}static banknoteInsertedRecycler(n=null,s=null){if(!e.#n(n)||!e.#i())return!1;const i=["B0","B1","B2","B3","B4"],t=e.#a(i,s);e.#e(["2","B0",t])}static banknoteTaken(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","B0","2a"])}static coinPurseEnabled(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","D0","1"])}static coinPurseDisabled(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","D0","0"])}static billPurseDisabled(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","D1","0","0"])}static billPurseEnabled(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","D1","1","1"])}static readTubes(n=null){if(!e.#n(n)||!e.#i())return!1;const s=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f"],[i,t,r,a,c,l]=[s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*30)]];e.#e(["2","D2",i,t,r,a,c,l])}static readBillPurse(n=null,s=null){if(!e.#n(n)||!e.#i()||e.instance===null)return!1;const i=e.instance,t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c"];if(i.__banknote_purse.recycler.ict){const r=t[Math.floor(Math.random()*31)];let a="0",c="0",l="0",f="0",h="0";if(s!==null&&!isNaN(parseInt(s)))switch(s.toString()){case"20":a=r;break;case"50":c=r;break;case"100":l=r;break;case"200":f=r;break;case"500":h=r;break}else switch(i.__banknote_purse.recycler.banknote){case 0:a=r;break;case 1:c=r;break;case 2:l=r;break;case 3:f=r;break;case 4:h=r;break}e.#e(["2","D3",a,c,l,f,h,"0"])}else{const[r,a,c,l,f,h]=[t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*2)],t[Math.floor(Math.random())],t[Math.floor(Math.random())]];e.#e(["2","D3",r,a,c,l,f,h])}}static banknoteAccepted(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","D4","1"])}static banknoteRejected(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","D4","0"])}static banknotesDispensed(n=null){if(!e.#n(n)||!e.#i()||e.instance===null)return!1;const s=e.instance,i=["1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c"];if(s.__banknote_purse.recycler.ict){const t=i[Math.floor(Math.random()*30)];let r="0",a="0",c="0",l="0",f="0";switch(s.__banknote_purse.recycler.banknote){case 0:r=t;break;case 1:a=t;break;case 2:c=t;break;case 3:l=t;break;case 4:f=t;break}e.#e(["2","D5",r,a,c,l,f,"0"])}else{const[t,r,a,c,l,f]=[i[Math.floor(Math.random()*30)],i[Math.floor(Math.random()*30)],i[Math.floor(Math.random()*30)],i[Math.floor(Math.random()*2)],i[Math.floor(Math.random())],i[Math.floor(Math.random())]];e.#e(["2","D5",t,r,a,c,l,f])}}static coinsDispensed(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","D6"])}static relayOn(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DA","1"])}static relayOff(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DA","0"])}static nayaxEnabled(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DD","1"])}static nayaxDisabled(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DD","0"])}static nayaxPreCreditAuthorized(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DD","3"])}static nayaxCancelRequest(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DD","4"])}static nayaxSellApproved(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DD","5"])}static nayaxSellDenied(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DD","6"])}static nayaxEndSession(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DD","7"])}static nayaxCancelled(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DD","8"])}static nayaxDispensed(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DD","A","0"])}static nayaxNotDispensed(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DD","A","1"])}static fullTray(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","4F"])}static setConnection(n=null){if(!e.#n(n)||e.instance===null)return!1;e.instance.__internal__.serial.connected=!0}}class y extends u.v{constructor(n={}){super(n),this.__internal__=structuredClone(this.__internal__),this.getResponseAsArrayHex(),this.__internal__.device.door_open=!1,this.__internal__.time.response_engines=2e3,this.__internal__.time.sense=100,this.__internal__.interval.waiting_sense=0,this.__internal__.dispense={must_response:!1,dispensing:!1,status:null,counter:0,limit_counter:20,custom_limit_counter:null,backup_dispense:{}}}get isDoorOpen(){return this.__internal__.device.door_open}get isDispensing(){return this.__internal__.interval.waiting_sense||this.__internal__.dispense.dispensing}async timeout(n,s){await super.timeout(n,s),s==="dispense"&&(this.__internal__.dispense.status="no-response")}internalClearSensing(){this.__internal__.interval.waiting_sense&&clearInterval(this.__internal__.interval.waiting_sense),this.__internal__.interval.waiting_sense=0,this.__internal__.dispense.status=null,this.__internal__.dispense.counter=0,this.__internal__.dispense.dispensing=!1}internalDispensingProcess(){let n=this.__internal__.dispense.limit_counter;return this.__internal__.dispense.custom_limit_counter&&(n=this.__internal__.dispense.custom_limit_counter),n+=Math.ceil(n*.6),this.__internal__.dispense.counter>=n?(this.internalClearSensing(),this.__internal__.dispense.status=!1,this.__internal__.dispense.dispensing=!1,!1):(this.__internal__.dispense.counter=parseFloat((.1+this.__internal__.dispense.counter).toFixed(1)),this.__internal__.dispense.counter%1===0&&this.dispatch("dispensing",{status:this.__internal__.dispense.status,counter:this.__internal__.dispense.counter,limit:n}),null)}async internalDispenseStatus(){return this.__internal__.dispense.must_response&&(await o(this.__internal__.time.response_engines+10),this.__internal__.dispense.status==="no-response")?(this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"no-response"}),{status:!1,error:"no-response"}):(this.__internal__.dispense.status=null,this.__internal__.dispense.dispensing=!0,this.dispatch("internal:dispense:running",{}),new Promise(n=>{this.__internal__.interval.waiting_sense=setInterval(()=>{switch(this.__internal__.dispense.status){case null:this.internalDispensingProcess()===!1&&(this.internalClearSensing(),this.dispatch("not-dispensed",{reason:"timeout"}),n({status:!1,error:"timeout"}));break;case!0:this.internalClearSensing(),this.__internal__.dispense.status=!0,this.dispatch("dispensed",{}),n({status:!0,error:null});break;case!1:this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"no-stock"}),n({status:!1,error:null});break;case"elevator-locked":this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"elevator-locked"}),n({status:!1,error:"elevator-locked"});break;case"no-response":this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"no-response"}),n({status:!1,error:"no-response"});break}},this.__internal__.time.sense)}))}async internalDispense(n){if(this.isDispensing)throw new Error("Another dispensing process is running");if(this.__internal__.dispense.dispensing=!0,!e.enable&&!this.__internal__.serial.connected&&(await this.serialConnect(),!this.__internal__.serial.connected))throw this.__internal__.dispense.dispensing=!1,new Error("Serial device not connected");return this.__internal__.serial.queue.length===0?(await this.appendToQueue(n,"dispense"),await this.internalDispenseStatus()):new Promise(s=>{const i=setInterval(async()=>{if(this.__internal__.serial.queue.length>0)return;clearInterval(i),await this.appendToQueue(n,"dispense");const t=await this.internalDispenseStatus();s(t)},100)})}__emulate(n){if(typeof n.code!="object"){console.error("Invalid data to make an emulation");return}this.__internal__.serial.connected||(this.__internal__.serial.connected=!0,this.dispatch("serial:connected"),p.Devices.instance.dispatch("change"),this.__internal__.interval.reconnection&&(clearInterval(this.__internal__.interval.reconnection),this.__internal__.interval.reconnection=0)),this.__internal__.timeout.until_response&&(clearTimeout(this.__internal__.timeout.until_response),this.__internal__.timeout.until_response=0);const s=[];for(const i in n.code)s.push(n.code[i].toString().padStart(2,"0").toLowerCase());this.serialMessage(s)}set listenOnPort(n){this.listenOnChannel=n}get listenOnPort(){return this.__internal__.device.listen_on_port??1}fixHexArray(n){return n.map(s=>typeof s=="string"?s.padStart(2,"0").toLowerCase():s.toString(16).padStart(2,"0").toLowerCase())}}exports.Emulator=e;exports.Kernel=y;exports.getSeconds=D;exports.isEmpty=w;exports.supportCrypto=g;exports.supportGeolocation=k;exports.supportWebSerial=b;exports.wait=o;
1
+ "use strict";const p=require("./devices-Dr6p2eHd.cjs"),u=require("./webserial-core-CTWEcKYn.cjs");function o(d=100){return new Promise(n=>setTimeout(()=>n(),d))}function b(){return"serial"in navigator}function k(){return"geolocation"in navigator}function g(){return"crypto"in window}function D(d=1){return d*1e3}function w(d){return d==null||d===""}class e{static enable=!1;static instance=null;static#t=null;static#r=1;static#d(){if(e.enable===!1)throw new Error("Emulator is disabled");return e.enable}static#h(n){return e.instance=n,e.#t=n.typeDevice,e.#r=n.deviceNumber,!0}static#n(n=null){return!e.#d()||n===null&&e.instance===null?!1:(e.instance===null&&n!==null&&e.#h(n),!0)}static#l(){if(e.#t!=="locker")throw new Error("This function is only available for Locker devices");return!0}static#i(){if(e.#t!=="boardroid")throw new Error("This function is only available for Boardroid devices");return!0}static#s(){if(e.#t!=="jofemar")throw new Error("This function is only available for Jofemar devices");return!0}static#c(){if(e.#t==="locker")throw new Error("This function is not available for Locker devices");return!0}static#e(n){e.instance!==null&&e.instance.__emulate({code:n})}static status(n=null){if(!e.#n(n))return!1;let s=[];switch(e.#t){case"locker":s=["0","8"];break;case"boardroid":s=["2",(5+e.#r).toString(16).toUpperCase()];break;case"jofemar":s=["6"];break;default:return!1}e.#e(s)}static dispensed(n=null){if(!e.#n(n))return!1;let s=[];switch(e.#t){case"locker":s=["0","7","4","4","4"];break;case"boardroid":s=["2","D7","A","0","0","0","0","0","0","0","0","0","F2"];break;case"jofemar":s=["6","30"];break;default:return!1}e.#e(s)}static notDispensed(n=null){if(!e.#n(n))return!1;let s=[];switch(e.#t){case"locker":s=["0","7","5","5","5"];break;case"boardroid":s=["2","D7","A","0","0","1","0","0","0","0","0","0","F2"];break;case"jofemar":s=["6","34"];break;default:return!1}e.#e(s)}static gateInactive(n=null){if(!e.#n(n)||!this.#l())return!1;this.#e(["0","7","5","5","5"])}static gateConfigured(n=null){if(!e.#n(n)||!this.#l())return!1;this.#e(["0","6"])}static keyPressed(n=null){if(!e.#n(n)||!e.#s())return!1;const s=["30","31","32","33","34","35","36","37","38","39","2A","23","41","42","43","44"],i=(128+e.#r).toString(16),t=Math.floor(Math.random()*15);e.#e(["2",i,"54",s[t]])}static doorOpened(n=null){if(!e.#n(n)||!this.#c())return!1;let s=[];const i=(128+e.#r).toString(16);switch(e.#t){case"boardroid":s=["2","D8","dc"];break;case"jofemar":s=["2",i,"50","4F"];break}e.#e(s)}static doorClosed(n=null){if(!e.#n(n)||!this.#c())return!1;let s=[];const i=(128+e.#r).toString(16);switch(e.#t){case"boardroid":s=["2","D8","db"];break;case"jofemar":s=["2",i,"50","43"];break}e.#e(s)}static channelDisconnected(n=null){if(!e.#n(n)||!e.#s())return!1;const s=(128+e.#r).toString(16);e.#e(["2",s,"43","43","43","FD"])}static channelConnected(n=null){if(!e.#n(n)||!e.#s())return!1;const s=(128+e.#r).toString(16);e.#e(["2",s,"43","43","43","FC"])}static channelEmpty(n=null){if(!e.#n(n)||!e.#s())return!1;const s=(128+e.#r).toString(16);e.#e(["2",s,"43","43","43","FF"])}static workingTemperature(n=null){if(!e.#n(n)||!e.#s())return!1;const s=(128+e.#r).toString(16);e.#e(["2",s,"43","54","16"])}static currentTemperature(n=null){if(!e.#n(n)||!e.#c())return!1;let s=[];const i=(128+e.#r).toString(16);switch(e.#t){case"boardroid":s=["2","D9","44","30"];break;case"jofemar":s=["2",i,"43","74","2B","30","39","2E","31","7F","43"];break}e.#e(s)}static ready(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","30"])}static busy(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","31"])}static invalidTray(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","32"])}static invalidChannel(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","33"])}static emptyChannel(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","34"])}static elevatorJam(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","35"])}static elevatorMalfunction(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","36"])}static phototransistorFailure(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","37"])}static allChannelsEmpty(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","38"])}static productDetectorFailure(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","39"])}static displayDisconnected(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","41"])}static productUnderElevator(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","42"])}static elevatorSettingAlarm(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","43"])}static buttonPanelFailure(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","44"])}static errorWritingEeprom(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","45"])}static errorControlTemperature(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","46"])}static thermometerDisconnected(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","47"])}static thermometerMisconfigured(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","48"])}static thermometerFailure(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","49"])}static errorExtractorConsumption(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","4A"])}static channelSearchError(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","4B"])}static productExitMouthSearchError(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","4C"])}static elevatorInteriorLocked(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","4D"])}static productDetectorVerifierError(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","4E"])}static waitingForProductRecall(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","4F"])}static productExpiredByTemperature(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","50"])}static faultyAutomaticDoor(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","51"])}static rejectLever(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","A0","1"])}static resetCoinPurse(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","A0","2"])}static#f(n,s=null){let i=n[Math.floor(Math.random()*5)];if(s!==null&&!isNaN(parseFloat(s)))switch(s.toString()){case"0.5":i=n[1];break;case"1":i=n[2];break;case"2":i=n[3];break;case"5":i=n[4];break;case"10":i=n[5];break}return i}static coinInsertedBox(n=null,s=null){if(!e.#n(n)||!e.#i())return!1;const i=["40","41","42","43","44","45"],t=e.#f(i,s);e.#e(["2","A0",t])}static coinInsertedTube(n=null,s=null){if(!e.#n(n)||!e.#i())return!1;const i=["50","51","52","53","54","55"],t=e.#f(i,s);e.#e(["2","A0",t])}static#a(n,s=null){let i=n[Math.floor(Math.random()*4)];if(s!==null&&!isNaN(parseFloat(s)))switch(s.toString()){case"20":i=n[0];break;case"50":i=n[1];break;case"100":i=n[2];break;case"200":i=n[3];break;case"500":i=n[4];break}return i}static banknoteInsertedStacker(n=null,s=null){if(!e.#n(n)||!e.#i())return!1;const i=["80","81","82","83","84"],t=e.#a(i,s);e.#e(["2","B0",t])}static banknoteInsertedEscrow(n=null,s=null){if(!e.#n(n)||!e.#i())return!1;const i=["90","91","92","93","94"],t=e.#a(i,s);e.#e(["2","B0",t])}static banknoteEjected(n=null,s=null){if(!e.#n(n)||!e.#i())return!1;const i=["A0","A1","A2","A3","A4"],t=e.#a(i,s);e.#e(["2","B0",t])}static banknoteInsertedRecycler(n=null,s=null){if(!e.#n(n)||!e.#i())return!1;const i=["B0","B1","B2","B3","B4"],t=e.#a(i,s);e.#e(["2","B0",t])}static banknoteTaken(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","B0","2a"])}static coinPurseEnabled(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","D0","1"])}static coinPurseDisabled(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","D0","0"])}static billPurseDisabled(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","D1","0","0"])}static billPurseEnabled(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","D1","1","1"])}static readTubes(n=null){if(!e.#n(n)||!e.#i())return!1;const s=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f"],[i,t,r,a,c,l]=[s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*30)]];e.#e(["2","D2",i,t,r,a,c,l])}static readBillPurse(n=null,s=null){if(!e.#n(n)||!e.#i()||e.instance===null)return!1;const i=e.instance,t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c"];if(i.__banknote_purse.recycler.ict){const r=t[Math.floor(Math.random()*31)];let a="0",c="0",l="0",f="0",h="0";if(s!==null&&!isNaN(parseInt(s)))switch(s.toString()){case"20":a=r;break;case"50":c=r;break;case"100":l=r;break;case"200":f=r;break;case"500":h=r;break}else switch(i.__banknote_purse.recycler.banknote){case 0:a=r;break;case 1:c=r;break;case 2:l=r;break;case 3:f=r;break;case 4:h=r;break}e.#e(["2","D3",a,c,l,f,h,"0"])}else{const[r,a,c,l,f,h]=[t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*2)],t[Math.floor(Math.random())],t[Math.floor(Math.random())]];e.#e(["2","D3",r,a,c,l,f,h])}}static banknoteAccepted(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","D4","1"])}static banknoteRejected(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","D4","0"])}static banknotesDispensed(n=null){if(!e.#n(n)||!e.#i()||e.instance===null)return!1;const s=e.instance,i=["1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c"];if(s.__banknote_purse.recycler.ict){const t=i[Math.floor(Math.random()*30)];let r="0",a="0",c="0",l="0",f="0";switch(s.__banknote_purse.recycler.banknote){case 0:r=t;break;case 1:a=t;break;case 2:c=t;break;case 3:l=t;break;case 4:f=t;break}e.#e(["2","D5",r,a,c,l,f,"0"])}else{const[t,r,a,c,l,f]=[i[Math.floor(Math.random()*30)],i[Math.floor(Math.random()*30)],i[Math.floor(Math.random()*30)],i[Math.floor(Math.random()*2)],i[Math.floor(Math.random())],i[Math.floor(Math.random())]];e.#e(["2","D5",t,r,a,c,l,f])}}static coinsDispensed(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","D6"])}static relayOn(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DA","1"])}static relayOff(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DA","0"])}static nayaxEnabled(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DD","1"])}static nayaxDisabled(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DD","0"])}static nayaxPreCreditAuthorized(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DD","3"])}static nayaxCancelRequest(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DD","4"])}static nayaxSellApproved(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DD","5"])}static nayaxSellDenied(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DD","6"])}static nayaxEndSession(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DD","7"])}static nayaxCancelled(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DD","8"])}static nayaxDispensed(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DD","A","0"])}static nayaxNotDispensed(n=null){if(!e.#n(n)||!e.#i())return!1;e.#e(["2","DD","A","1"])}static fullTray(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","4F"])}static setConnection(n=null){if(!e.#n(n)||e.instance===null)return!1;e.instance.__internal__.serial.connected=!0}}class y extends u.v{constructor(n={}){super(n),this.__internal__=structuredClone(this.__internal__),this.getResponseAsArrayHex(),this.__internal__.device.door_open=!1,this.__internal__.time.response_engines=2e3,this.__internal__.time.sense=100,this.__internal__.interval.waiting_sense=0,this.__internal__.dispense={must_response:!1,dispensing:!1,status:null,counter:0,limit_counter:20,custom_limit_counter:null,backup_dispense:{}}}get isDoorOpen(){return this.__internal__.device.door_open}get isDispensing(){return this.__internal__.interval.waiting_sense||this.__internal__.dispense.dispensing}async timeout(n,s){await super.timeout(n,s),s==="dispense"&&(this.__internal__.dispense.status="no-response")}internalClearSensing(){this.__internal__.interval.waiting_sense&&clearInterval(this.__internal__.interval.waiting_sense),this.__internal__.interval.waiting_sense=0,this.__internal__.dispense.status=null,this.__internal__.dispense.counter=0,this.__internal__.dispense.dispensing=!1}internalDispensingProcess(){let n=this.__internal__.dispense.limit_counter;return this.__internal__.dispense.custom_limit_counter&&(n=this.__internal__.dispense.custom_limit_counter),n+=Math.ceil(n*.6),this.__internal__.dispense.counter>=n?(this.internalClearSensing(),this.__internal__.dispense.status=!1,this.__internal__.dispense.dispensing=!1,!1):(this.__internal__.dispense.counter=parseFloat((.1+this.__internal__.dispense.counter).toFixed(1)),this.__internal__.dispense.counter%1===0&&this.dispatch("dispensing",{status:this.__internal__.dispense.status,counter:this.__internal__.dispense.counter,limit:n}),null)}async internalDispenseStatus(){return this.__internal__.dispense.must_response&&(await o(this.__internal__.time.response_engines+10),this.__internal__.dispense.status==="no-response")?(this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"no-response"}),{status:!1,error:"no-response"}):(this.__internal__.dispense.status=null,this.__internal__.dispense.dispensing=!0,this.dispatch("internal:dispense:running",{}),new Promise(n=>{this.__internal__.interval.waiting_sense=setInterval(()=>{switch(this.__internal__.dispense.status){case null:this.internalDispensingProcess()===!1&&(this.internalClearSensing(),this.dispatch("not-dispensed",{reason:"timeout"}),n({status:!1,error:"timeout"}));break;case!0:this.internalClearSensing(),this.__internal__.dispense.status=!0,this.dispatch("dispensed",{}),n({status:!0,error:null});break;case!1:this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"no-stock"}),n({status:!1,error:null});break;case"elevator-locked":this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"elevator-locked"}),n({status:!1,error:"elevator-locked"});break;case"no-response":this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"no-response"}),n({status:!1,error:"no-response"});break}},this.__internal__.time.sense)}))}async internalDispense(n){if(this.isDispensing)throw new Error("Another dispensing process is running");if(this.__internal__.dispense.dispensing=!0,!e.enable&&!this.__internal__.serial.connected&&(await this.serialConnect(),!this.__internal__.serial.connected))throw this.__internal__.dispense.dispensing=!1,new Error("Serial device not connected");return this.__internal__.serial.queue.length===0?(await this.appendToQueue(n,"dispense"),await this.internalDispenseStatus()):new Promise(s=>{const i=setInterval(async()=>{if(this.__internal__.serial.queue.length>0)return;clearInterval(i),await this.appendToQueue(n,"dispense");const t=await this.internalDispenseStatus();s(t)},100)})}__emulate(n){if(typeof n.code!="object"){console.error("Invalid data to make an emulation");return}this.__internal__.serial.connected||(this.__internal__.serial.connected=!0,this.dispatch("serial:connected"),p.Devices.instance.dispatch("change"),this.__internal__.interval.reconnection&&(clearInterval(this.__internal__.interval.reconnection),this.__internal__.interval.reconnection=0)),this.__internal__.timeout.until_response&&(clearTimeout(this.__internal__.timeout.until_response),this.__internal__.timeout.until_response=0);const s=[];for(const i in n.code)s.push(n.code[i].toString().padStart(2,"0").toLowerCase());this.serialMessage(s)}set listenOnPort(n){this.listenOnChannel=n}get listenOnPort(){return this.__internal__.device.listen_on_port??1}fixHexArray(n){return n.map(s=>typeof s=="string"?s.padStart(2,"0").toLowerCase():s.toString(16).padStart(2,"0").toLowerCase())}}exports.Emulator=e;exports.Kernel=y;exports.getSeconds=D;exports.isEmpty=w;exports.supportCrypto=g;exports.supportGeolocation=k;exports.supportWebSerial=b;exports.wait=o;
package/dist/kernel.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./kernel-BEA0hNWZ.cjs"),r=require("./devices-Be3Fj7uv.cjs"),n=void 0;exports.Kernel=e.Kernel;exports.Devices=r.Devices;exports.version=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./kernel-D5d0fk5q.cjs"),r=require("./devices-Dr6p2eHd.cjs"),n=void 0;exports.Kernel=e.Kernel;exports.Devices=r.Devices;exports.version=n;
package/dist/kernel.js CHANGED
@@ -1,5 +1,5 @@
1
- import { K as n } from "./kernel-ClC2wiQo.js";
2
- import { D as t } from "./devices-CzEcntFZ.js";
1
+ import { K as n } from "./kernel-D-xrX0LR.js";
2
+ import { D as t } from "./devices-52jckzh8.js";
3
3
  const e = void 0;
4
4
  export {
5
5
  t as Devices,
package/dist/locker.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./kernel-BEA0hNWZ.cjs"),a=require("./devices-Be3Fj7uv.cjs"),i=require("./relay-BG7CetDU.cjs");class r extends n.Kernel{#s=!1;#e=0;#t=0;_default_fallback_listen_on_channel=3;constructor({filters:s=null,config_port:e,no_device:t=1,device_listen_on_channel:l=3,socket:h=!1}={}){if(super({filters:s,config_port:e,no_device:t,device_listen_on_channel:l,socket:h}),this.__internal__.device.type="locker",a.Devices.getCustom(this.typeDevice,t))throw new Error(`Device ${this.typeDevice} ${t} already exists`);this.__internal__.time.response_engines=1e3,this.__internal__.dispense.limit_counter=1,a.Devices.add(this),this.#h()}#h(){const s=["percentage:disable","percentage:enable","percentage:open"];for(const e of s)this.serialRegisterAvailableListener(e)}serialMessage(s){s=this.fixHexArray(s);const e={code:s,name:null,description:null,request:null,no_code:0};switch(s[1]){case"08":e.name="Connection with the serial device completed.",e.description="Your connection with the serial device was successfully completed.",e.request="connect",e.no_code=100;break;case"07":switch(s[4]){case"00":e.name="Cell closed.",e.description="The selected cell is closed.",e.request="dispense",e.no_code=1102,this.__internal__.dispense.status=!1,this.dispatch("dispensed",{}),this.#s&&this.#e>=89?(e.finished_test=!0,this.#s=!1,this.#e=0):this.#s&&(e.finished_test=!1);break;case"01":case"04":e.name="Cell open.",e.description="The selected cell was open successfully.",e.request="dispense",e.no_code=102,this.__internal__.dispense.status=!0,this.dispatch("dispensed",{}),this.#s&&this.#e>=89?(e.finished_test=!0,this.#s=!1,this.#e=0):this.#s&&(e.finished_test=!1);break;case"03":e.name="Cell disconnected.",e.description="The selected cell is disconnected or doesn't exist.",e.request="dispense",e.no_code=101,this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{}),this.#s&&this.#e>=89?(e.finished_test=!0,this.#s=!1,this.#e=0):this.#s&&(e.finished_test=!1);break;case"05":e.name="Cell inactive.",e.description="The selected cell is inactive or doesn't exist.",e.request="dispense",e.no_code=104,this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{}),this.#s&&this.#e>=89?(e.finished_test=!0,this.#s=!1,this.#e=0):this.#s&&(e.finished_test=!1);break;default:e.name="Cell unknown.",e.description="Status of the selected cell is unknown.",e.request="dispense",e.status=s[4],e.no_code=404,this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{}),this.#s&&this.#e>=89?(e.finished_test=!0,this.#s=!1,this.#e=0):this.#s&&(e.finished_test=!1);break}break;case"06":e.name="Configuration applied.",e.description="The configuration was successfully applied.",e.request="configure cell",e.no_code=103;break;default:e.request="undefined",e.name="Response unrecognized",e.description="The response of application was received, but dont identify with any of current parameters",e.no_code=400;break}this.dispatch("serial:message",e)}serialSetConnectionConstant(s=3){return i.u.connection({channel:s})}#i(){this.#s=!1,this.#e=0,this.#t=0}#n(s=null){this.#t=Math.round(this.#e*100/80),this.dispatch("percentage:open",{percentage:this.#t,dispensed:s})}#a(){this.#t=Math.round(this.#e*100/80),this.dispatch("percentage:enable",{percentage:this.#t})}#l(){this.#t=Math.round(this.#e*100/80),this.dispatch("percentage:disable",{percentage:this.#t})}async dispense({cell:s=1,status:e=!0}={}){return setTimeout(()=>{e===!0?this.#r():this.#c()},this.__internal__.time.response_engines/2),await this.internalDispense(i.u.openCell({cell:s,channel:this.__internal__.device.listen_on_port||this._default_fallback_listen_on_channel}))}#r(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!0)}#c(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!1)}async status({cell:s=1}={}){return await this.appendToQueue(i.u.statusCell({cell:s,channel:this.__internal__.device.listen_on_port||this._default_fallback_listen_on_channel}),"status")}async lightScan({since:s=0,until:e=10}={}){return await this.appendToQueue(i.u.lightScan({channel:this.__internal__.device.listen_on_port||this._default_fallback_listen_on_channel,since:s,until:e}),"light-scan")}async enable({cell:s=1}={}){return await this.appendToQueue(i.u.enableCell({cell:s,channel:this.__internal__.device.listen_on_port||this._default_fallback_listen_on_channel}),"activate")}async disable({cell:s=1}={}){await this.appendToQueue(i.u.disableCell({cell:s,channel:this.__internal__.device.listen_on_port||this._default_fallback_listen_on_channel}),"disable")}async openAll(){if(this.isDispensing)throw new Error("Another dispensing process is running");this.#i(),this.#s=!0,this.#n();const s=[];for(let e=1;e<=80;e++){const t=await this.dispense({cell:e,status:!0});s.push(t),this.#e=e,this.#n()}this.#e=80,this.#n(s),this.#i()}async enableAll(){this.#i(),this.#s=!0,this.#a();for(let s=1;s<=80;s++)await this.enable({cell:s}),await n.wait(100),this.#e=s,this.#a();this.#e=80,this.#a(),this.#i()}async disableAll(){this.#i(),this.#s=!0,this.#l();for(let s=1;s<=80;s++)await this.disable({cell:s}),await n.wait(100),this.#e=s,this.#l();this.#e=80,this.#l(),this.#i()}}exports.Locker=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./kernel-D5d0fk5q.cjs"),a=require("./devices-Dr6p2eHd.cjs"),i=require("./relay-BG7CetDU.cjs");class r extends n.Kernel{#s=!1;#e=0;#t=0;_default_fallback_listen_on_channel=3;constructor({filters:s=null,config_port:e,no_device:t=1,device_listen_on_channel:l=3,socket:h=!1}={}){if(super({filters:s,config_port:e,no_device:t,device_listen_on_channel:l,socket:h}),this.__internal__.device.type="locker",a.Devices.getCustom(this.typeDevice,t))throw new Error(`Device ${this.typeDevice} ${t} already exists`);this.__internal__.time.response_engines=1e3,this.__internal__.dispense.limit_counter=1,a.Devices.add(this),this.#h()}#h(){const s=["percentage:disable","percentage:enable","percentage:open"];for(const e of s)this.serialRegisterAvailableListener(e)}serialMessage(s){s=this.fixHexArray(s);const e={code:s,name:null,description:null,request:null,no_code:0};switch(s[1]){case"08":e.name="Connection with the serial device completed.",e.description="Your connection with the serial device was successfully completed.",e.request="connect",e.no_code=100;break;case"07":switch(s[4]){case"00":e.name="Cell closed.",e.description="The selected cell is closed.",e.request="dispense",e.no_code=1102,this.__internal__.dispense.status=!1,this.dispatch("dispensed",{}),this.#s&&this.#e>=89?(e.finished_test=!0,this.#s=!1,this.#e=0):this.#s&&(e.finished_test=!1);break;case"01":case"04":e.name="Cell open.",e.description="The selected cell was open successfully.",e.request="dispense",e.no_code=102,this.__internal__.dispense.status=!0,this.dispatch("dispensed",{}),this.#s&&this.#e>=89?(e.finished_test=!0,this.#s=!1,this.#e=0):this.#s&&(e.finished_test=!1);break;case"03":e.name="Cell disconnected.",e.description="The selected cell is disconnected or doesn't exist.",e.request="dispense",e.no_code=101,this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{}),this.#s&&this.#e>=89?(e.finished_test=!0,this.#s=!1,this.#e=0):this.#s&&(e.finished_test=!1);break;case"05":e.name="Cell inactive.",e.description="The selected cell is inactive or doesn't exist.",e.request="dispense",e.no_code=104,this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{}),this.#s&&this.#e>=89?(e.finished_test=!0,this.#s=!1,this.#e=0):this.#s&&(e.finished_test=!1);break;default:e.name="Cell unknown.",e.description="Status of the selected cell is unknown.",e.request="dispense",e.status=s[4],e.no_code=404,this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{}),this.#s&&this.#e>=89?(e.finished_test=!0,this.#s=!1,this.#e=0):this.#s&&(e.finished_test=!1);break}break;case"06":e.name="Configuration applied.",e.description="The configuration was successfully applied.",e.request="configure cell",e.no_code=103;break;default:e.request="undefined",e.name="Response unrecognized",e.description="The response of application was received, but dont identify with any of current parameters",e.no_code=400;break}this.dispatch("serial:message",e)}serialSetConnectionConstant(s=3){return i.u.connection({channel:s})}#i(){this.#s=!1,this.#e=0,this.#t=0}#n(s=null){this.#t=Math.round(this.#e*100/80),this.dispatch("percentage:open",{percentage:this.#t,dispensed:s})}#a(){this.#t=Math.round(this.#e*100/80),this.dispatch("percentage:enable",{percentage:this.#t})}#l(){this.#t=Math.round(this.#e*100/80),this.dispatch("percentage:disable",{percentage:this.#t})}async dispense({cell:s=1,status:e=!0}={}){return setTimeout(()=>{e===!0?this.#r():this.#c()},this.__internal__.time.response_engines/2),await this.internalDispense(i.u.openCell({cell:s,channel:this.__internal__.device.listen_on_port||this._default_fallback_listen_on_channel}))}#r(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!0)}#c(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!1)}async status({cell:s=1}={}){return await this.appendToQueue(i.u.statusCell({cell:s,channel:this.__internal__.device.listen_on_port||this._default_fallback_listen_on_channel}),"status")}async lightScan({since:s=0,until:e=10}={}){return await this.appendToQueue(i.u.lightScan({channel:this.__internal__.device.listen_on_port||this._default_fallback_listen_on_channel,since:s,until:e}),"light-scan")}async enable({cell:s=1}={}){return await this.appendToQueue(i.u.enableCell({cell:s,channel:this.__internal__.device.listen_on_port||this._default_fallback_listen_on_channel}),"activate")}async disable({cell:s=1}={}){await this.appendToQueue(i.u.disableCell({cell:s,channel:this.__internal__.device.listen_on_port||this._default_fallback_listen_on_channel}),"disable")}async openAll(){if(this.isDispensing)throw new Error("Another dispensing process is running");this.#i(),this.#s=!0,this.#n();const s=[];for(let e=1;e<=80;e++){const t=await this.dispense({cell:e,status:!0});s.push(t),this.#e=e,this.#n()}this.#e=80,this.#n(s),this.#i()}async enableAll(){this.#i(),this.#s=!0,this.#a();for(let s=1;s<=80;s++)await this.enable({cell:s}),await n.wait(100),this.#e=s,this.#a();this.#e=80,this.#a(),this.#i()}async disableAll(){this.#i(),this.#s=!0,this.#l();for(let s=1;s<=80;s++)await this.disable({cell:s}),await n.wait(100),this.#e=s,this.#l();this.#e=80,this.#l(),this.#i()}}exports.Locker=r;
package/dist/locker.js CHANGED
@@ -1,5 +1,5 @@
1
- import { K as r, w as n } from "./kernel-ClC2wiQo.js";
2
- import { D as a } from "./devices-CzEcntFZ.js";
1
+ import { K as r, w as n } from "./kernel-D-xrX0LR.js";
2
+ import { D as a } from "./devices-52jckzh8.js";
3
3
  import { u as i } from "./relay-C71zVBZv.js";
4
4
  class p extends r {
5
5
  #s = !1;