@stencil/core 4.30.0 → 4.31.0-dev.1746680515.992a687

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil Dev Server Process v4.30.0 | MIT Licensed | https://stenciljs.com
2
+ Stencil Dev Server Process v4.31.0-dev.1746680515.992a687 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  "use strict";
5
5
  var __create = Object.create;
@@ -3941,6 +3941,3502 @@ var require_get_stream2 = __commonJS({
3941
3941
  }
3942
3942
  });
3943
3943
 
3944
+ // node_modules/ws/lib/stream.js
3945
+ var require_stream2 = __commonJS({
3946
+ "node_modules/ws/lib/stream.js"(exports2, module2) {
3947
+ "use strict";
3948
+ var { Duplex } = require("stream");
3949
+ function emitClose(stream) {
3950
+ stream.emit("close");
3951
+ }
3952
+ function duplexOnEnd() {
3953
+ if (!this.destroyed && this._writableState.finished) {
3954
+ this.destroy();
3955
+ }
3956
+ }
3957
+ function duplexOnError(err2) {
3958
+ this.removeListener("error", duplexOnError);
3959
+ this.destroy();
3960
+ if (this.listenerCount("error") === 0) {
3961
+ this.emit("error", err2);
3962
+ }
3963
+ }
3964
+ function createWebSocketStream2(ws, options) {
3965
+ let terminateOnDestroy = true;
3966
+ const duplex = new Duplex({
3967
+ ...options,
3968
+ autoDestroy: false,
3969
+ emitClose: false,
3970
+ objectMode: false,
3971
+ writableObjectMode: false
3972
+ });
3973
+ ws.on("message", function message(msg, isBinary) {
3974
+ const data = !isBinary && duplex._readableState.objectMode ? msg.toString() : msg;
3975
+ if (!duplex.push(data)) ws.pause();
3976
+ });
3977
+ ws.once("error", function error(err2) {
3978
+ if (duplex.destroyed) return;
3979
+ terminateOnDestroy = false;
3980
+ duplex.destroy(err2);
3981
+ });
3982
+ ws.once("close", function close() {
3983
+ if (duplex.destroyed) return;
3984
+ duplex.push(null);
3985
+ });
3986
+ duplex._destroy = function(err2, callback) {
3987
+ if (ws.readyState === ws.CLOSED) {
3988
+ callback(err2);
3989
+ process.nextTick(emitClose, duplex);
3990
+ return;
3991
+ }
3992
+ let called = false;
3993
+ ws.once("error", function error(err3) {
3994
+ called = true;
3995
+ callback(err3);
3996
+ });
3997
+ ws.once("close", function close() {
3998
+ if (!called) callback(err2);
3999
+ process.nextTick(emitClose, duplex);
4000
+ });
4001
+ if (terminateOnDestroy) ws.terminate();
4002
+ };
4003
+ duplex._final = function(callback) {
4004
+ if (ws.readyState === ws.CONNECTING) {
4005
+ ws.once("open", function open2() {
4006
+ duplex._final(callback);
4007
+ });
4008
+ return;
4009
+ }
4010
+ if (ws._socket === null) return;
4011
+ if (ws._socket._writableState.finished) {
4012
+ callback();
4013
+ if (duplex._readableState.endEmitted) duplex.destroy();
4014
+ } else {
4015
+ ws._socket.once("finish", function finish() {
4016
+ callback();
4017
+ });
4018
+ ws.close();
4019
+ }
4020
+ };
4021
+ duplex._read = function() {
4022
+ if (ws.isPaused) ws.resume();
4023
+ };
4024
+ duplex._write = function(chunk, encoding, callback) {
4025
+ if (ws.readyState === ws.CONNECTING) {
4026
+ ws.once("open", function open2() {
4027
+ duplex._write(chunk, encoding, callback);
4028
+ });
4029
+ return;
4030
+ }
4031
+ ws.send(chunk, callback);
4032
+ };
4033
+ duplex.on("end", duplexOnEnd);
4034
+ duplex.on("error", duplexOnError);
4035
+ return duplex;
4036
+ }
4037
+ module2.exports = createWebSocketStream2;
4038
+ }
4039
+ });
4040
+
4041
+ // node_modules/ws/lib/constants.js
4042
+ var require_constants = __commonJS({
4043
+ "node_modules/ws/lib/constants.js"(exports2, module2) {
4044
+ "use strict";
4045
+ module2.exports = {
4046
+ BINARY_TYPES: ["nodebuffer", "arraybuffer", "fragments"],
4047
+ EMPTY_BUFFER: Buffer.alloc(0),
4048
+ GUID: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
4049
+ kForOnEventAttribute: Symbol("kIsForOnEventAttribute"),
4050
+ kListener: Symbol("kListener"),
4051
+ kStatusCode: Symbol("status-code"),
4052
+ kWebSocket: Symbol("websocket"),
4053
+ NOOP: () => {
4054
+ }
4055
+ };
4056
+ }
4057
+ });
4058
+
4059
+ // node_modules/ws/lib/buffer-util.js
4060
+ var require_buffer_util = __commonJS({
4061
+ "node_modules/ws/lib/buffer-util.js"(exports2, module2) {
4062
+ "use strict";
4063
+ var { EMPTY_BUFFER } = require_constants();
4064
+ var FastBuffer = Buffer[Symbol.species];
4065
+ function concat(list, totalLength) {
4066
+ if (list.length === 0) return EMPTY_BUFFER;
4067
+ if (list.length === 1) return list[0];
4068
+ const target = Buffer.allocUnsafe(totalLength);
4069
+ let offset = 0;
4070
+ for (let i = 0; i < list.length; i++) {
4071
+ const buf = list[i];
4072
+ target.set(buf, offset);
4073
+ offset += buf.length;
4074
+ }
4075
+ if (offset < totalLength) {
4076
+ return new FastBuffer(target.buffer, target.byteOffset, offset);
4077
+ }
4078
+ return target;
4079
+ }
4080
+ function _mask(source, mask, output, offset, length) {
4081
+ for (let i = 0; i < length; i++) {
4082
+ output[offset + i] = source[i] ^ mask[i & 3];
4083
+ }
4084
+ }
4085
+ function _unmask(buffer, mask) {
4086
+ for (let i = 0; i < buffer.length; i++) {
4087
+ buffer[i] ^= mask[i & 3];
4088
+ }
4089
+ }
4090
+ function toArrayBuffer(buf) {
4091
+ if (buf.length === buf.buffer.byteLength) {
4092
+ return buf.buffer;
4093
+ }
4094
+ return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.length);
4095
+ }
4096
+ function toBuffer(data) {
4097
+ toBuffer.readOnly = true;
4098
+ if (Buffer.isBuffer(data)) return data;
4099
+ let buf;
4100
+ if (data instanceof ArrayBuffer) {
4101
+ buf = new FastBuffer(data);
4102
+ } else if (ArrayBuffer.isView(data)) {
4103
+ buf = new FastBuffer(data.buffer, data.byteOffset, data.byteLength);
4104
+ } else {
4105
+ buf = Buffer.from(data);
4106
+ toBuffer.readOnly = false;
4107
+ }
4108
+ return buf;
4109
+ }
4110
+ module2.exports = {
4111
+ concat,
4112
+ mask: _mask,
4113
+ toArrayBuffer,
4114
+ toBuffer,
4115
+ unmask: _unmask
4116
+ };
4117
+ if (!process.env.WS_NO_BUFFER_UTIL) {
4118
+ try {
4119
+ const bufferUtil = require("bufferutil");
4120
+ module2.exports.mask = function(source, mask, output, offset, length) {
4121
+ if (length < 48) _mask(source, mask, output, offset, length);
4122
+ else bufferUtil.mask(source, mask, output, offset, length);
4123
+ };
4124
+ module2.exports.unmask = function(buffer, mask) {
4125
+ if (buffer.length < 32) _unmask(buffer, mask);
4126
+ else bufferUtil.unmask(buffer, mask);
4127
+ };
4128
+ } catch (e) {
4129
+ }
4130
+ }
4131
+ }
4132
+ });
4133
+
4134
+ // node_modules/ws/lib/limiter.js
4135
+ var require_limiter = __commonJS({
4136
+ "node_modules/ws/lib/limiter.js"(exports2, module2) {
4137
+ "use strict";
4138
+ var kDone = Symbol("kDone");
4139
+ var kRun = Symbol("kRun");
4140
+ var Limiter = class {
4141
+ /**
4142
+ * Creates a new `Limiter`.
4143
+ *
4144
+ * @param {Number} [concurrency=Infinity] The maximum number of jobs allowed
4145
+ * to run concurrently
4146
+ */
4147
+ constructor(concurrency) {
4148
+ this[kDone] = () => {
4149
+ this.pending--;
4150
+ this[kRun]();
4151
+ };
4152
+ this.concurrency = concurrency || Infinity;
4153
+ this.jobs = [];
4154
+ this.pending = 0;
4155
+ }
4156
+ /**
4157
+ * Adds a job to the queue.
4158
+ *
4159
+ * @param {Function} job The job to run
4160
+ * @public
4161
+ */
4162
+ add(job) {
4163
+ this.jobs.push(job);
4164
+ this[kRun]();
4165
+ }
4166
+ /**
4167
+ * Removes a job from the queue and runs it if possible.
4168
+ *
4169
+ * @private
4170
+ */
4171
+ [kRun]() {
4172
+ if (this.pending === this.concurrency) return;
4173
+ if (this.jobs.length) {
4174
+ const job = this.jobs.shift();
4175
+ this.pending++;
4176
+ job(this[kDone]);
4177
+ }
4178
+ }
4179
+ };
4180
+ module2.exports = Limiter;
4181
+ }
4182
+ });
4183
+
4184
+ // node_modules/ws/lib/permessage-deflate.js
4185
+ var require_permessage_deflate = __commonJS({
4186
+ "node_modules/ws/lib/permessage-deflate.js"(exports2, module2) {
4187
+ "use strict";
4188
+ var zlib2 = require("zlib");
4189
+ var bufferUtil = require_buffer_util();
4190
+ var Limiter = require_limiter();
4191
+ var { kStatusCode } = require_constants();
4192
+ var FastBuffer = Buffer[Symbol.species];
4193
+ var TRAILER = Buffer.from([0, 0, 255, 255]);
4194
+ var kPerMessageDeflate = Symbol("permessage-deflate");
4195
+ var kTotalLength = Symbol("total-length");
4196
+ var kCallback = Symbol("callback");
4197
+ var kBuffers = Symbol("buffers");
4198
+ var kError = Symbol("error");
4199
+ var zlibLimiter;
4200
+ var PerMessageDeflate = class {
4201
+ /**
4202
+ * Creates a PerMessageDeflate instance.
4203
+ *
4204
+ * @param {Object} [options] Configuration options
4205
+ * @param {(Boolean|Number)} [options.clientMaxWindowBits] Advertise support
4206
+ * for, or request, a custom client window size
4207
+ * @param {Boolean} [options.clientNoContextTakeover=false] Advertise/
4208
+ * acknowledge disabling of client context takeover
4209
+ * @param {Number} [options.concurrencyLimit=10] The number of concurrent
4210
+ * calls to zlib
4211
+ * @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the
4212
+ * use of a custom server window size
4213
+ * @param {Boolean} [options.serverNoContextTakeover=false] Request/accept
4214
+ * disabling of server context takeover
4215
+ * @param {Number} [options.threshold=1024] Size (in bytes) below which
4216
+ * messages should not be compressed if context takeover is disabled
4217
+ * @param {Object} [options.zlibDeflateOptions] Options to pass to zlib on
4218
+ * deflate
4219
+ * @param {Object} [options.zlibInflateOptions] Options to pass to zlib on
4220
+ * inflate
4221
+ * @param {Boolean} [isServer=false] Create the instance in either server or
4222
+ * client mode
4223
+ * @param {Number} [maxPayload=0] The maximum allowed message length
4224
+ */
4225
+ constructor(options, isServer, maxPayload) {
4226
+ this._maxPayload = maxPayload | 0;
4227
+ this._options = options || {};
4228
+ this._threshold = this._options.threshold !== void 0 ? this._options.threshold : 1024;
4229
+ this._isServer = !!isServer;
4230
+ this._deflate = null;
4231
+ this._inflate = null;
4232
+ this.params = null;
4233
+ if (!zlibLimiter) {
4234
+ const concurrency = this._options.concurrencyLimit !== void 0 ? this._options.concurrencyLimit : 10;
4235
+ zlibLimiter = new Limiter(concurrency);
4236
+ }
4237
+ }
4238
+ /**
4239
+ * @type {String}
4240
+ */
4241
+ static get extensionName() {
4242
+ return "permessage-deflate";
4243
+ }
4244
+ /**
4245
+ * Create an extension negotiation offer.
4246
+ *
4247
+ * @return {Object} Extension parameters
4248
+ * @public
4249
+ */
4250
+ offer() {
4251
+ const params = {};
4252
+ if (this._options.serverNoContextTakeover) {
4253
+ params.server_no_context_takeover = true;
4254
+ }
4255
+ if (this._options.clientNoContextTakeover) {
4256
+ params.client_no_context_takeover = true;
4257
+ }
4258
+ if (this._options.serverMaxWindowBits) {
4259
+ params.server_max_window_bits = this._options.serverMaxWindowBits;
4260
+ }
4261
+ if (this._options.clientMaxWindowBits) {
4262
+ params.client_max_window_bits = this._options.clientMaxWindowBits;
4263
+ } else if (this._options.clientMaxWindowBits == null) {
4264
+ params.client_max_window_bits = true;
4265
+ }
4266
+ return params;
4267
+ }
4268
+ /**
4269
+ * Accept an extension negotiation offer/response.
4270
+ *
4271
+ * @param {Array} configurations The extension negotiation offers/reponse
4272
+ * @return {Object} Accepted configuration
4273
+ * @public
4274
+ */
4275
+ accept(configurations) {
4276
+ configurations = this.normalizeParams(configurations);
4277
+ this.params = this._isServer ? this.acceptAsServer(configurations) : this.acceptAsClient(configurations);
4278
+ return this.params;
4279
+ }
4280
+ /**
4281
+ * Releases all resources used by the extension.
4282
+ *
4283
+ * @public
4284
+ */
4285
+ cleanup() {
4286
+ if (this._inflate) {
4287
+ this._inflate.close();
4288
+ this._inflate = null;
4289
+ }
4290
+ if (this._deflate) {
4291
+ const callback = this._deflate[kCallback];
4292
+ this._deflate.close();
4293
+ this._deflate = null;
4294
+ if (callback) {
4295
+ callback(
4296
+ new Error(
4297
+ "The deflate stream was closed while data was being processed"
4298
+ )
4299
+ );
4300
+ }
4301
+ }
4302
+ }
4303
+ /**
4304
+ * Accept an extension negotiation offer.
4305
+ *
4306
+ * @param {Array} offers The extension negotiation offers
4307
+ * @return {Object} Accepted configuration
4308
+ * @private
4309
+ */
4310
+ acceptAsServer(offers) {
4311
+ const opts = this._options;
4312
+ const accepted = offers.find((params) => {
4313
+ if (opts.serverNoContextTakeover === false && params.server_no_context_takeover || params.server_max_window_bits && (opts.serverMaxWindowBits === false || typeof opts.serverMaxWindowBits === "number" && opts.serverMaxWindowBits > params.server_max_window_bits) || typeof opts.clientMaxWindowBits === "number" && !params.client_max_window_bits) {
4314
+ return false;
4315
+ }
4316
+ return true;
4317
+ });
4318
+ if (!accepted) {
4319
+ throw new Error("None of the extension offers can be accepted");
4320
+ }
4321
+ if (opts.serverNoContextTakeover) {
4322
+ accepted.server_no_context_takeover = true;
4323
+ }
4324
+ if (opts.clientNoContextTakeover) {
4325
+ accepted.client_no_context_takeover = true;
4326
+ }
4327
+ if (typeof opts.serverMaxWindowBits === "number") {
4328
+ accepted.server_max_window_bits = opts.serverMaxWindowBits;
4329
+ }
4330
+ if (typeof opts.clientMaxWindowBits === "number") {
4331
+ accepted.client_max_window_bits = opts.clientMaxWindowBits;
4332
+ } else if (accepted.client_max_window_bits === true || opts.clientMaxWindowBits === false) {
4333
+ delete accepted.client_max_window_bits;
4334
+ }
4335
+ return accepted;
4336
+ }
4337
+ /**
4338
+ * Accept the extension negotiation response.
4339
+ *
4340
+ * @param {Array} response The extension negotiation response
4341
+ * @return {Object} Accepted configuration
4342
+ * @private
4343
+ */
4344
+ acceptAsClient(response) {
4345
+ const params = response[0];
4346
+ if (this._options.clientNoContextTakeover === false && params.client_no_context_takeover) {
4347
+ throw new Error('Unexpected parameter "client_no_context_takeover"');
4348
+ }
4349
+ if (!params.client_max_window_bits) {
4350
+ if (typeof this._options.clientMaxWindowBits === "number") {
4351
+ params.client_max_window_bits = this._options.clientMaxWindowBits;
4352
+ }
4353
+ } else if (this._options.clientMaxWindowBits === false || typeof this._options.clientMaxWindowBits === "number" && params.client_max_window_bits > this._options.clientMaxWindowBits) {
4354
+ throw new Error(
4355
+ 'Unexpected or invalid parameter "client_max_window_bits"'
4356
+ );
4357
+ }
4358
+ return params;
4359
+ }
4360
+ /**
4361
+ * Normalize parameters.
4362
+ *
4363
+ * @param {Array} configurations The extension negotiation offers/reponse
4364
+ * @return {Array} The offers/response with normalized parameters
4365
+ * @private
4366
+ */
4367
+ normalizeParams(configurations) {
4368
+ configurations.forEach((params) => {
4369
+ Object.keys(params).forEach((key) => {
4370
+ let value = params[key];
4371
+ if (value.length > 1) {
4372
+ throw new Error(`Parameter "${key}" must have only a single value`);
4373
+ }
4374
+ value = value[0];
4375
+ if (key === "client_max_window_bits") {
4376
+ if (value !== true) {
4377
+ const num = +value;
4378
+ if (!Number.isInteger(num) || num < 8 || num > 15) {
4379
+ throw new TypeError(
4380
+ `Invalid value for parameter "${key}": ${value}`
4381
+ );
4382
+ }
4383
+ value = num;
4384
+ } else if (!this._isServer) {
4385
+ throw new TypeError(
4386
+ `Invalid value for parameter "${key}": ${value}`
4387
+ );
4388
+ }
4389
+ } else if (key === "server_max_window_bits") {
4390
+ const num = +value;
4391
+ if (!Number.isInteger(num) || num < 8 || num > 15) {
4392
+ throw new TypeError(
4393
+ `Invalid value for parameter "${key}": ${value}`
4394
+ );
4395
+ }
4396
+ value = num;
4397
+ } else if (key === "client_no_context_takeover" || key === "server_no_context_takeover") {
4398
+ if (value !== true) {
4399
+ throw new TypeError(
4400
+ `Invalid value for parameter "${key}": ${value}`
4401
+ );
4402
+ }
4403
+ } else {
4404
+ throw new Error(`Unknown parameter "${key}"`);
4405
+ }
4406
+ params[key] = value;
4407
+ });
4408
+ });
4409
+ return configurations;
4410
+ }
4411
+ /**
4412
+ * Decompress data. Concurrency limited.
4413
+ *
4414
+ * @param {Buffer} data Compressed data
4415
+ * @param {Boolean} fin Specifies whether or not this is the last fragment
4416
+ * @param {Function} callback Callback
4417
+ * @public
4418
+ */
4419
+ decompress(data, fin, callback) {
4420
+ zlibLimiter.add((done) => {
4421
+ this._decompress(data, fin, (err2, result) => {
4422
+ done();
4423
+ callback(err2, result);
4424
+ });
4425
+ });
4426
+ }
4427
+ /**
4428
+ * Compress data. Concurrency limited.
4429
+ *
4430
+ * @param {(Buffer|String)} data Data to compress
4431
+ * @param {Boolean} fin Specifies whether or not this is the last fragment
4432
+ * @param {Function} callback Callback
4433
+ * @public
4434
+ */
4435
+ compress(data, fin, callback) {
4436
+ zlibLimiter.add((done) => {
4437
+ this._compress(data, fin, (err2, result) => {
4438
+ done();
4439
+ callback(err2, result);
4440
+ });
4441
+ });
4442
+ }
4443
+ /**
4444
+ * Decompress data.
4445
+ *
4446
+ * @param {Buffer} data Compressed data
4447
+ * @param {Boolean} fin Specifies whether or not this is the last fragment
4448
+ * @param {Function} callback Callback
4449
+ * @private
4450
+ */
4451
+ _decompress(data, fin, callback) {
4452
+ const endpoint = this._isServer ? "client" : "server";
4453
+ if (!this._inflate) {
4454
+ const key = `${endpoint}_max_window_bits`;
4455
+ const windowBits = typeof this.params[key] !== "number" ? zlib2.Z_DEFAULT_WINDOWBITS : this.params[key];
4456
+ this._inflate = zlib2.createInflateRaw({
4457
+ ...this._options.zlibInflateOptions,
4458
+ windowBits
4459
+ });
4460
+ this._inflate[kPerMessageDeflate] = this;
4461
+ this._inflate[kTotalLength] = 0;
4462
+ this._inflate[kBuffers] = [];
4463
+ this._inflate.on("error", inflateOnError);
4464
+ this._inflate.on("data", inflateOnData);
4465
+ }
4466
+ this._inflate[kCallback] = callback;
4467
+ this._inflate.write(data);
4468
+ if (fin) this._inflate.write(TRAILER);
4469
+ this._inflate.flush(() => {
4470
+ const err2 = this._inflate[kError];
4471
+ if (err2) {
4472
+ this._inflate.close();
4473
+ this._inflate = null;
4474
+ callback(err2);
4475
+ return;
4476
+ }
4477
+ const data2 = bufferUtil.concat(
4478
+ this._inflate[kBuffers],
4479
+ this._inflate[kTotalLength]
4480
+ );
4481
+ if (this._inflate._readableState.endEmitted) {
4482
+ this._inflate.close();
4483
+ this._inflate = null;
4484
+ } else {
4485
+ this._inflate[kTotalLength] = 0;
4486
+ this._inflate[kBuffers] = [];
4487
+ if (fin && this.params[`${endpoint}_no_context_takeover`]) {
4488
+ this._inflate.reset();
4489
+ }
4490
+ }
4491
+ callback(null, data2);
4492
+ });
4493
+ }
4494
+ /**
4495
+ * Compress data.
4496
+ *
4497
+ * @param {(Buffer|String)} data Data to compress
4498
+ * @param {Boolean} fin Specifies whether or not this is the last fragment
4499
+ * @param {Function} callback Callback
4500
+ * @private
4501
+ */
4502
+ _compress(data, fin, callback) {
4503
+ const endpoint = this._isServer ? "server" : "client";
4504
+ if (!this._deflate) {
4505
+ const key = `${endpoint}_max_window_bits`;
4506
+ const windowBits = typeof this.params[key] !== "number" ? zlib2.Z_DEFAULT_WINDOWBITS : this.params[key];
4507
+ this._deflate = zlib2.createDeflateRaw({
4508
+ ...this._options.zlibDeflateOptions,
4509
+ windowBits
4510
+ });
4511
+ this._deflate[kTotalLength] = 0;
4512
+ this._deflate[kBuffers] = [];
4513
+ this._deflate.on("data", deflateOnData);
4514
+ }
4515
+ this._deflate[kCallback] = callback;
4516
+ this._deflate.write(data);
4517
+ this._deflate.flush(zlib2.Z_SYNC_FLUSH, () => {
4518
+ if (!this._deflate) {
4519
+ return;
4520
+ }
4521
+ let data2 = bufferUtil.concat(
4522
+ this._deflate[kBuffers],
4523
+ this._deflate[kTotalLength]
4524
+ );
4525
+ if (fin) {
4526
+ data2 = new FastBuffer(data2.buffer, data2.byteOffset, data2.length - 4);
4527
+ }
4528
+ this._deflate[kCallback] = null;
4529
+ this._deflate[kTotalLength] = 0;
4530
+ this._deflate[kBuffers] = [];
4531
+ if (fin && this.params[`${endpoint}_no_context_takeover`]) {
4532
+ this._deflate.reset();
4533
+ }
4534
+ callback(null, data2);
4535
+ });
4536
+ }
4537
+ };
4538
+ module2.exports = PerMessageDeflate;
4539
+ function deflateOnData(chunk) {
4540
+ this[kBuffers].push(chunk);
4541
+ this[kTotalLength] += chunk.length;
4542
+ }
4543
+ function inflateOnData(chunk) {
4544
+ this[kTotalLength] += chunk.length;
4545
+ if (this[kPerMessageDeflate]._maxPayload < 1 || this[kTotalLength] <= this[kPerMessageDeflate]._maxPayload) {
4546
+ this[kBuffers].push(chunk);
4547
+ return;
4548
+ }
4549
+ this[kError] = new RangeError("Max payload size exceeded");
4550
+ this[kError].code = "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH";
4551
+ this[kError][kStatusCode] = 1009;
4552
+ this.removeListener("data", inflateOnData);
4553
+ this.reset();
4554
+ }
4555
+ function inflateOnError(err2) {
4556
+ this[kPerMessageDeflate]._inflate = null;
4557
+ err2[kStatusCode] = 1007;
4558
+ this[kCallback](err2);
4559
+ }
4560
+ }
4561
+ });
4562
+
4563
+ // node_modules/ws/lib/validation.js
4564
+ var require_validation = __commonJS({
4565
+ "node_modules/ws/lib/validation.js"(exports2, module2) {
4566
+ "use strict";
4567
+ var { isUtf8 } = require("buffer");
4568
+ var tokenChars = [
4569
+ 0,
4570
+ 0,
4571
+ 0,
4572
+ 0,
4573
+ 0,
4574
+ 0,
4575
+ 0,
4576
+ 0,
4577
+ 0,
4578
+ 0,
4579
+ 0,
4580
+ 0,
4581
+ 0,
4582
+ 0,
4583
+ 0,
4584
+ 0,
4585
+ // 0 - 15
4586
+ 0,
4587
+ 0,
4588
+ 0,
4589
+ 0,
4590
+ 0,
4591
+ 0,
4592
+ 0,
4593
+ 0,
4594
+ 0,
4595
+ 0,
4596
+ 0,
4597
+ 0,
4598
+ 0,
4599
+ 0,
4600
+ 0,
4601
+ 0,
4602
+ // 16 - 31
4603
+ 0,
4604
+ 1,
4605
+ 0,
4606
+ 1,
4607
+ 1,
4608
+ 1,
4609
+ 1,
4610
+ 1,
4611
+ 0,
4612
+ 0,
4613
+ 1,
4614
+ 1,
4615
+ 0,
4616
+ 1,
4617
+ 1,
4618
+ 0,
4619
+ // 32 - 47
4620
+ 1,
4621
+ 1,
4622
+ 1,
4623
+ 1,
4624
+ 1,
4625
+ 1,
4626
+ 1,
4627
+ 1,
4628
+ 1,
4629
+ 1,
4630
+ 0,
4631
+ 0,
4632
+ 0,
4633
+ 0,
4634
+ 0,
4635
+ 0,
4636
+ // 48 - 63
4637
+ 0,
4638
+ 1,
4639
+ 1,
4640
+ 1,
4641
+ 1,
4642
+ 1,
4643
+ 1,
4644
+ 1,
4645
+ 1,
4646
+ 1,
4647
+ 1,
4648
+ 1,
4649
+ 1,
4650
+ 1,
4651
+ 1,
4652
+ 1,
4653
+ // 64 - 79
4654
+ 1,
4655
+ 1,
4656
+ 1,
4657
+ 1,
4658
+ 1,
4659
+ 1,
4660
+ 1,
4661
+ 1,
4662
+ 1,
4663
+ 1,
4664
+ 1,
4665
+ 0,
4666
+ 0,
4667
+ 0,
4668
+ 1,
4669
+ 1,
4670
+ // 80 - 95
4671
+ 1,
4672
+ 1,
4673
+ 1,
4674
+ 1,
4675
+ 1,
4676
+ 1,
4677
+ 1,
4678
+ 1,
4679
+ 1,
4680
+ 1,
4681
+ 1,
4682
+ 1,
4683
+ 1,
4684
+ 1,
4685
+ 1,
4686
+ 1,
4687
+ // 96 - 111
4688
+ 1,
4689
+ 1,
4690
+ 1,
4691
+ 1,
4692
+ 1,
4693
+ 1,
4694
+ 1,
4695
+ 1,
4696
+ 1,
4697
+ 1,
4698
+ 1,
4699
+ 0,
4700
+ 1,
4701
+ 0,
4702
+ 1,
4703
+ 0
4704
+ // 112 - 127
4705
+ ];
4706
+ function isValidStatusCode(code) {
4707
+ return code >= 1e3 && code <= 1014 && code !== 1004 && code !== 1005 && code !== 1006 || code >= 3e3 && code <= 4999;
4708
+ }
4709
+ function _isValidUTF8(buf) {
4710
+ const len = buf.length;
4711
+ let i = 0;
4712
+ while (i < len) {
4713
+ if ((buf[i] & 128) === 0) {
4714
+ i++;
4715
+ } else if ((buf[i] & 224) === 192) {
4716
+ if (i + 1 === len || (buf[i + 1] & 192) !== 128 || (buf[i] & 254) === 192) {
4717
+ return false;
4718
+ }
4719
+ i += 2;
4720
+ } else if ((buf[i] & 240) === 224) {
4721
+ if (i + 2 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || buf[i] === 224 && (buf[i + 1] & 224) === 128 || // Overlong
4722
+ buf[i] === 237 && (buf[i + 1] & 224) === 160) {
4723
+ return false;
4724
+ }
4725
+ i += 3;
4726
+ } else if ((buf[i] & 248) === 240) {
4727
+ if (i + 3 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || (buf[i + 3] & 192) !== 128 || buf[i] === 240 && (buf[i + 1] & 240) === 128 || // Overlong
4728
+ buf[i] === 244 && buf[i + 1] > 143 || buf[i] > 244) {
4729
+ return false;
4730
+ }
4731
+ i += 4;
4732
+ } else {
4733
+ return false;
4734
+ }
4735
+ }
4736
+ return true;
4737
+ }
4738
+ module2.exports = {
4739
+ isValidStatusCode,
4740
+ isValidUTF8: _isValidUTF8,
4741
+ tokenChars
4742
+ };
4743
+ if (isUtf8) {
4744
+ module2.exports.isValidUTF8 = function(buf) {
4745
+ return buf.length < 24 ? _isValidUTF8(buf) : isUtf8(buf);
4746
+ };
4747
+ } else if (!process.env.WS_NO_UTF_8_VALIDATE) {
4748
+ try {
4749
+ const isValidUTF8 = require("utf-8-validate");
4750
+ module2.exports.isValidUTF8 = function(buf) {
4751
+ return buf.length < 32 ? _isValidUTF8(buf) : isValidUTF8(buf);
4752
+ };
4753
+ } catch (e) {
4754
+ }
4755
+ }
4756
+ }
4757
+ });
4758
+
4759
+ // node_modules/ws/lib/receiver.js
4760
+ var require_receiver = __commonJS({
4761
+ "node_modules/ws/lib/receiver.js"(exports2, module2) {
4762
+ "use strict";
4763
+ var { Writable } = require("stream");
4764
+ var PerMessageDeflate = require_permessage_deflate();
4765
+ var {
4766
+ BINARY_TYPES,
4767
+ EMPTY_BUFFER,
4768
+ kStatusCode,
4769
+ kWebSocket
4770
+ } = require_constants();
4771
+ var { concat, toArrayBuffer, unmask } = require_buffer_util();
4772
+ var { isValidStatusCode, isValidUTF8 } = require_validation();
4773
+ var FastBuffer = Buffer[Symbol.species];
4774
+ var GET_INFO = 0;
4775
+ var GET_PAYLOAD_LENGTH_16 = 1;
4776
+ var GET_PAYLOAD_LENGTH_64 = 2;
4777
+ var GET_MASK = 3;
4778
+ var GET_DATA = 4;
4779
+ var INFLATING = 5;
4780
+ var DEFER_EVENT = 6;
4781
+ var Receiver2 = class extends Writable {
4782
+ /**
4783
+ * Creates a Receiver instance.
4784
+ *
4785
+ * @param {Object} [options] Options object
4786
+ * @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether
4787
+ * any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
4788
+ * multiple times in the same tick
4789
+ * @param {String} [options.binaryType=nodebuffer] The type for binary data
4790
+ * @param {Object} [options.extensions] An object containing the negotiated
4791
+ * extensions
4792
+ * @param {Boolean} [options.isServer=false] Specifies whether to operate in
4793
+ * client or server mode
4794
+ * @param {Number} [options.maxPayload=0] The maximum allowed message length
4795
+ * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
4796
+ * not to skip UTF-8 validation for text and close messages
4797
+ */
4798
+ constructor(options = {}) {
4799
+ super();
4800
+ this._allowSynchronousEvents = options.allowSynchronousEvents !== void 0 ? options.allowSynchronousEvents : true;
4801
+ this._binaryType = options.binaryType || BINARY_TYPES[0];
4802
+ this._extensions = options.extensions || {};
4803
+ this._isServer = !!options.isServer;
4804
+ this._maxPayload = options.maxPayload | 0;
4805
+ this._skipUTF8Validation = !!options.skipUTF8Validation;
4806
+ this[kWebSocket] = void 0;
4807
+ this._bufferedBytes = 0;
4808
+ this._buffers = [];
4809
+ this._compressed = false;
4810
+ this._payloadLength = 0;
4811
+ this._mask = void 0;
4812
+ this._fragmented = 0;
4813
+ this._masked = false;
4814
+ this._fin = false;
4815
+ this._opcode = 0;
4816
+ this._totalPayloadLength = 0;
4817
+ this._messageLength = 0;
4818
+ this._fragments = [];
4819
+ this._errored = false;
4820
+ this._loop = false;
4821
+ this._state = GET_INFO;
4822
+ }
4823
+ /**
4824
+ * Implements `Writable.prototype._write()`.
4825
+ *
4826
+ * @param {Buffer} chunk The chunk of data to write
4827
+ * @param {String} encoding The character encoding of `chunk`
4828
+ * @param {Function} cb Callback
4829
+ * @private
4830
+ */
4831
+ _write(chunk, encoding, cb) {
4832
+ if (this._opcode === 8 && this._state == GET_INFO) return cb();
4833
+ this._bufferedBytes += chunk.length;
4834
+ this._buffers.push(chunk);
4835
+ this.startLoop(cb);
4836
+ }
4837
+ /**
4838
+ * Consumes `n` bytes from the buffered data.
4839
+ *
4840
+ * @param {Number} n The number of bytes to consume
4841
+ * @return {Buffer} The consumed bytes
4842
+ * @private
4843
+ */
4844
+ consume(n) {
4845
+ this._bufferedBytes -= n;
4846
+ if (n === this._buffers[0].length) return this._buffers.shift();
4847
+ if (n < this._buffers[0].length) {
4848
+ const buf = this._buffers[0];
4849
+ this._buffers[0] = new FastBuffer(
4850
+ buf.buffer,
4851
+ buf.byteOffset + n,
4852
+ buf.length - n
4853
+ );
4854
+ return new FastBuffer(buf.buffer, buf.byteOffset, n);
4855
+ }
4856
+ const dst = Buffer.allocUnsafe(n);
4857
+ do {
4858
+ const buf = this._buffers[0];
4859
+ const offset = dst.length - n;
4860
+ if (n >= buf.length) {
4861
+ dst.set(this._buffers.shift(), offset);
4862
+ } else {
4863
+ dst.set(new Uint8Array(buf.buffer, buf.byteOffset, n), offset);
4864
+ this._buffers[0] = new FastBuffer(
4865
+ buf.buffer,
4866
+ buf.byteOffset + n,
4867
+ buf.length - n
4868
+ );
4869
+ }
4870
+ n -= buf.length;
4871
+ } while (n > 0);
4872
+ return dst;
4873
+ }
4874
+ /**
4875
+ * Starts the parsing loop.
4876
+ *
4877
+ * @param {Function} cb Callback
4878
+ * @private
4879
+ */
4880
+ startLoop(cb) {
4881
+ this._loop = true;
4882
+ do {
4883
+ switch (this._state) {
4884
+ case GET_INFO:
4885
+ this.getInfo(cb);
4886
+ break;
4887
+ case GET_PAYLOAD_LENGTH_16:
4888
+ this.getPayloadLength16(cb);
4889
+ break;
4890
+ case GET_PAYLOAD_LENGTH_64:
4891
+ this.getPayloadLength64(cb);
4892
+ break;
4893
+ case GET_MASK:
4894
+ this.getMask();
4895
+ break;
4896
+ case GET_DATA:
4897
+ this.getData(cb);
4898
+ break;
4899
+ case INFLATING:
4900
+ case DEFER_EVENT:
4901
+ this._loop = false;
4902
+ return;
4903
+ }
4904
+ } while (this._loop);
4905
+ if (!this._errored) cb();
4906
+ }
4907
+ /**
4908
+ * Reads the first two bytes of a frame.
4909
+ *
4910
+ * @param {Function} cb Callback
4911
+ * @private
4912
+ */
4913
+ getInfo(cb) {
4914
+ if (this._bufferedBytes < 2) {
4915
+ this._loop = false;
4916
+ return;
4917
+ }
4918
+ const buf = this.consume(2);
4919
+ if ((buf[0] & 48) !== 0) {
4920
+ const error = this.createError(
4921
+ RangeError,
4922
+ "RSV2 and RSV3 must be clear",
4923
+ true,
4924
+ 1002,
4925
+ "WS_ERR_UNEXPECTED_RSV_2_3"
4926
+ );
4927
+ cb(error);
4928
+ return;
4929
+ }
4930
+ const compressed = (buf[0] & 64) === 64;
4931
+ if (compressed && !this._extensions[PerMessageDeflate.extensionName]) {
4932
+ const error = this.createError(
4933
+ RangeError,
4934
+ "RSV1 must be clear",
4935
+ true,
4936
+ 1002,
4937
+ "WS_ERR_UNEXPECTED_RSV_1"
4938
+ );
4939
+ cb(error);
4940
+ return;
4941
+ }
4942
+ this._fin = (buf[0] & 128) === 128;
4943
+ this._opcode = buf[0] & 15;
4944
+ this._payloadLength = buf[1] & 127;
4945
+ if (this._opcode === 0) {
4946
+ if (compressed) {
4947
+ const error = this.createError(
4948
+ RangeError,
4949
+ "RSV1 must be clear",
4950
+ true,
4951
+ 1002,
4952
+ "WS_ERR_UNEXPECTED_RSV_1"
4953
+ );
4954
+ cb(error);
4955
+ return;
4956
+ }
4957
+ if (!this._fragmented) {
4958
+ const error = this.createError(
4959
+ RangeError,
4960
+ "invalid opcode 0",
4961
+ true,
4962
+ 1002,
4963
+ "WS_ERR_INVALID_OPCODE"
4964
+ );
4965
+ cb(error);
4966
+ return;
4967
+ }
4968
+ this._opcode = this._fragmented;
4969
+ } else if (this._opcode === 1 || this._opcode === 2) {
4970
+ if (this._fragmented) {
4971
+ const error = this.createError(
4972
+ RangeError,
4973
+ `invalid opcode ${this._opcode}`,
4974
+ true,
4975
+ 1002,
4976
+ "WS_ERR_INVALID_OPCODE"
4977
+ );
4978
+ cb(error);
4979
+ return;
4980
+ }
4981
+ this._compressed = compressed;
4982
+ } else if (this._opcode > 7 && this._opcode < 11) {
4983
+ if (!this._fin) {
4984
+ const error = this.createError(
4985
+ RangeError,
4986
+ "FIN must be set",
4987
+ true,
4988
+ 1002,
4989
+ "WS_ERR_EXPECTED_FIN"
4990
+ );
4991
+ cb(error);
4992
+ return;
4993
+ }
4994
+ if (compressed) {
4995
+ const error = this.createError(
4996
+ RangeError,
4997
+ "RSV1 must be clear",
4998
+ true,
4999
+ 1002,
5000
+ "WS_ERR_UNEXPECTED_RSV_1"
5001
+ );
5002
+ cb(error);
5003
+ return;
5004
+ }
5005
+ if (this._payloadLength > 125 || this._opcode === 8 && this._payloadLength === 1) {
5006
+ const error = this.createError(
5007
+ RangeError,
5008
+ `invalid payload length ${this._payloadLength}`,
5009
+ true,
5010
+ 1002,
5011
+ "WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"
5012
+ );
5013
+ cb(error);
5014
+ return;
5015
+ }
5016
+ } else {
5017
+ const error = this.createError(
5018
+ RangeError,
5019
+ `invalid opcode ${this._opcode}`,
5020
+ true,
5021
+ 1002,
5022
+ "WS_ERR_INVALID_OPCODE"
5023
+ );
5024
+ cb(error);
5025
+ return;
5026
+ }
5027
+ if (!this._fin && !this._fragmented) this._fragmented = this._opcode;
5028
+ this._masked = (buf[1] & 128) === 128;
5029
+ if (this._isServer) {
5030
+ if (!this._masked) {
5031
+ const error = this.createError(
5032
+ RangeError,
5033
+ "MASK must be set",
5034
+ true,
5035
+ 1002,
5036
+ "WS_ERR_EXPECTED_MASK"
5037
+ );
5038
+ cb(error);
5039
+ return;
5040
+ }
5041
+ } else if (this._masked) {
5042
+ const error = this.createError(
5043
+ RangeError,
5044
+ "MASK must be clear",
5045
+ true,
5046
+ 1002,
5047
+ "WS_ERR_UNEXPECTED_MASK"
5048
+ );
5049
+ cb(error);
5050
+ return;
5051
+ }
5052
+ if (this._payloadLength === 126) this._state = GET_PAYLOAD_LENGTH_16;
5053
+ else if (this._payloadLength === 127) this._state = GET_PAYLOAD_LENGTH_64;
5054
+ else this.haveLength(cb);
5055
+ }
5056
+ /**
5057
+ * Gets extended payload length (7+16).
5058
+ *
5059
+ * @param {Function} cb Callback
5060
+ * @private
5061
+ */
5062
+ getPayloadLength16(cb) {
5063
+ if (this._bufferedBytes < 2) {
5064
+ this._loop = false;
5065
+ return;
5066
+ }
5067
+ this._payloadLength = this.consume(2).readUInt16BE(0);
5068
+ this.haveLength(cb);
5069
+ }
5070
+ /**
5071
+ * Gets extended payload length (7+64).
5072
+ *
5073
+ * @param {Function} cb Callback
5074
+ * @private
5075
+ */
5076
+ getPayloadLength64(cb) {
5077
+ if (this._bufferedBytes < 8) {
5078
+ this._loop = false;
5079
+ return;
5080
+ }
5081
+ const buf = this.consume(8);
5082
+ const num = buf.readUInt32BE(0);
5083
+ if (num > Math.pow(2, 53 - 32) - 1) {
5084
+ const error = this.createError(
5085
+ RangeError,
5086
+ "Unsupported WebSocket frame: payload length > 2^53 - 1",
5087
+ false,
5088
+ 1009,
5089
+ "WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH"
5090
+ );
5091
+ cb(error);
5092
+ return;
5093
+ }
5094
+ this._payloadLength = num * Math.pow(2, 32) + buf.readUInt32BE(4);
5095
+ this.haveLength(cb);
5096
+ }
5097
+ /**
5098
+ * Payload length has been read.
5099
+ *
5100
+ * @param {Function} cb Callback
5101
+ * @private
5102
+ */
5103
+ haveLength(cb) {
5104
+ if (this._payloadLength && this._opcode < 8) {
5105
+ this._totalPayloadLength += this._payloadLength;
5106
+ if (this._totalPayloadLength > this._maxPayload && this._maxPayload > 0) {
5107
+ const error = this.createError(
5108
+ RangeError,
5109
+ "Max payload size exceeded",
5110
+ false,
5111
+ 1009,
5112
+ "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"
5113
+ );
5114
+ cb(error);
5115
+ return;
5116
+ }
5117
+ }
5118
+ if (this._masked) this._state = GET_MASK;
5119
+ else this._state = GET_DATA;
5120
+ }
5121
+ /**
5122
+ * Reads mask bytes.
5123
+ *
5124
+ * @private
5125
+ */
5126
+ getMask() {
5127
+ if (this._bufferedBytes < 4) {
5128
+ this._loop = false;
5129
+ return;
5130
+ }
5131
+ this._mask = this.consume(4);
5132
+ this._state = GET_DATA;
5133
+ }
5134
+ /**
5135
+ * Reads data bytes.
5136
+ *
5137
+ * @param {Function} cb Callback
5138
+ * @private
5139
+ */
5140
+ getData(cb) {
5141
+ let data = EMPTY_BUFFER;
5142
+ if (this._payloadLength) {
5143
+ if (this._bufferedBytes < this._payloadLength) {
5144
+ this._loop = false;
5145
+ return;
5146
+ }
5147
+ data = this.consume(this._payloadLength);
5148
+ if (this._masked && (this._mask[0] | this._mask[1] | this._mask[2] | this._mask[3]) !== 0) {
5149
+ unmask(data, this._mask);
5150
+ }
5151
+ }
5152
+ if (this._opcode > 7) {
5153
+ this.controlMessage(data, cb);
5154
+ return;
5155
+ }
5156
+ if (this._compressed) {
5157
+ this._state = INFLATING;
5158
+ this.decompress(data, cb);
5159
+ return;
5160
+ }
5161
+ if (data.length) {
5162
+ this._messageLength = this._totalPayloadLength;
5163
+ this._fragments.push(data);
5164
+ }
5165
+ this.dataMessage(cb);
5166
+ }
5167
+ /**
5168
+ * Decompresses data.
5169
+ *
5170
+ * @param {Buffer} data Compressed data
5171
+ * @param {Function} cb Callback
5172
+ * @private
5173
+ */
5174
+ decompress(data, cb) {
5175
+ const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
5176
+ perMessageDeflate.decompress(data, this._fin, (err2, buf) => {
5177
+ if (err2) return cb(err2);
5178
+ if (buf.length) {
5179
+ this._messageLength += buf.length;
5180
+ if (this._messageLength > this._maxPayload && this._maxPayload > 0) {
5181
+ const error = this.createError(
5182
+ RangeError,
5183
+ "Max payload size exceeded",
5184
+ false,
5185
+ 1009,
5186
+ "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"
5187
+ );
5188
+ cb(error);
5189
+ return;
5190
+ }
5191
+ this._fragments.push(buf);
5192
+ }
5193
+ this.dataMessage(cb);
5194
+ if (this._state === GET_INFO) this.startLoop(cb);
5195
+ });
5196
+ }
5197
+ /**
5198
+ * Handles a data message.
5199
+ *
5200
+ * @param {Function} cb Callback
5201
+ * @private
5202
+ */
5203
+ dataMessage(cb) {
5204
+ if (!this._fin) {
5205
+ this._state = GET_INFO;
5206
+ return;
5207
+ }
5208
+ const messageLength = this._messageLength;
5209
+ const fragments = this._fragments;
5210
+ this._totalPayloadLength = 0;
5211
+ this._messageLength = 0;
5212
+ this._fragmented = 0;
5213
+ this._fragments = [];
5214
+ if (this._opcode === 2) {
5215
+ let data;
5216
+ if (this._binaryType === "nodebuffer") {
5217
+ data = concat(fragments, messageLength);
5218
+ } else if (this._binaryType === "arraybuffer") {
5219
+ data = toArrayBuffer(concat(fragments, messageLength));
5220
+ } else {
5221
+ data = fragments;
5222
+ }
5223
+ if (this._allowSynchronousEvents) {
5224
+ this.emit("message", data, true);
5225
+ this._state = GET_INFO;
5226
+ } else {
5227
+ this._state = DEFER_EVENT;
5228
+ setImmediate(() => {
5229
+ this.emit("message", data, true);
5230
+ this._state = GET_INFO;
5231
+ this.startLoop(cb);
5232
+ });
5233
+ }
5234
+ } else {
5235
+ const buf = concat(fragments, messageLength);
5236
+ if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
5237
+ const error = this.createError(
5238
+ Error,
5239
+ "invalid UTF-8 sequence",
5240
+ true,
5241
+ 1007,
5242
+ "WS_ERR_INVALID_UTF8"
5243
+ );
5244
+ cb(error);
5245
+ return;
5246
+ }
5247
+ if (this._state === INFLATING || this._allowSynchronousEvents) {
5248
+ this.emit("message", buf, false);
5249
+ this._state = GET_INFO;
5250
+ } else {
5251
+ this._state = DEFER_EVENT;
5252
+ setImmediate(() => {
5253
+ this.emit("message", buf, false);
5254
+ this._state = GET_INFO;
5255
+ this.startLoop(cb);
5256
+ });
5257
+ }
5258
+ }
5259
+ }
5260
+ /**
5261
+ * Handles a control message.
5262
+ *
5263
+ * @param {Buffer} data Data to handle
5264
+ * @return {(Error|RangeError|undefined)} A possible error
5265
+ * @private
5266
+ */
5267
+ controlMessage(data, cb) {
5268
+ if (this._opcode === 8) {
5269
+ if (data.length === 0) {
5270
+ this._loop = false;
5271
+ this.emit("conclude", 1005, EMPTY_BUFFER);
5272
+ this.end();
5273
+ } else {
5274
+ const code = data.readUInt16BE(0);
5275
+ if (!isValidStatusCode(code)) {
5276
+ const error = this.createError(
5277
+ RangeError,
5278
+ `invalid status code ${code}`,
5279
+ true,
5280
+ 1002,
5281
+ "WS_ERR_INVALID_CLOSE_CODE"
5282
+ );
5283
+ cb(error);
5284
+ return;
5285
+ }
5286
+ const buf = new FastBuffer(
5287
+ data.buffer,
5288
+ data.byteOffset + 2,
5289
+ data.length - 2
5290
+ );
5291
+ if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
5292
+ const error = this.createError(
5293
+ Error,
5294
+ "invalid UTF-8 sequence",
5295
+ true,
5296
+ 1007,
5297
+ "WS_ERR_INVALID_UTF8"
5298
+ );
5299
+ cb(error);
5300
+ return;
5301
+ }
5302
+ this._loop = false;
5303
+ this.emit("conclude", code, buf);
5304
+ this.end();
5305
+ }
5306
+ this._state = GET_INFO;
5307
+ return;
5308
+ }
5309
+ if (this._allowSynchronousEvents) {
5310
+ this.emit(this._opcode === 9 ? "ping" : "pong", data);
5311
+ this._state = GET_INFO;
5312
+ } else {
5313
+ this._state = DEFER_EVENT;
5314
+ setImmediate(() => {
5315
+ this.emit(this._opcode === 9 ? "ping" : "pong", data);
5316
+ this._state = GET_INFO;
5317
+ this.startLoop(cb);
5318
+ });
5319
+ }
5320
+ }
5321
+ /**
5322
+ * Builds an error object.
5323
+ *
5324
+ * @param {function(new:Error|RangeError)} ErrorCtor The error constructor
5325
+ * @param {String} message The error message
5326
+ * @param {Boolean} prefix Specifies whether or not to add a default prefix to
5327
+ * `message`
5328
+ * @param {Number} statusCode The status code
5329
+ * @param {String} errorCode The exposed error code
5330
+ * @return {(Error|RangeError)} The error
5331
+ * @private
5332
+ */
5333
+ createError(ErrorCtor, message, prefix, statusCode, errorCode) {
5334
+ this._loop = false;
5335
+ this._errored = true;
5336
+ const err2 = new ErrorCtor(
5337
+ prefix ? `Invalid WebSocket frame: ${message}` : message
5338
+ );
5339
+ Error.captureStackTrace(err2, this.createError);
5340
+ err2.code = errorCode;
5341
+ err2[kStatusCode] = statusCode;
5342
+ return err2;
5343
+ }
5344
+ };
5345
+ module2.exports = Receiver2;
5346
+ }
5347
+ });
5348
+
5349
+ // node_modules/ws/lib/sender.js
5350
+ var require_sender = __commonJS({
5351
+ "node_modules/ws/lib/sender.js"(exports2, module2) {
5352
+ "use strict";
5353
+ var { Duplex } = require("stream");
5354
+ var { randomFillSync } = require("crypto");
5355
+ var PerMessageDeflate = require_permessage_deflate();
5356
+ var { EMPTY_BUFFER } = require_constants();
5357
+ var { isValidStatusCode } = require_validation();
5358
+ var { mask: applyMask, toBuffer } = require_buffer_util();
5359
+ var kByteLength = Symbol("kByteLength");
5360
+ var maskBuffer = Buffer.alloc(4);
5361
+ var RANDOM_POOL_SIZE = 8 * 1024;
5362
+ var randomPool;
5363
+ var randomPoolPointer = RANDOM_POOL_SIZE;
5364
+ var Sender2 = class _Sender {
5365
+ /**
5366
+ * Creates a Sender instance.
5367
+ *
5368
+ * @param {Duplex} socket The connection socket
5369
+ * @param {Object} [extensions] An object containing the negotiated extensions
5370
+ * @param {Function} [generateMask] The function used to generate the masking
5371
+ * key
5372
+ */
5373
+ constructor(socket, extensions, generateMask) {
5374
+ this._extensions = extensions || {};
5375
+ if (generateMask) {
5376
+ this._generateMask = generateMask;
5377
+ this._maskBuffer = Buffer.alloc(4);
5378
+ }
5379
+ this._socket = socket;
5380
+ this._firstFragment = true;
5381
+ this._compress = false;
5382
+ this._bufferedBytes = 0;
5383
+ this._deflating = false;
5384
+ this._queue = [];
5385
+ }
5386
+ /**
5387
+ * Frames a piece of data according to the HyBi WebSocket protocol.
5388
+ *
5389
+ * @param {(Buffer|String)} data The data to frame
5390
+ * @param {Object} options Options object
5391
+ * @param {Boolean} [options.fin=false] Specifies whether or not to set the
5392
+ * FIN bit
5393
+ * @param {Function} [options.generateMask] The function used to generate the
5394
+ * masking key
5395
+ * @param {Boolean} [options.mask=false] Specifies whether or not to mask
5396
+ * `data`
5397
+ * @param {Buffer} [options.maskBuffer] The buffer used to store the masking
5398
+ * key
5399
+ * @param {Number} options.opcode The opcode
5400
+ * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
5401
+ * modified
5402
+ * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
5403
+ * RSV1 bit
5404
+ * @return {(Buffer|String)[]} The framed data
5405
+ * @public
5406
+ */
5407
+ static frame(data, options) {
5408
+ let mask;
5409
+ let merge = false;
5410
+ let offset = 2;
5411
+ let skipMasking = false;
5412
+ if (options.mask) {
5413
+ mask = options.maskBuffer || maskBuffer;
5414
+ if (options.generateMask) {
5415
+ options.generateMask(mask);
5416
+ } else {
5417
+ if (randomPoolPointer === RANDOM_POOL_SIZE) {
5418
+ if (randomPool === void 0) {
5419
+ randomPool = Buffer.alloc(RANDOM_POOL_SIZE);
5420
+ }
5421
+ randomFillSync(randomPool, 0, RANDOM_POOL_SIZE);
5422
+ randomPoolPointer = 0;
5423
+ }
5424
+ mask[0] = randomPool[randomPoolPointer++];
5425
+ mask[1] = randomPool[randomPoolPointer++];
5426
+ mask[2] = randomPool[randomPoolPointer++];
5427
+ mask[3] = randomPool[randomPoolPointer++];
5428
+ }
5429
+ skipMasking = (mask[0] | mask[1] | mask[2] | mask[3]) === 0;
5430
+ offset = 6;
5431
+ }
5432
+ let dataLength;
5433
+ if (typeof data === "string") {
5434
+ if ((!options.mask || skipMasking) && options[kByteLength] !== void 0) {
5435
+ dataLength = options[kByteLength];
5436
+ } else {
5437
+ data = Buffer.from(data);
5438
+ dataLength = data.length;
5439
+ }
5440
+ } else {
5441
+ dataLength = data.length;
5442
+ merge = options.mask && options.readOnly && !skipMasking;
5443
+ }
5444
+ let payloadLength = dataLength;
5445
+ if (dataLength >= 65536) {
5446
+ offset += 8;
5447
+ payloadLength = 127;
5448
+ } else if (dataLength > 125) {
5449
+ offset += 2;
5450
+ payloadLength = 126;
5451
+ }
5452
+ const target = Buffer.allocUnsafe(merge ? dataLength + offset : offset);
5453
+ target[0] = options.fin ? options.opcode | 128 : options.opcode;
5454
+ if (options.rsv1) target[0] |= 64;
5455
+ target[1] = payloadLength;
5456
+ if (payloadLength === 126) {
5457
+ target.writeUInt16BE(dataLength, 2);
5458
+ } else if (payloadLength === 127) {
5459
+ target[2] = target[3] = 0;
5460
+ target.writeUIntBE(dataLength, 4, 6);
5461
+ }
5462
+ if (!options.mask) return [target, data];
5463
+ target[1] |= 128;
5464
+ target[offset - 4] = mask[0];
5465
+ target[offset - 3] = mask[1];
5466
+ target[offset - 2] = mask[2];
5467
+ target[offset - 1] = mask[3];
5468
+ if (skipMasking) return [target, data];
5469
+ if (merge) {
5470
+ applyMask(data, mask, target, offset, dataLength);
5471
+ return [target];
5472
+ }
5473
+ applyMask(data, mask, data, 0, dataLength);
5474
+ return [target, data];
5475
+ }
5476
+ /**
5477
+ * Sends a close message to the other peer.
5478
+ *
5479
+ * @param {Number} [code] The status code component of the body
5480
+ * @param {(String|Buffer)} [data] The message component of the body
5481
+ * @param {Boolean} [mask=false] Specifies whether or not to mask the message
5482
+ * @param {Function} [cb] Callback
5483
+ * @public
5484
+ */
5485
+ close(code, data, mask, cb) {
5486
+ let buf;
5487
+ if (code === void 0) {
5488
+ buf = EMPTY_BUFFER;
5489
+ } else if (typeof code !== "number" || !isValidStatusCode(code)) {
5490
+ throw new TypeError("First argument must be a valid error code number");
5491
+ } else if (data === void 0 || !data.length) {
5492
+ buf = Buffer.allocUnsafe(2);
5493
+ buf.writeUInt16BE(code, 0);
5494
+ } else {
5495
+ const length = Buffer.byteLength(data);
5496
+ if (length > 123) {
5497
+ throw new RangeError("The message must not be greater than 123 bytes");
5498
+ }
5499
+ buf = Buffer.allocUnsafe(2 + length);
5500
+ buf.writeUInt16BE(code, 0);
5501
+ if (typeof data === "string") {
5502
+ buf.write(data, 2);
5503
+ } else {
5504
+ buf.set(data, 2);
5505
+ }
5506
+ }
5507
+ const options = {
5508
+ [kByteLength]: buf.length,
5509
+ fin: true,
5510
+ generateMask: this._generateMask,
5511
+ mask,
5512
+ maskBuffer: this._maskBuffer,
5513
+ opcode: 8,
5514
+ readOnly: false,
5515
+ rsv1: false
5516
+ };
5517
+ if (this._deflating) {
5518
+ this.enqueue([this.dispatch, buf, false, options, cb]);
5519
+ } else {
5520
+ this.sendFrame(_Sender.frame(buf, options), cb);
5521
+ }
5522
+ }
5523
+ /**
5524
+ * Sends a ping message to the other peer.
5525
+ *
5526
+ * @param {*} data The message to send
5527
+ * @param {Boolean} [mask=false] Specifies whether or not to mask `data`
5528
+ * @param {Function} [cb] Callback
5529
+ * @public
5530
+ */
5531
+ ping(data, mask, cb) {
5532
+ let byteLength;
5533
+ let readOnly;
5534
+ if (typeof data === "string") {
5535
+ byteLength = Buffer.byteLength(data);
5536
+ readOnly = false;
5537
+ } else {
5538
+ data = toBuffer(data);
5539
+ byteLength = data.length;
5540
+ readOnly = toBuffer.readOnly;
5541
+ }
5542
+ if (byteLength > 125) {
5543
+ throw new RangeError("The data size must not be greater than 125 bytes");
5544
+ }
5545
+ const options = {
5546
+ [kByteLength]: byteLength,
5547
+ fin: true,
5548
+ generateMask: this._generateMask,
5549
+ mask,
5550
+ maskBuffer: this._maskBuffer,
5551
+ opcode: 9,
5552
+ readOnly,
5553
+ rsv1: false
5554
+ };
5555
+ if (this._deflating) {
5556
+ this.enqueue([this.dispatch, data, false, options, cb]);
5557
+ } else {
5558
+ this.sendFrame(_Sender.frame(data, options), cb);
5559
+ }
5560
+ }
5561
+ /**
5562
+ * Sends a pong message to the other peer.
5563
+ *
5564
+ * @param {*} data The message to send
5565
+ * @param {Boolean} [mask=false] Specifies whether or not to mask `data`
5566
+ * @param {Function} [cb] Callback
5567
+ * @public
5568
+ */
5569
+ pong(data, mask, cb) {
5570
+ let byteLength;
5571
+ let readOnly;
5572
+ if (typeof data === "string") {
5573
+ byteLength = Buffer.byteLength(data);
5574
+ readOnly = false;
5575
+ } else {
5576
+ data = toBuffer(data);
5577
+ byteLength = data.length;
5578
+ readOnly = toBuffer.readOnly;
5579
+ }
5580
+ if (byteLength > 125) {
5581
+ throw new RangeError("The data size must not be greater than 125 bytes");
5582
+ }
5583
+ const options = {
5584
+ [kByteLength]: byteLength,
5585
+ fin: true,
5586
+ generateMask: this._generateMask,
5587
+ mask,
5588
+ maskBuffer: this._maskBuffer,
5589
+ opcode: 10,
5590
+ readOnly,
5591
+ rsv1: false
5592
+ };
5593
+ if (this._deflating) {
5594
+ this.enqueue([this.dispatch, data, false, options, cb]);
5595
+ } else {
5596
+ this.sendFrame(_Sender.frame(data, options), cb);
5597
+ }
5598
+ }
5599
+ /**
5600
+ * Sends a data message to the other peer.
5601
+ *
5602
+ * @param {*} data The message to send
5603
+ * @param {Object} options Options object
5604
+ * @param {Boolean} [options.binary=false] Specifies whether `data` is binary
5605
+ * or text
5606
+ * @param {Boolean} [options.compress=false] Specifies whether or not to
5607
+ * compress `data`
5608
+ * @param {Boolean} [options.fin=false] Specifies whether the fragment is the
5609
+ * last one
5610
+ * @param {Boolean} [options.mask=false] Specifies whether or not to mask
5611
+ * `data`
5612
+ * @param {Function} [cb] Callback
5613
+ * @public
5614
+ */
5615
+ send(data, options, cb) {
5616
+ const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
5617
+ let opcode = options.binary ? 2 : 1;
5618
+ let rsv1 = options.compress;
5619
+ let byteLength;
5620
+ let readOnly;
5621
+ if (typeof data === "string") {
5622
+ byteLength = Buffer.byteLength(data);
5623
+ readOnly = false;
5624
+ } else {
5625
+ data = toBuffer(data);
5626
+ byteLength = data.length;
5627
+ readOnly = toBuffer.readOnly;
5628
+ }
5629
+ if (this._firstFragment) {
5630
+ this._firstFragment = false;
5631
+ if (rsv1 && perMessageDeflate && perMessageDeflate.params[perMessageDeflate._isServer ? "server_no_context_takeover" : "client_no_context_takeover"]) {
5632
+ rsv1 = byteLength >= perMessageDeflate._threshold;
5633
+ }
5634
+ this._compress = rsv1;
5635
+ } else {
5636
+ rsv1 = false;
5637
+ opcode = 0;
5638
+ }
5639
+ if (options.fin) this._firstFragment = true;
5640
+ if (perMessageDeflate) {
5641
+ const opts = {
5642
+ [kByteLength]: byteLength,
5643
+ fin: options.fin,
5644
+ generateMask: this._generateMask,
5645
+ mask: options.mask,
5646
+ maskBuffer: this._maskBuffer,
5647
+ opcode,
5648
+ readOnly,
5649
+ rsv1
5650
+ };
5651
+ if (this._deflating) {
5652
+ this.enqueue([this.dispatch, data, this._compress, opts, cb]);
5653
+ } else {
5654
+ this.dispatch(data, this._compress, opts, cb);
5655
+ }
5656
+ } else {
5657
+ this.sendFrame(
5658
+ _Sender.frame(data, {
5659
+ [kByteLength]: byteLength,
5660
+ fin: options.fin,
5661
+ generateMask: this._generateMask,
5662
+ mask: options.mask,
5663
+ maskBuffer: this._maskBuffer,
5664
+ opcode,
5665
+ readOnly,
5666
+ rsv1: false
5667
+ }),
5668
+ cb
5669
+ );
5670
+ }
5671
+ }
5672
+ /**
5673
+ * Dispatches a message.
5674
+ *
5675
+ * @param {(Buffer|String)} data The message to send
5676
+ * @param {Boolean} [compress=false] Specifies whether or not to compress
5677
+ * `data`
5678
+ * @param {Object} options Options object
5679
+ * @param {Boolean} [options.fin=false] Specifies whether or not to set the
5680
+ * FIN bit
5681
+ * @param {Function} [options.generateMask] The function used to generate the
5682
+ * masking key
5683
+ * @param {Boolean} [options.mask=false] Specifies whether or not to mask
5684
+ * `data`
5685
+ * @param {Buffer} [options.maskBuffer] The buffer used to store the masking
5686
+ * key
5687
+ * @param {Number} options.opcode The opcode
5688
+ * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
5689
+ * modified
5690
+ * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
5691
+ * RSV1 bit
5692
+ * @param {Function} [cb] Callback
5693
+ * @private
5694
+ */
5695
+ dispatch(data, compress, options, cb) {
5696
+ if (!compress) {
5697
+ this.sendFrame(_Sender.frame(data, options), cb);
5698
+ return;
5699
+ }
5700
+ const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
5701
+ this._bufferedBytes += options[kByteLength];
5702
+ this._deflating = true;
5703
+ perMessageDeflate.compress(data, options.fin, (_, buf) => {
5704
+ if (this._socket.destroyed) {
5705
+ const err2 = new Error(
5706
+ "The socket was closed while data was being compressed"
5707
+ );
5708
+ if (typeof cb === "function") cb(err2);
5709
+ for (let i = 0; i < this._queue.length; i++) {
5710
+ const params = this._queue[i];
5711
+ const callback = params[params.length - 1];
5712
+ if (typeof callback === "function") callback(err2);
5713
+ }
5714
+ return;
5715
+ }
5716
+ this._bufferedBytes -= options[kByteLength];
5717
+ this._deflating = false;
5718
+ options.readOnly = false;
5719
+ this.sendFrame(_Sender.frame(buf, options), cb);
5720
+ this.dequeue();
5721
+ });
5722
+ }
5723
+ /**
5724
+ * Executes queued send operations.
5725
+ *
5726
+ * @private
5727
+ */
5728
+ dequeue() {
5729
+ while (!this._deflating && this._queue.length) {
5730
+ const params = this._queue.shift();
5731
+ this._bufferedBytes -= params[3][kByteLength];
5732
+ Reflect.apply(params[0], this, params.slice(1));
5733
+ }
5734
+ }
5735
+ /**
5736
+ * Enqueues a send operation.
5737
+ *
5738
+ * @param {Array} params Send operation parameters.
5739
+ * @private
5740
+ */
5741
+ enqueue(params) {
5742
+ this._bufferedBytes += params[3][kByteLength];
5743
+ this._queue.push(params);
5744
+ }
5745
+ /**
5746
+ * Sends a frame.
5747
+ *
5748
+ * @param {Buffer[]} list The frame to send
5749
+ * @param {Function} [cb] Callback
5750
+ * @private
5751
+ */
5752
+ sendFrame(list, cb) {
5753
+ if (list.length === 2) {
5754
+ this._socket.cork();
5755
+ this._socket.write(list[0]);
5756
+ this._socket.write(list[1], cb);
5757
+ this._socket.uncork();
5758
+ } else {
5759
+ this._socket.write(list[0], cb);
5760
+ }
5761
+ }
5762
+ };
5763
+ module2.exports = Sender2;
5764
+ }
5765
+ });
5766
+
5767
+ // node_modules/ws/lib/event-target.js
5768
+ var require_event_target = __commonJS({
5769
+ "node_modules/ws/lib/event-target.js"(exports2, module2) {
5770
+ "use strict";
5771
+ var { kForOnEventAttribute, kListener } = require_constants();
5772
+ var kCode = Symbol("kCode");
5773
+ var kData = Symbol("kData");
5774
+ var kError = Symbol("kError");
5775
+ var kMessage = Symbol("kMessage");
5776
+ var kReason = Symbol("kReason");
5777
+ var kTarget = Symbol("kTarget");
5778
+ var kType = Symbol("kType");
5779
+ var kWasClean = Symbol("kWasClean");
5780
+ var Event = class {
5781
+ /**
5782
+ * Create a new `Event`.
5783
+ *
5784
+ * @param {String} type The name of the event
5785
+ * @throws {TypeError} If the `type` argument is not specified
5786
+ */
5787
+ constructor(type) {
5788
+ this[kTarget] = null;
5789
+ this[kType] = type;
5790
+ }
5791
+ /**
5792
+ * @type {*}
5793
+ */
5794
+ get target() {
5795
+ return this[kTarget];
5796
+ }
5797
+ /**
5798
+ * @type {String}
5799
+ */
5800
+ get type() {
5801
+ return this[kType];
5802
+ }
5803
+ };
5804
+ Object.defineProperty(Event.prototype, "target", { enumerable: true });
5805
+ Object.defineProperty(Event.prototype, "type", { enumerable: true });
5806
+ var CloseEvent = class extends Event {
5807
+ /**
5808
+ * Create a new `CloseEvent`.
5809
+ *
5810
+ * @param {String} type The name of the event
5811
+ * @param {Object} [options] A dictionary object that allows for setting
5812
+ * attributes via object members of the same name
5813
+ * @param {Number} [options.code=0] The status code explaining why the
5814
+ * connection was closed
5815
+ * @param {String} [options.reason=''] A human-readable string explaining why
5816
+ * the connection was closed
5817
+ * @param {Boolean} [options.wasClean=false] Indicates whether or not the
5818
+ * connection was cleanly closed
5819
+ */
5820
+ constructor(type, options = {}) {
5821
+ super(type);
5822
+ this[kCode] = options.code === void 0 ? 0 : options.code;
5823
+ this[kReason] = options.reason === void 0 ? "" : options.reason;
5824
+ this[kWasClean] = options.wasClean === void 0 ? false : options.wasClean;
5825
+ }
5826
+ /**
5827
+ * @type {Number}
5828
+ */
5829
+ get code() {
5830
+ return this[kCode];
5831
+ }
5832
+ /**
5833
+ * @type {String}
5834
+ */
5835
+ get reason() {
5836
+ return this[kReason];
5837
+ }
5838
+ /**
5839
+ * @type {Boolean}
5840
+ */
5841
+ get wasClean() {
5842
+ return this[kWasClean];
5843
+ }
5844
+ };
5845
+ Object.defineProperty(CloseEvent.prototype, "code", { enumerable: true });
5846
+ Object.defineProperty(CloseEvent.prototype, "reason", { enumerable: true });
5847
+ Object.defineProperty(CloseEvent.prototype, "wasClean", { enumerable: true });
5848
+ var ErrorEvent = class extends Event {
5849
+ /**
5850
+ * Create a new `ErrorEvent`.
5851
+ *
5852
+ * @param {String} type The name of the event
5853
+ * @param {Object} [options] A dictionary object that allows for setting
5854
+ * attributes via object members of the same name
5855
+ * @param {*} [options.error=null] The error that generated this event
5856
+ * @param {String} [options.message=''] The error message
5857
+ */
5858
+ constructor(type, options = {}) {
5859
+ super(type);
5860
+ this[kError] = options.error === void 0 ? null : options.error;
5861
+ this[kMessage] = options.message === void 0 ? "" : options.message;
5862
+ }
5863
+ /**
5864
+ * @type {*}
5865
+ */
5866
+ get error() {
5867
+ return this[kError];
5868
+ }
5869
+ /**
5870
+ * @type {String}
5871
+ */
5872
+ get message() {
5873
+ return this[kMessage];
5874
+ }
5875
+ };
5876
+ Object.defineProperty(ErrorEvent.prototype, "error", { enumerable: true });
5877
+ Object.defineProperty(ErrorEvent.prototype, "message", { enumerable: true });
5878
+ var MessageEvent = class extends Event {
5879
+ /**
5880
+ * Create a new `MessageEvent`.
5881
+ *
5882
+ * @param {String} type The name of the event
5883
+ * @param {Object} [options] A dictionary object that allows for setting
5884
+ * attributes via object members of the same name
5885
+ * @param {*} [options.data=null] The message content
5886
+ */
5887
+ constructor(type, options = {}) {
5888
+ super(type);
5889
+ this[kData] = options.data === void 0 ? null : options.data;
5890
+ }
5891
+ /**
5892
+ * @type {*}
5893
+ */
5894
+ get data() {
5895
+ return this[kData];
5896
+ }
5897
+ };
5898
+ Object.defineProperty(MessageEvent.prototype, "data", { enumerable: true });
5899
+ var EventTarget = {
5900
+ /**
5901
+ * Register an event listener.
5902
+ *
5903
+ * @param {String} type A string representing the event type to listen for
5904
+ * @param {(Function|Object)} handler The listener to add
5905
+ * @param {Object} [options] An options object specifies characteristics about
5906
+ * the event listener
5907
+ * @param {Boolean} [options.once=false] A `Boolean` indicating that the
5908
+ * listener should be invoked at most once after being added. If `true`,
5909
+ * the listener would be automatically removed when invoked.
5910
+ * @public
5911
+ */
5912
+ addEventListener(type, handler, options = {}) {
5913
+ for (const listener of this.listeners(type)) {
5914
+ if (!options[kForOnEventAttribute] && listener[kListener] === handler && !listener[kForOnEventAttribute]) {
5915
+ return;
5916
+ }
5917
+ }
5918
+ let wrapper;
5919
+ if (type === "message") {
5920
+ wrapper = function onMessage(data, isBinary) {
5921
+ const event = new MessageEvent("message", {
5922
+ data: isBinary ? data : data.toString()
5923
+ });
5924
+ event[kTarget] = this;
5925
+ callListener(handler, this, event);
5926
+ };
5927
+ } else if (type === "close") {
5928
+ wrapper = function onClose(code, message) {
5929
+ const event = new CloseEvent("close", {
5930
+ code,
5931
+ reason: message.toString(),
5932
+ wasClean: this._closeFrameReceived && this._closeFrameSent
5933
+ });
5934
+ event[kTarget] = this;
5935
+ callListener(handler, this, event);
5936
+ };
5937
+ } else if (type === "error") {
5938
+ wrapper = function onError(error) {
5939
+ const event = new ErrorEvent("error", {
5940
+ error,
5941
+ message: error.message
5942
+ });
5943
+ event[kTarget] = this;
5944
+ callListener(handler, this, event);
5945
+ };
5946
+ } else if (type === "open") {
5947
+ wrapper = function onOpen() {
5948
+ const event = new Event("open");
5949
+ event[kTarget] = this;
5950
+ callListener(handler, this, event);
5951
+ };
5952
+ } else {
5953
+ return;
5954
+ }
5955
+ wrapper[kForOnEventAttribute] = !!options[kForOnEventAttribute];
5956
+ wrapper[kListener] = handler;
5957
+ if (options.once) {
5958
+ this.once(type, wrapper);
5959
+ } else {
5960
+ this.on(type, wrapper);
5961
+ }
5962
+ },
5963
+ /**
5964
+ * Remove an event listener.
5965
+ *
5966
+ * @param {String} type A string representing the event type to remove
5967
+ * @param {(Function|Object)} handler The listener to remove
5968
+ * @public
5969
+ */
5970
+ removeEventListener(type, handler) {
5971
+ for (const listener of this.listeners(type)) {
5972
+ if (listener[kListener] === handler && !listener[kForOnEventAttribute]) {
5973
+ this.removeListener(type, listener);
5974
+ break;
5975
+ }
5976
+ }
5977
+ }
5978
+ };
5979
+ module2.exports = {
5980
+ CloseEvent,
5981
+ ErrorEvent,
5982
+ Event,
5983
+ EventTarget,
5984
+ MessageEvent
5985
+ };
5986
+ function callListener(listener, thisArg, event) {
5987
+ if (typeof listener === "object" && listener.handleEvent) {
5988
+ listener.handleEvent.call(listener, event);
5989
+ } else {
5990
+ listener.call(thisArg, event);
5991
+ }
5992
+ }
5993
+ }
5994
+ });
5995
+
5996
+ // node_modules/ws/lib/extension.js
5997
+ var require_extension = __commonJS({
5998
+ "node_modules/ws/lib/extension.js"(exports2, module2) {
5999
+ "use strict";
6000
+ var { tokenChars } = require_validation();
6001
+ function push(dest, name, elem) {
6002
+ if (dest[name] === void 0) dest[name] = [elem];
6003
+ else dest[name].push(elem);
6004
+ }
6005
+ function parse(header) {
6006
+ const offers = /* @__PURE__ */ Object.create(null);
6007
+ let params = /* @__PURE__ */ Object.create(null);
6008
+ let mustUnescape = false;
6009
+ let isEscaping = false;
6010
+ let inQuotes = false;
6011
+ let extensionName;
6012
+ let paramName;
6013
+ let start = -1;
6014
+ let code = -1;
6015
+ let end = -1;
6016
+ let i = 0;
6017
+ for (; i < header.length; i++) {
6018
+ code = header.charCodeAt(i);
6019
+ if (extensionName === void 0) {
6020
+ if (end === -1 && tokenChars[code] === 1) {
6021
+ if (start === -1) start = i;
6022
+ } else if (i !== 0 && (code === 32 || code === 9)) {
6023
+ if (end === -1 && start !== -1) end = i;
6024
+ } else if (code === 59 || code === 44) {
6025
+ if (start === -1) {
6026
+ throw new SyntaxError(`Unexpected character at index ${i}`);
6027
+ }
6028
+ if (end === -1) end = i;
6029
+ const name = header.slice(start, end);
6030
+ if (code === 44) {
6031
+ push(offers, name, params);
6032
+ params = /* @__PURE__ */ Object.create(null);
6033
+ } else {
6034
+ extensionName = name;
6035
+ }
6036
+ start = end = -1;
6037
+ } else {
6038
+ throw new SyntaxError(`Unexpected character at index ${i}`);
6039
+ }
6040
+ } else if (paramName === void 0) {
6041
+ if (end === -1 && tokenChars[code] === 1) {
6042
+ if (start === -1) start = i;
6043
+ } else if (code === 32 || code === 9) {
6044
+ if (end === -1 && start !== -1) end = i;
6045
+ } else if (code === 59 || code === 44) {
6046
+ if (start === -1) {
6047
+ throw new SyntaxError(`Unexpected character at index ${i}`);
6048
+ }
6049
+ if (end === -1) end = i;
6050
+ push(params, header.slice(start, end), true);
6051
+ if (code === 44) {
6052
+ push(offers, extensionName, params);
6053
+ params = /* @__PURE__ */ Object.create(null);
6054
+ extensionName = void 0;
6055
+ }
6056
+ start = end = -1;
6057
+ } else if (code === 61 && start !== -1 && end === -1) {
6058
+ paramName = header.slice(start, i);
6059
+ start = end = -1;
6060
+ } else {
6061
+ throw new SyntaxError(`Unexpected character at index ${i}`);
6062
+ }
6063
+ } else {
6064
+ if (isEscaping) {
6065
+ if (tokenChars[code] !== 1) {
6066
+ throw new SyntaxError(`Unexpected character at index ${i}`);
6067
+ }
6068
+ if (start === -1) start = i;
6069
+ else if (!mustUnescape) mustUnescape = true;
6070
+ isEscaping = false;
6071
+ } else if (inQuotes) {
6072
+ if (tokenChars[code] === 1) {
6073
+ if (start === -1) start = i;
6074
+ } else if (code === 34 && start !== -1) {
6075
+ inQuotes = false;
6076
+ end = i;
6077
+ } else if (code === 92) {
6078
+ isEscaping = true;
6079
+ } else {
6080
+ throw new SyntaxError(`Unexpected character at index ${i}`);
6081
+ }
6082
+ } else if (code === 34 && header.charCodeAt(i - 1) === 61) {
6083
+ inQuotes = true;
6084
+ } else if (end === -1 && tokenChars[code] === 1) {
6085
+ if (start === -1) start = i;
6086
+ } else if (start !== -1 && (code === 32 || code === 9)) {
6087
+ if (end === -1) end = i;
6088
+ } else if (code === 59 || code === 44) {
6089
+ if (start === -1) {
6090
+ throw new SyntaxError(`Unexpected character at index ${i}`);
6091
+ }
6092
+ if (end === -1) end = i;
6093
+ let value = header.slice(start, end);
6094
+ if (mustUnescape) {
6095
+ value = value.replace(/\\/g, "");
6096
+ mustUnescape = false;
6097
+ }
6098
+ push(params, paramName, value);
6099
+ if (code === 44) {
6100
+ push(offers, extensionName, params);
6101
+ params = /* @__PURE__ */ Object.create(null);
6102
+ extensionName = void 0;
6103
+ }
6104
+ paramName = void 0;
6105
+ start = end = -1;
6106
+ } else {
6107
+ throw new SyntaxError(`Unexpected character at index ${i}`);
6108
+ }
6109
+ }
6110
+ }
6111
+ if (start === -1 || inQuotes || code === 32 || code === 9) {
6112
+ throw new SyntaxError("Unexpected end of input");
6113
+ }
6114
+ if (end === -1) end = i;
6115
+ const token = header.slice(start, end);
6116
+ if (extensionName === void 0) {
6117
+ push(offers, token, params);
6118
+ } else {
6119
+ if (paramName === void 0) {
6120
+ push(params, token, true);
6121
+ } else if (mustUnescape) {
6122
+ push(params, paramName, token.replace(/\\/g, ""));
6123
+ } else {
6124
+ push(params, paramName, token);
6125
+ }
6126
+ push(offers, extensionName, params);
6127
+ }
6128
+ return offers;
6129
+ }
6130
+ function format(extensions) {
6131
+ return Object.keys(extensions).map((extension) => {
6132
+ let configurations = extensions[extension];
6133
+ if (!Array.isArray(configurations)) configurations = [configurations];
6134
+ return configurations.map((params) => {
6135
+ return [extension].concat(
6136
+ Object.keys(params).map((k) => {
6137
+ let values = params[k];
6138
+ if (!Array.isArray(values)) values = [values];
6139
+ return values.map((v) => v === true ? k : `${k}=${v}`).join("; ");
6140
+ })
6141
+ ).join("; ");
6142
+ }).join(", ");
6143
+ }).join(", ");
6144
+ }
6145
+ module2.exports = { format, parse };
6146
+ }
6147
+ });
6148
+
6149
+ // node_modules/ws/lib/websocket.js
6150
+ var require_websocket = __commonJS({
6151
+ "node_modules/ws/lib/websocket.js"(exports2, module2) {
6152
+ "use strict";
6153
+ var EventEmitter = require("events");
6154
+ var https2 = require("https");
6155
+ var http2 = require("http");
6156
+ var net2 = require("net");
6157
+ var tls = require("tls");
6158
+ var { randomBytes, createHash } = require("crypto");
6159
+ var { Duplex, Readable } = require("stream");
6160
+ var { URL: URL2 } = require("url");
6161
+ var PerMessageDeflate = require_permessage_deflate();
6162
+ var Receiver2 = require_receiver();
6163
+ var Sender2 = require_sender();
6164
+ var {
6165
+ BINARY_TYPES,
6166
+ EMPTY_BUFFER,
6167
+ GUID,
6168
+ kForOnEventAttribute,
6169
+ kListener,
6170
+ kStatusCode,
6171
+ kWebSocket,
6172
+ NOOP
6173
+ } = require_constants();
6174
+ var {
6175
+ EventTarget: { addEventListener, removeEventListener }
6176
+ } = require_event_target();
6177
+ var { format, parse } = require_extension();
6178
+ var { toBuffer } = require_buffer_util();
6179
+ var closeTimeout = 30 * 1e3;
6180
+ var kAborted = Symbol("kAborted");
6181
+ var protocolVersions = [8, 13];
6182
+ var readyStates = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
6183
+ var subprotocolRegex = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;
6184
+ var WebSocket2 = class _WebSocket extends EventEmitter {
6185
+ /**
6186
+ * Create a new `WebSocket`.
6187
+ *
6188
+ * @param {(String|URL)} address The URL to which to connect
6189
+ * @param {(String|String[])} [protocols] The subprotocols
6190
+ * @param {Object} [options] Connection options
6191
+ */
6192
+ constructor(address, protocols, options) {
6193
+ super();
6194
+ this._binaryType = BINARY_TYPES[0];
6195
+ this._closeCode = 1006;
6196
+ this._closeFrameReceived = false;
6197
+ this._closeFrameSent = false;
6198
+ this._closeMessage = EMPTY_BUFFER;
6199
+ this._closeTimer = null;
6200
+ this._extensions = {};
6201
+ this._paused = false;
6202
+ this._protocol = "";
6203
+ this._readyState = _WebSocket.CONNECTING;
6204
+ this._receiver = null;
6205
+ this._sender = null;
6206
+ this._socket = null;
6207
+ if (address !== null) {
6208
+ this._bufferedAmount = 0;
6209
+ this._isServer = false;
6210
+ this._redirects = 0;
6211
+ if (protocols === void 0) {
6212
+ protocols = [];
6213
+ } else if (!Array.isArray(protocols)) {
6214
+ if (typeof protocols === "object" && protocols !== null) {
6215
+ options = protocols;
6216
+ protocols = [];
6217
+ } else {
6218
+ protocols = [protocols];
6219
+ }
6220
+ }
6221
+ initAsClient(this, address, protocols, options);
6222
+ } else {
6223
+ this._autoPong = options.autoPong;
6224
+ this._isServer = true;
6225
+ }
6226
+ }
6227
+ /**
6228
+ * This deviates from the WHATWG interface since ws doesn't support the
6229
+ * required default "blob" type (instead we define a custom "nodebuffer"
6230
+ * type).
6231
+ *
6232
+ * @type {String}
6233
+ */
6234
+ get binaryType() {
6235
+ return this._binaryType;
6236
+ }
6237
+ set binaryType(type) {
6238
+ if (!BINARY_TYPES.includes(type)) return;
6239
+ this._binaryType = type;
6240
+ if (this._receiver) this._receiver._binaryType = type;
6241
+ }
6242
+ /**
6243
+ * @type {Number}
6244
+ */
6245
+ get bufferedAmount() {
6246
+ if (!this._socket) return this._bufferedAmount;
6247
+ return this._socket._writableState.length + this._sender._bufferedBytes;
6248
+ }
6249
+ /**
6250
+ * @type {String}
6251
+ */
6252
+ get extensions() {
6253
+ return Object.keys(this._extensions).join();
6254
+ }
6255
+ /**
6256
+ * @type {Boolean}
6257
+ */
6258
+ get isPaused() {
6259
+ return this._paused;
6260
+ }
6261
+ /**
6262
+ * @type {Function}
6263
+ */
6264
+ /* istanbul ignore next */
6265
+ get onclose() {
6266
+ return null;
6267
+ }
6268
+ /**
6269
+ * @type {Function}
6270
+ */
6271
+ /* istanbul ignore next */
6272
+ get onerror() {
6273
+ return null;
6274
+ }
6275
+ /**
6276
+ * @type {Function}
6277
+ */
6278
+ /* istanbul ignore next */
6279
+ get onopen() {
6280
+ return null;
6281
+ }
6282
+ /**
6283
+ * @type {Function}
6284
+ */
6285
+ /* istanbul ignore next */
6286
+ get onmessage() {
6287
+ return null;
6288
+ }
6289
+ /**
6290
+ * @type {String}
6291
+ */
6292
+ get protocol() {
6293
+ return this._protocol;
6294
+ }
6295
+ /**
6296
+ * @type {Number}
6297
+ */
6298
+ get readyState() {
6299
+ return this._readyState;
6300
+ }
6301
+ /**
6302
+ * @type {String}
6303
+ */
6304
+ get url() {
6305
+ return this._url;
6306
+ }
6307
+ /**
6308
+ * Set up the socket and the internal resources.
6309
+ *
6310
+ * @param {Duplex} socket The network socket between the server and client
6311
+ * @param {Buffer} head The first packet of the upgraded stream
6312
+ * @param {Object} options Options object
6313
+ * @param {Boolean} [options.allowSynchronousEvents=false] Specifies whether
6314
+ * any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
6315
+ * multiple times in the same tick
6316
+ * @param {Function} [options.generateMask] The function used to generate the
6317
+ * masking key
6318
+ * @param {Number} [options.maxPayload=0] The maximum allowed message size
6319
+ * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
6320
+ * not to skip UTF-8 validation for text and close messages
6321
+ * @private
6322
+ */
6323
+ setSocket(socket, head, options) {
6324
+ const receiver = new Receiver2({
6325
+ allowSynchronousEvents: options.allowSynchronousEvents,
6326
+ binaryType: this.binaryType,
6327
+ extensions: this._extensions,
6328
+ isServer: this._isServer,
6329
+ maxPayload: options.maxPayload,
6330
+ skipUTF8Validation: options.skipUTF8Validation
6331
+ });
6332
+ this._sender = new Sender2(socket, this._extensions, options.generateMask);
6333
+ this._receiver = receiver;
6334
+ this._socket = socket;
6335
+ receiver[kWebSocket] = this;
6336
+ socket[kWebSocket] = this;
6337
+ receiver.on("conclude", receiverOnConclude);
6338
+ receiver.on("drain", receiverOnDrain);
6339
+ receiver.on("error", receiverOnError);
6340
+ receiver.on("message", receiverOnMessage);
6341
+ receiver.on("ping", receiverOnPing);
6342
+ receiver.on("pong", receiverOnPong);
6343
+ if (socket.setTimeout) socket.setTimeout(0);
6344
+ if (socket.setNoDelay) socket.setNoDelay();
6345
+ if (head.length > 0) socket.unshift(head);
6346
+ socket.on("close", socketOnClose);
6347
+ socket.on("data", socketOnData);
6348
+ socket.on("end", socketOnEnd);
6349
+ socket.on("error", socketOnError);
6350
+ this._readyState = _WebSocket.OPEN;
6351
+ this.emit("open");
6352
+ }
6353
+ /**
6354
+ * Emit the `'close'` event.
6355
+ *
6356
+ * @private
6357
+ */
6358
+ emitClose() {
6359
+ if (!this._socket) {
6360
+ this._readyState = _WebSocket.CLOSED;
6361
+ this.emit("close", this._closeCode, this._closeMessage);
6362
+ return;
6363
+ }
6364
+ if (this._extensions[PerMessageDeflate.extensionName]) {
6365
+ this._extensions[PerMessageDeflate.extensionName].cleanup();
6366
+ }
6367
+ this._receiver.removeAllListeners();
6368
+ this._readyState = _WebSocket.CLOSED;
6369
+ this.emit("close", this._closeCode, this._closeMessage);
6370
+ }
6371
+ /**
6372
+ * Start a closing handshake.
6373
+ *
6374
+ * +----------+ +-----------+ +----------+
6375
+ * - - -|ws.close()|-->|close frame|-->|ws.close()|- - -
6376
+ * | +----------+ +-----------+ +----------+ |
6377
+ * +----------+ +-----------+ |
6378
+ * CLOSING |ws.close()|<--|close frame|<--+-----+ CLOSING
6379
+ * +----------+ +-----------+ |
6380
+ * | | | +---+ |
6381
+ * +------------------------+-->|fin| - - - -
6382
+ * | +---+ | +---+
6383
+ * - - - - -|fin|<---------------------+
6384
+ * +---+
6385
+ *
6386
+ * @param {Number} [code] Status code explaining why the connection is closing
6387
+ * @param {(String|Buffer)} [data] The reason why the connection is
6388
+ * closing
6389
+ * @public
6390
+ */
6391
+ close(code, data) {
6392
+ if (this.readyState === _WebSocket.CLOSED) return;
6393
+ if (this.readyState === _WebSocket.CONNECTING) {
6394
+ const msg = "WebSocket was closed before the connection was established";
6395
+ abortHandshake(this, this._req, msg);
6396
+ return;
6397
+ }
6398
+ if (this.readyState === _WebSocket.CLOSING) {
6399
+ if (this._closeFrameSent && (this._closeFrameReceived || this._receiver._writableState.errorEmitted)) {
6400
+ this._socket.end();
6401
+ }
6402
+ return;
6403
+ }
6404
+ this._readyState = _WebSocket.CLOSING;
6405
+ this._sender.close(code, data, !this._isServer, (err2) => {
6406
+ if (err2) return;
6407
+ this._closeFrameSent = true;
6408
+ if (this._closeFrameReceived || this._receiver._writableState.errorEmitted) {
6409
+ this._socket.end();
6410
+ }
6411
+ });
6412
+ this._closeTimer = setTimeout(
6413
+ this._socket.destroy.bind(this._socket),
6414
+ closeTimeout
6415
+ );
6416
+ }
6417
+ /**
6418
+ * Pause the socket.
6419
+ *
6420
+ * @public
6421
+ */
6422
+ pause() {
6423
+ if (this.readyState === _WebSocket.CONNECTING || this.readyState === _WebSocket.CLOSED) {
6424
+ return;
6425
+ }
6426
+ this._paused = true;
6427
+ this._socket.pause();
6428
+ }
6429
+ /**
6430
+ * Send a ping.
6431
+ *
6432
+ * @param {*} [data] The data to send
6433
+ * @param {Boolean} [mask] Indicates whether or not to mask `data`
6434
+ * @param {Function} [cb] Callback which is executed when the ping is sent
6435
+ * @public
6436
+ */
6437
+ ping(data, mask, cb) {
6438
+ if (this.readyState === _WebSocket.CONNECTING) {
6439
+ throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
6440
+ }
6441
+ if (typeof data === "function") {
6442
+ cb = data;
6443
+ data = mask = void 0;
6444
+ } else if (typeof mask === "function") {
6445
+ cb = mask;
6446
+ mask = void 0;
6447
+ }
6448
+ if (typeof data === "number") data = data.toString();
6449
+ if (this.readyState !== _WebSocket.OPEN) {
6450
+ sendAfterClose(this, data, cb);
6451
+ return;
6452
+ }
6453
+ if (mask === void 0) mask = !this._isServer;
6454
+ this._sender.ping(data || EMPTY_BUFFER, mask, cb);
6455
+ }
6456
+ /**
6457
+ * Send a pong.
6458
+ *
6459
+ * @param {*} [data] The data to send
6460
+ * @param {Boolean} [mask] Indicates whether or not to mask `data`
6461
+ * @param {Function} [cb] Callback which is executed when the pong is sent
6462
+ * @public
6463
+ */
6464
+ pong(data, mask, cb) {
6465
+ if (this.readyState === _WebSocket.CONNECTING) {
6466
+ throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
6467
+ }
6468
+ if (typeof data === "function") {
6469
+ cb = data;
6470
+ data = mask = void 0;
6471
+ } else if (typeof mask === "function") {
6472
+ cb = mask;
6473
+ mask = void 0;
6474
+ }
6475
+ if (typeof data === "number") data = data.toString();
6476
+ if (this.readyState !== _WebSocket.OPEN) {
6477
+ sendAfterClose(this, data, cb);
6478
+ return;
6479
+ }
6480
+ if (mask === void 0) mask = !this._isServer;
6481
+ this._sender.pong(data || EMPTY_BUFFER, mask, cb);
6482
+ }
6483
+ /**
6484
+ * Resume the socket.
6485
+ *
6486
+ * @public
6487
+ */
6488
+ resume() {
6489
+ if (this.readyState === _WebSocket.CONNECTING || this.readyState === _WebSocket.CLOSED) {
6490
+ return;
6491
+ }
6492
+ this._paused = false;
6493
+ if (!this._receiver._writableState.needDrain) this._socket.resume();
6494
+ }
6495
+ /**
6496
+ * Send a data message.
6497
+ *
6498
+ * @param {*} data The message to send
6499
+ * @param {Object} [options] Options object
6500
+ * @param {Boolean} [options.binary] Specifies whether `data` is binary or
6501
+ * text
6502
+ * @param {Boolean} [options.compress] Specifies whether or not to compress
6503
+ * `data`
6504
+ * @param {Boolean} [options.fin=true] Specifies whether the fragment is the
6505
+ * last one
6506
+ * @param {Boolean} [options.mask] Specifies whether or not to mask `data`
6507
+ * @param {Function} [cb] Callback which is executed when data is written out
6508
+ * @public
6509
+ */
6510
+ send(data, options, cb) {
6511
+ if (this.readyState === _WebSocket.CONNECTING) {
6512
+ throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
6513
+ }
6514
+ if (typeof options === "function") {
6515
+ cb = options;
6516
+ options = {};
6517
+ }
6518
+ if (typeof data === "number") data = data.toString();
6519
+ if (this.readyState !== _WebSocket.OPEN) {
6520
+ sendAfterClose(this, data, cb);
6521
+ return;
6522
+ }
6523
+ const opts = {
6524
+ binary: typeof data !== "string",
6525
+ mask: !this._isServer,
6526
+ compress: true,
6527
+ fin: true,
6528
+ ...options
6529
+ };
6530
+ if (!this._extensions[PerMessageDeflate.extensionName]) {
6531
+ opts.compress = false;
6532
+ }
6533
+ this._sender.send(data || EMPTY_BUFFER, opts, cb);
6534
+ }
6535
+ /**
6536
+ * Forcibly close the connection.
6537
+ *
6538
+ * @public
6539
+ */
6540
+ terminate() {
6541
+ if (this.readyState === _WebSocket.CLOSED) return;
6542
+ if (this.readyState === _WebSocket.CONNECTING) {
6543
+ const msg = "WebSocket was closed before the connection was established";
6544
+ abortHandshake(this, this._req, msg);
6545
+ return;
6546
+ }
6547
+ if (this._socket) {
6548
+ this._readyState = _WebSocket.CLOSING;
6549
+ this._socket.destroy();
6550
+ }
6551
+ }
6552
+ };
6553
+ Object.defineProperty(WebSocket2, "CONNECTING", {
6554
+ enumerable: true,
6555
+ value: readyStates.indexOf("CONNECTING")
6556
+ });
6557
+ Object.defineProperty(WebSocket2.prototype, "CONNECTING", {
6558
+ enumerable: true,
6559
+ value: readyStates.indexOf("CONNECTING")
6560
+ });
6561
+ Object.defineProperty(WebSocket2, "OPEN", {
6562
+ enumerable: true,
6563
+ value: readyStates.indexOf("OPEN")
6564
+ });
6565
+ Object.defineProperty(WebSocket2.prototype, "OPEN", {
6566
+ enumerable: true,
6567
+ value: readyStates.indexOf("OPEN")
6568
+ });
6569
+ Object.defineProperty(WebSocket2, "CLOSING", {
6570
+ enumerable: true,
6571
+ value: readyStates.indexOf("CLOSING")
6572
+ });
6573
+ Object.defineProperty(WebSocket2.prototype, "CLOSING", {
6574
+ enumerable: true,
6575
+ value: readyStates.indexOf("CLOSING")
6576
+ });
6577
+ Object.defineProperty(WebSocket2, "CLOSED", {
6578
+ enumerable: true,
6579
+ value: readyStates.indexOf("CLOSED")
6580
+ });
6581
+ Object.defineProperty(WebSocket2.prototype, "CLOSED", {
6582
+ enumerable: true,
6583
+ value: readyStates.indexOf("CLOSED")
6584
+ });
6585
+ [
6586
+ "binaryType",
6587
+ "bufferedAmount",
6588
+ "extensions",
6589
+ "isPaused",
6590
+ "protocol",
6591
+ "readyState",
6592
+ "url"
6593
+ ].forEach((property) => {
6594
+ Object.defineProperty(WebSocket2.prototype, property, { enumerable: true });
6595
+ });
6596
+ ["open", "error", "close", "message"].forEach((method) => {
6597
+ Object.defineProperty(WebSocket2.prototype, `on${method}`, {
6598
+ enumerable: true,
6599
+ get() {
6600
+ for (const listener of this.listeners(method)) {
6601
+ if (listener[kForOnEventAttribute]) return listener[kListener];
6602
+ }
6603
+ return null;
6604
+ },
6605
+ set(handler) {
6606
+ for (const listener of this.listeners(method)) {
6607
+ if (listener[kForOnEventAttribute]) {
6608
+ this.removeListener(method, listener);
6609
+ break;
6610
+ }
6611
+ }
6612
+ if (typeof handler !== "function") return;
6613
+ this.addEventListener(method, handler, {
6614
+ [kForOnEventAttribute]: true
6615
+ });
6616
+ }
6617
+ });
6618
+ });
6619
+ WebSocket2.prototype.addEventListener = addEventListener;
6620
+ WebSocket2.prototype.removeEventListener = removeEventListener;
6621
+ module2.exports = WebSocket2;
6622
+ function initAsClient(websocket, address, protocols, options) {
6623
+ const opts = {
6624
+ allowSynchronousEvents: true,
6625
+ autoPong: true,
6626
+ protocolVersion: protocolVersions[1],
6627
+ maxPayload: 100 * 1024 * 1024,
6628
+ skipUTF8Validation: false,
6629
+ perMessageDeflate: true,
6630
+ followRedirects: false,
6631
+ maxRedirects: 10,
6632
+ ...options,
6633
+ socketPath: void 0,
6634
+ hostname: void 0,
6635
+ protocol: void 0,
6636
+ timeout: void 0,
6637
+ method: "GET",
6638
+ host: void 0,
6639
+ path: void 0,
6640
+ port: void 0
6641
+ };
6642
+ websocket._autoPong = opts.autoPong;
6643
+ if (!protocolVersions.includes(opts.protocolVersion)) {
6644
+ throw new RangeError(
6645
+ `Unsupported protocol version: ${opts.protocolVersion} (supported versions: ${protocolVersions.join(", ")})`
6646
+ );
6647
+ }
6648
+ let parsedUrl;
6649
+ if (address instanceof URL2) {
6650
+ parsedUrl = address;
6651
+ } else {
6652
+ try {
6653
+ parsedUrl = new URL2(address);
6654
+ } catch (e) {
6655
+ throw new SyntaxError(`Invalid URL: ${address}`);
6656
+ }
6657
+ }
6658
+ if (parsedUrl.protocol === "http:") {
6659
+ parsedUrl.protocol = "ws:";
6660
+ } else if (parsedUrl.protocol === "https:") {
6661
+ parsedUrl.protocol = "wss:";
6662
+ }
6663
+ websocket._url = parsedUrl.href;
6664
+ const isSecure = parsedUrl.protocol === "wss:";
6665
+ const isIpcUrl = parsedUrl.protocol === "ws+unix:";
6666
+ let invalidUrlMessage;
6667
+ if (parsedUrl.protocol !== "ws:" && !isSecure && !isIpcUrl) {
6668
+ invalidUrlMessage = `The URL's protocol must be one of "ws:", "wss:", "http:", "https", or "ws+unix:"`;
6669
+ } else if (isIpcUrl && !parsedUrl.pathname) {
6670
+ invalidUrlMessage = "The URL's pathname is empty";
6671
+ } else if (parsedUrl.hash) {
6672
+ invalidUrlMessage = "The URL contains a fragment identifier";
6673
+ }
6674
+ if (invalidUrlMessage) {
6675
+ const err2 = new SyntaxError(invalidUrlMessage);
6676
+ if (websocket._redirects === 0) {
6677
+ throw err2;
6678
+ } else {
6679
+ emitErrorAndClose(websocket, err2);
6680
+ return;
6681
+ }
6682
+ }
6683
+ const defaultPort = isSecure ? 443 : 80;
6684
+ const key = randomBytes(16).toString("base64");
6685
+ const request = isSecure ? https2.request : http2.request;
6686
+ const protocolSet = /* @__PURE__ */ new Set();
6687
+ let perMessageDeflate;
6688
+ opts.createConnection = opts.createConnection || (isSecure ? tlsConnect : netConnect);
6689
+ opts.defaultPort = opts.defaultPort || defaultPort;
6690
+ opts.port = parsedUrl.port || defaultPort;
6691
+ opts.host = parsedUrl.hostname.startsWith("[") ? parsedUrl.hostname.slice(1, -1) : parsedUrl.hostname;
6692
+ opts.headers = {
6693
+ ...opts.headers,
6694
+ "Sec-WebSocket-Version": opts.protocolVersion,
6695
+ "Sec-WebSocket-Key": key,
6696
+ Connection: "Upgrade",
6697
+ Upgrade: "websocket"
6698
+ };
6699
+ opts.path = parsedUrl.pathname + parsedUrl.search;
6700
+ opts.timeout = opts.handshakeTimeout;
6701
+ if (opts.perMessageDeflate) {
6702
+ perMessageDeflate = new PerMessageDeflate(
6703
+ opts.perMessageDeflate !== true ? opts.perMessageDeflate : {},
6704
+ false,
6705
+ opts.maxPayload
6706
+ );
6707
+ opts.headers["Sec-WebSocket-Extensions"] = format({
6708
+ [PerMessageDeflate.extensionName]: perMessageDeflate.offer()
6709
+ });
6710
+ }
6711
+ if (protocols.length) {
6712
+ for (const protocol of protocols) {
6713
+ if (typeof protocol !== "string" || !subprotocolRegex.test(protocol) || protocolSet.has(protocol)) {
6714
+ throw new SyntaxError(
6715
+ "An invalid or duplicated subprotocol was specified"
6716
+ );
6717
+ }
6718
+ protocolSet.add(protocol);
6719
+ }
6720
+ opts.headers["Sec-WebSocket-Protocol"] = protocols.join(",");
6721
+ }
6722
+ if (opts.origin) {
6723
+ if (opts.protocolVersion < 13) {
6724
+ opts.headers["Sec-WebSocket-Origin"] = opts.origin;
6725
+ } else {
6726
+ opts.headers.Origin = opts.origin;
6727
+ }
6728
+ }
6729
+ if (parsedUrl.username || parsedUrl.password) {
6730
+ opts.auth = `${parsedUrl.username}:${parsedUrl.password}`;
6731
+ }
6732
+ if (isIpcUrl) {
6733
+ const parts = opts.path.split(":");
6734
+ opts.socketPath = parts[0];
6735
+ opts.path = parts[1];
6736
+ }
6737
+ let req;
6738
+ if (opts.followRedirects) {
6739
+ if (websocket._redirects === 0) {
6740
+ websocket._originalIpc = isIpcUrl;
6741
+ websocket._originalSecure = isSecure;
6742
+ websocket._originalHostOrSocketPath = isIpcUrl ? opts.socketPath : parsedUrl.host;
6743
+ const headers = options && options.headers;
6744
+ options = { ...options, headers: {} };
6745
+ if (headers) {
6746
+ for (const [key2, value] of Object.entries(headers)) {
6747
+ options.headers[key2.toLowerCase()] = value;
6748
+ }
6749
+ }
6750
+ } else if (websocket.listenerCount("redirect") === 0) {
6751
+ const isSameHost = isIpcUrl ? websocket._originalIpc ? opts.socketPath === websocket._originalHostOrSocketPath : false : websocket._originalIpc ? false : parsedUrl.host === websocket._originalHostOrSocketPath;
6752
+ if (!isSameHost || websocket._originalSecure && !isSecure) {
6753
+ delete opts.headers.authorization;
6754
+ delete opts.headers.cookie;
6755
+ if (!isSameHost) delete opts.headers.host;
6756
+ opts.auth = void 0;
6757
+ }
6758
+ }
6759
+ if (opts.auth && !options.headers.authorization) {
6760
+ options.headers.authorization = "Basic " + Buffer.from(opts.auth).toString("base64");
6761
+ }
6762
+ req = websocket._req = request(opts);
6763
+ if (websocket._redirects) {
6764
+ websocket.emit("redirect", websocket.url, req);
6765
+ }
6766
+ } else {
6767
+ req = websocket._req = request(opts);
6768
+ }
6769
+ if (opts.timeout) {
6770
+ req.on("timeout", () => {
6771
+ abortHandshake(websocket, req, "Opening handshake has timed out");
6772
+ });
6773
+ }
6774
+ req.on("error", (err2) => {
6775
+ if (req === null || req[kAborted]) return;
6776
+ req = websocket._req = null;
6777
+ emitErrorAndClose(websocket, err2);
6778
+ });
6779
+ req.on("response", (res) => {
6780
+ const location = res.headers.location;
6781
+ const statusCode = res.statusCode;
6782
+ if (location && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
6783
+ if (++websocket._redirects > opts.maxRedirects) {
6784
+ abortHandshake(websocket, req, "Maximum redirects exceeded");
6785
+ return;
6786
+ }
6787
+ req.abort();
6788
+ let addr;
6789
+ try {
6790
+ addr = new URL2(location, address);
6791
+ } catch (e) {
6792
+ const err2 = new SyntaxError(`Invalid URL: ${location}`);
6793
+ emitErrorAndClose(websocket, err2);
6794
+ return;
6795
+ }
6796
+ initAsClient(websocket, addr, protocols, options);
6797
+ } else if (!websocket.emit("unexpected-response", req, res)) {
6798
+ abortHandshake(
6799
+ websocket,
6800
+ req,
6801
+ `Unexpected server response: ${res.statusCode}`
6802
+ );
6803
+ }
6804
+ });
6805
+ req.on("upgrade", (res, socket, head) => {
6806
+ websocket.emit("upgrade", res);
6807
+ if (websocket.readyState !== WebSocket2.CONNECTING) return;
6808
+ req = websocket._req = null;
6809
+ const upgrade = res.headers.upgrade;
6810
+ if (upgrade === void 0 || upgrade.toLowerCase() !== "websocket") {
6811
+ abortHandshake(websocket, socket, "Invalid Upgrade header");
6812
+ return;
6813
+ }
6814
+ const digest = createHash("sha1").update(key + GUID).digest("base64");
6815
+ if (res.headers["sec-websocket-accept"] !== digest) {
6816
+ abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
6817
+ return;
6818
+ }
6819
+ const serverProt = res.headers["sec-websocket-protocol"];
6820
+ let protError;
6821
+ if (serverProt !== void 0) {
6822
+ if (!protocolSet.size) {
6823
+ protError = "Server sent a subprotocol but none was requested";
6824
+ } else if (!protocolSet.has(serverProt)) {
6825
+ protError = "Server sent an invalid subprotocol";
6826
+ }
6827
+ } else if (protocolSet.size) {
6828
+ protError = "Server sent no subprotocol";
6829
+ }
6830
+ if (protError) {
6831
+ abortHandshake(websocket, socket, protError);
6832
+ return;
6833
+ }
6834
+ if (serverProt) websocket._protocol = serverProt;
6835
+ const secWebSocketExtensions = res.headers["sec-websocket-extensions"];
6836
+ if (secWebSocketExtensions !== void 0) {
6837
+ if (!perMessageDeflate) {
6838
+ const message = "Server sent a Sec-WebSocket-Extensions header but no extension was requested";
6839
+ abortHandshake(websocket, socket, message);
6840
+ return;
6841
+ }
6842
+ let extensions;
6843
+ try {
6844
+ extensions = parse(secWebSocketExtensions);
6845
+ } catch (err2) {
6846
+ const message = "Invalid Sec-WebSocket-Extensions header";
6847
+ abortHandshake(websocket, socket, message);
6848
+ return;
6849
+ }
6850
+ const extensionNames = Object.keys(extensions);
6851
+ if (extensionNames.length !== 1 || extensionNames[0] !== PerMessageDeflate.extensionName) {
6852
+ const message = "Server indicated an extension that was not requested";
6853
+ abortHandshake(websocket, socket, message);
6854
+ return;
6855
+ }
6856
+ try {
6857
+ perMessageDeflate.accept(extensions[PerMessageDeflate.extensionName]);
6858
+ } catch (err2) {
6859
+ const message = "Invalid Sec-WebSocket-Extensions header";
6860
+ abortHandshake(websocket, socket, message);
6861
+ return;
6862
+ }
6863
+ websocket._extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
6864
+ }
6865
+ websocket.setSocket(socket, head, {
6866
+ allowSynchronousEvents: opts.allowSynchronousEvents,
6867
+ generateMask: opts.generateMask,
6868
+ maxPayload: opts.maxPayload,
6869
+ skipUTF8Validation: opts.skipUTF8Validation
6870
+ });
6871
+ });
6872
+ if (opts.finishRequest) {
6873
+ opts.finishRequest(req, websocket);
6874
+ } else {
6875
+ req.end();
6876
+ }
6877
+ }
6878
+ function emitErrorAndClose(websocket, err2) {
6879
+ websocket._readyState = WebSocket2.CLOSING;
6880
+ websocket.emit("error", err2);
6881
+ websocket.emitClose();
6882
+ }
6883
+ function netConnect(options) {
6884
+ options.path = options.socketPath;
6885
+ return net2.connect(options);
6886
+ }
6887
+ function tlsConnect(options) {
6888
+ options.path = void 0;
6889
+ if (!options.servername && options.servername !== "") {
6890
+ options.servername = net2.isIP(options.host) ? "" : options.host;
6891
+ }
6892
+ return tls.connect(options);
6893
+ }
6894
+ function abortHandshake(websocket, stream, message) {
6895
+ websocket._readyState = WebSocket2.CLOSING;
6896
+ const err2 = new Error(message);
6897
+ Error.captureStackTrace(err2, abortHandshake);
6898
+ if (stream.setHeader) {
6899
+ stream[kAborted] = true;
6900
+ stream.abort();
6901
+ if (stream.socket && !stream.socket.destroyed) {
6902
+ stream.socket.destroy();
6903
+ }
6904
+ process.nextTick(emitErrorAndClose, websocket, err2);
6905
+ } else {
6906
+ stream.destroy(err2);
6907
+ stream.once("error", websocket.emit.bind(websocket, "error"));
6908
+ stream.once("close", websocket.emitClose.bind(websocket));
6909
+ }
6910
+ }
6911
+ function sendAfterClose(websocket, data, cb) {
6912
+ if (data) {
6913
+ const length = toBuffer(data).length;
6914
+ if (websocket._socket) websocket._sender._bufferedBytes += length;
6915
+ else websocket._bufferedAmount += length;
6916
+ }
6917
+ if (cb) {
6918
+ const err2 = new Error(
6919
+ `WebSocket is not open: readyState ${websocket.readyState} (${readyStates[websocket.readyState]})`
6920
+ );
6921
+ process.nextTick(cb, err2);
6922
+ }
6923
+ }
6924
+ function receiverOnConclude(code, reason) {
6925
+ const websocket = this[kWebSocket];
6926
+ websocket._closeFrameReceived = true;
6927
+ websocket._closeMessage = reason;
6928
+ websocket._closeCode = code;
6929
+ if (websocket._socket[kWebSocket] === void 0) return;
6930
+ websocket._socket.removeListener("data", socketOnData);
6931
+ process.nextTick(resume, websocket._socket);
6932
+ if (code === 1005) websocket.close();
6933
+ else websocket.close(code, reason);
6934
+ }
6935
+ function receiverOnDrain() {
6936
+ const websocket = this[kWebSocket];
6937
+ if (!websocket.isPaused) websocket._socket.resume();
6938
+ }
6939
+ function receiverOnError(err2) {
6940
+ const websocket = this[kWebSocket];
6941
+ if (websocket._socket[kWebSocket] !== void 0) {
6942
+ websocket._socket.removeListener("data", socketOnData);
6943
+ process.nextTick(resume, websocket._socket);
6944
+ websocket.close(err2[kStatusCode]);
6945
+ }
6946
+ websocket.emit("error", err2);
6947
+ }
6948
+ function receiverOnFinish() {
6949
+ this[kWebSocket].emitClose();
6950
+ }
6951
+ function receiverOnMessage(data, isBinary) {
6952
+ this[kWebSocket].emit("message", data, isBinary);
6953
+ }
6954
+ function receiverOnPing(data) {
6955
+ const websocket = this[kWebSocket];
6956
+ if (websocket._autoPong) websocket.pong(data, !this._isServer, NOOP);
6957
+ websocket.emit("ping", data);
6958
+ }
6959
+ function receiverOnPong(data) {
6960
+ this[kWebSocket].emit("pong", data);
6961
+ }
6962
+ function resume(stream) {
6963
+ stream.resume();
6964
+ }
6965
+ function socketOnClose() {
6966
+ const websocket = this[kWebSocket];
6967
+ this.removeListener("close", socketOnClose);
6968
+ this.removeListener("data", socketOnData);
6969
+ this.removeListener("end", socketOnEnd);
6970
+ websocket._readyState = WebSocket2.CLOSING;
6971
+ let chunk;
6972
+ if (!this._readableState.endEmitted && !websocket._closeFrameReceived && !websocket._receiver._writableState.errorEmitted && (chunk = websocket._socket.read()) !== null) {
6973
+ websocket._receiver.write(chunk);
6974
+ }
6975
+ websocket._receiver.end();
6976
+ this[kWebSocket] = void 0;
6977
+ clearTimeout(websocket._closeTimer);
6978
+ if (websocket._receiver._writableState.finished || websocket._receiver._writableState.errorEmitted) {
6979
+ websocket.emitClose();
6980
+ } else {
6981
+ websocket._receiver.on("error", receiverOnFinish);
6982
+ websocket._receiver.on("finish", receiverOnFinish);
6983
+ }
6984
+ }
6985
+ function socketOnData(chunk) {
6986
+ if (!this[kWebSocket]._receiver.write(chunk)) {
6987
+ this.pause();
6988
+ }
6989
+ }
6990
+ function socketOnEnd() {
6991
+ const websocket = this[kWebSocket];
6992
+ websocket._readyState = WebSocket2.CLOSING;
6993
+ websocket._receiver.end();
6994
+ this.end();
6995
+ }
6996
+ function socketOnError() {
6997
+ const websocket = this[kWebSocket];
6998
+ this.removeListener("error", socketOnError);
6999
+ this.on("error", NOOP);
7000
+ if (websocket) {
7001
+ websocket._readyState = WebSocket2.CLOSING;
7002
+ this.destroy();
7003
+ }
7004
+ }
7005
+ }
7006
+ });
7007
+
7008
+ // node_modules/ws/lib/subprotocol.js
7009
+ var require_subprotocol = __commonJS({
7010
+ "node_modules/ws/lib/subprotocol.js"(exports2, module2) {
7011
+ "use strict";
7012
+ var { tokenChars } = require_validation();
7013
+ function parse(header) {
7014
+ const protocols = /* @__PURE__ */ new Set();
7015
+ let start = -1;
7016
+ let end = -1;
7017
+ let i = 0;
7018
+ for (i; i < header.length; i++) {
7019
+ const code = header.charCodeAt(i);
7020
+ if (end === -1 && tokenChars[code] === 1) {
7021
+ if (start === -1) start = i;
7022
+ } else if (i !== 0 && (code === 32 || code === 9)) {
7023
+ if (end === -1 && start !== -1) end = i;
7024
+ } else if (code === 44) {
7025
+ if (start === -1) {
7026
+ throw new SyntaxError(`Unexpected character at index ${i}`);
7027
+ }
7028
+ if (end === -1) end = i;
7029
+ const protocol2 = header.slice(start, end);
7030
+ if (protocols.has(protocol2)) {
7031
+ throw new SyntaxError(`The "${protocol2}" subprotocol is duplicated`);
7032
+ }
7033
+ protocols.add(protocol2);
7034
+ start = end = -1;
7035
+ } else {
7036
+ throw new SyntaxError(`Unexpected character at index ${i}`);
7037
+ }
7038
+ }
7039
+ if (start === -1 || end !== -1) {
7040
+ throw new SyntaxError("Unexpected end of input");
7041
+ }
7042
+ const protocol = header.slice(start, i);
7043
+ if (protocols.has(protocol)) {
7044
+ throw new SyntaxError(`The "${protocol}" subprotocol is duplicated`);
7045
+ }
7046
+ protocols.add(protocol);
7047
+ return protocols;
7048
+ }
7049
+ module2.exports = { parse };
7050
+ }
7051
+ });
7052
+
7053
+ // node_modules/ws/lib/websocket-server.js
7054
+ var require_websocket_server = __commonJS({
7055
+ "node_modules/ws/lib/websocket-server.js"(exports2, module2) {
7056
+ "use strict";
7057
+ var EventEmitter = require("events");
7058
+ var http2 = require("http");
7059
+ var { Duplex } = require("stream");
7060
+ var { createHash } = require("crypto");
7061
+ var extension = require_extension();
7062
+ var PerMessageDeflate = require_permessage_deflate();
7063
+ var subprotocol = require_subprotocol();
7064
+ var WebSocket2 = require_websocket();
7065
+ var { GUID, kWebSocket } = require_constants();
7066
+ var keyRegex = /^[+/0-9A-Za-z]{22}==$/;
7067
+ var RUNNING = 0;
7068
+ var CLOSING = 1;
7069
+ var CLOSED = 2;
7070
+ var WebSocketServer2 = class extends EventEmitter {
7071
+ /**
7072
+ * Create a `WebSocketServer` instance.
7073
+ *
7074
+ * @param {Object} options Configuration options
7075
+ * @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether
7076
+ * any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
7077
+ * multiple times in the same tick
7078
+ * @param {Boolean} [options.autoPong=true] Specifies whether or not to
7079
+ * automatically send a pong in response to a ping
7080
+ * @param {Number} [options.backlog=511] The maximum length of the queue of
7081
+ * pending connections
7082
+ * @param {Boolean} [options.clientTracking=true] Specifies whether or not to
7083
+ * track clients
7084
+ * @param {Function} [options.handleProtocols] A hook to handle protocols
7085
+ * @param {String} [options.host] The hostname where to bind the server
7086
+ * @param {Number} [options.maxPayload=104857600] The maximum allowed message
7087
+ * size
7088
+ * @param {Boolean} [options.noServer=false] Enable no server mode
7089
+ * @param {String} [options.path] Accept only connections matching this path
7090
+ * @param {(Boolean|Object)} [options.perMessageDeflate=false] Enable/disable
7091
+ * permessage-deflate
7092
+ * @param {Number} [options.port] The port where to bind the server
7093
+ * @param {(http.Server|https.Server)} [options.server] A pre-created HTTP/S
7094
+ * server to use
7095
+ * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
7096
+ * not to skip UTF-8 validation for text and close messages
7097
+ * @param {Function} [options.verifyClient] A hook to reject connections
7098
+ * @param {Function} [options.WebSocket=WebSocket] Specifies the `WebSocket`
7099
+ * class to use. It must be the `WebSocket` class or class that extends it
7100
+ * @param {Function} [callback] A listener for the `listening` event
7101
+ */
7102
+ constructor(options, callback) {
7103
+ super();
7104
+ options = {
7105
+ allowSynchronousEvents: true,
7106
+ autoPong: true,
7107
+ maxPayload: 100 * 1024 * 1024,
7108
+ skipUTF8Validation: false,
7109
+ perMessageDeflate: false,
7110
+ handleProtocols: null,
7111
+ clientTracking: true,
7112
+ verifyClient: null,
7113
+ noServer: false,
7114
+ backlog: null,
7115
+ // use default (511 as implemented in net.js)
7116
+ server: null,
7117
+ host: null,
7118
+ path: null,
7119
+ port: null,
7120
+ WebSocket: WebSocket2,
7121
+ ...options
7122
+ };
7123
+ if (options.port == null && !options.server && !options.noServer || options.port != null && (options.server || options.noServer) || options.server && options.noServer) {
7124
+ throw new TypeError(
7125
+ 'One and only one of the "port", "server", or "noServer" options must be specified'
7126
+ );
7127
+ }
7128
+ if (options.port != null) {
7129
+ this._server = http2.createServer((req, res) => {
7130
+ const body = http2.STATUS_CODES[426];
7131
+ res.writeHead(426, {
7132
+ "Content-Length": body.length,
7133
+ "Content-Type": "text/plain"
7134
+ });
7135
+ res.end(body);
7136
+ });
7137
+ this._server.listen(
7138
+ options.port,
7139
+ options.host,
7140
+ options.backlog,
7141
+ callback
7142
+ );
7143
+ } else if (options.server) {
7144
+ this._server = options.server;
7145
+ }
7146
+ if (this._server) {
7147
+ const emitConnection = this.emit.bind(this, "connection");
7148
+ this._removeListeners = addListeners(this._server, {
7149
+ listening: this.emit.bind(this, "listening"),
7150
+ error: this.emit.bind(this, "error"),
7151
+ upgrade: (req, socket, head) => {
7152
+ this.handleUpgrade(req, socket, head, emitConnection);
7153
+ }
7154
+ });
7155
+ }
7156
+ if (options.perMessageDeflate === true) options.perMessageDeflate = {};
7157
+ if (options.clientTracking) {
7158
+ this.clients = /* @__PURE__ */ new Set();
7159
+ this._shouldEmitClose = false;
7160
+ }
7161
+ this.options = options;
7162
+ this._state = RUNNING;
7163
+ }
7164
+ /**
7165
+ * Returns the bound address, the address family name, and port of the server
7166
+ * as reported by the operating system if listening on an IP socket.
7167
+ * If the server is listening on a pipe or UNIX domain socket, the name is
7168
+ * returned as a string.
7169
+ *
7170
+ * @return {(Object|String|null)} The address of the server
7171
+ * @public
7172
+ */
7173
+ address() {
7174
+ if (this.options.noServer) {
7175
+ throw new Error('The server is operating in "noServer" mode');
7176
+ }
7177
+ if (!this._server) return null;
7178
+ return this._server.address();
7179
+ }
7180
+ /**
7181
+ * Stop the server from accepting new connections and emit the `'close'` event
7182
+ * when all existing connections are closed.
7183
+ *
7184
+ * @param {Function} [cb] A one-time listener for the `'close'` event
7185
+ * @public
7186
+ */
7187
+ close(cb) {
7188
+ if (this._state === CLOSED) {
7189
+ if (cb) {
7190
+ this.once("close", () => {
7191
+ cb(new Error("The server is not running"));
7192
+ });
7193
+ }
7194
+ process.nextTick(emitClose, this);
7195
+ return;
7196
+ }
7197
+ if (cb) this.once("close", cb);
7198
+ if (this._state === CLOSING) return;
7199
+ this._state = CLOSING;
7200
+ if (this.options.noServer || this.options.server) {
7201
+ if (this._server) {
7202
+ this._removeListeners();
7203
+ this._removeListeners = this._server = null;
7204
+ }
7205
+ if (this.clients) {
7206
+ if (!this.clients.size) {
7207
+ process.nextTick(emitClose, this);
7208
+ } else {
7209
+ this._shouldEmitClose = true;
7210
+ }
7211
+ } else {
7212
+ process.nextTick(emitClose, this);
7213
+ }
7214
+ } else {
7215
+ const server = this._server;
7216
+ this._removeListeners();
7217
+ this._removeListeners = this._server = null;
7218
+ server.close(() => {
7219
+ emitClose(this);
7220
+ });
7221
+ }
7222
+ }
7223
+ /**
7224
+ * See if a given request should be handled by this server instance.
7225
+ *
7226
+ * @param {http.IncomingMessage} req Request object to inspect
7227
+ * @return {Boolean} `true` if the request is valid, else `false`
7228
+ * @public
7229
+ */
7230
+ shouldHandle(req) {
7231
+ if (this.options.path) {
7232
+ const index = req.url.indexOf("?");
7233
+ const pathname = index !== -1 ? req.url.slice(0, index) : req.url;
7234
+ if (pathname !== this.options.path) return false;
7235
+ }
7236
+ return true;
7237
+ }
7238
+ /**
7239
+ * Handle a HTTP Upgrade request.
7240
+ *
7241
+ * @param {http.IncomingMessage} req The request object
7242
+ * @param {Duplex} socket The network socket between the server and client
7243
+ * @param {Buffer} head The first packet of the upgraded stream
7244
+ * @param {Function} cb Callback
7245
+ * @public
7246
+ */
7247
+ handleUpgrade(req, socket, head, cb) {
7248
+ socket.on("error", socketOnError);
7249
+ const key = req.headers["sec-websocket-key"];
7250
+ const upgrade = req.headers.upgrade;
7251
+ const version2 = +req.headers["sec-websocket-version"];
7252
+ if (req.method !== "GET") {
7253
+ const message = "Invalid HTTP method";
7254
+ abortHandshakeOrEmitwsClientError(this, req, socket, 405, message);
7255
+ return;
7256
+ }
7257
+ if (upgrade === void 0 || upgrade.toLowerCase() !== "websocket") {
7258
+ const message = "Invalid Upgrade header";
7259
+ abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
7260
+ return;
7261
+ }
7262
+ if (key === void 0 || !keyRegex.test(key)) {
7263
+ const message = "Missing or invalid Sec-WebSocket-Key header";
7264
+ abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
7265
+ return;
7266
+ }
7267
+ if (version2 !== 8 && version2 !== 13) {
7268
+ const message = "Missing or invalid Sec-WebSocket-Version header";
7269
+ abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
7270
+ return;
7271
+ }
7272
+ if (!this.shouldHandle(req)) {
7273
+ abortHandshake(socket, 400);
7274
+ return;
7275
+ }
7276
+ const secWebSocketProtocol = req.headers["sec-websocket-protocol"];
7277
+ let protocols = /* @__PURE__ */ new Set();
7278
+ if (secWebSocketProtocol !== void 0) {
7279
+ try {
7280
+ protocols = subprotocol.parse(secWebSocketProtocol);
7281
+ } catch (err2) {
7282
+ const message = "Invalid Sec-WebSocket-Protocol header";
7283
+ abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
7284
+ return;
7285
+ }
7286
+ }
7287
+ const secWebSocketExtensions = req.headers["sec-websocket-extensions"];
7288
+ const extensions = {};
7289
+ if (this.options.perMessageDeflate && secWebSocketExtensions !== void 0) {
7290
+ const perMessageDeflate = new PerMessageDeflate(
7291
+ this.options.perMessageDeflate,
7292
+ true,
7293
+ this.options.maxPayload
7294
+ );
7295
+ try {
7296
+ const offers = extension.parse(secWebSocketExtensions);
7297
+ if (offers[PerMessageDeflate.extensionName]) {
7298
+ perMessageDeflate.accept(offers[PerMessageDeflate.extensionName]);
7299
+ extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
7300
+ }
7301
+ } catch (err2) {
7302
+ const message = "Invalid or unacceptable Sec-WebSocket-Extensions header";
7303
+ abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
7304
+ return;
7305
+ }
7306
+ }
7307
+ if (this.options.verifyClient) {
7308
+ const info = {
7309
+ origin: req.headers[`${version2 === 8 ? "sec-websocket-origin" : "origin"}`],
7310
+ secure: !!(req.socket.authorized || req.socket.encrypted),
7311
+ req
7312
+ };
7313
+ if (this.options.verifyClient.length === 2) {
7314
+ this.options.verifyClient(info, (verified, code, message, headers) => {
7315
+ if (!verified) {
7316
+ return abortHandshake(socket, code || 401, message, headers);
7317
+ }
7318
+ this.completeUpgrade(
7319
+ extensions,
7320
+ key,
7321
+ protocols,
7322
+ req,
7323
+ socket,
7324
+ head,
7325
+ cb
7326
+ );
7327
+ });
7328
+ return;
7329
+ }
7330
+ if (!this.options.verifyClient(info)) return abortHandshake(socket, 401);
7331
+ }
7332
+ this.completeUpgrade(extensions, key, protocols, req, socket, head, cb);
7333
+ }
7334
+ /**
7335
+ * Upgrade the connection to WebSocket.
7336
+ *
7337
+ * @param {Object} extensions The accepted extensions
7338
+ * @param {String} key The value of the `Sec-WebSocket-Key` header
7339
+ * @param {Set} protocols The subprotocols
7340
+ * @param {http.IncomingMessage} req The request object
7341
+ * @param {Duplex} socket The network socket between the server and client
7342
+ * @param {Buffer} head The first packet of the upgraded stream
7343
+ * @param {Function} cb Callback
7344
+ * @throws {Error} If called more than once with the same socket
7345
+ * @private
7346
+ */
7347
+ completeUpgrade(extensions, key, protocols, req, socket, head, cb) {
7348
+ if (!socket.readable || !socket.writable) return socket.destroy();
7349
+ if (socket[kWebSocket]) {
7350
+ throw new Error(
7351
+ "server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration"
7352
+ );
7353
+ }
7354
+ if (this._state > RUNNING) return abortHandshake(socket, 503);
7355
+ const digest = createHash("sha1").update(key + GUID).digest("base64");
7356
+ const headers = [
7357
+ "HTTP/1.1 101 Switching Protocols",
7358
+ "Upgrade: websocket",
7359
+ "Connection: Upgrade",
7360
+ `Sec-WebSocket-Accept: ${digest}`
7361
+ ];
7362
+ const ws = new this.options.WebSocket(null, void 0, this.options);
7363
+ if (protocols.size) {
7364
+ const protocol = this.options.handleProtocols ? this.options.handleProtocols(protocols, req) : protocols.values().next().value;
7365
+ if (protocol) {
7366
+ headers.push(`Sec-WebSocket-Protocol: ${protocol}`);
7367
+ ws._protocol = protocol;
7368
+ }
7369
+ }
7370
+ if (extensions[PerMessageDeflate.extensionName]) {
7371
+ const params = extensions[PerMessageDeflate.extensionName].params;
7372
+ const value = extension.format({
7373
+ [PerMessageDeflate.extensionName]: [params]
7374
+ });
7375
+ headers.push(`Sec-WebSocket-Extensions: ${value}`);
7376
+ ws._extensions = extensions;
7377
+ }
7378
+ this.emit("headers", headers, req);
7379
+ socket.write(headers.concat("\r\n").join("\r\n"));
7380
+ socket.removeListener("error", socketOnError);
7381
+ ws.setSocket(socket, head, {
7382
+ allowSynchronousEvents: this.options.allowSynchronousEvents,
7383
+ maxPayload: this.options.maxPayload,
7384
+ skipUTF8Validation: this.options.skipUTF8Validation
7385
+ });
7386
+ if (this.clients) {
7387
+ this.clients.add(ws);
7388
+ ws.on("close", () => {
7389
+ this.clients.delete(ws);
7390
+ if (this._shouldEmitClose && !this.clients.size) {
7391
+ process.nextTick(emitClose, this);
7392
+ }
7393
+ });
7394
+ }
7395
+ cb(ws, req);
7396
+ }
7397
+ };
7398
+ module2.exports = WebSocketServer2;
7399
+ function addListeners(server, map2) {
7400
+ for (const event of Object.keys(map2)) server.on(event, map2[event]);
7401
+ return function removeListeners() {
7402
+ for (const event of Object.keys(map2)) {
7403
+ server.removeListener(event, map2[event]);
7404
+ }
7405
+ };
7406
+ }
7407
+ function emitClose(server) {
7408
+ server._state = CLOSED;
7409
+ server.emit("close");
7410
+ }
7411
+ function socketOnError() {
7412
+ this.destroy();
7413
+ }
7414
+ function abortHandshake(socket, code, message, headers) {
7415
+ message = message || http2.STATUS_CODES[code];
7416
+ headers = {
7417
+ Connection: "close",
7418
+ "Content-Type": "text/html",
7419
+ "Content-Length": Buffer.byteLength(message),
7420
+ ...headers
7421
+ };
7422
+ socket.once("finish", socket.destroy);
7423
+ socket.end(
7424
+ `HTTP/1.1 ${code} ${http2.STATUS_CODES[code]}\r
7425
+ ` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join("\r\n") + "\r\n\r\n" + message
7426
+ );
7427
+ }
7428
+ function abortHandshakeOrEmitwsClientError(server, req, socket, code, message) {
7429
+ if (server.listenerCount("wsClientError")) {
7430
+ const err2 = new Error(message);
7431
+ Error.captureStackTrace(err2, abortHandshakeOrEmitwsClientError);
7432
+ server.emit("wsClientError", err2, socket, req);
7433
+ } else {
7434
+ abortHandshake(socket, code, message);
7435
+ }
7436
+ }
7437
+ }
7438
+ });
7439
+
3944
7440
  // build/dev-server/server-process.js
3945
7441
  var server_process_exports = {};
3946
7442
  __export(server_process_exports, {
@@ -4167,7 +7663,7 @@ var DEV_SERVER_INIT_URL = `${DEV_SERVER_URL}-init`;
4167
7663
  var OPEN_IN_EDITOR_URL = `${DEV_SERVER_URL}-open-in-editor`;
4168
7664
 
4169
7665
  // build/version.js
4170
- var version = "4.30.0";
7666
+ var version = "4.31.0-dev.1746680515.992a687";
4171
7667
 
4172
7668
  // build/dev-server/content-types-db.json
4173
7669
  var content_types_db_default = { "123": "application/vnd.lotus-1-2-3", "1km": "application/vnd.1000minds.decision-model+xml", "3dml": "text/vnd.in3d.3dml", "3ds": "image/x-3ds", "3g2": "video/3gpp2", "3gp": "video/3gpp", "3gpp": "video/3gpp", "3mf": "model/3mf", "7z": "application/x-7z-compressed", "aab": "application/x-authorware-bin", "aac": "audio/x-aac", "aam": "application/x-authorware-map", "aas": "application/x-authorware-seg", "abw": "application/x-abiword", "ac": "application/vnd.nokia.n-gage.ac+xml", "acc": "application/vnd.americandynamics.acc", "ace": "application/x-ace-compressed", "acu": "application/vnd.acucobol", "acutc": "application/vnd.acucorp", "adp": "audio/adpcm", "adts": "audio/aac", "aep": "application/vnd.audiograph", "afm": "application/x-font-type1", "afp": "application/vnd.ibm.modcap", "age": "application/vnd.age", "ahead": "application/vnd.ahead.space", "ai": "application/postscript", "aif": "audio/x-aiff", "aifc": "audio/x-aiff", "aiff": "audio/x-aiff", "air": "application/vnd.adobe.air-application-installer-package+zip", "ait": "application/vnd.dvb.ait", "ami": "application/vnd.amiga.ami", "aml": "application/automationml-aml+xml", "amlx": "application/automationml-amlx+zip", "amr": "audio/amr", "apk": "application/vnd.android.package-archive", "apng": "image/apng", "appcache": "text/cache-manifest", "appinstaller": "application/appinstaller", "application": "application/x-ms-application", "appx": "application/appx", "appxbundle": "application/appxbundle", "apr": "application/vnd.lotus-approach", "arc": "application/x-freearc", "arj": "application/x-arj", "asc": "application/pgp-signature", "asf": "video/x-ms-asf", "asm": "text/x-asm", "aso": "application/vnd.accpac.simply.aso", "asx": "video/x-ms-asf", "atc": "application/vnd.acucorp", "atom": "application/atom+xml", "atomcat": "application/atomcat+xml", "atomdeleted": "application/atomdeleted+xml", "atomsvc": "application/atomsvc+xml", "atx": "application/vnd.antix.game-component", "au": "audio/basic", "avci": "image/avci", "avcs": "image/avcs", "avi": "video/x-msvideo", "avif": "image/avif", "aw": "application/applixware", "azf": "application/vnd.airzip.filesecure.azf", "azs": "application/vnd.airzip.filesecure.azs", "azv": "image/vnd.airzip.accelerator.azv", "azw": "application/vnd.amazon.ebook", "b16": "image/vnd.pco.b16", "bary": "model/vnd.bary", "bat": "application/x-msdownload", "bcpio": "application/x-bcpio", "bdf": "application/x-font-bdf", "bdm": "application/vnd.syncml.dm+wbxml", "bdo": "application/vnd.nato.bindingdataobject+xml", "bdoc": "application/x-bdoc", "bed": "application/vnd.realvnc.bed", "bh2": "application/vnd.fujitsu.oasysprs", "bin": "application/octet-stream", "blb": "application/x-blorb", "blorb": "application/x-blorb", "bmi": "application/vnd.bmi", "bmml": "application/vnd.balsamiq.bmml+xml", "bmp": "image/x-ms-bmp", "book": "application/vnd.framemaker", "box": "application/vnd.previewsystems.box", "boz": "application/x-bzip2", "bpk": "application/octet-stream", "bsp": "model/vnd.valve.source.compiled-map", "btf": "image/prs.btif", "btif": "image/prs.btif", "buffer": "application/octet-stream", "bz": "application/x-bzip", "bz2": "application/x-bzip2", "c": "text/x-c", "c11amc": "application/vnd.cluetrust.cartomobile-config", "c11amz": "application/vnd.cluetrust.cartomobile-config-pkg", "c4d": "application/vnd.clonk.c4group", "c4f": "application/vnd.clonk.c4group", "c4g": "application/vnd.clonk.c4group", "c4p": "application/vnd.clonk.c4group", "c4u": "application/vnd.clonk.c4group", "cab": "application/vnd.ms-cab-compressed", "caf": "audio/x-caf", "cap": "application/vnd.tcpdump.pcap", "car": "application/vnd.curl.car", "cat": "application/vnd.ms-pki.seccat", "cb7": "application/x-cbr", "cba": "application/x-cbr", "cbr": "application/x-cbr", "cbt": "application/x-cbr", "cbz": "application/x-cbr", "cc": "text/x-c", "cco": "application/x-cocoa", "cct": "application/x-director", "ccxml": "application/ccxml+xml", "cdbcmsg": "application/vnd.contact.cmsg", "cdf": "application/x-netcdf", "cdfx": "application/cdfx+xml", "cdkey": "application/vnd.mediastation.cdkey", "cdmia": "application/cdmi-capability", "cdmic": "application/cdmi-container", "cdmid": "application/cdmi-domain", "cdmio": "application/cdmi-object", "cdmiq": "application/cdmi-queue", "cdx": "chemical/x-cdx", "cdxml": "application/vnd.chemdraw+xml", "cdy": "application/vnd.cinderella", "cer": "application/pkix-cert", "cfs": "application/x-cfs-compressed", "cgm": "image/cgm", "chat": "application/x-chat", "chm": "application/vnd.ms-htmlhelp", "chrt": "application/vnd.kde.kchart", "cif": "chemical/x-cif", "cii": "application/vnd.anser-web-certificate-issue-initiation", "cil": "application/vnd.ms-artgalry", "cjs": "application/node", "cla": "application/vnd.claymore", "class": "application/java-vm", "cld": "model/vnd.cld", "clkk": "application/vnd.crick.clicker.keyboard", "clkp": "application/vnd.crick.clicker.palette", "clkt": "application/vnd.crick.clicker.template", "clkw": "application/vnd.crick.clicker.wordbank", "clkx": "application/vnd.crick.clicker", "clp": "application/x-msclip", "cmc": "application/vnd.cosmocaller", "cmdf": "chemical/x-cmdf", "cml": "chemical/x-cml", "cmp": "application/vnd.yellowriver-custom-menu", "cmx": "image/x-cmx", "cod": "application/vnd.rim.cod", "coffee": "text/coffeescript", "com": "application/x-msdownload", "conf": "text/plain", "cpio": "application/x-cpio", "cpl": "application/cpl+xml", "cpp": "text/x-c", "cpt": "application/mac-compactpro", "crd": "application/x-mscardfile", "crl": "application/pkix-crl", "crt": "application/x-x509-ca-cert", "crx": "application/x-chrome-extension", "cryptonote": "application/vnd.rig.cryptonote", "csh": "application/x-csh", "csl": "application/vnd.citationstyles.style+xml", "csml": "chemical/x-csml", "csp": "application/vnd.commonspace", "css": "text/css", "cst": "application/x-director", "csv": "text/csv", "cu": "application/cu-seeme", "curl": "text/vnd.curl", "cwl": "application/cwl", "cww": "application/prs.cww", "cxt": "application/x-director", "cxx": "text/x-c", "dae": "model/vnd.collada+xml", "daf": "application/vnd.mobius.daf", "dart": "application/vnd.dart", "dataless": "application/vnd.fdsn.seed", "davmount": "application/davmount+xml", "dbf": "application/vnd.dbf", "dbk": "application/docbook+xml", "dcr": "application/x-director", "dcurl": "text/vnd.curl.dcurl", "dd2": "application/vnd.oma.dd2+xml", "ddd": "application/vnd.fujixerox.ddd", "ddf": "application/vnd.syncml.dmddf+xml", "dds": "image/vnd.ms-dds", "deb": "application/x-debian-package", "def": "text/plain", "deploy": "application/octet-stream", "der": "application/x-x509-ca-cert", "dfac": "application/vnd.dreamfactory", "dgc": "application/x-dgc-compressed", "dib": "image/bmp", "dic": "text/x-c", "dir": "application/x-director", "dis": "application/vnd.mobius.dis", "disposition-notification": "message/disposition-notification", "dist": "application/octet-stream", "distz": "application/octet-stream", "djv": "image/vnd.djvu", "djvu": "image/vnd.djvu", "dll": "application/x-msdownload", "dmg": "application/x-apple-diskimage", "dmp": "application/vnd.tcpdump.pcap", "dms": "application/octet-stream", "dna": "application/vnd.dna", "doc": "application/msword", "docm": "application/vnd.ms-word.document.macroenabled.12", "docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "dot": "application/msword", "dotm": "application/vnd.ms-word.template.macroenabled.12", "dotx": "application/vnd.openxmlformats-officedocument.wordprocessingml.template", "dp": "application/vnd.osgi.dp", "dpg": "application/vnd.dpgraph", "dpx": "image/dpx", "dra": "audio/vnd.dra", "drle": "image/dicom-rle", "dsc": "text/prs.lines.tag", "dssc": "application/dssc+der", "dtb": "application/x-dtbook+xml", "dtd": "application/xml-dtd", "dts": "audio/vnd.dts", "dtshd": "audio/vnd.dts.hd", "dump": "application/octet-stream", "dvb": "video/vnd.dvb.file", "dvi": "application/x-dvi", "dwd": "application/atsc-dwd+xml", "dwf": "model/vnd.dwf", "dwg": "image/vnd.dwg", "dxf": "image/vnd.dxf", "dxp": "application/vnd.spotfire.dxp", "dxr": "application/x-director", "ear": "application/java-archive", "ecelp4800": "audio/vnd.nuera.ecelp4800", "ecelp7470": "audio/vnd.nuera.ecelp7470", "ecelp9600": "audio/vnd.nuera.ecelp9600", "ecma": "application/ecmascript", "edm": "application/vnd.novadigm.edm", "edx": "application/vnd.novadigm.edx", "efif": "application/vnd.picsel", "ei6": "application/vnd.pg.osasli", "elc": "application/octet-stream", "emf": "image/emf", "eml": "message/rfc822", "emma": "application/emma+xml", "emotionml": "application/emotionml+xml", "emz": "application/x-msmetafile", "eol": "audio/vnd.digital-winds", "eot": "application/vnd.ms-fontobject", "eps": "application/postscript", "epub": "application/epub+zip", "es3": "application/vnd.eszigno3+xml", "esa": "application/vnd.osgi.subsystem", "esf": "application/vnd.epson.esf", "et3": "application/vnd.eszigno3+xml", "etx": "text/x-setext", "eva": "application/x-eva", "evy": "application/x-envoy", "exe": "application/x-msdownload", "exi": "application/exi", "exp": "application/express", "exr": "image/aces", "ext": "application/vnd.novadigm.ext", "ez": "application/andrew-inset", "ez2": "application/vnd.ezpix-album", "ez3": "application/vnd.ezpix-package", "f": "text/x-fortran", "f4v": "video/x-f4v", "f77": "text/x-fortran", "f90": "text/x-fortran", "fbs": "image/vnd.fastbidsheet", "fcdt": "application/vnd.adobe.formscentral.fcdt", "fcs": "application/vnd.isac.fcs", "fdf": "application/vnd.fdf", "fdt": "application/fdt+xml", "fe_launch": "application/vnd.denovo.fcselayout-link", "fg5": "application/vnd.fujitsu.oasysgp", "fgd": "application/x-director", "fh": "image/x-freehand", "fh4": "image/x-freehand", "fh5": "image/x-freehand", "fh7": "image/x-freehand", "fhc": "image/x-freehand", "fig": "application/x-xfig", "fits": "image/fits", "flac": "audio/x-flac", "fli": "video/x-fli", "flo": "application/vnd.micrografx.flo", "flv": "video/x-flv", "flw": "application/vnd.kde.kivio", "flx": "text/vnd.fmi.flexstor", "fly": "text/vnd.fly", "fm": "application/vnd.framemaker", "fnc": "application/vnd.frogans.fnc", "fo": "application/vnd.software602.filler.form+xml", "for": "text/x-fortran", "fpx": "image/vnd.fpx", "frame": "application/vnd.framemaker", "fsc": "application/vnd.fsc.weblaunch", "fst": "image/vnd.fst", "ftc": "application/vnd.fluxtime.clip", "fti": "application/vnd.anser-web-funds-transfer-initiation", "fvt": "video/vnd.fvt", "fxp": "application/vnd.adobe.fxp", "fxpl": "application/vnd.adobe.fxp", "fzs": "application/vnd.fuzzysheet", "g2w": "application/vnd.geoplan", "g3": "image/g3fax", "g3w": "application/vnd.geospace", "gac": "application/vnd.groove-account", "gam": "application/x-tads", "gbr": "application/rpki-ghostbusters", "gca": "application/x-gca-compressed", "gdl": "model/vnd.gdl", "gdoc": "application/vnd.google-apps.document", "ged": "text/vnd.familysearch.gedcom", "geo": "application/vnd.dynageo", "geojson": "application/geo+json", "gex": "application/vnd.geometry-explorer", "ggb": "application/vnd.geogebra.file", "ggs": "application/vnd.geogebra.slides", "ggt": "application/vnd.geogebra.tool", "ghf": "application/vnd.groove-help", "gif": "image/gif", "gim": "application/vnd.groove-identity-message", "glb": "model/gltf-binary", "gltf": "model/gltf+json", "gml": "application/gml+xml", "gmx": "application/vnd.gmx", "gnumeric": "application/x-gnumeric", "gph": "application/vnd.flographit", "gpx": "application/gpx+xml", "gqf": "application/vnd.grafeq", "gqs": "application/vnd.grafeq", "gram": "application/srgs", "gramps": "application/x-gramps-xml", "gre": "application/vnd.geometry-explorer", "grv": "application/vnd.groove-injector", "grxml": "application/srgs+xml", "gsf": "application/x-font-ghostscript", "gsheet": "application/vnd.google-apps.spreadsheet", "gslides": "application/vnd.google-apps.presentation", "gtar": "application/x-gtar", "gtm": "application/vnd.groove-tool-message", "gtw": "model/vnd.gtw", "gv": "text/vnd.graphviz", "gxf": "application/gxf", "gxt": "application/vnd.geonext", "gz": "application/gzip", "h": "text/x-c", "h261": "video/h261", "h263": "video/h263", "h264": "video/h264", "hal": "application/vnd.hal+xml", "hbci": "application/vnd.hbci", "hbs": "text/x-handlebars-template", "hdd": "application/x-virtualbox-hdd", "hdf": "application/x-hdf", "heic": "image/heic", "heics": "image/heic-sequence", "heif": "image/heif", "heifs": "image/heif-sequence", "hej2": "image/hej2k", "held": "application/atsc-held+xml", "hh": "text/x-c", "hjson": "application/hjson", "hlp": "application/winhlp", "hpgl": "application/vnd.hp-hpgl", "hpid": "application/vnd.hp-hpid", "hps": "application/vnd.hp-hps", "hqx": "application/mac-binhex40", "hsj2": "image/hsj2", "htc": "text/x-component", "htke": "application/vnd.kenameaapp", "htm": "text/html", "html": "text/html", "hvd": "application/vnd.yamaha.hv-dic", "hvp": "application/vnd.yamaha.hv-voice", "hvs": "application/vnd.yamaha.hv-script", "i2g": "application/vnd.intergeo", "icc": "application/vnd.iccprofile", "ice": "x-conference/x-cooltalk", "icm": "application/vnd.iccprofile", "ico": "image/x-icon", "ics": "text/calendar", "ief": "image/ief", "ifb": "text/calendar", "ifm": "application/vnd.shana.informed.formdata", "iges": "model/iges", "igl": "application/vnd.igloader", "igm": "application/vnd.insors.igm", "igs": "model/iges", "igx": "application/vnd.micrografx.igx", "iif": "application/vnd.shana.informed.interchange", "img": "application/octet-stream", "imp": "application/vnd.accpac.simply.imp", "ims": "application/vnd.ms-ims", "in": "text/plain", "ini": "text/plain", "ink": "application/inkml+xml", "inkml": "application/inkml+xml", "install": "application/x-install-instructions", "iota": "application/vnd.astraea-software.iota", "ipfix": "application/ipfix", "ipk": "application/vnd.shana.informed.package", "irm": "application/vnd.ibm.rights-management", "irp": "application/vnd.irepository.package+xml", "iso": "application/x-iso9660-image", "itp": "application/vnd.shana.informed.formtemplate", "its": "application/its+xml", "ivp": "application/vnd.immervision-ivp", "ivu": "application/vnd.immervision-ivu", "jad": "text/vnd.sun.j2me.app-descriptor", "jade": "text/jade", "jam": "application/vnd.jam", "jar": "application/java-archive", "jardiff": "application/x-java-archive-diff", "java": "text/x-java-source", "jhc": "image/jphc", "jisp": "application/vnd.jisp", "jls": "image/jls", "jlt": "application/vnd.hp-jlyt", "jng": "image/x-jng", "jnlp": "application/x-java-jnlp-file", "joda": "application/vnd.joost.joda-archive", "jp2": "image/jp2", "jpe": "image/jpeg", "jpeg": "image/jpeg", "jpf": "image/jpx", "jpg": "image/jpeg", "jpg2": "image/jp2", "jpgm": "video/jpm", "jpgv": "video/jpeg", "jph": "image/jph", "jpm": "video/jpm", "jpx": "image/jpx", "js": "text/javascript", "json": "application/json", "json5": "application/json5", "jsonld": "application/ld+json", "jsonml": "application/jsonml+json", "jsx": "text/jsx", "jt": "model/jt", "jxl": "image/jxl", "jxr": "image/jxr", "jxra": "image/jxra", "jxrs": "image/jxrs", "jxs": "image/jxs", "jxsc": "image/jxsc", "jxsi": "image/jxsi", "jxss": "image/jxss", "kar": "audio/midi", "karbon": "application/vnd.kde.karbon", "kdbx": "application/x-keepass2", "key": "application/x-iwork-keynote-sffkey", "kfo": "application/vnd.kde.kformula", "kia": "application/vnd.kidspiration", "kml": "application/vnd.google-earth.kml+xml", "kmz": "application/vnd.google-earth.kmz", "kne": "application/vnd.kinar", "knp": "application/vnd.kinar", "kon": "application/vnd.kde.kontour", "kpr": "application/vnd.kde.kpresenter", "kpt": "application/vnd.kde.kpresenter", "kpxx": "application/vnd.ds-keypoint", "ksp": "application/vnd.kde.kspread", "ktr": "application/vnd.kahootz", "ktx": "image/ktx", "ktx2": "image/ktx2", "ktz": "application/vnd.kahootz", "kwd": "application/vnd.kde.kword", "kwt": "application/vnd.kde.kword", "lasxml": "application/vnd.las.las+xml", "latex": "application/x-latex", "lbd": "application/vnd.llamagraphics.life-balance.desktop", "lbe": "application/vnd.llamagraphics.life-balance.exchange+xml", "les": "application/vnd.hhe.lesson-player", "less": "text/less", "lgr": "application/lgr+xml", "lha": "application/x-lzh-compressed", "link66": "application/vnd.route66.link66+xml", "list": "text/plain", "list3820": "application/vnd.ibm.modcap", "listafp": "application/vnd.ibm.modcap", "litcoffee": "text/coffeescript", "lnk": "application/x-ms-shortcut", "log": "text/plain", "lostxml": "application/lost+xml", "lrf": "application/octet-stream", "lrm": "application/vnd.ms-lrm", "ltf": "application/vnd.frogans.ltf", "lua": "text/x-lua", "luac": "application/x-lua-bytecode", "lvp": "audio/vnd.lucent.voice", "lwp": "application/vnd.lotus-wordpro", "lzh": "application/x-lzh-compressed", "m13": "application/x-msmediaview", "m14": "application/x-msmediaview", "m1v": "video/mpeg", "m21": "application/mp21", "m2a": "audio/mpeg", "m2t": "video/mp2t", "m2ts": "video/mp2t", "m2v": "video/mpeg", "m3a": "audio/mpeg", "m3u": "audio/x-mpegurl", "m3u8": "application/vnd.apple.mpegurl", "m4a": "audio/x-m4a", "m4p": "application/mp4", "m4s": "video/iso.segment", "m4u": "video/vnd.mpegurl", "m4v": "video/x-m4v", "ma": "application/mathematica", "mads": "application/mads+xml", "maei": "application/mmt-aei+xml", "mag": "application/vnd.ecowin.chart", "maker": "application/vnd.framemaker", "man": "text/troff", "manifest": "text/cache-manifest", "map": "application/json", "mar": "application/octet-stream", "markdown": "text/markdown", "mathml": "application/mathml+xml", "mb": "application/mathematica", "mbk": "application/vnd.mobius.mbk", "mbox": "application/mbox", "mc1": "application/vnd.medcalcdata", "mcd": "application/vnd.mcd", "mcurl": "text/vnd.curl.mcurl", "md": "text/markdown", "mdb": "application/x-msaccess", "mdi": "image/vnd.ms-modi", "mdx": "text/mdx", "me": "text/troff", "mesh": "model/mesh", "meta4": "application/metalink4+xml", "metalink": "application/metalink+xml", "mets": "application/mets+xml", "mfm": "application/vnd.mfmp", "mft": "application/rpki-manifest", "mgp": "application/vnd.osgeo.mapguide.package", "mgz": "application/vnd.proteus.magazine", "mid": "audio/midi", "midi": "audio/midi", "mie": "application/x-mie", "mif": "application/vnd.mif", "mime": "message/rfc822", "mj2": "video/mj2", "mjp2": "video/mj2", "mjs": "text/javascript", "mk3d": "video/x-matroska", "mka": "audio/x-matroska", "mkd": "text/x-markdown", "mks": "video/x-matroska", "mkv": "video/x-matroska", "mlp": "application/vnd.dolby.mlp", "mmd": "application/vnd.chipnuts.karaoke-mmd", "mmf": "application/vnd.smaf", "mml": "text/mathml", "mmr": "image/vnd.fujixerox.edmics-mmr", "mng": "video/x-mng", "mny": "application/x-msmoney", "mobi": "application/x-mobipocket-ebook", "mods": "application/mods+xml", "mov": "video/quicktime", "movie": "video/x-sgi-movie", "mp2": "audio/mpeg", "mp21": "application/mp21", "mp2a": "audio/mpeg", "mp3": "audio/mpeg", "mp4": "video/mp4", "mp4a": "audio/mp4", "mp4s": "application/mp4", "mp4v": "video/mp4", "mpc": "application/vnd.mophun.certificate", "mpd": "application/dash+xml", "mpe": "video/mpeg", "mpeg": "video/mpeg", "mpf": "application/media-policy-dataset+xml", "mpg": "video/mpeg", "mpg4": "video/mp4", "mpga": "audio/mpeg", "mpkg": "application/vnd.apple.installer+xml", "mpm": "application/vnd.blueice.multipass", "mpn": "application/vnd.mophun.application", "mpp": "application/vnd.ms-project", "mpt": "application/vnd.ms-project", "mpy": "application/vnd.ibm.minipay", "mqy": "application/vnd.mobius.mqy", "mrc": "application/marc", "mrcx": "application/marcxml+xml", "ms": "text/troff", "mscml": "application/mediaservercontrol+xml", "mseed": "application/vnd.fdsn.mseed", "mseq": "application/vnd.mseq", "msf": "application/vnd.epson.msf", "msg": "application/vnd.ms-outlook", "msh": "model/mesh", "msi": "application/x-msdownload", "msix": "application/msix", "msixbundle": "application/msixbundle", "msl": "application/vnd.mobius.msl", "msm": "application/octet-stream", "msp": "application/octet-stream", "msty": "application/vnd.muvee.style", "mtl": "model/mtl", "mts": "video/mp2t", "mus": "application/vnd.musician", "musd": "application/mmt-usd+xml", "musicxml": "application/vnd.recordare.musicxml+xml", "mvb": "application/x-msmediaview", "mvt": "application/vnd.mapbox-vector-tile", "mwf": "application/vnd.mfer", "mxf": "application/mxf", "mxl": "application/vnd.recordare.musicxml", "mxmf": "audio/mobile-xmf", "mxml": "application/xv+xml", "mxs": "application/vnd.triscape.mxs", "mxu": "video/vnd.mpegurl", "n-gage": "application/vnd.nokia.n-gage.symbian.install", "n3": "text/n3", "nb": "application/mathematica", "nbp": "application/vnd.wolfram.player", "nc": "application/x-netcdf", "ncx": "application/x-dtbncx+xml", "nfo": "text/x-nfo", "ngdat": "application/vnd.nokia.n-gage.data", "nitf": "application/vnd.nitf", "nlu": "application/vnd.neurolanguage.nlu", "nml": "application/vnd.enliven", "nnd": "application/vnd.noblenet-directory", "nns": "application/vnd.noblenet-sealer", "nnw": "application/vnd.noblenet-web", "npx": "image/vnd.net-fpx", "nq": "application/n-quads", "nsc": "application/x-conference", "nsf": "application/vnd.lotus-notes", "nt": "application/n-triples", "ntf": "application/vnd.nitf", "numbers": "application/x-iwork-numbers-sffnumbers", "nzb": "application/x-nzb", "oa2": "application/vnd.fujitsu.oasys2", "oa3": "application/vnd.fujitsu.oasys3", "oas": "application/vnd.fujitsu.oasys", "obd": "application/x-msbinder", "obgx": "application/vnd.openblox.game+xml", "obj": "model/obj", "oda": "application/oda", "odb": "application/vnd.oasis.opendocument.database", "odc": "application/vnd.oasis.opendocument.chart", "odf": "application/vnd.oasis.opendocument.formula", "odft": "application/vnd.oasis.opendocument.formula-template", "odg": "application/vnd.oasis.opendocument.graphics", "odi": "application/vnd.oasis.opendocument.image", "odm": "application/vnd.oasis.opendocument.text-master", "odp": "application/vnd.oasis.opendocument.presentation", "ods": "application/vnd.oasis.opendocument.spreadsheet", "odt": "application/vnd.oasis.opendocument.text", "oga": "audio/ogg", "ogex": "model/vnd.opengex", "ogg": "audio/ogg", "ogv": "video/ogg", "ogx": "application/ogg", "omdoc": "application/omdoc+xml", "onepkg": "application/onenote", "onetmp": "application/onenote", "onetoc": "application/onenote", "onetoc2": "application/onenote", "opf": "application/oebps-package+xml", "opml": "text/x-opml", "oprc": "application/vnd.palm", "opus": "audio/ogg", "org": "text/x-org", "osf": "application/vnd.yamaha.openscoreformat", "osfpvg": "application/vnd.yamaha.openscoreformat.osfpvg+xml", "osm": "application/vnd.openstreetmap.data+xml", "otc": "application/vnd.oasis.opendocument.chart-template", "otf": "font/otf", "otg": "application/vnd.oasis.opendocument.graphics-template", "oth": "application/vnd.oasis.opendocument.text-web", "oti": "application/vnd.oasis.opendocument.image-template", "otp": "application/vnd.oasis.opendocument.presentation-template", "ots": "application/vnd.oasis.opendocument.spreadsheet-template", "ott": "application/vnd.oasis.opendocument.text-template", "ova": "application/x-virtualbox-ova", "ovf": "application/x-virtualbox-ovf", "owl": "application/rdf+xml", "oxps": "application/oxps", "oxt": "application/vnd.openofficeorg.extension", "p": "text/x-pascal", "p10": "application/pkcs10", "p12": "application/x-pkcs12", "p7b": "application/x-pkcs7-certificates", "p7c": "application/pkcs7-mime", "p7m": "application/pkcs7-mime", "p7r": "application/x-pkcs7-certreqresp", "p7s": "application/pkcs7-signature", "p8": "application/pkcs8", "pac": "application/x-ns-proxy-autoconfig", "pages": "application/x-iwork-pages-sffpages", "pas": "text/x-pascal", "paw": "application/vnd.pawaafile", "pbd": "application/vnd.powerbuilder6", "pbm": "image/x-portable-bitmap", "pcap": "application/vnd.tcpdump.pcap", "pcf": "application/x-font-pcf", "pcl": "application/vnd.hp-pcl", "pclxl": "application/vnd.hp-pclxl", "pct": "image/x-pict", "pcurl": "application/vnd.curl.pcurl", "pcx": "image/x-pcx", "pdb": "application/x-pilot", "pde": "text/x-processing", "pdf": "application/pdf", "pem": "application/x-x509-ca-cert", "pfa": "application/x-font-type1", "pfb": "application/x-font-type1", "pfm": "application/x-font-type1", "pfr": "application/font-tdpfr", "pfx": "application/x-pkcs12", "pgm": "image/x-portable-graymap", "pgn": "application/x-chess-pgn", "pgp": "application/pgp-encrypted", "php": "application/x-httpd-php", "pic": "image/x-pict", "pkg": "application/octet-stream", "pki": "application/pkixcmp", "pkipath": "application/pkix-pkipath", "pkpass": "application/vnd.apple.pkpass", "pl": "application/x-perl", "plb": "application/vnd.3gpp.pic-bw-large", "plc": "application/vnd.mobius.plc", "plf": "application/vnd.pocketlearn", "pls": "application/pls+xml", "pm": "application/x-perl", "pml": "application/vnd.ctc-posml", "png": "image/png", "pnm": "image/x-portable-anymap", "portpkg": "application/vnd.macports.portpkg", "pot": "application/vnd.ms-powerpoint", "potm": "application/vnd.ms-powerpoint.template.macroenabled.12", "potx": "application/vnd.openxmlformats-officedocument.presentationml.template", "ppam": "application/vnd.ms-powerpoint.addin.macroenabled.12", "ppd": "application/vnd.cups-ppd", "ppm": "image/x-portable-pixmap", "pps": "application/vnd.ms-powerpoint", "ppsm": "application/vnd.ms-powerpoint.slideshow.macroenabled.12", "ppsx": "application/vnd.openxmlformats-officedocument.presentationml.slideshow", "ppt": "application/vnd.ms-powerpoint", "pptm": "application/vnd.ms-powerpoint.presentation.macroenabled.12", "pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation", "pqa": "application/vnd.palm", "prc": "model/prc", "pre": "application/vnd.lotus-freelance", "prf": "application/pics-rules", "provx": "application/provenance+xml", "ps": "application/postscript", "psb": "application/vnd.3gpp.pic-bw-small", "psd": "image/vnd.adobe.photoshop", "psf": "application/x-font-linux-psf", "pskcxml": "application/pskc+xml", "pti": "image/prs.pti", "ptid": "application/vnd.pvi.ptid1", "pub": "application/x-mspublisher", "pvb": "application/vnd.3gpp.pic-bw-var", "pwn": "application/vnd.3m.post-it-notes", "pya": "audio/vnd.ms-playready.media.pya", "pyo": "model/vnd.pytha.pyox", "pyox": "model/vnd.pytha.pyox", "pyv": "video/vnd.ms-playready.media.pyv", "qam": "application/vnd.epson.quickanime", "qbo": "application/vnd.intu.qbo", "qfx": "application/vnd.intu.qfx", "qps": "application/vnd.publishare-delta-tree", "qt": "video/quicktime", "qwd": "application/vnd.quark.quarkxpress", "qwt": "application/vnd.quark.quarkxpress", "qxb": "application/vnd.quark.quarkxpress", "qxd": "application/vnd.quark.quarkxpress", "qxl": "application/vnd.quark.quarkxpress", "qxt": "application/vnd.quark.quarkxpress", "ra": "audio/x-realaudio", "ram": "audio/x-pn-realaudio", "raml": "application/raml+yaml", "rapd": "application/route-apd+xml", "rar": "application/x-rar-compressed", "ras": "image/x-cmu-raster", "rcprofile": "application/vnd.ipunplugged.rcprofile", "rdf": "application/rdf+xml", "rdz": "application/vnd.data-vision.rdz", "relo": "application/p2p-overlay+xml", "rep": "application/vnd.businessobjects", "res": "application/x-dtbresource+xml", "rgb": "image/x-rgb", "rif": "application/reginfo+xml", "rip": "audio/vnd.rip", "ris": "application/x-research-info-systems", "rl": "application/resource-lists+xml", "rlc": "image/vnd.fujixerox.edmics-rlc", "rld": "application/resource-lists-diff+xml", "rm": "application/vnd.rn-realmedia", "rmi": "audio/midi", "rmp": "audio/x-pn-realaudio-plugin", "rms": "application/vnd.jcp.javame.midlet-rms", "rmvb": "application/vnd.rn-realmedia-vbr", "rnc": "application/relax-ng-compact-syntax", "rng": "application/xml", "roa": "application/rpki-roa", "roff": "text/troff", "rp9": "application/vnd.cloanto.rp9", "rpm": "application/x-redhat-package-manager", "rpss": "application/vnd.nokia.radio-presets", "rpst": "application/vnd.nokia.radio-preset", "rq": "application/sparql-query", "rs": "application/rls-services+xml", "rsat": "application/atsc-rsat+xml", "rsd": "application/rsd+xml", "rsheet": "application/urc-ressheet+xml", "rss": "application/rss+xml", "rtf": "text/rtf", "rtx": "text/richtext", "run": "application/x-makeself", "rusd": "application/route-usd+xml", "s": "text/x-asm", "s3m": "audio/s3m", "saf": "application/vnd.yamaha.smaf-audio", "sass": "text/x-sass", "sbml": "application/sbml+xml", "sc": "application/vnd.ibm.secure-container", "scd": "application/x-msschedule", "scm": "application/vnd.lotus-screencam", "scq": "application/scvp-cv-request", "scs": "application/scvp-cv-response", "scss": "text/x-scss", "scurl": "text/vnd.curl.scurl", "sda": "application/vnd.stardivision.draw", "sdc": "application/vnd.stardivision.calc", "sdd": "application/vnd.stardivision.impress", "sdkd": "application/vnd.solent.sdkm+xml", "sdkm": "application/vnd.solent.sdkm+xml", "sdp": "application/sdp", "sdw": "application/vnd.stardivision.writer", "sea": "application/x-sea", "see": "application/vnd.seemail", "seed": "application/vnd.fdsn.seed", "sema": "application/vnd.sema", "semd": "application/vnd.semd", "semf": "application/vnd.semf", "senmlx": "application/senml+xml", "sensmlx": "application/sensml+xml", "ser": "application/java-serialized-object", "setpay": "application/set-payment-initiation", "setreg": "application/set-registration-initiation", "sfd-hdstx": "application/vnd.hydrostatix.sof-data", "sfs": "application/vnd.spotfire.sfs", "sfv": "text/x-sfv", "sgi": "image/sgi", "sgl": "application/vnd.stardivision.writer-global", "sgm": "text/sgml", "sgml": "text/sgml", "sh": "application/x-sh", "shar": "application/x-shar", "shex": "text/shex", "shf": "application/shf+xml", "shtml": "text/html", "sid": "image/x-mrsid-image", "sieve": "application/sieve", "sig": "application/pgp-signature", "sil": "audio/silk", "silo": "model/mesh", "sis": "application/vnd.symbian.install", "sisx": "application/vnd.symbian.install", "sit": "application/x-stuffit", "sitx": "application/x-stuffitx", "siv": "application/sieve", "skd": "application/vnd.koan", "skm": "application/vnd.koan", "skp": "application/vnd.koan", "skt": "application/vnd.koan", "sldm": "application/vnd.ms-powerpoint.slide.macroenabled.12", "sldx": "application/vnd.openxmlformats-officedocument.presentationml.slide", "slim": "text/slim", "slm": "text/slim", "sls": "application/route-s-tsid+xml", "slt": "application/vnd.epson.salt", "sm": "application/vnd.stepmania.stepchart", "smf": "application/vnd.stardivision.math", "smi": "application/smil+xml", "smil": "application/smil+xml", "smv": "video/x-smv", "smzip": "application/vnd.stepmania.package", "snd": "audio/basic", "snf": "application/x-font-snf", "so": "application/octet-stream", "spc": "application/x-pkcs7-certificates", "spdx": "text/spdx", "spf": "application/vnd.yamaha.smaf-phrase", "spl": "application/x-futuresplash", "spot": "text/vnd.in3d.spot", "spp": "application/scvp-vp-response", "spq": "application/scvp-vp-request", "spx": "audio/ogg", "sql": "application/x-sql", "src": "application/x-wais-source", "srt": "application/x-subrip", "sru": "application/sru+xml", "srx": "application/sparql-results+xml", "ssdl": "application/ssdl+xml", "sse": "application/vnd.kodak-descriptor", "ssf": "application/vnd.epson.ssf", "ssml": "application/ssml+xml", "st": "application/vnd.sailingtracker.track", "stc": "application/vnd.sun.xml.calc.template", "std": "application/vnd.sun.xml.draw.template", "stf": "application/vnd.wt.stf", "sti": "application/vnd.sun.xml.impress.template", "stk": "application/hyperstudio", "stl": "model/stl", "stpx": "model/step+xml", "stpxz": "model/step-xml+zip", "stpz": "model/step+zip", "str": "application/vnd.pg.format", "stw": "application/vnd.sun.xml.writer.template", "styl": "text/stylus", "stylus": "text/stylus", "sub": "text/vnd.dvb.subtitle", "sus": "application/vnd.sus-calendar", "susp": "application/vnd.sus-calendar", "sv4cpio": "application/x-sv4cpio", "sv4crc": "application/x-sv4crc", "svc": "application/vnd.dvb.service", "svd": "application/vnd.svd", "svg": "image/svg+xml", "svgz": "image/svg+xml", "swa": "application/x-director", "swf": "application/x-shockwave-flash", "swi": "application/vnd.aristanetworks.swi", "swidtag": "application/swid+xml", "sxc": "application/vnd.sun.xml.calc", "sxd": "application/vnd.sun.xml.draw", "sxg": "application/vnd.sun.xml.writer.global", "sxi": "application/vnd.sun.xml.impress", "sxm": "application/vnd.sun.xml.math", "sxw": "application/vnd.sun.xml.writer", "t": "text/troff", "t3": "application/x-t3vm-image", "t38": "image/t38", "taglet": "application/vnd.mynfc", "tao": "application/vnd.tao.intent-module-archive", "tap": "image/vnd.tencent.tap", "tar": "application/x-tar", "tcap": "application/vnd.3gpp2.tcap", "tcl": "application/x-tcl", "td": "application/urc-targetdesc+xml", "teacher": "application/vnd.smart.teacher", "tei": "application/tei+xml", "teicorpus": "application/tei+xml", "tex": "application/x-tex", "texi": "application/x-texinfo", "texinfo": "application/x-texinfo", "text": "text/plain", "tfi": "application/thraud+xml", "tfm": "application/x-tex-tfm", "tfx": "image/tiff-fx", "tga": "image/x-tga", "thmx": "application/vnd.ms-officetheme", "tif": "image/tiff", "tiff": "image/tiff", "tk": "application/x-tcl", "tmo": "application/vnd.tmobile-livetv", "toml": "application/toml", "torrent": "application/x-bittorrent", "tpl": "application/vnd.groove-tool-template", "tpt": "application/vnd.trid.tpt", "tr": "text/troff", "tra": "application/vnd.trueapp", "trig": "application/trig", "trm": "application/x-msterminal", "ts": "video/mp2t", "tsd": "application/timestamped-data", "tsv": "text/tab-separated-values", "ttc": "font/collection", "ttf": "font/ttf", "ttl": "text/turtle", "ttml": "application/ttml+xml", "twd": "application/vnd.simtech-mindmapper", "twds": "application/vnd.simtech-mindmapper", "txd": "application/vnd.genomatix.tuxedo", "txf": "application/vnd.mobius.txf", "txt": "text/plain", "u32": "application/x-authorware-bin", "u3d": "model/u3d", "u8dsn": "message/global-delivery-status", "u8hdr": "message/global-headers", "u8mdn": "message/global-disposition-notification", "u8msg": "message/global", "ubj": "application/ubjson", "udeb": "application/x-debian-package", "ufd": "application/vnd.ufdl", "ufdl": "application/vnd.ufdl", "ulx": "application/x-glulx", "umj": "application/vnd.umajin", "unityweb": "application/vnd.unity", "uo": "application/vnd.uoml+xml", "uoml": "application/vnd.uoml+xml", "uri": "text/uri-list", "uris": "text/uri-list", "urls": "text/uri-list", "usda": "model/vnd.usda", "usdz": "model/vnd.usdz+zip", "ustar": "application/x-ustar", "utz": "application/vnd.uiq.theme", "uu": "text/x-uuencode", "uva": "audio/vnd.dece.audio", "uvd": "application/vnd.dece.data", "uvf": "application/vnd.dece.data", "uvg": "image/vnd.dece.graphic", "uvh": "video/vnd.dece.hd", "uvi": "image/vnd.dece.graphic", "uvm": "video/vnd.dece.mobile", "uvp": "video/vnd.dece.pd", "uvs": "video/vnd.dece.sd", "uvt": "application/vnd.dece.ttml+xml", "uvu": "video/vnd.uvvu.mp4", "uvv": "video/vnd.dece.video", "uvva": "audio/vnd.dece.audio", "uvvd": "application/vnd.dece.data", "uvvf": "application/vnd.dece.data", "uvvg": "image/vnd.dece.graphic", "uvvh": "video/vnd.dece.hd", "uvvi": "image/vnd.dece.graphic", "uvvm": "video/vnd.dece.mobile", "uvvp": "video/vnd.dece.pd", "uvvs": "video/vnd.dece.sd", "uvvt": "application/vnd.dece.ttml+xml", "uvvu": "video/vnd.uvvu.mp4", "uvvv": "video/vnd.dece.video", "uvvx": "application/vnd.dece.unspecified", "uvvz": "application/vnd.dece.zip", "uvx": "application/vnd.dece.unspecified", "uvz": "application/vnd.dece.zip", "vbox": "application/x-virtualbox-vbox", "vbox-extpack": "application/x-virtualbox-vbox-extpack", "vcard": "text/vcard", "vcd": "application/x-cdlink", "vcf": "text/x-vcard", "vcg": "application/vnd.groove-vcard", "vcs": "text/x-vcalendar", "vcx": "application/vnd.vcx", "vdi": "application/x-virtualbox-vdi", "vds": "model/vnd.sap.vds", "vhd": "application/x-virtualbox-vhd", "vis": "application/vnd.visionary", "viv": "video/vnd.vivo", "vmdk": "application/x-virtualbox-vmdk", "vob": "video/x-ms-vob", "vor": "application/vnd.stardivision.writer", "vox": "application/x-authorware-bin", "vrml": "model/vrml", "vsd": "application/vnd.visio", "vsf": "application/vnd.vsf", "vss": "application/vnd.visio", "vst": "application/vnd.visio", "vsw": "application/vnd.visio", "vtf": "image/vnd.valve.source.texture", "vtt": "text/vtt", "vtu": "model/vnd.vtu", "vxml": "application/voicexml+xml", "w3d": "application/x-director", "wad": "application/x-doom", "wadl": "application/vnd.sun.wadl+xml", "war": "application/java-archive", "wasm": "application/wasm", "wav": "audio/x-wav", "wax": "audio/x-ms-wax", "wbmp": "image/vnd.wap.wbmp", "wbs": "application/vnd.criticaltools.wbs+xml", "wbxml": "application/vnd.wap.wbxml", "wcm": "application/vnd.ms-works", "wdb": "application/vnd.ms-works", "wdp": "image/vnd.ms-photo", "weba": "audio/webm", "webapp": "application/x-web-app-manifest+json", "webm": "video/webm", "webmanifest": "application/manifest+json", "webp": "image/webp", "wg": "application/vnd.pmi.widget", "wgsl": "text/wgsl", "wgt": "application/widget", "wif": "application/watcherinfo+xml", "wks": "application/vnd.ms-works", "wm": "video/x-ms-wm", "wma": "audio/x-ms-wma", "wmd": "application/x-ms-wmd", "wmf": "image/wmf", "wml": "text/vnd.wap.wml", "wmlc": "application/vnd.wap.wmlc", "wmls": "text/vnd.wap.wmlscript", "wmlsc": "application/vnd.wap.wmlscriptc", "wmv": "video/x-ms-wmv", "wmx": "video/x-ms-wmx", "wmz": "application/x-msmetafile", "woff": "font/woff", "woff2": "font/woff2", "wpd": "application/vnd.wordperfect", "wpl": "application/vnd.ms-wpl", "wps": "application/vnd.ms-works", "wqd": "application/vnd.wqd", "wri": "application/x-mswrite", "wrl": "model/vrml", "wsc": "message/vnd.wfa.wsc", "wsdl": "application/wsdl+xml", "wspolicy": "application/wspolicy+xml", "wtb": "application/vnd.webturbo", "wvx": "video/x-ms-wvx", "x32": "application/x-authorware-bin", "x3d": "model/x3d+xml", "x3db": "model/x3d+fastinfoset", "x3dbz": "model/x3d+binary", "x3dv": "model/x3d-vrml", "x3dvz": "model/x3d+vrml", "x3dz": "model/x3d+xml", "x_b": "model/vnd.parasolid.transmit.binary", "x_t": "model/vnd.parasolid.transmit.text", "xaml": "application/xaml+xml", "xap": "application/x-silverlight-app", "xar": "application/vnd.xara", "xav": "application/xcap-att+xml", "xbap": "application/x-ms-xbap", "xbd": "application/vnd.fujixerox.docuworks.binder", "xbm": "image/x-xbitmap", "xca": "application/xcap-caps+xml", "xcs": "application/calendar+xml", "xdcf": "application/vnd.gov.sk.xmldatacontainer+xml", "xdf": "application/xcap-diff+xml", "xdm": "application/vnd.syncml.dm+xml", "xdp": "application/vnd.adobe.xdp+xml", "xdssc": "application/dssc+xml", "xdw": "application/vnd.fujixerox.docuworks", "xel": "application/xcap-el+xml", "xenc": "application/xenc+xml", "xer": "application/patch-ops-error+xml", "xfdf": "application/xfdf", "xfdl": "application/vnd.xfdl", "xht": "application/xhtml+xml", "xhtm": "application/vnd.pwg-xhtml-print+xml", "xhtml": "application/xhtml+xml", "xhvml": "application/xv+xml", "xif": "image/vnd.xiff", "xla": "application/vnd.ms-excel", "xlam": "application/vnd.ms-excel.addin.macroenabled.12", "xlc": "application/vnd.ms-excel", "xlf": "application/xliff+xml", "xlm": "application/vnd.ms-excel", "xls": "application/vnd.ms-excel", "xlsb": "application/vnd.ms-excel.sheet.binary.macroenabled.12", "xlsm": "application/vnd.ms-excel.sheet.macroenabled.12", "xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "xlt": "application/vnd.ms-excel", "xltm": "application/vnd.ms-excel.template.macroenabled.12", "xltx": "application/vnd.openxmlformats-officedocument.spreadsheetml.template", "xlw": "application/vnd.ms-excel", "xm": "audio/xm", "xml": "text/xml", "xns": "application/xcap-ns+xml", "xo": "application/vnd.olpc-sugar", "xop": "application/xop+xml", "xpi": "application/x-xpinstall", "xpl": "application/xproc+xml", "xpm": "image/x-xpixmap", "xpr": "application/vnd.is-xpr", "xps": "application/vnd.ms-xpsdocument", "xpw": "application/vnd.intercon.formnet", "xpx": "application/vnd.intercon.formnet", "xsd": "application/xml", "xsf": "application/prs.xsf+xml", "xsl": "application/xslt+xml", "xslt": "application/xslt+xml", "xsm": "application/vnd.syncml+xml", "xspf": "application/xspf+xml", "xul": "application/vnd.mozilla.xul+xml", "xvm": "application/xv+xml", "xvml": "application/xv+xml", "xwd": "image/x-xwindowdump", "xyz": "chemical/x-xyz", "xz": "application/x-xz", "yaml": "text/yaml", "yang": "application/yang", "yin": "application/yin+xml", "yml": "text/yaml", "ymp": "text/x-suse-ymp", "z1": "application/x-zmachine", "z2": "application/x-zmachine", "z3": "application/x-zmachine", "z4": "application/x-zmachine", "z5": "application/x-zmachine", "z6": "application/x-zmachine", "z7": "application/x-zmachine", "z8": "application/x-zmachine", "zaz": "application/vnd.zzazz.deck+xml", "zip": "application/zip", "zir": "application/vnd.zul", "zirz": "application/vnd.zul", "zmm": "application/vnd.handheld-entertainment+xml" };
@@ -5988,8 +9484,17 @@ var import_path9 = __toESM(require("path"));
5988
9484
  // build/dev-server/serve-dev-client.js
5989
9485
  var import_path6 = __toESM(require("path"));
5990
9486
 
9487
+ // build/dev-server/open-in-editor-api.js
9488
+ var openInEditorApi = {
9489
+ // mocked fns so unit tests work too
9490
+ configure(_opts, _cb) {
9491
+ return null;
9492
+ },
9493
+ editors: {}
9494
+ };
9495
+ var open_in_editor_api_default = openInEditorApi;
9496
+
5991
9497
  // build/dev-server/open-in-editor.js
5992
- var import_open_in_editor_api = __toESM(require("./open-in-editor-api"));
5993
9498
  async function serveOpenInEditor(serverCtx, req, res) {
5994
9499
  let status = 200;
5995
9500
  const data = {};
@@ -6054,7 +9559,7 @@ async function openDataInEditor(data) {
6054
9559
  const opts = {
6055
9560
  editor: data.editor
6056
9561
  };
6057
- const editor = import_open_in_editor_api.default.configure(opts, (err2) => data.error = err2 + "");
9562
+ const editor = open_in_editor_api_default.configure(opts, (err2) => data.error = err2 + "");
6058
9563
  if (data.error) {
6059
9564
  return;
6060
9565
  }
@@ -6070,7 +9575,7 @@ function getEditors() {
6070
9575
  editors = new Promise(async (resolve) => {
6071
9576
  const editors2 = [];
6072
9577
  try {
6073
- await Promise.all(Object.keys(import_open_in_editor_api.default.editors).map(async (editorId) => {
9578
+ await Promise.all(Object.keys(open_in_editor_api_default.editors).map(async (editorId) => {
6074
9579
  const isSupported = await isEditorSupported(editorId);
6075
9580
  editors2.push({
6076
9581
  id: editorId,
@@ -6099,7 +9604,7 @@ function getEditors() {
6099
9604
  async function isEditorSupported(editorId) {
6100
9605
  let isSupported = false;
6101
9606
  try {
6102
- await import_open_in_editor_api.default.editors[editorId].detect();
9607
+ await open_in_editor_api_default.editors[editorId].detect();
6103
9608
  isSupported = true;
6104
9609
  } catch (e) {
6105
9610
  }
@@ -6704,44 +10209,50 @@ function isPortTaken(host, port) {
6704
10209
  });
6705
10210
  }
6706
10211
 
10212
+ // node_modules/ws/wrapper.mjs
10213
+ var import_stream2 = __toESM(require_stream2(), 1);
10214
+ var import_receiver = __toESM(require_receiver(), 1);
10215
+ var import_sender = __toESM(require_sender(), 1);
10216
+ var import_websocket = __toESM(require_websocket(), 1);
10217
+ var import_websocket_server = __toESM(require_websocket_server(), 1);
10218
+
6707
10219
  // build/dev-server/server-web-socket.js
6708
- var import_ws = __toESM(require("./ws.js"));
6709
10220
  function createWebSocket(httpServer, onMessageFromClient) {
6710
10221
  const wsConfig = {
6711
10222
  server: httpServer
6712
10223
  };
6713
- const wsServer = new import_ws.default.Server(wsConfig);
10224
+ const wsServer = new import_websocket_server.default(wsConfig);
6714
10225
  function heartbeat() {
6715
10226
  this.isAlive = true;
6716
10227
  }
6717
- wsServer.on("connection", (ws2) => {
6718
- ws2.on("message", (data) => {
10228
+ wsServer.on("connection", (ws) => {
10229
+ ws.on("message", (data) => {
6719
10230
  try {
6720
10231
  onMessageFromClient(JSON.parse(data.toString()));
6721
10232
  } catch (e) {
6722
10233
  console.error(e);
6723
10234
  }
6724
10235
  });
6725
- ws2.isAlive = true;
6726
- ws2.on("pong", heartbeat);
6727
- ws2.on("error", console.error);
10236
+ ws.isAlive = true;
10237
+ ws.on("pong", heartbeat);
10238
+ ws.on("error", console.error);
6728
10239
  });
6729
10240
  const pingInterval = setInterval(() => {
6730
- wsServer.clients.forEach((ws2) => {
6731
- if (!ws2.isAlive) {
6732
- return ws2.close(1e3);
10241
+ wsServer.clients.forEach((ws) => {
10242
+ if (!ws.isAlive) {
10243
+ return ws.close(1e3);
6733
10244
  }
6734
- ws2.isAlive = false;
6735
- ws2.ping(noop);
10245
+ ws.isAlive = false;
10246
+ ws.ping(noop);
6736
10247
  });
6737
10248
  }, 1e4);
6738
10249
  return {
6739
10250
  sendToBrowser: (msg) => {
6740
10251
  if (msg && wsServer && wsServer.clients) {
6741
10252
  const data = JSON.stringify(msg);
6742
- wsServer.clients.forEach((ws2) => {
6743
- if (ws2.readyState === ws2.OPEN) {
6744
- ws2.send(data);
10253
+ wsServer.clients.forEach((ws) => {
10254
+ if (ws.readyState === ws.OPEN) {
10255
+ ws.send(data);
6745
10256
  }
6746
10257
  });
6747
10258
  }
@@ -6749,8 +10260,8 @@ function createWebSocket(httpServer, onMessageFromClient) {
6749
10260
  close: () => {
6750
10261
  return new Promise((resolve, reject) => {
6751
10262
  clearInterval(pingInterval);
6752
- wsServer.clients.forEach((ws2) => {
6753
- ws2.close(1e3);
10263
+ wsServer.clients.forEach((ws) => {
10264
+ ws.close(1e3);
6754
10265
  });
6755
10266
  wsServer.close((err2) => {
6756
10267
  if (err2) {