@danidoble/webserial 4.4.0 → 4.4.1

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/pinpad.js CHANGED
@@ -1,4 +1,4 @@
1
- import { K as mi, a as yi, D as le, i as z, b as fe, w as pe } from "./kernel-BnWXOCde.js";
1
+ import { K as mi, a as yi, D as le, i as z, b as fe, w as pe } from "./kernel-xjzKtp5x.js";
2
2
  var bi = "0123456789abcdefghijklmnopqrstuvwxyz";
3
3
  function G(n) {
4
4
  return bi.charAt(n);
@@ -119,7 +119,7 @@ var ct, wi = {
119
119
  }
120
120
  }, ut = 1e13, mt = (
121
121
  /** @class */
122
- function() {
122
+ (function() {
123
123
  function n(t) {
124
124
  this.buf = [+t || 0];
125
125
  }
@@ -148,14 +148,14 @@ var ct, wi = {
148
148
  var t = this.buf;
149
149
  return t.length == 1 ? t[0] : this;
150
150
  }, n;
151
- }()
151
+ })()
152
152
  ), Ke = "…", Si = /^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/, Ti = /^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;
153
153
  function lt(n, t) {
154
154
  return n.length > t && (n = n.substring(0, t) + Ke), n;
155
155
  }
156
156
  var Ht = (
157
157
  /** @class */
158
- function() {
158
+ (function() {
159
159
  function n(t, e) {
160
160
  this.hexDigits = "0123456789ABCDEF", t instanceof n ? (this.enc = t.enc, this.pos = t.pos) : (this.enc = t, this.pos = e);
161
161
  }
@@ -257,10 +257,10 @@ var Ht = (
257
257
  }
258
258
  return a > 0 && (r += ".incomplete"), r;
259
259
  }, n;
260
- }()
260
+ })()
261
261
  ), Ai = (
262
262
  /** @class */
263
- function() {
263
+ (function() {
264
264
  function n(t, e, i, r, s) {
265
265
  if (!(r instanceof me))
266
266
  throw new Error("Invalid tag value.");
@@ -468,10 +468,10 @@ var Ht = (
468
468
  }
469
469
  return new n(i, o, s, r, c);
470
470
  }, n;
471
- }()
471
+ })()
472
472
  ), me = (
473
473
  /** @class */
474
- function() {
474
+ (function() {
475
475
  function n(t) {
476
476
  var e = t.get();
477
477
  if (this.tagClass = e >> 6, this.tagConstructed = (e & 32) !== 0, this.tagNumber = e & 31, this.tagNumber == 31) {
@@ -487,10 +487,10 @@ var Ht = (
487
487
  }, n.prototype.isEOC = function() {
488
488
  return this.tagClass === 0 && this.tagNumber === 0;
489
489
  }, n;
490
- }()
490
+ })()
491
491
  ), Y, Ci = 244837814094590, ye = (Ci & 16777215) == 15715070, N = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997], Ri = (1 << 26) / N[N.length - 1], P = (
492
492
  /** @class */
493
- function() {
493
+ (function() {
494
494
  function n(t, e, i) {
495
495
  t != null && (typeof t == "number" ? this.fromNumber(t, e, i) : e == null && typeof t != "string" ? this.fromString(t, 256) : this.fromString(t, e));
496
496
  }
@@ -1007,10 +1007,10 @@ var Ht = (
1007
1007
  o.length = (t >> 3) + 1, e.nextBytes(o), c > 0 ? o[0] &= (1 << c) - 1 : o[0] = 0, this.fromString(o, 256);
1008
1008
  }
1009
1009
  }, n;
1010
- }()
1010
+ })()
1011
1011
  ), Oi = (
1012
1012
  /** @class */
1013
- function() {
1013
+ (function() {
1014
1014
  function n() {
1015
1015
  }
1016
1016
  return n.prototype.convert = function(t) {
@@ -1022,10 +1022,10 @@ var Ht = (
1022
1022
  }, n.prototype.sqrTo = function(t, e) {
1023
1023
  t.squareTo(e);
1024
1024
  }, n;
1025
- }()
1025
+ })()
1026
1026
  ), be = (
1027
1027
  /** @class */
1028
- function() {
1028
+ (function() {
1029
1029
  function n(t) {
1030
1030
  this.m = t;
1031
1031
  }
@@ -1040,10 +1040,10 @@ var Ht = (
1040
1040
  }, n.prototype.sqrTo = function(t, e) {
1041
1041
  t.squareTo(e), this.reduce(e);
1042
1042
  }, n;
1043
- }()
1043
+ })()
1044
1044
  ), Pe = (
1045
1045
  /** @class */
1046
- function() {
1046
+ (function() {
1047
1047
  function n(t) {
1048
1048
  this.m = t, this.mp = t.invDigit(), this.mpl = this.mp & 32767, this.mph = this.mp >> 15, this.um = (1 << t.DB - 15) - 1, this.mt2 = 2 * t.t;
1049
1049
  }
@@ -1067,10 +1067,10 @@ var Ht = (
1067
1067
  }, n.prototype.sqrTo = function(t, e) {
1068
1068
  t.squareTo(e), this.reduce(e);
1069
1069
  }, n;
1070
- }()
1070
+ })()
1071
1071
  ), Di = (
1072
1072
  /** @class */
1073
- function() {
1073
+ (function() {
1074
1074
  function n(t) {
1075
1075
  this.m = t, this.r2 = E(), this.q3 = E(), P.ONE.dlShiftTo(2 * t.t, this.r2), this.mu = this.r2.divide(t);
1076
1076
  }
@@ -1093,7 +1093,7 @@ var Ht = (
1093
1093
  }, n.prototype.sqrTo = function(t, e) {
1094
1094
  t.squareTo(e), this.reduce(e);
1095
1095
  }, n;
1096
- }()
1096
+ })()
1097
1097
  );
1098
1098
  function E() {
1099
1099
  return new P(null);
@@ -1124,10 +1124,10 @@ ve && ye && navigator.appName == "Microsoft Internet Explorer" ? (P.prototype.am
1124
1124
  P.prototype.DB = Y;
1125
1125
  P.prototype.DM = (1 << Y) - 1;
1126
1126
  P.prototype.DV = 1 << Y;
1127
- var ne = 52;
1128
- P.prototype.FV = Math.pow(2, ne);
1129
- P.prototype.F1 = ne - Y;
1130
- P.prototype.F2 = 2 * Y - ne;
1127
+ var ie = 52;
1128
+ P.prototype.FV = Math.pow(2, ie);
1129
+ P.prototype.F1 = ie - Y;
1130
+ P.prototype.F2 = 2 * Y - ie;
1131
1131
  var Lt = [], pt, k;
1132
1132
  pt = 48;
1133
1133
  for (k = 0; k <= 9; ++k)
@@ -1154,7 +1154,7 @@ P.ZERO = Q(0);
1154
1154
  P.ONE = Q(1);
1155
1155
  var Ii = (
1156
1156
  /** @class */
1157
- function() {
1157
+ (function() {
1158
1158
  function n() {
1159
1159
  this.i = 0, this.j = 0, this.S = [];
1160
1160
  }
@@ -1169,7 +1169,7 @@ var Ii = (
1169
1169
  var t;
1170
1170
  return this.i = this.i + 1 & 255, this.j = this.j + this.S[this.i] & 255, t = this.S[this.i], this.S[this.i] = this.S[this.j], this.S[this.j] = t, this.S[t + this.S[this.i] & 255];
1171
1171
  }, n;
1172
- }()
1172
+ })()
1173
1173
  );
1174
1174
  function Bi() {
1175
1175
  return new Ii();
@@ -1210,14 +1210,14 @@ function Ni() {
1210
1210
  }
1211
1211
  var Vt = (
1212
1212
  /** @class */
1213
- function() {
1213
+ (function() {
1214
1214
  function n() {
1215
1215
  }
1216
1216
  return n.prototype.nextBytes = function(t) {
1217
1217
  for (var e = 0; e < t.length; ++e)
1218
1218
  t[e] = Ni();
1219
1219
  }, n;
1220
- }()
1220
+ })()
1221
1221
  );
1222
1222
  function Qt(n) {
1223
1223
  return Vi(Ki(xi(n), n.length * 8));
@@ -1332,7 +1332,7 @@ function zi(n, t) {
1332
1332
  }
1333
1333
  var Gi = (
1334
1334
  /** @class */
1335
- function() {
1335
+ (function() {
1336
1336
  function n() {
1337
1337
  this.n = null, this.e = 0, this.d = null, this.p = null, this.q = null, this.dmp1 = null, this.dmq1 = null, this.coeff = null;
1338
1338
  }
@@ -1428,7 +1428,7 @@ var Gi = (
1428
1428
  var a = s.toString(16).replace(/^1f+00/, ""), o = Qi(a);
1429
1429
  return o == i(t).toString();
1430
1430
  }, n;
1431
- }()
1431
+ })()
1432
1432
  );
1433
1433
  function $i(n, t) {
1434
1434
  for (var e = n.toByteArray(), i = 0; i < e.length && e[i] == 0; )
@@ -1859,7 +1859,7 @@ p.asn1.DERTaggedObject = function(n) {
1859
1859
  }, typeof n < "u" && (typeof n.tag < "u" && (this.hT = n.tag), typeof n.explicit < "u" && (this.isExplicit = n.explicit), typeof n.obj < "u" && (this.asn1Object = n.obj, this.setASN1Object(this.isExplicit, this.hT, this.asn1Object)));
1860
1860
  };
1861
1861
  R(p.asn1.DERTaggedObject, p.asn1.ASN1Object);
1862
- var Zi = /* @__PURE__ */ function() {
1862
+ var Zi = /* @__PURE__ */ (function() {
1863
1863
  var n = function(t, e) {
1864
1864
  return n = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(i, r) {
1865
1865
  i.__proto__ = r;
@@ -1876,9 +1876,9 @@ var Zi = /* @__PURE__ */ function() {
1876
1876
  }
1877
1877
  t.prototype = e === null ? Object.create(e) : (i.prototype = e.prototype, new i());
1878
1878
  };
1879
- }(), Te = (
1879
+ })(), Te = (
1880
1880
  /** @class */
1881
- function(n) {
1881
+ (function(n) {
1882
1882
  Zi(t, n);
1883
1883
  function t(e) {
1884
1884
  var i = n.call(this) || this;
@@ -1974,10 +1974,10 @@ var Zi = /* @__PURE__ */ function() {
1974
1974
  }, t.prototype.parsePropertiesFrom = function(e) {
1975
1975
  this.n = e.n, this.e = e.e, e.hasOwnProperty("d") && (this.d = e.d, this.p = e.p, this.q = e.q, this.dmp1 = e.dmp1, this.dmq1 = e.dmq1, this.coeff = e.coeff);
1976
1976
  }, t;
1977
- }(Gi)
1977
+ })(Gi)
1978
1978
  ), Xt, Yi = typeof process < "u" ? (Xt = process.env) === null || Xt === void 0 ? void 0 : Xt.npm_package_version : void 0, tn = (
1979
1979
  /** @class */
1980
- function() {
1980
+ (function() {
1981
1981
  function n(t) {
1982
1982
  t === void 0 && (t = {}), this.default_key_size = t.default_key_size ? parseInt(t.default_key_size, 10) : 1024, this.default_public_exponent = t.default_public_exponent || "010001", this.log = t.log || !1, this.key = t.key || null;
1983
1983
  }
@@ -2049,14 +2049,14 @@ var Zi = /* @__PURE__ */ function() {
2049
2049
  }, n.prototype.getPublicKeyB64 = function() {
2050
2050
  return this.getKey().getPublicBaseKeyB64();
2051
2051
  }, n.version = Yi, n;
2052
- }()
2052
+ })()
2053
2053
  );
2054
2054
  function Xe(n, t) {
2055
2055
  return function() {
2056
2056
  return n.apply(t, arguments);
2057
2057
  };
2058
2058
  }
2059
- const { toString: en } = Object.prototype, { getPrototypeOf: re } = Object, { iterator: Mt, toStringTag: ze } = Symbol, kt = /* @__PURE__ */ ((n) => (t) => {
2059
+ const { toString: en } = Object.prototype, { getPrototypeOf: ne } = Object, { iterator: Mt, toStringTag: ze } = Symbol, kt = /* @__PURE__ */ ((n) => (t) => {
2060
2060
  const e = en.call(t);
2061
2061
  return n[e] || (n[e] = e.slice(8, -1).toLowerCase());
2062
2062
  })(/* @__PURE__ */ Object.create(null)), j = (n) => (n = n.toLowerCase(), (t) => kt(t) === n), Ft = (n) => (t) => typeof t === n, { isArray: dt } = Array, ft = Ft("undefined");
@@ -2071,7 +2071,7 @@ function nn(n) {
2071
2071
  const rn = Ft("string"), U = Ft("function"), $e = Ft("number"), Pt = (n) => n !== null && typeof n == "object", sn = (n) => n === !0 || n === !1, Bt = (n) => {
2072
2072
  if (kt(n) !== "object")
2073
2073
  return !1;
2074
- const t = re(n);
2074
+ const t = ne(n);
2075
2075
  return (t === null || t === Object.prototype || Object.getPrototypeOf(t) === null) && !(ze in n) && !(Mt in n);
2076
2076
  }, an = (n) => {
2077
2077
  if (!Pt(n) || bt(n))
@@ -2136,7 +2136,7 @@ const bn = (n, t, e, { allOwnKeys: i } = {}) => (vt(t, (r, s) => {
2136
2136
  do {
2137
2137
  for (r = Object.getOwnPropertyNames(n), s = r.length; s-- > 0; )
2138
2138
  a = r[s], (!i || i(a, n, t)) && !o[a] && (t[a] = n[a], o[a] = !0);
2139
- n = e !== !1 && re(n);
2139
+ n = e !== !1 && ne(n);
2140
2140
  } while (n && (!e || e(n, t)) && n !== Object.prototype);
2141
2141
  return t;
2142
2142
  }, wn = (n, t, e) => {
@@ -2152,7 +2152,7 @@ const bn = (n, t, e, { allOwnKeys: i } = {}) => (vt(t, (r, s) => {
2152
2152
  for (; t-- > 0; )
2153
2153
  e[t] = n[t];
2154
2154
  return e;
2155
- }, Tn = /* @__PURE__ */ ((n) => (t) => n && t instanceof n)(typeof Uint8Array < "u" && re(Uint8Array)), An = (n, t) => {
2155
+ }, Tn = /* @__PURE__ */ ((n) => (t) => n && t instanceof n)(typeof Uint8Array < "u" && ne(Uint8Array)), An = (n, t) => {
2156
2156
  const i = (n && n[Mt]).call(n);
2157
2157
  let r;
2158
2158
  for (; (r = i.next()) && !r.done; ) {
@@ -2436,10 +2436,10 @@ function Re(n) {
2436
2436
  return t[i];
2437
2437
  });
2438
2438
  }
2439
- function se(n, t) {
2439
+ function re(n, t) {
2440
2440
  this._pairs = [], n && jt(n, this, t);
2441
2441
  }
2442
- const ni = se.prototype;
2442
+ const ni = re.prototype;
2443
2443
  ni.append = function(t, e) {
2444
2444
  this._pairs.push([t, e]);
2445
2445
  };
@@ -2463,7 +2463,7 @@ function ri(n, t, e) {
2463
2463
  });
2464
2464
  const r = e && e.serialize;
2465
2465
  let s;
2466
- if (r ? s = r(t, e) : s = l.isURLSearchParams(t) ? t.toString() : new se(t, e).toString(i), s) {
2466
+ if (r ? s = r(t, e) : s = l.isURLSearchParams(t) ? t.toString() : new re(t, e).toString(i), s) {
2467
2467
  const a = n.indexOf("#");
2468
2468
  a !== -1 && (n = n.slice(0, a)), n += (n.indexOf("?") === -1 ? "?" : "&") + s;
2469
2469
  }
@@ -2494,7 +2494,7 @@ class Oe {
2494
2494
  *
2495
2495
  * @param {Number} id The ID that was returned by `use`
2496
2496
  *
2497
- * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
2497
+ * @returns {void}
2498
2498
  */
2499
2499
  eject(t) {
2500
2500
  this.handlers[t] && (this.handlers[t] = null);
@@ -2527,7 +2527,7 @@ const si = {
2527
2527
  silentJSONParsing: !0,
2528
2528
  forcedJSONParsing: !0,
2529
2529
  clarifyTimeoutError: !1
2530
- }, Wn = typeof URLSearchParams < "u" ? URLSearchParams : se, Xn = typeof FormData < "u" ? FormData : null, zn = typeof Blob < "u" ? Blob : null, Gn = {
2530
+ }, Wn = typeof URLSearchParams < "u" ? URLSearchParams : re, Xn = typeof FormData < "u" ? FormData : null, zn = typeof Blob < "u" ? Blob : null, Gn = {
2531
2531
  isBrowser: !0,
2532
2532
  classes: {
2533
2533
  URLSearchParams: Wn,
@@ -2535,10 +2535,10 @@ const si = {
2535
2535
  Blob: zn
2536
2536
  },
2537
2537
  protocols: ["http", "https", "file", "blob", "url", "data"]
2538
- }, ae = typeof window < "u" && typeof document < "u", te = typeof navigator == "object" && navigator || void 0, $n = ae && (!te || ["ReactNative", "NativeScript", "NS"].indexOf(te.product) < 0), Jn = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef
2539
- self instanceof WorkerGlobalScope && typeof self.importScripts == "function", Qn = ae && window.location.href || "http://localhost", Zn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2538
+ }, se = typeof window < "u" && typeof document < "u", te = typeof navigator == "object" && navigator || void 0, $n = se && (!te || ["ReactNative", "NativeScript", "NS"].indexOf(te.product) < 0), Jn = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef
2539
+ self instanceof WorkerGlobalScope && typeof self.importScripts == "function", Qn = se && window.location.href || "http://localhost", Zn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2540
2540
  __proto__: null,
2541
- hasBrowserEnv: ae,
2541
+ hasBrowserEnv: se,
2542
2542
  hasStandardBrowserEnv: $n,
2543
2543
  hasStandardBrowserWebWorkerEnv: Jn,
2544
2544
  navigator: te,
@@ -2952,16 +2952,18 @@ const Ut = (n, t, e = 3) => {
2952
2952
  ) : () => !0, pr = B.hasStandardBrowserEnv ? (
2953
2953
  // Standard browser envs support document.cookie
2954
2954
  {
2955
- write(n, t, e, i, r, s) {
2956
- const a = [n + "=" + encodeURIComponent(t)];
2957
- l.isNumber(e) && a.push("expires=" + new Date(e).toGMTString()), l.isString(i) && a.push("path=" + i), l.isString(r) && a.push("domain=" + r), s === !0 && a.push("secure"), document.cookie = a.join("; ");
2955
+ write(n, t, e, i, r, s, a) {
2956
+ if (typeof document > "u") return;
2957
+ const o = [`${n}=${encodeURIComponent(t)}`];
2958
+ l.isNumber(e) && o.push(`expires=${new Date(e).toUTCString()}`), l.isString(i) && o.push(`path=${i}`), l.isString(r) && o.push(`domain=${r}`), s === !0 && o.push("secure"), l.isString(a) && o.push(`SameSite=${a}`), document.cookie = o.join("; ");
2958
2959
  },
2959
2960
  read(n) {
2960
- const t = document.cookie.match(new RegExp("(^|;\\s*)(" + n + ")=([^;]*)"));
2961
- return t ? decodeURIComponent(t[3]) : null;
2961
+ if (typeof document > "u") return null;
2962
+ const t = document.cookie.match(new RegExp("(?:^|; )" + n + "=([^;]*)"));
2963
+ return t ? decodeURIComponent(t[1]) : null;
2962
2964
  },
2963
2965
  remove(n) {
2964
- this.write(n, "", Date.now() - 864e5);
2966
+ this.write(n, "", Date.now() - 864e5, "/");
2965
2967
  }
2966
2968
  }
2967
2969
  ) : (
@@ -3355,7 +3357,7 @@ const hi = (n) => {
3355
3357
  }
3356
3358
  };
3357
3359
  }, Sr = /* @__PURE__ */ new Map(), li = (n) => {
3358
- let t = n ? n.env : {};
3360
+ let t = n && n.env || {};
3359
3361
  const { fetch: e, Request: i, Response: r } = t, s = [
3360
3362
  i,
3361
3363
  r,
@@ -3367,14 +3369,14 @@ const hi = (n) => {
3367
3369
  return h;
3368
3370
  };
3369
3371
  li();
3370
- const ee = {
3372
+ const ae = {
3371
3373
  http: jn,
3372
3374
  xhr: mr,
3373
3375
  fetch: {
3374
3376
  get: li
3375
3377
  }
3376
3378
  };
3377
- l.forEach(ee, (n, t) => {
3379
+ l.forEach(ae, (n, t) => {
3378
3380
  if (n) {
3379
3381
  try {
3380
3382
  Object.defineProperty(n, "name", { value: t });
@@ -3383,36 +3385,46 @@ l.forEach(ee, (n, t) => {
3383
3385
  Object.defineProperty(n, "adapterName", { value: t });
3384
3386
  }
3385
3387
  });
3386
- const ke = (n) => `- ${n}`, Tr = (n) => l.isFunction(n) || n === null || n === !1, fi = {
3387
- getAdapter: (n, t) => {
3388
- n = l.isArray(n) ? n : [n];
3389
- const { length: e } = n;
3390
- let i, r;
3391
- const s = {};
3392
- for (let a = 0; a < e; a++) {
3393
- i = n[a];
3394
- let o;
3395
- if (r = i, !Tr(i) && (r = ee[(o = String(i)).toLowerCase()], r === void 0))
3396
- throw new v(`Unknown adapter '${o}'`);
3397
- if (r && (l.isFunction(r) || (r = r.get(t))))
3398
- break;
3399
- s[o || "#" + a] = r;
3400
- }
3401
- if (!r) {
3402
- const a = Object.entries(s).map(
3403
- ([c, h]) => `adapter ${c} ` + (h === !1 ? "is not supported by the environment" : "is not available in the build")
3404
- );
3405
- let o = e ? a.length > 1 ? `since :
3388
+ const ke = (n) => `- ${n}`, Tr = (n) => l.isFunction(n) || n === null || n === !1;
3389
+ function Ar(n, t) {
3390
+ n = l.isArray(n) ? n : [n];
3391
+ const { length: e } = n;
3392
+ let i, r;
3393
+ const s = {};
3394
+ for (let a = 0; a < e; a++) {
3395
+ i = n[a];
3396
+ let o;
3397
+ if (r = i, !Tr(i) && (r = ae[(o = String(i)).toLowerCase()], r === void 0))
3398
+ throw new v(`Unknown adapter '${o}'`);
3399
+ if (r && (l.isFunction(r) || (r = r.get(t))))
3400
+ break;
3401
+ s[o || "#" + a] = r;
3402
+ }
3403
+ if (!r) {
3404
+ const a = Object.entries(s).map(
3405
+ ([c, h]) => `adapter ${c} ` + (h === !1 ? "is not supported by the environment" : "is not available in the build")
3406
+ );
3407
+ let o = e ? a.length > 1 ? `since :
3406
3408
  ` + a.map(ke).join(`
3407
3409
  `) : " " + ke(a[0]) : "as no adapter specified";
3408
- throw new v(
3409
- "There is no suitable adapter to dispatch the request " + o,
3410
- "ERR_NOT_SUPPORT"
3411
- );
3412
- }
3413
- return r;
3414
- },
3415
- adapters: ee
3410
+ throw new v(
3411
+ "There is no suitable adapter to dispatch the request " + o,
3412
+ "ERR_NOT_SUPPORT"
3413
+ );
3414
+ }
3415
+ return r;
3416
+ }
3417
+ const fi = {
3418
+ /**
3419
+ * Resolve an adapter from a list of adapter names or functions.
3420
+ * @type {Function}
3421
+ */
3422
+ getAdapter: Ar,
3423
+ /**
3424
+ * Exposes all known adapters
3425
+ * @type {Object<string, Function|Object>}
3426
+ */
3427
+ adapters: ae
3416
3428
  };
3417
3429
  function $t(n) {
3418
3430
  if (n.cancelToken && n.cancelToken.throwIfRequested(), n.signal && n.signal.aborted)
@@ -3436,7 +3448,7 @@ function Fe(n) {
3436
3448
  ), i.response.headers = L.from(i.response.headers))), Promise.reject(i);
3437
3449
  });
3438
3450
  }
3439
- const pi = "1.12.2", qt = {};
3451
+ const pi = "1.13.1", qt = {};
3440
3452
  ["object", "boolean", "number", "function", "string", "symbol"].forEach((n, t) => {
3441
3453
  qt[n] = function(i) {
3442
3454
  return typeof i === n || "a" + (t < 1 ? "n " : " ") + n;
@@ -3464,7 +3476,7 @@ qt.transitional = function(t, e, i) {
3464
3476
  qt.spelling = function(t) {
3465
3477
  return (e, i) => (console.warn(`${i} is likely a misspelling of ${t}`), !0);
3466
3478
  };
3467
- function Ar(n, t, e) {
3479
+ function Cr(n, t, e) {
3468
3480
  if (typeof n != "object")
3469
3481
  throw new v("options must be an object", v.ERR_BAD_OPTION_VALUE);
3470
3482
  const i = Object.keys(n);
@@ -3482,7 +3494,7 @@ function Ar(n, t, e) {
3482
3494
  }
3483
3495
  }
3484
3496
  const xt = {
3485
- assertOptions: Ar,
3497
+ assertOptions: Cr,
3486
3498
  validators: qt
3487
3499
  }, H = xt.validators;
3488
3500
  let nt = class {
@@ -3609,7 +3621,7 @@ l.forEach(["post", "put", "patch"], function(t) {
3609
3621
  }
3610
3622
  nt.prototype[t] = e(), nt.prototype[t + "Form"] = e(!0);
3611
3623
  });
3612
- let Cr = class di {
3624
+ let Rr = class di {
3613
3625
  constructor(t) {
3614
3626
  if (typeof t != "function")
3615
3627
  throw new TypeError("executor must be a function.");
@@ -3682,15 +3694,15 @@ let Cr = class di {
3682
3694
  };
3683
3695
  }
3684
3696
  };
3685
- function Rr(n) {
3697
+ function Or(n) {
3686
3698
  return function(e) {
3687
3699
  return n.apply(null, e);
3688
3700
  };
3689
3701
  }
3690
- function Or(n) {
3702
+ function Dr(n) {
3691
3703
  return l.isObject(n) && n.isAxiosError === !0;
3692
3704
  }
3693
- const ie = {
3705
+ const ee = {
3694
3706
  Continue: 100,
3695
3707
  SwitchingProtocols: 101,
3696
3708
  Processing: 102,
@@ -3753,10 +3765,16 @@ const ie = {
3753
3765
  InsufficientStorage: 507,
3754
3766
  LoopDetected: 508,
3755
3767
  NotExtended: 510,
3756
- NetworkAuthenticationRequired: 511
3768
+ NetworkAuthenticationRequired: 511,
3769
+ WebServerIsDown: 521,
3770
+ ConnectionTimedOut: 522,
3771
+ OriginIsUnreachable: 523,
3772
+ TimeoutOccurred: 524,
3773
+ SslHandshakeFailed: 525,
3774
+ InvalidSslCertificate: 526
3757
3775
  };
3758
- Object.entries(ie).forEach(([n, t]) => {
3759
- ie[t] = n;
3776
+ Object.entries(ee).forEach(([n, t]) => {
3777
+ ee[t] = n;
3760
3778
  });
3761
3779
  function _i(n) {
3762
3780
  const t = new nt(n), e = Xe(nt.prototype.request, t);
@@ -3767,7 +3785,7 @@ function _i(n) {
3767
3785
  const S = _i(Et);
3768
3786
  S.Axios = nt;
3769
3787
  S.CanceledError = _t;
3770
- S.CancelToken = Cr;
3788
+ S.CancelToken = Rr;
3771
3789
  S.isCancel = oi;
3772
3790
  S.VERSION = pi;
3773
3791
  S.toFormData = jt;
@@ -3776,33 +3794,33 @@ S.Cancel = S.CanceledError;
3776
3794
  S.all = function(t) {
3777
3795
  return Promise.all(t);
3778
3796
  };
3779
- S.spread = Rr;
3780
- S.isAxiosError = Or;
3797
+ S.spread = Or;
3798
+ S.isAxiosError = Dr;
3781
3799
  S.mergeConfig = rt;
3782
3800
  S.AxiosHeaders = L;
3783
3801
  S.formToJSON = (n) => ai(l.isHTMLForm(n) ? new FormData(n) : n);
3784
3802
  S.getAdapter = fi.getAdapter;
3785
- S.HttpStatusCode = ie;
3803
+ S.HttpStatusCode = ee;
3786
3804
  S.default = S;
3787
3805
  const {
3788
- Axios: Nr,
3789
- AxiosError: xr,
3790
- CanceledError: Vr,
3791
- isCancel: Ur,
3792
- CancelToken: Lr,
3793
- VERSION: Mr,
3794
- all: kr,
3795
- Cancel: Fr,
3796
- isAxiosError: jr,
3797
- spread: qr,
3798
- toFormData: Kr,
3799
- AxiosHeaders: Hr,
3800
- HttpStatusCode: Wr,
3801
- formToJSON: Xr,
3802
- getAdapter: zr,
3803
- mergeConfig: Gr
3806
+ Axios: xr,
3807
+ AxiosError: Vr,
3808
+ CanceledError: Ur,
3809
+ isCancel: Lr,
3810
+ CancelToken: Mr,
3811
+ VERSION: kr,
3812
+ all: Fr,
3813
+ Cancel: jr,
3814
+ isAxiosError: qr,
3815
+ spread: Kr,
3816
+ toFormData: Hr,
3817
+ AxiosHeaders: Wr,
3818
+ HttpStatusCode: Xr,
3819
+ formToJSON: zr,
3820
+ getAdapter: Gr,
3821
+ mergeConfig: $r
3804
3822
  } = S;
3805
- class $r extends mi {
3823
+ class Jr extends mi {
3806
3824
  __pinPad__ = {
3807
3825
  buffer: null,
3808
3826
  about: {
@@ -4223,9 +4241,8 @@ class $r extends mi {
4223
4241
  this.dispatch("serial:message", e);
4224
4242
  }
4225
4243
  serialSetConnectionConstant() {
4226
- const t = "", e = "";
4227
4244
  let i = "C56AABOUT";
4228
- i = t + i.length.toString().padStart(3, "0") + i + e;
4245
+ i = "" + i.length.toString().padStart(3, "0") + i + "";
4229
4246
  let r = 0;
4230
4247
  for (let a = 0; a < i.length; a++)
4231
4248
  r ^= i.charCodeAt(a);
@@ -5331,5 +5348,5 @@ class $r extends mi {
5331
5348
  }
5332
5349
  }
5333
5350
  export {
5334
- $r as PinPad
5351
+ Jr as PinPad
5335
5352
  };
package/dist/pinpax.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./kernel-9JeWIxgz.cjs"),s=require("./relay-E3NCcSjS.cjs");class p extends c.Kernel{__pinpax__={server:"DEV",businessId:null,encryptionKey:null,apiKey:null,asyncResponses:{voucher:null,sale:null},waiting:{voucher:!1,sale:!1,sale_init:"idle",sale_login:"idle"}};constructor({filters:i=null,config_port:e={baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:t=1,device_listen_on_channel:a=1,socket:n=!1}={filters:null,config_port:{baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:1,device_listen_on_channel:1,socket:!1}){if(super({filters:i,config_port:e,no_device:t,device_listen_on_channel:a,socket:n}),this.__internal__.device.type="pinpax",c.Devices.getCustom(this.typeDevice,t))throw new Error(`Device ${this.typeDevice} ${t} already exists`);this.__internal__.time.response_connection=4e3,this.__internal__.time.response_general=3e3,this.__internal__.serial.delay_first_connection=1e3,this.__internal__.serial.response.replacer="",this.__internal__.serial.response.limiter=`\r
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./kernel-BTG8tlTU.cjs"),s=require("./relay-E3NCcSjS.cjs");class p extends c.Kernel{__pinpax__={server:"DEV",businessId:null,encryptionKey:null,apiKey:null,asyncResponses:{voucher:null,sale:null},waiting:{voucher:!1,sale:!1,sale_init:"idle",sale_login:"idle"}};constructor({filters:i=null,config_port:e={baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:t=1,device_listen_on_channel:a=1,socket:n=!1}={filters:null,config_port:{baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:1,device_listen_on_channel:1,socket:!1}){if(super({filters:i,config_port:e,no_device:t,device_listen_on_channel:a,socket:n}),this.__internal__.device.type="pinpax",c.Devices.getCustom(this.typeDevice,t))throw new Error(`Device ${this.typeDevice} ${t} already exists`);this.__internal__.time.response_connection=4e3,this.__internal__.time.response_general=3e3,this.__internal__.serial.delay_first_connection=1e3,this.__internal__.serial.response.replacer="",this.__internal__.serial.response.limiter=`\r
2
2
  `,this.#t(),c.Devices.add(this),this.getResponseAsString()}#t(){const i=["buttons-status","init-app","connectMessage","voucher","info","keep-alive","reset-app","get-config","payment","error","refund","login"];for(const e of i)this.serialRegisterAvailableListener(e)}set businessId(i){this.__pinpax__.businessId=i}get businessId(){return this.__pinpax__.businessId}set encryptionKey(i){this.__pinpax__.encryptionKey=i}get encryptionKey(){return this.__pinpax__.encryptionKey}set apiKey(i){this.__pinpax__.apiKey=i}get apiKey(){return this.__pinpax__.apiKey}set server(i){this.__pinpax__.server=i}get server(){return this.__pinpax__.server}serialMessage(i){let e=null;try{e=JSON.parse(i),e.request||(e.request=this.lastAction),e.name||(e.name=this.lastAction)}catch(t){console.error("Error parsing response",t,i),this.dispatch("serial:message",i);return}switch(e.response){case"INIT":this.dispatch("init",{name:"INIT",request:this.lastAction,status:"ok"}),this.__pinpax__.waiting.sale_init==="waiting"&&(this.__pinpax__.waiting.sale_init="received");break;case"INITAPP":this.dispatch("init-app",{name:"INITAPP",request:this.lastAction,status:"started"}),this.__pinpax__.waiting.sale_init==="waiting"?this.__pinpax__.waiting.sale_init="received":this.#n().then(()=>{});break;case"CONNECT":this.dispatch("connectMessage",{name:"CONNECT",request:this.lastAction,status:"connected"}),this.#r().then(()=>{});break;case"LOGIN":e.name||(e.name="LOGIN"),this.__pinpax__.waiting.sale_login==="waiting"&&(this.__pinpax__.waiting.sale_login="received"),this.dispatch("login",e);break;case"LASTVOUCHER":e.name||(e.name="LASTVOUCHER"),this.dispatch("voucher",e),this.__pinpax__.waiting.voucher&&(this.__pinpax__.asyncResponses.voucher=e,this.__pinpax__.waiting.voucher=!1);break;case"DEVICEINFO":e.name||(e.name="DEVICEINFO"),this.dispatch("info",e);break;case"KEEPALIVE":this.dispatch("keep-alive",{name:"KEEPALIVE",request:this.lastAction,status:"alive"});break;case"RESETAPP":this.dispatch("reset-app",{name:"RESETAPP",request:this.lastAction,status:"accepted"});break;case"GETCONFIG":e.name||(e.name="GETCONFIG"),this.dispatch("get-config",e);break;case"HIDEBUTTONS":this.dispatch("buttons-status",{name:"HIDEBUTTONS",request:this.lastAction,hidden:!0});break;case"SHOWBUTTONS":this.dispatch("buttons-status",{name:"SHOWBUTTONS",request:this.lastAction,hidden:!1});break;case"PAYMENT_PROCESS":e.name||(e.name="PAYMENT_PROCESS"),this.dispatch("payment",{name:"PAYMENT_PROCESS",request:this.lastAction,status:"starting",amount:e.amount,reference:e.referecence});break;case"INSERT_CARD":this.dispatch("payment",{name:"INSERT_CARD",request:this.lastAction,status:"insert card"});break;case"CARD_DATA":e.name||(e.name="CARD_DATA"),this.dispatch("payment",{name:"CARD_DATA",request:this.lastAction,status:"card data",amount:e.amount,cardHolderName:e.cardHolderName,ccMark:e.ccMark,ccType:e.ccType,currency:e.currency,maskedPan:e.maskedPan,readingType:e.readingType});break;case"MERCHANT":e.name||(e.name="MERCHANT"),this.dispatch("payment",{request:this.lastAction,status:"merchant",afiliation:e.afiliation,alias:e.alias,amountCashBackCommission:e.amountCashBackCommission,currency:e.currency,description:e.description,hasCashBack:e.hasCashBack,limitCashBackAmount:e.limitCashBackAmount,merchant:e.merchant,months:e.months,name:e.name});break;case"TRANSACTION_RESULT":e.name||(e.name="TRANSACTION_RESULT"),this.#o({status:"result",approved:e.approved,acquirer:e.acquirer,address:e.address,amount:e.amount,amountCashback:e.amountCashback,appIDLabel:e.appIDLabel,appId:e.appId,arqc:e.arqc,auth:e.auth,ccBin:e.ccBin,ccExpirationDate:e.ccExpirationDate,ccName:e.ccName,ccNumber:e.ccNumber,ccType:e.ccType,comissionCashback:e.comissionCashback,currency:e.currency,date:e.date,errorCode:e.errorCode,errorDescription:e.errorDescription,folio:e.folio,id:e.id,merchantName:e.merchantName,msiLabel:e.msiLabel,operation:e.operation,pin:e.pin,qps:e.qps,reference:e.reference,response:e.response,source:e.source,sourceLabel:e.sourceLabel,time:e.time});break;case"ERROR":e.name||(e.name="ERROR"),this.__pinpax__.waiting.sale&&(this.__pinpax__.asyncResponses.sale={status:"error",approved:!1,response:e}),this.dispatch("error",{name:"ERROR",request:this.lastAction,status:"error",response:e}),this.dispatch("payment",{name:"ERROR",request:this.lastAction,status:"error",response:e});break;case"REFUND":this.dispatch("refund",{name:"ERROR",request:this.lastAction,status:"refund",response:e});break}this.dispatch("serial:message",e)}serialSetConnectionConstant(){return s.s.connection()}softReload(){super.softReload(),this.__pinpax__.waiting.sale=!1,this.__pinpax__.waiting.voucher=!1,this.__pinpax__.asyncResponses.sale=null,this.__pinpax__.asyncResponses.voucher=null}async sendCustomCode(i={}){if(typeof i!="object")throw new Error("Invalid object");if(i.constructor!==Object)throw new Error("Invalid object");if(Object.keys(i).length===0)throw new Error("Empty object");if(i.action===void 0||i.action===null)throw new Error("Invalid object add action");const e=JSON.stringify(i),t=this.parseStringToBytes(e,`\r
3
3
  `);await this.appendToQueue(this.stringArrayToUint8Array(t),"custom")}async connectMessage(){await this.appendToQueue(s.s.connect(),"connect:message")}async#e(){if(this.isDisconnected)throw new Error("Device is disconnected");return this.queue.length===0?!0:new Promise(i=>{const e=setInterval(()=>{this.queue.length===0&&(clearInterval(e),i(!0))},500)})}async#i({type:i="production"}={}){const e=s.s.readQR({type:i});return await this.appendToQueue(e,"read-qr")}async#s(){await this.appendToQueue(s.s.forceHide(),"force-hide")}async#a(){await this.appendToQueue(s.s.forceShow(),"force-show")}async#n(){await this.connectMessage()}async#r(){await this.hideButtons()}#o(i){this.dispatch("payment",i),this.__pinpax__.waiting.sale&&(this.__pinpax__.asyncResponses.sale=i)}cancelSaleRequestInProcess(){this.__pinpax__.waiting.sale&&(this.__pinpax__.asyncResponses.sale={status:"error",approved:!1,response:{}})}async#c(){return new Promise((i,e)=>{const t=setTimeout(()=>{this.__pinpax__.waiting.sale_login==="waiting"&&(this.__pinpax__.waiting.sale_login="timeout",e(new Error("Login timeout")))},1e4),a=setInterval(()=>{this.__pinpax__.waiting.sale_login==="received"&&(clearTimeout(t),clearInterval(a),i(!0))},100)})}async#p(){return new Promise((i,e)=>{const t=setTimeout(()=>{this.__pinpax__.waiting.sale_init==="waiting"&&(this.__pinpax__.waiting.sale_init="timeout",e(new Error("Init timeout")))},1e4),a=setInterval(()=>{this.__pinpax__.waiting.sale_init==="received"&&(clearTimeout(t),clearInterval(a),i(!0))},100)})}async makeSale({amount:i=0,reference:e=null}={amount:0,reference:null}){if(this.isDisconnected)throw new Error("Device is disconnected");if(this.__pinpax__.waiting.sale)throw new Error("Already waiting for sale response");const t=s.s.makeSale({amount:i,reference:e});this.__pinpax__.waiting.sale=!0,this.__pinpax__.asyncResponses.sale=null,this.queue.length>0&&await this.#e();let a=!1;try{this.__pinpax__.waiting.sale_login="waiting",await this.login(),await this.#c(),this.__pinpax__.waiting.sale_login="idle",this.__pinpax__.waiting.sale_init="waiting",await this.init(),await this.#p(),this.__pinpax__.waiting.sale_init="idle"}catch(n){a=!0,this.__pinpax__.waiting.sale_login="idle",this.__pinpax__.waiting.sale_init="idle",this.__pinpax__.waiting.sale=!1,this.dispatch("error",{name:"ERROR",request:this.lastAction,status:"error",response:"Error during login/init before sale",error:n})}return a?!1:(await this.appendToQueue(t,"make-sale"),new Promise(n=>{const r=setInterval(()=>{if(this.__pinpax__.asyncResponses.sale){const o=this.__pinpax__.asyncResponses.sale;this.__pinpax__.asyncResponses.sale=null,this.__pinpax__.waiting.sale=!1,clearInterval(r),n(o.approved)}},100)}))}async getVoucher({folio:i=null}={}){if(this.isDisconnected)throw new Error("Device is disconnected");if(this.__pinpax__.waiting.voucher)throw new Error("Already waiting for voucher");if(!i)throw new Error("Folio is required");this.__pinpax__.waiting.voucher=!0,this.__pinpax__.asyncResponses.voucher=null;const e=s.s.getVoucher({folio:i});return this.queue.length>0&&await this.#e(),await this.appendToQueue(e,"get-voucher"),new Promise((t,a)=>{const n=setTimeout(()=>{this.__pinpax__.waiting.voucher=!1,a("Timeout")},1e4),r=setInterval(()=>{if(this.__pinpax__.asyncResponses.voucher){const o=this.__pinpax__.asyncResponses.voucher;this.__pinpax__.asyncResponses.voucher=null,this.__pinpax__.waiting.voucher=!1,clearInterval(r),clearTimeout(n),t(o.voucher)}},100)})}async info(){await this.appendToQueue(s.s.info(),"info")}async keepAlive(){await this.appendToQueue(s.s.keepAlive(),"keep-alive")}async restartApp(){await this.appendToQueue(s.s.restartApp(),"reset-app")}async getConfig(){return await this.appendToQueue(s.s.getConfig(),"get-config")}async hideButtons(){return await this.appendToQueue(s.s.hideButtons(),"hide-buttons"),await this.#s()}async showButtons(){return await this.appendToQueue(s.s.showButtons(),"show-buttons"),await this.#a()}async demo(){return console.warn("RUNNING DEMO APP, BE CAREFUL"),await this.appendToQueue(s.s.demo(),"demo")}async refund({amount:i=0,folio:e=null,auth:t=null}={}){return await this.appendToQueue(s.s.refund({amount:i,folio:e,auth:t}),"refund")}async readProductionQR(){return await this.#i({type:"production"})}async readQualityAssuranceQR(){return this.#i({type:"QA"})}async exit(){return await this.appendToQueue(s.s.exit(),"exit-app")}async init(){await this.appendToQueue(s.s.init(),"init-app")}async login(){if(!this.apiKey||!this.businessId||!this.encryptionKey||!this.server)throw new Error("Invalid data to login check apiKey, businessId, encryptionKey, server");const i=JSON.stringify({action:"LOGIN_MIT",server:this.__pinpax__.server,business_id:this.__pinpax__.businessId,encryption_key:this.__pinpax__.encryptionKey,api_key:this.__pinpax__.apiKey}),e=this.parseStringToBytes(i,`\r
4
4
  `);await this.appendToQueue(e,"login")}}exports.PinPax=p;
package/dist/pinpax.js CHANGED
@@ -1,4 +1,4 @@
1
- import { K as p, D as c } from "./kernel-BnWXOCde.js";
1
+ import { K as p, D as c } from "./kernel-xjzKtp5x.js";
2
2
  import { s } from "./relay-DP8PLsDP.js";
3
3
  class l extends p {
4
4
  __pinpax__ = {
package/dist/relay.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./kernel-9JeWIxgz.cjs"),a=require("./relay-E3NCcSjS.cjs");class r extends n.Kernel{constructor({filters:t=null,config_port:e,no_device:s=1,socket:i=!1}={}){if(super({filters:t,config_port:e,no_device:s,socket:i}),this.__internal__.device.type="relay",this.__internal__.auto_response=!1,this.__internal__.serial.auto_response=[2,6,221,221,240,207,3],n.Devices.getCustom(this.typeDevice,s))throw new Error(`Device ${this.typeDevice} ${s} already exists`);n.Devices.add(this)}serialMessage(t){t=this.fixHexArray(t);const e={code:t,name:null,description:null,request:null,no_code:0};t[0]==="a0"&&t[2]=="00"?(e.name="Relay turned off",e.description="The relay has been turned off successfully.",e.request=this.lastAction,e.no_code=101):t[0]==="a0"&&t[2]=="01"?(e.name="Relay turned on",e.description="The relay has been turned on successfully.",e.request=this.lastAction,e.no_code=102):(e.name="Unrecognized response",e.description="The response of application was received, but dont identify with any of current parameters",e.request="undefined",e.no_code=400),this.dispatch("serial:message",e)}serialSetConnectionConstant(t=1){return a.e.connection(t)}async turnOn(){const t=a.e.activate();await this.appendToQueue(t,"relay:turn-on")}async turnOff(){const t=a.e.deactivate();await this.appendToQueue(t,"relay:turn-off")}async toggle({inverse:t=!1,ms:e=300}={}){if(!t){await this.turnOn(),await n.wait(e),await this.turnOff();return}await this.turnOff(),await n.wait(e),await this.turnOn()}}exports.Relay=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./kernel-BTG8tlTU.cjs"),a=require("./relay-E3NCcSjS.cjs");class r extends n.Kernel{constructor({filters:t=null,config_port:e,no_device:s=1,socket:i=!1}={}){if(super({filters:t,config_port:e,no_device:s,socket:i}),this.__internal__.device.type="relay",this.__internal__.auto_response=!1,this.__internal__.serial.auto_response=[2,6,221,221,240,207,3],n.Devices.getCustom(this.typeDevice,s))throw new Error(`Device ${this.typeDevice} ${s} already exists`);n.Devices.add(this)}serialMessage(t){t=this.fixHexArray(t);const e={code:t,name:null,description:null,request:null,no_code:0};t[0]==="a0"&&t[2]=="00"?(e.name="Relay turned off",e.description="The relay has been turned off successfully.",e.request=this.lastAction,e.no_code=101):t[0]==="a0"&&t[2]=="01"?(e.name="Relay turned on",e.description="The relay has been turned on successfully.",e.request=this.lastAction,e.no_code=102):(e.name="Unrecognized response",e.description="The response of application was received, but dont identify with any of current parameters",e.request="undefined",e.no_code=400),this.dispatch("serial:message",e)}serialSetConnectionConstant(t=1){return a.e.connection(t)}async turnOn(){const t=a.e.activate();await this.appendToQueue(t,"relay:turn-on")}async turnOff(){const t=a.e.deactivate();await this.appendToQueue(t,"relay:turn-off")}async toggle({inverse:t=!1,ms:e=300}={}){if(!t){await this.turnOn(),await n.wait(e),await this.turnOff();return}await this.turnOff(),await n.wait(e),await this.turnOn()}}exports.Relay=r;
package/dist/relay.js CHANGED
@@ -1,4 +1,4 @@
1
- import { K as o, D as a, w as i } from "./kernel-BnWXOCde.js";
1
+ import { K as o, D as a, w as i } from "./kernel-xjzKtp5x.js";
2
2
  import { e as n } from "./relay-DP8PLsDP.js";
3
3
  class f extends o {
4
4
  constructor({ filters: t = null, config_port: e, no_device: s = 1, socket: r = !1 } = {}) {