unbrowse 10.2.0 → 10.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/runtime/cli.js CHANGED
@@ -16445,7 +16445,7 @@ For a list of runtimes that currently support Ed25519 operations, visit https://
16445
16445
  function getErrorMessage(code, context = {}) {
16446
16446
  if (true) {
16447
16447
  return getHumanReadableErrorMessage(code, context);
16448
- }
16448
+ } else {}
16449
16449
  }
16450
16450
  function isSolanaError(e, code) {
16451
16451
  const isSolanaError2 = e instanceof Error && e.name === "SolanaError";
@@ -22217,7 +22217,7 @@ var require_fallback = __commonJS((exports, module) => {
22217
22217
 
22218
22218
  // node_modules/.bun/bufferutil@4.1.0/node_modules/bufferutil/index.js
22219
22219
  var require_bufferutil = __commonJS((exports, module) => {
22220
- var __dirname = "/Users/lewis/act-runner/work/48768e304e69e0e9/hostexecutor/node_modules/.bun/bufferutil@4.1.0/node_modules/bufferutil";
22220
+ var __dirname = "/Users/lekt9/Projects/unbrowse-ecosystem/unbrowse/node_modules/.bun/bufferutil@4.1.0/node_modules/bufferutil";
22221
22221
  try {
22222
22222
  module.exports = require_node_gyp_build2()(__dirname);
22223
22223
  } catch (e) {
@@ -22633,7 +22633,7 @@ var require_fallback2 = __commonJS((exports, module) => {
22633
22633
 
22634
22634
  // node_modules/.bun/utf-8-validate@6.0.6/node_modules/utf-8-validate/index.js
22635
22635
  var require_utf_8_validate = __commonJS((exports, module) => {
22636
- var __dirname = "/Users/lewis/act-runner/work/48768e304e69e0e9/hostexecutor/node_modules/.bun/utf-8-validate@6.0.6/node_modules/utf-8-validate";
22636
+ var __dirname = "/Users/lekt9/Projects/unbrowse-ecosystem/unbrowse/node_modules/.bun/utf-8-validate@6.0.6/node_modules/utf-8-validate";
22637
22637
  try {
22638
22638
  module.exports = require_node_gyp_build2()(__dirname);
22639
22639
  } catch (e) {
@@ -64886,7 +64886,7 @@ var init_telemetry = __esm(() => {
64886
64886
  });
64887
64887
 
64888
64888
  // .tmp-runtime-src/build-info.generated.ts
64889
- var BUILD_RELEASE_VERSION = "10.2.0", BUILD_GIT_SHA = "a5129ea18c09", BUILD_CODE_HASH = "5d9ebf619c61", BUILD_RELEASE_MANIFEST_BASE64 = "eyJzY2hlbWFfdmVyc2lvbiI6MSwicmVsZWFzZV92ZXJzaW9uIjoiMTAuMi4wIiwiZ2l0X3NoYSI6ImE1MTI5ZWExOGMwOSIsImNvZGVfaGFzaCI6IjVkOWViZjYxOWM2MSIsInRyYWNlX3ZlcnNpb24iOiI1ZDllYmY2MTljNjFAYTUxMjllYTE4YzA5IiwiaXNzdWVkX2F0IjoiMjAyNi0wNi0yNFQwNTowMDozNi42ODRaIn0", BUILD_RELEASE_MANIFEST_SIGNATURE = "Qk8pVgRsymF5wBQGgm9sctXksHjjL89QgTSOURoSe3k", BUILD_DEFAULT_BACKEND_URL = "https://beta-api.unbrowse.ai", BUILD_DEFAULT_PROFILE = "";
64889
+ var BUILD_RELEASE_VERSION = "10.3.0", BUILD_GIT_SHA = "f83d7800067c", BUILD_CODE_HASH = "5d9ebf619c61", BUILD_RELEASE_MANIFEST_BASE64 = "eyJzY2hlbWFfdmVyc2lvbiI6MSwicmVsZWFzZV92ZXJzaW9uIjoiMTAuMy4wIiwiZ2l0X3NoYSI6ImY4M2Q3ODAwMDY3YyIsImNvZGVfaGFzaCI6IjVkOWViZjYxOWM2MSIsInRyYWNlX3ZlcnNpb24iOiI1ZDllYmY2MTljNjFAZjgzZDc4MDAwNjdjIiwiaXNzdWVkX2F0IjoiMjAyNi0wNi0yNFQxMzoxODoyMS44MDJaIn0", BUILD_RELEASE_MANIFEST_SIGNATURE = "ecKMJ9MsPEVLVo7Q4WKNqdJ_nF2UP4yu4ktN-ezC6Og", BUILD_DEFAULT_BACKEND_URL = "https://beta-api.unbrowse.ai", BUILD_DEFAULT_PROFILE = "";
64890
64890
 
64891
64891
  // .tmp-runtime-src/version.ts
64892
64892
  import { createHash as createHash8 } from "crypto";
@@ -68981,7 +68981,7 @@ Candidates:`;
68981
68981
 
68982
68982
  // node_modules/.bun/sodium-native@5.1.0+607645472ba173c2/node_modules/sodium-native/binding.js
68983
68983
  var require_binding = __commonJS((exports, module) => {
68984
- var __filename = "/Users/lewis/act-runner/work/48768e304e69e0e9/hostexecutor/node_modules/.bun/sodium-native@5.1.0+607645472ba173c2/node_modules/sodium-native/binding.js";
68984
+ var __filename = "/Users/lekt9/Projects/unbrowse-ecosystem/unbrowse/node_modules/.bun/sodium-native@5.1.0+607645472ba173c2/node_modules/sodium-native/binding.js";
68985
68985
  __require.addon = require_node();
68986
68986
  module.exports = __require.addon(".", __filename);
68987
68987
  });
@@ -76621,7 +76621,7 @@ var require_boot = __commonJS((exports, module) => {
76621
76621
  clearTimeout(timer);
76622
76622
  this._error = err;
76623
76623
  cb(this._error);
76624
- }
76624
+ } else {}
76625
76625
  }
76626
76626
  }
76627
76627
  function closeWithCbOrNextTick(func, cb) {
@@ -80242,7 +80242,7 @@ var require_indexes = __commonJS((exports, module) => {
80242
80242
 
80243
80243
  // node_modules/.bun/thread-stream@4.2.0/node_modules/thread-stream/index.js
80244
80244
  var require_thread_stream = __commonJS((exports, module) => {
80245
- var __dirname = "/Users/lewis/act-runner/work/48768e304e69e0e9/hostexecutor/node_modules/.bun/thread-stream@4.2.0/node_modules/thread-stream";
80245
+ var __dirname = "/Users/lekt9/Projects/unbrowse-ecosystem/unbrowse/node_modules/.bun/thread-stream@4.2.0/node_modules/thread-stream";
80246
80246
  var { version: version2 } = require_package();
80247
80247
  var { EventEmitter } = __require("events");
80248
80248
  var { Worker } = __require("worker_threads");
@@ -80758,7 +80758,7 @@ var require_thread_stream = __commonJS((exports, module) => {
80758
80758
 
80759
80759
  // node_modules/.bun/pino@10.3.1/node_modules/pino/lib/transport.js
80760
80760
  var require_transport = __commonJS((exports, module) => {
80761
- var __dirname = "/Users/lewis/act-runner/work/48768e304e69e0e9/hostexecutor/node_modules/.bun/pino@10.3.1/node_modules/pino/lib";
80761
+ var __dirname = "/Users/lekt9/Projects/unbrowse-ecosystem/unbrowse/node_modules/.bun/pino@10.3.1/node_modules/pino/lib";
80762
80762
  var { createRequire: createRequire2 } = __require("module");
80763
80763
  var { existsSync: existsSync22 } = __require("node:fs");
80764
80764
  var getCallers = require_caller();
@@ -108376,696 +108376,3311 @@ var require_plugin2 = __commonJS((exports, module) => {
108376
108376
  if (options.fastify !== undefined && typeof options.fastify !== "string") {
108377
108377
  throw new TypeError(`fastify-plugin expects a version string, instead got '${typeof options.fastify}'`);
108378
108378
  }
108379
- if (!options.name) {
108380
- autoName = true;
108381
- options.name = getPluginName(fn) + "-auto-" + count++;
108379
+ if (!options.name) {
108380
+ autoName = true;
108381
+ options.name = getPluginName(fn) + "-auto-" + count++;
108382
+ }
108383
+ fn[Symbol.for("skip-override")] = options.encapsulate !== true;
108384
+ fn[Symbol.for("fastify.display-name")] = options.name;
108385
+ fn[Symbol.for("plugin-meta")] = options;
108386
+ if (!fn.default) {
108387
+ fn.default = fn;
108388
+ }
108389
+ const camelCase = toCamelCase(options.name);
108390
+ if (!autoName && !fn[camelCase]) {
108391
+ fn[camelCase] = fn;
108392
+ }
108393
+ return fn;
108394
+ }
108395
+ module.exports = plugin;
108396
+ module.exports.default = plugin;
108397
+ module.exports.fastifyPlugin = plugin;
108398
+ });
108399
+
108400
+ // node_modules/.bun/@fastify+cors@11.2.0/node_modules/@fastify/cors/vary.js
108401
+ var require_vary = __commonJS((exports, module) => {
108402
+ var { FifoMap: FifoCache } = require_toad_cache();
108403
+ var validFieldnameRE = /^[!#$%&'*+\-.^\w`|~]+$/u;
108404
+ function validateFieldname(fieldname) {
108405
+ if (validFieldnameRE.test(fieldname) === false) {
108406
+ throw new TypeError("Fieldname contains invalid characters.");
108407
+ }
108408
+ }
108409
+ function parse2(header) {
108410
+ header = header.trim().toLowerCase();
108411
+ const result = [];
108412
+ if (header.length === 0) {} else if (header.indexOf(",") === -1) {
108413
+ result.push(header);
108414
+ } else {
108415
+ const il = header.length;
108416
+ let i = 0;
108417
+ let pos = 0;
108418
+ let char;
108419
+ for (i;i < il; ++i) {
108420
+ char = header[i];
108421
+ if (char === " ") {
108422
+ pos = i + 1;
108423
+ } else if (char === ",") {
108424
+ if (pos !== i) {
108425
+ result.push(header.slice(pos, i));
108426
+ }
108427
+ pos = i + 1;
108428
+ }
108429
+ }
108430
+ if (pos !== i) {
108431
+ result.push(header.slice(pos, i));
108432
+ }
108433
+ }
108434
+ return result;
108435
+ }
108436
+ function createAddFieldnameToVary(fieldname) {
108437
+ const headerCache = new FifoCache(1000);
108438
+ validateFieldname(fieldname);
108439
+ return function(reply) {
108440
+ let header = reply.getHeader("Vary");
108441
+ if (!header) {
108442
+ reply.header("Vary", fieldname);
108443
+ return;
108444
+ }
108445
+ if (header === "*") {
108446
+ return;
108447
+ }
108448
+ if (fieldname === "*") {
108449
+ reply.header("Vary", "*");
108450
+ return;
108451
+ }
108452
+ if (Array.isArray(header)) {
108453
+ header = header.join(", ");
108454
+ }
108455
+ if (headerCache.get(header) === undefined) {
108456
+ const vals = parse2(header);
108457
+ if (vals.indexOf("*") !== -1) {
108458
+ headerCache.set(header, "*");
108459
+ } else if (vals.indexOf(fieldname.toLowerCase()) === -1) {
108460
+ headerCache.set(header, header + ", " + fieldname);
108461
+ } else {
108462
+ headerCache.set(header, null);
108463
+ }
108464
+ }
108465
+ const cached3 = headerCache.get(header);
108466
+ if (cached3 !== null) {
108467
+ reply.header("Vary", cached3);
108468
+ }
108469
+ };
108470
+ }
108471
+ exports.createAddFieldnameToVary = createAddFieldnameToVary;
108472
+ exports.addOriginToVaryHeader = createAddFieldnameToVary("Origin");
108473
+ exports.addAccessControlRequestHeadersToVaryHeader = createAddFieldnameToVary("Access-Control-Request-Headers");
108474
+ exports.parse = parse2;
108475
+ });
108476
+
108477
+ // node_modules/.bun/@fastify+cors@11.2.0/node_modules/@fastify/cors/index.js
108478
+ var require_cors = __commonJS((exports, module) => {
108479
+ var fp = require_plugin2();
108480
+ var {
108481
+ addAccessControlRequestHeadersToVaryHeader,
108482
+ addOriginToVaryHeader
108483
+ } = require_vary();
108484
+ var defaultOptions = {
108485
+ origin: "*",
108486
+ methods: "GET,HEAD,POST",
108487
+ hook: "onRequest",
108488
+ preflightContinue: false,
108489
+ optionsSuccessStatus: 204,
108490
+ credentials: false,
108491
+ exposedHeaders: null,
108492
+ allowedHeaders: null,
108493
+ maxAge: null,
108494
+ preflight: true,
108495
+ strictPreflight: true
108496
+ };
108497
+ var validHooks = [
108498
+ "onRequest",
108499
+ "preParsing",
108500
+ "preValidation",
108501
+ "preHandler",
108502
+ "preSerialization",
108503
+ "onSend"
108504
+ ];
108505
+ var hookWithPayload = [
108506
+ "preSerialization",
108507
+ "preParsing",
108508
+ "onSend"
108509
+ ];
108510
+ function validateHook(value, next) {
108511
+ if (validHooks.indexOf(value) !== -1) {
108512
+ return;
108513
+ }
108514
+ next(new TypeError("@fastify/cors: Invalid hook option provided."));
108515
+ }
108516
+ function fastifyCors(fastify, opts, next) {
108517
+ fastify.decorateRequest("corsPreflightEnabled", false);
108518
+ let hideOptionsRoute = true;
108519
+ let logLevel;
108520
+ if (typeof opts === "function") {
108521
+ handleCorsOptionsDelegator(opts, fastify, { hook: defaultOptions.hook }, next);
108522
+ } else if (opts.delegator) {
108523
+ const { delegator, ...options } = opts;
108524
+ handleCorsOptionsDelegator(delegator, fastify, options, next);
108525
+ } else {
108526
+ const corsOptions = normalizeCorsOptions(opts);
108527
+ validateHook(corsOptions.hook, next);
108528
+ if (hookWithPayload.indexOf(corsOptions.hook) !== -1) {
108529
+ fastify.addHook(corsOptions.hook, function handleCors(req, reply, _payload, next2) {
108530
+ addCorsHeadersHandler(fastify, corsOptions, req, reply, next2);
108531
+ });
108532
+ } else {
108533
+ fastify.addHook(corsOptions.hook, function handleCors(req, reply, next2) {
108534
+ addCorsHeadersHandler(fastify, corsOptions, req, reply, next2);
108535
+ });
108536
+ }
108537
+ }
108538
+ if (opts.logLevel !== undefined)
108539
+ logLevel = opts.logLevel;
108540
+ if (opts.hideOptionsRoute !== undefined)
108541
+ hideOptionsRoute = opts.hideOptionsRoute;
108542
+ fastify.options("*", { schema: { hide: hideOptionsRoute }, logLevel }, (req, reply) => {
108543
+ if (!req.corsPreflightEnabled) {
108544
+ reply.callNotFound();
108545
+ return;
108546
+ }
108547
+ reply.send();
108548
+ });
108549
+ next();
108550
+ }
108551
+ function handleCorsOptionsDelegator(optionsResolver, fastify, opts, next) {
108552
+ const hook = opts?.hook || defaultOptions.hook;
108553
+ validateHook(hook, next);
108554
+ if (optionsResolver.length === 2) {
108555
+ if (hookWithPayload.indexOf(hook) !== -1) {
108556
+ fastify.addHook(hook, function handleCors(req, reply, _payload, next2) {
108557
+ handleCorsOptionsCallbackDelegator(optionsResolver, fastify, req, reply, next2);
108558
+ });
108559
+ } else {
108560
+ fastify.addHook(hook, function handleCors(req, reply, next2) {
108561
+ handleCorsOptionsCallbackDelegator(optionsResolver, fastify, req, reply, next2);
108562
+ });
108563
+ }
108564
+ } else {
108565
+ if (hookWithPayload.indexOf(hook) !== -1) {
108566
+ fastify.addHook(hook, function handleCors(req, reply, _payload, next2) {
108567
+ const ret = optionsResolver(req);
108568
+ if (ret && typeof ret.then === "function") {
108569
+ ret.then((options) => addCorsHeadersHandler(fastify, normalizeCorsOptions(options, true), req, reply, next2)).catch(next2);
108570
+ return;
108571
+ }
108572
+ next2(new Error("Invalid CORS origin option"));
108573
+ });
108574
+ } else {
108575
+ fastify.addHook(hook, function handleCors(req, reply, next2) {
108576
+ const ret = optionsResolver(req);
108577
+ if (ret && typeof ret.then === "function") {
108578
+ ret.then((options) => addCorsHeadersHandler(fastify, normalizeCorsOptions(options, true), req, reply, next2)).catch(next2);
108579
+ return;
108580
+ }
108581
+ next2(new Error("Invalid CORS origin option"));
108582
+ });
108583
+ }
108584
+ }
108585
+ }
108586
+ function handleCorsOptionsCallbackDelegator(optionsResolver, fastify, req, reply, next) {
108587
+ optionsResolver(req, (err, options) => {
108588
+ if (err) {
108589
+ next(err);
108590
+ } else {
108591
+ addCorsHeadersHandler(fastify, normalizeCorsOptions(options, true), req, reply, next);
108592
+ }
108593
+ });
108594
+ }
108595
+ function normalizeCorsOptions(opts, dynamic) {
108596
+ const corsOptions = { ...defaultOptions, ...opts };
108597
+ if (Array.isArray(opts.origin) && opts.origin.indexOf("*") !== -1) {
108598
+ corsOptions.origin = "*";
108599
+ }
108600
+ if (Number.isInteger(corsOptions.cacheControl)) {
108601
+ corsOptions.cacheControl = `max-age=${corsOptions.cacheControl}`;
108602
+ } else if (typeof corsOptions.cacheControl !== "string") {
108603
+ corsOptions.cacheControl = null;
108604
+ }
108605
+ corsOptions.dynamic = dynamic || false;
108606
+ return corsOptions;
108607
+ }
108608
+ function addCorsHeadersHandler(fastify, globalOptions, req, reply, next) {
108609
+ const options = { ...globalOptions, ...req.routeOptions.config?.cors };
108610
+ if (typeof options.origin !== "string" && options.origin !== false || options.dynamic) {
108611
+ addOriginToVaryHeader(reply);
108612
+ }
108613
+ const resolveOriginOption = typeof options.origin === "function" ? resolveOriginWrapper(fastify, options.origin) : (_, cb) => cb(null, options.origin);
108614
+ resolveOriginOption(req, (error, resolvedOriginOption) => {
108615
+ if (error !== null) {
108616
+ return next(error);
108617
+ }
108618
+ if (resolvedOriginOption === false) {
108619
+ return next();
108620
+ }
108621
+ if (req.routeOptions.config?.cors === false) {
108622
+ return next();
108623
+ }
108624
+ if (!resolvedOriginOption) {
108625
+ return next(new Error("Invalid CORS origin option"));
108626
+ }
108627
+ addCorsHeaders(req, reply, resolvedOriginOption, options);
108628
+ if (req.raw.method === "OPTIONS" && options.preflight === true) {
108629
+ if (options.strictPreflight === true && (!req.headers.origin || !req.headers["access-control-request-method"])) {
108630
+ reply.status(400).type("text/plain").send("Invalid Preflight Request");
108631
+ return;
108632
+ }
108633
+ req.corsPreflightEnabled = true;
108634
+ addPreflightHeaders(req, reply, options);
108635
+ if (!options.preflightContinue) {
108636
+ reply.code(options.optionsSuccessStatus).header("Content-Length", "0").send();
108637
+ return;
108638
+ }
108639
+ }
108640
+ return next();
108641
+ });
108642
+ }
108643
+ function addCorsHeaders(req, reply, originOption, corsOptions) {
108644
+ const origin = getAccessControlAllowOriginHeader(req.headers.origin, originOption);
108645
+ if (origin) {
108646
+ reply.header("Access-Control-Allow-Origin", origin);
108647
+ }
108648
+ if (corsOptions.credentials) {
108649
+ reply.header("Access-Control-Allow-Credentials", "true");
108650
+ }
108651
+ if (corsOptions.exposedHeaders !== null) {
108652
+ reply.header("Access-Control-Expose-Headers", Array.isArray(corsOptions.exposedHeaders) ? corsOptions.exposedHeaders.join(", ") : corsOptions.exposedHeaders);
108653
+ }
108654
+ }
108655
+ function addPreflightHeaders(req, reply, corsOptions) {
108656
+ reply.header("Access-Control-Allow-Methods", Array.isArray(corsOptions.methods) ? corsOptions.methods.join(", ") : corsOptions.methods);
108657
+ if (corsOptions.allowedHeaders === null) {
108658
+ addAccessControlRequestHeadersToVaryHeader(reply);
108659
+ const reqAllowedHeaders = req.headers["access-control-request-headers"];
108660
+ if (reqAllowedHeaders !== undefined) {
108661
+ reply.header("Access-Control-Allow-Headers", reqAllowedHeaders);
108662
+ }
108663
+ } else {
108664
+ reply.header("Access-Control-Allow-Headers", Array.isArray(corsOptions.allowedHeaders) ? corsOptions.allowedHeaders.join(", ") : corsOptions.allowedHeaders);
108665
+ }
108666
+ if (corsOptions.maxAge !== null) {
108667
+ reply.header("Access-Control-Max-Age", String(corsOptions.maxAge));
108668
+ }
108669
+ if (corsOptions.cacheControl) {
108670
+ reply.header("Cache-Control", corsOptions.cacheControl);
108671
+ }
108672
+ }
108673
+ function resolveOriginWrapper(fastify, origin) {
108674
+ return function(req, cb) {
108675
+ const result = origin.call(fastify, req.headers.origin, cb);
108676
+ if (result && typeof result.then === "function") {
108677
+ result.then((res) => cb(null, res), cb);
108678
+ }
108679
+ };
108680
+ }
108681
+ function getAccessControlAllowOriginHeader(reqOrigin, originOption) {
108682
+ if (typeof originOption === "string") {
108683
+ return originOption;
108684
+ }
108685
+ return isRequestOriginAllowed(reqOrigin, originOption) ? reqOrigin : false;
108686
+ }
108687
+ function isRequestOriginAllowed(reqOrigin, allowedOrigin) {
108688
+ if (Array.isArray(allowedOrigin)) {
108689
+ for (let i = 0;i < allowedOrigin.length; ++i) {
108690
+ if (isRequestOriginAllowed(reqOrigin, allowedOrigin[i])) {
108691
+ return true;
108692
+ }
108693
+ }
108694
+ return false;
108695
+ } else if (typeof allowedOrigin === "string") {
108696
+ return reqOrigin === allowedOrigin;
108697
+ } else if (allowedOrigin instanceof RegExp) {
108698
+ allowedOrigin.lastIndex = 0;
108699
+ return allowedOrigin.test(reqOrigin);
108700
+ } else {
108701
+ return !!allowedOrigin;
108702
+ }
108703
+ }
108704
+ var _fastifyCors = fp(fastifyCors, {
108705
+ fastify: "5.x",
108706
+ name: "@fastify/cors"
108707
+ });
108708
+ module.exports = _fastifyCors;
108709
+ module.exports.fastifyCors = _fastifyCors;
108710
+ module.exports.default = _fastifyCors;
108711
+ });
108712
+
108713
+ // .tmp-runtime-src/ratelimit/index.ts
108714
+ async function registerRateLimiter(_app) {}
108715
+ var ROUTE_LIMITS;
108716
+ var init_ratelimit = __esm(() => {
108717
+ ROUTE_LIMITS = {
108718
+ "/v1/intent/resolve": { max: 20, timeWindow: "1 minute" },
108719
+ "/v1/skills/:skill_id/execute": { max: 30, timeWindow: "1 minute" },
108720
+ "/v1/skills": { max: 5, timeWindow: "1 minute" },
108721
+ "/v1/auth/login": { max: 3, timeWindow: "5 minutes" },
108722
+ "/v1/feedback": { max: 60, timeWindow: "1 minute" }
108723
+ };
108724
+ });
108725
+
108726
+ // .tmp-runtime-src/logger.ts
108727
+ import fs2 from "node:fs";
108728
+ import path5 from "node:path";
108729
+ function logDir() {
108730
+ return path5.join(getUnbrowseHome2(), "logs");
108731
+ }
108732
+ function getLogFile() {
108733
+ const date = new Date().toISOString().slice(0, 10);
108734
+ return path5.join(logDir(), `unbrowse-${date}.log`);
108735
+ }
108736
+ function ensureLogDir() {
108737
+ fs2.mkdirSync(logDir(), { recursive: true });
108738
+ }
108739
+ function log(module, message) {
108740
+ const ts = new Date().toTimeString().slice(0, 8);
108741
+ const line = `[${ts}] [${module}] ${message}`;
108742
+ console.error(line);
108743
+ try {
108744
+ ensureLogDir();
108745
+ fs2.appendFileSync(getLogFile(), line + `
108746
+ `);
108747
+ } catch {}
108748
+ }
108749
+ function tsMs() {
108750
+ const d = new Date;
108751
+ const hh = String(d.getHours()).padStart(2, "0");
108752
+ const mm = String(d.getMinutes()).padStart(2, "0");
108753
+ const ss = String(d.getSeconds()).padStart(2, "0");
108754
+ const ms = String(d.getMilliseconds()).padStart(3, "0");
108755
+ return `${hh}:${mm}:${ss}.${ms}`;
108756
+ }
108757
+ function traceLine(message) {
108758
+ const line = `[${tsMs()}] [trace] ${message}`;
108759
+ console.log(line);
108760
+ try {
108761
+ ensureLogDir();
108762
+ fs2.appendFileSync(getLogFile(), line + `
108763
+ `);
108764
+ } catch {}
108765
+ }
108766
+ async function traceAsync(scope, sid, phase, fn) {
108767
+ if (!TRACE_ENABLED)
108768
+ return fn();
108769
+ const sidShort = (sid ?? "-").slice(0, 8);
108770
+ const tag = `sid=${sidShort} scope=${scope} phase=${phase}`;
108771
+ const start = Date.now();
108772
+ traceLine(`${tag} BEGIN`);
108773
+ const heartbeat = setInterval(() => {
108774
+ traceLine(`${tag} SLOW elapsed=${Date.now() - start}ms`);
108775
+ }, TRACE_SLOW_MS);
108776
+ heartbeat.unref?.();
108777
+ try {
108778
+ const result = await fn();
108779
+ clearInterval(heartbeat);
108780
+ traceLine(`${tag} END dur=${Date.now() - start}ms`);
108781
+ return result;
108782
+ } catch (err) {
108783
+ clearInterval(heartbeat);
108784
+ const msg = err instanceof Error ? err.message : String(err);
108785
+ traceLine(`${tag} THREW dur=${Date.now() - start}ms err=${msg}`);
108786
+ throw err;
108787
+ }
108788
+ }
108789
+ var TRACE_ENABLED, TRACE_SLOW_MS;
108790
+ var init_logger = __esm(() => {
108791
+ init_paths();
108792
+ TRACE_ENABLED = (() => {
108793
+ const v = process.env.UNBROWSE_TRACE;
108794
+ return v != null && v !== "" && v !== "0";
108795
+ })();
108796
+ TRACE_SLOW_MS = (() => {
108797
+ const n = parseInt(process.env.UNBROWSE_TRACE_SLOW_MS ?? "5000", 10);
108798
+ return Number.isFinite(n) && n > 0 ? n : 5000;
108799
+ })();
108800
+ });
108801
+
108802
+ // .tmp-runtime-src/domain.ts
108803
+ var exports_domain = {};
108804
+ __export(exports_domain, {
108805
+ isSameBrandDomain: () => isSameBrandDomain,
108806
+ isDomainMatch: () => isDomainMatch,
108807
+ getRegistrableDomain: () => getRegistrableDomain,
108808
+ getBrandName: () => getBrandName
108809
+ });
108810
+ function getBrandName(hostname4) {
108811
+ const h = hostname4.replace(/^\./, "").toLowerCase();
108812
+ const parts = h.split(".");
108813
+ if (parts.length >= 3) {
108814
+ const lastTwo = parts.slice(-2).join(".");
108815
+ if (GEO_TLD_SUFFIXES.has(lastTwo) || CC_TLDS.has(lastTwo)) {
108816
+ return parts[parts.length - 3] ?? parts[0] ?? h;
108817
+ }
108818
+ }
108819
+ return parts[parts.length - 2] ?? parts[0] ?? h;
108820
+ }
108821
+ function isSameBrandDomain(a, b) {
108822
+ return getBrandName(a) === getBrandName(b);
108823
+ }
108824
+ function getRegistrableDomain(hostname4) {
108825
+ const parts = hostname4.split(".");
108826
+ if (parts.length >= 3) {
108827
+ const lastTwo = parts.slice(-2).join(".");
108828
+ if (CC_TLDS.has(lastTwo) || GEO_TLD_SUFFIXES.has(lastTwo)) {
108829
+ return parts.slice(-3).join(".");
108830
+ }
108831
+ }
108832
+ return parts.slice(-2).join(".");
108833
+ }
108834
+ function isDomainMatch(cookieDomain, targetDomain) {
108835
+ const c = cookieDomain.replace(/^\./, "").toLowerCase();
108836
+ const t = targetDomain.replace(/^\./, "").toLowerCase();
108837
+ return t === c || t.endsWith("." + c);
108838
+ }
108839
+ var CC_TLDS, GEO_TLD_SUFFIXES;
108840
+ var init_domain = __esm(() => {
108841
+ CC_TLDS = new Set([
108842
+ "co.uk",
108843
+ "co.nz",
108844
+ "co.jp",
108845
+ "co.kr",
108846
+ "co.in",
108847
+ "com.br",
108848
+ "com.au",
108849
+ "com.cn",
108850
+ "com.mx",
108851
+ "com.ar",
108852
+ "com.tw",
108853
+ "org.uk",
108854
+ "gov.uk",
108855
+ "ac.uk",
108856
+ "net.au",
108857
+ "org.au"
108858
+ ]);
108859
+ GEO_TLD_SUFFIXES = new Set([
108860
+ "com.sg",
108861
+ "com.hk",
108862
+ "com.my",
108863
+ "com.ph",
108864
+ "com.vn",
108865
+ "com.id",
108866
+ "com.th",
108867
+ "com.np",
108868
+ "com.pk",
108869
+ "com.bd",
108870
+ "com.lk",
108871
+ "com.mm",
108872
+ "com.kh",
108873
+ "com.eg",
108874
+ "com.sa",
108875
+ "com.qa",
108876
+ "com.ae",
108877
+ "com.kw",
108878
+ "com.jo",
108879
+ "com.lb",
108880
+ "com.bh",
108881
+ "com.om",
108882
+ "com.iq",
108883
+ "co.id",
108884
+ "co.th",
108885
+ "co.nz",
108886
+ "co.jp",
108887
+ "co.kr",
108888
+ "co.in",
108889
+ "co.uk",
108890
+ "co.za",
108891
+ "co.zw",
108892
+ "co.ke",
108893
+ "co.tz",
108894
+ "co.ug"
108895
+ ]);
108896
+ });
108897
+
108898
+ // .tmp-runtime-src/settings.ts
108899
+ import { existsSync as existsSync22, mkdirSync as mkdirSync11, readFileSync as readFileSync19, writeFileSync as writeFileSync9 } from "node:fs";
108900
+ import { join as join23 } from "node:path";
108901
+ function sanitizeProfileName3(value) {
108902
+ return value.trim().replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
108903
+ }
108904
+ function getConfigDir3() {
108905
+ if (process.env.UNBROWSE_CONFIG_DIR)
108906
+ return process.env.UNBROWSE_CONFIG_DIR;
108907
+ const profile = sanitizeProfileName3(process.env.UNBROWSE_PROFILE ?? "");
108908
+ return profile ? join23(getUnbrowseHome2(), "profiles", profile) : getUnbrowseHome2();
108909
+ }
108910
+ function getUnbrowseConfigPath() {
108911
+ return join23(getConfigDir3(), "config.json");
108912
+ }
108913
+ function loadRawConfig() {
108914
+ try {
108915
+ const configPath2 = getUnbrowseConfigPath();
108916
+ if (existsSync22(configPath2)) {
108917
+ const parsed = JSON.parse(readFileSync19(configPath2, "utf-8"));
108918
+ if (parsed && typeof parsed === "object")
108919
+ return parsed;
108920
+ }
108921
+ } catch {}
108922
+ return {};
108923
+ }
108924
+ function saveRawConfig(config) {
108925
+ const configDir = getConfigDir3();
108926
+ if (!existsSync22(configDir))
108927
+ mkdirSync11(configDir, { recursive: true });
108928
+ writeFileSync9(getUnbrowseConfigPath(), JSON.stringify(config, null, 2), { mode: 384 });
108929
+ }
108930
+ function normalizeDomainRule(value) {
108931
+ let normalized = value.trim().toLowerCase();
108932
+ if (!normalized)
108933
+ return "";
108934
+ normalized = normalized.replace(/^\*\./, "");
108935
+ if (normalized.startsWith("http://") || normalized.startsWith("https://")) {
108936
+ try {
108937
+ normalized = new URL(normalized).hostname.toLowerCase();
108938
+ } catch {
108939
+ normalized = normalized.replace(/^https?:\/\//, "");
108940
+ }
108941
+ }
108942
+ normalized = normalized.split("/")[0] ?? normalized;
108943
+ normalized = normalized.replace(/:\d+$/, "");
108944
+ normalized = normalized.replace(/^www\./, "");
108945
+ return normalized;
108946
+ }
108947
+ function normalizeDomainList(values) {
108948
+ if (!Array.isArray(values))
108949
+ return [];
108950
+ const normalized = values.filter((value) => typeof value === "string").map(normalizeDomainRule).filter(Boolean);
108951
+ return Array.from(new Set(normalized)).sort();
108952
+ }
108953
+ function matchesDomainRule(domain, rule) {
108954
+ const host = normalizeDomainRule(domain);
108955
+ const target = normalizeDomainRule(rule);
108956
+ if (!host || !target)
108957
+ return false;
108958
+ if (host === target || host.endsWith(`.${target}`))
108959
+ return true;
108960
+ try {
108961
+ return getRegistrableDomain(host) === target;
108962
+ } catch {
108963
+ return false;
108964
+ }
108965
+ }
108966
+ function firstMatchingRule(domain, rules) {
108967
+ return rules.find((rule) => matchesDomainRule(domain, rule));
108968
+ }
108969
+ function getCapturePipelineSettings() {
108970
+ const raw = loadRawConfig();
108971
+ const capturePipeline = raw.capture_pipeline && typeof raw.capture_pipeline === "object" ? raw.capture_pipeline : {};
108972
+ return {
108973
+ auto_publish_checkpoints: capturePipeline.auto_publish_checkpoints !== false,
108974
+ publish_domain_blacklist: normalizeDomainList(capturePipeline.publish_domain_blacklist),
108975
+ publish_domain_promptlist: normalizeDomainList(capturePipeline.publish_domain_promptlist)
108976
+ };
108977
+ }
108978
+ function updateCapturePipelineSettings(update) {
108979
+ const raw = loadRawConfig();
108980
+ const existing = getCapturePipelineSettings();
108981
+ const next = {
108982
+ auto_publish_checkpoints: typeof update.auto_publish_checkpoints === "boolean" ? update.auto_publish_checkpoints : existing.auto_publish_checkpoints,
108983
+ publish_domain_blacklist: update.clear_publish_domain_blacklist ? [] : update.publish_domain_blacklist ? normalizeDomainList(update.publish_domain_blacklist) : existing.publish_domain_blacklist,
108984
+ publish_domain_promptlist: update.clear_publish_domain_promptlist ? [] : update.publish_domain_promptlist ? normalizeDomainList(update.publish_domain_promptlist) : existing.publish_domain_promptlist
108985
+ };
108986
+ saveRawConfig({
108987
+ ...raw,
108988
+ capture_pipeline: next
108989
+ });
108990
+ return next;
108991
+ }
108992
+ function getBrowserAttachPreference() {
108993
+ const raw = loadRawConfig();
108994
+ const browser = raw.browser && typeof raw.browser === "object" ? raw.browser : {};
108995
+ return typeof browser.attach_existing_chrome === "boolean" ? browser.attach_existing_chrome : undefined;
108996
+ }
108997
+ function getBrowserAttachEnabled() {
108998
+ return getBrowserAttachPreference() !== false;
108999
+ }
109000
+ function setBrowserAttachEnabled(enabled2) {
109001
+ const raw = loadRawConfig();
109002
+ const browser = raw.browser && typeof raw.browser === "object" ? { ...raw.browser } : {};
109003
+ browser.attach_existing_chrome = enabled2;
109004
+ saveRawConfig({ ...raw, browser });
109005
+ return enabled2;
109006
+ }
109007
+ function decideCheckpointPublish(domain) {
109008
+ const settings = getCapturePipelineSettings();
109009
+ if (!settings.auto_publish_checkpoints) {
109010
+ return {
109011
+ publishQueued: false,
109012
+ mode: "disabled",
109013
+ reason: "Auto-publish after sync/close is disabled in local settings."
109014
+ };
109015
+ }
109016
+ const blacklisted = firstMatchingRule(domain, settings.publish_domain_blacklist);
109017
+ if (blacklisted) {
109018
+ return {
109019
+ publishQueued: false,
109020
+ mode: "blacklisted",
109021
+ reason: `Auto-publish skipped because ${domain} matches blacklist entry ${blacklisted}.`,
109022
+ matchedDomain: blacklisted
109023
+ };
109024
+ }
109025
+ const prompted = firstMatchingRule(domain, settings.publish_domain_promptlist);
109026
+ if (prompted) {
109027
+ return {
109028
+ publishQueued: false,
109029
+ mode: "prompt",
109030
+ reason: `Auto-publish paused because ${domain} matches prompt-list entry ${prompted}.`,
109031
+ matchedDomain: prompted
109032
+ };
109033
+ }
109034
+ return {
109035
+ publishQueued: true,
109036
+ mode: "auto",
109037
+ reason: "Background publish is allowed for this checkpoint."
109038
+ };
109039
+ }
109040
+ function decideExplicitPublish(domain, confirmPublish) {
109041
+ const settings = getCapturePipelineSettings();
109042
+ const blacklisted = firstMatchingRule(domain, settings.publish_domain_blacklist);
109043
+ if (blacklisted && !confirmPublish) {
109044
+ return {
109045
+ allowed: false,
109046
+ mode: "blacklisted",
109047
+ reason: `Explicit publish requires confirmation because ${domain} matches blacklist entry ${blacklisted}.`,
109048
+ matchedDomain: blacklisted
109049
+ };
109050
+ }
109051
+ const prompted = firstMatchingRule(domain, settings.publish_domain_promptlist);
109052
+ if (prompted && !confirmPublish) {
109053
+ return {
109054
+ allowed: false,
109055
+ mode: "prompt",
109056
+ reason: `Explicit publish requires confirmation because ${domain} matches prompt-list entry ${prompted}.`,
109057
+ matchedDomain: prompted
109058
+ };
109059
+ }
109060
+ return {
109061
+ allowed: true,
109062
+ mode: "allowed",
109063
+ reason: "Explicit publish allowed."
109064
+ };
109065
+ }
109066
+ var init_settings = __esm(() => {
109067
+ init_domain();
109068
+ init_paths();
109069
+ });
109070
+
109071
+ // ../../../node_modules/ws/lib/constants.js
109072
+ var require_constants8 = __commonJS((exports, module) => {
109073
+ module.exports = {
109074
+ BINARY_TYPES: ["nodebuffer", "arraybuffer", "fragments"],
109075
+ GUID: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
109076
+ kStatusCode: Symbol("status-code"),
109077
+ kWebSocket: Symbol("websocket"),
109078
+ EMPTY_BUFFER: Buffer.alloc(0),
109079
+ NOOP: () => {}
109080
+ };
109081
+ });
109082
+
109083
+ // ../../../node_modules/node-gyp-build/node-gyp-build.js
109084
+ var require_node_gyp_build3 = __commonJS((exports, module) => {
109085
+ var fs3 = __require("fs");
109086
+ var path6 = __require("path");
109087
+ var os3 = __require("os");
109088
+ var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
109089
+ var vars = process.config && process.config.variables || {};
109090
+ var prebuildsOnly = !!process.env.PREBUILDS_ONLY;
109091
+ var abi = process.versions.modules;
109092
+ var runtime = isElectron() ? "electron" : isNwjs() ? "node-webkit" : "node";
109093
+ var arch = process.env.npm_config_arch || os3.arch();
109094
+ var platform3 = process.env.npm_config_platform || os3.platform();
109095
+ var libc = process.env.LIBC || (isAlpine(platform3) ? "musl" : "glibc");
109096
+ var armv = process.env.ARM_VERSION || (arch === "arm64" ? "8" : vars.arm_version) || "";
109097
+ var uv = (process.versions.uv || "").split(".")[0];
109098
+ module.exports = load3;
109099
+ function load3(dir) {
109100
+ return runtimeRequire(load3.resolve(dir));
109101
+ }
109102
+ load3.resolve = load3.path = function(dir) {
109103
+ dir = path6.resolve(dir || ".");
109104
+ try {
109105
+ var name = runtimeRequire(path6.join(dir, "package.json")).name.toUpperCase().replace(/-/g, "_");
109106
+ if (process.env[name + "_PREBUILD"])
109107
+ dir = process.env[name + "_PREBUILD"];
109108
+ } catch (err) {}
109109
+ if (!prebuildsOnly) {
109110
+ var release = getFirst(path6.join(dir, "build/Release"), matchBuild);
109111
+ if (release)
109112
+ return release;
109113
+ var debug = getFirst(path6.join(dir, "build/Debug"), matchBuild);
109114
+ if (debug)
109115
+ return debug;
109116
+ }
109117
+ var prebuild = resolve(dir);
109118
+ if (prebuild)
109119
+ return prebuild;
109120
+ var nearby = resolve(path6.dirname(process.execPath));
109121
+ if (nearby)
109122
+ return nearby;
109123
+ var target = [
109124
+ "platform=" + platform3,
109125
+ "arch=" + arch,
109126
+ "runtime=" + runtime,
109127
+ "abi=" + abi,
109128
+ "uv=" + uv,
109129
+ armv ? "armv=" + armv : "",
109130
+ "libc=" + libc,
109131
+ "node=" + process.versions.node,
109132
+ process.versions.electron ? "electron=" + process.versions.electron : "",
109133
+ typeof __webpack_require__ === "function" ? "webpack=true" : ""
109134
+ ].filter(Boolean).join(" ");
109135
+ throw new Error("No native build was found for " + target + `
109136
+ loaded from: ` + dir + `
109137
+ `);
109138
+ function resolve(dir2) {
109139
+ var tuples = readdirSync5(path6.join(dir2, "prebuilds")).map(parseTuple);
109140
+ var tuple = tuples.filter(matchTuple(platform3, arch)).sort(compareTuples)[0];
109141
+ if (!tuple)
109142
+ return;
109143
+ var prebuilds = path6.join(dir2, "prebuilds", tuple.name);
109144
+ var parsed = readdirSync5(prebuilds).map(parseTags);
109145
+ var candidates = parsed.filter(matchTags(runtime, abi));
109146
+ var winner = candidates.sort(compareTags(runtime))[0];
109147
+ if (winner)
109148
+ return path6.join(prebuilds, winner.file);
109149
+ }
109150
+ };
109151
+ function readdirSync5(dir) {
109152
+ try {
109153
+ return fs3.readdirSync(dir);
109154
+ } catch (err) {
109155
+ return [];
109156
+ }
109157
+ }
109158
+ function getFirst(dir, filter) {
109159
+ var files = readdirSync5(dir).filter(filter);
109160
+ return files[0] && path6.join(dir, files[0]);
109161
+ }
109162
+ function matchBuild(name) {
109163
+ return /\.node$/.test(name);
109164
+ }
109165
+ function parseTuple(name) {
109166
+ var arr = name.split("-");
109167
+ if (arr.length !== 2)
109168
+ return;
109169
+ var platform4 = arr[0];
109170
+ var architectures = arr[1].split("+");
109171
+ if (!platform4)
109172
+ return;
109173
+ if (!architectures.length)
109174
+ return;
109175
+ if (!architectures.every(Boolean))
109176
+ return;
109177
+ return { name, platform: platform4, architectures };
109178
+ }
109179
+ function matchTuple(platform4, arch2) {
109180
+ return function(tuple) {
109181
+ if (tuple == null)
109182
+ return false;
109183
+ if (tuple.platform !== platform4)
109184
+ return false;
109185
+ return tuple.architectures.includes(arch2);
109186
+ };
109187
+ }
109188
+ function compareTuples(a, b) {
109189
+ return a.architectures.length - b.architectures.length;
109190
+ }
109191
+ function parseTags(file) {
109192
+ var arr = file.split(".");
109193
+ var extension = arr.pop();
109194
+ var tags = { file, specificity: 0 };
109195
+ if (extension !== "node")
109196
+ return;
109197
+ for (var i = 0;i < arr.length; i++) {
109198
+ var tag = arr[i];
109199
+ if (tag === "node" || tag === "electron" || tag === "node-webkit") {
109200
+ tags.runtime = tag;
109201
+ } else if (tag === "napi") {
109202
+ tags.napi = true;
109203
+ } else if (tag.slice(0, 3) === "abi") {
109204
+ tags.abi = tag.slice(3);
109205
+ } else if (tag.slice(0, 2) === "uv") {
109206
+ tags.uv = tag.slice(2);
109207
+ } else if (tag.slice(0, 4) === "armv") {
109208
+ tags.armv = tag.slice(4);
109209
+ } else if (tag === "glibc" || tag === "musl") {
109210
+ tags.libc = tag;
109211
+ } else {
109212
+ continue;
109213
+ }
109214
+ tags.specificity++;
109215
+ }
109216
+ return tags;
109217
+ }
109218
+ function matchTags(runtime2, abi2) {
109219
+ return function(tags) {
109220
+ if (tags == null)
109221
+ return false;
109222
+ if (tags.runtime && tags.runtime !== runtime2 && !runtimeAgnostic(tags))
109223
+ return false;
109224
+ if (tags.abi && tags.abi !== abi2 && !tags.napi)
109225
+ return false;
109226
+ if (tags.uv && tags.uv !== uv)
109227
+ return false;
109228
+ if (tags.armv && tags.armv !== armv)
109229
+ return false;
109230
+ if (tags.libc && tags.libc !== libc)
109231
+ return false;
109232
+ return true;
109233
+ };
109234
+ }
109235
+ function runtimeAgnostic(tags) {
109236
+ return tags.runtime === "node" && tags.napi;
109237
+ }
109238
+ function compareTags(runtime2) {
109239
+ return function(a, b) {
109240
+ if (a.runtime !== b.runtime) {
109241
+ return a.runtime === runtime2 ? -1 : 1;
109242
+ } else if (a.abi !== b.abi) {
109243
+ return a.abi ? -1 : 1;
109244
+ } else if (a.specificity !== b.specificity) {
109245
+ return a.specificity > b.specificity ? -1 : 1;
109246
+ } else {
109247
+ return 0;
109248
+ }
109249
+ };
109250
+ }
109251
+ function isNwjs() {
109252
+ return !!(process.versions && process.versions.nw);
109253
+ }
109254
+ function isElectron() {
109255
+ if (process.versions && process.versions.electron)
109256
+ return true;
109257
+ if (process.env.ELECTRON_RUN_AS_NODE)
109258
+ return true;
109259
+ return typeof window !== "undefined" && window.process && window.process.type === "renderer";
109260
+ }
109261
+ function isAlpine(platform4) {
109262
+ return platform4 === "linux" && fs3.existsSync("/etc/alpine-release");
109263
+ }
109264
+ load3.parseTags = parseTags;
109265
+ load3.matchTags = matchTags;
109266
+ load3.compareTags = compareTags;
109267
+ load3.parseTuple = parseTuple;
109268
+ load3.matchTuple = matchTuple;
109269
+ load3.compareTuples = compareTuples;
109270
+ });
109271
+
109272
+ // ../../../node_modules/node-gyp-build/index.js
109273
+ var require_node_gyp_build4 = __commonJS((exports, module) => {
109274
+ var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
109275
+ if (typeof runtimeRequire.addon === "function") {
109276
+ module.exports = runtimeRequire.addon.bind(runtimeRequire);
109277
+ } else {
109278
+ module.exports = require_node_gyp_build3();
109279
+ }
109280
+ });
109281
+
109282
+ // ../../../node_modules/bufferutil/fallback.js
109283
+ var require_fallback3 = __commonJS((exports, module) => {
109284
+ var mask = (source, mask2, output, offset, length) => {
109285
+ for (var i = 0;i < length; i++) {
109286
+ output[offset + i] = source[i] ^ mask2[i & 3];
109287
+ }
109288
+ };
109289
+ var unmask = (buffer, mask2) => {
109290
+ const length = buffer.length;
109291
+ for (var i = 0;i < length; i++) {
109292
+ buffer[i] ^= mask2[i & 3];
109293
+ }
109294
+ };
109295
+ module.exports = { mask, unmask };
109296
+ });
109297
+
109298
+ // ../../../node_modules/bufferutil/index.js
109299
+ var require_bufferutil2 = __commonJS((exports, module) => {
109300
+ var __dirname = "/Users/lekt9/node_modules/bufferutil";
109301
+ try {
109302
+ module.exports = require_node_gyp_build4()(__dirname);
109303
+ } catch (e) {
109304
+ module.exports = require_fallback3();
109305
+ }
109306
+ });
109307
+
109308
+ // ../../../node_modules/ws/lib/buffer-util.js
109309
+ var require_buffer_util2 = __commonJS((exports, module) => {
109310
+ var { EMPTY_BUFFER } = require_constants8();
109311
+ function concat3(list, totalLength) {
109312
+ if (list.length === 0)
109313
+ return EMPTY_BUFFER;
109314
+ if (list.length === 1)
109315
+ return list[0];
109316
+ const target = Buffer.allocUnsafe(totalLength);
109317
+ let offset = 0;
109318
+ for (let i = 0;i < list.length; i++) {
109319
+ const buf = list[i];
109320
+ target.set(buf, offset);
109321
+ offset += buf.length;
109322
+ }
109323
+ if (offset < totalLength)
109324
+ return target.slice(0, offset);
109325
+ return target;
109326
+ }
109327
+ function _mask(source, mask, output, offset, length) {
109328
+ for (let i = 0;i < length; i++) {
109329
+ output[offset + i] = source[i] ^ mask[i & 3];
109330
+ }
109331
+ }
109332
+ function _unmask(buffer, mask) {
109333
+ const length = buffer.length;
109334
+ for (let i = 0;i < length; i++) {
109335
+ buffer[i] ^= mask[i & 3];
109336
+ }
109337
+ }
109338
+ function toArrayBuffer(buf) {
109339
+ if (buf.byteLength === buf.buffer.byteLength) {
109340
+ return buf.buffer;
109341
+ }
109342
+ return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
109343
+ }
109344
+ function toBuffer(data) {
109345
+ toBuffer.readOnly = true;
109346
+ if (Buffer.isBuffer(data))
109347
+ return data;
109348
+ let buf;
109349
+ if (data instanceof ArrayBuffer) {
109350
+ buf = Buffer.from(data);
109351
+ } else if (ArrayBuffer.isView(data)) {
109352
+ buf = Buffer.from(data.buffer, data.byteOffset, data.byteLength);
109353
+ } else {
109354
+ buf = Buffer.from(data);
109355
+ toBuffer.readOnly = false;
109356
+ }
109357
+ return buf;
109358
+ }
109359
+ try {
109360
+ const bufferUtil = require_bufferutil2();
109361
+ const bu = bufferUtil.BufferUtil || bufferUtil;
109362
+ module.exports = {
109363
+ concat: concat3,
109364
+ mask(source, mask, output, offset, length) {
109365
+ if (length < 48)
109366
+ _mask(source, mask, output, offset, length);
109367
+ else
109368
+ bu.mask(source, mask, output, offset, length);
109369
+ },
109370
+ toArrayBuffer,
109371
+ toBuffer,
109372
+ unmask(buffer, mask) {
109373
+ if (buffer.length < 32)
109374
+ _unmask(buffer, mask);
109375
+ else
109376
+ bu.unmask(buffer, mask);
109377
+ }
109378
+ };
109379
+ } catch (e) {
109380
+ module.exports = {
109381
+ concat: concat3,
109382
+ mask: _mask,
109383
+ toArrayBuffer,
109384
+ toBuffer,
109385
+ unmask: _unmask
109386
+ };
109387
+ }
109388
+ });
109389
+
109390
+ // ../../../node_modules/ws/lib/limiter.js
109391
+ var require_limiter2 = __commonJS((exports, module) => {
109392
+ var kDone = Symbol("kDone");
109393
+ var kRun = Symbol("kRun");
109394
+
109395
+ class Limiter {
109396
+ constructor(concurrency) {
109397
+ this[kDone] = () => {
109398
+ this.pending--;
109399
+ this[kRun]();
109400
+ };
109401
+ this.concurrency = concurrency || Infinity;
109402
+ this.jobs = [];
109403
+ this.pending = 0;
109404
+ }
109405
+ add(job) {
109406
+ this.jobs.push(job);
109407
+ this[kRun]();
109408
+ }
109409
+ [kRun]() {
109410
+ if (this.pending === this.concurrency)
109411
+ return;
109412
+ if (this.jobs.length) {
109413
+ const job = this.jobs.shift();
109414
+ this.pending++;
109415
+ job(this[kDone]);
109416
+ }
109417
+ }
109418
+ }
109419
+ module.exports = Limiter;
109420
+ });
109421
+
109422
+ // ../../../node_modules/ws/lib/permessage-deflate.js
109423
+ var require_permessage_deflate2 = __commonJS((exports, module) => {
109424
+ var zlib = __require("zlib");
109425
+ var bufferUtil = require_buffer_util2();
109426
+ var Limiter = require_limiter2();
109427
+ var { kStatusCode, NOOP } = require_constants8();
109428
+ var TRAILER = Buffer.from([0, 0, 255, 255]);
109429
+ var kPerMessageDeflate = Symbol("permessage-deflate");
109430
+ var kTotalLength = Symbol("total-length");
109431
+ var kCallback = Symbol("callback");
109432
+ var kBuffers = Symbol("buffers");
109433
+ var kError = Symbol("error");
109434
+ var zlibLimiter;
109435
+
109436
+ class PerMessageDeflate {
109437
+ constructor(options, isServer, maxPayload) {
109438
+ this._maxPayload = maxPayload | 0;
109439
+ this._options = options || {};
109440
+ this._threshold = this._options.threshold !== undefined ? this._options.threshold : 1024;
109441
+ this._isServer = !!isServer;
109442
+ this._deflate = null;
109443
+ this._inflate = null;
109444
+ this.params = null;
109445
+ if (!zlibLimiter) {
109446
+ const concurrency = this._options.concurrencyLimit !== undefined ? this._options.concurrencyLimit : 10;
109447
+ zlibLimiter = new Limiter(concurrency);
109448
+ }
109449
+ }
109450
+ static get extensionName() {
109451
+ return "permessage-deflate";
109452
+ }
109453
+ offer() {
109454
+ const params = {};
109455
+ if (this._options.serverNoContextTakeover) {
109456
+ params.server_no_context_takeover = true;
109457
+ }
109458
+ if (this._options.clientNoContextTakeover) {
109459
+ params.client_no_context_takeover = true;
109460
+ }
109461
+ if (this._options.serverMaxWindowBits) {
109462
+ params.server_max_window_bits = this._options.serverMaxWindowBits;
109463
+ }
109464
+ if (this._options.clientMaxWindowBits) {
109465
+ params.client_max_window_bits = this._options.clientMaxWindowBits;
109466
+ } else if (this._options.clientMaxWindowBits == null) {
109467
+ params.client_max_window_bits = true;
109468
+ }
109469
+ return params;
109470
+ }
109471
+ accept(configurations) {
109472
+ configurations = this.normalizeParams(configurations);
109473
+ this.params = this._isServer ? this.acceptAsServer(configurations) : this.acceptAsClient(configurations);
109474
+ return this.params;
109475
+ }
109476
+ cleanup() {
109477
+ if (this._inflate) {
109478
+ this._inflate.close();
109479
+ this._inflate = null;
109480
+ }
109481
+ if (this._deflate) {
109482
+ const callback = this._deflate[kCallback];
109483
+ this._deflate.close();
109484
+ this._deflate = null;
109485
+ if (callback) {
109486
+ callback(new Error("The deflate stream was closed while data was being processed"));
109487
+ }
109488
+ }
109489
+ }
109490
+ acceptAsServer(offers) {
109491
+ const opts = this._options;
109492
+ const accepted = offers.find((params) => {
109493
+ 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) {
109494
+ return false;
109495
+ }
109496
+ return true;
109497
+ });
109498
+ if (!accepted) {
109499
+ throw new Error("None of the extension offers can be accepted");
109500
+ }
109501
+ if (opts.serverNoContextTakeover) {
109502
+ accepted.server_no_context_takeover = true;
109503
+ }
109504
+ if (opts.clientNoContextTakeover) {
109505
+ accepted.client_no_context_takeover = true;
109506
+ }
109507
+ if (typeof opts.serverMaxWindowBits === "number") {
109508
+ accepted.server_max_window_bits = opts.serverMaxWindowBits;
109509
+ }
109510
+ if (typeof opts.clientMaxWindowBits === "number") {
109511
+ accepted.client_max_window_bits = opts.clientMaxWindowBits;
109512
+ } else if (accepted.client_max_window_bits === true || opts.clientMaxWindowBits === false) {
109513
+ delete accepted.client_max_window_bits;
109514
+ }
109515
+ return accepted;
109516
+ }
109517
+ acceptAsClient(response) {
109518
+ const params = response[0];
109519
+ if (this._options.clientNoContextTakeover === false && params.client_no_context_takeover) {
109520
+ throw new Error('Unexpected parameter "client_no_context_takeover"');
109521
+ }
109522
+ if (!params.client_max_window_bits) {
109523
+ if (typeof this._options.clientMaxWindowBits === "number") {
109524
+ params.client_max_window_bits = this._options.clientMaxWindowBits;
109525
+ }
109526
+ } else if (this._options.clientMaxWindowBits === false || typeof this._options.clientMaxWindowBits === "number" && params.client_max_window_bits > this._options.clientMaxWindowBits) {
109527
+ throw new Error('Unexpected or invalid parameter "client_max_window_bits"');
109528
+ }
109529
+ return params;
109530
+ }
109531
+ normalizeParams(configurations) {
109532
+ configurations.forEach((params) => {
109533
+ Object.keys(params).forEach((key) => {
109534
+ let value = params[key];
109535
+ if (value.length > 1) {
109536
+ throw new Error(`Parameter "${key}" must have only a single value`);
109537
+ }
109538
+ value = value[0];
109539
+ if (key === "client_max_window_bits") {
109540
+ if (value !== true) {
109541
+ const num = +value;
109542
+ if (!Number.isInteger(num) || num < 8 || num > 15) {
109543
+ throw new TypeError(`Invalid value for parameter "${key}": ${value}`);
109544
+ }
109545
+ value = num;
109546
+ } else if (!this._isServer) {
109547
+ throw new TypeError(`Invalid value for parameter "${key}": ${value}`);
109548
+ }
109549
+ } else if (key === "server_max_window_bits") {
109550
+ const num = +value;
109551
+ if (!Number.isInteger(num) || num < 8 || num > 15) {
109552
+ throw new TypeError(`Invalid value for parameter "${key}": ${value}`);
109553
+ }
109554
+ value = num;
109555
+ } else if (key === "client_no_context_takeover" || key === "server_no_context_takeover") {
109556
+ if (value !== true) {
109557
+ throw new TypeError(`Invalid value for parameter "${key}": ${value}`);
109558
+ }
109559
+ } else {
109560
+ throw new Error(`Unknown parameter "${key}"`);
109561
+ }
109562
+ params[key] = value;
109563
+ });
109564
+ });
109565
+ return configurations;
109566
+ }
109567
+ decompress(data, fin, callback) {
109568
+ zlibLimiter.add((done) => {
109569
+ this._decompress(data, fin, (err, result) => {
109570
+ done();
109571
+ callback(err, result);
109572
+ });
109573
+ });
109574
+ }
109575
+ compress(data, fin, callback) {
109576
+ zlibLimiter.add((done) => {
109577
+ this._compress(data, fin, (err, result) => {
109578
+ done();
109579
+ callback(err, result);
109580
+ });
109581
+ });
109582
+ }
109583
+ _decompress(data, fin, callback) {
109584
+ const endpoint = this._isServer ? "client" : "server";
109585
+ if (!this._inflate) {
109586
+ const key = `${endpoint}_max_window_bits`;
109587
+ const windowBits = typeof this.params[key] !== "number" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key];
109588
+ this._inflate = zlib.createInflateRaw({
109589
+ ...this._options.zlibInflateOptions,
109590
+ windowBits
109591
+ });
109592
+ this._inflate[kPerMessageDeflate] = this;
109593
+ this._inflate[kTotalLength] = 0;
109594
+ this._inflate[kBuffers] = [];
109595
+ this._inflate.on("error", inflateOnError);
109596
+ this._inflate.on("data", inflateOnData);
109597
+ }
109598
+ this._inflate[kCallback] = callback;
109599
+ this._inflate.write(data);
109600
+ if (fin)
109601
+ this._inflate.write(TRAILER);
109602
+ this._inflate.flush(() => {
109603
+ const err = this._inflate[kError];
109604
+ if (err) {
109605
+ this._inflate.close();
109606
+ this._inflate = null;
109607
+ callback(err);
109608
+ return;
109609
+ }
109610
+ const data2 = bufferUtil.concat(this._inflate[kBuffers], this._inflate[kTotalLength]);
109611
+ if (this._inflate._readableState.endEmitted) {
109612
+ this._inflate.close();
109613
+ this._inflate = null;
109614
+ } else {
109615
+ this._inflate[kTotalLength] = 0;
109616
+ this._inflate[kBuffers] = [];
109617
+ if (fin && this.params[`${endpoint}_no_context_takeover`]) {
109618
+ this._inflate.reset();
109619
+ }
109620
+ }
109621
+ callback(null, data2);
109622
+ });
109623
+ }
109624
+ _compress(data, fin, callback) {
109625
+ const endpoint = this._isServer ? "server" : "client";
109626
+ if (!this._deflate) {
109627
+ const key = `${endpoint}_max_window_bits`;
109628
+ const windowBits = typeof this.params[key] !== "number" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key];
109629
+ this._deflate = zlib.createDeflateRaw({
109630
+ ...this._options.zlibDeflateOptions,
109631
+ windowBits
109632
+ });
109633
+ this._deflate[kTotalLength] = 0;
109634
+ this._deflate[kBuffers] = [];
109635
+ this._deflate.on("error", NOOP);
109636
+ this._deflate.on("data", deflateOnData);
109637
+ }
109638
+ this._deflate[kCallback] = callback;
109639
+ this._deflate.write(data);
109640
+ this._deflate.flush(zlib.Z_SYNC_FLUSH, () => {
109641
+ if (!this._deflate) {
109642
+ return;
109643
+ }
109644
+ let data2 = bufferUtil.concat(this._deflate[kBuffers], this._deflate[kTotalLength]);
109645
+ if (fin)
109646
+ data2 = data2.slice(0, data2.length - 4);
109647
+ this._deflate[kCallback] = null;
109648
+ this._deflate[kTotalLength] = 0;
109649
+ this._deflate[kBuffers] = [];
109650
+ if (fin && this.params[`${endpoint}_no_context_takeover`]) {
109651
+ this._deflate.reset();
109652
+ }
109653
+ callback(null, data2);
109654
+ });
109655
+ }
109656
+ }
109657
+ module.exports = PerMessageDeflate;
109658
+ function deflateOnData(chunk) {
109659
+ this[kBuffers].push(chunk);
109660
+ this[kTotalLength] += chunk.length;
109661
+ }
109662
+ function inflateOnData(chunk) {
109663
+ this[kTotalLength] += chunk.length;
109664
+ if (this[kPerMessageDeflate]._maxPayload < 1 || this[kTotalLength] <= this[kPerMessageDeflate]._maxPayload) {
109665
+ this[kBuffers].push(chunk);
109666
+ return;
109667
+ }
109668
+ this[kError] = new RangeError("Max payload size exceeded");
109669
+ this[kError].code = "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH";
109670
+ this[kError][kStatusCode] = 1009;
109671
+ this.removeListener("data", inflateOnData);
109672
+ this.reset();
109673
+ }
109674
+ function inflateOnError(err) {
109675
+ this[kPerMessageDeflate]._inflate = null;
109676
+ err[kStatusCode] = 1007;
109677
+ this[kCallback](err);
109678
+ }
109679
+ });
109680
+
109681
+ // ../../../node_modules/ws/lib/validation.js
109682
+ var require_validation4 = __commonJS((exports, module) => {
109683
+ function isValidStatusCode(code) {
109684
+ return code >= 1000 && code <= 1014 && code !== 1004 && code !== 1005 && code !== 1006 || code >= 3000 && code <= 4999;
109685
+ }
109686
+ function _isValidUTF8(buf) {
109687
+ const len = buf.length;
109688
+ let i = 0;
109689
+ while (i < len) {
109690
+ if ((buf[i] & 128) === 0) {
109691
+ i++;
109692
+ } else if ((buf[i] & 224) === 192) {
109693
+ if (i + 1 === len || (buf[i + 1] & 192) !== 128 || (buf[i] & 254) === 192) {
109694
+ return false;
109695
+ }
109696
+ i += 2;
109697
+ } else if ((buf[i] & 240) === 224) {
109698
+ if (i + 2 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || buf[i] === 224 && (buf[i + 1] & 224) === 128 || buf[i] === 237 && (buf[i + 1] & 224) === 160) {
109699
+ return false;
109700
+ }
109701
+ i += 3;
109702
+ } else if ((buf[i] & 248) === 240) {
109703
+ 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 || buf[i] === 244 && buf[i + 1] > 143 || buf[i] > 244) {
109704
+ return false;
109705
+ }
109706
+ i += 4;
109707
+ } else {
109708
+ return false;
109709
+ }
109710
+ }
109711
+ return true;
109712
+ }
109713
+ try {
109714
+ let isValidUTF8 = (()=>{throw new Error("Cannot require module "+"utf-8-validate");})();
109715
+ if (typeof isValidUTF8 === "object") {
109716
+ isValidUTF8 = isValidUTF8.Validation.isValidUTF8;
109717
+ }
109718
+ module.exports = {
109719
+ isValidStatusCode,
109720
+ isValidUTF8(buf) {
109721
+ return buf.length < 150 ? _isValidUTF8(buf) : isValidUTF8(buf);
109722
+ }
109723
+ };
109724
+ } catch (e) {
109725
+ module.exports = {
109726
+ isValidStatusCode,
109727
+ isValidUTF8: _isValidUTF8
109728
+ };
109729
+ }
109730
+ });
109731
+
109732
+ // ../../../node_modules/ws/lib/receiver.js
109733
+ var require_receiver2 = __commonJS((exports, module) => {
109734
+ var { Writable } = __require("stream");
109735
+ var PerMessageDeflate = require_permessage_deflate2();
109736
+ var {
109737
+ BINARY_TYPES,
109738
+ EMPTY_BUFFER,
109739
+ kStatusCode,
109740
+ kWebSocket
109741
+ } = require_constants8();
109742
+ var { concat: concat3, toArrayBuffer, unmask } = require_buffer_util2();
109743
+ var { isValidStatusCode, isValidUTF8 } = require_validation4();
109744
+ var GET_INFO = 0;
109745
+ var GET_PAYLOAD_LENGTH_16 = 1;
109746
+ var GET_PAYLOAD_LENGTH_64 = 2;
109747
+ var GET_MASK = 3;
109748
+ var GET_DATA = 4;
109749
+ var INFLATING = 5;
109750
+
109751
+ class Receiver extends Writable {
109752
+ constructor(binaryType, extensions, isServer, maxPayload, maxBufferedChunks, maxFragments) {
109753
+ super();
109754
+ this._binaryType = binaryType || BINARY_TYPES[0];
109755
+ this[kWebSocket] = undefined;
109756
+ this._extensions = extensions || {};
109757
+ this._isServer = !!isServer;
109758
+ this._maxBufferedChunks = maxBufferedChunks | 0;
109759
+ this._maxFragments = maxFragments | 0;
109760
+ this._maxPayload = maxPayload | 0;
109761
+ this._bufferedBytes = 0;
109762
+ this._buffers = [];
109763
+ this._compressed = false;
109764
+ this._payloadLength = 0;
109765
+ this._mask = undefined;
109766
+ this._fragmented = 0;
109767
+ this._masked = false;
109768
+ this._fin = false;
109769
+ this._opcode = 0;
109770
+ this._totalPayloadLength = 0;
109771
+ this._messageLength = 0;
109772
+ this._fragments = [];
109773
+ this._state = GET_INFO;
109774
+ this._loop = false;
109775
+ }
109776
+ _write(chunk, encoding, cb) {
109777
+ if (this._opcode === 8 && this._state == GET_INFO)
109778
+ return cb();
109779
+ if (this._maxBufferedChunks > 0 && this._buffers.length >= this._maxBufferedChunks) {
109780
+ return cb(error(RangeError, "Too many buffered chunks", false, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS"));
109781
+ }
109782
+ this._bufferedBytes += chunk.length;
109783
+ this._buffers.push(chunk);
109784
+ this.startLoop(cb);
109785
+ }
109786
+ consume(n) {
109787
+ this._bufferedBytes -= n;
109788
+ if (n === this._buffers[0].length)
109789
+ return this._buffers.shift();
109790
+ if (n < this._buffers[0].length) {
109791
+ const buf = this._buffers[0];
109792
+ this._buffers[0] = buf.slice(n);
109793
+ return buf.slice(0, n);
109794
+ }
109795
+ const dst = Buffer.allocUnsafe(n);
109796
+ do {
109797
+ const buf = this._buffers[0];
109798
+ const offset = dst.length - n;
109799
+ if (n >= buf.length) {
109800
+ dst.set(this._buffers.shift(), offset);
109801
+ } else {
109802
+ dst.set(new Uint8Array(buf.buffer, buf.byteOffset, n), offset);
109803
+ this._buffers[0] = buf.slice(n);
109804
+ }
109805
+ n -= buf.length;
109806
+ } while (n > 0);
109807
+ return dst;
109808
+ }
109809
+ startLoop(cb) {
109810
+ let err;
109811
+ this._loop = true;
109812
+ do {
109813
+ switch (this._state) {
109814
+ case GET_INFO:
109815
+ err = this.getInfo();
109816
+ break;
109817
+ case GET_PAYLOAD_LENGTH_16:
109818
+ err = this.getPayloadLength16();
109819
+ break;
109820
+ case GET_PAYLOAD_LENGTH_64:
109821
+ err = this.getPayloadLength64();
109822
+ break;
109823
+ case GET_MASK:
109824
+ this.getMask();
109825
+ break;
109826
+ case GET_DATA:
109827
+ err = this.getData(cb);
109828
+ break;
109829
+ default:
109830
+ this._loop = false;
109831
+ return;
109832
+ }
109833
+ } while (this._loop);
109834
+ cb(err);
109835
+ }
109836
+ getInfo() {
109837
+ if (this._bufferedBytes < 2) {
109838
+ this._loop = false;
109839
+ return;
109840
+ }
109841
+ const buf = this.consume(2);
109842
+ if ((buf[0] & 48) !== 0) {
109843
+ this._loop = false;
109844
+ return error(RangeError, "RSV2 and RSV3 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_2_3");
109845
+ }
109846
+ const compressed = (buf[0] & 64) === 64;
109847
+ if (compressed && !this._extensions[PerMessageDeflate.extensionName]) {
109848
+ this._loop = false;
109849
+ return error(RangeError, "RSV1 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_1");
109850
+ }
109851
+ this._fin = (buf[0] & 128) === 128;
109852
+ this._opcode = buf[0] & 15;
109853
+ this._payloadLength = buf[1] & 127;
109854
+ if (this._opcode === 0) {
109855
+ if (compressed) {
109856
+ this._loop = false;
109857
+ return error(RangeError, "RSV1 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_1");
109858
+ }
109859
+ if (!this._fragmented) {
109860
+ this._loop = false;
109861
+ return error(RangeError, "invalid opcode 0", true, 1002, "WS_ERR_INVALID_OPCODE");
109862
+ }
109863
+ this._opcode = this._fragmented;
109864
+ } else if (this._opcode === 1 || this._opcode === 2) {
109865
+ if (this._fragmented) {
109866
+ this._loop = false;
109867
+ return error(RangeError, `invalid opcode ${this._opcode}`, true, 1002, "WS_ERR_INVALID_OPCODE");
109868
+ }
109869
+ this._compressed = compressed;
109870
+ } else if (this._opcode > 7 && this._opcode < 11) {
109871
+ if (!this._fin) {
109872
+ this._loop = false;
109873
+ return error(RangeError, "FIN must be set", true, 1002, "WS_ERR_EXPECTED_FIN");
109874
+ }
109875
+ if (compressed) {
109876
+ this._loop = false;
109877
+ return error(RangeError, "RSV1 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_1");
109878
+ }
109879
+ if (this._payloadLength > 125) {
109880
+ this._loop = false;
109881
+ return error(RangeError, `invalid payload length ${this._payloadLength}`, true, 1002, "WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");
109882
+ }
109883
+ } else {
109884
+ this._loop = false;
109885
+ return error(RangeError, `invalid opcode ${this._opcode}`, true, 1002, "WS_ERR_INVALID_OPCODE");
109886
+ }
109887
+ if (!this._fin && !this._fragmented)
109888
+ this._fragmented = this._opcode;
109889
+ this._masked = (buf[1] & 128) === 128;
109890
+ if (this._isServer) {
109891
+ if (!this._masked) {
109892
+ this._loop = false;
109893
+ return error(RangeError, "MASK must be set", true, 1002, "WS_ERR_EXPECTED_MASK");
109894
+ }
109895
+ } else if (this._masked) {
109896
+ this._loop = false;
109897
+ return error(RangeError, "MASK must be clear", true, 1002, "WS_ERR_UNEXPECTED_MASK");
109898
+ }
109899
+ if (this._payloadLength === 126)
109900
+ this._state = GET_PAYLOAD_LENGTH_16;
109901
+ else if (this._payloadLength === 127)
109902
+ this._state = GET_PAYLOAD_LENGTH_64;
109903
+ else
109904
+ return this.haveLength();
109905
+ }
109906
+ getPayloadLength16() {
109907
+ if (this._bufferedBytes < 2) {
109908
+ this._loop = false;
109909
+ return;
109910
+ }
109911
+ this._payloadLength = this.consume(2).readUInt16BE(0);
109912
+ return this.haveLength();
109913
+ }
109914
+ getPayloadLength64() {
109915
+ if (this._bufferedBytes < 8) {
109916
+ this._loop = false;
109917
+ return;
109918
+ }
109919
+ const buf = this.consume(8);
109920
+ const num = buf.readUInt32BE(0);
109921
+ if (num > Math.pow(2, 53 - 32) - 1) {
109922
+ this._loop = false;
109923
+ return error(RangeError, "Unsupported WebSocket frame: payload length > 2^53 - 1", false, 1009, "WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");
109924
+ }
109925
+ this._payloadLength = num * Math.pow(2, 32) + buf.readUInt32BE(4);
109926
+ return this.haveLength();
109927
+ }
109928
+ haveLength() {
109929
+ if (this._payloadLength && this._opcode < 8) {
109930
+ this._totalPayloadLength += this._payloadLength;
109931
+ if (this._totalPayloadLength > this._maxPayload && this._maxPayload > 0) {
109932
+ this._loop = false;
109933
+ return error(RangeError, "Max payload size exceeded", false, 1009, "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");
109934
+ }
109935
+ }
109936
+ if (this._masked)
109937
+ this._state = GET_MASK;
109938
+ else
109939
+ this._state = GET_DATA;
109940
+ }
109941
+ getMask() {
109942
+ if (this._bufferedBytes < 4) {
109943
+ this._loop = false;
109944
+ return;
109945
+ }
109946
+ this._mask = this.consume(4);
109947
+ this._state = GET_DATA;
109948
+ }
109949
+ getData(cb) {
109950
+ let data = EMPTY_BUFFER;
109951
+ if (this._payloadLength) {
109952
+ if (this._bufferedBytes < this._payloadLength) {
109953
+ this._loop = false;
109954
+ return;
109955
+ }
109956
+ data = this.consume(this._payloadLength);
109957
+ if (this._masked)
109958
+ unmask(data, this._mask);
109959
+ }
109960
+ if (this._opcode > 7)
109961
+ return this.controlMessage(data);
109962
+ if (this._compressed) {
109963
+ this._state = INFLATING;
109964
+ this.decompress(data, cb);
109965
+ return;
109966
+ }
109967
+ if (data.length) {
109968
+ if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
109969
+ this._loop = false;
109970
+ return error(RangeError, "Too many message fragments", false, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS");
109971
+ }
109972
+ this._messageLength = this._totalPayloadLength;
109973
+ this._fragments.push(data);
109974
+ }
109975
+ return this.dataMessage();
109976
+ }
109977
+ decompress(data, cb) {
109978
+ const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
109979
+ perMessageDeflate.decompress(data, this._fin, (err, buf) => {
109980
+ if (err)
109981
+ return cb(err);
109982
+ if (buf.length) {
109983
+ this._messageLength += buf.length;
109984
+ if (this._messageLength > this._maxPayload && this._maxPayload > 0) {
109985
+ return cb(error(RangeError, "Max payload size exceeded", false, 1009, "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));
109986
+ }
109987
+ if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
109988
+ return cb(error(RangeError, "Too many message fragments", false, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS"));
109989
+ }
109990
+ this._fragments.push(buf);
109991
+ }
109992
+ const er = this.dataMessage();
109993
+ if (er)
109994
+ return cb(er);
109995
+ this.startLoop(cb);
109996
+ });
109997
+ }
109998
+ dataMessage() {
109999
+ if (this._fin) {
110000
+ const messageLength = this._messageLength;
110001
+ const fragments = this._fragments;
110002
+ this._totalPayloadLength = 0;
110003
+ this._messageLength = 0;
110004
+ this._fragmented = 0;
110005
+ this._fragments = [];
110006
+ if (this._opcode === 2) {
110007
+ let data;
110008
+ if (this._binaryType === "nodebuffer") {
110009
+ data = concat3(fragments, messageLength);
110010
+ } else if (this._binaryType === "arraybuffer") {
110011
+ data = toArrayBuffer(concat3(fragments, messageLength));
110012
+ } else {
110013
+ data = fragments;
110014
+ }
110015
+ this.emit("message", data);
110016
+ } else {
110017
+ const buf = concat3(fragments, messageLength);
110018
+ if (!isValidUTF8(buf)) {
110019
+ this._loop = false;
110020
+ return error(Error, "invalid UTF-8 sequence", true, 1007, "WS_ERR_INVALID_UTF8");
110021
+ }
110022
+ this.emit("message", buf.toString());
110023
+ }
110024
+ }
110025
+ this._state = GET_INFO;
110026
+ }
110027
+ controlMessage(data) {
110028
+ if (this._opcode === 8) {
110029
+ this._loop = false;
110030
+ if (data.length === 0) {
110031
+ this.emit("conclude", 1005, "");
110032
+ this.end();
110033
+ } else if (data.length === 1) {
110034
+ return error(RangeError, "invalid payload length 1", true, 1002, "WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");
110035
+ } else {
110036
+ const code = data.readUInt16BE(0);
110037
+ if (!isValidStatusCode(code)) {
110038
+ return error(RangeError, `invalid status code ${code}`, true, 1002, "WS_ERR_INVALID_CLOSE_CODE");
110039
+ }
110040
+ const buf = data.slice(2);
110041
+ if (!isValidUTF8(buf)) {
110042
+ return error(Error, "invalid UTF-8 sequence", true, 1007, "WS_ERR_INVALID_UTF8");
110043
+ }
110044
+ this.emit("conclude", code, buf.toString());
110045
+ this.end();
110046
+ }
110047
+ } else if (this._opcode === 9) {
110048
+ this.emit("ping", data);
110049
+ } else {
110050
+ this.emit("pong", data);
110051
+ }
110052
+ this._state = GET_INFO;
110053
+ }
110054
+ }
110055
+ module.exports = Receiver;
110056
+ function error(ErrorCtor, message, prefix, statusCode, errorCode) {
110057
+ const err = new ErrorCtor(prefix ? `Invalid WebSocket frame: ${message}` : message);
110058
+ Error.captureStackTrace(err, error);
110059
+ err.code = errorCode;
110060
+ err[kStatusCode] = statusCode;
110061
+ return err;
110062
+ }
110063
+ });
110064
+
110065
+ // ../../../node_modules/ws/lib/sender.js
110066
+ var require_sender2 = __commonJS((exports, module) => {
110067
+ var net = __require("net");
110068
+ var tls = __require("tls");
110069
+ var { randomFillSync } = __require("crypto");
110070
+ var PerMessageDeflate = require_permessage_deflate2();
110071
+ var { EMPTY_BUFFER } = require_constants8();
110072
+ var { isValidStatusCode } = require_validation4();
110073
+ var { mask: applyMask, toBuffer } = require_buffer_util2();
110074
+ var mask = Buffer.alloc(4);
110075
+
110076
+ class Sender {
110077
+ constructor(socket, extensions) {
110078
+ this._extensions = extensions || {};
110079
+ this._socket = socket;
110080
+ this._firstFragment = true;
110081
+ this._compress = false;
110082
+ this._bufferedBytes = 0;
110083
+ this._deflating = false;
110084
+ this._queue = [];
110085
+ }
110086
+ static frame(data, options) {
110087
+ const merge = options.mask && options.readOnly;
110088
+ let offset = options.mask ? 6 : 2;
110089
+ let payloadLength = data.length;
110090
+ if (data.length >= 65536) {
110091
+ offset += 8;
110092
+ payloadLength = 127;
110093
+ } else if (data.length > 125) {
110094
+ offset += 2;
110095
+ payloadLength = 126;
110096
+ }
110097
+ const target = Buffer.allocUnsafe(merge ? data.length + offset : offset);
110098
+ target[0] = options.fin ? options.opcode | 128 : options.opcode;
110099
+ if (options.rsv1)
110100
+ target[0] |= 64;
110101
+ target[1] = payloadLength;
110102
+ if (payloadLength === 126) {
110103
+ target.writeUInt16BE(data.length, 2);
110104
+ } else if (payloadLength === 127) {
110105
+ target.writeUInt32BE(0, 2);
110106
+ target.writeUInt32BE(data.length, 6);
110107
+ }
110108
+ if (!options.mask)
110109
+ return [target, data];
110110
+ randomFillSync(mask, 0, 4);
110111
+ target[1] |= 128;
110112
+ target[offset - 4] = mask[0];
110113
+ target[offset - 3] = mask[1];
110114
+ target[offset - 2] = mask[2];
110115
+ target[offset - 1] = mask[3];
110116
+ if (merge) {
110117
+ applyMask(data, mask, target, offset, data.length);
110118
+ return [target];
110119
+ }
110120
+ applyMask(data, mask, data, 0, data.length);
110121
+ return [target, data];
110122
+ }
110123
+ close(code, data, mask2, cb) {
110124
+ let buf;
110125
+ if (code === undefined) {
110126
+ buf = EMPTY_BUFFER;
110127
+ } else if (typeof code !== "number" || !isValidStatusCode(code)) {
110128
+ throw new TypeError("First argument must be a valid error code number");
110129
+ } else if (data === undefined || data === "") {
110130
+ buf = Buffer.allocUnsafe(2);
110131
+ buf.writeUInt16BE(code, 0);
110132
+ } else {
110133
+ const length = Buffer.byteLength(data);
110134
+ if (length > 123) {
110135
+ throw new RangeError("The message must not be greater than 123 bytes");
110136
+ }
110137
+ buf = Buffer.allocUnsafe(2 + length);
110138
+ buf.writeUInt16BE(code, 0);
110139
+ buf.write(data, 2);
110140
+ }
110141
+ if (this._deflating) {
110142
+ this.enqueue([this.doClose, buf, mask2, cb]);
110143
+ } else {
110144
+ this.doClose(buf, mask2, cb);
110145
+ }
110146
+ }
110147
+ doClose(data, mask2, cb) {
110148
+ this.sendFrame(Sender.frame(data, {
110149
+ fin: true,
110150
+ rsv1: false,
110151
+ opcode: 8,
110152
+ mask: mask2,
110153
+ readOnly: false
110154
+ }), cb);
110155
+ }
110156
+ ping(data, mask2, cb) {
110157
+ const buf = toBuffer(data);
110158
+ if (buf.length > 125) {
110159
+ throw new RangeError("The data size must not be greater than 125 bytes");
110160
+ }
110161
+ if (this._deflating) {
110162
+ this.enqueue([this.doPing, buf, mask2, toBuffer.readOnly, cb]);
110163
+ } else {
110164
+ this.doPing(buf, mask2, toBuffer.readOnly, cb);
110165
+ }
110166
+ }
110167
+ doPing(data, mask2, readOnly, cb) {
110168
+ this.sendFrame(Sender.frame(data, {
110169
+ fin: true,
110170
+ rsv1: false,
110171
+ opcode: 9,
110172
+ mask: mask2,
110173
+ readOnly
110174
+ }), cb);
110175
+ }
110176
+ pong(data, mask2, cb) {
110177
+ const buf = toBuffer(data);
110178
+ if (buf.length > 125) {
110179
+ throw new RangeError("The data size must not be greater than 125 bytes");
110180
+ }
110181
+ if (this._deflating) {
110182
+ this.enqueue([this.doPong, buf, mask2, toBuffer.readOnly, cb]);
110183
+ } else {
110184
+ this.doPong(buf, mask2, toBuffer.readOnly, cb);
110185
+ }
110186
+ }
110187
+ doPong(data, mask2, readOnly, cb) {
110188
+ this.sendFrame(Sender.frame(data, {
110189
+ fin: true,
110190
+ rsv1: false,
110191
+ opcode: 10,
110192
+ mask: mask2,
110193
+ readOnly
110194
+ }), cb);
110195
+ }
110196
+ send(data, options, cb) {
110197
+ const buf = toBuffer(data);
110198
+ const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
110199
+ let opcode = options.binary ? 2 : 1;
110200
+ let rsv1 = options.compress;
110201
+ if (this._firstFragment) {
110202
+ this._firstFragment = false;
110203
+ if (rsv1 && perMessageDeflate) {
110204
+ rsv1 = buf.length >= perMessageDeflate._threshold;
110205
+ }
110206
+ this._compress = rsv1;
110207
+ } else {
110208
+ rsv1 = false;
110209
+ opcode = 0;
110210
+ }
110211
+ if (options.fin)
110212
+ this._firstFragment = true;
110213
+ if (perMessageDeflate) {
110214
+ const opts = {
110215
+ fin: options.fin,
110216
+ rsv1,
110217
+ opcode,
110218
+ mask: options.mask,
110219
+ readOnly: toBuffer.readOnly
110220
+ };
110221
+ if (this._deflating) {
110222
+ this.enqueue([this.dispatch, buf, this._compress, opts, cb]);
110223
+ } else {
110224
+ this.dispatch(buf, this._compress, opts, cb);
110225
+ }
110226
+ } else {
110227
+ this.sendFrame(Sender.frame(buf, {
110228
+ fin: options.fin,
110229
+ rsv1: false,
110230
+ opcode,
110231
+ mask: options.mask,
110232
+ readOnly: toBuffer.readOnly
110233
+ }), cb);
110234
+ }
110235
+ }
110236
+ dispatch(data, compress, options, cb) {
110237
+ if (!compress) {
110238
+ this.sendFrame(Sender.frame(data, options), cb);
110239
+ return;
110240
+ }
110241
+ const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
110242
+ this._bufferedBytes += data.length;
110243
+ this._deflating = true;
110244
+ perMessageDeflate.compress(data, options.fin, (_, buf) => {
110245
+ if (this._socket.destroyed) {
110246
+ const err = new Error("The socket was closed while data was being compressed");
110247
+ if (typeof cb === "function")
110248
+ cb(err);
110249
+ for (let i = 0;i < this._queue.length; i++) {
110250
+ const callback = this._queue[i][4];
110251
+ if (typeof callback === "function")
110252
+ callback(err);
110253
+ }
110254
+ return;
110255
+ }
110256
+ this._bufferedBytes -= data.length;
110257
+ this._deflating = false;
110258
+ options.readOnly = false;
110259
+ this.sendFrame(Sender.frame(buf, options), cb);
110260
+ this.dequeue();
110261
+ });
110262
+ }
110263
+ dequeue() {
110264
+ while (!this._deflating && this._queue.length) {
110265
+ const params = this._queue.shift();
110266
+ this._bufferedBytes -= params[1].length;
110267
+ Reflect.apply(params[0], this, params.slice(1));
110268
+ }
110269
+ }
110270
+ enqueue(params) {
110271
+ this._bufferedBytes += params[1].length;
110272
+ this._queue.push(params);
110273
+ }
110274
+ sendFrame(list, cb) {
110275
+ if (list.length === 2) {
110276
+ this._socket.cork();
110277
+ this._socket.write(list[0]);
110278
+ this._socket.write(list[1], cb);
110279
+ this._socket.uncork();
110280
+ } else {
110281
+ this._socket.write(list[0], cb);
110282
+ }
110283
+ }
110284
+ }
110285
+ module.exports = Sender;
110286
+ });
110287
+
110288
+ // ../../../node_modules/ws/lib/event-target.js
110289
+ var require_event_target2 = __commonJS((exports, module) => {
110290
+ class Event2 {
110291
+ constructor(type, target) {
110292
+ this.target = target;
110293
+ this.type = type;
110294
+ }
110295
+ }
110296
+
110297
+ class MessageEvent extends Event2 {
110298
+ constructor(data, target) {
110299
+ super("message", target);
110300
+ this.data = data;
110301
+ }
110302
+ }
110303
+
110304
+ class CloseEvent extends Event2 {
110305
+ constructor(code, reason, target) {
110306
+ super("close", target);
110307
+ this.wasClean = target._closeFrameReceived && target._closeFrameSent;
110308
+ this.reason = reason;
110309
+ this.code = code;
110310
+ }
110311
+ }
110312
+
110313
+ class OpenEvent extends Event2 {
110314
+ constructor(target) {
110315
+ super("open", target);
110316
+ }
110317
+ }
110318
+
110319
+ class ErrorEvent extends Event2 {
110320
+ constructor(error, target) {
110321
+ super("error", target);
110322
+ this.message = error.message;
110323
+ this.error = error;
110324
+ }
110325
+ }
110326
+ var EventTarget2 = {
110327
+ addEventListener(type, listener, options) {
110328
+ if (typeof listener !== "function")
110329
+ return;
110330
+ function onMessage(data) {
110331
+ listener.call(this, new MessageEvent(data, this));
110332
+ }
110333
+ function onClose(code, message) {
110334
+ listener.call(this, new CloseEvent(code, message, this));
110335
+ }
110336
+ function onError(error) {
110337
+ listener.call(this, new ErrorEvent(error, this));
110338
+ }
110339
+ function onOpen() {
110340
+ listener.call(this, new OpenEvent(this));
110341
+ }
110342
+ const method = options && options.once ? "once" : "on";
110343
+ if (type === "message") {
110344
+ onMessage._listener = listener;
110345
+ this[method](type, onMessage);
110346
+ } else if (type === "close") {
110347
+ onClose._listener = listener;
110348
+ this[method](type, onClose);
110349
+ } else if (type === "error") {
110350
+ onError._listener = listener;
110351
+ this[method](type, onError);
110352
+ } else if (type === "open") {
110353
+ onOpen._listener = listener;
110354
+ this[method](type, onOpen);
110355
+ } else {
110356
+ this[method](type, listener);
110357
+ }
110358
+ },
110359
+ removeEventListener(type, listener) {
110360
+ const listeners = this.listeners(type);
110361
+ for (let i = 0;i < listeners.length; i++) {
110362
+ if (listeners[i] === listener || listeners[i]._listener === listener) {
110363
+ this.removeListener(type, listeners[i]);
110364
+ }
110365
+ }
110366
+ }
110367
+ };
110368
+ module.exports = EventTarget2;
110369
+ });
110370
+
110371
+ // ../../../node_modules/ws/lib/extension.js
110372
+ var require_extension2 = __commonJS((exports, module) => {
110373
+ var tokenChars = [
110374
+ 0,
110375
+ 0,
110376
+ 0,
110377
+ 0,
110378
+ 0,
110379
+ 0,
110380
+ 0,
110381
+ 0,
110382
+ 0,
110383
+ 0,
110384
+ 0,
110385
+ 0,
110386
+ 0,
110387
+ 0,
110388
+ 0,
110389
+ 0,
110390
+ 0,
110391
+ 0,
110392
+ 0,
110393
+ 0,
110394
+ 0,
110395
+ 0,
110396
+ 0,
110397
+ 0,
110398
+ 0,
110399
+ 0,
110400
+ 0,
110401
+ 0,
110402
+ 0,
110403
+ 0,
110404
+ 0,
110405
+ 0,
110406
+ 0,
110407
+ 1,
110408
+ 0,
110409
+ 1,
110410
+ 1,
110411
+ 1,
110412
+ 1,
110413
+ 1,
110414
+ 0,
110415
+ 0,
110416
+ 1,
110417
+ 1,
110418
+ 0,
110419
+ 1,
110420
+ 1,
110421
+ 0,
110422
+ 1,
110423
+ 1,
110424
+ 1,
110425
+ 1,
110426
+ 1,
110427
+ 1,
110428
+ 1,
110429
+ 1,
110430
+ 1,
110431
+ 1,
110432
+ 0,
110433
+ 0,
110434
+ 0,
110435
+ 0,
110436
+ 0,
110437
+ 0,
110438
+ 0,
110439
+ 1,
110440
+ 1,
110441
+ 1,
110442
+ 1,
110443
+ 1,
110444
+ 1,
110445
+ 1,
110446
+ 1,
110447
+ 1,
110448
+ 1,
110449
+ 1,
110450
+ 1,
110451
+ 1,
110452
+ 1,
110453
+ 1,
110454
+ 1,
110455
+ 1,
110456
+ 1,
110457
+ 1,
110458
+ 1,
110459
+ 1,
110460
+ 1,
110461
+ 1,
110462
+ 1,
110463
+ 1,
110464
+ 1,
110465
+ 0,
110466
+ 0,
110467
+ 0,
110468
+ 1,
110469
+ 1,
110470
+ 1,
110471
+ 1,
110472
+ 1,
110473
+ 1,
110474
+ 1,
110475
+ 1,
110476
+ 1,
110477
+ 1,
110478
+ 1,
110479
+ 1,
110480
+ 1,
110481
+ 1,
110482
+ 1,
110483
+ 1,
110484
+ 1,
110485
+ 1,
110486
+ 1,
110487
+ 1,
110488
+ 1,
110489
+ 1,
110490
+ 1,
110491
+ 1,
110492
+ 1,
110493
+ 1,
110494
+ 1,
110495
+ 1,
110496
+ 1,
110497
+ 0,
110498
+ 1,
110499
+ 0,
110500
+ 1,
110501
+ 0
110502
+ ];
110503
+ function push(dest, name, elem) {
110504
+ if (dest[name] === undefined)
110505
+ dest[name] = [elem];
110506
+ else
110507
+ dest[name].push(elem);
110508
+ }
110509
+ function parse2(header) {
110510
+ const offers = Object.create(null);
110511
+ if (header === undefined || header === "")
110512
+ return offers;
110513
+ let params = Object.create(null);
110514
+ let mustUnescape = false;
110515
+ let isEscaping = false;
110516
+ let inQuotes = false;
110517
+ let extensionName;
110518
+ let paramName;
110519
+ let start = -1;
110520
+ let end = -1;
110521
+ let i = 0;
110522
+ for (;i < header.length; i++) {
110523
+ const code = header.charCodeAt(i);
110524
+ if (extensionName === undefined) {
110525
+ if (end === -1 && tokenChars[code] === 1) {
110526
+ if (start === -1)
110527
+ start = i;
110528
+ } else if (code === 32 || code === 9) {
110529
+ if (end === -1 && start !== -1)
110530
+ end = i;
110531
+ } else if (code === 59 || code === 44) {
110532
+ if (start === -1) {
110533
+ throw new SyntaxError(`Unexpected character at index ${i}`);
110534
+ }
110535
+ if (end === -1)
110536
+ end = i;
110537
+ const name = header.slice(start, end);
110538
+ if (code === 44) {
110539
+ push(offers, name, params);
110540
+ params = Object.create(null);
110541
+ } else {
110542
+ extensionName = name;
110543
+ }
110544
+ start = end = -1;
110545
+ } else {
110546
+ throw new SyntaxError(`Unexpected character at index ${i}`);
110547
+ }
110548
+ } else if (paramName === undefined) {
110549
+ if (end === -1 && tokenChars[code] === 1) {
110550
+ if (start === -1)
110551
+ start = i;
110552
+ } else if (code === 32 || code === 9) {
110553
+ if (end === -1 && start !== -1)
110554
+ end = i;
110555
+ } else if (code === 59 || code === 44) {
110556
+ if (start === -1) {
110557
+ throw new SyntaxError(`Unexpected character at index ${i}`);
110558
+ }
110559
+ if (end === -1)
110560
+ end = i;
110561
+ push(params, header.slice(start, end), true);
110562
+ if (code === 44) {
110563
+ push(offers, extensionName, params);
110564
+ params = Object.create(null);
110565
+ extensionName = undefined;
110566
+ }
110567
+ start = end = -1;
110568
+ } else if (code === 61 && start !== -1 && end === -1) {
110569
+ paramName = header.slice(start, i);
110570
+ start = end = -1;
110571
+ } else {
110572
+ throw new SyntaxError(`Unexpected character at index ${i}`);
110573
+ }
110574
+ } else {
110575
+ if (isEscaping) {
110576
+ if (tokenChars[code] !== 1) {
110577
+ throw new SyntaxError(`Unexpected character at index ${i}`);
110578
+ }
110579
+ if (start === -1)
110580
+ start = i;
110581
+ else if (!mustUnescape)
110582
+ mustUnescape = true;
110583
+ isEscaping = false;
110584
+ } else if (inQuotes) {
110585
+ if (tokenChars[code] === 1) {
110586
+ if (start === -1)
110587
+ start = i;
110588
+ } else if (code === 34 && start !== -1) {
110589
+ inQuotes = false;
110590
+ end = i;
110591
+ } else if (code === 92) {
110592
+ isEscaping = true;
110593
+ } else {
110594
+ throw new SyntaxError(`Unexpected character at index ${i}`);
110595
+ }
110596
+ } else if (code === 34 && header.charCodeAt(i - 1) === 61) {
110597
+ inQuotes = true;
110598
+ } else if (end === -1 && tokenChars[code] === 1) {
110599
+ if (start === -1)
110600
+ start = i;
110601
+ } else if (start !== -1 && (code === 32 || code === 9)) {
110602
+ if (end === -1)
110603
+ end = i;
110604
+ } else if (code === 59 || code === 44) {
110605
+ if (start === -1) {
110606
+ throw new SyntaxError(`Unexpected character at index ${i}`);
110607
+ }
110608
+ if (end === -1)
110609
+ end = i;
110610
+ let value = header.slice(start, end);
110611
+ if (mustUnescape) {
110612
+ value = value.replace(/\\/g, "");
110613
+ mustUnescape = false;
110614
+ }
110615
+ push(params, paramName, value);
110616
+ if (code === 44) {
110617
+ push(offers, extensionName, params);
110618
+ params = Object.create(null);
110619
+ extensionName = undefined;
110620
+ }
110621
+ paramName = undefined;
110622
+ start = end = -1;
110623
+ } else {
110624
+ throw new SyntaxError(`Unexpected character at index ${i}`);
110625
+ }
110626
+ }
110627
+ }
110628
+ if (start === -1 || inQuotes) {
110629
+ throw new SyntaxError("Unexpected end of input");
110630
+ }
110631
+ if (end === -1)
110632
+ end = i;
110633
+ const token = header.slice(start, end);
110634
+ if (extensionName === undefined) {
110635
+ push(offers, token, params);
110636
+ } else {
110637
+ if (paramName === undefined) {
110638
+ push(params, token, true);
110639
+ } else if (mustUnescape) {
110640
+ push(params, paramName, token.replace(/\\/g, ""));
110641
+ } else {
110642
+ push(params, paramName, token);
110643
+ }
110644
+ push(offers, extensionName, params);
110645
+ }
110646
+ return offers;
110647
+ }
110648
+ function format(extensions) {
110649
+ return Object.keys(extensions).map((extension) => {
110650
+ let configurations = extensions[extension];
110651
+ if (!Array.isArray(configurations))
110652
+ configurations = [configurations];
110653
+ return configurations.map((params) => {
110654
+ return [extension].concat(Object.keys(params).map((k) => {
110655
+ let values = params[k];
110656
+ if (!Array.isArray(values))
110657
+ values = [values];
110658
+ return values.map((v) => v === true ? k : `${k}=${v}`).join("; ");
110659
+ })).join("; ");
110660
+ }).join(", ");
110661
+ }).join(", ");
110662
+ }
110663
+ module.exports = { format, parse: parse2 };
110664
+ });
110665
+
110666
+ // ../../../node_modules/ws/lib/websocket.js
110667
+ var require_websocket2 = __commonJS((exports, module) => {
110668
+ var EventEmitter = __require("events");
110669
+ var https = __require("https");
110670
+ var http2 = __require("http");
110671
+ var net = __require("net");
110672
+ var tls = __require("tls");
110673
+ var { randomBytes: randomBytes8, createHash: createHash14 } = __require("crypto");
110674
+ var { Readable } = __require("stream");
110675
+ var { URL: URL2 } = __require("url");
110676
+ var PerMessageDeflate = require_permessage_deflate2();
110677
+ var Receiver = require_receiver2();
110678
+ var Sender = require_sender2();
110679
+ var {
110680
+ BINARY_TYPES,
110681
+ EMPTY_BUFFER,
110682
+ GUID,
110683
+ kStatusCode,
110684
+ kWebSocket,
110685
+ NOOP
110686
+ } = require_constants8();
110687
+ var { addEventListener, removeEventListener } = require_event_target2();
110688
+ var { format, parse: parse2 } = require_extension2();
110689
+ var { toBuffer } = require_buffer_util2();
110690
+ var readyStates = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
110691
+ var protocolVersions = [8, 13];
110692
+ var closeTimeout = 30 * 1000;
110693
+
110694
+ class WebSocket2 extends EventEmitter {
110695
+ constructor(address, protocols, options) {
110696
+ super();
110697
+ this._binaryType = BINARY_TYPES[0];
110698
+ this._closeCode = 1006;
110699
+ this._closeFrameReceived = false;
110700
+ this._closeFrameSent = false;
110701
+ this._closeMessage = "";
110702
+ this._closeTimer = null;
110703
+ this._extensions = {};
110704
+ this._protocol = "";
110705
+ this._readyState = WebSocket2.CONNECTING;
110706
+ this._receiver = null;
110707
+ this._sender = null;
110708
+ this._socket = null;
110709
+ if (address !== null) {
110710
+ this._bufferedAmount = 0;
110711
+ this._isServer = false;
110712
+ this._redirects = 0;
110713
+ if (Array.isArray(protocols)) {
110714
+ protocols = protocols.join(", ");
110715
+ } else if (typeof protocols === "object" && protocols !== null) {
110716
+ options = protocols;
110717
+ protocols = undefined;
110718
+ }
110719
+ initAsClient(this, address, protocols, options);
110720
+ } else {
110721
+ this._isServer = true;
110722
+ }
110723
+ }
110724
+ get binaryType() {
110725
+ return this._binaryType;
110726
+ }
110727
+ set binaryType(type) {
110728
+ if (!BINARY_TYPES.includes(type))
110729
+ return;
110730
+ this._binaryType = type;
110731
+ if (this._receiver)
110732
+ this._receiver._binaryType = type;
110733
+ }
110734
+ get bufferedAmount() {
110735
+ if (!this._socket)
110736
+ return this._bufferedAmount;
110737
+ return this._socket._writableState.length + this._sender._bufferedBytes;
110738
+ }
110739
+ get extensions() {
110740
+ return Object.keys(this._extensions).join();
110741
+ }
110742
+ get onclose() {
110743
+ return;
110744
+ }
110745
+ set onclose(listener) {}
110746
+ get onerror() {
110747
+ return;
110748
+ }
110749
+ set onerror(listener) {}
110750
+ get onopen() {
110751
+ return;
110752
+ }
110753
+ set onopen(listener) {}
110754
+ get onmessage() {
110755
+ return;
110756
+ }
110757
+ set onmessage(listener) {}
110758
+ get protocol() {
110759
+ return this._protocol;
110760
+ }
110761
+ get readyState() {
110762
+ return this._readyState;
110763
+ }
110764
+ get url() {
110765
+ return this._url;
110766
+ }
110767
+ setSocket(socket, head, maxPayload, maxBufferedChunks, maxFragments) {
110768
+ const receiver = new Receiver(this.binaryType, this._extensions, this._isServer, maxPayload, maxBufferedChunks, maxFragments);
110769
+ this._sender = new Sender(socket, this._extensions);
110770
+ this._receiver = receiver;
110771
+ this._socket = socket;
110772
+ receiver[kWebSocket] = this;
110773
+ socket[kWebSocket] = this;
110774
+ receiver.on("conclude", receiverOnConclude);
110775
+ receiver.on("drain", receiverOnDrain);
110776
+ receiver.on("error", receiverOnError);
110777
+ receiver.on("message", receiverOnMessage);
110778
+ receiver.on("ping", receiverOnPing);
110779
+ receiver.on("pong", receiverOnPong);
110780
+ socket.setTimeout(0);
110781
+ socket.setNoDelay();
110782
+ if (head.length > 0)
110783
+ socket.unshift(head);
110784
+ socket.on("close", socketOnClose);
110785
+ socket.on("data", socketOnData);
110786
+ socket.on("end", socketOnEnd);
110787
+ socket.on("error", socketOnError);
110788
+ this._readyState = WebSocket2.OPEN;
110789
+ this.emit("open");
110790
+ }
110791
+ emitClose() {
110792
+ if (!this._socket) {
110793
+ this._readyState = WebSocket2.CLOSED;
110794
+ this.emit("close", this._closeCode, this._closeMessage);
110795
+ return;
110796
+ }
110797
+ if (this._extensions[PerMessageDeflate.extensionName]) {
110798
+ this._extensions[PerMessageDeflate.extensionName].cleanup();
110799
+ }
110800
+ this._receiver.removeAllListeners();
110801
+ this._readyState = WebSocket2.CLOSED;
110802
+ this.emit("close", this._closeCode, this._closeMessage);
110803
+ }
110804
+ close(code, data) {
110805
+ if (this.readyState === WebSocket2.CLOSED)
110806
+ return;
110807
+ if (this.readyState === WebSocket2.CONNECTING) {
110808
+ const msg = "WebSocket was closed before the connection was established";
110809
+ return abortHandshake(this, this._req, msg);
110810
+ }
110811
+ if (this.readyState === WebSocket2.CLOSING) {
110812
+ if (this._closeFrameSent && (this._closeFrameReceived || this._receiver._writableState.errorEmitted)) {
110813
+ this._socket.end();
110814
+ }
110815
+ return;
110816
+ }
110817
+ this._readyState = WebSocket2.CLOSING;
110818
+ this._sender.close(code, data, !this._isServer, (err) => {
110819
+ if (err)
110820
+ return;
110821
+ this._closeFrameSent = true;
110822
+ if (this._closeFrameReceived || this._receiver._writableState.errorEmitted) {
110823
+ this._socket.end();
110824
+ }
110825
+ });
110826
+ this._closeTimer = setTimeout(this._socket.destroy.bind(this._socket), closeTimeout);
110827
+ }
110828
+ ping(data, mask, cb) {
110829
+ if (this.readyState === WebSocket2.CONNECTING) {
110830
+ throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
110831
+ }
110832
+ if (typeof data === "function") {
110833
+ cb = data;
110834
+ data = mask = undefined;
110835
+ } else if (typeof mask === "function") {
110836
+ cb = mask;
110837
+ mask = undefined;
110838
+ }
110839
+ if (typeof data === "number")
110840
+ data = data.toString();
110841
+ if (this.readyState !== WebSocket2.OPEN) {
110842
+ sendAfterClose(this, data, cb);
110843
+ return;
110844
+ }
110845
+ if (mask === undefined)
110846
+ mask = !this._isServer;
110847
+ this._sender.ping(data || EMPTY_BUFFER, mask, cb);
110848
+ }
110849
+ pong(data, mask, cb) {
110850
+ if (this.readyState === WebSocket2.CONNECTING) {
110851
+ throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
110852
+ }
110853
+ if (typeof data === "function") {
110854
+ cb = data;
110855
+ data = mask = undefined;
110856
+ } else if (typeof mask === "function") {
110857
+ cb = mask;
110858
+ mask = undefined;
110859
+ }
110860
+ if (typeof data === "number")
110861
+ data = data.toString();
110862
+ if (this.readyState !== WebSocket2.OPEN) {
110863
+ sendAfterClose(this, data, cb);
110864
+ return;
110865
+ }
110866
+ if (mask === undefined)
110867
+ mask = !this._isServer;
110868
+ this._sender.pong(data || EMPTY_BUFFER, mask, cb);
110869
+ }
110870
+ send(data, options, cb) {
110871
+ if (this.readyState === WebSocket2.CONNECTING) {
110872
+ throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
110873
+ }
110874
+ if (typeof options === "function") {
110875
+ cb = options;
110876
+ options = {};
110877
+ }
110878
+ if (typeof data === "number")
110879
+ data = data.toString();
110880
+ if (this.readyState !== WebSocket2.OPEN) {
110881
+ sendAfterClose(this, data, cb);
110882
+ return;
110883
+ }
110884
+ const opts = {
110885
+ binary: typeof data !== "string",
110886
+ mask: !this._isServer,
110887
+ compress: true,
110888
+ fin: true,
110889
+ ...options
110890
+ };
110891
+ if (!this._extensions[PerMessageDeflate.extensionName]) {
110892
+ opts.compress = false;
110893
+ }
110894
+ this._sender.send(data || EMPTY_BUFFER, opts, cb);
110895
+ }
110896
+ terminate() {
110897
+ if (this.readyState === WebSocket2.CLOSED)
110898
+ return;
110899
+ if (this.readyState === WebSocket2.CONNECTING) {
110900
+ const msg = "WebSocket was closed before the connection was established";
110901
+ return abortHandshake(this, this._req, msg);
110902
+ }
110903
+ if (this._socket) {
110904
+ this._readyState = WebSocket2.CLOSING;
110905
+ this._socket.destroy();
110906
+ }
110907
+ }
110908
+ }
110909
+ Object.defineProperty(WebSocket2, "CONNECTING", {
110910
+ enumerable: true,
110911
+ value: readyStates.indexOf("CONNECTING")
110912
+ });
110913
+ Object.defineProperty(WebSocket2.prototype, "CONNECTING", {
110914
+ enumerable: true,
110915
+ value: readyStates.indexOf("CONNECTING")
110916
+ });
110917
+ Object.defineProperty(WebSocket2, "OPEN", {
110918
+ enumerable: true,
110919
+ value: readyStates.indexOf("OPEN")
110920
+ });
110921
+ Object.defineProperty(WebSocket2.prototype, "OPEN", {
110922
+ enumerable: true,
110923
+ value: readyStates.indexOf("OPEN")
110924
+ });
110925
+ Object.defineProperty(WebSocket2, "CLOSING", {
110926
+ enumerable: true,
110927
+ value: readyStates.indexOf("CLOSING")
110928
+ });
110929
+ Object.defineProperty(WebSocket2.prototype, "CLOSING", {
110930
+ enumerable: true,
110931
+ value: readyStates.indexOf("CLOSING")
110932
+ });
110933
+ Object.defineProperty(WebSocket2, "CLOSED", {
110934
+ enumerable: true,
110935
+ value: readyStates.indexOf("CLOSED")
110936
+ });
110937
+ Object.defineProperty(WebSocket2.prototype, "CLOSED", {
110938
+ enumerable: true,
110939
+ value: readyStates.indexOf("CLOSED")
110940
+ });
110941
+ [
110942
+ "binaryType",
110943
+ "bufferedAmount",
110944
+ "extensions",
110945
+ "protocol",
110946
+ "readyState",
110947
+ "url"
110948
+ ].forEach((property) => {
110949
+ Object.defineProperty(WebSocket2.prototype, property, { enumerable: true });
110950
+ });
110951
+ ["open", "error", "close", "message"].forEach((method) => {
110952
+ Object.defineProperty(WebSocket2.prototype, `on${method}`, {
110953
+ enumerable: true,
110954
+ get() {
110955
+ const listeners = this.listeners(method);
110956
+ for (let i = 0;i < listeners.length; i++) {
110957
+ if (listeners[i]._listener)
110958
+ return listeners[i]._listener;
110959
+ }
110960
+ return;
110961
+ },
110962
+ set(listener) {
110963
+ const listeners = this.listeners(method);
110964
+ for (let i = 0;i < listeners.length; i++) {
110965
+ if (listeners[i]._listener)
110966
+ this.removeListener(method, listeners[i]);
110967
+ }
110968
+ this.addEventListener(method, listener);
110969
+ }
110970
+ });
110971
+ });
110972
+ WebSocket2.prototype.addEventListener = addEventListener;
110973
+ WebSocket2.prototype.removeEventListener = removeEventListener;
110974
+ module.exports = WebSocket2;
110975
+ function initAsClient(websocket, address, protocols, options) {
110976
+ const opts = {
110977
+ protocolVersion: protocolVersions[1],
110978
+ maxBufferedChunks: 1024 * 1024,
110979
+ maxFragments: 128 * 1024,
110980
+ maxPayload: 100 * 1024 * 1024,
110981
+ perMessageDeflate: true,
110982
+ followRedirects: false,
110983
+ maxRedirects: 10,
110984
+ ...options,
110985
+ createConnection: undefined,
110986
+ socketPath: undefined,
110987
+ hostname: undefined,
110988
+ protocol: undefined,
110989
+ timeout: undefined,
110990
+ method: undefined,
110991
+ host: undefined,
110992
+ path: undefined,
110993
+ port: undefined
110994
+ };
110995
+ if (!protocolVersions.includes(opts.protocolVersion)) {
110996
+ throw new RangeError(`Unsupported protocol version: ${opts.protocolVersion} ` + `(supported versions: ${protocolVersions.join(", ")})`);
110997
+ }
110998
+ let parsedUrl;
110999
+ if (address instanceof URL2) {
111000
+ parsedUrl = address;
111001
+ websocket._url = address.href;
111002
+ } else {
111003
+ parsedUrl = new URL2(address);
111004
+ websocket._url = address;
111005
+ }
111006
+ const isUnixSocket = parsedUrl.protocol === "ws+unix:";
111007
+ if (!parsedUrl.host && (!isUnixSocket || !parsedUrl.pathname)) {
111008
+ const err = new Error(`Invalid URL: ${websocket.url}`);
111009
+ if (websocket._redirects === 0) {
111010
+ throw err;
111011
+ } else {
111012
+ emitErrorAndClose(websocket, err);
111013
+ return;
111014
+ }
111015
+ }
111016
+ const isSecure = parsedUrl.protocol === "wss:" || parsedUrl.protocol === "https:";
111017
+ const defaultPort = isSecure ? 443 : 80;
111018
+ const key = randomBytes8(16).toString("base64");
111019
+ const get = isSecure ? https.get : http2.get;
111020
+ let perMessageDeflate;
111021
+ opts.createConnection = isSecure ? tlsConnect : netConnect;
111022
+ opts.defaultPort = opts.defaultPort || defaultPort;
111023
+ opts.port = parsedUrl.port || defaultPort;
111024
+ opts.host = parsedUrl.hostname.startsWith("[") ? parsedUrl.hostname.slice(1, -1) : parsedUrl.hostname;
111025
+ opts.headers = {
111026
+ "Sec-WebSocket-Version": opts.protocolVersion,
111027
+ "Sec-WebSocket-Key": key,
111028
+ Connection: "Upgrade",
111029
+ Upgrade: "websocket",
111030
+ ...opts.headers
111031
+ };
111032
+ opts.path = parsedUrl.pathname + parsedUrl.search;
111033
+ opts.timeout = opts.handshakeTimeout;
111034
+ if (opts.perMessageDeflate) {
111035
+ perMessageDeflate = new PerMessageDeflate(opts.perMessageDeflate !== true ? opts.perMessageDeflate : {}, false, opts.maxPayload);
111036
+ opts.headers["Sec-WebSocket-Extensions"] = format({
111037
+ [PerMessageDeflate.extensionName]: perMessageDeflate.offer()
111038
+ });
111039
+ }
111040
+ if (protocols) {
111041
+ opts.headers["Sec-WebSocket-Protocol"] = protocols;
111042
+ }
111043
+ if (opts.origin) {
111044
+ if (opts.protocolVersion < 13) {
111045
+ opts.headers["Sec-WebSocket-Origin"] = opts.origin;
111046
+ } else {
111047
+ opts.headers.Origin = opts.origin;
111048
+ }
111049
+ }
111050
+ if (parsedUrl.username || parsedUrl.password) {
111051
+ opts.auth = `${parsedUrl.username}:${parsedUrl.password}`;
111052
+ }
111053
+ if (isUnixSocket) {
111054
+ const parts = opts.path.split(":");
111055
+ opts.socketPath = parts[0];
111056
+ opts.path = parts[1];
111057
+ }
111058
+ if (opts.followRedirects) {
111059
+ if (websocket._redirects === 0) {
111060
+ websocket._originalUnixSocket = isUnixSocket;
111061
+ websocket._originalSecure = isSecure;
111062
+ websocket._originalHostOrSocketPath = isUnixSocket ? opts.socketPath : parsedUrl.host;
111063
+ const headers = options && options.headers;
111064
+ options = { ...options, headers: {} };
111065
+ if (headers) {
111066
+ for (const [key2, value] of Object.entries(headers)) {
111067
+ options.headers[key2.toLowerCase()] = value;
111068
+ }
111069
+ }
111070
+ } else {
111071
+ const isSameHost = isUnixSocket ? websocket._originalUnixSocket ? opts.socketPath === websocket._originalHostOrSocketPath : false : websocket._originalUnixSocket ? false : parsedUrl.host === websocket._originalHostOrSocketPath;
111072
+ if (!isSameHost || websocket._originalSecure && !isSecure) {
111073
+ delete opts.headers.authorization;
111074
+ delete opts.headers.cookie;
111075
+ if (!isSameHost)
111076
+ delete opts.headers.host;
111077
+ opts.auth = undefined;
111078
+ }
111079
+ }
111080
+ if (opts.auth && !options.headers.authorization) {
111081
+ options.headers.authorization = "Basic " + Buffer.from(opts.auth).toString("base64");
111082
+ }
111083
+ }
111084
+ let req = websocket._req = get(opts);
111085
+ if (opts.timeout) {
111086
+ req.on("timeout", () => {
111087
+ abortHandshake(websocket, req, "Opening handshake has timed out");
111088
+ });
111089
+ }
111090
+ req.on("error", (err) => {
111091
+ if (req === null || req.aborted)
111092
+ return;
111093
+ req = websocket._req = null;
111094
+ emitErrorAndClose(websocket, err);
111095
+ });
111096
+ req.on("response", (res) => {
111097
+ const location = res.headers.location;
111098
+ const statusCode = res.statusCode;
111099
+ if (location && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
111100
+ if (++websocket._redirects > opts.maxRedirects) {
111101
+ abortHandshake(websocket, req, "Maximum redirects exceeded");
111102
+ return;
111103
+ }
111104
+ req.abort();
111105
+ let addr;
111106
+ try {
111107
+ addr = new URL2(location, address);
111108
+ } catch (err) {
111109
+ emitErrorAndClose(websocket, err);
111110
+ return;
111111
+ }
111112
+ initAsClient(websocket, addr, protocols, options);
111113
+ } else if (!websocket.emit("unexpected-response", req, res)) {
111114
+ abortHandshake(websocket, req, `Unexpected server response: ${res.statusCode}`);
111115
+ }
111116
+ });
111117
+ req.on("upgrade", (res, socket, head) => {
111118
+ websocket.emit("upgrade", res);
111119
+ if (websocket.readyState !== WebSocket2.CONNECTING)
111120
+ return;
111121
+ req = websocket._req = null;
111122
+ const upgrade = res.headers.upgrade;
111123
+ if (upgrade === undefined || upgrade.toLowerCase() !== "websocket") {
111124
+ abortHandshake(websocket, socket, "Invalid Upgrade header");
111125
+ return;
111126
+ }
111127
+ const digest = createHash14("sha1").update(key + GUID).digest("base64");
111128
+ if (res.headers["sec-websocket-accept"] !== digest) {
111129
+ abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
111130
+ return;
111131
+ }
111132
+ const serverProt = res.headers["sec-websocket-protocol"];
111133
+ const protList = (protocols || "").split(/, */);
111134
+ let protError;
111135
+ if (!protocols && serverProt) {
111136
+ protError = "Server sent a subprotocol but none was requested";
111137
+ } else if (protocols && !serverProt) {
111138
+ protError = "Server sent no subprotocol";
111139
+ } else if (serverProt && !protList.includes(serverProt)) {
111140
+ protError = "Server sent an invalid subprotocol";
111141
+ }
111142
+ if (protError) {
111143
+ abortHandshake(websocket, socket, protError);
111144
+ return;
111145
+ }
111146
+ if (serverProt)
111147
+ websocket._protocol = serverProt;
111148
+ const secWebSocketExtensions = res.headers["sec-websocket-extensions"];
111149
+ if (secWebSocketExtensions !== undefined) {
111150
+ if (!perMessageDeflate) {
111151
+ const message = "Server sent a Sec-WebSocket-Extensions header but no extension " + "was requested";
111152
+ abortHandshake(websocket, socket, message);
111153
+ return;
111154
+ }
111155
+ let extensions;
111156
+ try {
111157
+ extensions = parse2(secWebSocketExtensions);
111158
+ } catch (err) {
111159
+ const message = "Invalid Sec-WebSocket-Extensions header";
111160
+ abortHandshake(websocket, socket, message);
111161
+ return;
111162
+ }
111163
+ const extensionNames = Object.keys(extensions);
111164
+ if (extensionNames.length) {
111165
+ if (extensionNames.length !== 1 || extensionNames[0] !== PerMessageDeflate.extensionName) {
111166
+ const message = "Server indicated an extension that was not requested";
111167
+ abortHandshake(websocket, socket, message);
111168
+ return;
111169
+ }
111170
+ try {
111171
+ perMessageDeflate.accept(extensions[PerMessageDeflate.extensionName]);
111172
+ } catch (err) {
111173
+ const message = "Invalid Sec-WebSocket-Extensions header";
111174
+ abortHandshake(websocket, socket, message);
111175
+ return;
111176
+ }
111177
+ websocket._extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
111178
+ }
111179
+ }
111180
+ websocket.setSocket(socket, head, opts.maxPayload, opts.maxBufferedChunks, opts.maxFragments);
111181
+ });
111182
+ }
111183
+ function emitErrorAndClose(websocket, err) {
111184
+ websocket._readyState = WebSocket2.CLOSING;
111185
+ websocket.emit("error", err);
111186
+ websocket.emitClose();
111187
+ }
111188
+ function netConnect(options) {
111189
+ options.path = options.socketPath;
111190
+ return net.connect(options);
111191
+ }
111192
+ function tlsConnect(options) {
111193
+ options.path = undefined;
111194
+ if (!options.servername && options.servername !== "") {
111195
+ options.servername = net.isIP(options.host) ? "" : options.host;
111196
+ }
111197
+ return tls.connect(options);
111198
+ }
111199
+ function abortHandshake(websocket, stream, message) {
111200
+ websocket._readyState = WebSocket2.CLOSING;
111201
+ const err = new Error(message);
111202
+ Error.captureStackTrace(err, abortHandshake);
111203
+ if (stream.setHeader) {
111204
+ stream.abort();
111205
+ if (stream.socket && !stream.socket.destroyed) {
111206
+ stream.socket.destroy();
111207
+ }
111208
+ stream.once("abort", websocket.emitClose.bind(websocket));
111209
+ websocket.emit("error", err);
111210
+ } else {
111211
+ stream.destroy(err);
111212
+ stream.once("error", websocket.emit.bind(websocket, "error"));
111213
+ stream.once("close", websocket.emitClose.bind(websocket));
111214
+ }
111215
+ }
111216
+ function sendAfterClose(websocket, data, cb) {
111217
+ if (data) {
111218
+ const length = toBuffer(data).length;
111219
+ if (websocket._socket)
111220
+ websocket._sender._bufferedBytes += length;
111221
+ else
111222
+ websocket._bufferedAmount += length;
111223
+ }
111224
+ if (cb) {
111225
+ const err = new Error(`WebSocket is not open: readyState ${websocket.readyState} ` + `(${readyStates[websocket.readyState]})`);
111226
+ cb(err);
111227
+ }
111228
+ }
111229
+ function receiverOnConclude(code, reason) {
111230
+ const websocket = this[kWebSocket];
111231
+ websocket._closeFrameReceived = true;
111232
+ websocket._closeMessage = reason;
111233
+ websocket._closeCode = code;
111234
+ if (websocket._socket[kWebSocket] === undefined)
111235
+ return;
111236
+ websocket._socket.removeListener("data", socketOnData);
111237
+ process.nextTick(resume, websocket._socket);
111238
+ if (code === 1005)
111239
+ websocket.close();
111240
+ else
111241
+ websocket.close(code, reason);
111242
+ }
111243
+ function receiverOnDrain() {
111244
+ this[kWebSocket]._socket.resume();
111245
+ }
111246
+ function receiverOnError(err) {
111247
+ const websocket = this[kWebSocket];
111248
+ if (websocket._socket[kWebSocket] !== undefined) {
111249
+ websocket._socket.removeListener("data", socketOnData);
111250
+ process.nextTick(resume, websocket._socket);
111251
+ websocket.close(err[kStatusCode]);
111252
+ }
111253
+ websocket.emit("error", err);
111254
+ }
111255
+ function receiverOnFinish() {
111256
+ this[kWebSocket].emitClose();
111257
+ }
111258
+ function receiverOnMessage(data) {
111259
+ this[kWebSocket].emit("message", data);
111260
+ }
111261
+ function receiverOnPing(data) {
111262
+ const websocket = this[kWebSocket];
111263
+ websocket.pong(data, !websocket._isServer, NOOP);
111264
+ websocket.emit("ping", data);
111265
+ }
111266
+ function receiverOnPong(data) {
111267
+ this[kWebSocket].emit("pong", data);
111268
+ }
111269
+ function resume(stream) {
111270
+ stream.resume();
111271
+ }
111272
+ function socketOnClose() {
111273
+ const websocket = this[kWebSocket];
111274
+ this.removeListener("close", socketOnClose);
111275
+ this.removeListener("data", socketOnData);
111276
+ this.removeListener("end", socketOnEnd);
111277
+ websocket._readyState = WebSocket2.CLOSING;
111278
+ let chunk;
111279
+ if (!this._readableState.endEmitted && !websocket._closeFrameReceived && !websocket._receiver._writableState.errorEmitted && (chunk = websocket._socket.read()) !== null) {
111280
+ websocket._receiver.write(chunk);
111281
+ }
111282
+ websocket._receiver.end();
111283
+ this[kWebSocket] = undefined;
111284
+ clearTimeout(websocket._closeTimer);
111285
+ if (websocket._receiver._writableState.finished || websocket._receiver._writableState.errorEmitted) {
111286
+ websocket.emitClose();
111287
+ } else {
111288
+ websocket._receiver.on("error", receiverOnFinish);
111289
+ websocket._receiver.on("finish", receiverOnFinish);
108382
111290
  }
108383
- fn[Symbol.for("skip-override")] = options.encapsulate !== true;
108384
- fn[Symbol.for("fastify.display-name")] = options.name;
108385
- fn[Symbol.for("plugin-meta")] = options;
108386
- if (!fn.default) {
108387
- fn.default = fn;
111291
+ }
111292
+ function socketOnData(chunk) {
111293
+ if (!this[kWebSocket]._receiver.write(chunk)) {
111294
+ this.pause();
108388
111295
  }
108389
- const camelCase = toCamelCase(options.name);
108390
- if (!autoName && !fn[camelCase]) {
108391
- fn[camelCase] = fn;
111296
+ }
111297
+ function socketOnEnd() {
111298
+ const websocket = this[kWebSocket];
111299
+ websocket._readyState = WebSocket2.CLOSING;
111300
+ websocket._receiver.end();
111301
+ this.end();
111302
+ }
111303
+ function socketOnError() {
111304
+ const websocket = this[kWebSocket];
111305
+ this.removeListener("error", socketOnError);
111306
+ this.on("error", NOOP);
111307
+ if (websocket) {
111308
+ websocket._readyState = WebSocket2.CLOSING;
111309
+ this.destroy();
108392
111310
  }
108393
- return fn;
108394
111311
  }
108395
- module.exports = plugin;
108396
- module.exports.default = plugin;
108397
- module.exports.fastifyPlugin = plugin;
108398
111312
  });
108399
111313
 
108400
- // node_modules/.bun/@fastify+cors@11.2.0/node_modules/@fastify/cors/vary.js
108401
- var require_vary = __commonJS((exports, module) => {
108402
- var { FifoMap: FifoCache } = require_toad_cache();
108403
- var validFieldnameRE = /^[!#$%&'*+\-.^\w`|~]+$/u;
108404
- function validateFieldname(fieldname) {
108405
- if (validFieldnameRE.test(fieldname) === false) {
108406
- throw new TypeError("Fieldname contains invalid characters.");
111314
+ // ../../../node_modules/ws/lib/stream.js
111315
+ var require_stream2 = __commonJS((exports, module) => {
111316
+ var { Duplex } = __require("stream");
111317
+ function emitClose(stream) {
111318
+ stream.emit("close");
111319
+ }
111320
+ function duplexOnEnd() {
111321
+ if (!this.destroyed && this._writableState.finished) {
111322
+ this.destroy();
108407
111323
  }
108408
111324
  }
108409
- function parse2(header) {
108410
- header = header.trim().toLowerCase();
108411
- const result = [];
108412
- if (header.length === 0) {} else if (header.indexOf(",") === -1) {
108413
- result.push(header);
108414
- } else {
108415
- const il = header.length;
108416
- let i = 0;
108417
- let pos = 0;
108418
- let char;
108419
- for (i;i < il; ++i) {
108420
- char = header[i];
108421
- if (char === " ") {
108422
- pos = i + 1;
108423
- } else if (char === ",") {
108424
- if (pos !== i) {
108425
- result.push(header.slice(pos, i));
108426
- }
108427
- pos = i + 1;
108428
- }
108429
- }
108430
- if (pos !== i) {
108431
- result.push(header.slice(pos, i));
108432
- }
111325
+ function duplexOnError(err) {
111326
+ this.removeListener("error", duplexOnError);
111327
+ this.destroy();
111328
+ if (this.listenerCount("error") === 0) {
111329
+ this.emit("error", err);
108433
111330
  }
108434
- return result;
108435
111331
  }
108436
- function createAddFieldnameToVary(fieldname) {
108437
- const headerCache = new FifoCache(1000);
108438
- validateFieldname(fieldname);
108439
- return function(reply) {
108440
- let header = reply.getHeader("Vary");
108441
- if (!header) {
108442
- reply.header("Vary", fieldname);
108443
- return;
111332
+ function createWebSocketStream(ws, options) {
111333
+ let resumeOnReceiverDrain = true;
111334
+ let terminateOnDestroy = true;
111335
+ function receiverOnDrain() {
111336
+ if (resumeOnReceiverDrain)
111337
+ ws._socket.resume();
111338
+ }
111339
+ if (ws.readyState === ws.CONNECTING) {
111340
+ ws.once("open", function open() {
111341
+ ws._receiver.removeAllListeners("drain");
111342
+ ws._receiver.on("drain", receiverOnDrain);
111343
+ });
111344
+ } else {
111345
+ ws._receiver.removeAllListeners("drain");
111346
+ ws._receiver.on("drain", receiverOnDrain);
111347
+ }
111348
+ const duplex = new Duplex({
111349
+ ...options,
111350
+ autoDestroy: false,
111351
+ emitClose: false,
111352
+ objectMode: false,
111353
+ writableObjectMode: false
111354
+ });
111355
+ ws.on("message", function message(msg) {
111356
+ if (!duplex.push(msg)) {
111357
+ resumeOnReceiverDrain = false;
111358
+ ws._socket.pause();
108444
111359
  }
108445
- if (header === "*") {
111360
+ });
111361
+ ws.once("error", function error(err) {
111362
+ if (duplex.destroyed)
111363
+ return;
111364
+ terminateOnDestroy = false;
111365
+ duplex.destroy(err);
111366
+ });
111367
+ ws.once("close", function close() {
111368
+ if (duplex.destroyed)
111369
+ return;
111370
+ duplex.push(null);
111371
+ });
111372
+ duplex._destroy = function(err, callback) {
111373
+ if (ws.readyState === ws.CLOSED) {
111374
+ callback(err);
111375
+ process.nextTick(emitClose, duplex);
108446
111376
  return;
108447
111377
  }
108448
- if (fieldname === "*") {
108449
- reply.header("Vary", "*");
111378
+ let called = false;
111379
+ ws.once("error", function error(err2) {
111380
+ called = true;
111381
+ callback(err2);
111382
+ });
111383
+ ws.once("close", function close() {
111384
+ if (!called)
111385
+ callback(err);
111386
+ process.nextTick(emitClose, duplex);
111387
+ });
111388
+ if (terminateOnDestroy)
111389
+ ws.terminate();
111390
+ };
111391
+ duplex._final = function(callback) {
111392
+ if (ws.readyState === ws.CONNECTING) {
111393
+ ws.once("open", function open() {
111394
+ duplex._final(callback);
111395
+ });
108450
111396
  return;
108451
111397
  }
108452
- if (Array.isArray(header)) {
108453
- header = header.join(", ");
111398
+ if (ws._socket === null)
111399
+ return;
111400
+ if (ws._socket._writableState.finished) {
111401
+ callback();
111402
+ if (duplex._readableState.endEmitted)
111403
+ duplex.destroy();
111404
+ } else {
111405
+ ws._socket.once("finish", function finish() {
111406
+ callback();
111407
+ });
111408
+ ws.close();
108454
111409
  }
108455
- if (headerCache.get(header) === undefined) {
108456
- const vals = parse2(header);
108457
- if (vals.indexOf("*") !== -1) {
108458
- headerCache.set(header, "*");
108459
- } else if (vals.indexOf(fieldname.toLowerCase()) === -1) {
108460
- headerCache.set(header, header + ", " + fieldname);
108461
- } else {
108462
- headerCache.set(header, null);
108463
- }
111410
+ };
111411
+ duplex._read = function() {
111412
+ if ((ws.readyState === ws.OPEN || ws.readyState === ws.CLOSING) && !resumeOnReceiverDrain) {
111413
+ resumeOnReceiverDrain = true;
111414
+ if (!ws._receiver._writableState.needDrain)
111415
+ ws._socket.resume();
108464
111416
  }
108465
- const cached3 = headerCache.get(header);
108466
- if (cached3 !== null) {
108467
- reply.header("Vary", cached3);
111417
+ };
111418
+ duplex._write = function(chunk, encoding, callback) {
111419
+ if (ws.readyState === ws.CONNECTING) {
111420
+ ws.once("open", function open() {
111421
+ duplex._write(chunk, encoding, callback);
111422
+ });
111423
+ return;
108468
111424
  }
111425
+ ws.send(chunk, callback);
108469
111426
  };
111427
+ duplex.on("end", duplexOnEnd);
111428
+ duplex.on("error", duplexOnError);
111429
+ return duplex;
108470
111430
  }
108471
- exports.createAddFieldnameToVary = createAddFieldnameToVary;
108472
- exports.addOriginToVaryHeader = createAddFieldnameToVary("Origin");
108473
- exports.addAccessControlRequestHeadersToVaryHeader = createAddFieldnameToVary("Access-Control-Request-Headers");
108474
- exports.parse = parse2;
111431
+ module.exports = createWebSocketStream;
108475
111432
  });
108476
111433
 
108477
- // node_modules/.bun/@fastify+cors@11.2.0/node_modules/@fastify/cors/index.js
108478
- var require_cors = __commonJS((exports, module) => {
108479
- var fp = require_plugin2();
108480
- var {
108481
- addAccessControlRequestHeadersToVaryHeader,
108482
- addOriginToVaryHeader
108483
- } = require_vary();
108484
- var defaultOptions = {
108485
- origin: "*",
108486
- methods: "GET,HEAD,POST",
108487
- hook: "onRequest",
108488
- preflightContinue: false,
108489
- optionsSuccessStatus: 204,
108490
- credentials: false,
108491
- exposedHeaders: null,
108492
- allowedHeaders: null,
108493
- maxAge: null,
108494
- preflight: true,
108495
- strictPreflight: true
108496
- };
108497
- var validHooks = [
108498
- "onRequest",
108499
- "preParsing",
108500
- "preValidation",
108501
- "preHandler",
108502
- "preSerialization",
108503
- "onSend"
108504
- ];
108505
- var hookWithPayload = [
108506
- "preSerialization",
108507
- "preParsing",
108508
- "onSend"
108509
- ];
108510
- function validateHook(value, next) {
108511
- if (validHooks.indexOf(value) !== -1) {
108512
- return;
108513
- }
108514
- next(new TypeError("@fastify/cors: Invalid hook option provided."));
108515
- }
108516
- function fastifyCors(fastify, opts, next) {
108517
- fastify.decorateRequest("corsPreflightEnabled", false);
108518
- let hideOptionsRoute = true;
108519
- let logLevel;
108520
- if (typeof opts === "function") {
108521
- handleCorsOptionsDelegator(opts, fastify, { hook: defaultOptions.hook }, next);
108522
- } else if (opts.delegator) {
108523
- const { delegator, ...options } = opts;
108524
- handleCorsOptionsDelegator(delegator, fastify, options, next);
108525
- } else {
108526
- const corsOptions = normalizeCorsOptions(opts);
108527
- validateHook(corsOptions.hook, next);
108528
- if (hookWithPayload.indexOf(corsOptions.hook) !== -1) {
108529
- fastify.addHook(corsOptions.hook, function handleCors(req, reply, _payload, next2) {
108530
- addCorsHeadersHandler(fastify, corsOptions, req, reply, next2);
108531
- });
108532
- } else {
108533
- fastify.addHook(corsOptions.hook, function handleCors(req, reply, next2) {
108534
- addCorsHeadersHandler(fastify, corsOptions, req, reply, next2);
108535
- });
108536
- }
108537
- }
108538
- if (opts.logLevel !== undefined)
108539
- logLevel = opts.logLevel;
108540
- if (opts.hideOptionsRoute !== undefined)
108541
- hideOptionsRoute = opts.hideOptionsRoute;
108542
- fastify.options("*", { schema: { hide: hideOptionsRoute }, logLevel }, (req, reply) => {
108543
- if (!req.corsPreflightEnabled) {
108544
- reply.callNotFound();
108545
- return;
111434
+ // ../../../node_modules/ws/lib/websocket-server.js
111435
+ var require_websocket_server2 = __commonJS((exports, module) => {
111436
+ var EventEmitter = __require("events");
111437
+ var http2 = __require("http");
111438
+ var https = __require("https");
111439
+ var net = __require("net");
111440
+ var tls = __require("tls");
111441
+ var { createHash: createHash14 } = __require("crypto");
111442
+ var PerMessageDeflate = require_permessage_deflate2();
111443
+ var WebSocket2 = require_websocket2();
111444
+ var { format, parse: parse2 } = require_extension2();
111445
+ var { GUID, kWebSocket } = require_constants8();
111446
+ var keyRegex = /^[+/0-9A-Za-z]{22}==$/;
111447
+ var RUNNING = 0;
111448
+ var CLOSING = 1;
111449
+ var CLOSED = 2;
111450
+
111451
+ class WebSocketServer extends EventEmitter {
111452
+ constructor(options, callback) {
111453
+ super();
111454
+ options = {
111455
+ maxBufferedChunks: 1024 * 1024,
111456
+ maxFragments: 128 * 1024,
111457
+ maxPayload: 100 * 1024 * 1024,
111458
+ perMessageDeflate: false,
111459
+ handleProtocols: null,
111460
+ clientTracking: true,
111461
+ verifyClient: null,
111462
+ noServer: false,
111463
+ backlog: null,
111464
+ server: null,
111465
+ host: null,
111466
+ path: null,
111467
+ port: null,
111468
+ ...options
111469
+ };
111470
+ if (options.port == null && !options.server && !options.noServer || options.port != null && (options.server || options.noServer) || options.server && options.noServer) {
111471
+ throw new TypeError('One and only one of the "port", "server", or "noServer" options ' + "must be specified");
108546
111472
  }
108547
- reply.send();
108548
- });
108549
- next();
108550
- }
108551
- function handleCorsOptionsDelegator(optionsResolver, fastify, opts, next) {
108552
- const hook = opts?.hook || defaultOptions.hook;
108553
- validateHook(hook, next);
108554
- if (optionsResolver.length === 2) {
108555
- if (hookWithPayload.indexOf(hook) !== -1) {
108556
- fastify.addHook(hook, function handleCors(req, reply, _payload, next2) {
108557
- handleCorsOptionsCallbackDelegator(optionsResolver, fastify, req, reply, next2);
108558
- });
108559
- } else {
108560
- fastify.addHook(hook, function handleCors(req, reply, next2) {
108561
- handleCorsOptionsCallbackDelegator(optionsResolver, fastify, req, reply, next2);
111473
+ if (options.port != null) {
111474
+ this._server = http2.createServer((req, res) => {
111475
+ const body = http2.STATUS_CODES[426];
111476
+ res.writeHead(426, {
111477
+ "Content-Length": body.length,
111478
+ "Content-Type": "text/plain"
111479
+ });
111480
+ res.end(body);
108562
111481
  });
111482
+ this._server.listen(options.port, options.host, options.backlog, callback);
111483
+ } else if (options.server) {
111484
+ this._server = options.server;
108563
111485
  }
108564
- } else {
108565
- if (hookWithPayload.indexOf(hook) !== -1) {
108566
- fastify.addHook(hook, function handleCors(req, reply, _payload, next2) {
108567
- const ret = optionsResolver(req);
108568
- if (ret && typeof ret.then === "function") {
108569
- ret.then((options) => addCorsHeadersHandler(fastify, normalizeCorsOptions(options, true), req, reply, next2)).catch(next2);
108570
- return;
108571
- }
108572
- next2(new Error("Invalid CORS origin option"));
108573
- });
108574
- } else {
108575
- fastify.addHook(hook, function handleCors(req, reply, next2) {
108576
- const ret = optionsResolver(req);
108577
- if (ret && typeof ret.then === "function") {
108578
- ret.then((options) => addCorsHeadersHandler(fastify, normalizeCorsOptions(options, true), req, reply, next2)).catch(next2);
108579
- return;
111486
+ if (this._server) {
111487
+ const emitConnection = this.emit.bind(this, "connection");
111488
+ this._removeListeners = addListeners(this._server, {
111489
+ listening: this.emit.bind(this, "listening"),
111490
+ error: this.emit.bind(this, "error"),
111491
+ upgrade: (req, socket, head) => {
111492
+ this.handleUpgrade(req, socket, head, emitConnection);
108580
111493
  }
108581
- next2(new Error("Invalid CORS origin option"));
108582
111494
  });
108583
111495
  }
111496
+ if (options.perMessageDeflate === true)
111497
+ options.perMessageDeflate = {};
111498
+ if (options.clientTracking)
111499
+ this.clients = new Set;
111500
+ this.options = options;
111501
+ this._state = RUNNING;
108584
111502
  }
108585
- }
108586
- function handleCorsOptionsCallbackDelegator(optionsResolver, fastify, req, reply, next) {
108587
- optionsResolver(req, (err, options) => {
108588
- if (err) {
108589
- next(err);
108590
- } else {
108591
- addCorsHeadersHandler(fastify, normalizeCorsOptions(options, true), req, reply, next);
111503
+ address() {
111504
+ if (this.options.noServer) {
111505
+ throw new Error('The server is operating in "noServer" mode');
108592
111506
  }
108593
- });
108594
- }
108595
- function normalizeCorsOptions(opts, dynamic) {
108596
- const corsOptions = { ...defaultOptions, ...opts };
108597
- if (Array.isArray(opts.origin) && opts.origin.indexOf("*") !== -1) {
108598
- corsOptions.origin = "*";
108599
- }
108600
- if (Number.isInteger(corsOptions.cacheControl)) {
108601
- corsOptions.cacheControl = `max-age=${corsOptions.cacheControl}`;
108602
- } else if (typeof corsOptions.cacheControl !== "string") {
108603
- corsOptions.cacheControl = null;
108604
- }
108605
- corsOptions.dynamic = dynamic || false;
108606
- return corsOptions;
108607
- }
108608
- function addCorsHeadersHandler(fastify, globalOptions, req, reply, next) {
108609
- const options = { ...globalOptions, ...req.routeOptions.config?.cors };
108610
- if (typeof options.origin !== "string" && options.origin !== false || options.dynamic) {
108611
- addOriginToVaryHeader(reply);
111507
+ if (!this._server)
111508
+ return null;
111509
+ return this._server.address();
108612
111510
  }
108613
- const resolveOriginOption = typeof options.origin === "function" ? resolveOriginWrapper(fastify, options.origin) : (_, cb) => cb(null, options.origin);
108614
- resolveOriginOption(req, (error, resolvedOriginOption) => {
108615
- if (error !== null) {
108616
- return next(error);
111511
+ close(cb) {
111512
+ if (cb)
111513
+ this.once("close", cb);
111514
+ if (this._state === CLOSED) {
111515
+ process.nextTick(emitClose, this);
111516
+ return;
108617
111517
  }
108618
- if (resolvedOriginOption === false) {
108619
- return next();
111518
+ if (this._state === CLOSING)
111519
+ return;
111520
+ this._state = CLOSING;
111521
+ if (this.clients) {
111522
+ for (const client of this.clients)
111523
+ client.terminate();
108620
111524
  }
108621
- if (req.routeOptions.config?.cors === false) {
108622
- return next();
111525
+ const server = this._server;
111526
+ if (server) {
111527
+ this._removeListeners();
111528
+ this._removeListeners = this._server = null;
111529
+ if (this.options.port != null) {
111530
+ server.close(emitClose.bind(undefined, this));
111531
+ return;
111532
+ }
108623
111533
  }
108624
- if (!resolvedOriginOption) {
108625
- return next(new Error("Invalid CORS origin option"));
111534
+ process.nextTick(emitClose, this);
111535
+ }
111536
+ shouldHandle(req) {
111537
+ if (this.options.path) {
111538
+ const index = req.url.indexOf("?");
111539
+ const pathname = index !== -1 ? req.url.slice(0, index) : req.url;
111540
+ if (pathname !== this.options.path)
111541
+ return false;
108626
111542
  }
108627
- addCorsHeaders(req, reply, resolvedOriginOption, options);
108628
- if (req.raw.method === "OPTIONS" && options.preflight === true) {
108629
- if (options.strictPreflight === true && (!req.headers.origin || !req.headers["access-control-request-method"])) {
108630
- reply.status(400).type("text/plain").send("Invalid Preflight Request");
108631
- return;
111543
+ return true;
111544
+ }
111545
+ handleUpgrade(req, socket, head, cb) {
111546
+ socket.on("error", socketOnError);
111547
+ const key = req.headers["sec-websocket-key"] !== undefined ? req.headers["sec-websocket-key"].trim() : false;
111548
+ const upgrade = req.headers.upgrade;
111549
+ const version2 = +req.headers["sec-websocket-version"];
111550
+ const extensions = {};
111551
+ if (req.method !== "GET" || upgrade === undefined || upgrade.toLowerCase() !== "websocket" || !key || !keyRegex.test(key) || version2 !== 8 && version2 !== 13 || !this.shouldHandle(req)) {
111552
+ return abortHandshake(socket, 400);
111553
+ }
111554
+ if (this.options.perMessageDeflate) {
111555
+ const perMessageDeflate = new PerMessageDeflate(this.options.perMessageDeflate, true, this.options.maxPayload);
111556
+ try {
111557
+ const offers = parse2(req.headers["sec-websocket-extensions"]);
111558
+ if (offers[PerMessageDeflate.extensionName]) {
111559
+ perMessageDeflate.accept(offers[PerMessageDeflate.extensionName]);
111560
+ extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
111561
+ }
111562
+ } catch (err) {
111563
+ return abortHandshake(socket, 400);
108632
111564
  }
108633
- req.corsPreflightEnabled = true;
108634
- addPreflightHeaders(req, reply, options);
108635
- if (!options.preflightContinue) {
108636
- reply.code(options.optionsSuccessStatus).header("Content-Length", "0").send();
111565
+ }
111566
+ if (this.options.verifyClient) {
111567
+ const info = {
111568
+ origin: req.headers[`${version2 === 8 ? "sec-websocket-origin" : "origin"}`],
111569
+ secure: !!(req.socket.authorized || req.socket.encrypted),
111570
+ req
111571
+ };
111572
+ if (this.options.verifyClient.length === 2) {
111573
+ this.options.verifyClient(info, (verified, code, message, headers) => {
111574
+ if (!verified) {
111575
+ return abortHandshake(socket, code || 401, message, headers);
111576
+ }
111577
+ this.completeUpgrade(key, extensions, req, socket, head, cb);
111578
+ });
108637
111579
  return;
108638
111580
  }
111581
+ if (!this.options.verifyClient(info))
111582
+ return abortHandshake(socket, 401);
108639
111583
  }
108640
- return next();
108641
- });
108642
- }
108643
- function addCorsHeaders(req, reply, originOption, corsOptions) {
108644
- const origin = getAccessControlAllowOriginHeader(req.headers.origin, originOption);
108645
- if (origin) {
108646
- reply.header("Access-Control-Allow-Origin", origin);
108647
- }
108648
- if (corsOptions.credentials) {
108649
- reply.header("Access-Control-Allow-Credentials", "true");
108650
- }
108651
- if (corsOptions.exposedHeaders !== null) {
108652
- reply.header("Access-Control-Expose-Headers", Array.isArray(corsOptions.exposedHeaders) ? corsOptions.exposedHeaders.join(", ") : corsOptions.exposedHeaders);
111584
+ this.completeUpgrade(key, extensions, req, socket, head, cb);
108653
111585
  }
108654
- }
108655
- function addPreflightHeaders(req, reply, corsOptions) {
108656
- reply.header("Access-Control-Allow-Methods", Array.isArray(corsOptions.methods) ? corsOptions.methods.join(", ") : corsOptions.methods);
108657
- if (corsOptions.allowedHeaders === null) {
108658
- addAccessControlRequestHeadersToVaryHeader(reply);
108659
- const reqAllowedHeaders = req.headers["access-control-request-headers"];
108660
- if (reqAllowedHeaders !== undefined) {
108661
- reply.header("Access-Control-Allow-Headers", reqAllowedHeaders);
111586
+ completeUpgrade(key, extensions, req, socket, head, cb) {
111587
+ if (!socket.readable || !socket.writable)
111588
+ return socket.destroy();
111589
+ if (socket[kWebSocket]) {
111590
+ throw new Error("server.handleUpgrade() was called more than once with the same " + "socket, possibly due to a misconfiguration");
108662
111591
  }
108663
- } else {
108664
- reply.header("Access-Control-Allow-Headers", Array.isArray(corsOptions.allowedHeaders) ? corsOptions.allowedHeaders.join(", ") : corsOptions.allowedHeaders);
108665
- }
108666
- if (corsOptions.maxAge !== null) {
108667
- reply.header("Access-Control-Max-Age", String(corsOptions.maxAge));
108668
- }
108669
- if (corsOptions.cacheControl) {
108670
- reply.header("Cache-Control", corsOptions.cacheControl);
111592
+ if (this._state > RUNNING)
111593
+ return abortHandshake(socket, 503);
111594
+ const digest = createHash14("sha1").update(key + GUID).digest("base64");
111595
+ const headers = [
111596
+ "HTTP/1.1 101 Switching Protocols",
111597
+ "Upgrade: websocket",
111598
+ "Connection: Upgrade",
111599
+ `Sec-WebSocket-Accept: ${digest}`
111600
+ ];
111601
+ const ws = new WebSocket2(null);
111602
+ let protocol = req.headers["sec-websocket-protocol"];
111603
+ if (protocol) {
111604
+ protocol = protocol.split(",").map(trim3);
111605
+ if (this.options.handleProtocols) {
111606
+ protocol = this.options.handleProtocols(protocol, req);
111607
+ } else {
111608
+ protocol = protocol[0];
111609
+ }
111610
+ if (protocol) {
111611
+ headers.push(`Sec-WebSocket-Protocol: ${protocol}`);
111612
+ ws._protocol = protocol;
111613
+ }
111614
+ }
111615
+ if (extensions[PerMessageDeflate.extensionName]) {
111616
+ const params = extensions[PerMessageDeflate.extensionName].params;
111617
+ const value = format({
111618
+ [PerMessageDeflate.extensionName]: [params]
111619
+ });
111620
+ headers.push(`Sec-WebSocket-Extensions: ${value}`);
111621
+ ws._extensions = extensions;
111622
+ }
111623
+ this.emit("headers", headers, req);
111624
+ socket.write(headers.concat(`\r
111625
+ `).join(`\r
111626
+ `));
111627
+ socket.removeListener("error", socketOnError);
111628
+ ws.setSocket(socket, head, this.options.maxPayload, this.options.maxBufferedChunks, this.options.maxFragments);
111629
+ if (this.clients) {
111630
+ this.clients.add(ws);
111631
+ ws.on("close", () => this.clients.delete(ws));
111632
+ }
111633
+ cb(ws, req);
108671
111634
  }
108672
111635
  }
108673
- function resolveOriginWrapper(fastify, origin) {
108674
- return function(req, cb) {
108675
- const result = origin.call(fastify, req.headers.origin, cb);
108676
- if (result && typeof result.then === "function") {
108677
- result.then((res) => cb(null, res), cb);
111636
+ module.exports = WebSocketServer;
111637
+ function addListeners(server, map) {
111638
+ for (const event of Object.keys(map))
111639
+ server.on(event, map[event]);
111640
+ return function removeListeners() {
111641
+ for (const event of Object.keys(map)) {
111642
+ server.removeListener(event, map[event]);
108678
111643
  }
108679
111644
  };
108680
111645
  }
108681
- function getAccessControlAllowOriginHeader(reqOrigin, originOption) {
108682
- if (typeof originOption === "string") {
108683
- return originOption;
108684
- }
108685
- return isRequestOriginAllowed(reqOrigin, originOption) ? reqOrigin : false;
108686
- }
108687
- function isRequestOriginAllowed(reqOrigin, allowedOrigin) {
108688
- if (Array.isArray(allowedOrigin)) {
108689
- for (let i = 0;i < allowedOrigin.length; ++i) {
108690
- if (isRequestOriginAllowed(reqOrigin, allowedOrigin[i])) {
108691
- return true;
108692
- }
108693
- }
108694
- return false;
108695
- } else if (typeof allowedOrigin === "string") {
108696
- return reqOrigin === allowedOrigin;
108697
- } else if (allowedOrigin instanceof RegExp) {
108698
- allowedOrigin.lastIndex = 0;
108699
- return allowedOrigin.test(reqOrigin);
108700
- } else {
108701
- return !!allowedOrigin;
108702
- }
111646
+ function emitClose(server) {
111647
+ server._state = CLOSED;
111648
+ server.emit("close");
108703
111649
  }
108704
- var _fastifyCors = fp(fastifyCors, {
108705
- fastify: "5.x",
108706
- name: "@fastify/cors"
108707
- });
108708
- module.exports = _fastifyCors;
108709
- module.exports.fastifyCors = _fastifyCors;
108710
- module.exports.default = _fastifyCors;
108711
- });
108712
-
108713
- // .tmp-runtime-src/ratelimit/index.ts
108714
- async function registerRateLimiter(_app) {}
108715
- var ROUTE_LIMITS;
108716
- var init_ratelimit = __esm(() => {
108717
- ROUTE_LIMITS = {
108718
- "/v1/intent/resolve": { max: 20, timeWindow: "1 minute" },
108719
- "/v1/skills/:skill_id/execute": { max: 30, timeWindow: "1 minute" },
108720
- "/v1/skills": { max: 5, timeWindow: "1 minute" },
108721
- "/v1/auth/login": { max: 3, timeWindow: "5 minutes" },
108722
- "/v1/feedback": { max: 60, timeWindow: "1 minute" }
108723
- };
108724
- });
108725
-
108726
- // .tmp-runtime-src/logger.ts
108727
- import fs2 from "node:fs";
108728
- import path5 from "node:path";
108729
- function logDir() {
108730
- return path5.join(getUnbrowseHome2(), "logs");
108731
- }
108732
- function getLogFile() {
108733
- const date = new Date().toISOString().slice(0, 10);
108734
- return path5.join(logDir(), `unbrowse-${date}.log`);
108735
- }
108736
- function ensureLogDir() {
108737
- fs2.mkdirSync(logDir(), { recursive: true });
108738
- }
108739
- function log(module, message) {
108740
- const ts = new Date().toTimeString().slice(0, 8);
108741
- const line = `[${ts}] [${module}] ${message}`;
108742
- console.error(line);
108743
- try {
108744
- ensureLogDir();
108745
- fs2.appendFileSync(getLogFile(), line + `
108746
- `);
108747
- } catch {}
108748
- }
108749
- function tsMs() {
108750
- const d = new Date;
108751
- const hh = String(d.getHours()).padStart(2, "0");
108752
- const mm = String(d.getMinutes()).padStart(2, "0");
108753
- const ss = String(d.getSeconds()).padStart(2, "0");
108754
- const ms = String(d.getMilliseconds()).padStart(3, "0");
108755
- return `${hh}:${mm}:${ss}.${ms}`;
108756
- }
108757
- function traceLine(message) {
108758
- const line = `[${tsMs()}] [trace] ${message}`;
108759
- console.log(line);
108760
- try {
108761
- ensureLogDir();
108762
- fs2.appendFileSync(getLogFile(), line + `
108763
- `);
108764
- } catch {}
108765
- }
108766
- async function traceAsync(scope, sid, phase, fn) {
108767
- if (!TRACE_ENABLED)
108768
- return fn();
108769
- const sidShort = (sid ?? "-").slice(0, 8);
108770
- const tag = `sid=${sidShort} scope=${scope} phase=${phase}`;
108771
- const start = Date.now();
108772
- traceLine(`${tag} BEGIN`);
108773
- const heartbeat = setInterval(() => {
108774
- traceLine(`${tag} SLOW elapsed=${Date.now() - start}ms`);
108775
- }, TRACE_SLOW_MS);
108776
- heartbeat.unref?.();
108777
- try {
108778
- const result = await fn();
108779
- clearInterval(heartbeat);
108780
- traceLine(`${tag} END dur=${Date.now() - start}ms`);
108781
- return result;
108782
- } catch (err) {
108783
- clearInterval(heartbeat);
108784
- const msg = err instanceof Error ? err.message : String(err);
108785
- traceLine(`${tag} THREW dur=${Date.now() - start}ms err=${msg}`);
108786
- throw err;
111650
+ function socketOnError() {
111651
+ this.destroy();
108787
111652
  }
108788
- }
108789
- var TRACE_ENABLED, TRACE_SLOW_MS;
108790
- var init_logger = __esm(() => {
108791
- init_paths();
108792
- TRACE_ENABLED = (() => {
108793
- const v = process.env.UNBROWSE_TRACE;
108794
- return v != null && v !== "" && v !== "0";
108795
- })();
108796
- TRACE_SLOW_MS = (() => {
108797
- const n = parseInt(process.env.UNBROWSE_TRACE_SLOW_MS ?? "5000", 10);
108798
- return Number.isFinite(n) && n > 0 ? n : 5000;
108799
- })();
108800
- });
108801
-
108802
- // .tmp-runtime-src/domain.ts
108803
- var exports_domain = {};
108804
- __export(exports_domain, {
108805
- isSameBrandDomain: () => isSameBrandDomain,
108806
- isDomainMatch: () => isDomainMatch,
108807
- getRegistrableDomain: () => getRegistrableDomain,
108808
- getBrandName: () => getBrandName
108809
- });
108810
- function getBrandName(hostname4) {
108811
- const h = hostname4.replace(/^\./, "").toLowerCase();
108812
- const parts = h.split(".");
108813
- if (parts.length >= 3) {
108814
- const lastTwo = parts.slice(-2).join(".");
108815
- if (GEO_TLD_SUFFIXES.has(lastTwo) || CC_TLDS.has(lastTwo)) {
108816
- return parts[parts.length - 3] ?? parts[0] ?? h;
111653
+ function abortHandshake(socket, code, message, headers) {
111654
+ if (socket.writable) {
111655
+ message = message || http2.STATUS_CODES[code];
111656
+ headers = {
111657
+ Connection: "close",
111658
+ "Content-Type": "text/html",
111659
+ "Content-Length": Buffer.byteLength(message),
111660
+ ...headers
111661
+ };
111662
+ socket.write(`HTTP/1.1 ${code} ${http2.STATUS_CODES[code]}\r
111663
+ ` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join(`\r
111664
+ `) + `\r
111665
+ \r
111666
+ ` + message);
108817
111667
  }
111668
+ socket.removeListener("error", socketOnError);
111669
+ socket.destroy();
108818
111670
  }
108819
- return parts[parts.length - 2] ?? parts[0] ?? h;
108820
- }
108821
- function isSameBrandDomain(a, b) {
108822
- return getBrandName(a) === getBrandName(b);
108823
- }
108824
- function getRegistrableDomain(hostname4) {
108825
- const parts = hostname4.split(".");
108826
- if (parts.length >= 3) {
108827
- const lastTwo = parts.slice(-2).join(".");
108828
- if (CC_TLDS.has(lastTwo) || GEO_TLD_SUFFIXES.has(lastTwo)) {
108829
- return parts.slice(-3).join(".");
108830
- }
111671
+ function trim3(str) {
111672
+ return str.trim();
108831
111673
  }
108832
- return parts.slice(-2).join(".");
108833
- }
108834
- function isDomainMatch(cookieDomain, targetDomain) {
108835
- const c = cookieDomain.replace(/^\./, "").toLowerCase();
108836
- const t = targetDomain.replace(/^\./, "").toLowerCase();
108837
- return t === c || t.endsWith("." + c);
108838
- }
108839
- var CC_TLDS, GEO_TLD_SUFFIXES;
108840
- var init_domain = __esm(() => {
108841
- CC_TLDS = new Set([
108842
- "co.uk",
108843
- "co.nz",
108844
- "co.jp",
108845
- "co.kr",
108846
- "co.in",
108847
- "com.br",
108848
- "com.au",
108849
- "com.cn",
108850
- "com.mx",
108851
- "com.ar",
108852
- "com.tw",
108853
- "org.uk",
108854
- "gov.uk",
108855
- "ac.uk",
108856
- "net.au",
108857
- "org.au"
108858
- ]);
108859
- GEO_TLD_SUFFIXES = new Set([
108860
- "com.sg",
108861
- "com.hk",
108862
- "com.my",
108863
- "com.ph",
108864
- "com.vn",
108865
- "com.id",
108866
- "com.th",
108867
- "com.np",
108868
- "com.pk",
108869
- "com.bd",
108870
- "com.lk",
108871
- "com.mm",
108872
- "com.kh",
108873
- "com.eg",
108874
- "com.sa",
108875
- "com.qa",
108876
- "com.ae",
108877
- "com.kw",
108878
- "com.jo",
108879
- "com.lb",
108880
- "com.bh",
108881
- "com.om",
108882
- "com.iq",
108883
- "co.id",
108884
- "co.th",
108885
- "co.nz",
108886
- "co.jp",
108887
- "co.kr",
108888
- "co.in",
108889
- "co.uk",
108890
- "co.za",
108891
- "co.zw",
108892
- "co.ke",
108893
- "co.tz",
108894
- "co.ug"
108895
- ]);
108896
111674
  });
108897
111675
 
108898
- // .tmp-runtime-src/settings.ts
108899
- import { existsSync as existsSync22, mkdirSync as mkdirSync11, readFileSync as readFileSync19, writeFileSync as writeFileSync9 } from "node:fs";
108900
- import { join as join23 } from "node:path";
108901
- function sanitizeProfileName3(value) {
108902
- return value.trim().replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
108903
- }
108904
- function getConfigDir3() {
108905
- if (process.env.UNBROWSE_CONFIG_DIR)
108906
- return process.env.UNBROWSE_CONFIG_DIR;
108907
- const profile = sanitizeProfileName3(process.env.UNBROWSE_PROFILE ?? "");
108908
- return profile ? join23(getUnbrowseHome2(), "profiles", profile) : getUnbrowseHome2();
108909
- }
108910
- function getUnbrowseConfigPath() {
108911
- return join23(getConfigDir3(), "config.json");
108912
- }
108913
- function loadRawConfig() {
108914
- try {
108915
- const configPath2 = getUnbrowseConfigPath();
108916
- if (existsSync22(configPath2)) {
108917
- const parsed = JSON.parse(readFileSync19(configPath2, "utf-8"));
108918
- if (parsed && typeof parsed === "object")
108919
- return parsed;
108920
- }
108921
- } catch {}
108922
- return {};
108923
- }
108924
- function saveRawConfig(config) {
108925
- const configDir = getConfigDir3();
108926
- if (!existsSync22(configDir))
108927
- mkdirSync11(configDir, { recursive: true });
108928
- writeFileSync9(getUnbrowseConfigPath(), JSON.stringify(config, null, 2), { mode: 384 });
108929
- }
108930
- function normalizeDomainRule(value) {
108931
- let normalized = value.trim().toLowerCase();
108932
- if (!normalized)
108933
- return "";
108934
- normalized = normalized.replace(/^\*\./, "");
108935
- if (normalized.startsWith("http://") || normalized.startsWith("https://")) {
108936
- try {
108937
- normalized = new URL(normalized).hostname.toLowerCase();
108938
- } catch {
108939
- normalized = normalized.replace(/^https?:\/\//, "");
108940
- }
108941
- }
108942
- normalized = normalized.split("/")[0] ?? normalized;
108943
- normalized = normalized.replace(/:\d+$/, "");
108944
- normalized = normalized.replace(/^www\./, "");
108945
- return normalized;
108946
- }
108947
- function normalizeDomainList(values) {
108948
- if (!Array.isArray(values))
108949
- return [];
108950
- const normalized = values.filter((value) => typeof value === "string").map(normalizeDomainRule).filter(Boolean);
108951
- return Array.from(new Set(normalized)).sort();
108952
- }
108953
- function matchesDomainRule(domain, rule) {
108954
- const host = normalizeDomainRule(domain);
108955
- const target = normalizeDomainRule(rule);
108956
- if (!host || !target)
108957
- return false;
108958
- if (host === target || host.endsWith(`.${target}`))
108959
- return true;
108960
- try {
108961
- return getRegistrableDomain(host) === target;
108962
- } catch {
108963
- return false;
108964
- }
108965
- }
108966
- function firstMatchingRule(domain, rules) {
108967
- return rules.find((rule) => matchesDomainRule(domain, rule));
108968
- }
108969
- function getCapturePipelineSettings() {
108970
- const raw = loadRawConfig();
108971
- const capturePipeline = raw.capture_pipeline && typeof raw.capture_pipeline === "object" ? raw.capture_pipeline : {};
108972
- return {
108973
- auto_publish_checkpoints: capturePipeline.auto_publish_checkpoints !== false,
108974
- publish_domain_blacklist: normalizeDomainList(capturePipeline.publish_domain_blacklist),
108975
- publish_domain_promptlist: normalizeDomainList(capturePipeline.publish_domain_promptlist)
108976
- };
108977
- }
108978
- function updateCapturePipelineSettings(update) {
108979
- const raw = loadRawConfig();
108980
- const existing = getCapturePipelineSettings();
108981
- const next = {
108982
- auto_publish_checkpoints: typeof update.auto_publish_checkpoints === "boolean" ? update.auto_publish_checkpoints : existing.auto_publish_checkpoints,
108983
- publish_domain_blacklist: update.clear_publish_domain_blacklist ? [] : update.publish_domain_blacklist ? normalizeDomainList(update.publish_domain_blacklist) : existing.publish_domain_blacklist,
108984
- publish_domain_promptlist: update.clear_publish_domain_promptlist ? [] : update.publish_domain_promptlist ? normalizeDomainList(update.publish_domain_promptlist) : existing.publish_domain_promptlist
108985
- };
108986
- saveRawConfig({
108987
- ...raw,
108988
- capture_pipeline: next
108989
- });
108990
- return next;
108991
- }
108992
- function getBrowserAttachPreference() {
108993
- const raw = loadRawConfig();
108994
- const browser = raw.browser && typeof raw.browser === "object" ? raw.browser : {};
108995
- return typeof browser.attach_existing_chrome === "boolean" ? browser.attach_existing_chrome : undefined;
108996
- }
108997
- function getBrowserAttachEnabled() {
108998
- return getBrowserAttachPreference() !== false;
108999
- }
109000
- function setBrowserAttachEnabled(enabled2) {
109001
- const raw = loadRawConfig();
109002
- const browser = raw.browser && typeof raw.browser === "object" ? { ...raw.browser } : {};
109003
- browser.attach_existing_chrome = enabled2;
109004
- saveRawConfig({ ...raw, browser });
109005
- return enabled2;
109006
- }
109007
- function decideCheckpointPublish(domain) {
109008
- const settings = getCapturePipelineSettings();
109009
- if (!settings.auto_publish_checkpoints) {
109010
- return {
109011
- publishQueued: false,
109012
- mode: "disabled",
109013
- reason: "Auto-publish after sync/close is disabled in local settings."
109014
- };
109015
- }
109016
- const blacklisted = firstMatchingRule(domain, settings.publish_domain_blacklist);
109017
- if (blacklisted) {
109018
- return {
109019
- publishQueued: false,
109020
- mode: "blacklisted",
109021
- reason: `Auto-publish skipped because ${domain} matches blacklist entry ${blacklisted}.`,
109022
- matchedDomain: blacklisted
109023
- };
109024
- }
109025
- const prompted = firstMatchingRule(domain, settings.publish_domain_promptlist);
109026
- if (prompted) {
109027
- return {
109028
- publishQueued: false,
109029
- mode: "prompt",
109030
- reason: `Auto-publish paused because ${domain} matches prompt-list entry ${prompted}.`,
109031
- matchedDomain: prompted
109032
- };
109033
- }
109034
- return {
109035
- publishQueued: true,
109036
- mode: "auto",
109037
- reason: "Background publish is allowed for this checkpoint."
109038
- };
109039
- }
109040
- function decideExplicitPublish(domain, confirmPublish) {
109041
- const settings = getCapturePipelineSettings();
109042
- const blacklisted = firstMatchingRule(domain, settings.publish_domain_blacklist);
109043
- if (blacklisted && !confirmPublish) {
109044
- return {
109045
- allowed: false,
109046
- mode: "blacklisted",
109047
- reason: `Explicit publish requires confirmation because ${domain} matches blacklist entry ${blacklisted}.`,
109048
- matchedDomain: blacklisted
109049
- };
109050
- }
109051
- const prompted = firstMatchingRule(domain, settings.publish_domain_promptlist);
109052
- if (prompted && !confirmPublish) {
109053
- return {
109054
- allowed: false,
109055
- mode: "prompt",
109056
- reason: `Explicit publish requires confirmation because ${domain} matches prompt-list entry ${prompted}.`,
109057
- matchedDomain: prompted
109058
- };
109059
- }
109060
- return {
109061
- allowed: true,
109062
- mode: "allowed",
109063
- reason: "Explicit publish allowed."
109064
- };
109065
- }
109066
- var init_settings = __esm(() => {
109067
- init_domain();
109068
- init_paths();
111676
+ // ../../../node_modules/ws/index.js
111677
+ var require_ws2 = __commonJS((exports, module) => {
111678
+ var WebSocket2 = require_websocket2();
111679
+ WebSocket2.createWebSocketStream = require_stream2();
111680
+ WebSocket2.Server = require_websocket_server2();
111681
+ WebSocket2.Receiver = require_receiver2();
111682
+ WebSocket2.Sender = require_sender2();
111683
+ module.exports = WebSocket2;
109069
111684
  });
109070
111685
 
109071
111686
  // .tmp-runtime-src/kuri/client.ts
@@ -109979,7 +112594,7 @@ async function setCookieViaCDP(wsUrl, cookie) {
109979
112594
  resolve(false);
109980
112595
  }, 3000);
109981
112596
  try {
109982
- const ws = new ((()=>{throw new Error("Cannot require module "+"ws");})())(wsUrl);
112597
+ const ws = new (require_ws2())(wsUrl);
109983
112598
  ws.on("open", () => {
109984
112599
  ws.send(JSON.stringify({
109985
112600
  id: 1,
@@ -152475,7 +155090,7 @@ var require_dbcs_codec = __commonJS((exports) => {
152475
155090
  if (resCode !== undefined) {
152476
155091
  dbcsCode = resCode;
152477
155092
  nextChar = uCode;
152478
- }
155093
+ } else {}
152479
155094
  }
152480
155095
  seqObj = undefined;
152481
155096
  } else if (uCode >= 0) {
@@ -152536,7 +155151,7 @@ var require_dbcs_codec = __commonJS((exports) => {
152536
155151
  newBuf[j++] = dbcsCode >> 8;
152537
155152
  newBuf[j++] = dbcsCode & 255;
152538
155153
  }
152539
- }
155154
+ } else {}
152540
155155
  this.seqObj = undefined;
152541
155156
  }
152542
155157
  if (this.leadSurrogate !== -1) {
@@ -155319,7 +157934,7 @@ var require_errors8 = __commonJS((exports, module) => {
155319
157934
  });
155320
157935
 
155321
157936
  // node_modules/.bun/undici@7.25.0/node_modules/undici/lib/core/constants.js
155322
- var require_constants8 = __commonJS((exports, module) => {
157937
+ var require_constants9 = __commonJS((exports, module) => {
155323
157938
  var wellknownHeaderNames = [
155324
157939
  "Accept",
155325
157940
  "Accept-Encoding",
@@ -155445,7 +158060,7 @@ var require_tree = __commonJS((exports, module) => {
155445
158060
  var {
155446
158061
  wellknownHeaderNames,
155447
158062
  headerNameLowerCasedRecord
155448
- } = require_constants8();
158063
+ } = require_constants9();
155449
158064
 
155450
158065
  class TstNode {
155451
158066
  value = null;
@@ -155563,7 +158178,7 @@ var require_util3 = __commonJS((exports, module) => {
155563
158178
  var { EventEmitter: EE } = __require("node:events");
155564
158179
  var timers = require_timers();
155565
158180
  var { InvalidArgumentError, ConnectTimeoutError } = require_errors8();
155566
- var { headerNameLowerCasedRecord } = require_constants8();
158181
+ var { headerNameLowerCasedRecord } = require_constants9();
155567
158182
  var { tree } = require_tree();
155568
158183
  var [nodeMajor, nodeMinor] = process.versions.node.split(".", 2).map((v) => Number(v));
155569
158184
 
@@ -156552,7 +159167,7 @@ var require_request3 = __commonJS((exports, module) => {
156552
159167
  getProtocolFromUrlString
156553
159168
  } = require_util3();
156554
159169
  var { channels } = require_diagnostics();
156555
- var { headerNameLowerCasedRecord } = require_constants8();
159170
+ var { headerNameLowerCasedRecord } = require_constants9();
156556
159171
  var invalidPathRegex = /[^\u0021-\u00ff]/;
156557
159172
  var kHandler = Symbol("handler");
156558
159173
 
@@ -157331,7 +159946,7 @@ var require_utils8 = __commonJS((exports) => {
157331
159946
  });
157332
159947
 
157333
159948
  // node_modules/.bun/undici@7.25.0/node_modules/undici/lib/llhttp/constants.js
157334
- var require_constants9 = __commonJS((exports) => {
159949
+ var require_constants10 = __commonJS((exports) => {
157335
159950
  Object.defineProperty(exports, "__esModule", { value: true });
157336
159951
  exports.SPECIAL_HEADERS = exports.MINOR = exports.MAJOR = exports.HTAB_SP_VCHAR_OBS_TEXT = exports.QUOTED_STRING = exports.CONNECTION_TOKEN_CHARS = exports.HEADER_CHARS = exports.TOKEN = exports.HEX = exports.URL_CHAR = exports.USERINFO_CHARS = exports.MARK = exports.ALPHANUM = exports.NUM = exports.HEX_MAP = exports.NUM_MAP = exports.ALPHA = exports.STATUSES_HTTP = exports.H_METHOD_MAP = exports.METHOD_MAP = exports.METHODS_RTSP = exports.METHODS_ICE = exports.METHODS_HTTP = exports.HEADER_STATE = exports.FINISH = exports.STATUSES = exports.METHODS = exports.LENIENT_FLAGS = exports.FLAGS = exports.TYPE = exports.ERROR = undefined;
157337
159952
  var utils_1 = require_utils8();
@@ -157923,7 +160538,7 @@ var require_llhttp_simd_wasm = __commonJS((exports, module) => {
157923
160538
  });
157924
160539
 
157925
160540
  // node_modules/.bun/undici@7.25.0/node_modules/undici/lib/web/fetch/constants.js
157926
- var require_constants10 = __commonJS((exports, module) => {
160541
+ var require_constants11 = __commonJS((exports, module) => {
157927
160542
  var corsSafeListedMethods = ["GET", "HEAD", "POST"];
157928
160543
  var corsSafeListedMethodsSet = new Set(corsSafeListedMethods);
157929
160544
  var nullBodyStatus = [101, 204, 205, 304];
@@ -159149,7 +161764,7 @@ var require_webidl = __commonJS((exports, module) => {
159149
161764
  var require_util4 = __commonJS((exports, module) => {
159150
161765
  var { Transform } = __require("node:stream");
159151
161766
  var zlib = __require("node:zlib");
159152
- var { redirectStatusSet, referrerPolicyTokens, badPortsSet } = require_constants10();
161767
+ var { redirectStatusSet, referrerPolicyTokens, badPortsSet } = require_constants11();
159153
161768
  var { getGlobalOrigin } = require_global();
159154
161769
  var { collectAnHTTPQuotedString, parseMIMEType } = require_data_url();
159155
161770
  var { performance: performance2 } = __require("node:perf_hooks");
@@ -160615,7 +163230,7 @@ var require_client_h1 = __commonJS((exports, module) => {
160615
163230
  kHTTPContext,
160616
163231
  kClosed
160617
163232
  } = require_symbols4();
160618
- var constants = require_constants9();
163233
+ var constants = require_constants10();
160619
163234
  var EMPTY_BUF = Buffer.alloc(0);
160620
163235
  var FastBuffer = Buffer[Symbol.species];
160621
163236
  var removeAllListeners = util.removeAllListeners;
@@ -171179,7 +173794,7 @@ var require_response2 = __commonJS((exports, module) => {
171179
173794
  var {
171180
173795
  redirectStatusSet,
171181
173796
  nullBodyStatus
171182
- } = require_constants10();
173797
+ } = require_constants11();
171183
173798
  var { webidl } = require_webidl();
171184
173799
  var { URLSerializer } = require_data_url();
171185
173800
  var { kConstruct } = require_symbols4();
@@ -171566,7 +174181,7 @@ var require_request4 = __commonJS((exports, module) => {
171566
174181
  requestCredentials,
171567
174182
  requestCache,
171568
174183
  requestDuplex
171569
- } = require_constants10();
174184
+ } = require_constants11();
171570
174185
  var { kEnumerableProperty, normalizedMethodRecordsBase, normalizedMethodRecords } = util;
171571
174186
  var { webidl } = require_webidl();
171572
174187
  var { URLSerializer } = require_data_url();
@@ -172360,7 +174975,7 @@ var require_fetch = __commonJS((exports, module) => {
172360
174975
  safeMethodsSet,
172361
174976
  requestBodyHeader,
172362
174977
  subresourceSet
172363
- } = require_constants10();
174978
+ } = require_constants11();
172364
174979
  var EE = __require("node:events");
172365
174980
  var { Readable, pipeline, finished, isErrored, isReadable } = __require("node:stream");
172366
174981
  var { addAbortListener, bufferToLowerCasedHeaderName } = require_util3();
@@ -173055,7 +175670,7 @@ var require_fetch = __commonJS((exports, module) => {
173055
175670
  request.cache = "no-store";
173056
175671
  }
173057
175672
  const newConnection = forceNewConnection ? "yes" : "no";
173058
- if (request.mode === "websocket") {}
175673
+ if (request.mode === "websocket") {} else {}
173059
175674
  let requestBody = null;
173060
175675
  if (request.body == null && fetchParams.processRequestEndOfBody) {
173061
175676
  queueMicrotask(() => fetchParams.processRequestEndOfBody());
@@ -173988,7 +176603,7 @@ var require_cachestorage = __commonJS((exports, module) => {
173988
176603
  });
173989
176604
 
173990
176605
  // node_modules/.bun/undici@7.25.0/node_modules/undici/lib/web/cookies/constants.js
173991
- var require_constants11 = __commonJS((exports, module) => {
176606
+ var require_constants12 = __commonJS((exports, module) => {
173992
176607
  var maxAttributeValueSize = 1024;
173993
176608
  var maxNameValuePairSize = 4096;
173994
176609
  module.exports = {
@@ -174142,7 +176757,7 @@ var require_util6 = __commonJS((exports, module) => {
174142
176757
  // node_modules/.bun/undici@7.25.0/node_modules/undici/lib/web/cookies/parse.js
174143
176758
  var require_parse6 = __commonJS((exports, module) => {
174144
176759
  var { collectASequenceOfCodePointsFast } = require_infra();
174145
- var { maxNameValuePairSize, maxAttributeValueSize } = require_constants11();
176760
+ var { maxNameValuePairSize, maxAttributeValueSize } = require_constants12();
174146
176761
  var { isCTLExcludingHtab } = require_util6();
174147
176762
  var assert = __require("node:assert");
174148
176763
  var { unescape: qsUnescape } = __require("node:querystring");
@@ -174659,7 +177274,7 @@ var require_events3 = __commonJS((exports, module) => {
174659
177274
  });
174660
177275
 
174661
177276
  // node_modules/.bun/undici@7.25.0/node_modules/undici/lib/web/websocket/constants.js
174662
- var require_constants12 = __commonJS((exports, module) => {
177277
+ var require_constants13 = __commonJS((exports, module) => {
174663
177278
  var uid = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
174664
177279
  var staticPropertyDescriptors = {
174665
177280
  enumerable: true,
@@ -174713,7 +177328,7 @@ var require_constants12 = __commonJS((exports, module) => {
174713
177328
 
174714
177329
  // node_modules/.bun/undici@7.25.0/node_modules/undici/lib/web/websocket/util.js
174715
177330
  var require_util7 = __commonJS((exports, module) => {
174716
- var { states, opcodes } = require_constants12();
177331
+ var { states, opcodes } = require_constants13();
174717
177332
  var { isUtf8 } = __require("node:buffer");
174718
177333
  var { removeHTTPWhitespace } = require_data_url();
174719
177334
  var { collectASequenceOfCodePointsFast } = require_infra();
@@ -174866,7 +177481,7 @@ var require_util7 = __commonJS((exports, module) => {
174866
177481
  // node_modules/.bun/undici@7.25.0/node_modules/undici/lib/web/websocket/frame.js
174867
177482
  var require_frame = __commonJS((exports, module) => {
174868
177483
  var { runtimeFeatures } = require_runtime_features();
174869
- var { maxUnsigned16Bit, opcodes } = require_constants12();
177484
+ var { maxUnsigned16Bit, opcodes } = require_constants13();
174870
177485
  var BUFFER_SIZE = 8 * 1024;
174871
177486
  var buffer = null;
174872
177487
  var bufIdx = BUFFER_SIZE;
@@ -174962,7 +177577,7 @@ var require_frame = __commonJS((exports, module) => {
174962
177577
 
174963
177578
  // node_modules/.bun/undici@7.25.0/node_modules/undici/lib/web/websocket/connection.js
174964
177579
  var require_connection = __commonJS((exports, module) => {
174965
- var { uid, states, sentCloseFrameState, emptyBuffer, opcodes } = require_constants12();
177580
+ var { uid, states, sentCloseFrameState, emptyBuffer, opcodes } = require_constants13();
174966
177581
  var { parseExtensions, isClosed, isClosing, isEstablished, isConnecting, validateCloseCodeAndReason } = require_util7();
174967
177582
  var { makeRequest } = require_request4();
174968
177583
  var { fetching } = require_fetch();
@@ -175114,7 +177729,7 @@ var require_connection = __commonJS((exports, module) => {
175114
177729
  });
175115
177730
 
175116
177731
  // node_modules/.bun/undici@7.25.0/node_modules/undici/lib/web/websocket/permessage-deflate.js
175117
- var require_permessage_deflate2 = __commonJS((exports, module) => {
177732
+ var require_permessage_deflate3 = __commonJS((exports, module) => {
175118
177733
  var { createInflateRaw, Z_DEFAULT_WINDOWBITS } = __require("node:zlib");
175119
177734
  var { isValidClientWindowBits } = require_util7();
175120
177735
  var { MessageSizeExceededError } = require_errors8();
@@ -175199,10 +177814,10 @@ var require_permessage_deflate2 = __commonJS((exports, module) => {
175199
177814
  });
175200
177815
 
175201
177816
  // node_modules/.bun/undici@7.25.0/node_modules/undici/lib/web/websocket/receiver.js
175202
- var require_receiver2 = __commonJS((exports, module) => {
177817
+ var require_receiver3 = __commonJS((exports, module) => {
175203
177818
  var { Writable } = __require("node:stream");
175204
177819
  var assert = __require("node:assert");
175205
- var { parserStates, opcodes, states, emptyBuffer, sentCloseFrameState } = require_constants12();
177820
+ var { parserStates, opcodes, states, emptyBuffer, sentCloseFrameState } = require_constants13();
175206
177821
  var {
175207
177822
  isValidStatusCode,
175208
177823
  isValidOpcode,
@@ -175214,7 +177829,7 @@ var require_receiver2 = __commonJS((exports, module) => {
175214
177829
  } = require_util7();
175215
177830
  var { failWebsocketConnection } = require_connection();
175216
177831
  var { WebsocketFrameSend } = require_frame();
175217
- var { PerMessageDeflate } = require_permessage_deflate2();
177832
+ var { PerMessageDeflate } = require_permessage_deflate3();
175218
177833
  var { MessageSizeExceededError } = require_errors8();
175219
177834
 
175220
177835
  class ByteParser extends Writable {
@@ -175491,9 +178106,9 @@ var require_receiver2 = __commonJS((exports, module) => {
175491
178106
  });
175492
178107
 
175493
178108
  // node_modules/.bun/undici@7.25.0/node_modules/undici/lib/web/websocket/sender.js
175494
- var require_sender2 = __commonJS((exports, module) => {
178109
+ var require_sender3 = __commonJS((exports, module) => {
175495
178110
  var { WebsocketFrameSend } = require_frame();
175496
- var { opcodes, sendHints } = require_constants12();
178111
+ var { opcodes, sendHints } = require_constants13();
175497
178112
  var FixedQueue = require_fixed_queue();
175498
178113
 
175499
178114
  class SendQueue {
@@ -175569,12 +178184,12 @@ var require_sender2 = __commonJS((exports, module) => {
175569
178184
  });
175570
178185
 
175571
178186
  // node_modules/.bun/undici@7.25.0/node_modules/undici/lib/web/websocket/websocket.js
175572
- var require_websocket2 = __commonJS((exports, module) => {
178187
+ var require_websocket3 = __commonJS((exports, module) => {
175573
178188
  var { isArrayBuffer } = __require("node:util/types");
175574
178189
  var { webidl } = require_webidl();
175575
178190
  var { URLSerializer } = require_data_url();
175576
178191
  var { environmentSettingsObject } = require_util4();
175577
- var { staticPropertyDescriptors, states, sentCloseFrameState, sendHints, opcodes } = require_constants12();
178192
+ var { staticPropertyDescriptors, states, sentCloseFrameState, sendHints, opcodes } = require_constants13();
175578
178193
  var {
175579
178194
  isConnecting,
175580
178195
  isEstablished,
@@ -175587,11 +178202,11 @@ var require_websocket2 = __commonJS((exports, module) => {
175587
178202
  getURLRecord
175588
178203
  } = require_util7();
175589
178204
  var { establishWebSocketConnection, closeWebSocketConnection, failWebsocketConnection } = require_connection();
175590
- var { ByteParser } = require_receiver2();
178205
+ var { ByteParser } = require_receiver3();
175591
178206
  var { kEnumerableProperty } = require_util3();
175592
178207
  var { getGlobalDispatcher } = require_global2();
175593
178208
  var { ErrorEvent, CloseEvent, createFastMessageEvent } = require_events3();
175594
- var { SendQueue } = require_sender2();
178209
+ var { SendQueue } = require_sender3();
175595
178210
  var { WebsocketFrameSend } = require_frame();
175596
178211
  var { channels } = require_diagnostics();
175597
178212
  function getSocketAddress(socket) {
@@ -176093,13 +178708,13 @@ var require_websocketerror = __commonJS((exports, module) => {
176093
178708
  var require_websocketstream = __commonJS((exports, module) => {
176094
178709
  var { createDeferredPromise } = require_promise2();
176095
178710
  var { environmentSettingsObject } = require_util4();
176096
- var { states, opcodes, sentCloseFrameState } = require_constants12();
178711
+ var { states, opcodes, sentCloseFrameState } = require_constants13();
176097
178712
  var { webidl } = require_webidl();
176098
178713
  var { getURLRecord, isValidSubprotocol, isEstablished, utf8Decode } = require_util7();
176099
178714
  var { establishWebSocketConnection, failWebsocketConnection, closeWebSocketConnection } = require_connection();
176100
178715
  var { channels } = require_diagnostics();
176101
178716
  var { WebsocketFrameSend } = require_frame();
176102
- var { ByteParser } = require_receiver2();
178717
+ var { ByteParser } = require_receiver3();
176103
178718
  var { WebSocketError, createUnvalidatedWebSocketError } = require_websocketerror();
176104
178719
  var { kEnumerableProperty } = require_util3();
176105
178720
  var { utf8DecodeBytes } = require_encoding2();
@@ -176896,7 +179511,7 @@ function makeDispatcher(fn) {
176896
179511
  }, handler);
176897
179512
  };
176898
179513
  }
176899
- var __filename = "/Users/lewis/act-runner/work/48768e304e69e0e9/hostexecutor/node_modules/.bun/undici@7.25.0/node_modules/undici/index.js", Client, Dispatcher, Pool, BalancedPool, RoundRobinPool, Agent, ProxyAgent, Socks5ProxyAgent, EnvHttpProxyAgent, RetryAgent, H2CClient, errors, util, InvalidArgumentError, api3, buildConnector, MockClient, MockCallHistory, MockCallHistoryLog, MockAgent, MockPool, SnapshotAgent, mockErrors, RetryHandler, getGlobalDispatcher, setGlobalDispatcher, DecoratorHandler, RedirectHandler, $interceptors, $cacheStores, SqliteCacheStore, $util, fetchImpl, $Headers, $Response, $Request, $FormData, setGlobalOrigin, getGlobalOrigin, CacheStorage, kConstruct, $caches, deleteCookie, getCookies2, getSetCookies, setCookie2, parseCookie, parseMIMEType, serializeAMimeType, CloseEvent, ErrorEvent, MessageEvent, WebSocket2, ping, $WebSocketStream, $WebSocketError, $request, $stream, $pipeline, $connect, $upgrade, EventSource;
179514
+ var __filename = "/Users/lekt9/Projects/unbrowse-ecosystem/unbrowse/node_modules/.bun/undici@7.25.0/node_modules/undici/index.js", Client, Dispatcher, Pool, BalancedPool, RoundRobinPool, Agent, ProxyAgent, Socks5ProxyAgent, EnvHttpProxyAgent, RetryAgent, H2CClient, errors, util, InvalidArgumentError, api3, buildConnector, MockClient, MockCallHistory, MockCallHistoryLog, MockAgent, MockPool, SnapshotAgent, mockErrors, RetryHandler, getGlobalDispatcher, setGlobalDispatcher, DecoratorHandler, RedirectHandler, $interceptors, $cacheStores, SqliteCacheStore, $util, fetchImpl, $Headers, $Response, $Request, $FormData, setGlobalOrigin, getGlobalOrigin, CacheStorage, kConstruct, $caches, deleteCookie, getCookies2, getSetCookies, setCookie2, parseCookie, parseMIMEType, serializeAMimeType, CloseEvent, ErrorEvent, MessageEvent, WebSocket2, ping, $WebSocketStream, $WebSocketError, $request, $stream, $pipeline, $connect, $upgrade, EventSource;
176900
179515
  var init_undici = __esm(() => {
176901
179516
  Client = require_client();
176902
179517
  Dispatcher = require_dispatcher();
@@ -176956,7 +179571,7 @@ var init_undici = __esm(() => {
176956
179571
  ({ deleteCookie, getCookies: getCookies2, getSetCookies, setCookie: setCookie2, parseCookie } = require_cookies());
176957
179572
  ({ parseMIMEType, serializeAMimeType } = require_data_url());
176958
179573
  ({ CloseEvent, ErrorEvent, MessageEvent } = require_events3());
176959
- ({ WebSocket: WebSocket2, ping } = require_websocket2());
179574
+ ({ WebSocket: WebSocket2, ping } = require_websocket3());
176960
179575
  $WebSocketStream = require_websocketstream().WebSocketStream;
176961
179576
  $WebSocketError = require_websocketerror().WebSocketError;
176962
179577
  $request = makeDispatcher(api3.request);
@@ -187842,7 +190457,7 @@ async function executeEndpoint(skill, endpoint, params = {}, projection, options
187842
190457
  const startedAt2 = new Date().toISOString();
187843
190458
  const traceId = nanoid();
187844
190459
  try {
187845
- const { WebSocket: WebSocket3 } = await import("ws");
190460
+ const { WebSocket: WebSocket3 } = await Promise.resolve().then(() => __toESM(require_ws2(), 1));
187846
190461
  const messages = [];
187847
190462
  await new Promise((resolve2, reject) => {
187848
190463
  const ws = new WebSocket3(endpoint.url_template);
@@ -247689,7 +250304,7 @@ var require_errors9 = __commonJS((exports, module) => {
247689
250304
  });
247690
250305
 
247691
250306
  // node_modules/.bun/ws@7.5.10+84634d09670b738c/node_modules/ws/lib/constants.js
247692
- var require_constants13 = __commonJS((exports, module) => {
250307
+ var require_constants14 = __commonJS((exports, module) => {
247693
250308
  module.exports = {
247694
250309
  BINARY_TYPES: ["nodebuffer", "arraybuffer", "fragments"],
247695
250310
  GUID: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
@@ -247701,8 +250316,8 @@ var require_constants13 = __commonJS((exports, module) => {
247701
250316
  });
247702
250317
 
247703
250318
  // node_modules/.bun/ws@7.5.10+84634d09670b738c/node_modules/ws/lib/buffer-util.js
247704
- var require_buffer_util2 = __commonJS((exports, module) => {
247705
- var { EMPTY_BUFFER } = require_constants13();
250319
+ var require_buffer_util3 = __commonJS((exports, module) => {
250320
+ var { EMPTY_BUFFER } = require_constants14();
247706
250321
  function concat3(list, totalLength) {
247707
250322
  if (list.length === 0)
247708
250323
  return EMPTY_BUFFER;
@@ -247783,7 +250398,7 @@ var require_buffer_util2 = __commonJS((exports, module) => {
247783
250398
  });
247784
250399
 
247785
250400
  // node_modules/.bun/ws@7.5.10+84634d09670b738c/node_modules/ws/lib/limiter.js
247786
- var require_limiter2 = __commonJS((exports, module) => {
250401
+ var require_limiter3 = __commonJS((exports, module) => {
247787
250402
  var kDone = Symbol("kDone");
247788
250403
  var kRun = Symbol("kRun");
247789
250404
 
@@ -247815,11 +250430,11 @@ var require_limiter2 = __commonJS((exports, module) => {
247815
250430
  });
247816
250431
 
247817
250432
  // node_modules/.bun/ws@7.5.10+84634d09670b738c/node_modules/ws/lib/permessage-deflate.js
247818
- var require_permessage_deflate3 = __commonJS((exports, module) => {
250433
+ var require_permessage_deflate4 = __commonJS((exports, module) => {
247819
250434
  var zlib = __require("zlib");
247820
- var bufferUtil = require_buffer_util2();
247821
- var Limiter = require_limiter2();
247822
- var { kStatusCode, NOOP } = require_constants13();
250435
+ var bufferUtil = require_buffer_util3();
250436
+ var Limiter = require_limiter3();
250437
+ var { kStatusCode, NOOP } = require_constants14();
247823
250438
  var TRAILER = Buffer.from([0, 0, 255, 255]);
247824
250439
  var kPerMessageDeflate = Symbol("permessage-deflate");
247825
250440
  var kTotalLength = Symbol("total-length");
@@ -248074,7 +250689,7 @@ var require_permessage_deflate3 = __commonJS((exports, module) => {
248074
250689
  });
248075
250690
 
248076
250691
  // node_modules/.bun/ws@7.5.10+84634d09670b738c/node_modules/ws/lib/validation.js
248077
- var require_validation4 = __commonJS((exports, module) => {
250692
+ var require_validation5 = __commonJS((exports, module) => {
248078
250693
  function isValidStatusCode(code) {
248079
250694
  return code >= 1000 && code <= 1014 && code !== 1004 && code !== 1005 && code !== 1006 || code >= 3000 && code <= 4999;
248080
250695
  }
@@ -248125,17 +250740,17 @@ var require_validation4 = __commonJS((exports, module) => {
248125
250740
  });
248126
250741
 
248127
250742
  // node_modules/.bun/ws@7.5.10+84634d09670b738c/node_modules/ws/lib/receiver.js
248128
- var require_receiver3 = __commonJS((exports, module) => {
250743
+ var require_receiver4 = __commonJS((exports, module) => {
248129
250744
  var { Writable } = __require("stream");
248130
- var PerMessageDeflate = require_permessage_deflate3();
250745
+ var PerMessageDeflate = require_permessage_deflate4();
248131
250746
  var {
248132
250747
  BINARY_TYPES,
248133
250748
  EMPTY_BUFFER,
248134
250749
  kStatusCode,
248135
250750
  kWebSocket
248136
- } = require_constants13();
248137
- var { concat: concat3, toArrayBuffer, unmask } = require_buffer_util2();
248138
- var { isValidStatusCode, isValidUTF8 } = require_validation4();
250751
+ } = require_constants14();
250752
+ var { concat: concat3, toArrayBuffer, unmask } = require_buffer_util3();
250753
+ var { isValidStatusCode, isValidUTF8 } = require_validation5();
248139
250754
  var GET_INFO = 0;
248140
250755
  var GET_PAYLOAD_LENGTH_16 = 1;
248141
250756
  var GET_PAYLOAD_LENGTH_64 = 2;
@@ -248446,14 +251061,14 @@ var require_receiver3 = __commonJS((exports, module) => {
248446
251061
  });
248447
251062
 
248448
251063
  // node_modules/.bun/ws@7.5.10+84634d09670b738c/node_modules/ws/lib/sender.js
248449
- var require_sender3 = __commonJS((exports, module) => {
251064
+ var require_sender4 = __commonJS((exports, module) => {
248450
251065
  var net2 = __require("net");
248451
251066
  var tls = __require("tls");
248452
251067
  var { randomFillSync } = __require("crypto");
248453
- var PerMessageDeflate = require_permessage_deflate3();
248454
- var { EMPTY_BUFFER } = require_constants13();
248455
- var { isValidStatusCode } = require_validation4();
248456
- var { mask: applyMask, toBuffer } = require_buffer_util2();
251068
+ var PerMessageDeflate = require_permessage_deflate4();
251069
+ var { EMPTY_BUFFER } = require_constants14();
251070
+ var { isValidStatusCode } = require_validation5();
251071
+ var { mask: applyMask, toBuffer } = require_buffer_util3();
248457
251072
  var mask = Buffer.alloc(4);
248458
251073
 
248459
251074
  class Sender {
@@ -248669,7 +251284,7 @@ var require_sender3 = __commonJS((exports, module) => {
248669
251284
  });
248670
251285
 
248671
251286
  // node_modules/.bun/ws@7.5.10+84634d09670b738c/node_modules/ws/lib/event-target.js
248672
- var require_event_target2 = __commonJS((exports, module) => {
251287
+ var require_event_target3 = __commonJS((exports, module) => {
248673
251288
  class Event2 {
248674
251289
  constructor(type, target) {
248675
251290
  this.target = target;
@@ -248752,7 +251367,7 @@ var require_event_target2 = __commonJS((exports, module) => {
248752
251367
  });
248753
251368
 
248754
251369
  // node_modules/.bun/ws@7.5.10+84634d09670b738c/node_modules/ws/lib/extension.js
248755
- var require_extension2 = __commonJS((exports, module) => {
251370
+ var require_extension3 = __commonJS((exports, module) => {
248756
251371
  var tokenChars = [
248757
251372
  0,
248758
251373
  0,
@@ -249047,7 +251662,7 @@ var require_extension2 = __commonJS((exports, module) => {
249047
251662
  });
249048
251663
 
249049
251664
  // node_modules/.bun/ws@7.5.10+84634d09670b738c/node_modules/ws/lib/websocket.js
249050
- var require_websocket3 = __commonJS((exports, module) => {
251665
+ var require_websocket4 = __commonJS((exports, module) => {
249051
251666
  var EventEmitter = __require("events");
249052
251667
  var https = __require("https");
249053
251668
  var http2 = __require("http");
@@ -249056,9 +251671,9 @@ var require_websocket3 = __commonJS((exports, module) => {
249056
251671
  var { randomBytes: randomBytes16, createHash: createHash26 } = __require("crypto");
249057
251672
  var { Readable } = __require("stream");
249058
251673
  var { URL: URL2 } = __require("url");
249059
- var PerMessageDeflate = require_permessage_deflate3();
249060
- var Receiver = require_receiver3();
249061
- var Sender = require_sender3();
251674
+ var PerMessageDeflate = require_permessage_deflate4();
251675
+ var Receiver = require_receiver4();
251676
+ var Sender = require_sender4();
249062
251677
  var {
249063
251678
  BINARY_TYPES,
249064
251679
  EMPTY_BUFFER,
@@ -249066,10 +251681,10 @@ var require_websocket3 = __commonJS((exports, module) => {
249066
251681
  kStatusCode,
249067
251682
  kWebSocket,
249068
251683
  NOOP
249069
- } = require_constants13();
249070
- var { addEventListener, removeEventListener } = require_event_target2();
249071
- var { format, parse: parse9 } = require_extension2();
249072
- var { toBuffer } = require_buffer_util2();
251684
+ } = require_constants14();
251685
+ var { addEventListener, removeEventListener } = require_event_target3();
251686
+ var { format, parse: parse9 } = require_extension3();
251687
+ var { toBuffer } = require_buffer_util3();
249073
251688
  var readyStates = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
249074
251689
  var protocolVersions = [8, 13];
249075
251690
  var closeTimeout = 30 * 1000;
@@ -249693,7 +252308,7 @@ var require_websocket3 = __commonJS((exports, module) => {
249693
252308
  });
249694
252309
 
249695
252310
  // node_modules/.bun/ws@7.5.10+84634d09670b738c/node_modules/ws/lib/stream.js
249696
- var require_stream2 = __commonJS((exports, module) => {
252311
+ var require_stream3 = __commonJS((exports, module) => {
249697
252312
  var { Duplex } = __require("stream");
249698
252313
  function emitClose(stream) {
249699
252314
  stream.emit("close");
@@ -249813,17 +252428,17 @@ var require_stream2 = __commonJS((exports, module) => {
249813
252428
  });
249814
252429
 
249815
252430
  // node_modules/.bun/ws@7.5.10+84634d09670b738c/node_modules/ws/lib/websocket-server.js
249816
- var require_websocket_server2 = __commonJS((exports, module) => {
252431
+ var require_websocket_server3 = __commonJS((exports, module) => {
249817
252432
  var EventEmitter = __require("events");
249818
252433
  var http2 = __require("http");
249819
252434
  var https = __require("https");
249820
252435
  var net2 = __require("net");
249821
252436
  var tls = __require("tls");
249822
252437
  var { createHash: createHash26 } = __require("crypto");
249823
- var PerMessageDeflate = require_permessage_deflate3();
249824
- var WebSocket3 = require_websocket3();
249825
- var { format, parse: parse9 } = require_extension2();
249826
- var { GUID, kWebSocket } = require_constants13();
252438
+ var PerMessageDeflate = require_permessage_deflate4();
252439
+ var WebSocket3 = require_websocket4();
252440
+ var { format, parse: parse9 } = require_extension3();
252441
+ var { GUID, kWebSocket } = require_constants14();
249827
252442
  var keyRegex = /^[+/0-9A-Za-z]{22}==$/;
249828
252443
  var RUNNING = 0;
249829
252444
  var CLOSING = 1;
@@ -250053,12 +252668,12 @@ var require_websocket_server2 = __commonJS((exports, module) => {
250053
252668
  });
250054
252669
 
250055
252670
  // node_modules/.bun/ws@7.5.10+84634d09670b738c/node_modules/ws/index.js
250056
- var require_ws2 = __commonJS((exports, module) => {
250057
- var WebSocket3 = require_websocket3();
250058
- WebSocket3.createWebSocketStream = require_stream2();
250059
- WebSocket3.Server = require_websocket_server2();
250060
- WebSocket3.Receiver = require_receiver3();
250061
- WebSocket3.Sender = require_sender3();
252671
+ var require_ws3 = __commonJS((exports, module) => {
252672
+ var WebSocket3 = require_websocket4();
252673
+ WebSocket3.createWebSocketStream = require_stream3();
252674
+ WebSocket3.Server = require_websocket_server3();
252675
+ WebSocket3.Receiver = require_receiver4();
252676
+ WebSocket3.Sender = require_sender4();
250062
252677
  module.exports = WebSocket3;
250063
252678
  });
250064
252679
 
@@ -250148,7 +252763,7 @@ var require_chrome = __commonJS((exports, module) => {
250148
252763
  var util2 = __require("util");
250149
252764
  var formatUrl = __require("url").format;
250150
252765
  var parseUrl = __require("url").parse;
250151
- var WebSocket3 = require_ws2();
252766
+ var WebSocket3 = require_ws3();
250152
252767
  var api5 = require_api2();
250153
252768
  var defaults = require_defaults2();
250154
252769
  var devtools = require_devtools();
@@ -250566,7 +253181,7 @@ var init_types2 = __esm(() => {
250566
253181
  });
250567
253182
 
250568
253183
  // node_modules/.bun/semver@7.8.1/node_modules/semver/internal/constants.js
250569
- var require_constants14 = __commonJS((exports, module) => {
253184
+ var require_constants15 = __commonJS((exports, module) => {
250570
253185
  var SEMVER_SPEC_VERSION = "2.0.0";
250571
253186
  var MAX_LENGTH = 256;
250572
253187
  var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
@@ -250605,7 +253220,7 @@ var require_re2 = __commonJS((exports, module) => {
250605
253220
  MAX_SAFE_COMPONENT_LENGTH,
250606
253221
  MAX_SAFE_BUILD_LENGTH,
250607
253222
  MAX_LENGTH
250608
- } = require_constants14();
253223
+ } = require_constants15();
250609
253224
  var debug = require_debug3();
250610
253225
  exports = module.exports = {};
250611
253226
  var re = exports.re = [];
@@ -250725,7 +253340,7 @@ var require_identifiers2 = __commonJS((exports, module) => {
250725
253340
  // node_modules/.bun/semver@7.8.1/node_modules/semver/classes/semver.js
250726
253341
  var require_semver3 = __commonJS((exports, module) => {
250727
253342
  var debug = require_debug3();
250728
- var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants14();
253343
+ var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants15();
250729
253344
  var { safeRe: re, t } = require_re2();
250730
253345
  var parseOptions = require_parse_options2();
250731
253346
  var { compareIdentifiers } = require_identifiers2();
@@ -251301,7 +253916,7 @@ var require_coerce2 = __commonJS((exports, module) => {
251301
253916
  // node_modules/.bun/semver@7.8.1/node_modules/semver/functions/truncate.js
251302
253917
  var require_truncate = __commonJS((exports, module) => {
251303
253918
  var parse9 = require_parse7();
251304
- var constants = require_constants14();
253919
+ var constants = require_constants15();
251305
253920
  var SemVer = require_semver3();
251306
253921
  var truncate = (version2, truncation, options) => {
251307
253922
  if (!constants.RELEASE_TYPES.includes(truncation)) {
@@ -251528,7 +254143,7 @@ var require_range3 = __commonJS((exports, module) => {
251528
254143
  tildeTrimReplace,
251529
254144
  caretTrimReplace
251530
254145
  } = require_re2();
251531
- var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants14();
254146
+ var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants15();
251532
254147
  var BUILDSTRIPRE = new RegExp(src[t.BUILD], "g");
251533
254148
  var isNullSet = (c) => c.value === "<0.0.0-0";
251534
254149
  var isAny = (c) => c.value === "";
@@ -252300,7 +254915,7 @@ var require_subset2 = __commonJS((exports, module) => {
252300
254915
  // node_modules/.bun/semver@7.8.1/node_modules/semver/index.js
252301
254916
  var require_semver4 = __commonJS((exports, module) => {
252302
254917
  var internalRe = require_re2();
252303
- var constants = require_constants14();
254918
+ var constants = require_constants15();
252304
254919
  var SemVer = require_semver3();
252305
254920
  var identifiers = require_identifiers2();
252306
254921
  var parse9 = require_parse7();
@@ -255339,7 +257954,7 @@ var require_smartbuffer = __commonJS((exports) => {
255339
257954
  });
255340
257955
 
255341
257956
  // node_modules/.bun/socks@2.8.9/node_modules/socks/build/common/constants.js
255342
- var require_constants15 = __commonJS((exports) => {
257957
+ var require_constants16 = __commonJS((exports) => {
255343
257958
  Object.defineProperty(exports, "__esModule", { value: true });
255344
257959
  exports.SOCKS5_NO_ACCEPTABLE_AUTH = exports.SOCKS5_CUSTOM_AUTH_END = exports.SOCKS5_CUSTOM_AUTH_START = exports.SOCKS_INCOMING_PACKET_SIZES = exports.SocksClientState = exports.Socks5Response = exports.Socks5HostType = exports.Socks5Auth = exports.Socks4Response = exports.SocksCommand = exports.ERRORS = exports.DEFAULT_TIMEOUT = undefined;
255345
257960
  var DEFAULT_TIMEOUT = 30000;
@@ -255542,7 +258157,7 @@ var require_common5 = __commonJS((exports) => {
255542
258157
  });
255543
258158
 
255544
258159
  // node_modules/.bun/ip-address@10.2.0/node_modules/ip-address/dist/v4/constants.js
255545
- var require_constants16 = __commonJS((exports) => {
258160
+ var require_constants17 = __commonJS((exports) => {
255546
258161
  Object.defineProperty(exports, "__esModule", { value: true });
255547
258162
  exports.RE_SUBNET_STRING = exports.RE_ADDRESS = exports.GROUPS = exports.BITS = undefined;
255548
258163
  exports.BITS = 32;
@@ -255588,7 +258203,7 @@ var require_ipv4 = __commonJS((exports) => {
255588
258203
  Object.defineProperty(exports, "__esModule", { value: true });
255589
258204
  exports.Address4 = undefined;
255590
258205
  var common = __importStar(require_common5());
255591
- var constants = __importStar(require_constants16());
258206
+ var constants = __importStar(require_constants17());
255592
258207
  var address_error_1 = require_address_error();
255593
258208
  var isCorrect4 = common.isCorrect(constants.BITS);
255594
258209
 
@@ -255823,7 +258438,7 @@ var require_ipv4 = __commonJS((exports) => {
255823
258438
  });
255824
258439
 
255825
258440
  // node_modules/.bun/ip-address@10.2.0/node_modules/ip-address/dist/v6/constants.js
255826
- var require_constants17 = __commonJS((exports) => {
258441
+ var require_constants18 = __commonJS((exports) => {
255827
258442
  Object.defineProperty(exports, "__esModule", { value: true });
255828
258443
  exports.RE_URL_WITH_PORT = exports.RE_URL = exports.RE_ZONE_STRING = exports.RE_SUBNET_STRING = exports.RE_BAD_ADDRESS = exports.RE_BAD_CHARACTERS = exports.TYPES = exports.SCOPES = exports.GROUPS = exports.BITS = undefined;
255829
258444
  exports.BITS = 128;
@@ -255951,7 +258566,7 @@ var require_regular_expressions = __commonJS((exports) => {
255951
258566
  exports.padGroup = padGroup;
255952
258567
  exports.simpleRegularExpression = simpleRegularExpression;
255953
258568
  exports.possibleElisions = possibleElisions;
255954
- var v6 = __importStar(require_constants17());
258569
+ var v6 = __importStar(require_constants18());
255955
258570
  function groupPossibilities(possibilities) {
255956
258571
  return `(${possibilities.join("|")})`;
255957
258572
  }
@@ -256042,8 +258657,8 @@ var require_ipv6 = __commonJS((exports) => {
256042
258657
  Object.defineProperty(exports, "__esModule", { value: true });
256043
258658
  exports.Address6 = undefined;
256044
258659
  var common = __importStar(require_common5());
256045
- var constants4 = __importStar(require_constants16());
256046
- var constants6 = __importStar(require_constants17());
258660
+ var constants4 = __importStar(require_constants17());
258661
+ var constants6 = __importStar(require_constants18());
256047
258662
  var helpers2 = __importStar(require_helpers2());
256048
258663
  var ipv4_1 = require_ipv4();
256049
258664
  var regular_expressions_1 = require_regular_expressions();
@@ -256815,7 +259430,7 @@ var require_helpers3 = __commonJS((exports) => {
256815
259430
  Object.defineProperty(exports, "__esModule", { value: true });
256816
259431
  exports.ipToBuffer = exports.int32ToIpv4 = exports.ipv4ToInt32 = exports.validateSocksClientChainOptions = exports.validateSocksClientOptions = undefined;
256817
259432
  var util_1 = require_util9();
256818
- var constants_1 = require_constants15();
259433
+ var constants_1 = require_constants16();
256819
259434
  var stream = __require("stream");
256820
259435
  var ip_address_1 = require_ip_address();
256821
259436
  var net2 = __require("net");
@@ -256994,7 +259609,7 @@ var require_socksclient = __commonJS((exports) => {
256994
259609
  var events_1 = __require("events");
256995
259610
  var net2 = __require("net");
256996
259611
  var smart_buffer_1 = require_smartbuffer();
256997
- var constants_1 = require_constants15();
259612
+ var constants_1 = require_constants16();
256998
259613
  var helpers_1 = require_helpers3();
256999
259614
  var receivebuffer_1 = require_receivebuffer();
257000
259615
  var util_1 = require_util9();
@@ -276615,7 +279230,7 @@ var require_ffi_WASM_RELEASE_SYNC = __commonJS((exports) => {
276615
279230
 
276616
279231
  // node_modules/.bun/@tootallnate+quickjs-emscripten@0.23.0/node_modules/@tootallnate/quickjs-emscripten/dist/generated/emscripten-module.WASM_RELEASE_SYNC.js
276617
279232
  var require_emscripten_module_WASM_RELEASE_SYNC = __commonJS((exports, module) => {
276618
- var __dirname = "/Users/lewis/act-runner/work/48768e304e69e0e9/hostexecutor/node_modules/.bun/@tootallnate+quickjs-emscripten@0.23.0/node_modules/@tootallnate/quickjs-emscripten/dist/generated", __filename = "/Users/lewis/act-runner/work/48768e304e69e0e9/hostexecutor/node_modules/.bun/@tootallnate+quickjs-emscripten@0.23.0/node_modules/@tootallnate/quickjs-emscripten/dist/generated/emscripten-module.WASM_RELEASE_SYNC.js";
279233
+ var __dirname = "/Users/lekt9/Projects/unbrowse-ecosystem/unbrowse/node_modules/.bun/@tootallnate+quickjs-emscripten@0.23.0/node_modules/@tootallnate/quickjs-emscripten/dist/generated", __filename = "/Users/lekt9/Projects/unbrowse-ecosystem/unbrowse/node_modules/.bun/@tootallnate+quickjs-emscripten@0.23.0/node_modules/@tootallnate/quickjs-emscripten/dist/generated/emscripten-module.WASM_RELEASE_SYNC.js";
276619
279234
  var QuickJSRaw = (() => {
276620
279235
  var _scriptDir = typeof document !== "undefined" && document.currentScript ? document.currentScript.src : undefined;
276621
279236
  if (typeof __filename !== "undefined")
@@ -283483,7 +286098,7 @@ var require_extract = __commonJS((exports, module) => {
283483
286098
  });
283484
286099
 
283485
286100
  // node_modules/.bun/tar-stream@3.2.0/node_modules/tar-stream/constants.js
283486
- var require_constants18 = __commonJS((exports, module) => {
286101
+ var require_constants19 = __commonJS((exports, module) => {
283487
286102
  var constants = {
283488
286103
  S_IFMT: 61440,
283489
286104
  S_IFDIR: 16384,
@@ -283503,7 +286118,7 @@ var require_constants18 = __commonJS((exports, module) => {
283503
286118
  var require_pack = __commonJS((exports, module) => {
283504
286119
  var { Readable, Writable, getStreamError } = require_streamx();
283505
286120
  var b4a = require_b4a();
283506
- var constants = require_constants18();
286121
+ var constants = require_constants19();
283507
286122
  var headers = require_headers2();
283508
286123
  var DMODE = 493;
283509
286124
  var FMODE = 420;
@@ -285798,7 +288413,8 @@ var init_lib2 = __esm(() => {
285798
288413
  require: (path28) => {
285799
288414
  if (true) {
285800
288415
  return __require(path28);
285801
- }
288416
+ } else
288417
+ ;
285802
288418
  }
285803
288419
  });
285804
288420
  yargsParser.detailed = function(args, opts) {