@medplum/agent 3.1.3 → 3.1.5
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/cjs/index.cjs +51 -3489
- package/package.json +6 -7
package/dist/cjs/index.cjs
CHANGED
|
@@ -5,7 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
8
|
var __commonJS = (cb, mod) => function __require() {
|
|
10
9
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
10
|
};
|
|
@@ -30,10 +29,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
29
|
mod
|
|
31
30
|
));
|
|
32
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
|
-
var __publicField = (obj, key, value) => {
|
|
34
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
35
|
-
return value;
|
|
36
|
-
};
|
|
37
32
|
|
|
38
33
|
// ../../node_modules/ws/lib/stream.js
|
|
39
34
|
var require_stream = __commonJS({
|
|
@@ -882,8 +877,6 @@ var require_receiver = __commonJS({
|
|
|
882
877
|
var { concat, toArrayBuffer, unmask } = require_buffer_util();
|
|
883
878
|
var { isValidStatusCode, isValidUTF8 } = require_validation();
|
|
884
879
|
var FastBuffer = Buffer[Symbol.species];
|
|
885
|
-
var promise = Promise.resolve();
|
|
886
|
-
var queueTask = typeof queueMicrotask === "function" ? queueMicrotask : queueMicrotaskShim;
|
|
887
880
|
var GET_INFO = 0;
|
|
888
881
|
var GET_PAYLOAD_LENGTH_16 = 1;
|
|
889
882
|
var GET_PAYLOAD_LENGTH_64 = 2;
|
|
@@ -896,7 +889,7 @@ var require_receiver = __commonJS({
|
|
|
896
889
|
* Creates a Receiver instance.
|
|
897
890
|
*
|
|
898
891
|
* @param {Object} [options] Options object
|
|
899
|
-
* @param {Boolean} [options.allowSynchronousEvents=
|
|
892
|
+
* @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether
|
|
900
893
|
* any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
|
|
901
894
|
* multiple times in the same tick
|
|
902
895
|
* @param {String} [options.binaryType=nodebuffer] The type for binary data
|
|
@@ -910,7 +903,7 @@ var require_receiver = __commonJS({
|
|
|
910
903
|
*/
|
|
911
904
|
constructor(options = {}) {
|
|
912
905
|
super();
|
|
913
|
-
this._allowSynchronousEvents =
|
|
906
|
+
this._allowSynchronousEvents = options.allowSynchronousEvents !== void 0 ? options.allowSynchronousEvents : true;
|
|
914
907
|
this._binaryType = options.binaryType || BINARY_TYPES[0];
|
|
915
908
|
this._extensions = options.extensions || {};
|
|
916
909
|
this._isServer = !!options.isServer;
|
|
@@ -1344,12 +1337,12 @@ var require_receiver = __commonJS({
|
|
|
1344
1337
|
} else {
|
|
1345
1338
|
data2 = fragments;
|
|
1346
1339
|
}
|
|
1347
|
-
if (this.
|
|
1340
|
+
if (this._allowSynchronousEvents) {
|
|
1348
1341
|
this.emit("message", data2, true);
|
|
1349
1342
|
this._state = GET_INFO;
|
|
1350
1343
|
} else {
|
|
1351
1344
|
this._state = DEFER_EVENT;
|
|
1352
|
-
|
|
1345
|
+
setImmediate(() => {
|
|
1353
1346
|
this.emit("message", data2, true);
|
|
1354
1347
|
this._state = GET_INFO;
|
|
1355
1348
|
this.startLoop(cb);
|
|
@@ -1373,7 +1366,7 @@ var require_receiver = __commonJS({
|
|
|
1373
1366
|
this._state = GET_INFO;
|
|
1374
1367
|
} else {
|
|
1375
1368
|
this._state = DEFER_EVENT;
|
|
1376
|
-
|
|
1369
|
+
setImmediate(() => {
|
|
1377
1370
|
this.emit("message", buf, false);
|
|
1378
1371
|
this._state = GET_INFO;
|
|
1379
1372
|
this.startLoop(cb);
|
|
@@ -1435,7 +1428,7 @@ var require_receiver = __commonJS({
|
|
|
1435
1428
|
this._state = GET_INFO;
|
|
1436
1429
|
} else {
|
|
1437
1430
|
this._state = DEFER_EVENT;
|
|
1438
|
-
|
|
1431
|
+
setImmediate(() => {
|
|
1439
1432
|
this.emit(this._opcode === 9 ? "ping" : "pong", data2);
|
|
1440
1433
|
this._state = GET_INFO;
|
|
1441
1434
|
this.startLoop(cb);
|
|
@@ -1467,15 +1460,6 @@ var require_receiver = __commonJS({
|
|
|
1467
1460
|
}
|
|
1468
1461
|
};
|
|
1469
1462
|
module2.exports = Receiver2;
|
|
1470
|
-
function queueMicrotaskShim(cb) {
|
|
1471
|
-
promise.then(cb).catch(throwErrorNextTick);
|
|
1472
|
-
}
|
|
1473
|
-
function throwError(err) {
|
|
1474
|
-
throw err;
|
|
1475
|
-
}
|
|
1476
|
-
function throwErrorNextTick(err) {
|
|
1477
|
-
process.nextTick(throwError, err);
|
|
1478
|
-
}
|
|
1479
1463
|
}
|
|
1480
1464
|
});
|
|
1481
1465
|
|
|
@@ -2781,7 +2765,7 @@ var require_websocket = __commonJS({
|
|
|
2781
2765
|
module2.exports = WebSocket3;
|
|
2782
2766
|
function initAsClient(websocket, address, protocols, options) {
|
|
2783
2767
|
const opts = {
|
|
2784
|
-
allowSynchronousEvents:
|
|
2768
|
+
allowSynchronousEvents: true,
|
|
2785
2769
|
autoPong: true,
|
|
2786
2770
|
protocolVersion: protocolVersions[1],
|
|
2787
2771
|
maxPayload: 100 * 1024 * 1024,
|
|
@@ -2790,7 +2774,6 @@ var require_websocket = __commonJS({
|
|
|
2790
2774
|
followRedirects: false,
|
|
2791
2775
|
maxRedirects: 10,
|
|
2792
2776
|
...options,
|
|
2793
|
-
createConnection: void 0,
|
|
2794
2777
|
socketPath: void 0,
|
|
2795
2778
|
hostname: void 0,
|
|
2796
2779
|
protocol: void 0,
|
|
@@ -2846,7 +2829,7 @@ var require_websocket = __commonJS({
|
|
|
2846
2829
|
const request = isSecure ? https.request : http.request;
|
|
2847
2830
|
const protocolSet = /* @__PURE__ */ new Set();
|
|
2848
2831
|
let perMessageDeflate;
|
|
2849
|
-
opts.createConnection = isSecure ? tlsConnect : netConnect;
|
|
2832
|
+
opts.createConnection = opts.createConnection || (isSecure ? tlsConnect : netConnect);
|
|
2850
2833
|
opts.defaultPort = opts.defaultPort || defaultPort;
|
|
2851
2834
|
opts.port = parsedUrl.port || defaultPort;
|
|
2852
2835
|
opts.host = parsedUrl.hostname.startsWith("[") ? parsedUrl.hostname.slice(1, -1) : parsedUrl.hostname;
|
|
@@ -3246,7 +3229,7 @@ var require_websocket_server = __commonJS({
|
|
|
3246
3229
|
* Create a `WebSocketServer` instance.
|
|
3247
3230
|
*
|
|
3248
3231
|
* @param {Object} options Configuration options
|
|
3249
|
-
* @param {Boolean} [options.allowSynchronousEvents=
|
|
3232
|
+
* @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether
|
|
3250
3233
|
* any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
|
|
3251
3234
|
* multiple times in the same tick
|
|
3252
3235
|
* @param {Boolean} [options.autoPong=true] Specifies whether or not to
|
|
@@ -3276,7 +3259,7 @@ var require_websocket_server = __commonJS({
|
|
|
3276
3259
|
constructor(options, callback) {
|
|
3277
3260
|
super();
|
|
3278
3261
|
options = {
|
|
3279
|
-
allowSynchronousEvents:
|
|
3262
|
+
allowSynchronousEvents: true,
|
|
3280
3263
|
autoPong: true,
|
|
3281
3264
|
maxPayload: 100 * 1024 * 1024,
|
|
3282
3265
|
skipUTF8Validation: false,
|
|
@@ -11196,13 +11179,13 @@ var require_dcmjs = __commonJS({
|
|
|
11196
11179
|
key: "xyz2LAB",
|
|
11197
11180
|
value: function xyz2LAB(xyz) {
|
|
11198
11181
|
var whitePoint = Colors2.d65WhitePointXYZ();
|
|
11199
|
-
var
|
|
11182
|
+
var X = xyz[0] / whitePoint[0];
|
|
11200
11183
|
var Y = xyz[1] / whitePoint[1];
|
|
11201
11184
|
var Z2 = xyz[2] / whitePoint[2];
|
|
11202
|
-
|
|
11185
|
+
X = Colors2.labf(X);
|
|
11203
11186
|
Y = Colors2.labf(Y);
|
|
11204
11187
|
Z2 = Colors2.labf(Z2);
|
|
11205
|
-
return [116 * Y - 16, 500 * (
|
|
11188
|
+
return [116 * Y - 16, 500 * (X - Y), 200 * (Y - Z2)];
|
|
11206
11189
|
}
|
|
11207
11190
|
}, {
|
|
11208
11191
|
key: "lab2RGB",
|
|
@@ -37022,3289 +37005,6 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
37022
37005
|
}
|
|
37023
37006
|
});
|
|
37024
37007
|
|
|
37025
|
-
// ../../node_modules/@serialport/parser-byte-length/dist/index.js
|
|
37026
|
-
var require_dist = __commonJS({
|
|
37027
|
-
"../../node_modules/@serialport/parser-byte-length/dist/index.js"(exports2) {
|
|
37028
|
-
"use strict";
|
|
37029
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
37030
|
-
exports2.ByteLengthParser = void 0;
|
|
37031
|
-
var stream_1 = require("stream");
|
|
37032
|
-
var ByteLengthParser = class extends stream_1.Transform {
|
|
37033
|
-
constructor(options) {
|
|
37034
|
-
super(options);
|
|
37035
|
-
__publicField(this, "length");
|
|
37036
|
-
__publicField(this, "position");
|
|
37037
|
-
__publicField(this, "buffer");
|
|
37038
|
-
if (typeof options.length !== "number") {
|
|
37039
|
-
throw new TypeError('"length" is not a number');
|
|
37040
|
-
}
|
|
37041
|
-
if (options.length < 1) {
|
|
37042
|
-
throw new TypeError('"length" is not greater than 0');
|
|
37043
|
-
}
|
|
37044
|
-
this.length = options.length;
|
|
37045
|
-
this.position = 0;
|
|
37046
|
-
this.buffer = Buffer.alloc(this.length);
|
|
37047
|
-
}
|
|
37048
|
-
_transform(chunk, _encoding, cb) {
|
|
37049
|
-
let cursor = 0;
|
|
37050
|
-
while (cursor < chunk.length) {
|
|
37051
|
-
this.buffer[this.position] = chunk[cursor];
|
|
37052
|
-
cursor++;
|
|
37053
|
-
this.position++;
|
|
37054
|
-
if (this.position === this.length) {
|
|
37055
|
-
this.push(this.buffer);
|
|
37056
|
-
this.buffer = Buffer.alloc(this.length);
|
|
37057
|
-
this.position = 0;
|
|
37058
|
-
}
|
|
37059
|
-
}
|
|
37060
|
-
cb();
|
|
37061
|
-
}
|
|
37062
|
-
_flush(cb) {
|
|
37063
|
-
this.push(this.buffer.slice(0, this.position));
|
|
37064
|
-
this.buffer = Buffer.alloc(this.length);
|
|
37065
|
-
cb();
|
|
37066
|
-
}
|
|
37067
|
-
};
|
|
37068
|
-
exports2.ByteLengthParser = ByteLengthParser;
|
|
37069
|
-
}
|
|
37070
|
-
});
|
|
37071
|
-
|
|
37072
|
-
// ../../node_modules/@serialport/parser-cctalk/dist/index.js
|
|
37073
|
-
var require_dist2 = __commonJS({
|
|
37074
|
-
"../../node_modules/@serialport/parser-cctalk/dist/index.js"(exports2) {
|
|
37075
|
-
"use strict";
|
|
37076
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
37077
|
-
exports2.CCTalkParser = void 0;
|
|
37078
|
-
var stream_1 = require("stream");
|
|
37079
|
-
var CCTalkParser = class extends stream_1.Transform {
|
|
37080
|
-
constructor(maxDelayBetweenBytesMs = 50) {
|
|
37081
|
-
super();
|
|
37082
|
-
__publicField(this, "array");
|
|
37083
|
-
__publicField(this, "cursor");
|
|
37084
|
-
__publicField(this, "lastByteFetchTime");
|
|
37085
|
-
__publicField(this, "maxDelayBetweenBytesMs");
|
|
37086
|
-
this.array = [];
|
|
37087
|
-
this.cursor = 0;
|
|
37088
|
-
this.lastByteFetchTime = 0;
|
|
37089
|
-
this.maxDelayBetweenBytesMs = maxDelayBetweenBytesMs;
|
|
37090
|
-
}
|
|
37091
|
-
_transform(buffer, encoding, cb) {
|
|
37092
|
-
if (this.maxDelayBetweenBytesMs > 0) {
|
|
37093
|
-
const now = Date.now();
|
|
37094
|
-
if (now - this.lastByteFetchTime > this.maxDelayBetweenBytesMs) {
|
|
37095
|
-
this.array = [];
|
|
37096
|
-
this.cursor = 0;
|
|
37097
|
-
}
|
|
37098
|
-
this.lastByteFetchTime = now;
|
|
37099
|
-
}
|
|
37100
|
-
this.cursor += buffer.length;
|
|
37101
|
-
Array.from(buffer).map((byte) => this.array.push(byte));
|
|
37102
|
-
while (this.cursor > 1 && this.cursor >= this.array[1] + 5) {
|
|
37103
|
-
const FullMsgLength = this.array[1] + 5;
|
|
37104
|
-
const frame = Buffer.from(this.array.slice(0, FullMsgLength));
|
|
37105
|
-
this.array = this.array.slice(frame.length, this.array.length);
|
|
37106
|
-
this.cursor -= FullMsgLength;
|
|
37107
|
-
this.push(frame);
|
|
37108
|
-
}
|
|
37109
|
-
cb();
|
|
37110
|
-
}
|
|
37111
|
-
};
|
|
37112
|
-
exports2.CCTalkParser = CCTalkParser;
|
|
37113
|
-
}
|
|
37114
|
-
});
|
|
37115
|
-
|
|
37116
|
-
// ../../node_modules/@serialport/parser-delimiter/dist/index.js
|
|
37117
|
-
var require_dist3 = __commonJS({
|
|
37118
|
-
"../../node_modules/@serialport/parser-delimiter/dist/index.js"(exports2) {
|
|
37119
|
-
"use strict";
|
|
37120
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
37121
|
-
exports2.DelimiterParser = void 0;
|
|
37122
|
-
var stream_1 = require("stream");
|
|
37123
|
-
var DelimiterParser = class extends stream_1.Transform {
|
|
37124
|
-
constructor({ delimiter, includeDelimiter = false, ...options }) {
|
|
37125
|
-
super(options);
|
|
37126
|
-
__publicField(this, "includeDelimiter");
|
|
37127
|
-
__publicField(this, "delimiter");
|
|
37128
|
-
__publicField(this, "buffer");
|
|
37129
|
-
if (delimiter === void 0) {
|
|
37130
|
-
throw new TypeError('"delimiter" is not a bufferable object');
|
|
37131
|
-
}
|
|
37132
|
-
if (delimiter.length === 0) {
|
|
37133
|
-
throw new TypeError('"delimiter" has a 0 or undefined length');
|
|
37134
|
-
}
|
|
37135
|
-
this.includeDelimiter = includeDelimiter;
|
|
37136
|
-
this.delimiter = Buffer.from(delimiter);
|
|
37137
|
-
this.buffer = Buffer.alloc(0);
|
|
37138
|
-
}
|
|
37139
|
-
_transform(chunk, encoding, cb) {
|
|
37140
|
-
let data2 = Buffer.concat([this.buffer, chunk]);
|
|
37141
|
-
let position;
|
|
37142
|
-
while ((position = data2.indexOf(this.delimiter)) !== -1) {
|
|
37143
|
-
this.push(data2.slice(0, position + (this.includeDelimiter ? this.delimiter.length : 0)));
|
|
37144
|
-
data2 = data2.slice(position + this.delimiter.length);
|
|
37145
|
-
}
|
|
37146
|
-
this.buffer = data2;
|
|
37147
|
-
cb();
|
|
37148
|
-
}
|
|
37149
|
-
_flush(cb) {
|
|
37150
|
-
this.push(this.buffer);
|
|
37151
|
-
this.buffer = Buffer.alloc(0);
|
|
37152
|
-
cb();
|
|
37153
|
-
}
|
|
37154
|
-
};
|
|
37155
|
-
exports2.DelimiterParser = DelimiterParser;
|
|
37156
|
-
}
|
|
37157
|
-
});
|
|
37158
|
-
|
|
37159
|
-
// ../../node_modules/@serialport/parser-inter-byte-timeout/dist/index.js
|
|
37160
|
-
var require_dist4 = __commonJS({
|
|
37161
|
-
"../../node_modules/@serialport/parser-inter-byte-timeout/dist/index.js"(exports2) {
|
|
37162
|
-
"use strict";
|
|
37163
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
37164
|
-
exports2.InterByteTimeoutParser = void 0;
|
|
37165
|
-
var stream_1 = require("stream");
|
|
37166
|
-
var InterByteTimeoutParser = class extends stream_1.Transform {
|
|
37167
|
-
constructor({ maxBufferSize = 65536, interval, ...transformOptions }) {
|
|
37168
|
-
super(transformOptions);
|
|
37169
|
-
__publicField(this, "maxBufferSize");
|
|
37170
|
-
__publicField(this, "currentPacket");
|
|
37171
|
-
__publicField(this, "interval");
|
|
37172
|
-
__publicField(this, "intervalID");
|
|
37173
|
-
if (!interval) {
|
|
37174
|
-
throw new TypeError('"interval" is required');
|
|
37175
|
-
}
|
|
37176
|
-
if (typeof interval !== "number" || Number.isNaN(interval)) {
|
|
37177
|
-
throw new TypeError('"interval" is not a number');
|
|
37178
|
-
}
|
|
37179
|
-
if (interval < 1) {
|
|
37180
|
-
throw new TypeError('"interval" is not greater than 0');
|
|
37181
|
-
}
|
|
37182
|
-
if (typeof maxBufferSize !== "number" || Number.isNaN(maxBufferSize)) {
|
|
37183
|
-
throw new TypeError('"maxBufferSize" is not a number');
|
|
37184
|
-
}
|
|
37185
|
-
if (maxBufferSize < 1) {
|
|
37186
|
-
throw new TypeError('"maxBufferSize" is not greater than 0');
|
|
37187
|
-
}
|
|
37188
|
-
this.maxBufferSize = maxBufferSize;
|
|
37189
|
-
this.currentPacket = [];
|
|
37190
|
-
this.interval = interval;
|
|
37191
|
-
}
|
|
37192
|
-
_transform(chunk, encoding, cb) {
|
|
37193
|
-
if (this.intervalID) {
|
|
37194
|
-
clearTimeout(this.intervalID);
|
|
37195
|
-
}
|
|
37196
|
-
for (let offset = 0; offset < chunk.length; offset++) {
|
|
37197
|
-
this.currentPacket.push(chunk[offset]);
|
|
37198
|
-
if (this.currentPacket.length >= this.maxBufferSize) {
|
|
37199
|
-
this.emitPacket();
|
|
37200
|
-
}
|
|
37201
|
-
}
|
|
37202
|
-
this.intervalID = setTimeout(this.emitPacket.bind(this), this.interval);
|
|
37203
|
-
cb();
|
|
37204
|
-
}
|
|
37205
|
-
emitPacket() {
|
|
37206
|
-
if (this.intervalID) {
|
|
37207
|
-
clearTimeout(this.intervalID);
|
|
37208
|
-
}
|
|
37209
|
-
if (this.currentPacket.length > 0) {
|
|
37210
|
-
this.push(Buffer.from(this.currentPacket));
|
|
37211
|
-
}
|
|
37212
|
-
this.currentPacket = [];
|
|
37213
|
-
}
|
|
37214
|
-
_flush(cb) {
|
|
37215
|
-
this.emitPacket();
|
|
37216
|
-
cb();
|
|
37217
|
-
}
|
|
37218
|
-
};
|
|
37219
|
-
exports2.InterByteTimeoutParser = InterByteTimeoutParser;
|
|
37220
|
-
}
|
|
37221
|
-
});
|
|
37222
|
-
|
|
37223
|
-
// ../../node_modules/@serialport/parser-packet-length/dist/index.js
|
|
37224
|
-
var require_dist5 = __commonJS({
|
|
37225
|
-
"../../node_modules/@serialport/parser-packet-length/dist/index.js"(exports2) {
|
|
37226
|
-
"use strict";
|
|
37227
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
37228
|
-
exports2.PacketLengthParser = void 0;
|
|
37229
|
-
var stream_1 = require("stream");
|
|
37230
|
-
var PacketLengthParser = class extends stream_1.Transform {
|
|
37231
|
-
constructor(options = {}) {
|
|
37232
|
-
super(options);
|
|
37233
|
-
__publicField(this, "buffer");
|
|
37234
|
-
__publicField(this, "start");
|
|
37235
|
-
__publicField(this, "opts");
|
|
37236
|
-
const { delimiter = 170, packetOverhead = 2, lengthBytes = 1, lengthOffset = 1, maxLen = 255 } = options;
|
|
37237
|
-
this.opts = {
|
|
37238
|
-
delimiter,
|
|
37239
|
-
packetOverhead,
|
|
37240
|
-
lengthBytes,
|
|
37241
|
-
lengthOffset,
|
|
37242
|
-
maxLen
|
|
37243
|
-
};
|
|
37244
|
-
this.buffer = Buffer.alloc(0);
|
|
37245
|
-
this.start = false;
|
|
37246
|
-
}
|
|
37247
|
-
_transform(chunk, encoding, cb) {
|
|
37248
|
-
for (let ndx = 0; ndx < chunk.length; ndx++) {
|
|
37249
|
-
const byte = chunk[ndx];
|
|
37250
|
-
if (byte === this.opts.delimiter) {
|
|
37251
|
-
this.start = true;
|
|
37252
|
-
}
|
|
37253
|
-
if (true === this.start) {
|
|
37254
|
-
this.buffer = Buffer.concat([this.buffer, Buffer.from([byte])]);
|
|
37255
|
-
if (this.buffer.length >= this.opts.lengthOffset + this.opts.lengthBytes) {
|
|
37256
|
-
const len = this.buffer.readUIntLE(this.opts.lengthOffset, this.opts.lengthBytes);
|
|
37257
|
-
if (this.buffer.length == len + this.opts.packetOverhead || len > this.opts.maxLen) {
|
|
37258
|
-
this.push(this.buffer);
|
|
37259
|
-
this.buffer = Buffer.alloc(0);
|
|
37260
|
-
this.start = false;
|
|
37261
|
-
}
|
|
37262
|
-
}
|
|
37263
|
-
}
|
|
37264
|
-
}
|
|
37265
|
-
cb();
|
|
37266
|
-
}
|
|
37267
|
-
_flush(cb) {
|
|
37268
|
-
this.push(this.buffer);
|
|
37269
|
-
this.buffer = Buffer.alloc(0);
|
|
37270
|
-
cb();
|
|
37271
|
-
}
|
|
37272
|
-
};
|
|
37273
|
-
exports2.PacketLengthParser = PacketLengthParser;
|
|
37274
|
-
}
|
|
37275
|
-
});
|
|
37276
|
-
|
|
37277
|
-
// ../../node_modules/@serialport/parser-readline/dist/index.js
|
|
37278
|
-
var require_dist6 = __commonJS({
|
|
37279
|
-
"../../node_modules/@serialport/parser-readline/dist/index.js"(exports2) {
|
|
37280
|
-
"use strict";
|
|
37281
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
37282
|
-
exports2.ReadlineParser = void 0;
|
|
37283
|
-
var parser_delimiter_1 = require_dist3();
|
|
37284
|
-
var ReadlineParser = class extends parser_delimiter_1.DelimiterParser {
|
|
37285
|
-
constructor(options) {
|
|
37286
|
-
const opts = {
|
|
37287
|
-
delimiter: Buffer.from("\n", "utf8"),
|
|
37288
|
-
encoding: "utf8",
|
|
37289
|
-
...options
|
|
37290
|
-
};
|
|
37291
|
-
if (typeof opts.delimiter === "string") {
|
|
37292
|
-
opts.delimiter = Buffer.from(opts.delimiter, opts.encoding);
|
|
37293
|
-
}
|
|
37294
|
-
super(opts);
|
|
37295
|
-
}
|
|
37296
|
-
};
|
|
37297
|
-
exports2.ReadlineParser = ReadlineParser;
|
|
37298
|
-
}
|
|
37299
|
-
});
|
|
37300
|
-
|
|
37301
|
-
// ../../node_modules/@serialport/parser-ready/dist/index.js
|
|
37302
|
-
var require_dist7 = __commonJS({
|
|
37303
|
-
"../../node_modules/@serialport/parser-ready/dist/index.js"(exports2) {
|
|
37304
|
-
"use strict";
|
|
37305
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
37306
|
-
exports2.ReadyParser = void 0;
|
|
37307
|
-
var stream_1 = require("stream");
|
|
37308
|
-
var ReadyParser = class extends stream_1.Transform {
|
|
37309
|
-
constructor({ delimiter, ...options }) {
|
|
37310
|
-
if (delimiter === void 0) {
|
|
37311
|
-
throw new TypeError('"delimiter" is not a bufferable object');
|
|
37312
|
-
}
|
|
37313
|
-
if (delimiter.length === 0) {
|
|
37314
|
-
throw new TypeError('"delimiter" has a 0 or undefined length');
|
|
37315
|
-
}
|
|
37316
|
-
super(options);
|
|
37317
|
-
__publicField(this, "delimiter");
|
|
37318
|
-
__publicField(this, "readOffset");
|
|
37319
|
-
__publicField(this, "ready");
|
|
37320
|
-
this.delimiter = Buffer.from(delimiter);
|
|
37321
|
-
this.readOffset = 0;
|
|
37322
|
-
this.ready = false;
|
|
37323
|
-
}
|
|
37324
|
-
_transform(chunk, encoding, cb) {
|
|
37325
|
-
if (this.ready) {
|
|
37326
|
-
this.push(chunk);
|
|
37327
|
-
return cb();
|
|
37328
|
-
}
|
|
37329
|
-
const delimiter = this.delimiter;
|
|
37330
|
-
let chunkOffset = 0;
|
|
37331
|
-
while (this.readOffset < delimiter.length && chunkOffset < chunk.length) {
|
|
37332
|
-
if (delimiter[this.readOffset] === chunk[chunkOffset]) {
|
|
37333
|
-
this.readOffset++;
|
|
37334
|
-
} else {
|
|
37335
|
-
this.readOffset = 0;
|
|
37336
|
-
}
|
|
37337
|
-
chunkOffset++;
|
|
37338
|
-
}
|
|
37339
|
-
if (this.readOffset === delimiter.length) {
|
|
37340
|
-
this.ready = true;
|
|
37341
|
-
this.emit("ready");
|
|
37342
|
-
const chunkRest = chunk.slice(chunkOffset);
|
|
37343
|
-
if (chunkRest.length > 0) {
|
|
37344
|
-
this.push(chunkRest);
|
|
37345
|
-
}
|
|
37346
|
-
}
|
|
37347
|
-
cb();
|
|
37348
|
-
}
|
|
37349
|
-
};
|
|
37350
|
-
exports2.ReadyParser = ReadyParser;
|
|
37351
|
-
}
|
|
37352
|
-
});
|
|
37353
|
-
|
|
37354
|
-
// ../../node_modules/@serialport/parser-regex/dist/index.js
|
|
37355
|
-
var require_dist8 = __commonJS({
|
|
37356
|
-
"../../node_modules/@serialport/parser-regex/dist/index.js"(exports2) {
|
|
37357
|
-
"use strict";
|
|
37358
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
37359
|
-
exports2.RegexParser = void 0;
|
|
37360
|
-
var stream_1 = require("stream");
|
|
37361
|
-
var RegexParser = class extends stream_1.Transform {
|
|
37362
|
-
constructor({ regex, ...options }) {
|
|
37363
|
-
const opts = {
|
|
37364
|
-
encoding: "utf8",
|
|
37365
|
-
...options
|
|
37366
|
-
};
|
|
37367
|
-
if (regex === void 0) {
|
|
37368
|
-
throw new TypeError('"options.regex" must be a regular expression pattern or object');
|
|
37369
|
-
}
|
|
37370
|
-
if (!(regex instanceof RegExp)) {
|
|
37371
|
-
regex = new RegExp(regex.toString());
|
|
37372
|
-
}
|
|
37373
|
-
super(opts);
|
|
37374
|
-
__publicField(this, "regex");
|
|
37375
|
-
__publicField(this, "data");
|
|
37376
|
-
this.regex = regex;
|
|
37377
|
-
this.data = "";
|
|
37378
|
-
}
|
|
37379
|
-
_transform(chunk, encoding, cb) {
|
|
37380
|
-
const data2 = this.data + chunk;
|
|
37381
|
-
const parts = data2.split(this.regex);
|
|
37382
|
-
this.data = parts.pop() || "";
|
|
37383
|
-
parts.forEach((part) => {
|
|
37384
|
-
this.push(part);
|
|
37385
|
-
});
|
|
37386
|
-
cb();
|
|
37387
|
-
}
|
|
37388
|
-
_flush(cb) {
|
|
37389
|
-
this.push(this.data);
|
|
37390
|
-
this.data = "";
|
|
37391
|
-
cb();
|
|
37392
|
-
}
|
|
37393
|
-
};
|
|
37394
|
-
exports2.RegexParser = RegexParser;
|
|
37395
|
-
}
|
|
37396
|
-
});
|
|
37397
|
-
|
|
37398
|
-
// ../../node_modules/@serialport/parser-slip-encoder/dist/decoder.js
|
|
37399
|
-
var require_decoder = __commonJS({
|
|
37400
|
-
"../../node_modules/@serialport/parser-slip-encoder/dist/decoder.js"(exports2) {
|
|
37401
|
-
"use strict";
|
|
37402
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
37403
|
-
exports2.SlipDecoder = void 0;
|
|
37404
|
-
var stream_1 = require("stream");
|
|
37405
|
-
var SlipDecoder = class extends stream_1.Transform {
|
|
37406
|
-
constructor(options = {}) {
|
|
37407
|
-
super(options);
|
|
37408
|
-
__publicField(this, "opts");
|
|
37409
|
-
__publicField(this, "buffer");
|
|
37410
|
-
__publicField(this, "escape");
|
|
37411
|
-
__publicField(this, "start");
|
|
37412
|
-
const { START, ESC = 219, END = 192, ESC_START, ESC_END = 220, ESC_ESC = 221 } = options;
|
|
37413
|
-
this.opts = {
|
|
37414
|
-
START,
|
|
37415
|
-
ESC,
|
|
37416
|
-
END,
|
|
37417
|
-
ESC_START,
|
|
37418
|
-
ESC_END,
|
|
37419
|
-
ESC_ESC
|
|
37420
|
-
};
|
|
37421
|
-
this.buffer = Buffer.alloc(0);
|
|
37422
|
-
this.escape = false;
|
|
37423
|
-
this.start = false;
|
|
37424
|
-
}
|
|
37425
|
-
_transform(chunk, encoding, cb) {
|
|
37426
|
-
for (let ndx = 0; ndx < chunk.length; ndx++) {
|
|
37427
|
-
let byte = chunk[ndx];
|
|
37428
|
-
if (byte === this.opts.START) {
|
|
37429
|
-
this.start = true;
|
|
37430
|
-
continue;
|
|
37431
|
-
} else if (void 0 == this.opts.START) {
|
|
37432
|
-
this.start = true;
|
|
37433
|
-
}
|
|
37434
|
-
if (this.escape) {
|
|
37435
|
-
if (byte === this.opts.ESC_START && this.opts.START) {
|
|
37436
|
-
byte = this.opts.START;
|
|
37437
|
-
} else if (byte === this.opts.ESC_ESC) {
|
|
37438
|
-
byte = this.opts.ESC;
|
|
37439
|
-
} else if (byte === this.opts.ESC_END) {
|
|
37440
|
-
byte = this.opts.END;
|
|
37441
|
-
} else {
|
|
37442
|
-
this.escape = false;
|
|
37443
|
-
this.push(this.buffer);
|
|
37444
|
-
this.buffer = Buffer.alloc(0);
|
|
37445
|
-
}
|
|
37446
|
-
} else {
|
|
37447
|
-
if (byte === this.opts.ESC) {
|
|
37448
|
-
this.escape = true;
|
|
37449
|
-
continue;
|
|
37450
|
-
}
|
|
37451
|
-
if (byte === this.opts.END) {
|
|
37452
|
-
this.push(this.buffer);
|
|
37453
|
-
this.buffer = Buffer.alloc(0);
|
|
37454
|
-
this.escape = false;
|
|
37455
|
-
this.start = false;
|
|
37456
|
-
continue;
|
|
37457
|
-
}
|
|
37458
|
-
}
|
|
37459
|
-
this.escape = false;
|
|
37460
|
-
if (this.start) {
|
|
37461
|
-
this.buffer = Buffer.concat([this.buffer, Buffer.from([byte])]);
|
|
37462
|
-
}
|
|
37463
|
-
}
|
|
37464
|
-
cb();
|
|
37465
|
-
}
|
|
37466
|
-
_flush(cb) {
|
|
37467
|
-
this.push(this.buffer);
|
|
37468
|
-
this.buffer = Buffer.alloc(0);
|
|
37469
|
-
cb();
|
|
37470
|
-
}
|
|
37471
|
-
};
|
|
37472
|
-
exports2.SlipDecoder = SlipDecoder;
|
|
37473
|
-
}
|
|
37474
|
-
});
|
|
37475
|
-
|
|
37476
|
-
// ../../node_modules/@serialport/parser-slip-encoder/dist/encoder.js
|
|
37477
|
-
var require_encoder = __commonJS({
|
|
37478
|
-
"../../node_modules/@serialport/parser-slip-encoder/dist/encoder.js"(exports2) {
|
|
37479
|
-
"use strict";
|
|
37480
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
37481
|
-
exports2.SlipEncoder = void 0;
|
|
37482
|
-
var stream_1 = require("stream");
|
|
37483
|
-
var SlipEncoder = class extends stream_1.Transform {
|
|
37484
|
-
constructor(options = {}) {
|
|
37485
|
-
super(options);
|
|
37486
|
-
__publicField(this, "opts");
|
|
37487
|
-
const { START, ESC = 219, END = 192, ESC_START, ESC_END = 220, ESC_ESC = 221, bluetoothQuirk = false } = options;
|
|
37488
|
-
this.opts = {
|
|
37489
|
-
START,
|
|
37490
|
-
ESC,
|
|
37491
|
-
END,
|
|
37492
|
-
ESC_START,
|
|
37493
|
-
ESC_END,
|
|
37494
|
-
ESC_ESC,
|
|
37495
|
-
bluetoothQuirk
|
|
37496
|
-
};
|
|
37497
|
-
}
|
|
37498
|
-
_transform(chunk, encoding, cb) {
|
|
37499
|
-
const chunkLength = chunk.length;
|
|
37500
|
-
if (this.opts.bluetoothQuirk && chunkLength === 0) {
|
|
37501
|
-
return cb();
|
|
37502
|
-
}
|
|
37503
|
-
const encoded = Buffer.alloc(chunkLength * 2 + 2);
|
|
37504
|
-
let j2 = 0;
|
|
37505
|
-
if (this.opts.bluetoothQuirk == true) {
|
|
37506
|
-
encoded[j2++] = this.opts.END;
|
|
37507
|
-
}
|
|
37508
|
-
if (this.opts.START !== void 0) {
|
|
37509
|
-
encoded[j2++] = this.opts.START;
|
|
37510
|
-
}
|
|
37511
|
-
for (let i2 = 0; i2 < chunkLength; i2++) {
|
|
37512
|
-
let byte = chunk[i2];
|
|
37513
|
-
if (byte === this.opts.START && this.opts.ESC_START) {
|
|
37514
|
-
encoded[j2++] = this.opts.ESC;
|
|
37515
|
-
byte = this.opts.ESC_START;
|
|
37516
|
-
} else if (byte === this.opts.END) {
|
|
37517
|
-
encoded[j2++] = this.opts.ESC;
|
|
37518
|
-
byte = this.opts.ESC_END;
|
|
37519
|
-
} else if (byte === this.opts.ESC) {
|
|
37520
|
-
encoded[j2++] = this.opts.ESC;
|
|
37521
|
-
byte = this.opts.ESC_ESC;
|
|
37522
|
-
}
|
|
37523
|
-
encoded[j2++] = byte;
|
|
37524
|
-
}
|
|
37525
|
-
encoded[j2++] = this.opts.END;
|
|
37526
|
-
cb(null, encoded.slice(0, j2));
|
|
37527
|
-
}
|
|
37528
|
-
};
|
|
37529
|
-
exports2.SlipEncoder = SlipEncoder;
|
|
37530
|
-
}
|
|
37531
|
-
});
|
|
37532
|
-
|
|
37533
|
-
// ../../node_modules/@serialport/parser-slip-encoder/dist/index.js
|
|
37534
|
-
var require_dist9 = __commonJS({
|
|
37535
|
-
"../../node_modules/@serialport/parser-slip-encoder/dist/index.js"(exports2) {
|
|
37536
|
-
"use strict";
|
|
37537
|
-
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m3, k2, k22) {
|
|
37538
|
-
if (k22 === void 0)
|
|
37539
|
-
k22 = k2;
|
|
37540
|
-
var desc = Object.getOwnPropertyDescriptor(m3, k2);
|
|
37541
|
-
if (!desc || ("get" in desc ? !m3.__esModule : desc.writable || desc.configurable)) {
|
|
37542
|
-
desc = { enumerable: true, get: function() {
|
|
37543
|
-
return m3[k2];
|
|
37544
|
-
} };
|
|
37545
|
-
}
|
|
37546
|
-
Object.defineProperty(o, k22, desc);
|
|
37547
|
-
} : function(o, m3, k2, k22) {
|
|
37548
|
-
if (k22 === void 0)
|
|
37549
|
-
k22 = k2;
|
|
37550
|
-
o[k22] = m3[k2];
|
|
37551
|
-
});
|
|
37552
|
-
var __exportStar = exports2 && exports2.__exportStar || function(m3, exports3) {
|
|
37553
|
-
for (var p2 in m3)
|
|
37554
|
-
if (p2 !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p2))
|
|
37555
|
-
__createBinding(exports3, m3, p2);
|
|
37556
|
-
};
|
|
37557
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
37558
|
-
__exportStar(require_decoder(), exports2);
|
|
37559
|
-
__exportStar(require_encoder(), exports2);
|
|
37560
|
-
}
|
|
37561
|
-
});
|
|
37562
|
-
|
|
37563
|
-
// ../../node_modules/@serialport/parser-spacepacket/dist/utils.js
|
|
37564
|
-
var require_utils2 = __commonJS({
|
|
37565
|
-
"../../node_modules/@serialport/parser-spacepacket/dist/utils.js"(exports2) {
|
|
37566
|
-
"use strict";
|
|
37567
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
37568
|
-
exports2.convertHeaderBufferToObj = exports2.HEADER_LENGTH = void 0;
|
|
37569
|
-
exports2.HEADER_LENGTH = 6;
|
|
37570
|
-
var toOctetStr = (num) => {
|
|
37571
|
-
let str = Number(num).toString(2);
|
|
37572
|
-
while (str.length < 8) {
|
|
37573
|
-
str = `0${str}`;
|
|
37574
|
-
}
|
|
37575
|
-
return str;
|
|
37576
|
-
};
|
|
37577
|
-
var convertHeaderBufferToObj = (buf) => {
|
|
37578
|
-
const headerStr = Array.from(buf.slice(0, exports2.HEADER_LENGTH)).reduce((accum, curr) => `${accum}${toOctetStr(curr)}`, "");
|
|
37579
|
-
const isVersion1 = headerStr.slice(0, 3) === "000";
|
|
37580
|
-
const versionNumber = isVersion1 ? 1 : "UNKNOWN_VERSION";
|
|
37581
|
-
const type = Number(headerStr[3]);
|
|
37582
|
-
const secondaryHeader = Number(headerStr[4]);
|
|
37583
|
-
const apid = parseInt(headerStr.slice(5, 16), 2);
|
|
37584
|
-
const sequenceFlags = parseInt(headerStr.slice(16, 18), 2);
|
|
37585
|
-
const packetName = parseInt(headerStr.slice(18, 32), 2);
|
|
37586
|
-
const dataLength = parseInt(headerStr.slice(-16), 2) + 1;
|
|
37587
|
-
return {
|
|
37588
|
-
versionNumber,
|
|
37589
|
-
identification: {
|
|
37590
|
-
apid,
|
|
37591
|
-
secondaryHeader,
|
|
37592
|
-
type
|
|
37593
|
-
},
|
|
37594
|
-
sequenceControl: {
|
|
37595
|
-
packetName,
|
|
37596
|
-
sequenceFlags
|
|
37597
|
-
},
|
|
37598
|
-
dataLength
|
|
37599
|
-
};
|
|
37600
|
-
};
|
|
37601
|
-
exports2.convertHeaderBufferToObj = convertHeaderBufferToObj;
|
|
37602
|
-
}
|
|
37603
|
-
});
|
|
37604
|
-
|
|
37605
|
-
// ../../node_modules/@serialport/parser-spacepacket/dist/index.js
|
|
37606
|
-
var require_dist10 = __commonJS({
|
|
37607
|
-
"../../node_modules/@serialport/parser-spacepacket/dist/index.js"(exports2) {
|
|
37608
|
-
"use strict";
|
|
37609
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
37610
|
-
exports2.SpacePacketParser = void 0;
|
|
37611
|
-
var stream_1 = require("stream");
|
|
37612
|
-
var utils_1 = require_utils2();
|
|
37613
|
-
var SpacePacketParser = class extends stream_1.Transform {
|
|
37614
|
-
/**
|
|
37615
|
-
* A Transform stream that accepts a stream of octet data and emits object representations of
|
|
37616
|
-
* CCSDS Space Packets once a packet has been completely received.
|
|
37617
|
-
* @param {Object} [options] Configuration options for the stream
|
|
37618
|
-
* @param {Number} options.timeCodeFieldLength The length of the time code field within the data
|
|
37619
|
-
* @param {Number} options.ancillaryDataFieldLength The length of the ancillary data field within the data
|
|
37620
|
-
*/
|
|
37621
|
-
constructor(options = {}) {
|
|
37622
|
-
super({ ...options, objectMode: true });
|
|
37623
|
-
__publicField(this, "timeCodeFieldLength");
|
|
37624
|
-
__publicField(this, "ancillaryDataFieldLength");
|
|
37625
|
-
__publicField(this, "dataBuffer");
|
|
37626
|
-
__publicField(this, "headerBuffer");
|
|
37627
|
-
__publicField(this, "dataLength");
|
|
37628
|
-
__publicField(this, "expectingHeader");
|
|
37629
|
-
__publicField(this, "dataSlice");
|
|
37630
|
-
__publicField(this, "header");
|
|
37631
|
-
this.timeCodeFieldLength = options.timeCodeFieldLength || 0;
|
|
37632
|
-
this.ancillaryDataFieldLength = options.ancillaryDataFieldLength || 0;
|
|
37633
|
-
this.dataSlice = this.timeCodeFieldLength + this.ancillaryDataFieldLength;
|
|
37634
|
-
this.dataBuffer = Buffer.alloc(0);
|
|
37635
|
-
this.headerBuffer = Buffer.alloc(0);
|
|
37636
|
-
this.dataLength = 0;
|
|
37637
|
-
this.expectingHeader = true;
|
|
37638
|
-
}
|
|
37639
|
-
/**
|
|
37640
|
-
* Bundle the header, secondary header if present, and the data into a JavaScript object to emit.
|
|
37641
|
-
* If more data has been received past the current packet, begin the process of parsing the next
|
|
37642
|
-
* packet(s).
|
|
37643
|
-
*/
|
|
37644
|
-
pushCompletedPacket() {
|
|
37645
|
-
if (!this.header) {
|
|
37646
|
-
throw new Error("Missing header");
|
|
37647
|
-
}
|
|
37648
|
-
const timeCode = Buffer.from(this.dataBuffer.slice(0, this.timeCodeFieldLength));
|
|
37649
|
-
const ancillaryData = Buffer.from(this.dataBuffer.slice(this.timeCodeFieldLength, this.timeCodeFieldLength + this.ancillaryDataFieldLength));
|
|
37650
|
-
const data2 = Buffer.from(this.dataBuffer.slice(this.dataSlice, this.dataLength));
|
|
37651
|
-
const completedPacket = {
|
|
37652
|
-
header: { ...this.header },
|
|
37653
|
-
data: data2.toString()
|
|
37654
|
-
};
|
|
37655
|
-
if (timeCode.length > 0 || ancillaryData.length > 0) {
|
|
37656
|
-
completedPacket.secondaryHeader = {};
|
|
37657
|
-
if (timeCode.length) {
|
|
37658
|
-
completedPacket.secondaryHeader.timeCode = timeCode.toString();
|
|
37659
|
-
}
|
|
37660
|
-
if (ancillaryData.length) {
|
|
37661
|
-
completedPacket.secondaryHeader.ancillaryData = ancillaryData.toString();
|
|
37662
|
-
}
|
|
37663
|
-
}
|
|
37664
|
-
this.push(completedPacket);
|
|
37665
|
-
const nextChunk = Buffer.from(this.dataBuffer.slice(this.dataLength));
|
|
37666
|
-
if (nextChunk.length >= utils_1.HEADER_LENGTH) {
|
|
37667
|
-
this.extractHeader(nextChunk);
|
|
37668
|
-
} else {
|
|
37669
|
-
this.headerBuffer = nextChunk;
|
|
37670
|
-
this.dataBuffer = Buffer.alloc(0);
|
|
37671
|
-
this.expectingHeader = true;
|
|
37672
|
-
this.dataLength = 0;
|
|
37673
|
-
this.header = void 0;
|
|
37674
|
-
}
|
|
37675
|
-
}
|
|
37676
|
-
/**
|
|
37677
|
-
* Build the Stream's headerBuffer property from the received Buffer chunk; extract data from it
|
|
37678
|
-
* if it's complete. If there's more to the chunk than just the header, initiate handling the
|
|
37679
|
-
* packet data.
|
|
37680
|
-
* @param chunk - Build the Stream's headerBuffer property from
|
|
37681
|
-
*/
|
|
37682
|
-
extractHeader(chunk) {
|
|
37683
|
-
const headerAsBuffer = Buffer.concat([this.headerBuffer, chunk]);
|
|
37684
|
-
const startOfDataBuffer = headerAsBuffer.slice(utils_1.HEADER_LENGTH);
|
|
37685
|
-
if (headerAsBuffer.length >= utils_1.HEADER_LENGTH) {
|
|
37686
|
-
this.header = (0, utils_1.convertHeaderBufferToObj)(headerAsBuffer);
|
|
37687
|
-
this.dataLength = this.header.dataLength;
|
|
37688
|
-
this.headerBuffer = Buffer.alloc(0);
|
|
37689
|
-
this.expectingHeader = false;
|
|
37690
|
-
} else {
|
|
37691
|
-
this.headerBuffer = headerAsBuffer;
|
|
37692
|
-
}
|
|
37693
|
-
if (startOfDataBuffer.length > 0) {
|
|
37694
|
-
this.dataBuffer = Buffer.from(startOfDataBuffer);
|
|
37695
|
-
if (this.dataBuffer.length >= this.dataLength) {
|
|
37696
|
-
this.pushCompletedPacket();
|
|
37697
|
-
}
|
|
37698
|
-
}
|
|
37699
|
-
}
|
|
37700
|
-
_transform(chunk, encoding, cb) {
|
|
37701
|
-
if (this.expectingHeader) {
|
|
37702
|
-
this.extractHeader(chunk);
|
|
37703
|
-
} else {
|
|
37704
|
-
this.dataBuffer = Buffer.concat([this.dataBuffer, chunk]);
|
|
37705
|
-
if (this.dataBuffer.length >= this.dataLength) {
|
|
37706
|
-
this.pushCompletedPacket();
|
|
37707
|
-
}
|
|
37708
|
-
}
|
|
37709
|
-
cb();
|
|
37710
|
-
}
|
|
37711
|
-
_flush(cb) {
|
|
37712
|
-
const remaining = Buffer.concat([this.headerBuffer, this.dataBuffer]);
|
|
37713
|
-
const remainingArray = Array.from(remaining);
|
|
37714
|
-
this.push(remainingArray);
|
|
37715
|
-
cb();
|
|
37716
|
-
}
|
|
37717
|
-
};
|
|
37718
|
-
exports2.SpacePacketParser = SpacePacketParser;
|
|
37719
|
-
}
|
|
37720
|
-
});
|
|
37721
|
-
|
|
37722
|
-
// ../../node_modules/debug/src/common.js
|
|
37723
|
-
var require_common2 = __commonJS({
|
|
37724
|
-
"../../node_modules/debug/src/common.js"(exports2, module2) {
|
|
37725
|
-
"use strict";
|
|
37726
|
-
function setup(env) {
|
|
37727
|
-
createDebug.debug = createDebug;
|
|
37728
|
-
createDebug.default = createDebug;
|
|
37729
|
-
createDebug.coerce = coerce;
|
|
37730
|
-
createDebug.disable = disable;
|
|
37731
|
-
createDebug.enable = enable;
|
|
37732
|
-
createDebug.enabled = enabled;
|
|
37733
|
-
createDebug.humanize = require_ms();
|
|
37734
|
-
createDebug.destroy = destroy;
|
|
37735
|
-
Object.keys(env).forEach((key) => {
|
|
37736
|
-
createDebug[key] = env[key];
|
|
37737
|
-
});
|
|
37738
|
-
createDebug.names = [];
|
|
37739
|
-
createDebug.skips = [];
|
|
37740
|
-
createDebug.formatters = {};
|
|
37741
|
-
function selectColor(namespace) {
|
|
37742
|
-
let hash = 0;
|
|
37743
|
-
for (let i2 = 0; i2 < namespace.length; i2++) {
|
|
37744
|
-
hash = (hash << 5) - hash + namespace.charCodeAt(i2);
|
|
37745
|
-
hash |= 0;
|
|
37746
|
-
}
|
|
37747
|
-
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
37748
|
-
}
|
|
37749
|
-
createDebug.selectColor = selectColor;
|
|
37750
|
-
function createDebug(namespace) {
|
|
37751
|
-
let prevTime;
|
|
37752
|
-
let enableOverride = null;
|
|
37753
|
-
let namespacesCache;
|
|
37754
|
-
let enabledCache;
|
|
37755
|
-
function debug(...args) {
|
|
37756
|
-
if (!debug.enabled) {
|
|
37757
|
-
return;
|
|
37758
|
-
}
|
|
37759
|
-
const self2 = debug;
|
|
37760
|
-
const curr = Number(/* @__PURE__ */ new Date());
|
|
37761
|
-
const ms2 = curr - (prevTime || curr);
|
|
37762
|
-
self2.diff = ms2;
|
|
37763
|
-
self2.prev = prevTime;
|
|
37764
|
-
self2.curr = curr;
|
|
37765
|
-
prevTime = curr;
|
|
37766
|
-
args[0] = createDebug.coerce(args[0]);
|
|
37767
|
-
if (typeof args[0] !== "string") {
|
|
37768
|
-
args.unshift("%O");
|
|
37769
|
-
}
|
|
37770
|
-
let index = 0;
|
|
37771
|
-
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
37772
|
-
if (match === "%%") {
|
|
37773
|
-
return "%";
|
|
37774
|
-
}
|
|
37775
|
-
index++;
|
|
37776
|
-
const formatter = createDebug.formatters[format];
|
|
37777
|
-
if (typeof formatter === "function") {
|
|
37778
|
-
const val = args[index];
|
|
37779
|
-
match = formatter.call(self2, val);
|
|
37780
|
-
args.splice(index, 1);
|
|
37781
|
-
index--;
|
|
37782
|
-
}
|
|
37783
|
-
return match;
|
|
37784
|
-
});
|
|
37785
|
-
createDebug.formatArgs.call(self2, args);
|
|
37786
|
-
const logFn = self2.log || createDebug.log;
|
|
37787
|
-
logFn.apply(self2, args);
|
|
37788
|
-
}
|
|
37789
|
-
debug.namespace = namespace;
|
|
37790
|
-
debug.useColors = createDebug.useColors();
|
|
37791
|
-
debug.color = createDebug.selectColor(namespace);
|
|
37792
|
-
debug.extend = extend;
|
|
37793
|
-
debug.destroy = createDebug.destroy;
|
|
37794
|
-
Object.defineProperty(debug, "enabled", {
|
|
37795
|
-
enumerable: true,
|
|
37796
|
-
configurable: false,
|
|
37797
|
-
get: () => {
|
|
37798
|
-
if (enableOverride !== null) {
|
|
37799
|
-
return enableOverride;
|
|
37800
|
-
}
|
|
37801
|
-
if (namespacesCache !== createDebug.namespaces) {
|
|
37802
|
-
namespacesCache = createDebug.namespaces;
|
|
37803
|
-
enabledCache = createDebug.enabled(namespace);
|
|
37804
|
-
}
|
|
37805
|
-
return enabledCache;
|
|
37806
|
-
},
|
|
37807
|
-
set: (v2) => {
|
|
37808
|
-
enableOverride = v2;
|
|
37809
|
-
}
|
|
37810
|
-
});
|
|
37811
|
-
if (typeof createDebug.init === "function") {
|
|
37812
|
-
createDebug.init(debug);
|
|
37813
|
-
}
|
|
37814
|
-
return debug;
|
|
37815
|
-
}
|
|
37816
|
-
function extend(namespace, delimiter) {
|
|
37817
|
-
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
37818
|
-
newDebug.log = this.log;
|
|
37819
|
-
return newDebug;
|
|
37820
|
-
}
|
|
37821
|
-
function enable(namespaces) {
|
|
37822
|
-
createDebug.save(namespaces);
|
|
37823
|
-
createDebug.namespaces = namespaces;
|
|
37824
|
-
createDebug.names = [];
|
|
37825
|
-
createDebug.skips = [];
|
|
37826
|
-
let i2;
|
|
37827
|
-
const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/);
|
|
37828
|
-
const len = split.length;
|
|
37829
|
-
for (i2 = 0; i2 < len; i2++) {
|
|
37830
|
-
if (!split[i2]) {
|
|
37831
|
-
continue;
|
|
37832
|
-
}
|
|
37833
|
-
namespaces = split[i2].replace(/\*/g, ".*?");
|
|
37834
|
-
if (namespaces[0] === "-") {
|
|
37835
|
-
createDebug.skips.push(new RegExp("^" + namespaces.slice(1) + "$"));
|
|
37836
|
-
} else {
|
|
37837
|
-
createDebug.names.push(new RegExp("^" + namespaces + "$"));
|
|
37838
|
-
}
|
|
37839
|
-
}
|
|
37840
|
-
}
|
|
37841
|
-
function disable() {
|
|
37842
|
-
const namespaces = [
|
|
37843
|
-
...createDebug.names.map(toNamespace),
|
|
37844
|
-
...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace)
|
|
37845
|
-
].join(",");
|
|
37846
|
-
createDebug.enable("");
|
|
37847
|
-
return namespaces;
|
|
37848
|
-
}
|
|
37849
|
-
function enabled(name) {
|
|
37850
|
-
if (name[name.length - 1] === "*") {
|
|
37851
|
-
return true;
|
|
37852
|
-
}
|
|
37853
|
-
let i2;
|
|
37854
|
-
let len;
|
|
37855
|
-
for (i2 = 0, len = createDebug.skips.length; i2 < len; i2++) {
|
|
37856
|
-
if (createDebug.skips[i2].test(name)) {
|
|
37857
|
-
return false;
|
|
37858
|
-
}
|
|
37859
|
-
}
|
|
37860
|
-
for (i2 = 0, len = createDebug.names.length; i2 < len; i2++) {
|
|
37861
|
-
if (createDebug.names[i2].test(name)) {
|
|
37862
|
-
return true;
|
|
37863
|
-
}
|
|
37864
|
-
}
|
|
37865
|
-
return false;
|
|
37866
|
-
}
|
|
37867
|
-
function toNamespace(regexp) {
|
|
37868
|
-
return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*");
|
|
37869
|
-
}
|
|
37870
|
-
function coerce(val) {
|
|
37871
|
-
if (val instanceof Error) {
|
|
37872
|
-
return val.stack || val.message;
|
|
37873
|
-
}
|
|
37874
|
-
return val;
|
|
37875
|
-
}
|
|
37876
|
-
function destroy() {
|
|
37877
|
-
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
37878
|
-
}
|
|
37879
|
-
createDebug.enable(createDebug.load());
|
|
37880
|
-
return createDebug;
|
|
37881
|
-
}
|
|
37882
|
-
module2.exports = setup;
|
|
37883
|
-
}
|
|
37884
|
-
});
|
|
37885
|
-
|
|
37886
|
-
// ../../node_modules/debug/src/browser.js
|
|
37887
|
-
var require_browser = __commonJS({
|
|
37888
|
-
"../../node_modules/debug/src/browser.js"(exports2, module2) {
|
|
37889
|
-
"use strict";
|
|
37890
|
-
exports2.formatArgs = formatArgs;
|
|
37891
|
-
exports2.save = save;
|
|
37892
|
-
exports2.load = load;
|
|
37893
|
-
exports2.useColors = useColors;
|
|
37894
|
-
exports2.storage = localstorage();
|
|
37895
|
-
exports2.destroy = /* @__PURE__ */ (() => {
|
|
37896
|
-
let warned = false;
|
|
37897
|
-
return () => {
|
|
37898
|
-
if (!warned) {
|
|
37899
|
-
warned = true;
|
|
37900
|
-
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
37901
|
-
}
|
|
37902
|
-
};
|
|
37903
|
-
})();
|
|
37904
|
-
exports2.colors = [
|
|
37905
|
-
"#0000CC",
|
|
37906
|
-
"#0000FF",
|
|
37907
|
-
"#0033CC",
|
|
37908
|
-
"#0033FF",
|
|
37909
|
-
"#0066CC",
|
|
37910
|
-
"#0066FF",
|
|
37911
|
-
"#0099CC",
|
|
37912
|
-
"#0099FF",
|
|
37913
|
-
"#00CC00",
|
|
37914
|
-
"#00CC33",
|
|
37915
|
-
"#00CC66",
|
|
37916
|
-
"#00CC99",
|
|
37917
|
-
"#00CCCC",
|
|
37918
|
-
"#00CCFF",
|
|
37919
|
-
"#3300CC",
|
|
37920
|
-
"#3300FF",
|
|
37921
|
-
"#3333CC",
|
|
37922
|
-
"#3333FF",
|
|
37923
|
-
"#3366CC",
|
|
37924
|
-
"#3366FF",
|
|
37925
|
-
"#3399CC",
|
|
37926
|
-
"#3399FF",
|
|
37927
|
-
"#33CC00",
|
|
37928
|
-
"#33CC33",
|
|
37929
|
-
"#33CC66",
|
|
37930
|
-
"#33CC99",
|
|
37931
|
-
"#33CCCC",
|
|
37932
|
-
"#33CCFF",
|
|
37933
|
-
"#6600CC",
|
|
37934
|
-
"#6600FF",
|
|
37935
|
-
"#6633CC",
|
|
37936
|
-
"#6633FF",
|
|
37937
|
-
"#66CC00",
|
|
37938
|
-
"#66CC33",
|
|
37939
|
-
"#9900CC",
|
|
37940
|
-
"#9900FF",
|
|
37941
|
-
"#9933CC",
|
|
37942
|
-
"#9933FF",
|
|
37943
|
-
"#99CC00",
|
|
37944
|
-
"#99CC33",
|
|
37945
|
-
"#CC0000",
|
|
37946
|
-
"#CC0033",
|
|
37947
|
-
"#CC0066",
|
|
37948
|
-
"#CC0099",
|
|
37949
|
-
"#CC00CC",
|
|
37950
|
-
"#CC00FF",
|
|
37951
|
-
"#CC3300",
|
|
37952
|
-
"#CC3333",
|
|
37953
|
-
"#CC3366",
|
|
37954
|
-
"#CC3399",
|
|
37955
|
-
"#CC33CC",
|
|
37956
|
-
"#CC33FF",
|
|
37957
|
-
"#CC6600",
|
|
37958
|
-
"#CC6633",
|
|
37959
|
-
"#CC9900",
|
|
37960
|
-
"#CC9933",
|
|
37961
|
-
"#CCCC00",
|
|
37962
|
-
"#CCCC33",
|
|
37963
|
-
"#FF0000",
|
|
37964
|
-
"#FF0033",
|
|
37965
|
-
"#FF0066",
|
|
37966
|
-
"#FF0099",
|
|
37967
|
-
"#FF00CC",
|
|
37968
|
-
"#FF00FF",
|
|
37969
|
-
"#FF3300",
|
|
37970
|
-
"#FF3333",
|
|
37971
|
-
"#FF3366",
|
|
37972
|
-
"#FF3399",
|
|
37973
|
-
"#FF33CC",
|
|
37974
|
-
"#FF33FF",
|
|
37975
|
-
"#FF6600",
|
|
37976
|
-
"#FF6633",
|
|
37977
|
-
"#FF9900",
|
|
37978
|
-
"#FF9933",
|
|
37979
|
-
"#FFCC00",
|
|
37980
|
-
"#FFCC33"
|
|
37981
|
-
];
|
|
37982
|
-
function useColors() {
|
|
37983
|
-
if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
|
|
37984
|
-
return true;
|
|
37985
|
-
}
|
|
37986
|
-
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
37987
|
-
return false;
|
|
37988
|
-
}
|
|
37989
|
-
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
|
37990
|
-
typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
|
37991
|
-
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
37992
|
-
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
|
37993
|
-
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
37994
|
-
}
|
|
37995
|
-
function formatArgs(args) {
|
|
37996
|
-
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module2.exports.humanize(this.diff);
|
|
37997
|
-
if (!this.useColors) {
|
|
37998
|
-
return;
|
|
37999
|
-
}
|
|
38000
|
-
const c2 = "color: " + this.color;
|
|
38001
|
-
args.splice(1, 0, c2, "color: inherit");
|
|
38002
|
-
let index = 0;
|
|
38003
|
-
let lastC = 0;
|
|
38004
|
-
args[0].replace(/%[a-zA-Z%]/g, (match) => {
|
|
38005
|
-
if (match === "%%") {
|
|
38006
|
-
return;
|
|
38007
|
-
}
|
|
38008
|
-
index++;
|
|
38009
|
-
if (match === "%c") {
|
|
38010
|
-
lastC = index;
|
|
38011
|
-
}
|
|
38012
|
-
});
|
|
38013
|
-
args.splice(lastC, 0, c2);
|
|
38014
|
-
}
|
|
38015
|
-
exports2.log = console.debug || console.log || (() => {
|
|
38016
|
-
});
|
|
38017
|
-
function save(namespaces) {
|
|
38018
|
-
try {
|
|
38019
|
-
if (namespaces) {
|
|
38020
|
-
exports2.storage.setItem("debug", namespaces);
|
|
38021
|
-
} else {
|
|
38022
|
-
exports2.storage.removeItem("debug");
|
|
38023
|
-
}
|
|
38024
|
-
} catch (error) {
|
|
38025
|
-
}
|
|
38026
|
-
}
|
|
38027
|
-
function load() {
|
|
38028
|
-
let r4;
|
|
38029
|
-
try {
|
|
38030
|
-
r4 = exports2.storage.getItem("debug");
|
|
38031
|
-
} catch (error) {
|
|
38032
|
-
}
|
|
38033
|
-
if (!r4 && typeof process !== "undefined" && "env" in process) {
|
|
38034
|
-
r4 = process.env.DEBUG;
|
|
38035
|
-
}
|
|
38036
|
-
return r4;
|
|
38037
|
-
}
|
|
38038
|
-
function localstorage() {
|
|
38039
|
-
try {
|
|
38040
|
-
return localStorage;
|
|
38041
|
-
} catch (error) {
|
|
38042
|
-
}
|
|
38043
|
-
}
|
|
38044
|
-
module2.exports = require_common2()(exports2);
|
|
38045
|
-
var { formatters } = module2.exports;
|
|
38046
|
-
formatters.j = function(v2) {
|
|
38047
|
-
try {
|
|
38048
|
-
return JSON.stringify(v2);
|
|
38049
|
-
} catch (error) {
|
|
38050
|
-
return "[UnexpectedJSONParseError]: " + error.message;
|
|
38051
|
-
}
|
|
38052
|
-
};
|
|
38053
|
-
}
|
|
38054
|
-
});
|
|
38055
|
-
|
|
38056
|
-
// ../../node_modules/has-flag/index.js
|
|
38057
|
-
var require_has_flag2 = __commonJS({
|
|
38058
|
-
"../../node_modules/has-flag/index.js"(exports2, module2) {
|
|
38059
|
-
"use strict";
|
|
38060
|
-
module2.exports = (flag, argv = process.argv) => {
|
|
38061
|
-
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
38062
|
-
const position = argv.indexOf(prefix + flag);
|
|
38063
|
-
const terminatorPosition = argv.indexOf("--");
|
|
38064
|
-
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
38065
|
-
};
|
|
38066
|
-
}
|
|
38067
|
-
});
|
|
38068
|
-
|
|
38069
|
-
// ../../node_modules/supports-color/index.js
|
|
38070
|
-
var require_supports_color = __commonJS({
|
|
38071
|
-
"../../node_modules/supports-color/index.js"(exports2, module2) {
|
|
38072
|
-
"use strict";
|
|
38073
|
-
var os = require("os");
|
|
38074
|
-
var tty = require("tty");
|
|
38075
|
-
var hasFlag = require_has_flag2();
|
|
38076
|
-
var { env } = process;
|
|
38077
|
-
var flagForceColor;
|
|
38078
|
-
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
38079
|
-
flagForceColor = 0;
|
|
38080
|
-
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
38081
|
-
flagForceColor = 1;
|
|
38082
|
-
}
|
|
38083
|
-
function envForceColor() {
|
|
38084
|
-
if ("FORCE_COLOR" in env) {
|
|
38085
|
-
if (env.FORCE_COLOR === "true") {
|
|
38086
|
-
return 1;
|
|
38087
|
-
}
|
|
38088
|
-
if (env.FORCE_COLOR === "false") {
|
|
38089
|
-
return 0;
|
|
38090
|
-
}
|
|
38091
|
-
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
38092
|
-
}
|
|
38093
|
-
}
|
|
38094
|
-
function translateLevel(level) {
|
|
38095
|
-
if (level === 0) {
|
|
38096
|
-
return false;
|
|
38097
|
-
}
|
|
38098
|
-
return {
|
|
38099
|
-
level,
|
|
38100
|
-
hasBasic: true,
|
|
38101
|
-
has256: level >= 2,
|
|
38102
|
-
has16m: level >= 3
|
|
38103
|
-
};
|
|
38104
|
-
}
|
|
38105
|
-
function supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
38106
|
-
const noFlagForceColor = envForceColor();
|
|
38107
|
-
if (noFlagForceColor !== void 0) {
|
|
38108
|
-
flagForceColor = noFlagForceColor;
|
|
38109
|
-
}
|
|
38110
|
-
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
38111
|
-
if (forceColor === 0) {
|
|
38112
|
-
return 0;
|
|
38113
|
-
}
|
|
38114
|
-
if (sniffFlags) {
|
|
38115
|
-
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
38116
|
-
return 3;
|
|
38117
|
-
}
|
|
38118
|
-
if (hasFlag("color=256")) {
|
|
38119
|
-
return 2;
|
|
38120
|
-
}
|
|
38121
|
-
}
|
|
38122
|
-
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
38123
|
-
return 0;
|
|
38124
|
-
}
|
|
38125
|
-
const min = forceColor || 0;
|
|
38126
|
-
if (env.TERM === "dumb") {
|
|
38127
|
-
return min;
|
|
38128
|
-
}
|
|
38129
|
-
if (process.platform === "win32") {
|
|
38130
|
-
const osRelease = os.release().split(".");
|
|
38131
|
-
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
38132
|
-
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
38133
|
-
}
|
|
38134
|
-
return 1;
|
|
38135
|
-
}
|
|
38136
|
-
if ("CI" in env) {
|
|
38137
|
-
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
38138
|
-
return 1;
|
|
38139
|
-
}
|
|
38140
|
-
return min;
|
|
38141
|
-
}
|
|
38142
|
-
if ("TEAMCITY_VERSION" in env) {
|
|
38143
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
38144
|
-
}
|
|
38145
|
-
if (env.COLORTERM === "truecolor") {
|
|
38146
|
-
return 3;
|
|
38147
|
-
}
|
|
38148
|
-
if ("TERM_PROGRAM" in env) {
|
|
38149
|
-
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
38150
|
-
switch (env.TERM_PROGRAM) {
|
|
38151
|
-
case "iTerm.app":
|
|
38152
|
-
return version >= 3 ? 3 : 2;
|
|
38153
|
-
case "Apple_Terminal":
|
|
38154
|
-
return 2;
|
|
38155
|
-
}
|
|
38156
|
-
}
|
|
38157
|
-
if (/-256(color)?$/i.test(env.TERM)) {
|
|
38158
|
-
return 2;
|
|
38159
|
-
}
|
|
38160
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
38161
|
-
return 1;
|
|
38162
|
-
}
|
|
38163
|
-
if ("COLORTERM" in env) {
|
|
38164
|
-
return 1;
|
|
38165
|
-
}
|
|
38166
|
-
return min;
|
|
38167
|
-
}
|
|
38168
|
-
function getSupportLevel(stream, options = {}) {
|
|
38169
|
-
const level = supportsColor(stream, {
|
|
38170
|
-
streamIsTTY: stream && stream.isTTY,
|
|
38171
|
-
...options
|
|
38172
|
-
});
|
|
38173
|
-
return translateLevel(level);
|
|
38174
|
-
}
|
|
38175
|
-
module2.exports = {
|
|
38176
|
-
supportsColor: getSupportLevel,
|
|
38177
|
-
stdout: getSupportLevel({ isTTY: tty.isatty(1) }),
|
|
38178
|
-
stderr: getSupportLevel({ isTTY: tty.isatty(2) })
|
|
38179
|
-
};
|
|
38180
|
-
}
|
|
38181
|
-
});
|
|
38182
|
-
|
|
38183
|
-
// ../../node_modules/debug/src/node.js
|
|
38184
|
-
var require_node3 = __commonJS({
|
|
38185
|
-
"../../node_modules/debug/src/node.js"(exports2, module2) {
|
|
38186
|
-
"use strict";
|
|
38187
|
-
var tty = require("tty");
|
|
38188
|
-
var util = require("util");
|
|
38189
|
-
exports2.init = init;
|
|
38190
|
-
exports2.log = log;
|
|
38191
|
-
exports2.formatArgs = formatArgs;
|
|
38192
|
-
exports2.save = save;
|
|
38193
|
-
exports2.load = load;
|
|
38194
|
-
exports2.useColors = useColors;
|
|
38195
|
-
exports2.destroy = util.deprecate(
|
|
38196
|
-
() => {
|
|
38197
|
-
},
|
|
38198
|
-
"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."
|
|
38199
|
-
);
|
|
38200
|
-
exports2.colors = [6, 2, 3, 4, 5, 1];
|
|
38201
|
-
try {
|
|
38202
|
-
const supportsColor = require_supports_color();
|
|
38203
|
-
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
|
38204
|
-
exports2.colors = [
|
|
38205
|
-
20,
|
|
38206
|
-
21,
|
|
38207
|
-
26,
|
|
38208
|
-
27,
|
|
38209
|
-
32,
|
|
38210
|
-
33,
|
|
38211
|
-
38,
|
|
38212
|
-
39,
|
|
38213
|
-
40,
|
|
38214
|
-
41,
|
|
38215
|
-
42,
|
|
38216
|
-
43,
|
|
38217
|
-
44,
|
|
38218
|
-
45,
|
|
38219
|
-
56,
|
|
38220
|
-
57,
|
|
38221
|
-
62,
|
|
38222
|
-
63,
|
|
38223
|
-
68,
|
|
38224
|
-
69,
|
|
38225
|
-
74,
|
|
38226
|
-
75,
|
|
38227
|
-
76,
|
|
38228
|
-
77,
|
|
38229
|
-
78,
|
|
38230
|
-
79,
|
|
38231
|
-
80,
|
|
38232
|
-
81,
|
|
38233
|
-
92,
|
|
38234
|
-
93,
|
|
38235
|
-
98,
|
|
38236
|
-
99,
|
|
38237
|
-
112,
|
|
38238
|
-
113,
|
|
38239
|
-
128,
|
|
38240
|
-
129,
|
|
38241
|
-
134,
|
|
38242
|
-
135,
|
|
38243
|
-
148,
|
|
38244
|
-
149,
|
|
38245
|
-
160,
|
|
38246
|
-
161,
|
|
38247
|
-
162,
|
|
38248
|
-
163,
|
|
38249
|
-
164,
|
|
38250
|
-
165,
|
|
38251
|
-
166,
|
|
38252
|
-
167,
|
|
38253
|
-
168,
|
|
38254
|
-
169,
|
|
38255
|
-
170,
|
|
38256
|
-
171,
|
|
38257
|
-
172,
|
|
38258
|
-
173,
|
|
38259
|
-
178,
|
|
38260
|
-
179,
|
|
38261
|
-
184,
|
|
38262
|
-
185,
|
|
38263
|
-
196,
|
|
38264
|
-
197,
|
|
38265
|
-
198,
|
|
38266
|
-
199,
|
|
38267
|
-
200,
|
|
38268
|
-
201,
|
|
38269
|
-
202,
|
|
38270
|
-
203,
|
|
38271
|
-
204,
|
|
38272
|
-
205,
|
|
38273
|
-
206,
|
|
38274
|
-
207,
|
|
38275
|
-
208,
|
|
38276
|
-
209,
|
|
38277
|
-
214,
|
|
38278
|
-
215,
|
|
38279
|
-
220,
|
|
38280
|
-
221
|
|
38281
|
-
];
|
|
38282
|
-
}
|
|
38283
|
-
} catch (error) {
|
|
38284
|
-
}
|
|
38285
|
-
exports2.inspectOpts = Object.keys(process.env).filter((key) => {
|
|
38286
|
-
return /^debug_/i.test(key);
|
|
38287
|
-
}).reduce((obj, key) => {
|
|
38288
|
-
const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_2, k2) => {
|
|
38289
|
-
return k2.toUpperCase();
|
|
38290
|
-
});
|
|
38291
|
-
let val = process.env[key];
|
|
38292
|
-
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
|
38293
|
-
val = true;
|
|
38294
|
-
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
|
38295
|
-
val = false;
|
|
38296
|
-
} else if (val === "null") {
|
|
38297
|
-
val = null;
|
|
38298
|
-
} else {
|
|
38299
|
-
val = Number(val);
|
|
38300
|
-
}
|
|
38301
|
-
obj[prop] = val;
|
|
38302
|
-
return obj;
|
|
38303
|
-
}, {});
|
|
38304
|
-
function useColors() {
|
|
38305
|
-
return "colors" in exports2.inspectOpts ? Boolean(exports2.inspectOpts.colors) : tty.isatty(process.stderr.fd);
|
|
38306
|
-
}
|
|
38307
|
-
function formatArgs(args) {
|
|
38308
|
-
const { namespace: name, useColors: useColors2 } = this;
|
|
38309
|
-
if (useColors2) {
|
|
38310
|
-
const c2 = this.color;
|
|
38311
|
-
const colorCode = "\x1B[3" + (c2 < 8 ? c2 : "8;5;" + c2);
|
|
38312
|
-
const prefix = ` ${colorCode};1m${name} \x1B[0m`;
|
|
38313
|
-
args[0] = prefix + args[0].split("\n").join("\n" + prefix);
|
|
38314
|
-
args.push(colorCode + "m+" + module2.exports.humanize(this.diff) + "\x1B[0m");
|
|
38315
|
-
} else {
|
|
38316
|
-
args[0] = getDate() + name + " " + args[0];
|
|
38317
|
-
}
|
|
38318
|
-
}
|
|
38319
|
-
function getDate() {
|
|
38320
|
-
if (exports2.inspectOpts.hideDate) {
|
|
38321
|
-
return "";
|
|
38322
|
-
}
|
|
38323
|
-
return (/* @__PURE__ */ new Date()).toISOString() + " ";
|
|
38324
|
-
}
|
|
38325
|
-
function log(...args) {
|
|
38326
|
-
return process.stderr.write(util.format(...args) + "\n");
|
|
38327
|
-
}
|
|
38328
|
-
function save(namespaces) {
|
|
38329
|
-
if (namespaces) {
|
|
38330
|
-
process.env.DEBUG = namespaces;
|
|
38331
|
-
} else {
|
|
38332
|
-
delete process.env.DEBUG;
|
|
38333
|
-
}
|
|
38334
|
-
}
|
|
38335
|
-
function load() {
|
|
38336
|
-
return process.env.DEBUG;
|
|
38337
|
-
}
|
|
38338
|
-
function init(debug) {
|
|
38339
|
-
debug.inspectOpts = {};
|
|
38340
|
-
const keys = Object.keys(exports2.inspectOpts);
|
|
38341
|
-
for (let i2 = 0; i2 < keys.length; i2++) {
|
|
38342
|
-
debug.inspectOpts[keys[i2]] = exports2.inspectOpts[keys[i2]];
|
|
38343
|
-
}
|
|
38344
|
-
}
|
|
38345
|
-
module2.exports = require_common2()(exports2);
|
|
38346
|
-
var { formatters } = module2.exports;
|
|
38347
|
-
formatters.o = function(v2) {
|
|
38348
|
-
this.inspectOpts.colors = this.useColors;
|
|
38349
|
-
return util.inspect(v2, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
|
|
38350
|
-
};
|
|
38351
|
-
formatters.O = function(v2) {
|
|
38352
|
-
this.inspectOpts.colors = this.useColors;
|
|
38353
|
-
return util.inspect(v2, this.inspectOpts);
|
|
38354
|
-
};
|
|
38355
|
-
}
|
|
38356
|
-
});
|
|
38357
|
-
|
|
38358
|
-
// ../../node_modules/debug/src/index.js
|
|
38359
|
-
var require_src = __commonJS({
|
|
38360
|
-
"../../node_modules/debug/src/index.js"(exports2, module2) {
|
|
38361
|
-
"use strict";
|
|
38362
|
-
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
|
38363
|
-
module2.exports = require_browser();
|
|
38364
|
-
} else {
|
|
38365
|
-
module2.exports = require_node3();
|
|
38366
|
-
}
|
|
38367
|
-
}
|
|
38368
|
-
});
|
|
38369
|
-
|
|
38370
|
-
// ../../node_modules/@serialport/stream/dist/index.js
|
|
38371
|
-
var require_dist11 = __commonJS({
|
|
38372
|
-
"../../node_modules/@serialport/stream/dist/index.js"(exports2) {
|
|
38373
|
-
"use strict";
|
|
38374
|
-
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
|
38375
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
38376
|
-
};
|
|
38377
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
38378
|
-
exports2.SerialPortStream = exports2.DisconnectedError = void 0;
|
|
38379
|
-
var stream_1 = require("stream");
|
|
38380
|
-
var debug_1 = __importDefault(require_src());
|
|
38381
|
-
var debug = (0, debug_1.default)("serialport/stream");
|
|
38382
|
-
var DisconnectedError = class extends Error {
|
|
38383
|
-
constructor(message) {
|
|
38384
|
-
super(message);
|
|
38385
|
-
__publicField(this, "disconnected");
|
|
38386
|
-
this.disconnected = true;
|
|
38387
|
-
}
|
|
38388
|
-
};
|
|
38389
|
-
exports2.DisconnectedError = DisconnectedError;
|
|
38390
|
-
var defaultSetFlags = {
|
|
38391
|
-
brk: false,
|
|
38392
|
-
cts: false,
|
|
38393
|
-
dtr: true,
|
|
38394
|
-
rts: true
|
|
38395
|
-
};
|
|
38396
|
-
function allocNewReadPool(poolSize) {
|
|
38397
|
-
const pool = Buffer.allocUnsafe(poolSize);
|
|
38398
|
-
pool.used = 0;
|
|
38399
|
-
return pool;
|
|
38400
|
-
}
|
|
38401
|
-
var SerialPortStream = class extends stream_1.Duplex {
|
|
38402
|
-
/**
|
|
38403
|
-
* Create a new serial port object for the `path`. In the case of invalid arguments or invalid options, when constructing a new SerialPort it will throw an error. The port will open automatically by default, which is the equivalent of calling `port.open(openCallback)` in the next tick. You can disable this by setting the option `autoOpen` to `false`.
|
|
38404
|
-
* @emits open
|
|
38405
|
-
* @emits data
|
|
38406
|
-
* @emits close
|
|
38407
|
-
* @emits error
|
|
38408
|
-
*/
|
|
38409
|
-
constructor(options, openCallback) {
|
|
38410
|
-
const settings = {
|
|
38411
|
-
autoOpen: true,
|
|
38412
|
-
endOnClose: false,
|
|
38413
|
-
highWaterMark: 64 * 1024,
|
|
38414
|
-
...options
|
|
38415
|
-
};
|
|
38416
|
-
super({
|
|
38417
|
-
highWaterMark: settings.highWaterMark
|
|
38418
|
-
});
|
|
38419
|
-
__publicField(this, "port");
|
|
38420
|
-
__publicField(this, "_pool");
|
|
38421
|
-
__publicField(this, "_kMinPoolSpace");
|
|
38422
|
-
__publicField(this, "opening");
|
|
38423
|
-
__publicField(this, "closing");
|
|
38424
|
-
__publicField(this, "settings");
|
|
38425
|
-
if (!settings.binding) {
|
|
38426
|
-
throw new TypeError('"Bindings" is invalid pass it as `options.binding`');
|
|
38427
|
-
}
|
|
38428
|
-
if (!settings.path) {
|
|
38429
|
-
throw new TypeError(`"path" is not defined: ${settings.path}`);
|
|
38430
|
-
}
|
|
38431
|
-
if (typeof settings.baudRate !== "number") {
|
|
38432
|
-
throw new TypeError(`"baudRate" must be a number: ${settings.baudRate}`);
|
|
38433
|
-
}
|
|
38434
|
-
this.settings = settings;
|
|
38435
|
-
this.opening = false;
|
|
38436
|
-
this.closing = false;
|
|
38437
|
-
this._pool = allocNewReadPool(this.settings.highWaterMark);
|
|
38438
|
-
this._kMinPoolSpace = 128;
|
|
38439
|
-
if (this.settings.autoOpen) {
|
|
38440
|
-
this.open(openCallback);
|
|
38441
|
-
}
|
|
38442
|
-
}
|
|
38443
|
-
get path() {
|
|
38444
|
-
return this.settings.path;
|
|
38445
|
-
}
|
|
38446
|
-
get baudRate() {
|
|
38447
|
-
return this.settings.baudRate;
|
|
38448
|
-
}
|
|
38449
|
-
get isOpen() {
|
|
38450
|
-
return (this.port?.isOpen ?? false) && !this.closing;
|
|
38451
|
-
}
|
|
38452
|
-
_error(error, callback) {
|
|
38453
|
-
if (callback) {
|
|
38454
|
-
callback.call(this, error);
|
|
38455
|
-
} else {
|
|
38456
|
-
this.emit("error", error);
|
|
38457
|
-
}
|
|
38458
|
-
}
|
|
38459
|
-
_asyncError(error, callback) {
|
|
38460
|
-
process.nextTick(() => this._error(error, callback));
|
|
38461
|
-
}
|
|
38462
|
-
/**
|
|
38463
|
-
* Opens a connection to the given serial port.
|
|
38464
|
-
* @param {ErrorCallback=} openCallback - Called after a connection is opened. If this is not provided and an error occurs, it will be emitted on the port's `error` event.
|
|
38465
|
-
* @emits open
|
|
38466
|
-
*/
|
|
38467
|
-
open(openCallback) {
|
|
38468
|
-
if (this.isOpen) {
|
|
38469
|
-
return this._asyncError(new Error("Port is already open"), openCallback);
|
|
38470
|
-
}
|
|
38471
|
-
if (this.opening) {
|
|
38472
|
-
return this._asyncError(new Error("Port is opening"), openCallback);
|
|
38473
|
-
}
|
|
38474
|
-
const { highWaterMark, binding, autoOpen, endOnClose, ...openOptions } = this.settings;
|
|
38475
|
-
this.opening = true;
|
|
38476
|
-
debug("opening", `path: ${this.path}`);
|
|
38477
|
-
this.settings.binding.open(openOptions).then((port) => {
|
|
38478
|
-
debug("opened", `path: ${this.path}`);
|
|
38479
|
-
this.port = port;
|
|
38480
|
-
this.opening = false;
|
|
38481
|
-
this.emit("open");
|
|
38482
|
-
if (openCallback) {
|
|
38483
|
-
openCallback.call(this, null);
|
|
38484
|
-
}
|
|
38485
|
-
}, (err) => {
|
|
38486
|
-
this.opening = false;
|
|
38487
|
-
debug("Binding #open had an error", err);
|
|
38488
|
-
this._error(err, openCallback);
|
|
38489
|
-
});
|
|
38490
|
-
}
|
|
38491
|
-
/**
|
|
38492
|
-
* Changes the baud rate for an open port. Emits an error or calls the callback if the baud rate isn't supported.
|
|
38493
|
-
* @param {object=} options Only supports `baudRate`.
|
|
38494
|
-
* @param {number=} [options.baudRate] The baud rate of the port to be opened. This should match one of the commonly available baud rates, such as 110, 300, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 57600, or 115200. Custom rates are supported best effort per platform. The device connected to the serial port is not guaranteed to support the requested baud rate, even if the port itself supports that baud rate.
|
|
38495
|
-
* @param {ErrorCallback=} [callback] Called once the port's baud rate changes. If `.update` is called without a callback, and there is an error, an error event is emitted.
|
|
38496
|
-
* @returns {undefined}
|
|
38497
|
-
*/
|
|
38498
|
-
update(options, callback) {
|
|
38499
|
-
if (!this.isOpen || !this.port) {
|
|
38500
|
-
debug("update attempted, but port is not open");
|
|
38501
|
-
return this._asyncError(new Error("Port is not open"), callback);
|
|
38502
|
-
}
|
|
38503
|
-
debug("update", `baudRate: ${options.baudRate}`);
|
|
38504
|
-
this.port.update(options).then(() => {
|
|
38505
|
-
debug("binding.update", "finished");
|
|
38506
|
-
this.settings.baudRate = options.baudRate;
|
|
38507
|
-
if (callback) {
|
|
38508
|
-
callback.call(this, null);
|
|
38509
|
-
}
|
|
38510
|
-
}, (err) => {
|
|
38511
|
-
debug("binding.update", "error", err);
|
|
38512
|
-
return this._error(err, callback);
|
|
38513
|
-
});
|
|
38514
|
-
}
|
|
38515
|
-
write(data2, encoding, callback) {
|
|
38516
|
-
if (Array.isArray(data2)) {
|
|
38517
|
-
data2 = Buffer.from(data2);
|
|
38518
|
-
}
|
|
38519
|
-
if (typeof encoding === "function") {
|
|
38520
|
-
return super.write(data2, encoding);
|
|
38521
|
-
}
|
|
38522
|
-
return super.write(data2, encoding, callback);
|
|
38523
|
-
}
|
|
38524
|
-
_write(data2, encoding, callback) {
|
|
38525
|
-
if (!this.isOpen || !this.port) {
|
|
38526
|
-
this.once("open", () => {
|
|
38527
|
-
this._write(data2, encoding, callback);
|
|
38528
|
-
});
|
|
38529
|
-
return;
|
|
38530
|
-
}
|
|
38531
|
-
debug("_write", `${data2.length} bytes of data`);
|
|
38532
|
-
this.port.write(data2).then(() => {
|
|
38533
|
-
debug("binding.write", "write finished");
|
|
38534
|
-
callback(null);
|
|
38535
|
-
}, (err) => {
|
|
38536
|
-
debug("binding.write", "error", err);
|
|
38537
|
-
if (!err.canceled) {
|
|
38538
|
-
this._disconnected(err);
|
|
38539
|
-
}
|
|
38540
|
-
callback(err);
|
|
38541
|
-
});
|
|
38542
|
-
}
|
|
38543
|
-
_writev(data2, callback) {
|
|
38544
|
-
debug("_writev", `${data2.length} chunks of data`);
|
|
38545
|
-
const dataV = data2.map((write) => write.chunk);
|
|
38546
|
-
this._write(Buffer.concat(dataV), void 0, callback);
|
|
38547
|
-
}
|
|
38548
|
-
_read(bytesToRead) {
|
|
38549
|
-
if (!this.isOpen || !this.port) {
|
|
38550
|
-
debug("_read", "queueing _read for after open");
|
|
38551
|
-
this.once("open", () => {
|
|
38552
|
-
this._read(bytesToRead);
|
|
38553
|
-
});
|
|
38554
|
-
return;
|
|
38555
|
-
}
|
|
38556
|
-
if (!this._pool || this._pool.length - this._pool.used < this._kMinPoolSpace) {
|
|
38557
|
-
debug("_read", "discarding the read buffer pool because it is below kMinPoolSpace");
|
|
38558
|
-
this._pool = allocNewReadPool(this.settings.highWaterMark);
|
|
38559
|
-
}
|
|
38560
|
-
const pool = this._pool;
|
|
38561
|
-
const toRead = Math.min(pool.length - pool.used, bytesToRead);
|
|
38562
|
-
const start = pool.used;
|
|
38563
|
-
debug("_read", `reading`, { start, toRead });
|
|
38564
|
-
this.port.read(pool, start, toRead).then(({ bytesRead }) => {
|
|
38565
|
-
debug("binding.read", `finished`, { bytesRead });
|
|
38566
|
-
if (bytesRead === 0) {
|
|
38567
|
-
debug("binding.read", "Zero bytes read closing readable stream");
|
|
38568
|
-
this.push(null);
|
|
38569
|
-
return;
|
|
38570
|
-
}
|
|
38571
|
-
pool.used += bytesRead;
|
|
38572
|
-
this.push(pool.slice(start, start + bytesRead));
|
|
38573
|
-
}, (err) => {
|
|
38574
|
-
debug("binding.read", `error`, err);
|
|
38575
|
-
if (!err.canceled) {
|
|
38576
|
-
this._disconnected(err);
|
|
38577
|
-
}
|
|
38578
|
-
this._read(bytesToRead);
|
|
38579
|
-
});
|
|
38580
|
-
}
|
|
38581
|
-
_disconnected(err) {
|
|
38582
|
-
if (!this.isOpen) {
|
|
38583
|
-
debug("disconnected aborted because already closed", err);
|
|
38584
|
-
return;
|
|
38585
|
-
}
|
|
38586
|
-
debug("disconnected", err);
|
|
38587
|
-
this.close(void 0, new DisconnectedError(err.message));
|
|
38588
|
-
}
|
|
38589
|
-
/**
|
|
38590
|
-
* Closes an open connection.
|
|
38591
|
-
*
|
|
38592
|
-
* If there are in progress writes when the port is closed the writes will error.
|
|
38593
|
-
* @param {ErrorCallback} callback Called once a connection is closed.
|
|
38594
|
-
* @param {Error} disconnectError used internally to propagate a disconnect error
|
|
38595
|
-
*/
|
|
38596
|
-
close(callback, disconnectError = null) {
|
|
38597
|
-
if (!this.isOpen || !this.port) {
|
|
38598
|
-
debug("close attempted, but port is not open");
|
|
38599
|
-
return this._asyncError(new Error("Port is not open"), callback);
|
|
38600
|
-
}
|
|
38601
|
-
this.closing = true;
|
|
38602
|
-
debug("#close");
|
|
38603
|
-
this.port.close().then(() => {
|
|
38604
|
-
this.closing = false;
|
|
38605
|
-
debug("binding.close", "finished");
|
|
38606
|
-
this.emit("close", disconnectError);
|
|
38607
|
-
if (this.settings.endOnClose) {
|
|
38608
|
-
this.emit("end");
|
|
38609
|
-
}
|
|
38610
|
-
if (callback) {
|
|
38611
|
-
callback.call(this, disconnectError);
|
|
38612
|
-
}
|
|
38613
|
-
}, (err) => {
|
|
38614
|
-
this.closing = false;
|
|
38615
|
-
debug("binding.close", "had an error", err);
|
|
38616
|
-
return this._error(err, callback);
|
|
38617
|
-
});
|
|
38618
|
-
}
|
|
38619
|
-
/**
|
|
38620
|
-
* Set control flags on an open port. Uses [`SetCommMask`](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363257(v=vs.85).aspx) for Windows and [`ioctl`](http://linux.die.net/man/4/tty_ioctl) for OS X and Linux.
|
|
38621
|
-
*
|
|
38622
|
-
* All options are operating system default when the port is opened. Every flag is set on each call to the provided or default values. If options isn't provided default options is used.
|
|
38623
|
-
*/
|
|
38624
|
-
set(options, callback) {
|
|
38625
|
-
if (!this.isOpen || !this.port) {
|
|
38626
|
-
debug("set attempted, but port is not open");
|
|
38627
|
-
return this._asyncError(new Error("Port is not open"), callback);
|
|
38628
|
-
}
|
|
38629
|
-
const settings = { ...defaultSetFlags, ...options };
|
|
38630
|
-
debug("#set", settings);
|
|
38631
|
-
this.port.set(settings).then(() => {
|
|
38632
|
-
debug("binding.set", "finished");
|
|
38633
|
-
if (callback) {
|
|
38634
|
-
callback.call(this, null);
|
|
38635
|
-
}
|
|
38636
|
-
}, (err) => {
|
|
38637
|
-
debug("binding.set", "had an error", err);
|
|
38638
|
-
return this._error(err, callback);
|
|
38639
|
-
});
|
|
38640
|
-
}
|
|
38641
|
-
/**
|
|
38642
|
-
* Returns the control flags (CTS, DSR, DCD) on the open port.
|
|
38643
|
-
* Uses [`GetCommModemStatus`](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363258(v=vs.85).aspx) for Windows and [`ioctl`](http://linux.die.net/man/4/tty_ioctl) for mac and linux.
|
|
38644
|
-
*/
|
|
38645
|
-
get(callback) {
|
|
38646
|
-
if (!this.isOpen || !this.port) {
|
|
38647
|
-
debug("get attempted, but port is not open");
|
|
38648
|
-
return this._asyncError(new Error("Port is not open"), callback);
|
|
38649
|
-
}
|
|
38650
|
-
debug("#get");
|
|
38651
|
-
this.port.get().then((status) => {
|
|
38652
|
-
debug("binding.get", "finished");
|
|
38653
|
-
callback.call(this, null, status);
|
|
38654
|
-
}, (err) => {
|
|
38655
|
-
debug("binding.get", "had an error", err);
|
|
38656
|
-
return this._error(err, callback);
|
|
38657
|
-
});
|
|
38658
|
-
}
|
|
38659
|
-
/**
|
|
38660
|
-
* Flush discards data received but not read, and written but not transmitted by the operating system. For more technical details, see [`tcflush(fd, TCIOFLUSH)`](http://linux.die.net/man/3/tcflush) for Mac/Linux and [`FlushFileBuffers`](http://msdn.microsoft.com/en-us/library/windows/desktop/aa364439) for Windows.
|
|
38661
|
-
*/
|
|
38662
|
-
flush(callback) {
|
|
38663
|
-
if (!this.isOpen || !this.port) {
|
|
38664
|
-
debug("flush attempted, but port is not open");
|
|
38665
|
-
return this._asyncError(new Error("Port is not open"), callback);
|
|
38666
|
-
}
|
|
38667
|
-
debug("#flush");
|
|
38668
|
-
this.port.flush().then(() => {
|
|
38669
|
-
debug("binding.flush", "finished");
|
|
38670
|
-
if (callback) {
|
|
38671
|
-
callback.call(this, null);
|
|
38672
|
-
}
|
|
38673
|
-
}, (err) => {
|
|
38674
|
-
debug("binding.flush", "had an error", err);
|
|
38675
|
-
return this._error(err, callback);
|
|
38676
|
-
});
|
|
38677
|
-
}
|
|
38678
|
-
/**
|
|
38679
|
-
* Waits until all output data is transmitted to the serial port. After any pending write has completed it calls [`tcdrain()`](http://linux.die.net/man/3/tcdrain) or [FlushFileBuffers()](https://msdn.microsoft.com/en-us/library/windows/desktop/aa364439(v=vs.85).aspx) to ensure it has been written to the device.
|
|
38680
|
-
* @example
|
|
38681
|
-
Write the `data` and wait until it has finished transmitting to the target serial port before calling the callback. This will queue until the port is open and writes are finished.
|
|
38682
|
-
|
|
38683
|
-
```js
|
|
38684
|
-
function writeAndDrain (data, callback) {
|
|
38685
|
-
port.write(data);
|
|
38686
|
-
port.drain(callback);
|
|
38687
|
-
}
|
|
38688
|
-
```
|
|
38689
|
-
*/
|
|
38690
|
-
drain(callback) {
|
|
38691
|
-
debug("drain");
|
|
38692
|
-
if (!this.isOpen || !this.port) {
|
|
38693
|
-
debug("drain queuing on port open");
|
|
38694
|
-
this.once("open", () => {
|
|
38695
|
-
this.drain(callback);
|
|
38696
|
-
});
|
|
38697
|
-
return;
|
|
38698
|
-
}
|
|
38699
|
-
this.port.drain().then(() => {
|
|
38700
|
-
debug("binding.drain", "finished");
|
|
38701
|
-
if (callback) {
|
|
38702
|
-
callback.call(this, null);
|
|
38703
|
-
}
|
|
38704
|
-
}, (err) => {
|
|
38705
|
-
debug("binding.drain", "had an error", err);
|
|
38706
|
-
return this._error(err, callback);
|
|
38707
|
-
});
|
|
38708
|
-
}
|
|
38709
|
-
};
|
|
38710
|
-
exports2.SerialPortStream = SerialPortStream;
|
|
38711
|
-
}
|
|
38712
|
-
});
|
|
38713
|
-
|
|
38714
|
-
// ../../node_modules/@serialport/binding-mock/dist/index.js
|
|
38715
|
-
var require_dist12 = __commonJS({
|
|
38716
|
-
"../../node_modules/@serialport/binding-mock/dist/index.js"(exports2) {
|
|
38717
|
-
"use strict";
|
|
38718
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
38719
|
-
var debugFactory = require_src();
|
|
38720
|
-
function _interopDefaultLegacy(e) {
|
|
38721
|
-
return e && typeof e === "object" && "default" in e ? e : { "default": e };
|
|
38722
|
-
}
|
|
38723
|
-
var debugFactory__default = /* @__PURE__ */ _interopDefaultLegacy(debugFactory);
|
|
38724
|
-
var debug = debugFactory__default["default"]("serialport/binding-mock");
|
|
38725
|
-
var ports = {};
|
|
38726
|
-
var serialNumber = 0;
|
|
38727
|
-
function resolveNextTick() {
|
|
38728
|
-
return new Promise((resolve) => process.nextTick(() => resolve()));
|
|
38729
|
-
}
|
|
38730
|
-
var CanceledError = class extends Error {
|
|
38731
|
-
constructor(message) {
|
|
38732
|
-
super(message);
|
|
38733
|
-
this.canceled = true;
|
|
38734
|
-
}
|
|
38735
|
-
};
|
|
38736
|
-
var MockBinding = {
|
|
38737
|
-
reset() {
|
|
38738
|
-
ports = {};
|
|
38739
|
-
serialNumber = 0;
|
|
38740
|
-
},
|
|
38741
|
-
// Create a mock port
|
|
38742
|
-
createPort(path, options = {}) {
|
|
38743
|
-
serialNumber++;
|
|
38744
|
-
const optWithDefaults = Object.assign({ echo: false, record: false, manufacturer: "The J5 Robotics Company", vendorId: void 0, productId: void 0, maxReadSize: 1024 }, options);
|
|
38745
|
-
ports[path] = {
|
|
38746
|
-
data: Buffer.alloc(0),
|
|
38747
|
-
echo: optWithDefaults.echo,
|
|
38748
|
-
record: optWithDefaults.record,
|
|
38749
|
-
readyData: optWithDefaults.readyData,
|
|
38750
|
-
maxReadSize: optWithDefaults.maxReadSize,
|
|
38751
|
-
info: {
|
|
38752
|
-
path,
|
|
38753
|
-
manufacturer: optWithDefaults.manufacturer,
|
|
38754
|
-
serialNumber: `${serialNumber}`,
|
|
38755
|
-
pnpId: void 0,
|
|
38756
|
-
locationId: void 0,
|
|
38757
|
-
vendorId: optWithDefaults.vendorId,
|
|
38758
|
-
productId: optWithDefaults.productId
|
|
38759
|
-
}
|
|
38760
|
-
};
|
|
38761
|
-
debug(serialNumber, "created port", JSON.stringify({ path, opt: options }));
|
|
38762
|
-
},
|
|
38763
|
-
async list() {
|
|
38764
|
-
debug(null, "list");
|
|
38765
|
-
return Object.values(ports).map((port) => port.info);
|
|
38766
|
-
},
|
|
38767
|
-
async open(options) {
|
|
38768
|
-
var _a;
|
|
38769
|
-
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
38770
|
-
throw new TypeError('"options" is not an object');
|
|
38771
|
-
}
|
|
38772
|
-
if (!options.path) {
|
|
38773
|
-
throw new TypeError('"path" is not a valid port');
|
|
38774
|
-
}
|
|
38775
|
-
if (!options.baudRate) {
|
|
38776
|
-
throw new TypeError('"baudRate" is not a valid baudRate');
|
|
38777
|
-
}
|
|
38778
|
-
const openOptions = Object.assign({ dataBits: 8, lock: true, stopBits: 1, parity: "none", rtscts: false, xon: false, xoff: false, xany: false, hupcl: true }, options);
|
|
38779
|
-
const { path } = openOptions;
|
|
38780
|
-
debug(null, `open: opening path ${path}`);
|
|
38781
|
-
const port = ports[path];
|
|
38782
|
-
await resolveNextTick();
|
|
38783
|
-
if (!port) {
|
|
38784
|
-
throw new Error(`Port does not exist - please call MockBinding.createPort('${path}') first`);
|
|
38785
|
-
}
|
|
38786
|
-
const serialNumber2 = port.info.serialNumber;
|
|
38787
|
-
if ((_a = port.openOpt) === null || _a === void 0 ? void 0 : _a.lock) {
|
|
38788
|
-
debug(serialNumber2, "open: Port is locked cannot open");
|
|
38789
|
-
throw new Error("Port is locked cannot open");
|
|
38790
|
-
}
|
|
38791
|
-
debug(serialNumber2, `open: opened path ${path}`);
|
|
38792
|
-
port.openOpt = Object.assign({}, openOptions);
|
|
38793
|
-
return new MockPortBinding(port, openOptions);
|
|
38794
|
-
}
|
|
38795
|
-
};
|
|
38796
|
-
var MockPortBinding = class {
|
|
38797
|
-
constructor(port, openOptions) {
|
|
38798
|
-
this.port = port;
|
|
38799
|
-
this.openOptions = openOptions;
|
|
38800
|
-
this.pendingRead = null;
|
|
38801
|
-
this.isOpen = true;
|
|
38802
|
-
this.lastWrite = null;
|
|
38803
|
-
this.recording = Buffer.alloc(0);
|
|
38804
|
-
this.writeOperation = null;
|
|
38805
|
-
this.serialNumber = port.info.serialNumber;
|
|
38806
|
-
if (port.readyData) {
|
|
38807
|
-
const data2 = port.readyData;
|
|
38808
|
-
process.nextTick(() => {
|
|
38809
|
-
if (this.isOpen) {
|
|
38810
|
-
debug(this.serialNumber, "emitting ready data");
|
|
38811
|
-
this.emitData(data2);
|
|
38812
|
-
}
|
|
38813
|
-
});
|
|
38814
|
-
}
|
|
38815
|
-
}
|
|
38816
|
-
// Emit data on a mock port
|
|
38817
|
-
emitData(data2) {
|
|
38818
|
-
if (!this.isOpen || !this.port) {
|
|
38819
|
-
throw new Error("Port must be open to pretend to receive data");
|
|
38820
|
-
}
|
|
38821
|
-
const bufferData = Buffer.isBuffer(data2) ? data2 : Buffer.from(data2);
|
|
38822
|
-
debug(this.serialNumber, "emitting data - pending read:", Boolean(this.pendingRead));
|
|
38823
|
-
this.port.data = Buffer.concat([this.port.data, bufferData]);
|
|
38824
|
-
if (this.pendingRead) {
|
|
38825
|
-
process.nextTick(this.pendingRead);
|
|
38826
|
-
this.pendingRead = null;
|
|
38827
|
-
}
|
|
38828
|
-
}
|
|
38829
|
-
async close() {
|
|
38830
|
-
debug(this.serialNumber, "close");
|
|
38831
|
-
if (!this.isOpen) {
|
|
38832
|
-
throw new Error("Port is not open");
|
|
38833
|
-
}
|
|
38834
|
-
const port = this.port;
|
|
38835
|
-
if (!port) {
|
|
38836
|
-
throw new Error("already closed");
|
|
38837
|
-
}
|
|
38838
|
-
port.openOpt = void 0;
|
|
38839
|
-
port.data = Buffer.alloc(0);
|
|
38840
|
-
debug(this.serialNumber, "port is closed");
|
|
38841
|
-
this.serialNumber = void 0;
|
|
38842
|
-
this.isOpen = false;
|
|
38843
|
-
if (this.pendingRead) {
|
|
38844
|
-
this.pendingRead(new CanceledError("port is closed"));
|
|
38845
|
-
}
|
|
38846
|
-
}
|
|
38847
|
-
async read(buffer, offset, length) {
|
|
38848
|
-
if (!Buffer.isBuffer(buffer)) {
|
|
38849
|
-
throw new TypeError('"buffer" is not a Buffer');
|
|
38850
|
-
}
|
|
38851
|
-
if (typeof offset !== "number" || isNaN(offset)) {
|
|
38852
|
-
throw new TypeError(`"offset" is not an integer got "${isNaN(offset) ? "NaN" : typeof offset}"`);
|
|
38853
|
-
}
|
|
38854
|
-
if (typeof length !== "number" || isNaN(length)) {
|
|
38855
|
-
throw new TypeError(`"length" is not an integer got "${isNaN(length) ? "NaN" : typeof length}"`);
|
|
38856
|
-
}
|
|
38857
|
-
if (buffer.length < offset + length) {
|
|
38858
|
-
throw new Error("buffer is too small");
|
|
38859
|
-
}
|
|
38860
|
-
if (!this.isOpen) {
|
|
38861
|
-
throw new Error("Port is not open");
|
|
38862
|
-
}
|
|
38863
|
-
debug(this.serialNumber, "read", length, "bytes");
|
|
38864
|
-
await resolveNextTick();
|
|
38865
|
-
if (!this.isOpen || !this.port) {
|
|
38866
|
-
throw new CanceledError("Read canceled");
|
|
38867
|
-
}
|
|
38868
|
-
if (this.port.data.length <= 0) {
|
|
38869
|
-
return new Promise((resolve, reject) => {
|
|
38870
|
-
this.pendingRead = (err) => {
|
|
38871
|
-
if (err) {
|
|
38872
|
-
return reject(err);
|
|
38873
|
-
}
|
|
38874
|
-
this.read(buffer, offset, length).then(resolve, reject);
|
|
38875
|
-
};
|
|
38876
|
-
});
|
|
38877
|
-
}
|
|
38878
|
-
const lengthToRead = this.port.maxReadSize > length ? length : this.port.maxReadSize;
|
|
38879
|
-
const data2 = this.port.data.slice(0, lengthToRead);
|
|
38880
|
-
const bytesRead = data2.copy(buffer, offset);
|
|
38881
|
-
this.port.data = this.port.data.slice(lengthToRead);
|
|
38882
|
-
debug(this.serialNumber, "read", bytesRead, "bytes");
|
|
38883
|
-
return { bytesRead, buffer };
|
|
38884
|
-
}
|
|
38885
|
-
async write(buffer) {
|
|
38886
|
-
if (!Buffer.isBuffer(buffer)) {
|
|
38887
|
-
throw new TypeError('"buffer" is not a Buffer');
|
|
38888
|
-
}
|
|
38889
|
-
if (!this.isOpen || !this.port) {
|
|
38890
|
-
debug("write", "error port is not open");
|
|
38891
|
-
throw new Error("Port is not open");
|
|
38892
|
-
}
|
|
38893
|
-
debug(this.serialNumber, "write", buffer.length, "bytes");
|
|
38894
|
-
if (this.writeOperation) {
|
|
38895
|
-
throw new Error("Overlapping writes are not supported and should be queued by the serialport object");
|
|
38896
|
-
}
|
|
38897
|
-
this.writeOperation = (async () => {
|
|
38898
|
-
await resolveNextTick();
|
|
38899
|
-
if (!this.isOpen || !this.port) {
|
|
38900
|
-
throw new Error("Write canceled");
|
|
38901
|
-
}
|
|
38902
|
-
const data2 = this.lastWrite = Buffer.from(buffer);
|
|
38903
|
-
if (this.port.record) {
|
|
38904
|
-
this.recording = Buffer.concat([this.recording, data2]);
|
|
38905
|
-
}
|
|
38906
|
-
if (this.port.echo) {
|
|
38907
|
-
process.nextTick(() => {
|
|
38908
|
-
if (this.isOpen) {
|
|
38909
|
-
this.emitData(data2);
|
|
38910
|
-
}
|
|
38911
|
-
});
|
|
38912
|
-
}
|
|
38913
|
-
this.writeOperation = null;
|
|
38914
|
-
debug(this.serialNumber, "writing finished");
|
|
38915
|
-
})();
|
|
38916
|
-
return this.writeOperation;
|
|
38917
|
-
}
|
|
38918
|
-
async update(options) {
|
|
38919
|
-
if (typeof options !== "object") {
|
|
38920
|
-
throw TypeError('"options" is not an object');
|
|
38921
|
-
}
|
|
38922
|
-
if (typeof options.baudRate !== "number") {
|
|
38923
|
-
throw new TypeError('"options.baudRate" is not a number');
|
|
38924
|
-
}
|
|
38925
|
-
debug(this.serialNumber, "update");
|
|
38926
|
-
if (!this.isOpen || !this.port) {
|
|
38927
|
-
throw new Error("Port is not open");
|
|
38928
|
-
}
|
|
38929
|
-
await resolveNextTick();
|
|
38930
|
-
if (this.port.openOpt) {
|
|
38931
|
-
this.port.openOpt.baudRate = options.baudRate;
|
|
38932
|
-
}
|
|
38933
|
-
}
|
|
38934
|
-
async set(options) {
|
|
38935
|
-
if (typeof options !== "object") {
|
|
38936
|
-
throw new TypeError('"options" is not an object');
|
|
38937
|
-
}
|
|
38938
|
-
debug(this.serialNumber, "set");
|
|
38939
|
-
if (!this.isOpen) {
|
|
38940
|
-
throw new Error("Port is not open");
|
|
38941
|
-
}
|
|
38942
|
-
await resolveNextTick();
|
|
38943
|
-
}
|
|
38944
|
-
async get() {
|
|
38945
|
-
debug(this.serialNumber, "get");
|
|
38946
|
-
if (!this.isOpen) {
|
|
38947
|
-
throw new Error("Port is not open");
|
|
38948
|
-
}
|
|
38949
|
-
await resolveNextTick();
|
|
38950
|
-
return {
|
|
38951
|
-
cts: true,
|
|
38952
|
-
dsr: false,
|
|
38953
|
-
dcd: false
|
|
38954
|
-
};
|
|
38955
|
-
}
|
|
38956
|
-
async getBaudRate() {
|
|
38957
|
-
var _a;
|
|
38958
|
-
debug(this.serialNumber, "getBaudRate");
|
|
38959
|
-
if (!this.isOpen || !this.port) {
|
|
38960
|
-
throw new Error("Port is not open");
|
|
38961
|
-
}
|
|
38962
|
-
await resolveNextTick();
|
|
38963
|
-
if (!((_a = this.port.openOpt) === null || _a === void 0 ? void 0 : _a.baudRate)) {
|
|
38964
|
-
throw new Error("Internal Error");
|
|
38965
|
-
}
|
|
38966
|
-
return {
|
|
38967
|
-
baudRate: this.port.openOpt.baudRate
|
|
38968
|
-
};
|
|
38969
|
-
}
|
|
38970
|
-
async flush() {
|
|
38971
|
-
debug(this.serialNumber, "flush");
|
|
38972
|
-
if (!this.isOpen || !this.port) {
|
|
38973
|
-
throw new Error("Port is not open");
|
|
38974
|
-
}
|
|
38975
|
-
await resolveNextTick();
|
|
38976
|
-
this.port.data = Buffer.alloc(0);
|
|
38977
|
-
}
|
|
38978
|
-
async drain() {
|
|
38979
|
-
debug(this.serialNumber, "drain");
|
|
38980
|
-
if (!this.isOpen) {
|
|
38981
|
-
throw new Error("Port is not open");
|
|
38982
|
-
}
|
|
38983
|
-
await this.writeOperation;
|
|
38984
|
-
await resolveNextTick();
|
|
38985
|
-
}
|
|
38986
|
-
};
|
|
38987
|
-
exports2.CanceledError = CanceledError;
|
|
38988
|
-
exports2.MockBinding = MockBinding;
|
|
38989
|
-
exports2.MockPortBinding = MockPortBinding;
|
|
38990
|
-
}
|
|
38991
|
-
});
|
|
38992
|
-
|
|
38993
|
-
// ../../node_modules/serialport/dist/serialport-mock.js
|
|
38994
|
-
var require_serialport_mock = __commonJS({
|
|
38995
|
-
"../../node_modules/serialport/dist/serialport-mock.js"(exports2) {
|
|
38996
|
-
"use strict";
|
|
38997
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
38998
|
-
exports2.SerialPortMock = void 0;
|
|
38999
|
-
var stream_1 = require_dist11();
|
|
39000
|
-
var binding_mock_1 = require_dist12();
|
|
39001
|
-
var SerialPortMock = class extends stream_1.SerialPortStream {
|
|
39002
|
-
constructor(options, openCallback) {
|
|
39003
|
-
const opts = {
|
|
39004
|
-
binding: binding_mock_1.MockBinding,
|
|
39005
|
-
...options
|
|
39006
|
-
};
|
|
39007
|
-
super(opts, openCallback);
|
|
39008
|
-
}
|
|
39009
|
-
};
|
|
39010
|
-
__publicField(SerialPortMock, "list", binding_mock_1.MockBinding.list);
|
|
39011
|
-
__publicField(SerialPortMock, "binding", binding_mock_1.MockBinding);
|
|
39012
|
-
exports2.SerialPortMock = SerialPortMock;
|
|
39013
|
-
}
|
|
39014
|
-
});
|
|
39015
|
-
|
|
39016
|
-
// ../../node_modules/node-gyp-build/node-gyp-build.js
|
|
39017
|
-
var require_node_gyp_build = __commonJS({
|
|
39018
|
-
"../../node_modules/node-gyp-build/node-gyp-build.js"(exports2, module2) {
|
|
39019
|
-
"use strict";
|
|
39020
|
-
var fs2 = require("fs");
|
|
39021
|
-
var path = require("path");
|
|
39022
|
-
var os = require("os");
|
|
39023
|
-
var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : require;
|
|
39024
|
-
var vars = process.config && process.config.variables || {};
|
|
39025
|
-
var prebuildsOnly = !!process.env.PREBUILDS_ONLY;
|
|
39026
|
-
var abi = process.versions.modules;
|
|
39027
|
-
var runtime = isElectron() ? "electron" : isNwjs() ? "node-webkit" : "node";
|
|
39028
|
-
var arch = process.env.npm_config_arch || os.arch();
|
|
39029
|
-
var platform2 = process.env.npm_config_platform || os.platform();
|
|
39030
|
-
var libc = process.env.LIBC || (isAlpine(platform2) ? "musl" : "glibc");
|
|
39031
|
-
var armv = process.env.ARM_VERSION || (arch === "arm64" ? "8" : vars.arm_version) || "";
|
|
39032
|
-
var uv = (process.versions.uv || "").split(".")[0];
|
|
39033
|
-
module2.exports = load;
|
|
39034
|
-
function load(dir) {
|
|
39035
|
-
return runtimeRequire(load.resolve(dir));
|
|
39036
|
-
}
|
|
39037
|
-
load.resolve = load.path = function(dir) {
|
|
39038
|
-
dir = path.resolve(dir || ".");
|
|
39039
|
-
try {
|
|
39040
|
-
var name = runtimeRequire(path.join(dir, "package.json")).name.toUpperCase().replace(/-/g, "_");
|
|
39041
|
-
if (process.env[name + "_PREBUILD"])
|
|
39042
|
-
dir = process.env[name + "_PREBUILD"];
|
|
39043
|
-
} catch (err) {
|
|
39044
|
-
}
|
|
39045
|
-
if (!prebuildsOnly) {
|
|
39046
|
-
var release = getFirst(path.join(dir, "build/Release"), matchBuild);
|
|
39047
|
-
if (release)
|
|
39048
|
-
return release;
|
|
39049
|
-
var debug = getFirst(path.join(dir, "build/Debug"), matchBuild);
|
|
39050
|
-
if (debug)
|
|
39051
|
-
return debug;
|
|
39052
|
-
}
|
|
39053
|
-
var prebuild = resolve(dir);
|
|
39054
|
-
if (prebuild)
|
|
39055
|
-
return prebuild;
|
|
39056
|
-
var nearby = resolve(path.dirname(process.execPath));
|
|
39057
|
-
if (nearby)
|
|
39058
|
-
return nearby;
|
|
39059
|
-
var target = [
|
|
39060
|
-
"platform=" + platform2,
|
|
39061
|
-
"arch=" + arch,
|
|
39062
|
-
"runtime=" + runtime,
|
|
39063
|
-
"abi=" + abi,
|
|
39064
|
-
"uv=" + uv,
|
|
39065
|
-
armv ? "armv=" + armv : "",
|
|
39066
|
-
"libc=" + libc,
|
|
39067
|
-
"node=" + process.versions.node,
|
|
39068
|
-
process.versions.electron ? "electron=" + process.versions.electron : "",
|
|
39069
|
-
typeof __webpack_require__ === "function" ? "webpack=true" : ""
|
|
39070
|
-
// eslint-disable-line
|
|
39071
|
-
].filter(Boolean).join(" ");
|
|
39072
|
-
throw new Error("No native build was found for " + target + "\n loaded from: " + dir + "\n");
|
|
39073
|
-
function resolve(dir2) {
|
|
39074
|
-
var tuples = readdirSync(path.join(dir2, "prebuilds")).map(parseTuple);
|
|
39075
|
-
var tuple = tuples.filter(matchTuple(platform2, arch)).sort(compareTuples)[0];
|
|
39076
|
-
if (!tuple)
|
|
39077
|
-
return;
|
|
39078
|
-
var prebuilds = path.join(dir2, "prebuilds", tuple.name);
|
|
39079
|
-
var parsed = readdirSync(prebuilds).map(parseTags);
|
|
39080
|
-
var candidates = parsed.filter(matchTags(runtime, abi));
|
|
39081
|
-
var winner = candidates.sort(compareTags(runtime))[0];
|
|
39082
|
-
if (winner)
|
|
39083
|
-
return path.join(prebuilds, winner.file);
|
|
39084
|
-
}
|
|
39085
|
-
};
|
|
39086
|
-
function readdirSync(dir) {
|
|
39087
|
-
try {
|
|
39088
|
-
return fs2.readdirSync(dir);
|
|
39089
|
-
} catch (err) {
|
|
39090
|
-
return [];
|
|
39091
|
-
}
|
|
39092
|
-
}
|
|
39093
|
-
function getFirst(dir, filter) {
|
|
39094
|
-
var files = readdirSync(dir).filter(filter);
|
|
39095
|
-
return files[0] && path.join(dir, files[0]);
|
|
39096
|
-
}
|
|
39097
|
-
function matchBuild(name) {
|
|
39098
|
-
return /\.node$/.test(name);
|
|
39099
|
-
}
|
|
39100
|
-
function parseTuple(name) {
|
|
39101
|
-
var arr = name.split("-");
|
|
39102
|
-
if (arr.length !== 2)
|
|
39103
|
-
return;
|
|
39104
|
-
var platform3 = arr[0];
|
|
39105
|
-
var architectures = arr[1].split("+");
|
|
39106
|
-
if (!platform3)
|
|
39107
|
-
return;
|
|
39108
|
-
if (!architectures.length)
|
|
39109
|
-
return;
|
|
39110
|
-
if (!architectures.every(Boolean))
|
|
39111
|
-
return;
|
|
39112
|
-
return { name, platform: platform3, architectures };
|
|
39113
|
-
}
|
|
39114
|
-
function matchTuple(platform3, arch2) {
|
|
39115
|
-
return function(tuple) {
|
|
39116
|
-
if (tuple == null)
|
|
39117
|
-
return false;
|
|
39118
|
-
if (tuple.platform !== platform3)
|
|
39119
|
-
return false;
|
|
39120
|
-
return tuple.architectures.includes(arch2);
|
|
39121
|
-
};
|
|
39122
|
-
}
|
|
39123
|
-
function compareTuples(a, b2) {
|
|
39124
|
-
return a.architectures.length - b2.architectures.length;
|
|
39125
|
-
}
|
|
39126
|
-
function parseTags(file) {
|
|
39127
|
-
var arr = file.split(".");
|
|
39128
|
-
var extension = arr.pop();
|
|
39129
|
-
var tags = { file, specificity: 0 };
|
|
39130
|
-
if (extension !== "node")
|
|
39131
|
-
return;
|
|
39132
|
-
for (var i2 = 0; i2 < arr.length; i2++) {
|
|
39133
|
-
var tag = arr[i2];
|
|
39134
|
-
if (tag === "node" || tag === "electron" || tag === "node-webkit") {
|
|
39135
|
-
tags.runtime = tag;
|
|
39136
|
-
} else if (tag === "napi") {
|
|
39137
|
-
tags.napi = true;
|
|
39138
|
-
} else if (tag.slice(0, 3) === "abi") {
|
|
39139
|
-
tags.abi = tag.slice(3);
|
|
39140
|
-
} else if (tag.slice(0, 2) === "uv") {
|
|
39141
|
-
tags.uv = tag.slice(2);
|
|
39142
|
-
} else if (tag.slice(0, 4) === "armv") {
|
|
39143
|
-
tags.armv = tag.slice(4);
|
|
39144
|
-
} else if (tag === "glibc" || tag === "musl") {
|
|
39145
|
-
tags.libc = tag;
|
|
39146
|
-
} else {
|
|
39147
|
-
continue;
|
|
39148
|
-
}
|
|
39149
|
-
tags.specificity++;
|
|
39150
|
-
}
|
|
39151
|
-
return tags;
|
|
39152
|
-
}
|
|
39153
|
-
function matchTags(runtime2, abi2) {
|
|
39154
|
-
return function(tags) {
|
|
39155
|
-
if (tags == null)
|
|
39156
|
-
return false;
|
|
39157
|
-
if (tags.runtime !== runtime2 && !runtimeAgnostic(tags))
|
|
39158
|
-
return false;
|
|
39159
|
-
if (tags.abi !== abi2 && !tags.napi)
|
|
39160
|
-
return false;
|
|
39161
|
-
if (tags.uv && tags.uv !== uv)
|
|
39162
|
-
return false;
|
|
39163
|
-
if (tags.armv && tags.armv !== armv)
|
|
39164
|
-
return false;
|
|
39165
|
-
if (tags.libc && tags.libc !== libc)
|
|
39166
|
-
return false;
|
|
39167
|
-
return true;
|
|
39168
|
-
};
|
|
39169
|
-
}
|
|
39170
|
-
function runtimeAgnostic(tags) {
|
|
39171
|
-
return tags.runtime === "node" && tags.napi;
|
|
39172
|
-
}
|
|
39173
|
-
function compareTags(runtime2) {
|
|
39174
|
-
return function(a, b2) {
|
|
39175
|
-
if (a.runtime !== b2.runtime) {
|
|
39176
|
-
return a.runtime === runtime2 ? -1 : 1;
|
|
39177
|
-
} else if (a.abi !== b2.abi) {
|
|
39178
|
-
return a.abi ? -1 : 1;
|
|
39179
|
-
} else if (a.specificity !== b2.specificity) {
|
|
39180
|
-
return a.specificity > b2.specificity ? -1 : 1;
|
|
39181
|
-
} else {
|
|
39182
|
-
return 0;
|
|
39183
|
-
}
|
|
39184
|
-
};
|
|
39185
|
-
}
|
|
39186
|
-
function isNwjs() {
|
|
39187
|
-
return !!(process.versions && process.versions.nw);
|
|
39188
|
-
}
|
|
39189
|
-
function isElectron() {
|
|
39190
|
-
if (process.versions && process.versions.electron)
|
|
39191
|
-
return true;
|
|
39192
|
-
if (process.env.ELECTRON_RUN_AS_NODE)
|
|
39193
|
-
return true;
|
|
39194
|
-
return typeof window !== "undefined" && window.process && window.process.type === "renderer";
|
|
39195
|
-
}
|
|
39196
|
-
function isAlpine(platform3) {
|
|
39197
|
-
return platform3 === "linux" && fs2.existsSync("/etc/alpine-release");
|
|
39198
|
-
}
|
|
39199
|
-
load.parseTags = parseTags;
|
|
39200
|
-
load.matchTags = matchTags;
|
|
39201
|
-
load.compareTags = compareTags;
|
|
39202
|
-
load.parseTuple = parseTuple;
|
|
39203
|
-
load.matchTuple = matchTuple;
|
|
39204
|
-
load.compareTuples = compareTuples;
|
|
39205
|
-
}
|
|
39206
|
-
});
|
|
39207
|
-
|
|
39208
|
-
// ../../node_modules/node-gyp-build/index.js
|
|
39209
|
-
var require_node_gyp_build2 = __commonJS({
|
|
39210
|
-
"../../node_modules/node-gyp-build/index.js"(exports2, module2) {
|
|
39211
|
-
"use strict";
|
|
39212
|
-
if (typeof process.addon === "function") {
|
|
39213
|
-
module2.exports = process.addon.bind(process);
|
|
39214
|
-
} else {
|
|
39215
|
-
module2.exports = require_node_gyp_build();
|
|
39216
|
-
}
|
|
39217
|
-
}
|
|
39218
|
-
});
|
|
39219
|
-
|
|
39220
|
-
// ../../node_modules/@serialport/bindings-cpp/dist/load-bindings.js
|
|
39221
|
-
var require_load_bindings = __commonJS({
|
|
39222
|
-
"../../node_modules/@serialport/bindings-cpp/dist/load-bindings.js"(exports2) {
|
|
39223
|
-
"use strict";
|
|
39224
|
-
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
|
39225
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
39226
|
-
};
|
|
39227
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
39228
|
-
exports2.asyncWrite = exports2.asyncRead = exports2.asyncUpdate = exports2.asyncSet = exports2.asyncOpen = exports2.asyncList = exports2.asyncGetBaudRate = exports2.asyncGet = exports2.asyncFlush = exports2.asyncDrain = exports2.asyncClose = void 0;
|
|
39229
|
-
var node_gyp_build_1 = __importDefault(require_node_gyp_build2());
|
|
39230
|
-
var util_1 = require("util");
|
|
39231
|
-
var path_1 = require("path");
|
|
39232
|
-
var binding = (0, node_gyp_build_1.default)((0, path_1.join)(__dirname, "../"));
|
|
39233
|
-
exports2.asyncClose = binding.close ? (0, util_1.promisify)(binding.close) : async () => {
|
|
39234
|
-
throw new Error('"binding.close" Method not implemented');
|
|
39235
|
-
};
|
|
39236
|
-
exports2.asyncDrain = binding.drain ? (0, util_1.promisify)(binding.drain) : async () => {
|
|
39237
|
-
throw new Error('"binding.drain" Method not implemented');
|
|
39238
|
-
};
|
|
39239
|
-
exports2.asyncFlush = binding.flush ? (0, util_1.promisify)(binding.flush) : async () => {
|
|
39240
|
-
throw new Error('"binding.flush" Method not implemented');
|
|
39241
|
-
};
|
|
39242
|
-
exports2.asyncGet = binding.get ? (0, util_1.promisify)(binding.get) : async () => {
|
|
39243
|
-
throw new Error('"binding.get" Method not implemented');
|
|
39244
|
-
};
|
|
39245
|
-
exports2.asyncGetBaudRate = binding.getBaudRate ? (0, util_1.promisify)(binding.getBaudRate) : async () => {
|
|
39246
|
-
throw new Error('"binding.getBaudRate" Method not implemented');
|
|
39247
|
-
};
|
|
39248
|
-
exports2.asyncList = binding.list ? (0, util_1.promisify)(binding.list) : async () => {
|
|
39249
|
-
throw new Error('"binding.list" Method not implemented');
|
|
39250
|
-
};
|
|
39251
|
-
exports2.asyncOpen = binding.open ? (0, util_1.promisify)(binding.open) : async () => {
|
|
39252
|
-
throw new Error('"binding.open" Method not implemented');
|
|
39253
|
-
};
|
|
39254
|
-
exports2.asyncSet = binding.set ? (0, util_1.promisify)(binding.set) : async () => {
|
|
39255
|
-
throw new Error('"binding.set" Method not implemented');
|
|
39256
|
-
};
|
|
39257
|
-
exports2.asyncUpdate = binding.update ? (0, util_1.promisify)(binding.update) : async () => {
|
|
39258
|
-
throw new Error('"binding.update" Method not implemented');
|
|
39259
|
-
};
|
|
39260
|
-
exports2.asyncRead = binding.read ? (0, util_1.promisify)(binding.read) : async () => {
|
|
39261
|
-
throw new Error('"binding.read" Method not implemented');
|
|
39262
|
-
};
|
|
39263
|
-
exports2.asyncWrite = binding.write ? (0, util_1.promisify)(binding.write) : async () => {
|
|
39264
|
-
throw new Error('"binding.write" Method not implemented');
|
|
39265
|
-
};
|
|
39266
|
-
}
|
|
39267
|
-
});
|
|
39268
|
-
|
|
39269
|
-
// ../../node_modules/@serialport/bindings-cpp/dist/errors.js
|
|
39270
|
-
var require_errors3 = __commonJS({
|
|
39271
|
-
"../../node_modules/@serialport/bindings-cpp/dist/errors.js"(exports2) {
|
|
39272
|
-
"use strict";
|
|
39273
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
39274
|
-
exports2.BindingsError = void 0;
|
|
39275
|
-
var BindingsError = class extends Error {
|
|
39276
|
-
constructor(message, { canceled = false } = {}) {
|
|
39277
|
-
super(message);
|
|
39278
|
-
this.canceled = canceled;
|
|
39279
|
-
}
|
|
39280
|
-
};
|
|
39281
|
-
exports2.BindingsError = BindingsError;
|
|
39282
|
-
}
|
|
39283
|
-
});
|
|
39284
|
-
|
|
39285
|
-
// ../../node_modules/@serialport/bindings-cpp/dist/poller.js
|
|
39286
|
-
var require_poller = __commonJS({
|
|
39287
|
-
"../../node_modules/@serialport/bindings-cpp/dist/poller.js"(exports2) {
|
|
39288
|
-
"use strict";
|
|
39289
|
-
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
|
39290
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
39291
|
-
};
|
|
39292
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
39293
|
-
exports2.Poller = exports2.EVENTS = void 0;
|
|
39294
|
-
var debug_1 = __importDefault(require_src());
|
|
39295
|
-
var events_1 = require("events");
|
|
39296
|
-
var path_1 = require("path");
|
|
39297
|
-
var node_gyp_build_1 = __importDefault(require_node_gyp_build2());
|
|
39298
|
-
var errors_1 = require_errors3();
|
|
39299
|
-
var { Poller: PollerBindings } = (0, node_gyp_build_1.default)((0, path_1.join)(__dirname, "../"));
|
|
39300
|
-
var logger = (0, debug_1.default)("serialport/bindings-cpp/poller");
|
|
39301
|
-
exports2.EVENTS = {
|
|
39302
|
-
UV_READABLE: 1,
|
|
39303
|
-
UV_WRITABLE: 2,
|
|
39304
|
-
UV_DISCONNECT: 4
|
|
39305
|
-
};
|
|
39306
|
-
function handleEvent(error, eventFlag) {
|
|
39307
|
-
if (error) {
|
|
39308
|
-
logger("error", error);
|
|
39309
|
-
this.emit("readable", error);
|
|
39310
|
-
this.emit("writable", error);
|
|
39311
|
-
this.emit("disconnect", error);
|
|
39312
|
-
return;
|
|
39313
|
-
}
|
|
39314
|
-
if (eventFlag & exports2.EVENTS.UV_READABLE) {
|
|
39315
|
-
logger('received "readable"');
|
|
39316
|
-
this.emit("readable", null);
|
|
39317
|
-
}
|
|
39318
|
-
if (eventFlag & exports2.EVENTS.UV_WRITABLE) {
|
|
39319
|
-
logger('received "writable"');
|
|
39320
|
-
this.emit("writable", null);
|
|
39321
|
-
}
|
|
39322
|
-
if (eventFlag & exports2.EVENTS.UV_DISCONNECT) {
|
|
39323
|
-
logger('received "disconnect"');
|
|
39324
|
-
this.emit("disconnect", null);
|
|
39325
|
-
}
|
|
39326
|
-
}
|
|
39327
|
-
var Poller = class extends events_1.EventEmitter {
|
|
39328
|
-
constructor(fd, FDPoller = PollerBindings) {
|
|
39329
|
-
logger("Creating poller");
|
|
39330
|
-
super();
|
|
39331
|
-
this.poller = new FDPoller(fd, handleEvent.bind(this));
|
|
39332
|
-
}
|
|
39333
|
-
/**
|
|
39334
|
-
* Wait for the next event to occur
|
|
39335
|
-
* @param {string} event ('readable'|'writable'|'disconnect')
|
|
39336
|
-
* @returns {Poller} returns itself
|
|
39337
|
-
*/
|
|
39338
|
-
once(event, callback) {
|
|
39339
|
-
switch (event) {
|
|
39340
|
-
case "readable":
|
|
39341
|
-
this.poll(exports2.EVENTS.UV_READABLE);
|
|
39342
|
-
break;
|
|
39343
|
-
case "writable":
|
|
39344
|
-
this.poll(exports2.EVENTS.UV_WRITABLE);
|
|
39345
|
-
break;
|
|
39346
|
-
case "disconnect":
|
|
39347
|
-
this.poll(exports2.EVENTS.UV_DISCONNECT);
|
|
39348
|
-
break;
|
|
39349
|
-
}
|
|
39350
|
-
return super.once(event, callback);
|
|
39351
|
-
}
|
|
39352
|
-
/**
|
|
39353
|
-
* Ask the bindings to listen for an event, it is recommend to use `.once()` for easy use
|
|
39354
|
-
* @param {EVENTS} eventFlag polls for an event or group of events based upon a flag.
|
|
39355
|
-
*/
|
|
39356
|
-
poll(eventFlag = 0) {
|
|
39357
|
-
if (eventFlag & exports2.EVENTS.UV_READABLE) {
|
|
39358
|
-
logger('Polling for "readable"');
|
|
39359
|
-
}
|
|
39360
|
-
if (eventFlag & exports2.EVENTS.UV_WRITABLE) {
|
|
39361
|
-
logger('Polling for "writable"');
|
|
39362
|
-
}
|
|
39363
|
-
if (eventFlag & exports2.EVENTS.UV_DISCONNECT) {
|
|
39364
|
-
logger('Polling for "disconnect"');
|
|
39365
|
-
}
|
|
39366
|
-
this.poller.poll(eventFlag);
|
|
39367
|
-
}
|
|
39368
|
-
/**
|
|
39369
|
-
* Stop listening for events and cancel all outstanding listening with an error
|
|
39370
|
-
*/
|
|
39371
|
-
stop() {
|
|
39372
|
-
logger("Stopping poller");
|
|
39373
|
-
this.poller.stop();
|
|
39374
|
-
this.emitCanceled();
|
|
39375
|
-
}
|
|
39376
|
-
destroy() {
|
|
39377
|
-
logger("Destroying poller");
|
|
39378
|
-
this.poller.destroy();
|
|
39379
|
-
this.emitCanceled();
|
|
39380
|
-
}
|
|
39381
|
-
emitCanceled() {
|
|
39382
|
-
const err = new errors_1.BindingsError("Canceled", { canceled: true });
|
|
39383
|
-
this.emit("readable", err);
|
|
39384
|
-
this.emit("writable", err);
|
|
39385
|
-
this.emit("disconnect", err);
|
|
39386
|
-
}
|
|
39387
|
-
};
|
|
39388
|
-
exports2.Poller = Poller;
|
|
39389
|
-
}
|
|
39390
|
-
});
|
|
39391
|
-
|
|
39392
|
-
// ../../node_modules/@serialport/bindings-cpp/dist/unix-read.js
|
|
39393
|
-
var require_unix_read = __commonJS({
|
|
39394
|
-
"../../node_modules/@serialport/bindings-cpp/dist/unix-read.js"(exports2) {
|
|
39395
|
-
"use strict";
|
|
39396
|
-
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
|
39397
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
39398
|
-
};
|
|
39399
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
39400
|
-
exports2.unixRead = void 0;
|
|
39401
|
-
var util_1 = require("util");
|
|
39402
|
-
var fs_1 = require("fs");
|
|
39403
|
-
var errors_1 = require_errors3();
|
|
39404
|
-
var debug_1 = __importDefault(require_src());
|
|
39405
|
-
var logger = (0, debug_1.default)("serialport/bindings-cpp/unixRead");
|
|
39406
|
-
var readAsync = (0, util_1.promisify)(fs_1.read);
|
|
39407
|
-
var readable = (binding) => {
|
|
39408
|
-
return new Promise((resolve, reject) => {
|
|
39409
|
-
if (!binding.poller) {
|
|
39410
|
-
throw new Error("No poller on bindings");
|
|
39411
|
-
}
|
|
39412
|
-
binding.poller.once("readable", (err) => err ? reject(err) : resolve());
|
|
39413
|
-
});
|
|
39414
|
-
};
|
|
39415
|
-
var unixRead = async ({ binding, buffer, offset, length, fsReadAsync = readAsync }) => {
|
|
39416
|
-
logger("Starting read");
|
|
39417
|
-
if (!binding.isOpen || !binding.fd) {
|
|
39418
|
-
throw new errors_1.BindingsError("Port is not open", { canceled: true });
|
|
39419
|
-
}
|
|
39420
|
-
try {
|
|
39421
|
-
const { bytesRead } = await fsReadAsync(binding.fd, buffer, offset, length, null);
|
|
39422
|
-
if (bytesRead === 0) {
|
|
39423
|
-
return (0, exports2.unixRead)({ binding, buffer, offset, length, fsReadAsync });
|
|
39424
|
-
}
|
|
39425
|
-
logger("Finished read", bytesRead, "bytes");
|
|
39426
|
-
return { bytesRead, buffer };
|
|
39427
|
-
} catch (err) {
|
|
39428
|
-
logger("read error", err);
|
|
39429
|
-
if (err.code === "EAGAIN" || err.code === "EWOULDBLOCK" || err.code === "EINTR") {
|
|
39430
|
-
if (!binding.isOpen) {
|
|
39431
|
-
throw new errors_1.BindingsError("Port is not open", { canceled: true });
|
|
39432
|
-
}
|
|
39433
|
-
logger("waiting for readable because of code:", err.code);
|
|
39434
|
-
await readable(binding);
|
|
39435
|
-
return (0, exports2.unixRead)({ binding, buffer, offset, length, fsReadAsync });
|
|
39436
|
-
}
|
|
39437
|
-
const disconnectError = err.code === "EBADF" || // Bad file number means we got closed
|
|
39438
|
-
err.code === "ENXIO" || // No such device or address probably usb disconnect
|
|
39439
|
-
err.code === "UNKNOWN" || err.errno === -1;
|
|
39440
|
-
if (disconnectError) {
|
|
39441
|
-
err.disconnect = true;
|
|
39442
|
-
logger("disconnecting", err);
|
|
39443
|
-
}
|
|
39444
|
-
throw err;
|
|
39445
|
-
}
|
|
39446
|
-
};
|
|
39447
|
-
exports2.unixRead = unixRead;
|
|
39448
|
-
}
|
|
39449
|
-
});
|
|
39450
|
-
|
|
39451
|
-
// ../../node_modules/@serialport/bindings-cpp/dist/unix-write.js
|
|
39452
|
-
var require_unix_write = __commonJS({
|
|
39453
|
-
"../../node_modules/@serialport/bindings-cpp/dist/unix-write.js"(exports2) {
|
|
39454
|
-
"use strict";
|
|
39455
|
-
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
|
39456
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
39457
|
-
};
|
|
39458
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
39459
|
-
exports2.unixWrite = void 0;
|
|
39460
|
-
var fs_1 = require("fs");
|
|
39461
|
-
var debug_1 = __importDefault(require_src());
|
|
39462
|
-
var util_1 = require("util");
|
|
39463
|
-
var logger = (0, debug_1.default)("serialport/bindings-cpp/unixWrite");
|
|
39464
|
-
var writeAsync = (0, util_1.promisify)(fs_1.write);
|
|
39465
|
-
var writable = (binding) => {
|
|
39466
|
-
return new Promise((resolve, reject) => {
|
|
39467
|
-
binding.poller.once("writable", (err) => err ? reject(err) : resolve());
|
|
39468
|
-
});
|
|
39469
|
-
};
|
|
39470
|
-
var unixWrite = async ({ binding, buffer, offset = 0, fsWriteAsync = writeAsync }) => {
|
|
39471
|
-
const bytesToWrite = buffer.length - offset;
|
|
39472
|
-
logger("Starting write", buffer.length, "bytes offset", offset, "bytesToWrite", bytesToWrite);
|
|
39473
|
-
if (!binding.isOpen || !binding.fd) {
|
|
39474
|
-
throw new Error("Port is not open");
|
|
39475
|
-
}
|
|
39476
|
-
try {
|
|
39477
|
-
const { bytesWritten } = await fsWriteAsync(binding.fd, buffer, offset, bytesToWrite);
|
|
39478
|
-
logger("write returned: wrote", bytesWritten, "bytes");
|
|
39479
|
-
if (bytesWritten + offset < buffer.length) {
|
|
39480
|
-
if (!binding.isOpen) {
|
|
39481
|
-
throw new Error("Port is not open");
|
|
39482
|
-
}
|
|
39483
|
-
return (0, exports2.unixWrite)({ binding, buffer, offset: bytesWritten + offset, fsWriteAsync });
|
|
39484
|
-
}
|
|
39485
|
-
logger("Finished writing", bytesWritten + offset, "bytes");
|
|
39486
|
-
} catch (err) {
|
|
39487
|
-
logger("write errored", err);
|
|
39488
|
-
if (err.code === "EAGAIN" || err.code === "EWOULDBLOCK" || err.code === "EINTR") {
|
|
39489
|
-
if (!binding.isOpen) {
|
|
39490
|
-
throw new Error("Port is not open");
|
|
39491
|
-
}
|
|
39492
|
-
logger("waiting for writable because of code:", err.code);
|
|
39493
|
-
await writable(binding);
|
|
39494
|
-
return (0, exports2.unixWrite)({ binding, buffer, offset, fsWriteAsync });
|
|
39495
|
-
}
|
|
39496
|
-
const disconnectError = err.code === "EBADF" || // Bad file number means we got closed
|
|
39497
|
-
err.code === "ENXIO" || // No such device or address probably usb disconnect
|
|
39498
|
-
err.code === "UNKNOWN" || err.errno === -1;
|
|
39499
|
-
if (disconnectError) {
|
|
39500
|
-
err.disconnect = true;
|
|
39501
|
-
logger("disconnecting", err);
|
|
39502
|
-
}
|
|
39503
|
-
logger("error", err);
|
|
39504
|
-
throw err;
|
|
39505
|
-
}
|
|
39506
|
-
};
|
|
39507
|
-
exports2.unixWrite = unixWrite;
|
|
39508
|
-
}
|
|
39509
|
-
});
|
|
39510
|
-
|
|
39511
|
-
// ../../node_modules/@serialport/bindings-cpp/dist/darwin.js
|
|
39512
|
-
var require_darwin = __commonJS({
|
|
39513
|
-
"../../node_modules/@serialport/bindings-cpp/dist/darwin.js"(exports2) {
|
|
39514
|
-
"use strict";
|
|
39515
|
-
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
|
39516
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
39517
|
-
};
|
|
39518
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
39519
|
-
exports2.DarwinPortBinding = exports2.DarwinBinding = void 0;
|
|
39520
|
-
var debug_1 = __importDefault(require_src());
|
|
39521
|
-
var load_bindings_1 = require_load_bindings();
|
|
39522
|
-
var poller_1 = require_poller();
|
|
39523
|
-
var unix_read_1 = require_unix_read();
|
|
39524
|
-
var unix_write_1 = require_unix_write();
|
|
39525
|
-
var debug = (0, debug_1.default)("serialport/bindings-cpp");
|
|
39526
|
-
exports2.DarwinBinding = {
|
|
39527
|
-
list() {
|
|
39528
|
-
debug("list");
|
|
39529
|
-
return (0, load_bindings_1.asyncList)();
|
|
39530
|
-
},
|
|
39531
|
-
async open(options) {
|
|
39532
|
-
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
39533
|
-
throw new TypeError('"options" is not an object');
|
|
39534
|
-
}
|
|
39535
|
-
if (!options.path) {
|
|
39536
|
-
throw new TypeError('"path" is not a valid port');
|
|
39537
|
-
}
|
|
39538
|
-
if (!options.baudRate) {
|
|
39539
|
-
throw new TypeError('"baudRate" is not a valid baudRate');
|
|
39540
|
-
}
|
|
39541
|
-
debug("open");
|
|
39542
|
-
const openOptions = Object.assign({ vmin: 1, vtime: 0, dataBits: 8, lock: true, stopBits: 1, parity: "none", rtscts: false, xon: false, xoff: false, xany: false, hupcl: true }, options);
|
|
39543
|
-
const fd = await (0, load_bindings_1.asyncOpen)(openOptions.path, openOptions);
|
|
39544
|
-
return new DarwinPortBinding(fd, openOptions);
|
|
39545
|
-
}
|
|
39546
|
-
};
|
|
39547
|
-
var DarwinPortBinding = class {
|
|
39548
|
-
constructor(fd, options) {
|
|
39549
|
-
this.fd = fd;
|
|
39550
|
-
this.openOptions = options;
|
|
39551
|
-
this.poller = new poller_1.Poller(fd);
|
|
39552
|
-
this.writeOperation = null;
|
|
39553
|
-
}
|
|
39554
|
-
get isOpen() {
|
|
39555
|
-
return this.fd !== null;
|
|
39556
|
-
}
|
|
39557
|
-
async close() {
|
|
39558
|
-
debug("close");
|
|
39559
|
-
if (!this.isOpen) {
|
|
39560
|
-
throw new Error("Port is not open");
|
|
39561
|
-
}
|
|
39562
|
-
const fd = this.fd;
|
|
39563
|
-
this.poller.stop();
|
|
39564
|
-
this.poller.destroy();
|
|
39565
|
-
this.fd = null;
|
|
39566
|
-
await (0, load_bindings_1.asyncClose)(fd);
|
|
39567
|
-
}
|
|
39568
|
-
async read(buffer, offset, length) {
|
|
39569
|
-
if (!Buffer.isBuffer(buffer)) {
|
|
39570
|
-
throw new TypeError('"buffer" is not a Buffer');
|
|
39571
|
-
}
|
|
39572
|
-
if (typeof offset !== "number" || isNaN(offset)) {
|
|
39573
|
-
throw new TypeError(`"offset" is not an integer got "${isNaN(offset) ? "NaN" : typeof offset}"`);
|
|
39574
|
-
}
|
|
39575
|
-
if (typeof length !== "number" || isNaN(length)) {
|
|
39576
|
-
throw new TypeError(`"length" is not an integer got "${isNaN(length) ? "NaN" : typeof length}"`);
|
|
39577
|
-
}
|
|
39578
|
-
debug("read");
|
|
39579
|
-
if (buffer.length < offset + length) {
|
|
39580
|
-
throw new Error("buffer is too small");
|
|
39581
|
-
}
|
|
39582
|
-
if (!this.isOpen) {
|
|
39583
|
-
throw new Error("Port is not open");
|
|
39584
|
-
}
|
|
39585
|
-
return (0, unix_read_1.unixRead)({ binding: this, buffer, offset, length });
|
|
39586
|
-
}
|
|
39587
|
-
async write(buffer) {
|
|
39588
|
-
if (!Buffer.isBuffer(buffer)) {
|
|
39589
|
-
throw new TypeError('"buffer" is not a Buffer');
|
|
39590
|
-
}
|
|
39591
|
-
debug("write", buffer.length, "bytes");
|
|
39592
|
-
if (!this.isOpen) {
|
|
39593
|
-
debug("write", "error port is not open");
|
|
39594
|
-
throw new Error("Port is not open");
|
|
39595
|
-
}
|
|
39596
|
-
this.writeOperation = (async () => {
|
|
39597
|
-
if (buffer.length === 0) {
|
|
39598
|
-
return;
|
|
39599
|
-
}
|
|
39600
|
-
await (0, unix_write_1.unixWrite)({ binding: this, buffer });
|
|
39601
|
-
this.writeOperation = null;
|
|
39602
|
-
})();
|
|
39603
|
-
return this.writeOperation;
|
|
39604
|
-
}
|
|
39605
|
-
async update(options) {
|
|
39606
|
-
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
39607
|
-
throw TypeError('"options" is not an object');
|
|
39608
|
-
}
|
|
39609
|
-
if (typeof options.baudRate !== "number") {
|
|
39610
|
-
throw new TypeError('"options.baudRate" is not a number');
|
|
39611
|
-
}
|
|
39612
|
-
debug("update");
|
|
39613
|
-
if (!this.isOpen) {
|
|
39614
|
-
throw new Error("Port is not open");
|
|
39615
|
-
}
|
|
39616
|
-
await (0, load_bindings_1.asyncUpdate)(this.fd, options);
|
|
39617
|
-
}
|
|
39618
|
-
async set(options) {
|
|
39619
|
-
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
39620
|
-
throw new TypeError('"options" is not an object');
|
|
39621
|
-
}
|
|
39622
|
-
debug("set", options);
|
|
39623
|
-
if (!this.isOpen) {
|
|
39624
|
-
throw new Error("Port is not open");
|
|
39625
|
-
}
|
|
39626
|
-
await (0, load_bindings_1.asyncSet)(this.fd, options);
|
|
39627
|
-
}
|
|
39628
|
-
async get() {
|
|
39629
|
-
debug("get");
|
|
39630
|
-
if (!this.isOpen) {
|
|
39631
|
-
throw new Error("Port is not open");
|
|
39632
|
-
}
|
|
39633
|
-
return (0, load_bindings_1.asyncGet)(this.fd);
|
|
39634
|
-
}
|
|
39635
|
-
async getBaudRate() {
|
|
39636
|
-
debug("getBaudRate");
|
|
39637
|
-
if (!this.isOpen) {
|
|
39638
|
-
throw new Error("Port is not open");
|
|
39639
|
-
}
|
|
39640
|
-
throw new Error("getBaudRate is not implemented on darwin");
|
|
39641
|
-
}
|
|
39642
|
-
async flush() {
|
|
39643
|
-
debug("flush");
|
|
39644
|
-
if (!this.isOpen) {
|
|
39645
|
-
throw new Error("Port is not open");
|
|
39646
|
-
}
|
|
39647
|
-
await (0, load_bindings_1.asyncFlush)(this.fd);
|
|
39648
|
-
}
|
|
39649
|
-
async drain() {
|
|
39650
|
-
debug("drain");
|
|
39651
|
-
if (!this.isOpen) {
|
|
39652
|
-
throw new Error("Port is not open");
|
|
39653
|
-
}
|
|
39654
|
-
await this.writeOperation;
|
|
39655
|
-
await (0, load_bindings_1.asyncDrain)(this.fd);
|
|
39656
|
-
}
|
|
39657
|
-
};
|
|
39658
|
-
exports2.DarwinPortBinding = DarwinPortBinding;
|
|
39659
|
-
}
|
|
39660
|
-
});
|
|
39661
|
-
|
|
39662
|
-
// ../../node_modules/@serialport/bindings-cpp/node_modules/@serialport/parser-delimiter/dist/index.js
|
|
39663
|
-
var require_dist13 = __commonJS({
|
|
39664
|
-
"../../node_modules/@serialport/bindings-cpp/node_modules/@serialport/parser-delimiter/dist/index.js"(exports2) {
|
|
39665
|
-
"use strict";
|
|
39666
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
39667
|
-
exports2.DelimiterParser = void 0;
|
|
39668
|
-
var stream_1 = require("stream");
|
|
39669
|
-
var DelimiterParser = class extends stream_1.Transform {
|
|
39670
|
-
constructor({ delimiter, includeDelimiter = false, ...options }) {
|
|
39671
|
-
super(options);
|
|
39672
|
-
if (delimiter === void 0) {
|
|
39673
|
-
throw new TypeError('"delimiter" is not a bufferable object');
|
|
39674
|
-
}
|
|
39675
|
-
if (delimiter.length === 0) {
|
|
39676
|
-
throw new TypeError('"delimiter" has a 0 or undefined length');
|
|
39677
|
-
}
|
|
39678
|
-
this.includeDelimiter = includeDelimiter;
|
|
39679
|
-
this.delimiter = Buffer.from(delimiter);
|
|
39680
|
-
this.buffer = Buffer.alloc(0);
|
|
39681
|
-
}
|
|
39682
|
-
_transform(chunk, encoding, cb) {
|
|
39683
|
-
let data2 = Buffer.concat([this.buffer, chunk]);
|
|
39684
|
-
let position;
|
|
39685
|
-
while ((position = data2.indexOf(this.delimiter)) !== -1) {
|
|
39686
|
-
this.push(data2.slice(0, position + (this.includeDelimiter ? this.delimiter.length : 0)));
|
|
39687
|
-
data2 = data2.slice(position + this.delimiter.length);
|
|
39688
|
-
}
|
|
39689
|
-
this.buffer = data2;
|
|
39690
|
-
cb();
|
|
39691
|
-
}
|
|
39692
|
-
_flush(cb) {
|
|
39693
|
-
this.push(this.buffer);
|
|
39694
|
-
this.buffer = Buffer.alloc(0);
|
|
39695
|
-
cb();
|
|
39696
|
-
}
|
|
39697
|
-
};
|
|
39698
|
-
exports2.DelimiterParser = DelimiterParser;
|
|
39699
|
-
}
|
|
39700
|
-
});
|
|
39701
|
-
|
|
39702
|
-
// ../../node_modules/@serialport/bindings-cpp/node_modules/@serialport/parser-readline/dist/index.js
|
|
39703
|
-
var require_dist14 = __commonJS({
|
|
39704
|
-
"../../node_modules/@serialport/bindings-cpp/node_modules/@serialport/parser-readline/dist/index.js"(exports2) {
|
|
39705
|
-
"use strict";
|
|
39706
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
39707
|
-
exports2.ReadlineParser = void 0;
|
|
39708
|
-
var parser_delimiter_1 = require_dist13();
|
|
39709
|
-
var ReadlineParser = class extends parser_delimiter_1.DelimiterParser {
|
|
39710
|
-
constructor(options) {
|
|
39711
|
-
const opts = {
|
|
39712
|
-
delimiter: Buffer.from("\n", "utf8"),
|
|
39713
|
-
encoding: "utf8",
|
|
39714
|
-
...options
|
|
39715
|
-
};
|
|
39716
|
-
if (typeof opts.delimiter === "string") {
|
|
39717
|
-
opts.delimiter = Buffer.from(opts.delimiter, opts.encoding);
|
|
39718
|
-
}
|
|
39719
|
-
super(opts);
|
|
39720
|
-
}
|
|
39721
|
-
};
|
|
39722
|
-
exports2.ReadlineParser = ReadlineParser;
|
|
39723
|
-
}
|
|
39724
|
-
});
|
|
39725
|
-
|
|
39726
|
-
// ../../node_modules/@serialport/bindings-cpp/dist/linux-list.js
|
|
39727
|
-
var require_linux_list = __commonJS({
|
|
39728
|
-
"../../node_modules/@serialport/bindings-cpp/dist/linux-list.js"(exports2) {
|
|
39729
|
-
"use strict";
|
|
39730
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
39731
|
-
exports2.linuxList = void 0;
|
|
39732
|
-
var child_process_1 = require("child_process");
|
|
39733
|
-
var parser_readline_1 = require_dist14();
|
|
39734
|
-
function checkPathOfDevice(path) {
|
|
39735
|
-
return /(tty(S|WCH|ACM|USB|AMA|MFD|O|XRUSB)|rfcomm)/.test(path) && path;
|
|
39736
|
-
}
|
|
39737
|
-
function propName(name) {
|
|
39738
|
-
return {
|
|
39739
|
-
DEVNAME: "path",
|
|
39740
|
-
ID_VENDOR_ENC: "manufacturer",
|
|
39741
|
-
ID_SERIAL_SHORT: "serialNumber",
|
|
39742
|
-
ID_VENDOR_ID: "vendorId",
|
|
39743
|
-
ID_MODEL_ID: "productId",
|
|
39744
|
-
DEVLINKS: "pnpId",
|
|
39745
|
-
/**
|
|
39746
|
-
* Workaround for systemd defect
|
|
39747
|
-
* see https://github.com/serialport/bindings-cpp/issues/115
|
|
39748
|
-
*/
|
|
39749
|
-
ID_USB_VENDOR_ENC: "manufacturer",
|
|
39750
|
-
ID_USB_SERIAL_SHORT: "serialNumber",
|
|
39751
|
-
ID_USB_VENDOR_ID: "vendorId",
|
|
39752
|
-
ID_USB_MODEL_ID: "productId"
|
|
39753
|
-
// End of workaround
|
|
39754
|
-
}[name.toUpperCase()];
|
|
39755
|
-
}
|
|
39756
|
-
function decodeHexEscape(str) {
|
|
39757
|
-
return str.replace(/\\x([a-fA-F0-9]{2})/g, (a, b2) => {
|
|
39758
|
-
return String.fromCharCode(parseInt(b2, 16));
|
|
39759
|
-
});
|
|
39760
|
-
}
|
|
39761
|
-
function propVal(name, val) {
|
|
39762
|
-
if (name === "pnpId") {
|
|
39763
|
-
const match = val.match(/\/by-id\/([^\s]+)/);
|
|
39764
|
-
return (match === null || match === void 0 ? void 0 : match[1]) || void 0;
|
|
39765
|
-
}
|
|
39766
|
-
if (name === "manufacturer") {
|
|
39767
|
-
return decodeHexEscape(val);
|
|
39768
|
-
}
|
|
39769
|
-
if (/^0x/.test(val)) {
|
|
39770
|
-
return val.substr(2);
|
|
39771
|
-
}
|
|
39772
|
-
return val;
|
|
39773
|
-
}
|
|
39774
|
-
function linuxList(spawnCmd = child_process_1.spawn) {
|
|
39775
|
-
const ports = [];
|
|
39776
|
-
const udevadm = spawnCmd("udevadm", ["info", "-e"]);
|
|
39777
|
-
const lines = udevadm.stdout.pipe(new parser_readline_1.ReadlineParser());
|
|
39778
|
-
let skipPort = false;
|
|
39779
|
-
let port = {
|
|
39780
|
-
path: "",
|
|
39781
|
-
manufacturer: void 0,
|
|
39782
|
-
serialNumber: void 0,
|
|
39783
|
-
pnpId: void 0,
|
|
39784
|
-
locationId: void 0,
|
|
39785
|
-
vendorId: void 0,
|
|
39786
|
-
productId: void 0
|
|
39787
|
-
};
|
|
39788
|
-
lines.on("data", (line) => {
|
|
39789
|
-
const lineType = line.slice(0, 1);
|
|
39790
|
-
const data2 = line.slice(3);
|
|
39791
|
-
if (lineType === "P") {
|
|
39792
|
-
port = {
|
|
39793
|
-
path: "",
|
|
39794
|
-
manufacturer: void 0,
|
|
39795
|
-
serialNumber: void 0,
|
|
39796
|
-
pnpId: void 0,
|
|
39797
|
-
locationId: void 0,
|
|
39798
|
-
vendorId: void 0,
|
|
39799
|
-
productId: void 0
|
|
39800
|
-
};
|
|
39801
|
-
skipPort = false;
|
|
39802
|
-
return;
|
|
39803
|
-
}
|
|
39804
|
-
if (skipPort) {
|
|
39805
|
-
return;
|
|
39806
|
-
}
|
|
39807
|
-
if (lineType === "N") {
|
|
39808
|
-
if (checkPathOfDevice(data2)) {
|
|
39809
|
-
ports.push(port);
|
|
39810
|
-
} else {
|
|
39811
|
-
skipPort = true;
|
|
39812
|
-
}
|
|
39813
|
-
return;
|
|
39814
|
-
}
|
|
39815
|
-
if (lineType === "E") {
|
|
39816
|
-
const keyValue = data2.match(/^(.+)=(.*)/);
|
|
39817
|
-
if (!keyValue) {
|
|
39818
|
-
return;
|
|
39819
|
-
}
|
|
39820
|
-
const key = propName(keyValue[1]);
|
|
39821
|
-
if (!key) {
|
|
39822
|
-
return;
|
|
39823
|
-
}
|
|
39824
|
-
port[key] = propVal(key, keyValue[2]);
|
|
39825
|
-
}
|
|
39826
|
-
});
|
|
39827
|
-
return new Promise((resolve, reject) => {
|
|
39828
|
-
udevadm.on("close", (code) => {
|
|
39829
|
-
if (code) {
|
|
39830
|
-
reject(new Error(`Error listing ports udevadm exited with error code: ${code}`));
|
|
39831
|
-
}
|
|
39832
|
-
});
|
|
39833
|
-
udevadm.on("error", reject);
|
|
39834
|
-
lines.on("error", reject);
|
|
39835
|
-
lines.on("finish", () => resolve(ports));
|
|
39836
|
-
});
|
|
39837
|
-
}
|
|
39838
|
-
exports2.linuxList = linuxList;
|
|
39839
|
-
}
|
|
39840
|
-
});
|
|
39841
|
-
|
|
39842
|
-
// ../../node_modules/@serialport/bindings-cpp/dist/linux.js
|
|
39843
|
-
var require_linux = __commonJS({
|
|
39844
|
-
"../../node_modules/@serialport/bindings-cpp/dist/linux.js"(exports2) {
|
|
39845
|
-
"use strict";
|
|
39846
|
-
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
|
39847
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
39848
|
-
};
|
|
39849
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
39850
|
-
exports2.LinuxPortBinding = exports2.LinuxBinding = void 0;
|
|
39851
|
-
var debug_1 = __importDefault(require_src());
|
|
39852
|
-
var linux_list_1 = require_linux_list();
|
|
39853
|
-
var poller_1 = require_poller();
|
|
39854
|
-
var unix_read_1 = require_unix_read();
|
|
39855
|
-
var unix_write_1 = require_unix_write();
|
|
39856
|
-
var load_bindings_1 = require_load_bindings();
|
|
39857
|
-
var debug = (0, debug_1.default)("serialport/bindings-cpp");
|
|
39858
|
-
exports2.LinuxBinding = {
|
|
39859
|
-
list() {
|
|
39860
|
-
debug("list");
|
|
39861
|
-
return (0, linux_list_1.linuxList)();
|
|
39862
|
-
},
|
|
39863
|
-
async open(options) {
|
|
39864
|
-
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
39865
|
-
throw new TypeError('"options" is not an object');
|
|
39866
|
-
}
|
|
39867
|
-
if (!options.path) {
|
|
39868
|
-
throw new TypeError('"path" is not a valid port');
|
|
39869
|
-
}
|
|
39870
|
-
if (!options.baudRate) {
|
|
39871
|
-
throw new TypeError('"baudRate" is not a valid baudRate');
|
|
39872
|
-
}
|
|
39873
|
-
debug("open");
|
|
39874
|
-
const openOptions = Object.assign({ vmin: 1, vtime: 0, dataBits: 8, lock: true, stopBits: 1, parity: "none", rtscts: false, xon: false, xoff: false, xany: false, hupcl: true }, options);
|
|
39875
|
-
const fd = await (0, load_bindings_1.asyncOpen)(openOptions.path, openOptions);
|
|
39876
|
-
this.fd = fd;
|
|
39877
|
-
return new LinuxPortBinding(fd, openOptions);
|
|
39878
|
-
}
|
|
39879
|
-
};
|
|
39880
|
-
var LinuxPortBinding = class {
|
|
39881
|
-
constructor(fd, openOptions) {
|
|
39882
|
-
this.fd = fd;
|
|
39883
|
-
this.openOptions = openOptions;
|
|
39884
|
-
this.poller = new poller_1.Poller(fd);
|
|
39885
|
-
this.writeOperation = null;
|
|
39886
|
-
}
|
|
39887
|
-
get isOpen() {
|
|
39888
|
-
return this.fd !== null;
|
|
39889
|
-
}
|
|
39890
|
-
async close() {
|
|
39891
|
-
debug("close");
|
|
39892
|
-
if (!this.isOpen) {
|
|
39893
|
-
throw new Error("Port is not open");
|
|
39894
|
-
}
|
|
39895
|
-
const fd = this.fd;
|
|
39896
|
-
this.poller.stop();
|
|
39897
|
-
this.poller.destroy();
|
|
39898
|
-
this.fd = null;
|
|
39899
|
-
await (0, load_bindings_1.asyncClose)(fd);
|
|
39900
|
-
}
|
|
39901
|
-
async read(buffer, offset, length) {
|
|
39902
|
-
if (!Buffer.isBuffer(buffer)) {
|
|
39903
|
-
throw new TypeError('"buffer" is not a Buffer');
|
|
39904
|
-
}
|
|
39905
|
-
if (typeof offset !== "number" || isNaN(offset)) {
|
|
39906
|
-
throw new TypeError(`"offset" is not an integer got "${isNaN(offset) ? "NaN" : typeof offset}"`);
|
|
39907
|
-
}
|
|
39908
|
-
if (typeof length !== "number" || isNaN(length)) {
|
|
39909
|
-
throw new TypeError(`"length" is not an integer got "${isNaN(length) ? "NaN" : typeof length}"`);
|
|
39910
|
-
}
|
|
39911
|
-
debug("read");
|
|
39912
|
-
if (buffer.length < offset + length) {
|
|
39913
|
-
throw new Error("buffer is too small");
|
|
39914
|
-
}
|
|
39915
|
-
if (!this.isOpen) {
|
|
39916
|
-
throw new Error("Port is not open");
|
|
39917
|
-
}
|
|
39918
|
-
return (0, unix_read_1.unixRead)({ binding: this, buffer, offset, length });
|
|
39919
|
-
}
|
|
39920
|
-
async write(buffer) {
|
|
39921
|
-
if (!Buffer.isBuffer(buffer)) {
|
|
39922
|
-
throw new TypeError('"buffer" is not a Buffer');
|
|
39923
|
-
}
|
|
39924
|
-
debug("write", buffer.length, "bytes");
|
|
39925
|
-
if (!this.isOpen) {
|
|
39926
|
-
debug("write", "error port is not open");
|
|
39927
|
-
throw new Error("Port is not open");
|
|
39928
|
-
}
|
|
39929
|
-
this.writeOperation = (async () => {
|
|
39930
|
-
if (buffer.length === 0) {
|
|
39931
|
-
return;
|
|
39932
|
-
}
|
|
39933
|
-
await (0, unix_write_1.unixWrite)({ binding: this, buffer });
|
|
39934
|
-
this.writeOperation = null;
|
|
39935
|
-
})();
|
|
39936
|
-
return this.writeOperation;
|
|
39937
|
-
}
|
|
39938
|
-
async update(options) {
|
|
39939
|
-
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
39940
|
-
throw TypeError('"options" is not an object');
|
|
39941
|
-
}
|
|
39942
|
-
if (typeof options.baudRate !== "number") {
|
|
39943
|
-
throw new TypeError('"options.baudRate" is not a number');
|
|
39944
|
-
}
|
|
39945
|
-
debug("update");
|
|
39946
|
-
if (!this.isOpen) {
|
|
39947
|
-
throw new Error("Port is not open");
|
|
39948
|
-
}
|
|
39949
|
-
await (0, load_bindings_1.asyncUpdate)(this.fd, options);
|
|
39950
|
-
}
|
|
39951
|
-
async set(options) {
|
|
39952
|
-
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
39953
|
-
throw new TypeError('"options" is not an object');
|
|
39954
|
-
}
|
|
39955
|
-
debug("set");
|
|
39956
|
-
if (!this.isOpen) {
|
|
39957
|
-
throw new Error("Port is not open");
|
|
39958
|
-
}
|
|
39959
|
-
await (0, load_bindings_1.asyncSet)(this.fd, options);
|
|
39960
|
-
}
|
|
39961
|
-
async get() {
|
|
39962
|
-
debug("get");
|
|
39963
|
-
if (!this.isOpen) {
|
|
39964
|
-
throw new Error("Port is not open");
|
|
39965
|
-
}
|
|
39966
|
-
return (0, load_bindings_1.asyncGet)(this.fd);
|
|
39967
|
-
}
|
|
39968
|
-
async getBaudRate() {
|
|
39969
|
-
debug("getBaudRate");
|
|
39970
|
-
if (!this.isOpen) {
|
|
39971
|
-
throw new Error("Port is not open");
|
|
39972
|
-
}
|
|
39973
|
-
return (0, load_bindings_1.asyncGetBaudRate)(this.fd);
|
|
39974
|
-
}
|
|
39975
|
-
async flush() {
|
|
39976
|
-
debug("flush");
|
|
39977
|
-
if (!this.isOpen) {
|
|
39978
|
-
throw new Error("Port is not open");
|
|
39979
|
-
}
|
|
39980
|
-
await (0, load_bindings_1.asyncFlush)(this.fd);
|
|
39981
|
-
}
|
|
39982
|
-
async drain() {
|
|
39983
|
-
debug("drain");
|
|
39984
|
-
if (!this.isOpen) {
|
|
39985
|
-
throw new Error("Port is not open");
|
|
39986
|
-
}
|
|
39987
|
-
await this.writeOperation;
|
|
39988
|
-
await (0, load_bindings_1.asyncDrain)(this.fd);
|
|
39989
|
-
}
|
|
39990
|
-
};
|
|
39991
|
-
exports2.LinuxPortBinding = LinuxPortBinding;
|
|
39992
|
-
}
|
|
39993
|
-
});
|
|
39994
|
-
|
|
39995
|
-
// ../../node_modules/@serialport/bindings-cpp/dist/win32-sn-parser.js
|
|
39996
|
-
var require_win32_sn_parser = __commonJS({
|
|
39997
|
-
"../../node_modules/@serialport/bindings-cpp/dist/win32-sn-parser.js"(exports2) {
|
|
39998
|
-
"use strict";
|
|
39999
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
40000
|
-
exports2.serialNumParser = void 0;
|
|
40001
|
-
var PARSERS = [/USB\\(?:.+)\\(.+)/, /FTDIBUS\\(?:.+)\+(.+?)A?\\.+/];
|
|
40002
|
-
var serialNumParser = (pnpId) => {
|
|
40003
|
-
if (!pnpId) {
|
|
40004
|
-
return null;
|
|
40005
|
-
}
|
|
40006
|
-
for (const parser of PARSERS) {
|
|
40007
|
-
const sn2 = pnpId.match(parser);
|
|
40008
|
-
if (sn2) {
|
|
40009
|
-
return sn2[1];
|
|
40010
|
-
}
|
|
40011
|
-
}
|
|
40012
|
-
return null;
|
|
40013
|
-
};
|
|
40014
|
-
exports2.serialNumParser = serialNumParser;
|
|
40015
|
-
}
|
|
40016
|
-
});
|
|
40017
|
-
|
|
40018
|
-
// ../../node_modules/@serialport/bindings-cpp/dist/win32.js
|
|
40019
|
-
var require_win32 = __commonJS({
|
|
40020
|
-
"../../node_modules/@serialport/bindings-cpp/dist/win32.js"(exports2) {
|
|
40021
|
-
"use strict";
|
|
40022
|
-
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
|
40023
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
40024
|
-
};
|
|
40025
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
40026
|
-
exports2.WindowsPortBinding = exports2.WindowsBinding = void 0;
|
|
40027
|
-
var debug_1 = __importDefault(require_src());
|
|
40028
|
-
var _1 = require_dist16();
|
|
40029
|
-
var load_bindings_1 = require_load_bindings();
|
|
40030
|
-
var win32_sn_parser_1 = require_win32_sn_parser();
|
|
40031
|
-
var debug = (0, debug_1.default)("serialport/bindings-cpp");
|
|
40032
|
-
exports2.WindowsBinding = {
|
|
40033
|
-
async list() {
|
|
40034
|
-
const ports = await (0, load_bindings_1.asyncList)();
|
|
40035
|
-
return ports.map((port) => {
|
|
40036
|
-
if (port.pnpId && !port.serialNumber) {
|
|
40037
|
-
const serialNumber = (0, win32_sn_parser_1.serialNumParser)(port.pnpId);
|
|
40038
|
-
if (serialNumber) {
|
|
40039
|
-
return Object.assign(Object.assign({}, port), { serialNumber });
|
|
40040
|
-
}
|
|
40041
|
-
}
|
|
40042
|
-
return port;
|
|
40043
|
-
});
|
|
40044
|
-
},
|
|
40045
|
-
async open(options) {
|
|
40046
|
-
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
40047
|
-
throw new TypeError('"options" is not an object');
|
|
40048
|
-
}
|
|
40049
|
-
if (!options.path) {
|
|
40050
|
-
throw new TypeError('"path" is not a valid port');
|
|
40051
|
-
}
|
|
40052
|
-
if (!options.baudRate) {
|
|
40053
|
-
throw new TypeError('"baudRate" is not a valid baudRate');
|
|
40054
|
-
}
|
|
40055
|
-
debug("open");
|
|
40056
|
-
const openOptions = Object.assign({ dataBits: 8, lock: true, stopBits: 1, parity: "none", rtscts: false, rtsMode: "handshake", xon: false, xoff: false, xany: false, hupcl: true }, options);
|
|
40057
|
-
const fd = await (0, load_bindings_1.asyncOpen)(openOptions.path, openOptions);
|
|
40058
|
-
return new WindowsPortBinding(fd, openOptions);
|
|
40059
|
-
}
|
|
40060
|
-
};
|
|
40061
|
-
var WindowsPortBinding = class {
|
|
40062
|
-
constructor(fd, options) {
|
|
40063
|
-
this.fd = fd;
|
|
40064
|
-
this.openOptions = options;
|
|
40065
|
-
this.writeOperation = null;
|
|
40066
|
-
}
|
|
40067
|
-
get isOpen() {
|
|
40068
|
-
return this.fd !== null;
|
|
40069
|
-
}
|
|
40070
|
-
async close() {
|
|
40071
|
-
debug("close");
|
|
40072
|
-
if (!this.isOpen) {
|
|
40073
|
-
throw new Error("Port is not open");
|
|
40074
|
-
}
|
|
40075
|
-
const fd = this.fd;
|
|
40076
|
-
this.fd = null;
|
|
40077
|
-
await (0, load_bindings_1.asyncClose)(fd);
|
|
40078
|
-
}
|
|
40079
|
-
async read(buffer, offset, length) {
|
|
40080
|
-
if (!Buffer.isBuffer(buffer)) {
|
|
40081
|
-
throw new TypeError('"buffer" is not a Buffer');
|
|
40082
|
-
}
|
|
40083
|
-
if (typeof offset !== "number" || isNaN(offset)) {
|
|
40084
|
-
throw new TypeError(`"offset" is not an integer got "${isNaN(offset) ? "NaN" : typeof offset}"`);
|
|
40085
|
-
}
|
|
40086
|
-
if (typeof length !== "number" || isNaN(length)) {
|
|
40087
|
-
throw new TypeError(`"length" is not an integer got "${isNaN(length) ? "NaN" : typeof length}"`);
|
|
40088
|
-
}
|
|
40089
|
-
debug("read");
|
|
40090
|
-
if (buffer.length < offset + length) {
|
|
40091
|
-
throw new Error("buffer is too small");
|
|
40092
|
-
}
|
|
40093
|
-
if (!this.isOpen) {
|
|
40094
|
-
throw new Error("Port is not open");
|
|
40095
|
-
}
|
|
40096
|
-
try {
|
|
40097
|
-
const bytesRead = await (0, load_bindings_1.asyncRead)(this.fd, buffer, offset, length);
|
|
40098
|
-
return { bytesRead, buffer };
|
|
40099
|
-
} catch (err) {
|
|
40100
|
-
if (!this.isOpen) {
|
|
40101
|
-
throw new _1.BindingsError(err.message, { canceled: true });
|
|
40102
|
-
}
|
|
40103
|
-
throw err;
|
|
40104
|
-
}
|
|
40105
|
-
}
|
|
40106
|
-
async write(buffer) {
|
|
40107
|
-
if (!Buffer.isBuffer(buffer)) {
|
|
40108
|
-
throw new TypeError('"buffer" is not a Buffer');
|
|
40109
|
-
}
|
|
40110
|
-
debug("write", buffer.length, "bytes");
|
|
40111
|
-
if (!this.isOpen) {
|
|
40112
|
-
debug("write", "error port is not open");
|
|
40113
|
-
throw new Error("Port is not open");
|
|
40114
|
-
}
|
|
40115
|
-
this.writeOperation = (async () => {
|
|
40116
|
-
if (buffer.length === 0) {
|
|
40117
|
-
return;
|
|
40118
|
-
}
|
|
40119
|
-
await (0, load_bindings_1.asyncWrite)(this.fd, buffer);
|
|
40120
|
-
this.writeOperation = null;
|
|
40121
|
-
})();
|
|
40122
|
-
return this.writeOperation;
|
|
40123
|
-
}
|
|
40124
|
-
async update(options) {
|
|
40125
|
-
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
40126
|
-
throw TypeError('"options" is not an object');
|
|
40127
|
-
}
|
|
40128
|
-
if (typeof options.baudRate !== "number") {
|
|
40129
|
-
throw new TypeError('"options.baudRate" is not a number');
|
|
40130
|
-
}
|
|
40131
|
-
debug("update");
|
|
40132
|
-
if (!this.isOpen) {
|
|
40133
|
-
throw new Error("Port is not open");
|
|
40134
|
-
}
|
|
40135
|
-
await (0, load_bindings_1.asyncUpdate)(this.fd, options);
|
|
40136
|
-
}
|
|
40137
|
-
async set(options) {
|
|
40138
|
-
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
40139
|
-
throw new TypeError('"options" is not an object');
|
|
40140
|
-
}
|
|
40141
|
-
debug("set", options);
|
|
40142
|
-
if (!this.isOpen) {
|
|
40143
|
-
throw new Error("Port is not open");
|
|
40144
|
-
}
|
|
40145
|
-
await (0, load_bindings_1.asyncSet)(this.fd, options);
|
|
40146
|
-
}
|
|
40147
|
-
async get() {
|
|
40148
|
-
debug("get");
|
|
40149
|
-
if (!this.isOpen) {
|
|
40150
|
-
throw new Error("Port is not open");
|
|
40151
|
-
}
|
|
40152
|
-
return (0, load_bindings_1.asyncGet)(this.fd);
|
|
40153
|
-
}
|
|
40154
|
-
async getBaudRate() {
|
|
40155
|
-
debug("getBaudRate");
|
|
40156
|
-
if (!this.isOpen) {
|
|
40157
|
-
throw new Error("Port is not open");
|
|
40158
|
-
}
|
|
40159
|
-
return (0, load_bindings_1.asyncGetBaudRate)(this.fd);
|
|
40160
|
-
}
|
|
40161
|
-
async flush() {
|
|
40162
|
-
debug("flush");
|
|
40163
|
-
if (!this.isOpen) {
|
|
40164
|
-
throw new Error("Port is not open");
|
|
40165
|
-
}
|
|
40166
|
-
await (0, load_bindings_1.asyncFlush)(this.fd);
|
|
40167
|
-
}
|
|
40168
|
-
async drain() {
|
|
40169
|
-
debug("drain");
|
|
40170
|
-
if (!this.isOpen) {
|
|
40171
|
-
throw new Error("Port is not open");
|
|
40172
|
-
}
|
|
40173
|
-
await this.writeOperation;
|
|
40174
|
-
await (0, load_bindings_1.asyncDrain)(this.fd);
|
|
40175
|
-
}
|
|
40176
|
-
};
|
|
40177
|
-
exports2.WindowsPortBinding = WindowsPortBinding;
|
|
40178
|
-
}
|
|
40179
|
-
});
|
|
40180
|
-
|
|
40181
|
-
// ../../node_modules/@serialport/bindings-interface/dist/index.js
|
|
40182
|
-
var require_dist15 = __commonJS({
|
|
40183
|
-
"../../node_modules/@serialport/bindings-interface/dist/index.js"() {
|
|
40184
|
-
"use strict";
|
|
40185
|
-
}
|
|
40186
|
-
});
|
|
40187
|
-
|
|
40188
|
-
// ../../node_modules/@serialport/bindings-cpp/dist/index.js
|
|
40189
|
-
var require_dist16 = __commonJS({
|
|
40190
|
-
"../../node_modules/@serialport/bindings-cpp/dist/index.js"(exports2) {
|
|
40191
|
-
"use strict";
|
|
40192
|
-
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m3, k2, k22) {
|
|
40193
|
-
if (k22 === void 0)
|
|
40194
|
-
k22 = k2;
|
|
40195
|
-
var desc = Object.getOwnPropertyDescriptor(m3, k2);
|
|
40196
|
-
if (!desc || ("get" in desc ? !m3.__esModule : desc.writable || desc.configurable)) {
|
|
40197
|
-
desc = { enumerable: true, get: function() {
|
|
40198
|
-
return m3[k2];
|
|
40199
|
-
} };
|
|
40200
|
-
}
|
|
40201
|
-
Object.defineProperty(o, k22, desc);
|
|
40202
|
-
} : function(o, m3, k2, k22) {
|
|
40203
|
-
if (k22 === void 0)
|
|
40204
|
-
k22 = k2;
|
|
40205
|
-
o[k22] = m3[k2];
|
|
40206
|
-
});
|
|
40207
|
-
var __exportStar = exports2 && exports2.__exportStar || function(m3, exports3) {
|
|
40208
|
-
for (var p2 in m3)
|
|
40209
|
-
if (p2 !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p2))
|
|
40210
|
-
__createBinding(exports3, m3, p2);
|
|
40211
|
-
};
|
|
40212
|
-
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
|
40213
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
40214
|
-
};
|
|
40215
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
40216
|
-
exports2.autoDetect = void 0;
|
|
40217
|
-
var debug_1 = __importDefault(require_src());
|
|
40218
|
-
var darwin_1 = require_darwin();
|
|
40219
|
-
var linux_1 = require_linux();
|
|
40220
|
-
var win32_1 = require_win32();
|
|
40221
|
-
var debug = (0, debug_1.default)("serialport/bindings-cpp");
|
|
40222
|
-
__exportStar(require_dist15(), exports2);
|
|
40223
|
-
__exportStar(require_darwin(), exports2);
|
|
40224
|
-
__exportStar(require_linux(), exports2);
|
|
40225
|
-
__exportStar(require_win32(), exports2);
|
|
40226
|
-
__exportStar(require_errors3(), exports2);
|
|
40227
|
-
function autoDetect() {
|
|
40228
|
-
switch (process.platform) {
|
|
40229
|
-
case "win32":
|
|
40230
|
-
debug("loading WindowsBinding");
|
|
40231
|
-
return win32_1.WindowsBinding;
|
|
40232
|
-
case "darwin":
|
|
40233
|
-
debug("loading DarwinBinding");
|
|
40234
|
-
return darwin_1.DarwinBinding;
|
|
40235
|
-
default:
|
|
40236
|
-
debug("loading LinuxBinding");
|
|
40237
|
-
return linux_1.LinuxBinding;
|
|
40238
|
-
}
|
|
40239
|
-
}
|
|
40240
|
-
exports2.autoDetect = autoDetect;
|
|
40241
|
-
}
|
|
40242
|
-
});
|
|
40243
|
-
|
|
40244
|
-
// ../../node_modules/serialport/dist/serialport.js
|
|
40245
|
-
var require_serialport = __commonJS({
|
|
40246
|
-
"../../node_modules/serialport/dist/serialport.js"(exports2) {
|
|
40247
|
-
"use strict";
|
|
40248
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
40249
|
-
exports2.SerialPort = void 0;
|
|
40250
|
-
var stream_1 = require_dist11();
|
|
40251
|
-
var bindings_cpp_1 = require_dist16();
|
|
40252
|
-
var DetectedBinding = (0, bindings_cpp_1.autoDetect)();
|
|
40253
|
-
var SerialPort2 = class extends stream_1.SerialPortStream {
|
|
40254
|
-
constructor(options, openCallback) {
|
|
40255
|
-
const opts = {
|
|
40256
|
-
binding: DetectedBinding,
|
|
40257
|
-
...options
|
|
40258
|
-
};
|
|
40259
|
-
super(opts, openCallback);
|
|
40260
|
-
}
|
|
40261
|
-
};
|
|
40262
|
-
__publicField(SerialPort2, "list", DetectedBinding.list);
|
|
40263
|
-
__publicField(SerialPort2, "binding", DetectedBinding);
|
|
40264
|
-
exports2.SerialPort = SerialPort2;
|
|
40265
|
-
}
|
|
40266
|
-
});
|
|
40267
|
-
|
|
40268
|
-
// ../../node_modules/serialport/dist/index.js
|
|
40269
|
-
var require_dist17 = __commonJS({
|
|
40270
|
-
"../../node_modules/serialport/dist/index.js"(exports2) {
|
|
40271
|
-
"use strict";
|
|
40272
|
-
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m3, k2, k22) {
|
|
40273
|
-
if (k22 === void 0)
|
|
40274
|
-
k22 = k2;
|
|
40275
|
-
var desc = Object.getOwnPropertyDescriptor(m3, k2);
|
|
40276
|
-
if (!desc || ("get" in desc ? !m3.__esModule : desc.writable || desc.configurable)) {
|
|
40277
|
-
desc = { enumerable: true, get: function() {
|
|
40278
|
-
return m3[k2];
|
|
40279
|
-
} };
|
|
40280
|
-
}
|
|
40281
|
-
Object.defineProperty(o, k22, desc);
|
|
40282
|
-
} : function(o, m3, k2, k22) {
|
|
40283
|
-
if (k22 === void 0)
|
|
40284
|
-
k22 = k2;
|
|
40285
|
-
o[k22] = m3[k2];
|
|
40286
|
-
});
|
|
40287
|
-
var __exportStar = exports2 && exports2.__exportStar || function(m3, exports3) {
|
|
40288
|
-
for (var p2 in m3)
|
|
40289
|
-
if (p2 !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p2))
|
|
40290
|
-
__createBinding(exports3, m3, p2);
|
|
40291
|
-
};
|
|
40292
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
40293
|
-
__exportStar(require_dist(), exports2);
|
|
40294
|
-
__exportStar(require_dist2(), exports2);
|
|
40295
|
-
__exportStar(require_dist3(), exports2);
|
|
40296
|
-
__exportStar(require_dist4(), exports2);
|
|
40297
|
-
__exportStar(require_dist5(), exports2);
|
|
40298
|
-
__exportStar(require_dist6(), exports2);
|
|
40299
|
-
__exportStar(require_dist7(), exports2);
|
|
40300
|
-
__exportStar(require_dist8(), exports2);
|
|
40301
|
-
__exportStar(require_dist9(), exports2);
|
|
40302
|
-
__exportStar(require_dist10(), exports2);
|
|
40303
|
-
__exportStar(require_serialport_mock(), exports2);
|
|
40304
|
-
__exportStar(require_serialport(), exports2);
|
|
40305
|
-
}
|
|
40306
|
-
});
|
|
40307
|
-
|
|
40308
37008
|
// src/main.ts
|
|
40309
37009
|
var main_exports = {};
|
|
40310
37010
|
__export(main_exports, {
|
|
@@ -40425,7 +37125,7 @@ function m(r4) {
|
|
|
40425
37125
|
function Ur(r4) {
|
|
40426
37126
|
return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "exception", details: { text: "Internal server error" }, diagnostics: r4.toString() }] };
|
|
40427
37127
|
}
|
|
40428
|
-
function
|
|
37128
|
+
function pe(r4) {
|
|
40429
37129
|
return typeof r4 == "object" && r4 !== null && r4.resourceType === "OperationOutcome";
|
|
40430
37130
|
}
|
|
40431
37131
|
function Lt(r4) {
|
|
@@ -40437,10 +37137,10 @@ var d = class extends Error {
|
|
|
40437
37137
|
}
|
|
40438
37138
|
};
|
|
40439
37139
|
function $e(r4) {
|
|
40440
|
-
return r4 instanceof d ? r4.outcome :
|
|
37140
|
+
return r4 instanceof d ? r4.outcome : pe(r4) ? r4 : R(vi(r4));
|
|
40441
37141
|
}
|
|
40442
37142
|
function vi(r4) {
|
|
40443
|
-
return r4 ? typeof r4 == "string" ? r4 : r4 instanceof Error ? r4.message :
|
|
37143
|
+
return r4 ? typeof r4 == "string" ? r4 : r4 instanceof Error ? r4.message : pe(r4) ? Br(r4) : typeof r4 == "object" && "code" in r4 && typeof r4.code == "string" ? r4.code : JSON.stringify(r4) : "Unknown error";
|
|
40444
37144
|
}
|
|
40445
37145
|
function Br(r4) {
|
|
40446
37146
|
let e = r4.issue?.map(Ti) ?? [];
|
|
@@ -40788,15 +37488,15 @@ function Li(r4, e) {
|
|
|
40788
37488
|
return delete e.__proto__, delete e.constructor, Object.assign(r4, e);
|
|
40789
37489
|
}
|
|
40790
37490
|
function K(r4) {
|
|
40791
|
-
let e =
|
|
37491
|
+
let e = te(r4), t = Bi(r4);
|
|
40792
37492
|
return t === e ? { reference: e } : { reference: e, display: t };
|
|
40793
37493
|
}
|
|
40794
|
-
function
|
|
40795
|
-
return
|
|
37494
|
+
function te(r4) {
|
|
37495
|
+
return ee(r4) ? r4.reference : `${r4.resourceType}/${r4.id}`;
|
|
40796
37496
|
}
|
|
40797
37497
|
function et(r4) {
|
|
40798
37498
|
if (r4)
|
|
40799
|
-
return
|
|
37499
|
+
return ee(r4) ? r4.reference.split("/")[1] : r4.id;
|
|
40800
37500
|
}
|
|
40801
37501
|
function Ui(r4) {
|
|
40802
37502
|
return r4.resourceType === "Patient" || r4.resourceType === "Practitioner" || r4.resourceType === "RelatedPerson";
|
|
@@ -40828,7 +37528,7 @@ function Bi(r4) {
|
|
|
40828
37528
|
if (Zi(e))
|
|
40829
37529
|
return e.text;
|
|
40830
37530
|
}
|
|
40831
|
-
return
|
|
37531
|
+
return te(r4);
|
|
40832
37532
|
}
|
|
40833
37533
|
function qi(r4) {
|
|
40834
37534
|
let e = r4.name;
|
|
@@ -40996,7 +37696,7 @@ function To(r4, e) {
|
|
|
40996
37696
|
function _(r4) {
|
|
40997
37697
|
return !!(r4 && typeof r4 == "object" && "resourceType" in r4);
|
|
40998
37698
|
}
|
|
40999
|
-
function
|
|
37699
|
+
function ee(r4) {
|
|
41000
37700
|
return !!(r4 && typeof r4 == "object" && "reference" in r4 && typeof r4.reference == "string");
|
|
41001
37701
|
}
|
|
41002
37702
|
var V = { types: {} };
|
|
@@ -41266,7 +37966,7 @@ var st = class extends Ue {
|
|
|
41266
37966
|
return this.operator + this.child.toString();
|
|
41267
37967
|
}
|
|
41268
37968
|
};
|
|
41269
|
-
var
|
|
37969
|
+
var ie = class extends Q {
|
|
41270
37970
|
constructor(e, t) {
|
|
41271
37971
|
super("as", e, t);
|
|
41272
37972
|
}
|
|
@@ -41375,7 +38075,7 @@ var ft = class extends P {
|
|
|
41375
38075
|
return er(rr(n, i2));
|
|
41376
38076
|
}
|
|
41377
38077
|
};
|
|
41378
|
-
var
|
|
38078
|
+
var oe = class extends P {
|
|
41379
38079
|
constructor(e, t) {
|
|
41380
38080
|
super("is", e, t);
|
|
41381
38081
|
}
|
|
@@ -41438,7 +38138,7 @@ var G = class {
|
|
|
41438
38138
|
return `${this.name}(${this.args.map((e) => e.toString()).join(", ")})`;
|
|
41439
38139
|
}
|
|
41440
38140
|
};
|
|
41441
|
-
var
|
|
38141
|
+
var se = class {
|
|
41442
38142
|
constructor(e, t) {
|
|
41443
38143
|
this.left = e;
|
|
41444
38144
|
this.expr = t;
|
|
@@ -41469,7 +38169,7 @@ var Ro = { parse(r4, e) {
|
|
|
41469
38169
|
let t = r4.consumeAndParse();
|
|
41470
38170
|
if (!r4.match("]"))
|
|
41471
38171
|
throw new Error("Parse error: expected `]`");
|
|
41472
|
-
return new
|
|
38172
|
+
return new se(e, t);
|
|
41473
38173
|
}, precedence: h.Indexer };
|
|
41474
38174
|
var Po = { parse(r4, e) {
|
|
41475
38175
|
if (!(e instanceof $))
|
|
@@ -41484,7 +38184,7 @@ function Co(r4) {
|
|
|
41484
38184
|
return n?.startsWith("'") && n.endsWith("'") ? n = n.substring(1, n.length - 1) : n = "{" + n + "}", { value: t, unit: n };
|
|
41485
38185
|
}
|
|
41486
38186
|
function ke() {
|
|
41487
|
-
return new Be().registerPrefix("String", { parse: (r4, e) => new M({ type: l.string, value: e.value }) }).registerPrefix("DateTime", { parse: (r4, e) => new M({ type: l.dateTime, value: ge(e.value) }) }).registerPrefix("Quantity", { parse: (r4, e) => new M({ type: l.Quantity, value: Co(e.value) }) }).registerPrefix("Number", { parse: (r4, e) => new M({ type: e.value.includes(".") ? l.decimal : l.integer, value: parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new M({ type: l.boolean, value: true }) }).registerPrefix("false", { parse: () => new M({ type: l.boolean, value: false }) }).registerPrefix("Symbol", { parse: (r4, e) => new $(e.value) }).registerPrefix("{}", { parse: () => new ot() }).registerPrefix("(", bo).registerInfix("[", Ro).registerInfix("(", Po).prefix("+", h.UnaryAdd, (r4, e) => new st("+", e, (t) => t)).prefix("-", h.UnarySubtract, (r4, e) => new I("-", e, e, (t, n) => -n)).infixLeft(".", h.Dot, (r4, e, t) => new z(r4, t)).infixLeft("/", h.Divide, (r4, e, t) => new I("/", r4, t, (n, i2) => n / i2)).infixLeft("*", h.Multiply, (r4, e, t) => new I("*", r4, t, (n, i2) => n * i2)).infixLeft("+", h.Add, (r4, e, t) => new I("+", r4, t, (n, i2) => n + i2)).infixLeft("-", h.Subtract, (r4, e, t) => new I("-", r4, t, (n, i2) => n - i2)).infixLeft("|", h.Union, (r4, e, t) => new xe(r4, t)).infixLeft("=", h.Equals, (r4, e, t) => new lt(r4, t)).infixLeft("!=", h.NotEquals, (r4, e, t) => new pt(r4, t)).infixLeft("~", h.Equivalent, (r4, e, t) => new dt(r4, t)).infixLeft("!~", h.NotEquivalent, (r4, e, t) => new ft(r4, t)).infixLeft("<", h.LessThan, (r4, e, t) => new I("<", r4, t, (n, i2) => n < i2)).infixLeft("<=", h.LessThanOrEquals, (r4, e, t) => new I("<=", r4, t, (n, i2) => n <= i2)).infixLeft(">", h.GreaterThan, (r4, e, t) => new I(">", r4, t, (n, i2) => n > i2)).infixLeft(">=", h.GreaterThanOrEquals, (r4, e, t) => new I(">=", r4, t, (n, i2) => n >= i2)).infixLeft("&", h.Ampersand, (r4, e, t) => new at(r4, t)).infixLeft("and", h.And, (r4, e, t) => new mt(r4, t)).infixLeft("as", h.As, (r4, e, t) => new
|
|
38187
|
+
return new Be().registerPrefix("String", { parse: (r4, e) => new M({ type: l.string, value: e.value }) }).registerPrefix("DateTime", { parse: (r4, e) => new M({ type: l.dateTime, value: ge(e.value) }) }).registerPrefix("Quantity", { parse: (r4, e) => new M({ type: l.Quantity, value: Co(e.value) }) }).registerPrefix("Number", { parse: (r4, e) => new M({ type: e.value.includes(".") ? l.decimal : l.integer, value: parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new M({ type: l.boolean, value: true }) }).registerPrefix("false", { parse: () => new M({ type: l.boolean, value: false }) }).registerPrefix("Symbol", { parse: (r4, e) => new $(e.value) }).registerPrefix("{}", { parse: () => new ot() }).registerPrefix("(", bo).registerInfix("[", Ro).registerInfix("(", Po).prefix("+", h.UnaryAdd, (r4, e) => new st("+", e, (t) => t)).prefix("-", h.UnarySubtract, (r4, e) => new I("-", e, e, (t, n) => -n)).infixLeft(".", h.Dot, (r4, e, t) => new z(r4, t)).infixLeft("/", h.Divide, (r4, e, t) => new I("/", r4, t, (n, i2) => n / i2)).infixLeft("*", h.Multiply, (r4, e, t) => new I("*", r4, t, (n, i2) => n * i2)).infixLeft("+", h.Add, (r4, e, t) => new I("+", r4, t, (n, i2) => n + i2)).infixLeft("-", h.Subtract, (r4, e, t) => new I("-", r4, t, (n, i2) => n - i2)).infixLeft("|", h.Union, (r4, e, t) => new xe(r4, t)).infixLeft("=", h.Equals, (r4, e, t) => new lt(r4, t)).infixLeft("!=", h.NotEquals, (r4, e, t) => new pt(r4, t)).infixLeft("~", h.Equivalent, (r4, e, t) => new dt(r4, t)).infixLeft("!~", h.NotEquivalent, (r4, e, t) => new ft(r4, t)).infixLeft("<", h.LessThan, (r4, e, t) => new I("<", r4, t, (n, i2) => n < i2)).infixLeft("<=", h.LessThanOrEquals, (r4, e, t) => new I("<=", r4, t, (n, i2) => n <= i2)).infixLeft(">", h.GreaterThan, (r4, e, t) => new I(">", r4, t, (n, i2) => n > i2)).infixLeft(">=", h.GreaterThanOrEquals, (r4, e, t) => new I(">=", r4, t, (n, i2) => n >= i2)).infixLeft("&", h.Ampersand, (r4, e, t) => new at(r4, t)).infixLeft("and", h.And, (r4, e, t) => new mt(r4, t)).infixLeft("as", h.As, (r4, e, t) => new ie(r4, t)).infixLeft("contains", h.Contains, (r4, e, t) => new ct(r4, t)).infixLeft("div", h.Divide, (r4, e, t) => new I("div", r4, t, (n, i2) => n / i2 | 0)).infixLeft("in", h.In, (r4, e, t) => new ut(r4, t)).infixLeft("is", h.Is, (r4, e, t) => new oe(r4, t)).infixLeft("mod", h.Modulo, (r4, e, t) => new I("mod", r4, t, (n, i2) => n % i2)).infixLeft("or", h.Or, (r4, e, t) => new ht(r4, t)).infixLeft("xor", h.Xor, (r4, e, t) => new yt(r4, t)).infixLeft("implies", h.Implies, (r4, e, t) => new gt(r4, t));
|
|
41488
38188
|
}
|
|
41489
38189
|
var wo = ke();
|
|
41490
38190
|
var On = ((p2) => (p2.BOOLEAN = "BOOLEAN", p2.NUMBER = "NUMBER", p2.QUANTITY = "QUANTITY", p2.TEXT = "TEXT", p2.REFERENCE = "REFERENCE", p2.CANONICAL = "CANONICAL", p2.DATE = "DATE", p2.DATETIME = "DATETIME", p2.PERIOD = "PERIOD", p2.UUID = "UUID", p2))(On || {});
|
|
@@ -41511,7 +38211,7 @@ function yr() {
|
|
|
41511
38211
|
async function qn(r4) {
|
|
41512
38212
|
return crypto.subtle.digest("SHA-256", new TextEncoder().encode(r4));
|
|
41513
38213
|
}
|
|
41514
|
-
function
|
|
38214
|
+
function ae() {
|
|
41515
38215
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (r4) => {
|
|
41516
38216
|
let e = Math.random() * 16 | 0;
|
|
41517
38217
|
return (r4 === "x" ? e : e & 3 | 8).toString(16);
|
|
@@ -41570,7 +38270,7 @@ var De = class {
|
|
|
41570
38270
|
this.listeners = {};
|
|
41571
38271
|
}
|
|
41572
38272
|
};
|
|
41573
|
-
var
|
|
38273
|
+
var ce = class {
|
|
41574
38274
|
constructor() {
|
|
41575
38275
|
this.emitter = new De();
|
|
41576
38276
|
}
|
|
@@ -41672,9 +38372,9 @@ function Tr(r4, e, t, n) {
|
|
|
41672
38372
|
if (xr.includes(e) && !n)
|
|
41673
38373
|
throw new d(m(`The '${e}' event must contain a 'context.versionId'.`));
|
|
41674
38374
|
let i2 = Array.isArray(t) ? t : [t];
|
|
41675
|
-
return hs(e, i2), { timestamp: (/* @__PURE__ */ new Date()).toISOString(), id:
|
|
38375
|
+
return hs(e, i2), { timestamp: (/* @__PURE__ */ new Date()).toISOString(), id: ae(), event: { "hub.topic": r4, "hub.event": e, context: i2, ...n ? { "context.versionId": n } : {} } };
|
|
41676
38376
|
}
|
|
41677
|
-
var Tt = class extends
|
|
38377
|
+
var Tt = class extends ce {
|
|
41678
38378
|
constructor(e) {
|
|
41679
38379
|
if (super(), this.subRequest = e, !e.endpoint)
|
|
41680
38380
|
throw new d(m("Subscription request should contain an endpoint."));
|
|
@@ -41820,7 +38520,7 @@ var Sr = class {
|
|
|
41820
38520
|
return Array.from(this.data.keys())[e];
|
|
41821
38521
|
}
|
|
41822
38522
|
};
|
|
41823
|
-
var Er = class extends
|
|
38523
|
+
var Er = class extends ce {
|
|
41824
38524
|
constructor(t) {
|
|
41825
38525
|
super();
|
|
41826
38526
|
this.bufferedAmount = -1 / 0;
|
|
@@ -41860,7 +38560,7 @@ var Er = class extends ae {
|
|
|
41860
38560
|
}
|
|
41861
38561
|
}
|
|
41862
38562
|
};
|
|
41863
|
-
var Ne = class extends
|
|
38563
|
+
var Ne = class extends ce {
|
|
41864
38564
|
constructor(...e) {
|
|
41865
38565
|
super(), this.criteria = new Set(e);
|
|
41866
38566
|
}
|
|
@@ -41939,7 +38639,7 @@ var Rt = class {
|
|
|
41939
38639
|
}
|
|
41940
38640
|
async getTokenForCriteria(e) {
|
|
41941
38641
|
let t = e?.subscriptionId;
|
|
41942
|
-
t || (t = (await this.medplum.createResource({ resourceType: "Subscription", status: "active", reason: `WebSocket subscription for ${
|
|
38642
|
+
t || (t = (await this.medplum.createResource({ resourceType: "Subscription", status: "active", reason: `WebSocket subscription for ${te(this.medplum.getProfile())}`, criteria: e.criteria, channel: { type: "websocket" } })).id);
|
|
41943
38643
|
let { parameter: n } = await this.medplum.get(`fhir/R4/Subscription/${t}/$get-ws-binding-token`), i2 = n?.find((s) => s.name === "token")?.valueString, o = n?.find((s) => s.name === "websocket-url")?.valueUrl;
|
|
41944
38644
|
if (!i2)
|
|
41945
38645
|
throw new d(m("Failed to get token"));
|
|
@@ -41980,7 +38680,7 @@ var Rt = class {
|
|
|
41980
38680
|
return this.masterSubEmitter || (this.masterSubEmitter = new Ne(...Array.from(this.criteriaEntries.keys()))), this.masterSubEmitter;
|
|
41981
38681
|
}
|
|
41982
38682
|
};
|
|
41983
|
-
var Op = "3.1.
|
|
38683
|
+
var Op = "3.1.5-6e0fc2e2f";
|
|
41984
38684
|
var xs = N.FHIR_JSON + ", */*; q=0.1";
|
|
41985
38685
|
var vs = "https://api.medplum.com/";
|
|
41986
38686
|
var Ts = 1e3;
|
|
@@ -42297,8 +38997,8 @@ var Pt = class extends De {
|
|
|
42297
38997
|
return { contentType: a.contentType, url: u2.url, title: a.filename };
|
|
42298
38998
|
}
|
|
42299
38999
|
createBinary(t, n, i2, o, s) {
|
|
42300
|
-
let a = ei(t, n, i2, o), c2 = s ?? (typeof n == "object" ? n : {}), { data: u2, contentType: p2, filename: y, securityContext: g2, onProgress:
|
|
42301
|
-
return y && Re.searchParams.set("_filename", y), g2?.reference && this.setRequestHeader(c2, "X-Security-Context", g2.reference),
|
|
39000
|
+
let a = ei(t, n, i2, o), c2 = s ?? (typeof n == "object" ? n : {}), { data: u2, contentType: p2, filename: y, securityContext: g2, onProgress: le } = a, Re = this.fhirUrl("Binary");
|
|
39001
|
+
return y && Re.searchParams.set("_filename", y), g2?.reference && this.setRequestHeader(c2, "X-Security-Context", g2.reference), le ? this.uploadwithProgress(Re, u2, p2, le, c2) : this.post(Re, u2, p2, c2);
|
|
42302
39002
|
}
|
|
42303
39003
|
uploadwithProgress(t, n, i2, o, s) {
|
|
42304
39004
|
return new Promise((a, c2) => {
|
|
@@ -42311,8 +39011,8 @@ var Pt = class extends De {
|
|
|
42311
39011
|
u2.status >= 200 && u2.status < 300 ? y(u2.response) : y(new d($e(u2.response || u2.statusText)));
|
|
42312
39012
|
}, u2.open("POST", t), u2.withCredentials = true, u2.setRequestHeader("Authorization", "Bearer " + this.accessToken), u2.setRequestHeader("Cache-Control", "no-cache, no-store, max-age=0"), u2.setRequestHeader("Content-Type", i2), u2.setRequestHeader("X-Medplum", "extended"), s?.headers) {
|
|
42313
39013
|
let g2 = s.headers;
|
|
42314
|
-
for (let [
|
|
42315
|
-
u2.setRequestHeader(
|
|
39014
|
+
for (let [le, Re] of Object.entries(g2))
|
|
39015
|
+
u2.setRequestHeader(le, Re);
|
|
42316
39016
|
}
|
|
42317
39017
|
u2.send(n);
|
|
42318
39018
|
});
|
|
@@ -42320,8 +39020,8 @@ var Pt = class extends De {
|
|
|
42320
39020
|
async createPdf(t, n, i2, o) {
|
|
42321
39021
|
if (!this.createPdfImpl)
|
|
42322
39022
|
throw new Error("PDF creation not enabled");
|
|
42323
|
-
let s = ks(t, n, i2, o), a = typeof n == "object" ? n : {}, { docDefinition: c2, tableLayouts: u2, fonts: p2, ...y } = s, g2 = await this.createPdfImpl(c2, u2, p2),
|
|
42324
|
-
return this.createBinary(
|
|
39023
|
+
let s = ks(t, n, i2, o), a = typeof n == "object" ? n : {}, { docDefinition: c2, tableLayouts: u2, fonts: p2, ...y } = s, g2 = await this.createPdfImpl(c2, u2, p2), le = { ...y, data: g2, contentType: "application/pdf" };
|
|
39024
|
+
return this.createBinary(le, a);
|
|
42325
39025
|
}
|
|
42326
39026
|
createComment(t, n, i2) {
|
|
42327
39027
|
let o = this.getProfile(), s, a;
|
|
@@ -42368,13 +39068,13 @@ var Pt = class extends De {
|
|
|
42368
39068
|
return this.get(`${this.fhirUrl(t, n)}/$graph?graph=${i2}`, o);
|
|
42369
39069
|
}
|
|
42370
39070
|
pushToAgent(t, n, i2, o, s, a) {
|
|
42371
|
-
return this.post(this.fhirUrl("Agent", et(t), "$push"), { destination: typeof n == "string" ? n :
|
|
39071
|
+
return this.post(this.fhirUrl("Agent", et(t), "$push"), { destination: typeof n == "string" ? n : te(n), body: i2, contentType: o, waitForResponse: s }, N.FHIR_JSON, a);
|
|
42372
39072
|
}
|
|
42373
39073
|
getActiveLogin() {
|
|
42374
39074
|
return this.storage.getObject("activeLogin");
|
|
42375
39075
|
}
|
|
42376
39076
|
async setActiveLogin(t) {
|
|
42377
|
-
(!this.sessionDetails?.profile ||
|
|
39077
|
+
(!this.sessionDetails?.profile || te(this.sessionDetails.profile) !== t.profile?.reference) && this.clearActiveLogin(), this.setAccessToken(t.accessToken, t.refreshToken), this.storage.setObject("activeLogin", t), this.addLogin(t), this.refreshPromise = void 0, await this.refreshProfile();
|
|
42378
39078
|
}
|
|
42379
39079
|
getAccessToken() {
|
|
42380
39080
|
return this.accessToken;
|
|
@@ -42728,7 +39428,7 @@ async function Xn(r4, e) {
|
|
|
42728
39428
|
let n = r4.headers.get("location");
|
|
42729
39429
|
if (n)
|
|
42730
39430
|
return n;
|
|
42731
|
-
if (
|
|
39431
|
+
if (pe(e) && e.issue?.[0]?.diagnostics)
|
|
42732
39432
|
return e.issue[0].diagnostics;
|
|
42733
39433
|
}
|
|
42734
39434
|
function Rr(r4) {
|
|
@@ -43180,149 +39880,6 @@ var AgentHl7ChannelConnection = class {
|
|
|
43180
39880
|
}
|
|
43181
39881
|
};
|
|
43182
39882
|
|
|
43183
|
-
// src/serialport.ts
|
|
43184
|
-
var import_serialport = __toESM(require_dist17());
|
|
43185
|
-
var ASCII_START_OF_HEADING = 1;
|
|
43186
|
-
var ASCII_START_OF_TEXT = 2;
|
|
43187
|
-
var ASCII_END_OF_TEXT = 3;
|
|
43188
|
-
var ASCII_END_OF_TRANSMISSION = 4;
|
|
43189
|
-
var ASCII_ENQUIRY = 5;
|
|
43190
|
-
var ASCII_ACKNOWLEDGE = 6;
|
|
43191
|
-
var ASCII_NEW_LINE = 10;
|
|
43192
|
-
var AgentSerialPortChannel = class {
|
|
43193
|
-
constructor(app, definition, endpoint) {
|
|
43194
|
-
this.app = app;
|
|
43195
|
-
this.definition = definition;
|
|
43196
|
-
this.endpoint = endpoint;
|
|
43197
|
-
this.buffer = "";
|
|
43198
|
-
this.url = new URL(this.endpoint.address);
|
|
43199
|
-
this.path = this.url.hostname + this.url.pathname;
|
|
43200
|
-
this.port = new import_serialport.SerialPort({
|
|
43201
|
-
path: this.path,
|
|
43202
|
-
baudRate: parseInt(this.url.searchParams.get("baudRate") || "9600", 10),
|
|
43203
|
-
dataBits: parseInt(this.url.searchParams.get("dataBits") || "8", 10),
|
|
43204
|
-
stopBits: parseFloat(this.url.searchParams.get("stopBits") || "1"),
|
|
43205
|
-
autoOpen: false
|
|
43206
|
-
});
|
|
43207
|
-
}
|
|
43208
|
-
start() {
|
|
43209
|
-
this.app.log.info(`Channel starting on ${this.url}`);
|
|
43210
|
-
const clearOnStartOfHeading = this.url.searchParams.get("clearOnStartOfHeading") === "true";
|
|
43211
|
-
const clearOnStartOfText = this.url.searchParams.get("clearOnStartOfText") === "true";
|
|
43212
|
-
const ackOnEndOfText = this.url.searchParams.get("ackOnEndOfText") === "true";
|
|
43213
|
-
const ackOnEndOfTransmission = this.url.searchParams.get("ackOnEndOfTransmission") === "true";
|
|
43214
|
-
const transmitOnEndOfText = this.url.searchParams.get("transmitOnEndOfText") === "true";
|
|
43215
|
-
const transmitOnEndOfTransmission = this.url.searchParams.get("transmitOnEndOfTransmission") === "true";
|
|
43216
|
-
const ackOnEnquiry = this.url.searchParams.get("ackOnEnquiry") === "true";
|
|
43217
|
-
const ackOnNewLine = this.url.searchParams.get("ackOnNewLine") === "true";
|
|
43218
|
-
const transmitOnNewLine = this.url.searchParams.get("transmitOnNewLine") === "true";
|
|
43219
|
-
this.port.on("open", () => {
|
|
43220
|
-
this.logInfo(`[${this.path}] Serial port open`);
|
|
43221
|
-
this.sendToServer(`[${this.path}] Serial port open`);
|
|
43222
|
-
});
|
|
43223
|
-
this.port.on("error", (err) => {
|
|
43224
|
-
this.logError(`[${this.path}] Serial port error: ` + err);
|
|
43225
|
-
this.sendToServer(`[${this.path}] Serial port error: ` + err);
|
|
43226
|
-
});
|
|
43227
|
-
this.port.on("data", (data2) => {
|
|
43228
|
-
const str = data2.toString("ascii");
|
|
43229
|
-
for (let i2 = 0; i2 < str.length; i2++) {
|
|
43230
|
-
const code = str.charCodeAt(i2);
|
|
43231
|
-
switch (code) {
|
|
43232
|
-
case ASCII_START_OF_HEADING:
|
|
43233
|
-
if (clearOnStartOfHeading) {
|
|
43234
|
-
this.buffer = "";
|
|
43235
|
-
}
|
|
43236
|
-
break;
|
|
43237
|
-
case ASCII_START_OF_TEXT:
|
|
43238
|
-
if (clearOnStartOfText) {
|
|
43239
|
-
this.buffer = "";
|
|
43240
|
-
}
|
|
43241
|
-
break;
|
|
43242
|
-
case ASCII_END_OF_TEXT:
|
|
43243
|
-
if (transmitOnEndOfText) {
|
|
43244
|
-
this.sendToServer(this.buffer);
|
|
43245
|
-
this.buffer = "";
|
|
43246
|
-
}
|
|
43247
|
-
if (ackOnEndOfText) {
|
|
43248
|
-
this.port.write(String.fromCharCode(ASCII_ACKNOWLEDGE));
|
|
43249
|
-
}
|
|
43250
|
-
break;
|
|
43251
|
-
case ASCII_END_OF_TRANSMISSION:
|
|
43252
|
-
if (transmitOnEndOfTransmission) {
|
|
43253
|
-
this.sendToServer(this.buffer);
|
|
43254
|
-
this.buffer = "";
|
|
43255
|
-
}
|
|
43256
|
-
if (ackOnEndOfTransmission) {
|
|
43257
|
-
this.port.write(String.fromCharCode(ASCII_ACKNOWLEDGE));
|
|
43258
|
-
}
|
|
43259
|
-
break;
|
|
43260
|
-
case ASCII_ENQUIRY:
|
|
43261
|
-
if (ackOnEnquiry) {
|
|
43262
|
-
this.port.write(String.fromCharCode(ASCII_ACKNOWLEDGE));
|
|
43263
|
-
}
|
|
43264
|
-
break;
|
|
43265
|
-
case ASCII_NEW_LINE:
|
|
43266
|
-
if (transmitOnNewLine) {
|
|
43267
|
-
this.sendToServer(this.buffer);
|
|
43268
|
-
this.buffer = "";
|
|
43269
|
-
} else {
|
|
43270
|
-
this.buffer += "\n";
|
|
43271
|
-
}
|
|
43272
|
-
if (ackOnNewLine) {
|
|
43273
|
-
this.port.write(String.fromCharCode(ASCII_ACKNOWLEDGE));
|
|
43274
|
-
}
|
|
43275
|
-
break;
|
|
43276
|
-
default:
|
|
43277
|
-
this.buffer += str.charAt(i2);
|
|
43278
|
-
break;
|
|
43279
|
-
}
|
|
43280
|
-
}
|
|
43281
|
-
});
|
|
43282
|
-
this.port.open((err) => {
|
|
43283
|
-
if (err) {
|
|
43284
|
-
this.logError(`[${this.path}] Error opening serial port: ` + err);
|
|
43285
|
-
}
|
|
43286
|
-
});
|
|
43287
|
-
this.sendToServer(`[${this.path}] Running`);
|
|
43288
|
-
this.app.log.info("Channel started successfully");
|
|
43289
|
-
}
|
|
43290
|
-
stop() {
|
|
43291
|
-
this.app.log.info("Channel stopping...");
|
|
43292
|
-
this.port.close((err) => {
|
|
43293
|
-
if (err) {
|
|
43294
|
-
this.logError(`[${this.path}] Error closing serial port: ` + err);
|
|
43295
|
-
}
|
|
43296
|
-
});
|
|
43297
|
-
this.app.log.info("Channel stopped successfully");
|
|
43298
|
-
}
|
|
43299
|
-
sendToRemote(msg) {
|
|
43300
|
-
console.warn(`SerialPort sendToRemote not implemented (${msg.body})`);
|
|
43301
|
-
}
|
|
43302
|
-
sendToServer(body) {
|
|
43303
|
-
try {
|
|
43304
|
-
this.app.log.info("Received:");
|
|
43305
|
-
this.app.log.info(body);
|
|
43306
|
-
this.app.addToWebSocketQueue({
|
|
43307
|
-
type: "agent:transmit:request",
|
|
43308
|
-
accessToken: "placeholder",
|
|
43309
|
-
channel: this.definition.name,
|
|
43310
|
-
remote: this.path,
|
|
43311
|
-
contentType: N.TEXT,
|
|
43312
|
-
body
|
|
43313
|
-
});
|
|
43314
|
-
} catch (err) {
|
|
43315
|
-
this.app.log.error(`HL7 error: ${vi(err)}`);
|
|
43316
|
-
}
|
|
43317
|
-
}
|
|
43318
|
-
logInfo(message) {
|
|
43319
|
-
this.app.log.info(message);
|
|
43320
|
-
}
|
|
43321
|
-
logError(message) {
|
|
43322
|
-
this.app.log.error(message);
|
|
43323
|
-
}
|
|
43324
|
-
};
|
|
43325
|
-
|
|
43326
39883
|
// src/app.ts
|
|
43327
39884
|
async function execAsync(command, options) {
|
|
43328
39885
|
return new Promise((resolve, reject) => {
|
|
@@ -43460,8 +40017,6 @@ var App = class _App {
|
|
|
43460
40017
|
channel = new AgentDicomChannel(this, definition, endpoint);
|
|
43461
40018
|
} else if (endpoint.address.startsWith("mllp")) {
|
|
43462
40019
|
channel = new AgentHl7Channel(this, definition, endpoint);
|
|
43463
|
-
} else if (endpoint.address.startsWith("serial")) {
|
|
43464
|
-
channel = new AgentSerialPortChannel(this, definition, endpoint);
|
|
43465
40020
|
} else {
|
|
43466
40021
|
this.log.error(`Unsupported endpoint type: ${endpoint.address}`);
|
|
43467
40022
|
}
|
|
@@ -43654,6 +40209,13 @@ async function main(argv) {
|
|
|
43654
40209
|
let args;
|
|
43655
40210
|
if (argv.length >= 6) {
|
|
43656
40211
|
args = readCommandLineArgs(argv);
|
|
40212
|
+
} else if (argv.length === 3 && (argv[2] === "-h" || argv[2] === "--help")) {
|
|
40213
|
+
console.log("Expected arguments:");
|
|
40214
|
+
console.log(" baseUrl: The Medplum server base URL.");
|
|
40215
|
+
console.log(" clientId: The OAuth client ID.");
|
|
40216
|
+
console.log(" clientSecret: The OAuth client secret.");
|
|
40217
|
+
console.log(" agentId: The Medplum agent ID.");
|
|
40218
|
+
process.exit(0);
|
|
43657
40219
|
} else if ((0, import_fs.existsSync)("agent.properties")) {
|
|
43658
40220
|
args = readPropertiesFile("agent.properties");
|
|
43659
40221
|
} else {
|