webserial-core 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 danidoble
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  And easy way to connect to a serial port from a web page.
4
4
 
5
+ > [!NOTE]
6
+ > Since version 1.0.7 default response is an instance of Uint8Array.
7
+ > To change the response put this code inside your constructor to change the default response.
8
+ > `this.getResponseAsArrayBuffer()`
9
+ > `this.getResponseAsArrayHex()`
10
+ > `this.getResponseAsUint8Array()`
11
+ > `this.getResponseAsString()`
12
+ > Only choose one of them.
13
+
5
14
  ## Installation
6
15
 
7
16
  ```bash
@@ -10,6 +19,13 @@ npm install webserial-core
10
19
 
11
20
  ## Usage
12
21
 
22
+ > [!NOTE]
23
+ > If you are using Linux, you need to add your user to the `dialout` group to access the serial port.
24
+ > ```bash
25
+ > sudo usermod -a -G dialout $USER
26
+ > ```
27
+ > After that, you need to log out and log in again to apply the changes.
28
+
13
29
  You need to create a new class to configure your device functions. In this example, we are going to create a class to
14
30
  connect to an Arduino device.
15
31
 
@@ -81,12 +97,8 @@ export class Arduino extends Core {
81
97
  this.__internal__.time.response_general = 2e3;
82
98
  this.__internal__.serial.delay_first_connection = 1_000;
83
99
  this.#registerAvailableListenersArduino();
84
- this.#touch();
85
- this.getResponseAsString();
86
- }
87
-
88
- #touch() {
89
100
  Devices.add(this);
101
+ this.getResponseAsString();
90
102
  }
91
103
 
92
104
  #registerAvailableListenersArduino() {
package/dist/Core.d.ts CHANGED
@@ -2,7 +2,7 @@ import { Dispatcher } from "./Dispatcher.ts";
2
2
  interface LastError {
3
3
  message: string | null;
4
4
  action: string | null;
5
- code: number | Array<Uint8Array> | Array<string> | null;
5
+ code: string | Uint8Array | Array<string> | Array<number> | null | number;
6
6
  no_code: number;
7
7
  }
8
8
  interface DeviceData {
@@ -19,7 +19,7 @@ interface SerialResponse {
19
19
  limiter: null | string | RegExp;
20
20
  }
21
21
  interface QueueData {
22
- bytes: string[];
22
+ bytes: string | Uint8Array | Array<string> | Array<number>;
23
23
  action: string;
24
24
  }
25
25
  type SerialData = {
@@ -35,7 +35,7 @@ type SerialData = {
35
35
  keep_reading: boolean;
36
36
  time_until_send_bytes: number | undefined | ReturnType<typeof setTimeout>;
37
37
  delay_first_connection: number;
38
- bytes_connection: Array<string> | null;
38
+ bytes_connection: string | Uint8Array | string[] | number[] | null;
39
39
  filters: SerialPortFilter[];
40
40
  config_port: SerialOptions;
41
41
  queue: QueueData[];
@@ -98,7 +98,7 @@ interface ICore {
98
98
  add0x(bytes: string[]): string[];
99
99
  bytesToHex(bytes: string[]): string[];
100
100
  appendToQueue(arr: string[], action: string): Promise<void>;
101
- serialSetConnectionConstant(listen_on_port?: number): never[] | string[];
101
+ serialSetConnectionConstant(listen_on_port?: number): string | Uint8Array | string[] | number[] | null;
102
102
  serialMessage(hex: string[]): void;
103
103
  serialCorruptMessage(code: string[], data: never | null): void;
104
104
  clearSerialQueue(): void;
@@ -140,7 +140,7 @@ export declare class Core extends Dispatcher implements ICore {
140
140
  get uuid(): string;
141
141
  get typeDevice(): string;
142
142
  get queue(): QueueData[];
143
- timeout(bytes: string[], event: string): Promise<void>;
143
+ timeout(bytes: string | Uint8Array | Array<string> | Array<number>, event: string): Promise<void>;
144
144
  disconnect(detail?: null): Promise<void>;
145
145
  connect(): Promise<string>;
146
146
  serialDisconnect(): Promise<void>;
@@ -157,10 +157,11 @@ export declare class Core extends Dispatcher implements ICore {
157
157
  hexMaker(val?: string, min?: number): string;
158
158
  add0x(bytes: string[]): string[];
159
159
  bytesToHex(bytes: string[]): string[];
160
- appendToQueue(arr: string[], action: string): Promise<void>;
161
- serialSetConnectionConstant(listen_on_port?: number): never[] | string[];
160
+ validateBytes(data: string | Uint8Array | Array<string> | Array<number>): Uint8Array;
161
+ appendToQueue(arr: string | Uint8Array | string[] | number[], action: string): Promise<void>;
162
+ serialSetConnectionConstant(listen_on_port?: number): string | Uint8Array | string[] | number[] | null;
162
163
  serialMessage(hex: string[] | Uint8Array<ArrayBufferLike> | string | ArrayBuffer): void;
163
- serialCorruptMessage(code: string[], data: never | null): void;
164
+ serialCorruptMessage(code: Uint8Array | number[] | string[], data: never | null): void;
164
165
  clearSerialQueue(): void;
165
166
  sumHex(arr: string[]): string;
166
167
  toString(): string;
@@ -174,7 +175,7 @@ export declare class Core extends Dispatcher implements ICore {
174
175
  parseUint8ToHex(array: Uint8Array): string[];
175
176
  parseHexToUint8(array: string[]): Uint8Array;
176
177
  stringArrayToUint8Array(strings: string[]): Uint8Array;
177
- parseUint8ArrayToString(array: string[]): string;
178
+ parseUint8ArrayToString(array: Uint8Array | string[]): string;
178
179
  hexToAscii(hex: string | number): string;
179
180
  asciiToHex(asciiString: string): string;
180
181
  $checkAndD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eError(o);
4
4
  };
5
- var N = (l, n, e) => n in l ? M(l, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : l[n] = e;
6
- var d = (l, n, e) => N(l, typeof n != "symbol" ? n + "" : n, e), O = (l, n, e) => n.has(l) || w("Cannot " + e);
7
- var m = (l, n, e) => n.has(l) ? w("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(l) : n.set(l, e);
8
- var o = (l, n, e) => (O(l, n, "access private method"), e);
9
- class v extends CustomEvent {
5
+ var M = (o, n, e) => n in o ? I(o, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[n] = e;
6
+ var u = (o, n, e) => M(o, typeof n != "symbol" ? n + "" : n, e), N = (o, n, e) => n.has(o) || b("Cannot " + e);
7
+ var w = (o, n, e) => n.has(o) ? b("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(o) : n.set(o, e);
8
+ var l = (o, n, e) => (N(o, n, "access private method"), e);
9
+ class m extends CustomEvent {
10
10
  constructor(n, e) {
11
11
  super(n, e);
12
12
  }
13
13
  }
14
- class x extends EventTarget {
14
+ class C extends EventTarget {
15
15
  constructor() {
16
16
  super(...arguments);
17
- d(this, "__listeners__", {
17
+ u(this, "__listeners__", {
18
18
  debug: !1
19
19
  });
20
- d(this, "__debug__", !1);
20
+ u(this, "__debug__", !1);
21
21
  }
22
22
  dispatch(e, t = null) {
23
- const i = new v(e, { detail: t });
24
- this.dispatchEvent(i), this.__debug__ && this.dispatchEvent(new v("debug", { detail: { type: e, data: t } }));
23
+ const i = new m(e, { detail: t });
24
+ this.dispatchEvent(i), this.__debug__ && this.dispatchEvent(new m("debug", { detail: { type: e, data: t } }));
25
25
  }
26
26
  dispatchAsync(e, t = null, i = 100) {
27
- const r = this;
27
+ const s = this;
28
28
  setTimeout(() => {
29
- r.dispatch(e, t);
29
+ s.dispatch(e, t);
30
30
  }, i);
31
31
  }
32
32
  on(e, t) {
@@ -45,7 +45,7 @@ class x extends EventTarget {
45
45
  }));
46
46
  }
47
47
  }
48
- const a = class a extends x {
48
+ const a = class a extends C {
49
49
  constructor() {
50
50
  super(), ["change"].forEach((e) => {
51
51
  this.serialRegisterAvailableListener(e);
@@ -85,15 +85,15 @@ const a = class a extends x {
85
85
  return typeof a.devices[n] > "u" && a.typeError(n), Object.values(a.devices[n]).find((i) => i.deviceNumber === e) ?? null;
86
86
  }
87
87
  };
88
- d(a, "instance"), d(a, "devices", {});
88
+ u(a, "instance"), u(a, "devices", {});
89
89
  let _ = a;
90
90
  _.instance || (_.instance = new _());
91
- function C(l = 100) {
91
+ function v(o = 100) {
92
92
  return new Promise(
93
- (n) => setTimeout(() => n(), l)
93
+ (n) => setTimeout(() => n(), o)
94
94
  );
95
95
  }
96
- function H() {
96
+ function B() {
97
97
  return "serial" in navigator;
98
98
  }
99
99
  const g = {
@@ -104,13 +104,13 @@ const g = {
104
104
  bufferSize: 32768,
105
105
  flowControl: "none"
106
106
  };
107
- var s, p, f, b, h, S, A, E, T, k, U, L, P, D, $, q, I;
108
- class B extends x {
107
+ var r, d, f, y, h, A, E, x, T, S, U, k, P, L, D, $, q;
108
+ class R extends C {
109
109
  constructor({
110
110
  filters: e = null,
111
111
  config_port: t = g,
112
112
  no_device: i = 1,
113
- device_listen_on_channel: r = 1
113
+ device_listen_on_channel: s = 1
114
114
  } = {
115
115
  filters: null,
116
116
  config_port: g,
@@ -118,8 +118,8 @@ class B extends x {
118
118
  device_listen_on_channel: 1
119
119
  }) {
120
120
  super();
121
- m(this, s);
122
- d(this, "__internal__", {
121
+ w(this, r);
122
+ u(this, "__internal__", {
123
123
  auto_response: !1,
124
124
  device_number: 1,
125
125
  aux_port_connector: 0,
@@ -136,7 +136,7 @@ class B extends x {
136
136
  response: {
137
137
  length: null,
138
138
  buffer: new Uint8Array([]),
139
- as: "hex",
139
+ as: "uint8",
140
140
  replacer: /[\n\r]+/g,
141
141
  limiter: null
142
142
  },
@@ -172,7 +172,7 @@ class B extends x {
172
172
  });
173
173
  if (!("serial" in navigator))
174
174
  throw new Error("Web Serial not supported");
175
- e && (this.serialFilters = e), t && (this.serialConfigPort = t), i && o(this, s, q).call(this, i), r && ["number", "string"].includes(typeof r) && (this.listenOnChannel = r), o(this, s, L).call(this), o(this, s, P).call(this);
175
+ e && (this.serialFilters = e), t && (this.serialConfigPort = t), i && l(this, r, $).call(this, i), s && ["number", "string"].includes(typeof s) && (this.listenOnChannel = s), l(this, r, k).call(this), l(this, r, P).call(this);
176
176
  }
177
177
  set listenOnChannel(e) {
178
178
  if (typeof e == "string" && (e = parseInt(e)), isNaN(e) || e < 1 || e > 255)
@@ -198,11 +198,11 @@ class B extends x {
198
198
  return this.__internal__.serial.config_port;
199
199
  }
200
200
  get isConnected() {
201
- const e = this.__internal__.serial.connected, t = o(this, s, p).call(this, this.__internal__.serial.port);
202
- return e && !t && o(this, s, f).call(this, { error: "Port is closed, not readable or writable." }), this.__internal__.serial.connected = t, this.__internal__.serial.connected;
201
+ const e = this.__internal__.serial.connected, t = l(this, r, d).call(this, this.__internal__.serial.port);
202
+ return e && !t && l(this, r, f).call(this, { error: "Port is closed, not readable or writable." }), this.__internal__.serial.connected = t, this.__internal__.serial.connected;
203
203
  }
204
204
  get isDisconnected() {
205
- const e = this.__internal__.serial.connected, t = o(this, s, p).call(this, this.__internal__.serial.port);
205
+ const e = this.__internal__.serial.connected, t = l(this, r, d).call(this, this.__internal__.serial.port);
206
206
  return !e && t && (this.dispatch("serial:connected"), _.$dispatchChange(this)), this.__internal__.serial.connected = t, !this.__internal__.serial.connected;
207
207
  }
208
208
  get deviceNumber() {
@@ -225,19 +225,19 @@ class B extends x {
225
225
  });
226
226
  }
227
227
  async disconnect(e = null) {
228
- await this.serialDisconnect(), o(this, s, f).call(this, e);
228
+ await this.serialDisconnect(), l(this, r, f).call(this, e);
229
229
  }
230
230
  async connect() {
231
231
  return new Promise((e, t) => {
232
- H() || t("Web Serial not supported"), setTimeout(async () => {
233
- await C(499), await this.serialConnect(), this.isConnected ? e(`${this.typeDevice} device ${this.deviceNumber} connected`) : t(`${this.typeDevice} device ${this.deviceNumber} not connected`);
232
+ B() || t("Web Serial not supported"), setTimeout(async () => {
233
+ await v(499), await this.serialConnect(), this.isConnected ? e(`${this.typeDevice} device ${this.deviceNumber} connected`) : t(`${this.typeDevice} device ${this.deviceNumber} not connected`);
234
234
  }, 1);
235
235
  });
236
236
  }
237
237
  async serialDisconnect() {
238
238
  try {
239
239
  const e = this.__internal__.serial.reader, t = this.__internal__.serial.output_stream;
240
- e && (await e.cancel().catch((r) => this.serialErrors(r)), await this.__internal__.serial.input_done), t && (await t.getWriter().close(), await this.__internal__.serial.output_done), this.__internal__.serial.connected && this.__internal__.serial && this.__internal__.serial.port && await this.__internal__.serial.port.close();
240
+ e && (await e.cancel().catch((s) => this.serialErrors(s)), await this.__internal__.serial.input_done), t && (await t.getWriter().close(), await this.__internal__.serial.output_done), this.__internal__.serial.connected && this.__internal__.serial && this.__internal__.serial.port && await this.__internal__.serial.port.close();
241
241
  } catch (e) {
242
242
  this.serialErrors(e);
243
243
  } finally {
@@ -318,13 +318,13 @@ class B extends x {
318
318
  async serialConnect() {
319
319
  try {
320
320
  this.dispatch("serial:connecting", {});
321
- const e = await o(this, s, S).call(this);
321
+ const e = await l(this, r, A).call(this);
322
322
  if (e.length > 0)
323
323
  await this.serialPortsSaved(e);
324
324
  else {
325
- const r = this.serialFilters;
325
+ const s = this.serialFilters;
326
326
  this.__internal__.serial.port = await navigator.serial.requestPort({
327
- filters: r
327
+ filters: s
328
328
  });
329
329
  }
330
330
  const t = this.__internal__.serial.port;
@@ -332,22 +332,22 @@ class B extends x {
332
332
  throw new Error("No port selected by the user");
333
333
  await t.open(this.serialConfigPort);
334
334
  const i = this;
335
- t.onconnect = (r) => {
336
- console.log(r), i.dispatch("serial:connected", r), _.$dispatchChange(this), i.__internal__.serial.queue.length > 0 && i.dispatch("internal:queue", {});
335
+ t.onconnect = (s) => {
336
+ console.log(s), i.dispatch("serial:connected", s), _.$dispatchChange(this), i.__internal__.serial.queue.length > 0 && i.dispatch("internal:queue", {});
337
337
  }, t.ondisconnect = async () => {
338
338
  await i.disconnect();
339
- }, await C(this.__internal__.serial.delay_first_connection), this.__internal__.timeout.until_response = setTimeout(async () => {
339
+ }, await v(this.__internal__.serial.delay_first_connection), this.__internal__.timeout.until_response = setTimeout(async () => {
340
340
  await i.timeout(i.__internal__.serial.bytes_connection ?? [], "connection:start");
341
- }, this.__internal__.time.response_connection), this.__internal__.serial.last_action = "connect", await o(this, s, b).call(this, this.__internal__.serial.bytes_connection ?? []), this.dispatch("serial:sent", {
341
+ }, this.__internal__.time.response_connection), this.__internal__.serial.last_action = "connect", await l(this, r, y).call(this, this.__internal__.serial.bytes_connection ?? []), this.dispatch("serial:sent", {
342
342
  action: "connect",
343
343
  bytes: this.__internal__.serial.bytes_connection
344
- }), this.__internal__.auto_response && o(this, s, h).call(this, this.__internal__.serial.auto_response, null), await o(this, s, k).call(this);
344
+ }), this.__internal__.auto_response && l(this, r, h).call(this, this.__internal__.serial.auto_response, null), await l(this, r, S).call(this);
345
345
  } catch (e) {
346
346
  this.serialErrors(e);
347
347
  }
348
348
  }
349
349
  async serialForget() {
350
- return await o(this, s, U).call(this);
350
+ return await l(this, r, U).call(this);
351
351
  }
352
352
  decToHex(e) {
353
353
  return typeof e == "string" && (e = parseInt(e, 10)), e.toString(16);
@@ -360,15 +360,29 @@ class B extends x {
360
360
  }
361
361
  add0x(e) {
362
362
  const t = [];
363
- return e.forEach((i, r) => {
364
- t[r] = "0x" + i;
363
+ return e.forEach((i, s) => {
364
+ t[s] = "0x" + i;
365
365
  }), t;
366
366
  }
367
367
  bytesToHex(e) {
368
368
  return this.add0x(Array.from(e, (t) => this.hexMaker(t)));
369
369
  }
370
+ validateBytes(e) {
371
+ let t = new Uint8Array(0);
372
+ if (e instanceof Uint8Array)
373
+ t = e;
374
+ else if (typeof e == "string")
375
+ t = this.parseStringToTextEncoder(e);
376
+ else if (Array.isArray(e) && typeof e[0] == "string")
377
+ t = this.stringArrayToUint8Array(e);
378
+ else if (Array.isArray(e) && typeof e[0] == "number")
379
+ t = new Uint8Array(e);
380
+ else
381
+ throw new Error("Invalid data type");
382
+ return t;
383
+ }
370
384
  async appendToQueue(e, t) {
371
- const i = this.bytesToHex(e);
385
+ const i = this.validateBytes(e);
372
386
  if (["connect", "connection:start"].includes(t)) {
373
387
  if (this.__internal__.serial.connected) return;
374
388
  await this.serialConnect();
@@ -404,7 +418,7 @@ class B extends x {
404
418
  });
405
419
  }
406
420
  softReload() {
407
- o(this, s, I).call(this), this.dispatch("serial:soft-reload", {});
421
+ l(this, r, q).call(this), this.dispatch("serial:soft-reload", {});
408
422
  }
409
423
  async sendConnect() {
410
424
  if (!this.__internal__.serial.bytes_connection)
@@ -432,7 +446,7 @@ class B extends x {
432
446
  parseStringToBytes(e = "", t = `
433
447
  `) {
434
448
  const i = this.parseStringToTextEncoder(e, t);
435
- return Array.from(i).map((r) => r.toString(16));
449
+ return Array.from(i).map((s) => s.toString(16));
436
450
  }
437
451
  parseUint8ToHex(e) {
438
452
  return Array.from(e).map((t) => t.toString(16));
@@ -443,26 +457,26 @@ class B extends x {
443
457
  stringArrayToUint8Array(e) {
444
458
  const t = [];
445
459
  return e.forEach((i) => {
446
- const r = i.replace("0x", "");
447
- t.push(parseInt(r, 16));
460
+ const s = i.replace("0x", "");
461
+ t.push(parseInt(s, 16));
448
462
  }), new Uint8Array(t);
449
463
  }
450
464
  parseUint8ArrayToString(e) {
451
- const t = this.stringArrayToUint8Array(e);
452
- e = this.parseUint8ToHex(t);
453
- const i = e.map((r) => parseInt(r, 16));
465
+ let t = new Uint8Array(0);
466
+ e instanceof Uint8Array ? t = e : t = this.stringArrayToUint8Array(e), e = this.parseUint8ToHex(t);
467
+ const i = e.map((s) => parseInt(s, 16));
454
468
  return this.__internal__.serial.response.replacer ? String.fromCharCode(...i).replace(this.__internal__.serial.response.replacer, "") : String.fromCharCode(...i);
455
469
  }
456
470
  hexToAscii(e) {
457
471
  const t = e.toString();
458
472
  let i = "";
459
- for (let r = 0; r < t.length; r += 2)
460
- i += String.fromCharCode(parseInt(t.substring(r, 2), 16));
473
+ for (let s = 0; s < t.length; s += 2)
474
+ i += String.fromCharCode(parseInt(t.substring(s, 2), 16));
461
475
  return i;
462
476
  }
463
477
  asciiToHex(e) {
464
478
  const t = [];
465
- for (let i = 0, r = e.length; i < r; i++) {
479
+ for (let i = 0, s = e.length; i < s; i++) {
466
480
  const c = Number(e.charCodeAt(i)).toString(16);
467
481
  t.push(c);
468
482
  }
@@ -472,79 +486,65 @@ class B extends x {
472
486
  return this.isConnected;
473
487
  }
474
488
  }
475
- s = new WeakSet(), p = function(e) {
489
+ r = new WeakSet(), d = function(e) {
476
490
  return !!(e && e.readable && e.writable);
477
491
  }, f = function(e = null) {
478
492
  this.__internal__.serial.connected = !1, this.__internal__.aux_port_connector = 0, this.dispatch("serial:disconnected", e), _.$dispatchChange(this);
479
- }, b = async function(e) {
493
+ }, y = async function(e) {
480
494
  const t = this.__internal__.serial.port;
481
495
  if (!t || t && (!t.readable || !t.writable))
482
- throw o(this, s, f).call(this, { error: "Port is closed, not readable or writable." }), new Error("The port is closed or is not readable/writable");
483
- const i = this.stringArrayToUint8Array(e);
496
+ throw l(this, r, f).call(this, { error: "Port is closed, not readable or writable." }), new Error("The port is closed or is not readable/writable");
497
+ const i = this.validateBytes(e);
484
498
  if (t.writable === null) return;
485
- const r = t.writable.getWriter();
486
- await r.write(i), r.releaseLock();
487
- }, h = function(e = [], t = null) {
499
+ const s = t.writable.getWriter();
500
+ await s.write(i), s.releaseLock();
501
+ }, h = function(e = new Uint8Array([]), t = null) {
488
502
  if (e && e.length > 0) {
489
503
  const i = this.__internal__.serial.connected;
490
- this.__internal__.serial.connected = o(this, s, p).call(this, this.__internal__.serial.port), _.$dispatchChange(this), !i && this.__internal__.serial.connected && this.dispatch("serial:connected"), 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);
491
- const r = [];
492
- for (const c in e)
493
- r.push(e[c].toString().padStart(2, "0").toLowerCase());
494
- if (this.__internal__.serial.response.as === "hex")
495
- this.serialMessage(r);
504
+ if (this.__internal__.serial.connected = l(this, r, d).call(this, this.__internal__.serial.port), _.$dispatchChange(this), !i && this.__internal__.serial.connected && this.dispatch("serial:connected"), 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), this.__internal__.serial.response.as === "hex")
505
+ this.serialMessage(this.parseUint8ToHex(e));
496
506
  else if (this.__internal__.serial.response.as === "uint8")
497
- this.serialMessage(this.parseHexToUint8(this.add0x(r)));
498
- else if (this.__internal__.serial.response.as === "string")
507
+ this.serialMessage(e);
508
+ else if (this.__internal__.serial.response.as === "string") {
509
+ const s = this.parseUint8ArrayToString(e);
499
510
  if (this.__internal__.serial.response.limiter !== null) {
500
- const u = this.parseUint8ArrayToString(this.add0x(r)).split(this.__internal__.serial.response.limiter);
501
- for (const y in u)
502
- u[y] && this.serialMessage(u[y]);
511
+ const c = s.split(this.__internal__.serial.response.limiter);
512
+ for (const p in c)
513
+ c[p] && this.serialMessage(c[p]);
503
514
  } else
504
- this.serialMessage(this.parseUint8ArrayToString(this.add0x(r)));
505
- else {
506
- const c = this.stringToArrayBuffer(
507
- this.parseUint8ArrayToString(this.add0x(r))
508
- );
509
- this.serialMessage(c);
515
+ this.serialMessage(s);
516
+ } else {
517
+ const s = this.stringToArrayBuffer(this.parseUint8ArrayToString(e));
518
+ this.serialMessage(s);
510
519
  }
511
520
  } else
512
521
  this.serialCorruptMessage(e, t);
513
522
  this.__internal__.serial.queue.length !== 0 && this.dispatch("internal:queue", {});
514
- }, S = async function() {
523
+ }, A = async function() {
515
524
  const e = this.serialFilters, t = await navigator.serial.getPorts({ filters: e });
516
- return e.length === 0 ? t : t.filter((r) => {
517
- const c = r.getInfo();
518
- return e.some((u) => c.usbProductId === u.usbProductId && c.usbVendorId === u.usbVendorId);
519
- }).filter((r) => !o(this, s, p).call(this, r));
520
- }, A = function(e) {
525
+ return e.length === 0 ? t : t.filter((s) => {
526
+ const c = s.getInfo();
527
+ return e.some((p) => c.usbProductId === p.usbProductId && c.usbVendorId === p.usbVendorId);
528
+ }).filter((s) => !l(this, r, d).call(this, s));
529
+ }, E = function(e) {
521
530
  if (e) {
522
531
  const t = this.__internal__.serial.response.buffer, i = new Uint8Array(t.length + e.byteLength);
523
532
  i.set(t, 0), i.set(new Uint8Array(e), t.length), this.__internal__.serial.response.buffer = i;
524
533
  }
525
- }, E = async function() {
534
+ }, x = async function() {
526
535
  this.__internal__.serial.time_until_send_bytes && (clearTimeout(this.__internal__.serial.time_until_send_bytes), this.__internal__.serial.time_until_send_bytes = 0), this.__internal__.serial.time_until_send_bytes = setTimeout(() => {
527
- const e = [];
528
- for (const t in this.__internal__.serial.response.buffer)
529
- e.push(this.__internal__.serial.response.buffer[t].toString(16));
530
- this.__internal__.serial.response.buffer && o(this, s, h).call(this, e), this.__internal__.serial.response.buffer = new Uint8Array(0);
536
+ this.__internal__.serial.response.buffer && l(this, r, h).call(this, this.__internal__.serial.response.buffer), this.__internal__.serial.response.buffer = new Uint8Array(0);
531
537
  }, 400);
532
538
  }, T = async function() {
533
539
  if (this.__internal__.serial.response.length !== null) {
534
- if (this.__internal__.serial.response.length === this.__internal__.serial.response.buffer.length) {
535
- const e = [];
536
- for (const t in this.__internal__.serial.response.buffer)
537
- e.push(this.__internal__.serial.response.buffer[t].toString(16));
538
- o(this, s, h).call(this, e), this.__internal__.serial.response.buffer = new Uint8Array(0);
539
- } else if (this.__internal__.serial.response.length < this.__internal__.serial.response.buffer.length) {
540
+ if (this.__internal__.serial.response.length === this.__internal__.serial.response.buffer.length)
541
+ l(this, r, h).call(this, this.__internal__.serial.response.buffer), this.__internal__.serial.response.buffer = new Uint8Array(0);
542
+ else if (this.__internal__.serial.response.length < this.__internal__.serial.response.buffer.length) {
540
543
  let e = new Uint8Array(0);
541
544
  for (let i = 0; i < this.__internal__.serial.response.length; i++)
542
545
  e[i] = this.__internal__.serial.response.buffer[i];
543
546
  if (e.length === this.__internal__.serial.response.length) {
544
- const i = [];
545
- for (const r in e)
546
- i.push(e[r].toString(16));
547
- o(this, s, h).call(this, i), this.__internal__.serial.response.buffer = new Uint8Array(0);
547
+ l(this, r, h).call(this, e), this.__internal__.serial.response.buffer = new Uint8Array(0);
548
548
  return;
549
549
  }
550
550
  e = new Uint8Array(0);
@@ -552,16 +552,11 @@ s = new WeakSet(), p = function(e) {
552
552
  if (this.__internal__.serial.response.buffer.length === t) {
553
553
  for (let i = 14; i < t; i++)
554
554
  e[i - this.__internal__.serial.response.length] = this.__internal__.serial.response.buffer[i];
555
- if (e.length === this.__internal__.serial.response.length) {
556
- const i = [];
557
- for (const r in e)
558
- i.push(e[r].toString(16));
559
- o(this, s, h).call(this, i), this.__internal__.serial.response.buffer = new Uint8Array(0);
560
- }
555
+ e.length === this.__internal__.serial.response.length && (l(this, r, h).call(this, e), this.__internal__.serial.response.buffer = new Uint8Array(0));
561
556
  }
562
557
  }
563
558
  }
564
- }, k = async function() {
559
+ }, S = async function() {
565
560
  const e = this.__internal__.serial.port;
566
561
  if (!e || !e.readable) throw new Error("Port is not readable");
567
562
  for (; e.readable && this.__internal__.serial.keep_reading; ) {
@@ -570,12 +565,12 @@ s = new WeakSet(), p = function(e) {
570
565
  try {
571
566
  let i = !0;
572
567
  for (; i; ) {
573
- const { value: r, done: c } = await t.read();
568
+ const { value: s, done: c } = await t.read();
574
569
  if (c) {
575
570
  t.releaseLock(), this.__internal__.serial.keep_reading = !1, i = !1;
576
571
  break;
577
572
  }
578
- o(this, s, A).call(this, r), this.__internal__.serial.response.length === null ? await o(this, s, E).call(this) : await o(this, s, T).call(this);
573
+ l(this, r, E).call(this, s), this.__internal__.serial.response.length === null ? await l(this, r, x).call(this) : await l(this, r, T).call(this);
579
574
  }
580
575
  } catch (i) {
581
576
  this.serialErrors(i);
@@ -586,7 +581,7 @@ s = new WeakSet(), p = function(e) {
586
581
  this.__internal__.serial.keep_reading = !0, this.__internal__.serial.port && await this.__internal__.serial.port.close();
587
582
  }, U = async function() {
588
583
  return typeof window > "u" ? !1 : "serial" in navigator && "forget" in SerialPort.prototype && this.__internal__.serial.port ? (await this.__internal__.serial.port.forget(), !0) : !1;
589
- }, L = function() {
584
+ }, k = function() {
590
585
  [
591
586
  "serial:connected",
592
587
  "serial:connecting",
@@ -609,33 +604,41 @@ s = new WeakSet(), p = function(e) {
609
604
  const e = this;
610
605
  this.on("internal:queue", async () => {
611
606
  var t;
612
- await o(t = e, s, $).call(t);
613
- }), o(this, s, D).call(this);
614
- }, D = function() {
607
+ await l(t = e, r, D).call(t);
608
+ }), l(this, r, L).call(this);
609
+ }, L = function() {
615
610
  const e = this;
616
611
  navigator.serial.addEventListener("connect", async () => {
617
612
  e.isDisconnected && await e.serialConnect().catch(() => {
618
613
  });
619
614
  });
620
- }, $ = async function() {
621
- if (!o(this, s, p).call(this, this.__internal__.serial.port)) {
622
- o(this, s, f).call(this, { error: "Port is closed, not readable or writable." }), await this.serialConnect();
615
+ }, D = async function() {
616
+ if (!l(this, r, d).call(this, this.__internal__.serial.port)) {
617
+ l(this, r, f).call(this, { error: "Port is closed, not readable or writable." }), await this.serialConnect();
623
618
  return;
624
619
  }
625
620
  if (this.__internal__.timeout.until_response || this.__internal__.serial.queue.length === 0) return;
626
621
  const e = this.__internal__.serial.queue[0];
627
622
  let t = this.__internal__.time.response_general;
628
- e.action === "connect" && (t = this.__internal__.time.response_connection), this.__internal__.timeout.until_response = setTimeout(async () => {
623
+ if (e.action === "connect" && (t = this.__internal__.time.response_connection), this.__internal__.timeout.until_response = setTimeout(async () => {
629
624
  await this.timeout(e.bytes, e.action);
630
- }, t), this.__internal__.serial.last_action = e.action ?? "unknown", await o(this, s, b).call(this, e.bytes), this.dispatch("serial:sent", {
625
+ }, t), this.__internal__.serial.last_action = e.action ?? "unknown", await l(this, r, y).call(this, e.bytes), this.dispatch("serial:sent", {
631
626
  action: e.action,
632
627
  bytes: e.bytes
633
- }), this.__internal__.auto_response && o(this, s, h).call(this, this.__internal__.serial.auto_response, null);
628
+ }), this.__internal__.auto_response) {
629
+ let s = new Uint8Array(0);
630
+ try {
631
+ s = this.validateBytes(this.__internal__.serial.auto_response);
632
+ } catch (c) {
633
+ this.serialErrors(c);
634
+ }
635
+ l(this, r, h).call(this, s, null);
636
+ }
634
637
  const i = [...this.__internal__.serial.queue];
635
638
  this.__internal__.serial.queue = i.splice(1);
636
- }, q = function(e = 1) {
639
+ }, $ = function(e = 1) {
637
640
  this.__internal__.device_number = e, this.__internal__.serial.bytes_connection = this.serialSetConnectionConstant(e);
638
- }, I = function() {
641
+ }, q = function() {
639
642
  this.__internal__.last_error = {
640
643
  message: null,
641
644
  action: null,
@@ -644,7 +647,7 @@ s = new WeakSet(), p = function(e) {
644
647
  };
645
648
  };
646
649
  export {
647
- B as Core,
650
+ R as Core,
648
651
  _ as Devices,
649
- x as Dispatcher
652
+ C as Dispatcher
650
653
  };
@@ -1,4 +1,4 @@
1
- (function(l,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(l=typeof globalThis<"u"?globalThis:l||self,_(l.WebSerialCore={}))})(this,function(l){"use strict";var H=Object.defineProperty;var x=l=>{throw TypeError(l)};var R=(l,_,h)=>_ in l?H(l,_,{enumerable:!0,configurable:!0,writable:!0,value:h}):l[_]=h;var f=(l,_,h)=>R(l,typeof _!="symbol"?_+"":_,h),j=(l,_,h)=>_.has(l)||x("Cannot "+h);var S=(l,_,h)=>_.has(l)?x("Cannot add the same private member more than once"):_ instanceof WeakSet?_.add(l):_.set(l,h);var o=(l,_,h)=>(j(l,_,"access private method"),h);var n,g,b,m,d,A,T,E,k,U,P,L,D,$,q,I,M;class _ extends CustomEvent{constructor(r,e){super(r,e)}}class h extends EventTarget{constructor(){super(...arguments);f(this,"__listeners__",{debug:!1});f(this,"__debug__",!1)}dispatch(e,t=null){const i=new _(e,{detail:t});this.dispatchEvent(i),this.__debug__&&this.dispatchEvent(new _("debug",{detail:{type:e,data:t}}))}dispatchAsync(e,t=null,i=100){const s=this;setTimeout(()=>{s.dispatch(e,t)},i)}on(e,t){typeof this.__listeners__[e]<"u"&&!this.__listeners__[e]&&(this.__listeners__[e]=!0),this.addEventListener(e,t)}off(e,t){this.removeEventListener(e,t)}serialRegisterAvailableListener(e){this.__listeners__[e]||(this.__listeners__[e]=!1)}get availableListeners(){return Object.keys(this.__listeners__).sort().map(t=>({type:t,listening:this.__listeners__[t]}))}}const a=class a extends h{constructor(){super(),["change"].forEach(e=>{this.serialRegisterAvailableListener(e)})}static $dispatchChange(r=null){r&&r.$checkAndDispatchConnection(),a.instance.dispatch("change",{devices:a.devices,dispatcher:r})}static typeError(r){const e=new Error;throw e.message=`Type ${r} is not supported`,e.name="DeviceTypeError",e}static registerType(r){typeof a.devices[r]>"u"&&(a.devices[r]={})}static add(r){const e=r.typeDevice;typeof a.devices[e]>"u"&&(a.devices[e]={});const t=r.uuid;if(typeof a.devices[e]>"u"&&a.typeError(e),a.devices[e][t])throw new Error(`Device with id ${t} already exists`);return a.devices[e][t]=r,a.$dispatchChange(r),Object.keys(a.devices[e]).indexOf(t)}static get(r,e){return typeof a.devices[r]>"u"&&(a.devices[r]={}),typeof a.devices[r]>"u"&&a.typeError(r),a.devices[r][e]}static getAll(r=null){return r===null?a.devices:(typeof a.devices[r]>"u"&&a.typeError(r),a.devices[r])}static getList(){return Object.values(a.devices).map(e=>Object.values(e)).flat()}static getByNumber(r,e){return typeof a.devices[r]>"u"&&a.typeError(r),Object.values(a.devices[r]).find(i=>i.deviceNumber===e)??null}static getCustom(r,e=1){return typeof a.devices[r]>"u"&&a.typeError(r),Object.values(a.devices[r]).find(i=>i.deviceNumber===e)??null}};f(a,"instance"),f(a,"devices",{});let c=a;c.instance||(c.instance=new c);function v(y=100){return new Promise(r=>setTimeout(()=>r(),y))}function N(){return"serial"in navigator}const w={baudRate:9600,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"};class O extends h{constructor({filters:e=null,config_port:t=w,no_device:i=1,device_listen_on_channel:s=1}={filters:null,config_port:w,no_device:1,device_listen_on_channel:1}){super();S(this,n);f(this,"__internal__",{auto_response:!1,device_number:1,aux_port_connector:0,last_error:{message:null,action:null,code:null,no_code:0},serial:{connected:!1,port:null,last_action:null,response:{length:null,buffer:new Uint8Array([]),as:"hex",replacer:/[\n\r]+/g,limiter:null},reader:null,input_done:null,output_done:null,input_stream:null,output_stream:null,keep_reading:!0,time_until_send_bytes:void 0,delay_first_connection:200,bytes_connection:null,filters:[],config_port:w,queue:[],auto_response:["DD","DD"]},device:{type:"unknown",id:window.crypto.randomUUID(),listen_on_port:null},time:{response_connection:500,response_general:2e3},timeout:{until_response:0},interval:{reconnection:0}});if(!("serial"in navigator))throw new Error("Web Serial not supported");e&&(this.serialFilters=e),t&&(this.serialConfigPort=t),i&&o(this,n,I).call(this,i),s&&["number","string"].includes(typeof s)&&(this.listenOnChannel=s),o(this,n,L).call(this),o(this,n,D).call(this)}set listenOnChannel(e){if(typeof e=="string"&&(e=parseInt(e)),isNaN(e)||e<1||e>255)throw new Error("Invalid port number");this.__internal__.device.listen_on_port=e,this.__internal__.serial.bytes_connection=this.serialSetConnectionConstant(e)}get lastAction(){return this.__internal__.serial.last_action}get listenOnChannel(){return this.__internal__.device.listen_on_port??1}set serialFilters(e){this.__internal__.serial.filters=e}get serialFilters(){return this.__internal__.serial.filters}set serialConfigPort(e){this.__internal__.serial.config_port=e}get serialConfigPort(){return this.__internal__.serial.config_port}get isConnected(){const e=this.__internal__.serial.connected,t=o(this,n,g).call(this,this.__internal__.serial.port);return e&&!t&&o(this,n,b).call(this,{error:"Port is closed, not readable or writable."}),this.__internal__.serial.connected=t,this.__internal__.serial.connected}get isDisconnected(){const e=this.__internal__.serial.connected,t=o(this,n,g).call(this,this.__internal__.serial.port);return!e&&t&&(this.dispatch("serial:connected"),c.$dispatchChange(this)),this.__internal__.serial.connected=t,!this.__internal__.serial.connected}get deviceNumber(){return this.__internal__.device_number}get uuid(){return this.__internal__.device.id}get typeDevice(){return this.__internal__.device.type}get queue(){return this.__internal__.serial.queue}async timeout(e,t){this.__internal__.last_error.message="Operation response timed out.",this.__internal__.last_error.action=t,this.__internal__.last_error.code=e,this.__internal__.timeout.until_response&&(clearTimeout(this.__internal__.timeout.until_response),this.__internal__.timeout.until_response=0),t==="connect"?(this.__internal__.serial.connected=!1,this.dispatch("serial:reconnect",{}),c.$dispatchChange(this)):t==="connection:start"&&(await this.serialDisconnect(),this.__internal__.serial.connected=!1,this.__internal__.aux_port_connector+=1,c.$dispatchChange(this),await this.serialConnect()),this.dispatch("serial:timeout",{...this.__internal__.last_error,bytes:e,action:t})}async disconnect(e=null){await this.serialDisconnect(),o(this,n,b).call(this,e)}async connect(){return new Promise((e,t)=>{N()||t("Web Serial not supported"),setTimeout(async()=>{await v(499),await this.serialConnect(),this.isConnected?e(`${this.typeDevice} device ${this.deviceNumber} connected`):t(`${this.typeDevice} device ${this.deviceNumber} not connected`)},1)})}async serialDisconnect(){try{const e=this.__internal__.serial.reader,t=this.__internal__.serial.output_stream;e&&(await e.cancel().catch(s=>this.serialErrors(s)),await this.__internal__.serial.input_done),t&&(await t.getWriter().close(),await this.__internal__.serial.output_done),this.__internal__.serial.connected&&this.__internal__.serial&&this.__internal__.serial.port&&await this.__internal__.serial.port.close()}catch(e){this.serialErrors(e)}finally{this.__internal__.serial.reader=null,this.__internal__.serial.input_done=null,this.__internal__.serial.output_stream=null,this.__internal__.serial.output_done=null,this.__internal__.serial.connected=!1,this.__internal__.serial.port=null,c.$dispatchChange(this)}}getResponseAsArrayBuffer(){this.__internal__.serial.response.as="arraybuffer"}getResponseAsArrayHex(){this.__internal__.serial.response.as="hex"}getResponseAsUint8Array(){this.__internal__.serial.response.as="uint8"}getResponseAsString(){this.__internal__.serial.response.as="string"}async serialPortsSaved(e){const t=this.serialFilters;if(this.__internal__.aux_port_connector<e.length){const i=this.__internal__.aux_port_connector;this.__internal__.serial.port=e[i]}else this.__internal__.aux_port_connector=0,this.__internal__.serial.port=await navigator.serial.requestPort({filters:t});if(!this.__internal__.serial.port)throw new Error("Select another port please")}serialErrors(e){const t=e.toString().toLowerCase();switch(!0){case t.includes("must be handling a user gesture to show a permission request"):case t.includes("the port is closed."):case t.includes("the port is closed or is not writable"):case t.includes("the port is closed or is not readable"):case t.includes("the port is closed or is not readable/writable"):case t.includes("select another port please"):case t.includes("no port selected by the user"):case t.includes("this readable stream reader has been released and cannot be used to cancel its previous owner stream"):this.dispatch("serial:need-permission",{}),c.$dispatchChange(this);break;case t.includes("the port is already open."):case t.includes("failed to open serial port"):this.serialDisconnect().then(async()=>{this.__internal__.aux_port_connector+=1,await this.serialConnect()});break;case t.includes("cannot read properties of undefined (reading 'writable')"):case t.includes("cannot read properties of null (reading 'writable')"):case t.includes("cannot read property 'writable' of null"):case t.includes("cannot read property 'writable' of undefined"):this.serialDisconnect().then(async()=>{await this.serialConnect()});break;case t.includes("'close' on 'serialport': a call to close() is already in progress."):break;case t.includes("failed to execute 'open' on 'serialport': a call to open() is already in progress."):break;case t.includes("the port is already closed."):break;case t.includes("the device has been lost"):this.dispatch("serial:lost",{}),c.$dispatchChange(this);break;case t.includes("navigator.serial is undefined"):this.dispatch("serial:unsupported",{});break;default:console.error(e);break}this.dispatch("serial:error",e)}async serialConnect(){try{this.dispatch("serial:connecting",{});const e=await o(this,n,A).call(this);if(e.length>0)await this.serialPortsSaved(e);else{const s=this.serialFilters;this.__internal__.serial.port=await navigator.serial.requestPort({filters:s})}const t=this.__internal__.serial.port;if(!t)throw new Error("No port selected by the user");await t.open(this.serialConfigPort);const i=this;t.onconnect=s=>{console.log(s),i.dispatch("serial:connected",s),c.$dispatchChange(this),i.__internal__.serial.queue.length>0&&i.dispatch("internal:queue",{})},t.ondisconnect=async()=>{await i.disconnect()},await v(this.__internal__.serial.delay_first_connection),this.__internal__.timeout.until_response=setTimeout(async()=>{await i.timeout(i.__internal__.serial.bytes_connection??[],"connection:start")},this.__internal__.time.response_connection),this.__internal__.serial.last_action="connect",await o(this,n,m).call(this,this.__internal__.serial.bytes_connection??[]),this.dispatch("serial:sent",{action:"connect",bytes:this.__internal__.serial.bytes_connection}),this.__internal__.auto_response&&o(this,n,d).call(this,this.__internal__.serial.auto_response,null),await o(this,n,U).call(this)}catch(e){this.serialErrors(e)}}async serialForget(){return await o(this,n,P).call(this)}decToHex(e){return typeof e=="string"&&(e=parseInt(e,10)),e.toString(16)}hexToDec(e){return parseInt(e,16)}hexMaker(e="00",t=2){return e.toString().padStart(t,"0").toLowerCase()}add0x(e){const t=[];return e.forEach((i,s)=>{t[s]="0x"+i}),t}bytesToHex(e){return this.add0x(Array.from(e,t=>this.hexMaker(t)))}async appendToQueue(e,t){const i=this.bytesToHex(e);if(["connect","connection:start"].includes(t)){if(this.__internal__.serial.connected)return;await this.serialConnect();return}this.__internal__.serial.queue.push({bytes:i,action:t}),this.dispatch("internal:queue",{})}serialSetConnectionConstant(e=1){throw new Error(`Method not implemented 'serialSetConnectionConstant' to listen on channel ${e}`)}serialMessage(e){throw console.log(e),new Error("Method not implemented 'serialMessage'")}serialCorruptMessage(e,t){throw console.log(e,t),new Error("Method not implemented 'serialCorruptMessage'")}clearSerialQueue(){this.__internal__.serial.queue=[]}sumHex(e){let t=0;return e.forEach(i=>{t+=parseInt(i,16)}),t.toString(16)}toString(){return JSON.stringify({__class:this.typeDevice,device_number:this.deviceNumber,uuid:this.uuid,connected:this.isConnected,connection:this.__internal__.serial.bytes_connection})}softReload(){o(this,n,M).call(this),this.dispatch("serial:soft-reload",{})}async sendConnect(){if(!this.__internal__.serial.bytes_connection)throw new Error("No connection bytes defined");await this.appendToQueue(this.__internal__.serial.bytes_connection,"connect")}async sendCustomCode({code:e=[]}={code:[]}){if(e===null||e.length===0)throw new Error("No data to send");await this.appendToQueue(e,"custom")}stringToArrayHex(e){return Array.from(e).map(t=>t.charCodeAt(0).toString(16))}stringToArrayBuffer(e,t=`
1
+ (function(o,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(o=typeof globalThis<"u"?globalThis:o||self,_(o.WebSerialCore={}))})(this,function(o){"use strict";var O=Object.defineProperty;var C=o=>{throw TypeError(o)};var B=(o,_,h)=>_ in o?O(o,_,{enumerable:!0,configurable:!0,writable:!0,value:h}):o[_]=h;var p=(o,_,h)=>B(o,typeof _!="symbol"?_+"":_,h),R=(o,_,h)=>_.has(o)||C("Cannot "+h);var A=(o,_,h)=>_.has(o)?C("Cannot add the same private member more than once"):_ instanceof WeakSet?_.add(o):_.set(o,h);var l=(o,_,h)=>(R(o,_,"access private method"),h);var n,f,y,m,d,E,T,S,x,U,k,P,D,L,$,q,I;class _ extends CustomEvent{constructor(r,e){super(r,e)}}class h extends EventTarget{constructor(){super(...arguments);p(this,"__listeners__",{debug:!1});p(this,"__debug__",!1)}dispatch(e,t=null){const i=new _(e,{detail:t});this.dispatchEvent(i),this.__debug__&&this.dispatchEvent(new _("debug",{detail:{type:e,data:t}}))}dispatchAsync(e,t=null,i=100){const s=this;setTimeout(()=>{s.dispatch(e,t)},i)}on(e,t){typeof this.__listeners__[e]<"u"&&!this.__listeners__[e]&&(this.__listeners__[e]=!0),this.addEventListener(e,t)}off(e,t){this.removeEventListener(e,t)}serialRegisterAvailableListener(e){this.__listeners__[e]||(this.__listeners__[e]=!1)}get availableListeners(){return Object.keys(this.__listeners__).sort().map(t=>({type:t,listening:this.__listeners__[t]}))}}const a=class a extends h{constructor(){super(),["change"].forEach(e=>{this.serialRegisterAvailableListener(e)})}static $dispatchChange(r=null){r&&r.$checkAndDispatchConnection(),a.instance.dispatch("change",{devices:a.devices,dispatcher:r})}static typeError(r){const e=new Error;throw e.message=`Type ${r} is not supported`,e.name="DeviceTypeError",e}static registerType(r){typeof a.devices[r]>"u"&&(a.devices[r]={})}static add(r){const e=r.typeDevice;typeof a.devices[e]>"u"&&(a.devices[e]={});const t=r.uuid;if(typeof a.devices[e]>"u"&&a.typeError(e),a.devices[e][t])throw new Error(`Device with id ${t} already exists`);return a.devices[e][t]=r,a.$dispatchChange(r),Object.keys(a.devices[e]).indexOf(t)}static get(r,e){return typeof a.devices[r]>"u"&&(a.devices[r]={}),typeof a.devices[r]>"u"&&a.typeError(r),a.devices[r][e]}static getAll(r=null){return r===null?a.devices:(typeof a.devices[r]>"u"&&a.typeError(r),a.devices[r])}static getList(){return Object.values(a.devices).map(e=>Object.values(e)).flat()}static getByNumber(r,e){return typeof a.devices[r]>"u"&&a.typeError(r),Object.values(a.devices[r]).find(i=>i.deviceNumber===e)??null}static getCustom(r,e=1){return typeof a.devices[r]>"u"&&a.typeError(r),Object.values(a.devices[r]).find(i=>i.deviceNumber===e)??null}};p(a,"instance"),p(a,"devices",{});let c=a;c.instance||(c.instance=new c);function v(b=100){return new Promise(r=>setTimeout(()=>r(),b))}function M(){return"serial"in navigator}const w={baudRate:9600,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"};class N extends h{constructor({filters:e=null,config_port:t=w,no_device:i=1,device_listen_on_channel:s=1}={filters:null,config_port:w,no_device:1,device_listen_on_channel:1}){super();A(this,n);p(this,"__internal__",{auto_response:!1,device_number:1,aux_port_connector:0,last_error:{message:null,action:null,code:null,no_code:0},serial:{connected:!1,port:null,last_action:null,response:{length:null,buffer:new Uint8Array([]),as:"uint8",replacer:/[\n\r]+/g,limiter:null},reader:null,input_done:null,output_done:null,input_stream:null,output_stream:null,keep_reading:!0,time_until_send_bytes:void 0,delay_first_connection:200,bytes_connection:null,filters:[],config_port:w,queue:[],auto_response:["DD","DD"]},device:{type:"unknown",id:window.crypto.randomUUID(),listen_on_port:null},time:{response_connection:500,response_general:2e3},timeout:{until_response:0},interval:{reconnection:0}});if(!("serial"in navigator))throw new Error("Web Serial not supported");e&&(this.serialFilters=e),t&&(this.serialConfigPort=t),i&&l(this,n,q).call(this,i),s&&["number","string"].includes(typeof s)&&(this.listenOnChannel=s),l(this,n,P).call(this),l(this,n,D).call(this)}set listenOnChannel(e){if(typeof e=="string"&&(e=parseInt(e)),isNaN(e)||e<1||e>255)throw new Error("Invalid port number");this.__internal__.device.listen_on_port=e,this.__internal__.serial.bytes_connection=this.serialSetConnectionConstant(e)}get lastAction(){return this.__internal__.serial.last_action}get listenOnChannel(){return this.__internal__.device.listen_on_port??1}set serialFilters(e){this.__internal__.serial.filters=e}get serialFilters(){return this.__internal__.serial.filters}set serialConfigPort(e){this.__internal__.serial.config_port=e}get serialConfigPort(){return this.__internal__.serial.config_port}get isConnected(){const e=this.__internal__.serial.connected,t=l(this,n,f).call(this,this.__internal__.serial.port);return e&&!t&&l(this,n,y).call(this,{error:"Port is closed, not readable or writable."}),this.__internal__.serial.connected=t,this.__internal__.serial.connected}get isDisconnected(){const e=this.__internal__.serial.connected,t=l(this,n,f).call(this,this.__internal__.serial.port);return!e&&t&&(this.dispatch("serial:connected"),c.$dispatchChange(this)),this.__internal__.serial.connected=t,!this.__internal__.serial.connected}get deviceNumber(){return this.__internal__.device_number}get uuid(){return this.__internal__.device.id}get typeDevice(){return this.__internal__.device.type}get queue(){return this.__internal__.serial.queue}async timeout(e,t){this.__internal__.last_error.message="Operation response timed out.",this.__internal__.last_error.action=t,this.__internal__.last_error.code=e,this.__internal__.timeout.until_response&&(clearTimeout(this.__internal__.timeout.until_response),this.__internal__.timeout.until_response=0),t==="connect"?(this.__internal__.serial.connected=!1,this.dispatch("serial:reconnect",{}),c.$dispatchChange(this)):t==="connection:start"&&(await this.serialDisconnect(),this.__internal__.serial.connected=!1,this.__internal__.aux_port_connector+=1,c.$dispatchChange(this),await this.serialConnect()),this.dispatch("serial:timeout",{...this.__internal__.last_error,bytes:e,action:t})}async disconnect(e=null){await this.serialDisconnect(),l(this,n,y).call(this,e)}async connect(){return new Promise((e,t)=>{M()||t("Web Serial not supported"),setTimeout(async()=>{await v(499),await this.serialConnect(),this.isConnected?e(`${this.typeDevice} device ${this.deviceNumber} connected`):t(`${this.typeDevice} device ${this.deviceNumber} not connected`)},1)})}async serialDisconnect(){try{const e=this.__internal__.serial.reader,t=this.__internal__.serial.output_stream;e&&(await e.cancel().catch(s=>this.serialErrors(s)),await this.__internal__.serial.input_done),t&&(await t.getWriter().close(),await this.__internal__.serial.output_done),this.__internal__.serial.connected&&this.__internal__.serial&&this.__internal__.serial.port&&await this.__internal__.serial.port.close()}catch(e){this.serialErrors(e)}finally{this.__internal__.serial.reader=null,this.__internal__.serial.input_done=null,this.__internal__.serial.output_stream=null,this.__internal__.serial.output_done=null,this.__internal__.serial.connected=!1,this.__internal__.serial.port=null,c.$dispatchChange(this)}}getResponseAsArrayBuffer(){this.__internal__.serial.response.as="arraybuffer"}getResponseAsArrayHex(){this.__internal__.serial.response.as="hex"}getResponseAsUint8Array(){this.__internal__.serial.response.as="uint8"}getResponseAsString(){this.__internal__.serial.response.as="string"}async serialPortsSaved(e){const t=this.serialFilters;if(this.__internal__.aux_port_connector<e.length){const i=this.__internal__.aux_port_connector;this.__internal__.serial.port=e[i]}else this.__internal__.aux_port_connector=0,this.__internal__.serial.port=await navigator.serial.requestPort({filters:t});if(!this.__internal__.serial.port)throw new Error("Select another port please")}serialErrors(e){const t=e.toString().toLowerCase();switch(!0){case t.includes("must be handling a user gesture to show a permission request"):case t.includes("the port is closed."):case t.includes("the port is closed or is not writable"):case t.includes("the port is closed or is not readable"):case t.includes("the port is closed or is not readable/writable"):case t.includes("select another port please"):case t.includes("no port selected by the user"):case t.includes("this readable stream reader has been released and cannot be used to cancel its previous owner stream"):this.dispatch("serial:need-permission",{}),c.$dispatchChange(this);break;case t.includes("the port is already open."):case t.includes("failed to open serial port"):this.serialDisconnect().then(async()=>{this.__internal__.aux_port_connector+=1,await this.serialConnect()});break;case t.includes("cannot read properties of undefined (reading 'writable')"):case t.includes("cannot read properties of null (reading 'writable')"):case t.includes("cannot read property 'writable' of null"):case t.includes("cannot read property 'writable' of undefined"):this.serialDisconnect().then(async()=>{await this.serialConnect()});break;case t.includes("'close' on 'serialport': a call to close() is already in progress."):break;case t.includes("failed to execute 'open' on 'serialport': a call to open() is already in progress."):break;case t.includes("the port is already closed."):break;case t.includes("the device has been lost"):this.dispatch("serial:lost",{}),c.$dispatchChange(this);break;case t.includes("navigator.serial is undefined"):this.dispatch("serial:unsupported",{});break;default:console.error(e);break}this.dispatch("serial:error",e)}async serialConnect(){try{this.dispatch("serial:connecting",{});const e=await l(this,n,E).call(this);if(e.length>0)await this.serialPortsSaved(e);else{const s=this.serialFilters;this.__internal__.serial.port=await navigator.serial.requestPort({filters:s})}const t=this.__internal__.serial.port;if(!t)throw new Error("No port selected by the user");await t.open(this.serialConfigPort);const i=this;t.onconnect=s=>{console.log(s),i.dispatch("serial:connected",s),c.$dispatchChange(this),i.__internal__.serial.queue.length>0&&i.dispatch("internal:queue",{})},t.ondisconnect=async()=>{await i.disconnect()},await v(this.__internal__.serial.delay_first_connection),this.__internal__.timeout.until_response=setTimeout(async()=>{await i.timeout(i.__internal__.serial.bytes_connection??[],"connection:start")},this.__internal__.time.response_connection),this.__internal__.serial.last_action="connect",await l(this,n,m).call(this,this.__internal__.serial.bytes_connection??[]),this.dispatch("serial:sent",{action:"connect",bytes:this.__internal__.serial.bytes_connection}),this.__internal__.auto_response&&l(this,n,d).call(this,this.__internal__.serial.auto_response,null),await l(this,n,U).call(this)}catch(e){this.serialErrors(e)}}async serialForget(){return await l(this,n,k).call(this)}decToHex(e){return typeof e=="string"&&(e=parseInt(e,10)),e.toString(16)}hexToDec(e){return parseInt(e,16)}hexMaker(e="00",t=2){return e.toString().padStart(t,"0").toLowerCase()}add0x(e){const t=[];return e.forEach((i,s)=>{t[s]="0x"+i}),t}bytesToHex(e){return this.add0x(Array.from(e,t=>this.hexMaker(t)))}validateBytes(e){let t=new Uint8Array(0);if(e instanceof Uint8Array)t=e;else if(typeof e=="string")t=this.parseStringToTextEncoder(e);else if(Array.isArray(e)&&typeof e[0]=="string")t=this.stringArrayToUint8Array(e);else if(Array.isArray(e)&&typeof e[0]=="number")t=new Uint8Array(e);else throw new Error("Invalid data type");return t}async appendToQueue(e,t){const i=this.validateBytes(e);if(["connect","connection:start"].includes(t)){if(this.__internal__.serial.connected)return;await this.serialConnect();return}this.__internal__.serial.queue.push({bytes:i,action:t}),this.dispatch("internal:queue",{})}serialSetConnectionConstant(e=1){throw new Error(`Method not implemented 'serialSetConnectionConstant' to listen on channel ${e}`)}serialMessage(e){throw console.log(e),new Error("Method not implemented 'serialMessage'")}serialCorruptMessage(e,t){throw console.log(e,t),new Error("Method not implemented 'serialCorruptMessage'")}clearSerialQueue(){this.__internal__.serial.queue=[]}sumHex(e){let t=0;return e.forEach(i=>{t+=parseInt(i,16)}),t.toString(16)}toString(){return JSON.stringify({__class:this.typeDevice,device_number:this.deviceNumber,uuid:this.uuid,connected:this.isConnected,connection:this.__internal__.serial.bytes_connection})}softReload(){l(this,n,I).call(this),this.dispatch("serial:soft-reload",{})}async sendConnect(){if(!this.__internal__.serial.bytes_connection)throw new Error("No connection bytes defined");await this.appendToQueue(this.__internal__.serial.bytes_connection,"connect")}async sendCustomCode({code:e=[]}={code:[]}){if(e===null||e.length===0)throw new Error("No data to send");await this.appendToQueue(e,"custom")}stringToArrayHex(e){return Array.from(e).map(t=>t.charCodeAt(0).toString(16))}stringToArrayBuffer(e,t=`
2
2
  `){return this.parseStringToTextEncoder(e,t).buffer}parseStringToTextEncoder(e="",t=`
3
3
  `){const i=new TextEncoder;return e+=t,i.encode(e)}parseStringToBytes(e="",t=`
4
- `){const i=this.parseStringToTextEncoder(e,t);return Array.from(i).map(s=>s.toString(16))}parseUint8ToHex(e){return Array.from(e).map(t=>t.toString(16))}parseHexToUint8(e){return new Uint8Array(e.map(t=>parseInt(t,16)))}stringArrayToUint8Array(e){const t=[];return e.forEach(i=>{const s=i.replace("0x","");t.push(parseInt(s,16))}),new Uint8Array(t)}parseUint8ArrayToString(e){const t=this.stringArrayToUint8Array(e);e=this.parseUint8ToHex(t);const i=e.map(s=>parseInt(s,16));return this.__internal__.serial.response.replacer?String.fromCharCode(...i).replace(this.__internal__.serial.response.replacer,""):String.fromCharCode(...i)}hexToAscii(e){const t=e.toString();let i="";for(let s=0;s<t.length;s+=2)i+=String.fromCharCode(parseInt(t.substring(s,2),16));return i}asciiToHex(e){const t=[];for(let i=0,s=e.length;i<s;i++){const u=Number(e.charCodeAt(i)).toString(16);t.push(u)}return t.join("")}$checkAndDispatchConnection(){return this.isConnected}}n=new WeakSet,g=function(e){return!!(e&&e.readable&&e.writable)},b=function(e=null){this.__internal__.serial.connected=!1,this.__internal__.aux_port_connector=0,this.dispatch("serial:disconnected",e),c.$dispatchChange(this)},m=async function(e){const t=this.__internal__.serial.port;if(!t||t&&(!t.readable||!t.writable))throw o(this,n,b).call(this,{error:"Port is closed, not readable or writable."}),new Error("The port is closed or is not readable/writable");const i=this.stringArrayToUint8Array(e);if(t.writable===null)return;const s=t.writable.getWriter();await s.write(i),s.releaseLock()},d=function(e=[],t=null){if(e&&e.length>0){const i=this.__internal__.serial.connected;this.__internal__.serial.connected=o(this,n,g).call(this,this.__internal__.serial.port),c.$dispatchChange(this),!i&&this.__internal__.serial.connected&&this.dispatch("serial:connected"),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 u in e)s.push(e[u].toString().padStart(2,"0").toLowerCase());if(this.__internal__.serial.response.as==="hex")this.serialMessage(s);else if(this.__internal__.serial.response.as==="uint8")this.serialMessage(this.parseHexToUint8(this.add0x(s)));else if(this.__internal__.serial.response.as==="string")if(this.__internal__.serial.response.limiter!==null){const p=this.parseUint8ArrayToString(this.add0x(s)).split(this.__internal__.serial.response.limiter);for(const C in p)p[C]&&this.serialMessage(p[C])}else this.serialMessage(this.parseUint8ArrayToString(this.add0x(s)));else{const u=this.stringToArrayBuffer(this.parseUint8ArrayToString(this.add0x(s)));this.serialMessage(u)}}else this.serialCorruptMessage(e,t);this.__internal__.serial.queue.length!==0&&this.dispatch("internal:queue",{})},A=async function(){const e=this.serialFilters,t=await navigator.serial.getPorts({filters:e});return e.length===0?t:t.filter(s=>{const u=s.getInfo();return e.some(p=>u.usbProductId===p.usbProductId&&u.usbVendorId===p.usbVendorId)}).filter(s=>!o(this,n,g).call(this,s))},T=function(e){if(e){const t=this.__internal__.serial.response.buffer,i=new Uint8Array(t.length+e.byteLength);i.set(t,0),i.set(new Uint8Array(e),t.length),this.__internal__.serial.response.buffer=i}},E=async function(){this.__internal__.serial.time_until_send_bytes&&(clearTimeout(this.__internal__.serial.time_until_send_bytes),this.__internal__.serial.time_until_send_bytes=0),this.__internal__.serial.time_until_send_bytes=setTimeout(()=>{const e=[];for(const t in this.__internal__.serial.response.buffer)e.push(this.__internal__.serial.response.buffer[t].toString(16));this.__internal__.serial.response.buffer&&o(this,n,d).call(this,e),this.__internal__.serial.response.buffer=new Uint8Array(0)},400)},k=async function(){if(this.__internal__.serial.response.length!==null){if(this.__internal__.serial.response.length===this.__internal__.serial.response.buffer.length){const e=[];for(const t in this.__internal__.serial.response.buffer)e.push(this.__internal__.serial.response.buffer[t].toString(16));o(this,n,d).call(this,e),this.__internal__.serial.response.buffer=new Uint8Array(0)}else if(this.__internal__.serial.response.length<this.__internal__.serial.response.buffer.length){let e=new Uint8Array(0);for(let i=0;i<this.__internal__.serial.response.length;i++)e[i]=this.__internal__.serial.response.buffer[i];if(e.length===this.__internal__.serial.response.length){const i=[];for(const s in e)i.push(e[s].toString(16));o(this,n,d).call(this,i),this.__internal__.serial.response.buffer=new Uint8Array(0);return}e=new Uint8Array(0);const t=this.__internal__.serial.response.length*2;if(this.__internal__.serial.response.buffer.length===t){for(let i=14;i<t;i++)e[i-this.__internal__.serial.response.length]=this.__internal__.serial.response.buffer[i];if(e.length===this.__internal__.serial.response.length){const i=[];for(const s in e)i.push(e[s].toString(16));o(this,n,d).call(this,i),this.__internal__.serial.response.buffer=new Uint8Array(0)}}}}},U=async function(){const e=this.__internal__.serial.port;if(!e||!e.readable)throw new Error("Port is not readable");for(;e.readable&&this.__internal__.serial.keep_reading;){const t=e.readable.getReader();this.__internal__.serial.reader=t;try{let i=!0;for(;i;){const{value:s,done:u}=await t.read();if(u){t.releaseLock(),this.__internal__.serial.keep_reading=!1,i=!1;break}o(this,n,T).call(this,s),this.__internal__.serial.response.length===null?await o(this,n,E).call(this):await o(this,n,k).call(this)}}catch(i){this.serialErrors(i)}finally{t.releaseLock()}}this.__internal__.serial.keep_reading=!0,this.__internal__.serial.port&&await this.__internal__.serial.port.close()},P=async function(){return typeof window>"u"?!1:"serial"in navigator&&"forget"in SerialPort.prototype&&this.__internal__.serial.port?(await this.__internal__.serial.port.forget(),!0):!1},L=function(){["serial:connected","serial:connecting","serial:reconnect","serial:timeout","serial:disconnected","serial:sent","serial:soft-reload","serial:message","unknown","serial:need-permission","serial:lost","serial:unsupported","serial:error","debug"].forEach(t=>{this.serialRegisterAvailableListener(t)})},D=function(){const e=this;this.on("internal:queue",async()=>{var t;await o(t=e,n,q).call(t)}),o(this,n,$).call(this)},$=function(){const e=this;navigator.serial.addEventListener("connect",async()=>{e.isDisconnected&&await e.serialConnect().catch(()=>{})})},q=async function(){if(!o(this,n,g).call(this,this.__internal__.serial.port)){o(this,n,b).call(this,{error:"Port is closed, not readable or writable."}),await this.serialConnect();return}if(this.__internal__.timeout.until_response||this.__internal__.serial.queue.length===0)return;const e=this.__internal__.serial.queue[0];let t=this.__internal__.time.response_general;e.action==="connect"&&(t=this.__internal__.time.response_connection),this.__internal__.timeout.until_response=setTimeout(async()=>{await this.timeout(e.bytes,e.action)},t),this.__internal__.serial.last_action=e.action??"unknown",await o(this,n,m).call(this,e.bytes),this.dispatch("serial:sent",{action:e.action,bytes:e.bytes}),this.__internal__.auto_response&&o(this,n,d).call(this,this.__internal__.serial.auto_response,null);const i=[...this.__internal__.serial.queue];this.__internal__.serial.queue=i.splice(1)},I=function(e=1){this.__internal__.device_number=e,this.__internal__.serial.bytes_connection=this.serialSetConnectionConstant(e)},M=function(){this.__internal__.last_error={message:null,action:null,code:null,no_code:0}},l.Core=O,l.Devices=c,l.Dispatcher=h,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
4
+ `){const i=this.parseStringToTextEncoder(e,t);return Array.from(i).map(s=>s.toString(16))}parseUint8ToHex(e){return Array.from(e).map(t=>t.toString(16))}parseHexToUint8(e){return new Uint8Array(e.map(t=>parseInt(t,16)))}stringArrayToUint8Array(e){const t=[];return e.forEach(i=>{const s=i.replace("0x","");t.push(parseInt(s,16))}),new Uint8Array(t)}parseUint8ArrayToString(e){let t=new Uint8Array(0);e instanceof Uint8Array?t=e:t=this.stringArrayToUint8Array(e),e=this.parseUint8ToHex(t);const i=e.map(s=>parseInt(s,16));return this.__internal__.serial.response.replacer?String.fromCharCode(...i).replace(this.__internal__.serial.response.replacer,""):String.fromCharCode(...i)}hexToAscii(e){const t=e.toString();let i="";for(let s=0;s<t.length;s+=2)i+=String.fromCharCode(parseInt(t.substring(s,2),16));return i}asciiToHex(e){const t=[];for(let i=0,s=e.length;i<s;i++){const u=Number(e.charCodeAt(i)).toString(16);t.push(u)}return t.join("")}$checkAndDispatchConnection(){return this.isConnected}}n=new WeakSet,f=function(e){return!!(e&&e.readable&&e.writable)},y=function(e=null){this.__internal__.serial.connected=!1,this.__internal__.aux_port_connector=0,this.dispatch("serial:disconnected",e),c.$dispatchChange(this)},m=async function(e){const t=this.__internal__.serial.port;if(!t||t&&(!t.readable||!t.writable))throw l(this,n,y).call(this,{error:"Port is closed, not readable or writable."}),new Error("The port is closed or is not readable/writable");const i=this.validateBytes(e);if(t.writable===null)return;const s=t.writable.getWriter();await s.write(i),s.releaseLock()},d=function(e=new Uint8Array([]),t=null){if(e&&e.length>0){const i=this.__internal__.serial.connected;if(this.__internal__.serial.connected=l(this,n,f).call(this,this.__internal__.serial.port),c.$dispatchChange(this),!i&&this.__internal__.serial.connected&&this.dispatch("serial:connected"),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),this.__internal__.serial.response.as==="hex")this.serialMessage(this.parseUint8ToHex(e));else if(this.__internal__.serial.response.as==="uint8")this.serialMessage(e);else if(this.__internal__.serial.response.as==="string"){const s=this.parseUint8ArrayToString(e);if(this.__internal__.serial.response.limiter!==null){const u=s.split(this.__internal__.serial.response.limiter);for(const g in u)u[g]&&this.serialMessage(u[g])}else this.serialMessage(s)}else{const s=this.stringToArrayBuffer(this.parseUint8ArrayToString(e));this.serialMessage(s)}}else this.serialCorruptMessage(e,t);this.__internal__.serial.queue.length!==0&&this.dispatch("internal:queue",{})},E=async function(){const e=this.serialFilters,t=await navigator.serial.getPorts({filters:e});return e.length===0?t:t.filter(s=>{const u=s.getInfo();return e.some(g=>u.usbProductId===g.usbProductId&&u.usbVendorId===g.usbVendorId)}).filter(s=>!l(this,n,f).call(this,s))},T=function(e){if(e){const t=this.__internal__.serial.response.buffer,i=new Uint8Array(t.length+e.byteLength);i.set(t,0),i.set(new Uint8Array(e),t.length),this.__internal__.serial.response.buffer=i}},S=async function(){this.__internal__.serial.time_until_send_bytes&&(clearTimeout(this.__internal__.serial.time_until_send_bytes),this.__internal__.serial.time_until_send_bytes=0),this.__internal__.serial.time_until_send_bytes=setTimeout(()=>{this.__internal__.serial.response.buffer&&l(this,n,d).call(this,this.__internal__.serial.response.buffer),this.__internal__.serial.response.buffer=new Uint8Array(0)},400)},x=async function(){if(this.__internal__.serial.response.length!==null){if(this.__internal__.serial.response.length===this.__internal__.serial.response.buffer.length)l(this,n,d).call(this,this.__internal__.serial.response.buffer),this.__internal__.serial.response.buffer=new Uint8Array(0);else if(this.__internal__.serial.response.length<this.__internal__.serial.response.buffer.length){let e=new Uint8Array(0);for(let i=0;i<this.__internal__.serial.response.length;i++)e[i]=this.__internal__.serial.response.buffer[i];if(e.length===this.__internal__.serial.response.length){l(this,n,d).call(this,e),this.__internal__.serial.response.buffer=new Uint8Array(0);return}e=new Uint8Array(0);const t=this.__internal__.serial.response.length*2;if(this.__internal__.serial.response.buffer.length===t){for(let i=14;i<t;i++)e[i-this.__internal__.serial.response.length]=this.__internal__.serial.response.buffer[i];e.length===this.__internal__.serial.response.length&&(l(this,n,d).call(this,e),this.__internal__.serial.response.buffer=new Uint8Array(0))}}}},U=async function(){const e=this.__internal__.serial.port;if(!e||!e.readable)throw new Error("Port is not readable");for(;e.readable&&this.__internal__.serial.keep_reading;){const t=e.readable.getReader();this.__internal__.serial.reader=t;try{let i=!0;for(;i;){const{value:s,done:u}=await t.read();if(u){t.releaseLock(),this.__internal__.serial.keep_reading=!1,i=!1;break}l(this,n,T).call(this,s),this.__internal__.serial.response.length===null?await l(this,n,S).call(this):await l(this,n,x).call(this)}}catch(i){this.serialErrors(i)}finally{t.releaseLock()}}this.__internal__.serial.keep_reading=!0,this.__internal__.serial.port&&await this.__internal__.serial.port.close()},k=async function(){return typeof window>"u"?!1:"serial"in navigator&&"forget"in SerialPort.prototype&&this.__internal__.serial.port?(await this.__internal__.serial.port.forget(),!0):!1},P=function(){["serial:connected","serial:connecting","serial:reconnect","serial:timeout","serial:disconnected","serial:sent","serial:soft-reload","serial:message","unknown","serial:need-permission","serial:lost","serial:unsupported","serial:error","debug"].forEach(t=>{this.serialRegisterAvailableListener(t)})},D=function(){const e=this;this.on("internal:queue",async()=>{var t;await l(t=e,n,$).call(t)}),l(this,n,L).call(this)},L=function(){const e=this;navigator.serial.addEventListener("connect",async()=>{e.isDisconnected&&await e.serialConnect().catch(()=>{})})},$=async function(){if(!l(this,n,f).call(this,this.__internal__.serial.port)){l(this,n,y).call(this,{error:"Port is closed, not readable or writable."}),await this.serialConnect();return}if(this.__internal__.timeout.until_response||this.__internal__.serial.queue.length===0)return;const e=this.__internal__.serial.queue[0];let t=this.__internal__.time.response_general;if(e.action==="connect"&&(t=this.__internal__.time.response_connection),this.__internal__.timeout.until_response=setTimeout(async()=>{await this.timeout(e.bytes,e.action)},t),this.__internal__.serial.last_action=e.action??"unknown",await l(this,n,m).call(this,e.bytes),this.dispatch("serial:sent",{action:e.action,bytes:e.bytes}),this.__internal__.auto_response){let s=new Uint8Array(0);try{s=this.validateBytes(this.__internal__.serial.auto_response)}catch(u){this.serialErrors(u)}l(this,n,d).call(this,s,null)}const i=[...this.__internal__.serial.queue];this.__internal__.serial.queue=i.splice(1)},q=function(e=1){this.__internal__.device_number=e,this.__internal__.serial.bytes_connection=this.serialSetConnectionConstant(e)},I=function(){this.__internal__.last_error={message:null,action:null,code:null,no_code:0}},o.Core=N,o.Devices=c,o.Dispatcher=h,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "webserial-core",
3
3
  "description": "Webserial Core to easy connections with serial devices",
4
- "version": "1.0.6",
4
+ "version": "1.0.7",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": "danidoble",