llonebot-dist 7.1.2 → 7.1.3

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/llonebot.js CHANGED
@@ -7,26 +7,27 @@ import * as fs from "node:fs";
7
7
  import fs__default, { existsSync, mkdirSync, appendFile, statSync, appendFileSync } from "node:fs";
8
8
  import * as os from "node:os";
9
9
  import os__default from "node:os";
10
- import require$$0$4 from "fs";
10
+ import require$$0$3 from "fs";
11
11
  import fsPromise, { unlink, stat, access, copyFile, writeFile, readFile } from "node:fs/promises";
12
12
  import crypto$1, { randomUUID, randomBytes, createHash } from "node:crypto";
13
13
  import require$$4$1, { gzipSync, gunzipSync, deflateSync, inflateSync } from "node:zlib";
14
14
  import path$1 from "path";
15
15
  import require$$1$2 from "util";
16
16
  import require$$2$2 from "events";
17
- import require$$0$5 from "child_process";
17
+ import require$$0$4 from "child_process";
18
18
  import require$$1$1 from "os";
19
19
  import require$$2$1 from "stream";
20
20
  import { WebSocketServer, WebSocket as WebSocket$2 } from "ws";
21
- import require$$0$7 from "debug";
22
- import require$$0$6 from "buffer";
21
+ import require$$0$6 from "debug";
22
+ import require$$0$5 from "buffer";
23
23
  import require$$1$3 from "string_decoder";
24
24
  import require$$2$3 from "object-inspect";
25
25
  import require$$1$5 from "node:events";
26
- import require$$0$8, { fileURLToPath as fileURLToPath$1 } from "url";
26
+ import require$$0$7, { fileURLToPath as fileURLToPath$1 } from "url";
27
27
  import require$$2$4 from "node:http";
28
- import require$$0$9 from "crypto";
29
- import require$$6$1 from "querystring";
28
+ import require$$0$8 from "crypto";
29
+ import require$$6$1 from "node:querystring";
30
+ import require$$7$1 from "node:buffer";
30
31
  import require$$1$4 from "node:net";
31
32
  import require$$8 from "ms";
32
33
  import * as fileType from "file-type";
@@ -1233,11 +1234,12 @@ var __name$8 = (target, value) => __defProp$9(target, "name", { value, configura
1233
1234
  var __commonJS$1 = (cb, mod) => function __require() {
1234
1235
  return mod || (0, cb[__getOwnPropNames$1(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
1235
1236
  };
1236
- var require_src = __commonJS$1({
1237
+ var require_index$1 = __commonJS$1({
1237
1238
  "src/index.ts"(exports$1, module) {
1238
1239
  var kSchema = Symbol.for("schemastery");
1239
1240
  var kValidationError = Symbol.for("ValidationError");
1240
1241
  globalThis.__schemastery_index__ ??= 0;
1242
+ globalThis.__schemastery_refs__ = void 0;
1241
1243
  var ValidationError = class extends TypeError {
1242
1244
  constructor(message, options) {
1243
1245
  let prefix = "$";
@@ -1270,16 +1272,16 @@ var require_src = __commonJS$1({
1270
1272
  return Schema.resolve(data, schema, options2)[0];
1271
1273
  }, "schema");
1272
1274
  if (options.refs) {
1273
- const refs2 = valueMap(options.refs, (options2) => new Schema(options2));
1274
- const getRef = /* @__PURE__ */ __name$8((uid) => refs2[uid], "getRef");
1275
- for (const key2 in refs2) {
1276
- const options2 = refs2[key2];
1275
+ const refs = valueMap(options.refs, (options2) => new Schema(options2));
1276
+ const getRef = /* @__PURE__ */ __name$8((uid) => refs[uid], "getRef");
1277
+ for (const key2 in refs) {
1278
+ const options2 = refs[key2];
1277
1279
  options2.sKey = getRef(options2.sKey);
1278
1280
  options2.inner = getRef(options2.inner);
1279
1281
  options2.list = options2.list && options2.list.map(getRef);
1280
1282
  options2.dict = options2.dict && valueMap(options2.dict, getRef);
1281
1283
  }
1282
- return refs2[options.uid];
1284
+ return refs[options.uid];
1283
1285
  }
1284
1286
  Object.assign(schema, options);
1285
1287
  if (typeof schema.callback === "string") {
@@ -1297,16 +1299,15 @@ var require_src = __commonJS$1({
1297
1299
  Schema.prototype = Object.create(Function.prototype);
1298
1300
  Schema.prototype[kSchema] = true;
1299
1301
  Schema.ValidationError = ValidationError;
1300
- var refs;
1301
1302
  Schema.prototype.toJSON = /* @__PURE__ */ __name$8(function toJSON() {
1302
- if (refs) {
1303
- refs[this.uid] ??= JSON.parse(JSON.stringify({ ...this }));
1303
+ if (globalThis.__schemastery_refs__) {
1304
+ globalThis.__schemastery_refs__[this.uid] ??= JSON.parse(JSON.stringify({ ...this }));
1304
1305
  return this.uid;
1305
1306
  }
1306
- refs = { [this.uid]: { ...this } };
1307
- refs[this.uid] = JSON.parse(JSON.stringify({ ...this }));
1308
- const result = { uid: this.uid, refs };
1309
- refs = void 0;
1307
+ globalThis.__schemastery_refs__ = { [this.uid]: { ...this } };
1308
+ globalThis.__schemastery_refs__[this.uid] = JSON.parse(JSON.stringify({ ...this }));
1309
+ const result = { uid: this.uid, refs: globalThis.__schemastery_refs__ };
1310
+ globalThis.__schemastery_refs__ = void 0;
1310
1311
  return result;
1311
1312
  }, "toJSON");
1312
1313
  Schema.prototype.set = /* @__PURE__ */ __name$8(function set2(key2, value) {
@@ -1651,9 +1652,21 @@ var require_src = __commonJS$1({
1651
1652
  if (typeof data === "function") return [data];
1652
1653
  throw new ValidationError(`expected function but got ${data}`, options);
1653
1654
  });
1654
- Schema.extend("is", (data, { callback }, options) => {
1655
- if (data instanceof callback) return [data];
1656
- throw new ValidationError(`expected ${callback.name} but got ${data}`, options);
1655
+ Schema.extend("is", (data, { constructor }, options) => {
1656
+ if (typeof constructor === "function") {
1657
+ if (data instanceof constructor) return [data];
1658
+ throw new ValidationError(`expected ${constructor.name} but got ${data}`, options);
1659
+ } else {
1660
+ if (isNullable(data)) {
1661
+ throw new ValidationError(`expected ${constructor} but got ${data}`, options);
1662
+ }
1663
+ let prototype = Object.getPrototypeOf(data);
1664
+ while (prototype) {
1665
+ if (prototype.constructor?.name === constructor) return [data];
1666
+ prototype = Object.getPrototypeOf(prototype);
1667
+ }
1668
+ throw new ValidationError(`expected ${constructor} but got ${data}`, options);
1669
+ }
1657
1670
  });
1658
1671
  function property(data, key2, schema, options) {
1659
1672
  try {
@@ -1728,6 +1741,7 @@ var require_src = __commonJS$1({
1728
1741
  throw new ValidationError(`expected ${toString()} but got ${JSON.stringify(data)}`, options);
1729
1742
  });
1730
1743
  Schema.extend("intersect", (data, { list, toString }, options, strict) => {
1744
+ if (!list.length) return [data];
1731
1745
  let result;
1732
1746
  for (const inner of list) {
1733
1747
  const value = Schema.resolve(data, inner, options, true)[0];
@@ -1782,8 +1796,15 @@ var require_src = __commonJS$1({
1782
1796
  break;
1783
1797
  }
1784
1798
  case "callback": {
1785
- schema.callback = args[index2];
1786
- schema.callback["toJSON"] ||= () => schema.callback.toString();
1799
+ const callback = schema.callback = args[index2];
1800
+ callback["toJSON"] ||= () => callback.toString();
1801
+ break;
1802
+ }
1803
+ case "constructor": {
1804
+ const constructor = schema.constructor = args[index2];
1805
+ if (typeof constructor === "function") {
1806
+ constructor["toJSON"] ||= () => constructor["name"];
1807
+ }
1787
1808
  break;
1788
1809
  }
1789
1810
  default:
@@ -1802,7 +1823,13 @@ var require_src = __commonJS$1({
1802
1823
  });
1803
1824
  }
1804
1825
  __name$8(defineMethod, "defineMethod");
1805
- defineMethod("is", ["callback"], ({ callback }) => callback.name);
1826
+ defineMethod("is", ["constructor"], ({ constructor }) => {
1827
+ if (typeof constructor === "function") {
1828
+ return constructor.name;
1829
+ } else {
1830
+ return constructor;
1831
+ }
1832
+ });
1806
1833
  defineMethod("any", [], () => "any");
1807
1834
  defineMethod("never", [], () => "never");
1808
1835
  defineMethod("const", ["value"], ({ value }) => typeof value === "string" ? JSON.stringify(value) : value);
@@ -1831,7 +1858,7 @@ var require_src = __commonJS$1({
1831
1858
  module.exports = Schema;
1832
1859
  }
1833
1860
  });
1834
- const z$1 = require_src();
1861
+ const z$1 = require_index$1();
1835
1862
  var __defProp$8 = Object.defineProperty;
1836
1863
  var __name$7 = (target, value) => __defProp$8(target, "name", { value, configurable: true });
1837
1864
  var kSchemaOrder = Symbol("cordis.schema.order");
@@ -3764,7 +3791,7 @@ class PMHQ {
3764
3791
  reject(new Error("pmhq ws send: wait result timeout"));
3765
3792
  this.removeResListener(listenerId);
3766
3793
  }, timeout2);
3767
- const listenerId = this.addResListener((res) => {
3794
+ const listenerId = this.addResListener(((res) => {
3768
3795
  if (!res.data) {
3769
3796
  console.error(`PMHQ WS send error: payload ${JSON.stringify(data)}, response ${JSON.stringify(res)}`);
3770
3797
  }
@@ -3773,7 +3800,7 @@ class PMHQ {
3773
3800
  clearTimeout(timeoutId);
3774
3801
  this.removeResListener(listenerId);
3775
3802
  }
3776
- });
3803
+ }));
3777
3804
  });
3778
3805
  this.ws.send(payload);
3779
3806
  return p;
@@ -6039,7 +6066,7 @@ function requireWindows() {
6039
6066
  hasRequiredWindows = 1;
6040
6067
  windows = isexe;
6041
6068
  isexe.sync = sync;
6042
- var fs2 = require$$0$4;
6069
+ var fs2 = require$$0$3;
6043
6070
  function checkPathExt(path2, options) {
6044
6071
  var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
6045
6072
  if (!pathext) {
@@ -6080,7 +6107,7 @@ function requireMode() {
6080
6107
  hasRequiredMode = 1;
6081
6108
  mode = isexe;
6082
6109
  isexe.sync = sync;
6083
- var fs2 = require$$0$4;
6110
+ var fs2 = require$$0$3;
6084
6111
  function isexe(path2, options, cb) {
6085
6112
  fs2.stat(path2, function(er, stat2) {
6086
6113
  cb(er, er ? false : checkStat(stat2, options));
@@ -6280,7 +6307,7 @@ var hasRequiredUtils$3;
6280
6307
  function requireUtils$3() {
6281
6308
  if (hasRequiredUtils$3) return utils$3.exports;
6282
6309
  hasRequiredUtils$3 = 1;
6283
- require$$0$5.exec;
6310
+ require$$0$4.exec;
6284
6311
  var isWindows = require$$1$1.platform().match(/win(32|64)/);
6285
6312
  var which = requireWhich();
6286
6313
  var nlRegexp = /\r\n|\r|\n/g;
@@ -7998,7 +8025,7 @@ var hasRequiredProcessor;
7998
8025
  function requireProcessor() {
7999
8026
  if (hasRequiredProcessor) return processor;
8000
8027
  hasRequiredProcessor = 1;
8001
- var spawn = require$$0$5.spawn;
8028
+ var spawn = require$$0$4.spawn;
8002
8029
  var async2 = requireAsync();
8003
8030
  var utils2 = requireUtils$3();
8004
8031
  function runFfprobe(command) {
@@ -8394,7 +8421,7 @@ var hasRequiredCapabilities;
8394
8421
  function requireCapabilities() {
8395
8422
  if (hasRequiredCapabilities) return capabilities;
8396
8423
  hasRequiredCapabilities = 1;
8397
- var fs2 = require$$0$4;
8424
+ var fs2 = require$$0$3;
8398
8425
  var path2 = path$1;
8399
8426
  var async2 = requireAsync();
8400
8427
  var utils2 = requireUtils$3();
@@ -8807,7 +8834,7 @@ var hasRequiredFfprobe;
8807
8834
  function requireFfprobe() {
8808
8835
  if (hasRequiredFfprobe) return ffprobe;
8809
8836
  hasRequiredFfprobe = 1;
8810
- var spawn = require$$0$5.spawn;
8837
+ var spawn = require$$0$4.spawn;
8811
8838
  function legacyTag(key2) {
8812
8839
  return key2.match(/^TAG:/);
8813
8840
  }
@@ -8993,7 +9020,7 @@ var hasRequiredRecipes;
8993
9020
  function requireRecipes() {
8994
9021
  if (hasRequiredRecipes) return recipes;
8995
9022
  hasRequiredRecipes = 1;
8996
- var fs2 = require$$0$4;
9023
+ var fs2 = require$$0$3;
8997
9024
  var path2 = path$1;
8998
9025
  var PassThrough = require$$2$1.PassThrough;
8999
9026
  var async2 = requireAsync();
@@ -10690,7 +10717,7 @@ class OB11HeartbeatEvent extends OB11BaseMetaEvent {
10690
10717
  };
10691
10718
  }
10692
10719
  }
10693
- const version$1 = "7.1.2";
10720
+ const version$1 = "7.1.3";
10694
10721
  class OB11WebSocket {
10695
10722
  constructor(ctx, config2) {
10696
10723
  this.ctx = ctx;
@@ -11407,7 +11434,7 @@ function requireSetprototypeof() {
11407
11434
  }
11408
11435
  return setprototypeof;
11409
11436
  }
11410
- const require$$0$3 = {
11437
+ const require$$0$2 = {
11411
11438
  "100": "Continue",
11412
11439
  "101": "Switching Protocols",
11413
11440
  "102": "Processing",
@@ -11472,13 +11499,13 @@ const require$$0$3 = {
11472
11499
  "510": "Not Extended",
11473
11500
  "511": "Network Authentication Required"
11474
11501
  };
11475
- var statuses$1;
11476
- var hasRequiredStatuses$1;
11477
- function requireStatuses$1() {
11478
- if (hasRequiredStatuses$1) return statuses$1;
11479
- hasRequiredStatuses$1 = 1;
11480
- var codes = require$$0$3;
11481
- statuses$1 = status;
11502
+ var statuses;
11503
+ var hasRequiredStatuses;
11504
+ function requireStatuses() {
11505
+ if (hasRequiredStatuses) return statuses;
11506
+ hasRequiredStatuses = 1;
11507
+ var codes = require$$0$2;
11508
+ statuses = status;
11482
11509
  status.message = codes;
11483
11510
  status.code = createMessageToStatusCodeMap(codes);
11484
11511
  status.codes = createStatusCodeList(codes);
@@ -11541,7 +11568,7 @@ function requireStatuses$1() {
11541
11568
  }
11542
11569
  return getStatusCode(code);
11543
11570
  }
11544
- return statuses$1;
11571
+ return statuses;
11545
11572
  }
11546
11573
  var inherits_browser = { exports: {} };
11547
11574
  var hasRequiredInherits_browser;
@@ -11596,7 +11623,7 @@ function requireHttpErrors() {
11596
11623
  (function(module) {
11597
11624
  var deprecate = requireBrowser()("http-errors");
11598
11625
  var setPrototypeOf = requireSetprototypeof();
11599
- var statuses2 = requireStatuses$1();
11626
+ var statuses2 = requireStatuses();
11600
11627
  var inherits = requireInherits_browser();
11601
11628
  var toIdentifier = requireToidentifier();
11602
11629
  module.exports = createError;
@@ -11749,171 +11776,11 @@ function requireHttpErrors() {
11749
11776
  });
11750
11777
  }
11751
11778
  function toClassName(name) {
11752
- return name.substr(-5) !== "Error" ? name + "Error" : name;
11779
+ return name.slice(-5) === "Error" ? name : name + "Error";
11753
11780
  }
11754
11781
  })(httpErrors);
11755
11782
  return httpErrors.exports;
11756
11783
  }
11757
- var onFinished = { exports: {} };
11758
- var eeFirst;
11759
- var hasRequiredEeFirst;
11760
- function requireEeFirst() {
11761
- if (hasRequiredEeFirst) return eeFirst;
11762
- hasRequiredEeFirst = 1;
11763
- eeFirst = first;
11764
- function first(stuff, done) {
11765
- if (!Array.isArray(stuff))
11766
- throw new TypeError("arg must be an array of [ee, events...] arrays");
11767
- var cleanups = [];
11768
- for (var i = 0; i < stuff.length; i++) {
11769
- var arr = stuff[i];
11770
- if (!Array.isArray(arr) || arr.length < 2)
11771
- throw new TypeError("each array member must be [ee, events...]");
11772
- var ee = arr[0];
11773
- for (var j = 1; j < arr.length; j++) {
11774
- var event = arr[j];
11775
- var fn = listener(event, callback);
11776
- ee.on(event, fn);
11777
- cleanups.push({
11778
- ee,
11779
- event,
11780
- fn
11781
- });
11782
- }
11783
- }
11784
- function callback() {
11785
- cleanup();
11786
- done.apply(null, arguments);
11787
- }
11788
- function cleanup() {
11789
- var x;
11790
- for (var i2 = 0; i2 < cleanups.length; i2++) {
11791
- x = cleanups[i2];
11792
- x.ee.removeListener(x.event, x.fn);
11793
- }
11794
- }
11795
- function thunk(fn2) {
11796
- done = fn2;
11797
- }
11798
- thunk.cancel = cleanup;
11799
- return thunk;
11800
- }
11801
- function listener(event, done) {
11802
- return function onevent(arg1) {
11803
- var args = new Array(arguments.length);
11804
- var ee = this;
11805
- var err = event === "error" ? arg1 : null;
11806
- for (var i = 0; i < args.length; i++) {
11807
- args[i] = arguments[i];
11808
- }
11809
- done(err, ee, event, args);
11810
- };
11811
- }
11812
- return eeFirst;
11813
- }
11814
- var hasRequiredOnFinished;
11815
- function requireOnFinished() {
11816
- if (hasRequiredOnFinished) return onFinished.exports;
11817
- hasRequiredOnFinished = 1;
11818
- onFinished.exports = onFinished$1;
11819
- onFinished.exports.isFinished = isFinished;
11820
- var asyncHooks = tryRequireAsyncHooks();
11821
- var first = requireEeFirst();
11822
- var defer = typeof setImmediate === "function" ? setImmediate : function(fn) {
11823
- process.nextTick(fn.bind.apply(fn, arguments));
11824
- };
11825
- function onFinished$1(msg, listener) {
11826
- if (isFinished(msg) !== false) {
11827
- defer(listener, null, msg);
11828
- return msg;
11829
- }
11830
- attachListener(msg, wrap(listener));
11831
- return msg;
11832
- }
11833
- function isFinished(msg) {
11834
- var socket = msg.socket;
11835
- if (typeof msg.finished === "boolean") {
11836
- return Boolean(msg.finished || socket && !socket.writable);
11837
- }
11838
- if (typeof msg.complete === "boolean") {
11839
- return Boolean(msg.upgrade || !socket || !socket.readable || msg.complete && !msg.readable);
11840
- }
11841
- return void 0;
11842
- }
11843
- function attachFinishedListener(msg, callback) {
11844
- var eeMsg;
11845
- var eeSocket;
11846
- var finished = false;
11847
- function onFinish(error2) {
11848
- eeMsg.cancel();
11849
- eeSocket.cancel();
11850
- finished = true;
11851
- callback(error2);
11852
- }
11853
- eeMsg = eeSocket = first([[msg, "end", "finish"]], onFinish);
11854
- function onSocket(socket) {
11855
- msg.removeListener("socket", onSocket);
11856
- if (finished) return;
11857
- if (eeMsg !== eeSocket) return;
11858
- eeSocket = first([[socket, "error", "close"]], onFinish);
11859
- }
11860
- if (msg.socket) {
11861
- onSocket(msg.socket);
11862
- return;
11863
- }
11864
- msg.on("socket", onSocket);
11865
- if (msg.socket === void 0) {
11866
- patchAssignSocket(msg, onSocket);
11867
- }
11868
- }
11869
- function attachListener(msg, listener) {
11870
- var attached = msg.__onFinished;
11871
- if (!attached || !attached.queue) {
11872
- attached = msg.__onFinished = createListener(msg);
11873
- attachFinishedListener(msg, attached);
11874
- }
11875
- attached.queue.push(listener);
11876
- }
11877
- function createListener(msg) {
11878
- function listener(err) {
11879
- if (msg.__onFinished === listener) msg.__onFinished = null;
11880
- if (!listener.queue) return;
11881
- var queue2 = listener.queue;
11882
- listener.queue = null;
11883
- for (var i = 0; i < queue2.length; i++) {
11884
- queue2[i](err, msg);
11885
- }
11886
- }
11887
- listener.queue = [];
11888
- return listener;
11889
- }
11890
- function patchAssignSocket(res, callback) {
11891
- var assignSocket = res.assignSocket;
11892
- if (typeof assignSocket !== "function") return;
11893
- res.assignSocket = function _assignSocket(socket) {
11894
- assignSocket.call(this, socket);
11895
- callback(socket);
11896
- };
11897
- }
11898
- function tryRequireAsyncHooks() {
11899
- try {
11900
- return require("async_hooks");
11901
- } catch (e) {
11902
- return {};
11903
- }
11904
- }
11905
- function wrap(fn) {
11906
- var res;
11907
- if (asyncHooks.AsyncResource) {
11908
- res = new asyncHooks.AsyncResource(fn.name || "bound-anonymous-fn");
11909
- }
11910
- if (!res || !res.runInAsyncScope) {
11911
- return fn;
11912
- }
11913
- return res.runInAsyncScope.bind(res, fn, null);
11914
- }
11915
- return onFinished.exports;
11916
- }
11917
11784
  var bytes = { exports: {} };
11918
11785
  var hasRequiredBytes;
11919
11786
  function requireBytes() {
@@ -12009,7 +11876,7 @@ var hasRequiredSafer;
12009
11876
  function requireSafer() {
12010
11877
  if (hasRequiredSafer) return safer_1;
12011
11878
  hasRequiredSafer = 1;
12012
- var buffer2 = require$$0$6;
11879
+ var buffer2 = require$$0$5;
12013
11880
  var Buffer2 = buffer2.Buffer;
12014
11881
  var safer = {};
12015
11882
  var key2;
@@ -12101,12 +11968,14 @@ function requireBomHandling() {
12101
11968
  }
12102
11969
  StripBOMWrapper.prototype.write = function(buf) {
12103
11970
  var res = this.decoder.write(buf);
12104
- if (this.pass || !res)
11971
+ if (this.pass || !res) {
12105
11972
  return res;
11973
+ }
12106
11974
  if (res[0] === BOMChar) {
12107
11975
  res = res.slice(1);
12108
- if (typeof this.options.stripBOM === "function")
11976
+ if (typeof this.options.stripBOM === "function") {
12109
11977
  this.options.stripBOM();
11978
+ }
12110
11979
  }
12111
11980
  this.pass = true;
12112
11981
  return res;
@@ -12116,6 +11985,22 @@ function requireBomHandling() {
12116
11985
  };
12117
11986
  return bomHandling;
12118
11987
  }
11988
+ var mergeExports;
11989
+ var hasRequiredMergeExports;
11990
+ function requireMergeExports() {
11991
+ if (hasRequiredMergeExports) return mergeExports;
11992
+ hasRequiredMergeExports = 1;
11993
+ var hasOwn = typeof Object.hasOwn === "undefined" ? Function.call.bind(Object.prototype.hasOwnProperty) : Object.hasOwn;
11994
+ function mergeModules(target, module) {
11995
+ for (var key2 in module) {
11996
+ if (hasOwn(module, key2)) {
11997
+ target[key2] = module[key2];
11998
+ }
11999
+ }
12000
+ }
12001
+ mergeExports = mergeModules;
12002
+ return mergeExports;
12003
+ }
12119
12004
  var encodings = {};
12120
12005
  var internal;
12121
12006
  var hasRequiredInternal;
@@ -12139,9 +12024,11 @@ function requireInternal() {
12139
12024
  function InternalCodec(codecOptions, iconv) {
12140
12025
  this.enc = codecOptions.encodingName;
12141
12026
  this.bomAware = codecOptions.bomAware;
12142
- if (this.enc === "base64")
12027
+ if (this.enc === "base64") {
12143
12028
  this.encoder = InternalEncoderBase64;
12144
- else if (this.enc === "cesu8") {
12029
+ } else if (this.enc === "utf8") {
12030
+ this.encoder = InternalEncoderUtf8;
12031
+ } else if (this.enc === "cesu8") {
12145
12032
  this.enc = "utf8";
12146
12033
  this.encoder = InternalEncoderCesu8;
12147
12034
  if (Buffer2.from("eda0bdedb2a9", "hex").toString() !== "💩") {
@@ -12153,9 +12040,6 @@ function requireInternal() {
12153
12040
  InternalCodec.prototype.encoder = InternalEncoder;
12154
12041
  InternalCodec.prototype.decoder = InternalDecoder;
12155
12042
  var StringDecoder = require$$1$3.StringDecoder;
12156
- if (!StringDecoder.prototype.end)
12157
- StringDecoder.prototype.end = function() {
12158
- };
12159
12043
  function InternalDecoder(options, codec2) {
12160
12044
  this.decoder = new StringDecoder(codec2.enc);
12161
12045
  }
@@ -12192,12 +12076,13 @@ function requireInternal() {
12192
12076
  function InternalEncoderCesu8(options, codec2) {
12193
12077
  }
12194
12078
  InternalEncoderCesu8.prototype.write = function(str) {
12195
- var buf = Buffer2.alloc(str.length * 3), bufIdx = 0;
12079
+ var buf = Buffer2.alloc(str.length * 3);
12080
+ var bufIdx = 0;
12196
12081
  for (var i = 0; i < str.length; i++) {
12197
12082
  var charCode = str.charCodeAt(i);
12198
- if (charCode < 128)
12083
+ if (charCode < 128) {
12199
12084
  buf[bufIdx++] = charCode;
12200
- else if (charCode < 2048) {
12085
+ } else if (charCode < 2048) {
12201
12086
  buf[bufIdx++] = 192 + (charCode >>> 6);
12202
12087
  buf[bufIdx++] = 128 + (charCode & 63);
12203
12088
  } else {
@@ -12217,7 +12102,10 @@ function requireInternal() {
12217
12102
  this.defaultCharUnicode = codec2.defaultCharUnicode;
12218
12103
  }
12219
12104
  InternalDecoderCesu8.prototype.write = function(buf) {
12220
- var acc = this.acc, contBytes = this.contBytes, accBytes = this.accBytes, res = "";
12105
+ var acc = this.acc;
12106
+ var contBytes = this.contBytes;
12107
+ var accBytes = this.accBytes;
12108
+ var res = "";
12221
12109
  for (var i = 0; i < buf.length; i++) {
12222
12110
  var curByte = buf[i];
12223
12111
  if ((curByte & 192) !== 128) {
@@ -12244,12 +12132,13 @@ function requireInternal() {
12244
12132
  contBytes--;
12245
12133
  accBytes++;
12246
12134
  if (contBytes === 0) {
12247
- if (accBytes === 2 && acc < 128 && acc > 0)
12135
+ if (accBytes === 2 && acc < 128 && acc > 0) {
12248
12136
  res += this.defaultCharUnicode;
12249
- else if (accBytes === 3 && acc < 2048)
12137
+ } else if (accBytes === 3 && acc < 2048) {
12250
12138
  res += this.defaultCharUnicode;
12251
- else
12139
+ } else {
12252
12140
  res += String.fromCharCode(acc);
12141
+ }
12253
12142
  }
12254
12143
  } else {
12255
12144
  res += this.defaultCharUnicode;
@@ -12263,10 +12152,35 @@ function requireInternal() {
12263
12152
  };
12264
12153
  InternalDecoderCesu8.prototype.end = function() {
12265
12154
  var res = 0;
12266
- if (this.contBytes > 0)
12155
+ if (this.contBytes > 0) {
12267
12156
  res += this.defaultCharUnicode;
12157
+ }
12268
12158
  return res;
12269
12159
  };
12160
+ function InternalEncoderUtf8(options, codec2) {
12161
+ this.highSurrogate = "";
12162
+ }
12163
+ InternalEncoderUtf8.prototype.write = function(str) {
12164
+ if (this.highSurrogate) {
12165
+ str = this.highSurrogate + str;
12166
+ this.highSurrogate = "";
12167
+ }
12168
+ if (str.length > 0) {
12169
+ var charCode = str.charCodeAt(str.length - 1);
12170
+ if (charCode >= 55296 && charCode < 56320) {
12171
+ this.highSurrogate = str[str.length - 1];
12172
+ str = str.slice(0, str.length - 1);
12173
+ }
12174
+ }
12175
+ return Buffer2.from(str, this.enc);
12176
+ };
12177
+ InternalEncoderUtf8.prototype.end = function() {
12178
+ if (this.highSurrogate) {
12179
+ var str = this.highSurrogate;
12180
+ this.highSurrogate = "";
12181
+ return Buffer2.from(str, this.enc);
12182
+ }
12183
+ };
12270
12184
  return internal;
12271
12185
  }
12272
12186
  var utf32 = {};
@@ -12298,8 +12212,8 @@ function requireUtf32() {
12298
12212
  var offset = 0;
12299
12213
  for (var i = 0; i < src.length; i += 2) {
12300
12214
  var code = src.readUInt16LE(i);
12301
- var isHighSurrogate = 55296 <= code && code < 56320;
12302
- var isLowSurrogate = 56320 <= code && code < 57344;
12215
+ var isHighSurrogate = code >= 55296 && code < 56320;
12216
+ var isLowSurrogate = code >= 56320 && code < 57344;
12303
12217
  if (this.highSurrogate) {
12304
12218
  if (isHighSurrogate || !isLowSurrogate) {
12305
12219
  write32.call(dst, this.highSurrogate, offset);
@@ -12312,26 +12226,29 @@ function requireUtf32() {
12312
12226
  continue;
12313
12227
  }
12314
12228
  }
12315
- if (isHighSurrogate)
12229
+ if (isHighSurrogate) {
12316
12230
  this.highSurrogate = code;
12317
- else {
12231
+ } else {
12318
12232
  write32.call(dst, code, offset);
12319
12233
  offset += 4;
12320
12234
  this.highSurrogate = 0;
12321
12235
  }
12322
12236
  }
12323
- if (offset < dst.length)
12237
+ if (offset < dst.length) {
12324
12238
  dst = dst.slice(0, offset);
12239
+ }
12325
12240
  return dst;
12326
12241
  };
12327
12242
  Utf32Encoder.prototype.end = function() {
12328
- if (!this.highSurrogate)
12243
+ if (!this.highSurrogate) {
12329
12244
  return;
12245
+ }
12330
12246
  var buf = Buffer2.alloc(4);
12331
- if (this.isLE)
12247
+ if (this.isLE) {
12332
12248
  buf.writeUInt32LE(this.highSurrogate, 0);
12333
- else
12249
+ } else {
12334
12250
  buf.writeUInt32BE(this.highSurrogate, 0);
12251
+ }
12335
12252
  this.highSurrogate = 0;
12336
12253
  return buf;
12337
12254
  };
@@ -12341,8 +12258,9 @@ function requireUtf32() {
12341
12258
  this.overflow = [];
12342
12259
  }
12343
12260
  Utf32Decoder.prototype.write = function(src) {
12344
- if (src.length === 0)
12261
+ if (src.length === 0) {
12345
12262
  return "";
12263
+ }
12346
12264
  var i = 0;
12347
12265
  var codepoint = 0;
12348
12266
  var dst = Buffer2.alloc(src.length + 4);
@@ -12351,8 +12269,9 @@ function requireUtf32() {
12351
12269
  var overflow = this.overflow;
12352
12270
  var badChar = this.badChar;
12353
12271
  if (overflow.length > 0) {
12354
- for (; i < src.length && overflow.length < 4; i++)
12272
+ for (; i < src.length && overflow.length < 4; i++) {
12355
12273
  overflow.push(src[i]);
12274
+ }
12356
12275
  if (overflow.length === 4) {
12357
12276
  if (isLE) {
12358
12277
  codepoint = overflow[i] | overflow[i + 1] << 8 | overflow[i + 2] << 16 | overflow[i + 3] << 24;
@@ -12403,8 +12322,9 @@ function requireUtf32() {
12403
12322
  Utf32AutoCodec.prototype.decoder = Utf32AutoDecoder;
12404
12323
  function Utf32AutoEncoder(options, codec2) {
12405
12324
  options = options || {};
12406
- if (options.addBOM === void 0)
12325
+ if (options.addBOM === void 0) {
12407
12326
  options.addBOM = true;
12327
+ }
12408
12328
  this.encoder = codec2.iconv.getEncoder(options.defaultEncoding || "utf-32le", options);
12409
12329
  }
12410
12330
  Utf32AutoEncoder.prototype.write = function(str) {
@@ -12424,13 +12344,15 @@ function requireUtf32() {
12424
12344
  if (!this.decoder) {
12425
12345
  this.initialBufs.push(buf);
12426
12346
  this.initialBufsLen += buf.length;
12427
- if (this.initialBufsLen < 32)
12347
+ if (this.initialBufsLen < 32) {
12428
12348
  return "";
12349
+ }
12429
12350
  var encoding2 = detectEncoding(this.initialBufs, this.options.defaultEncoding);
12430
12351
  this.decoder = this.iconv.getDecoder(encoding2, this.options);
12431
12352
  var resStr = "";
12432
- for (var i = 0; i < this.initialBufs.length; i++)
12353
+ for (var i = 0; i < this.initialBufs.length; i++) {
12433
12354
  resStr += this.decoder.write(this.initialBufs[i]);
12355
+ }
12434
12356
  this.initialBufs.length = this.initialBufsLen = 0;
12435
12357
  return resStr;
12436
12358
  }
@@ -12441,11 +12363,13 @@ function requireUtf32() {
12441
12363
  var encoding2 = detectEncoding(this.initialBufs, this.options.defaultEncoding);
12442
12364
  this.decoder = this.iconv.getDecoder(encoding2, this.options);
12443
12365
  var resStr = "";
12444
- for (var i = 0; i < this.initialBufs.length; i++)
12366
+ for (var i = 0; i < this.initialBufs.length; i++) {
12445
12367
  resStr += this.decoder.write(this.initialBufs[i]);
12368
+ }
12446
12369
  var trail = this.decoder.end();
12447
- if (trail)
12370
+ if (trail) {
12448
12371
  resStr += trail;
12372
+ }
12449
12373
  this.initialBufs.length = this.initialBufsLen = 0;
12450
12374
  return resStr;
12451
12375
  }
@@ -12454,9 +12378,11 @@ function requireUtf32() {
12454
12378
  function detectEncoding(bufs, defaultEncoding) {
12455
12379
  var b = [];
12456
12380
  var charsProcessed = 0;
12457
- var invalidLE = 0, invalidBE = 0;
12458
- var bmpCharsLE = 0, bmpCharsBE = 0;
12459
- outer_loop:
12381
+ var invalidLE = 0;
12382
+ var invalidBE = 0;
12383
+ var bmpCharsLE = 0;
12384
+ var bmpCharsBE = 0;
12385
+ outerLoop:
12460
12386
  for (var i = 0; i < bufs.length; i++) {
12461
12387
  var buf = bufs[i];
12462
12388
  for (var j = 0; j < buf.length; j++) {
@@ -12477,7 +12403,7 @@ function requireUtf32() {
12477
12403
  b.length = 0;
12478
12404
  charsProcessed++;
12479
12405
  if (charsProcessed >= 100) {
12480
- break outer_loop;
12406
+ break outerLoop;
12481
12407
  }
12482
12408
  }
12483
12409
  }
@@ -12517,9 +12443,12 @@ function requireUtf16() {
12517
12443
  this.overflowByte = -1;
12518
12444
  }
12519
12445
  Utf16BEDecoder.prototype.write = function(buf) {
12520
- if (buf.length == 0)
12446
+ if (buf.length == 0) {
12521
12447
  return "";
12522
- var buf2 = Buffer2.alloc(buf.length + 1), i = 0, j = 0;
12448
+ }
12449
+ var buf2 = Buffer2.alloc(buf.length + 1);
12450
+ var i = 0;
12451
+ var j = 0;
12523
12452
  if (this.overflowByte !== -1) {
12524
12453
  buf2[0] = buf[0];
12525
12454
  buf2[1] = this.overflowByte;
@@ -12544,8 +12473,9 @@ function requireUtf16() {
12544
12473
  Utf16Codec.prototype.decoder = Utf16Decoder;
12545
12474
  function Utf16Encoder(options, codec2) {
12546
12475
  options = options || {};
12547
- if (options.addBOM === void 0)
12476
+ if (options.addBOM === void 0) {
12548
12477
  options.addBOM = true;
12478
+ }
12549
12479
  this.encoder = codec2.iconv.getEncoder("utf-16le", options);
12550
12480
  }
12551
12481
  Utf16Encoder.prototype.write = function(str) {
@@ -12565,13 +12495,15 @@ function requireUtf16() {
12565
12495
  if (!this.decoder) {
12566
12496
  this.initialBufs.push(buf);
12567
12497
  this.initialBufsLen += buf.length;
12568
- if (this.initialBufsLen < 16)
12498
+ if (this.initialBufsLen < 16) {
12569
12499
  return "";
12500
+ }
12570
12501
  var encoding2 = detectEncoding(this.initialBufs, this.options.defaultEncoding);
12571
12502
  this.decoder = this.iconv.getDecoder(encoding2, this.options);
12572
12503
  var resStr = "";
12573
- for (var i = 0; i < this.initialBufs.length; i++)
12504
+ for (var i = 0; i < this.initialBufs.length; i++) {
12574
12505
  resStr += this.decoder.write(this.initialBufs[i]);
12506
+ }
12575
12507
  this.initialBufs.length = this.initialBufsLen = 0;
12576
12508
  return resStr;
12577
12509
  }
@@ -12582,11 +12514,13 @@ function requireUtf16() {
12582
12514
  var encoding2 = detectEncoding(this.initialBufs, this.options.defaultEncoding);
12583
12515
  this.decoder = this.iconv.getDecoder(encoding2, this.options);
12584
12516
  var resStr = "";
12585
- for (var i = 0; i < this.initialBufs.length; i++)
12517
+ for (var i = 0; i < this.initialBufs.length; i++) {
12586
12518
  resStr += this.decoder.write(this.initialBufs[i]);
12519
+ }
12587
12520
  var trail = this.decoder.end();
12588
- if (trail)
12521
+ if (trail) {
12589
12522
  resStr += trail;
12523
+ }
12590
12524
  this.initialBufs.length = this.initialBufsLen = 0;
12591
12525
  return resStr;
12592
12526
  }
@@ -12595,8 +12529,9 @@ function requireUtf16() {
12595
12529
  function detectEncoding(bufs, defaultEncoding) {
12596
12530
  var b = [];
12597
12531
  var charsProcessed = 0;
12598
- var asciiCharsLE = 0, asciiCharsBE = 0;
12599
- outer_loop:
12532
+ var asciiCharsLE = 0;
12533
+ var asciiCharsBE = 0;
12534
+ outerLoop:
12600
12535
  for (var i = 0; i < bufs.length; i++) {
12601
12536
  var buf = bufs[i];
12602
12537
  for (var j = 0; j < buf.length; j++) {
@@ -12611,7 +12546,7 @@ function requireUtf16() {
12611
12546
  b.length = 0;
12612
12547
  charsProcessed++;
12613
12548
  if (charsProcessed >= 100) {
12614
- break outer_loop;
12549
+ break outerLoop;
12615
12550
  }
12616
12551
  }
12617
12552
  }
@@ -12654,11 +12589,17 @@ function requireUtf7() {
12654
12589
  }
12655
12590
  var base64Regex = /[A-Za-z0-9\/+]/;
12656
12591
  var base64Chars = [];
12657
- for (var i = 0; i < 256; i++)
12592
+ for (var i = 0; i < 256; i++) {
12658
12593
  base64Chars[i] = base64Regex.test(String.fromCharCode(i));
12659
- var plusChar = "+".charCodeAt(0), minusChar = "-".charCodeAt(0), andChar = "&".charCodeAt(0);
12594
+ }
12595
+ var plusChar = "+".charCodeAt(0);
12596
+ var minusChar = "-".charCodeAt(0);
12597
+ var andChar = "&".charCodeAt(0);
12660
12598
  Utf7Decoder.prototype.write = function(buf) {
12661
- var res = "", lastI = 0, inBase64 = this.inBase64, base64Accum = this.base64Accum;
12599
+ var res = "";
12600
+ var lastI = 0;
12601
+ var inBase64 = this.inBase64;
12602
+ var base64Accum = this.base64Accum;
12662
12603
  for (var i2 = 0; i2 < buf.length; i2++) {
12663
12604
  if (!inBase64) {
12664
12605
  if (buf[i2] == plusChar) {
@@ -12674,8 +12615,9 @@ function requireUtf7() {
12674
12615
  var b64str = base64Accum + this.iconv.decode(buf.slice(lastI, i2), "ascii");
12675
12616
  res += this.iconv.decode(Buffer2.from(b64str, "base64"), "utf16-be");
12676
12617
  }
12677
- if (buf[i2] != minusChar)
12618
+ if (buf[i2] != minusChar) {
12678
12619
  i2--;
12620
+ }
12679
12621
  lastI = i2 + 1;
12680
12622
  inBase64 = false;
12681
12623
  base64Accum = "";
@@ -12697,8 +12639,9 @@ function requireUtf7() {
12697
12639
  };
12698
12640
  Utf7Decoder.prototype.end = function() {
12699
12641
  var res = "";
12700
- if (this.inBase64 && this.base64Accum.length > 0)
12642
+ if (this.inBase64 && this.base64Accum.length > 0) {
12701
12643
  res = this.iconv.decode(Buffer2.from(this.base64Accum, "base64"), "utf16-be");
12644
+ }
12702
12645
  this.inBase64 = false;
12703
12646
  this.base64Accum = "";
12704
12647
  return res;
@@ -12717,10 +12660,14 @@ function requireUtf7() {
12717
12660
  this.base64AccumIdx = 0;
12718
12661
  }
12719
12662
  Utf7IMAPEncoder.prototype.write = function(str) {
12720
- var inBase64 = this.inBase64, base64Accum = this.base64Accum, base64AccumIdx = this.base64AccumIdx, buf = Buffer2.alloc(str.length * 5 + 10), bufIdx = 0;
12663
+ var inBase64 = this.inBase64;
12664
+ var base64Accum = this.base64Accum;
12665
+ var base64AccumIdx = this.base64AccumIdx;
12666
+ var buf = Buffer2.alloc(str.length * 5 + 10);
12667
+ var bufIdx = 0;
12721
12668
  for (var i2 = 0; i2 < str.length; i2++) {
12722
12669
  var uChar = str.charCodeAt(i2);
12723
- if (32 <= uChar && uChar <= 126) {
12670
+ if (uChar >= 32 && uChar <= 126) {
12724
12671
  if (inBase64) {
12725
12672
  if (base64AccumIdx > 0) {
12726
12673
  bufIdx += buf.write(base64Accum.slice(0, base64AccumIdx).toString("base64").replace(/\//g, ",").replace(/=+$/, ""), bufIdx);
@@ -12731,8 +12678,9 @@ function requireUtf7() {
12731
12678
  }
12732
12679
  if (!inBase64) {
12733
12680
  buf[bufIdx++] = uChar;
12734
- if (uChar === andChar)
12681
+ if (uChar === andChar) {
12735
12682
  buf[bufIdx++] = minusChar;
12683
+ }
12736
12684
  }
12737
12685
  } else {
12738
12686
  if (!inBase64) {
@@ -12754,7 +12702,8 @@ function requireUtf7() {
12754
12702
  return buf.slice(0, bufIdx);
12755
12703
  };
12756
12704
  Utf7IMAPEncoder.prototype.end = function() {
12757
- var buf = Buffer2.alloc(10), bufIdx = 0;
12705
+ var buf = Buffer2.alloc(10);
12706
+ var bufIdx = 0;
12758
12707
  if (this.inBase64) {
12759
12708
  if (this.base64AccumIdx > 0) {
12760
12709
  bufIdx += buf.write(this.base64Accum.slice(0, this.base64AccumIdx).toString("base64").replace(/\//g, ",").replace(/=+$/, ""), bufIdx);
@@ -12773,7 +12722,10 @@ function requireUtf7() {
12773
12722
  var base64IMAPChars = base64Chars.slice();
12774
12723
  base64IMAPChars[",".charCodeAt(0)] = true;
12775
12724
  Utf7IMAPDecoder.prototype.write = function(buf) {
12776
- var res = "", lastI = 0, inBase64 = this.inBase64, base64Accum = this.base64Accum;
12725
+ var res = "";
12726
+ var lastI = 0;
12727
+ var inBase64 = this.inBase64;
12728
+ var base64Accum = this.base64Accum;
12777
12729
  for (var i2 = 0; i2 < buf.length; i2++) {
12778
12730
  if (!inBase64) {
12779
12731
  if (buf[i2] == andChar) {
@@ -12789,8 +12741,9 @@ function requireUtf7() {
12789
12741
  var b64str = base64Accum + this.iconv.decode(buf.slice(lastI, i2), "ascii").replace(/,/g, "/");
12790
12742
  res += this.iconv.decode(Buffer2.from(b64str, "base64"), "utf16-be");
12791
12743
  }
12792
- if (buf[i2] != minusChar)
12744
+ if (buf[i2] != minusChar) {
12793
12745
  i2--;
12746
+ }
12794
12747
  lastI = i2 + 1;
12795
12748
  inBase64 = false;
12796
12749
  base64Accum = "";
@@ -12812,8 +12765,9 @@ function requireUtf7() {
12812
12765
  };
12813
12766
  Utf7IMAPDecoder.prototype.end = function() {
12814
12767
  var res = "";
12815
- if (this.inBase64 && this.base64Accum.length > 0)
12768
+ if (this.inBase64 && this.base64Accum.length > 0) {
12816
12769
  res = this.iconv.decode(Buffer2.from(this.base64Accum, "base64"), "utf16-be");
12770
+ }
12817
12771
  this.inBase64 = false;
12818
12772
  this.base64Accum = "";
12819
12773
  return res;
@@ -12828,20 +12782,24 @@ function requireSbcsCodec() {
12828
12782
  var Buffer2 = requireSafer().Buffer;
12829
12783
  sbcsCodec._sbcs = SBCSCodec;
12830
12784
  function SBCSCodec(codecOptions, iconv) {
12831
- if (!codecOptions)
12785
+ if (!codecOptions) {
12832
12786
  throw new Error("SBCS codec is called without the data.");
12833
- if (!codecOptions.chars || codecOptions.chars.length !== 128 && codecOptions.chars.length !== 256)
12787
+ }
12788
+ if (!codecOptions.chars || codecOptions.chars.length !== 128 && codecOptions.chars.length !== 256) {
12834
12789
  throw new Error("Encoding '" + codecOptions.type + "' has incorrect 'chars' (must be of len 128 or 256)");
12790
+ }
12835
12791
  if (codecOptions.chars.length === 128) {
12836
12792
  var asciiString = "";
12837
- for (var i = 0; i < 128; i++)
12793
+ for (var i = 0; i < 128; i++) {
12838
12794
  asciiString += String.fromCharCode(i);
12795
+ }
12839
12796
  codecOptions.chars = asciiString + codecOptions.chars;
12840
12797
  }
12841
12798
  this.decodeBuf = Buffer2.from(codecOptions.chars, "ucs2");
12842
12799
  var encodeBuf = Buffer2.alloc(65536, iconv.defaultCharSingleByte.charCodeAt(0));
12843
- for (var i = 0; i < codecOptions.chars.length; i++)
12800
+ for (var i = 0; i < codecOptions.chars.length; i++) {
12844
12801
  encodeBuf[codecOptions.chars.charCodeAt(i)] = i;
12802
+ }
12845
12803
  this.encodeBuf = encodeBuf;
12846
12804
  }
12847
12805
  SBCSCodec.prototype.encoder = SBCSEncoder;
@@ -12851,8 +12809,9 @@ function requireSbcsCodec() {
12851
12809
  }
12852
12810
  SBCSEncoder.prototype.write = function(str) {
12853
12811
  var buf = Buffer2.alloc(str.length);
12854
- for (var i = 0; i < str.length; i++)
12812
+ for (var i = 0; i < str.length; i++) {
12855
12813
  buf[i] = this.encodeBuf[str.charCodeAt(i)];
12814
+ }
12856
12815
  return buf;
12857
12816
  };
12858
12817
  SBCSEncoder.prototype.end = function() {
@@ -12863,7 +12822,8 @@ function requireSbcsCodec() {
12863
12822
  SBCSDecoder.prototype.write = function(buf) {
12864
12823
  var decodeBuf = this.decodeBuf;
12865
12824
  var newBuf = Buffer2.alloc(buf.length * 2);
12866
- var idx1 = 0, idx2 = 0;
12825
+ var idx1 = 0;
12826
+ var idx2 = 0;
12867
12827
  for (var i = 0; i < buf.length; i++) {
12868
12828
  idx1 = buf[i] * 2;
12869
12829
  idx2 = i * 2;
@@ -12883,149 +12843,149 @@ function requireSbcsData() {
12883
12843
  hasRequiredSbcsData = 1;
12884
12844
  sbcsData = {
12885
12845
  // Not supported by iconv, not sure why.
12886
- "10029": "maccenteuro",
12887
- "maccenteuro": {
12888
- "type": "_sbcs",
12889
- "chars": "ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ"
12846
+ 10029: "maccenteuro",
12847
+ maccenteuro: {
12848
+ type: "_sbcs",
12849
+ chars: "ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ"
12890
12850
  },
12891
- "808": "cp808",
12892
- "ibm808": "cp808",
12893
- "cp808": {
12894
- "type": "_sbcs",
12895
- "chars": "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмноп░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀рстуфхцчшщъыьэюяЁёЄєЇїЎў°∙·√№€■ "
12851
+ 808: "cp808",
12852
+ ibm808: "cp808",
12853
+ cp808: {
12854
+ type: "_sbcs",
12855
+ chars: "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмноп░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀рстуфхцчшщъыьэюяЁёЄєЇїЎў°∙·√№€■ "
12896
12856
  },
12897
- "mik": {
12898
- "type": "_sbcs",
12899
- "chars": "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя└┴┬├─┼╣║╚╔╩╦╠═╬┐░▒▓│┤№§╗╝┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ "
12857
+ mik: {
12858
+ type: "_sbcs",
12859
+ chars: "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя└┴┬├─┼╣║╚╔╩╦╠═╬┐░▒▓│┤№§╗╝┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ "
12900
12860
  },
12901
- "cp720": {
12902
- "type": "_sbcs",
12903
- "chars": "€éâ„à†çêëèïّْô¤ـûùءآأؤ£إئابةتثجحخدذرزسشص«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ضطظعغفµقكلمنهوىي≡ًٌٍَُِ≈°∙·√ⁿ²■ "
12861
+ cp720: {
12862
+ type: "_sbcs",
12863
+ chars: "€éâ„à†çêëèïّْô¤ـûùءآأؤ£إئابةتثجحخدذرزسشص«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ضطظعغفµقكلمنهوىي≡ًٌٍَُِ≈°∙·√ⁿ²■ "
12904
12864
  },
12905
12865
  // Aliases of generated encodings.
12906
- "ascii8bit": "ascii",
12907
- "usascii": "ascii",
12908
- "ansix34": "ascii",
12909
- "ansix341968": "ascii",
12910
- "ansix341986": "ascii",
12911
- "csascii": "ascii",
12912
- "cp367": "ascii",
12913
- "ibm367": "ascii",
12914
- "isoir6": "ascii",
12915
- "iso646us": "ascii",
12916
- "iso646irv": "ascii",
12917
- "us": "ascii",
12918
- "latin1": "iso88591",
12919
- "latin2": "iso88592",
12920
- "latin3": "iso88593",
12921
- "latin4": "iso88594",
12922
- "latin5": "iso88599",
12923
- "latin6": "iso885910",
12924
- "latin7": "iso885913",
12925
- "latin8": "iso885914",
12926
- "latin9": "iso885915",
12927
- "latin10": "iso885916",
12928
- "csisolatin1": "iso88591",
12929
- "csisolatin2": "iso88592",
12930
- "csisolatin3": "iso88593",
12931
- "csisolatin4": "iso88594",
12932
- "csisolatincyrillic": "iso88595",
12933
- "csisolatinarabic": "iso88596",
12934
- "csisolatingreek": "iso88597",
12935
- "csisolatinhebrew": "iso88598",
12936
- "csisolatin5": "iso88599",
12937
- "csisolatin6": "iso885910",
12938
- "l1": "iso88591",
12939
- "l2": "iso88592",
12940
- "l3": "iso88593",
12941
- "l4": "iso88594",
12942
- "l5": "iso88599",
12943
- "l6": "iso885910",
12944
- "l7": "iso885913",
12945
- "l8": "iso885914",
12946
- "l9": "iso885915",
12947
- "l10": "iso885916",
12948
- "isoir14": "iso646jp",
12949
- "isoir57": "iso646cn",
12950
- "isoir100": "iso88591",
12951
- "isoir101": "iso88592",
12952
- "isoir109": "iso88593",
12953
- "isoir110": "iso88594",
12954
- "isoir144": "iso88595",
12955
- "isoir127": "iso88596",
12956
- "isoir126": "iso88597",
12957
- "isoir138": "iso88598",
12958
- "isoir148": "iso88599",
12959
- "isoir157": "iso885910",
12960
- "isoir166": "tis620",
12961
- "isoir179": "iso885913",
12962
- "isoir199": "iso885914",
12963
- "isoir203": "iso885915",
12964
- "isoir226": "iso885916",
12965
- "cp819": "iso88591",
12966
- "ibm819": "iso88591",
12967
- "cyrillic": "iso88595",
12968
- "arabic": "iso88596",
12969
- "arabic8": "iso88596",
12970
- "ecma114": "iso88596",
12971
- "asmo708": "iso88596",
12972
- "greek": "iso88597",
12973
- "greek8": "iso88597",
12974
- "ecma118": "iso88597",
12975
- "elot928": "iso88597",
12976
- "hebrew": "iso88598",
12977
- "hebrew8": "iso88598",
12978
- "turkish": "iso88599",
12979
- "turkish8": "iso88599",
12980
- "thai": "iso885911",
12981
- "thai8": "iso885911",
12982
- "celtic": "iso885914",
12983
- "celtic8": "iso885914",
12984
- "isoceltic": "iso885914",
12985
- "tis6200": "tis620",
12986
- "tis62025291": "tis620",
12987
- "tis62025330": "tis620",
12988
- "10000": "macroman",
12989
- "10006": "macgreek",
12990
- "10007": "maccyrillic",
12991
- "10079": "maciceland",
12992
- "10081": "macturkish",
12993
- "cspc8codepage437": "cp437",
12994
- "cspc775baltic": "cp775",
12995
- "cspc850multilingual": "cp850",
12996
- "cspcp852": "cp852",
12997
- "cspc862latinhebrew": "cp862",
12998
- "cpgr": "cp869",
12999
- "msee": "cp1250",
13000
- "mscyrl": "cp1251",
13001
- "msansi": "cp1252",
13002
- "msgreek": "cp1253",
13003
- "msturk": "cp1254",
13004
- "mshebr": "cp1255",
13005
- "msarab": "cp1256",
13006
- "winbaltrim": "cp1257",
13007
- "cp20866": "koi8r",
13008
- "20866": "koi8r",
13009
- "ibm878": "koi8r",
13010
- "cskoi8r": "koi8r",
13011
- "cp21866": "koi8u",
13012
- "21866": "koi8u",
13013
- "ibm1168": "koi8u",
13014
- "strk10482002": "rk1048",
13015
- "tcvn5712": "tcvn",
13016
- "tcvn57121": "tcvn",
13017
- "gb198880": "iso646cn",
13018
- "cn": "iso646cn",
13019
- "csiso14jisc6220ro": "iso646jp",
13020
- "jisc62201969ro": "iso646jp",
13021
- "jp": "iso646jp",
13022
- "cshproman8": "hproman8",
13023
- "r8": "hproman8",
13024
- "roman8": "hproman8",
13025
- "xroman8": "hproman8",
13026
- "ibm1051": "hproman8",
13027
- "mac": "macintosh",
13028
- "csmacintosh": "macintosh"
12866
+ ascii8bit: "ascii",
12867
+ usascii: "ascii",
12868
+ ansix34: "ascii",
12869
+ ansix341968: "ascii",
12870
+ ansix341986: "ascii",
12871
+ csascii: "ascii",
12872
+ cp367: "ascii",
12873
+ ibm367: "ascii",
12874
+ isoir6: "ascii",
12875
+ iso646us: "ascii",
12876
+ iso646irv: "ascii",
12877
+ us: "ascii",
12878
+ latin1: "iso88591",
12879
+ latin2: "iso88592",
12880
+ latin3: "iso88593",
12881
+ latin4: "iso88594",
12882
+ latin5: "iso88599",
12883
+ latin6: "iso885910",
12884
+ latin7: "iso885913",
12885
+ latin8: "iso885914",
12886
+ latin9: "iso885915",
12887
+ latin10: "iso885916",
12888
+ csisolatin1: "iso88591",
12889
+ csisolatin2: "iso88592",
12890
+ csisolatin3: "iso88593",
12891
+ csisolatin4: "iso88594",
12892
+ csisolatincyrillic: "iso88595",
12893
+ csisolatinarabic: "iso88596",
12894
+ csisolatingreek: "iso88597",
12895
+ csisolatinhebrew: "iso88598",
12896
+ csisolatin5: "iso88599",
12897
+ csisolatin6: "iso885910",
12898
+ l1: "iso88591",
12899
+ l2: "iso88592",
12900
+ l3: "iso88593",
12901
+ l4: "iso88594",
12902
+ l5: "iso88599",
12903
+ l6: "iso885910",
12904
+ l7: "iso885913",
12905
+ l8: "iso885914",
12906
+ l9: "iso885915",
12907
+ l10: "iso885916",
12908
+ isoir14: "iso646jp",
12909
+ isoir57: "iso646cn",
12910
+ isoir100: "iso88591",
12911
+ isoir101: "iso88592",
12912
+ isoir109: "iso88593",
12913
+ isoir110: "iso88594",
12914
+ isoir144: "iso88595",
12915
+ isoir127: "iso88596",
12916
+ isoir126: "iso88597",
12917
+ isoir138: "iso88598",
12918
+ isoir148: "iso88599",
12919
+ isoir157: "iso885910",
12920
+ isoir166: "tis620",
12921
+ isoir179: "iso885913",
12922
+ isoir199: "iso885914",
12923
+ isoir203: "iso885915",
12924
+ isoir226: "iso885916",
12925
+ cp819: "iso88591",
12926
+ ibm819: "iso88591",
12927
+ cyrillic: "iso88595",
12928
+ arabic: "iso88596",
12929
+ arabic8: "iso88596",
12930
+ ecma114: "iso88596",
12931
+ asmo708: "iso88596",
12932
+ greek: "iso88597",
12933
+ greek8: "iso88597",
12934
+ ecma118: "iso88597",
12935
+ elot928: "iso88597",
12936
+ hebrew: "iso88598",
12937
+ hebrew8: "iso88598",
12938
+ turkish: "iso88599",
12939
+ turkish8: "iso88599",
12940
+ thai: "iso885911",
12941
+ thai8: "iso885911",
12942
+ celtic: "iso885914",
12943
+ celtic8: "iso885914",
12944
+ isoceltic: "iso885914",
12945
+ tis6200: "tis620",
12946
+ tis62025291: "tis620",
12947
+ tis62025330: "tis620",
12948
+ 1e4: "macroman",
12949
+ 10006: "macgreek",
12950
+ 10007: "maccyrillic",
12951
+ 10079: "maciceland",
12952
+ 10081: "macturkish",
12953
+ cspc8codepage437: "cp437",
12954
+ cspc775baltic: "cp775",
12955
+ cspc850multilingual: "cp850",
12956
+ cspcp852: "cp852",
12957
+ cspc862latinhebrew: "cp862",
12958
+ cpgr: "cp869",
12959
+ msee: "cp1250",
12960
+ mscyrl: "cp1251",
12961
+ msansi: "cp1252",
12962
+ msgreek: "cp1253",
12963
+ msturk: "cp1254",
12964
+ mshebr: "cp1255",
12965
+ msarab: "cp1256",
12966
+ winbaltrim: "cp1257",
12967
+ cp20866: "koi8r",
12968
+ 20866: "koi8r",
12969
+ ibm878: "koi8r",
12970
+ cskoi8r: "koi8r",
12971
+ cp21866: "koi8u",
12972
+ 21866: "koi8u",
12973
+ ibm1168: "koi8u",
12974
+ strk10482002: "rk1048",
12975
+ tcvn5712: "tcvn",
12976
+ tcvn57121: "tcvn",
12977
+ gb198880: "iso646cn",
12978
+ cn: "iso646cn",
12979
+ csiso14jisc6220ro: "iso646jp",
12980
+ jisc62201969ro: "iso646jp",
12981
+ jp: "iso646jp",
12982
+ cshproman8: "hproman8",
12983
+ r8: "hproman8",
12984
+ roman8: "hproman8",
12985
+ xroman8: "hproman8",
12986
+ ibm1051: "hproman8",
12987
+ mac: "macintosh",
12988
+ csmacintosh: "macintosh"
13029
12989
  };
13030
12990
  return sbcsData;
13031
12991
  }
@@ -13491,21 +13451,30 @@ function requireDbcsCodec() {
13491
13451
  hasRequiredDbcsCodec = 1;
13492
13452
  var Buffer2 = requireSafer().Buffer;
13493
13453
  dbcsCodec._dbcs = DBCSCodec;
13494
- var UNASSIGNED = -1, GB18030_CODE = -2, SEQ_START = -10, NODE_START = -1e3, UNASSIGNED_NODE = new Array(256), DEF_CHAR = -1;
13495
- for (var i = 0; i < 256; i++)
13454
+ var UNASSIGNED = -1;
13455
+ var GB18030_CODE = -2;
13456
+ var SEQ_START = -10;
13457
+ var NODE_START = -1e3;
13458
+ var UNASSIGNED_NODE = new Array(256);
13459
+ var DEF_CHAR = -1;
13460
+ for (var i = 0; i < 256; i++) {
13496
13461
  UNASSIGNED_NODE[i] = UNASSIGNED;
13462
+ }
13497
13463
  function DBCSCodec(codecOptions, iconv) {
13498
13464
  this.encodingName = codecOptions.encodingName;
13499
- if (!codecOptions)
13465
+ if (!codecOptions) {
13500
13466
  throw new Error("DBCS codec is called without the data.");
13501
- if (!codecOptions.table)
13467
+ }
13468
+ if (!codecOptions.table) {
13502
13469
  throw new Error("Encoding '" + this.encodingName + "' has no data.");
13470
+ }
13503
13471
  var mappingTable = codecOptions.table();
13504
13472
  this.decodeTables = [];
13505
13473
  this.decodeTables[0] = UNASSIGNED_NODE.slice(0);
13506
13474
  this.decodeTableSeq = [];
13507
- for (var i2 = 0; i2 < mappingTable.length; i2++)
13475
+ for (var i2 = 0; i2 < mappingTable.length; i2++) {
13508
13476
  this._addDecodeChunk(mappingTable[i2]);
13477
+ }
13509
13478
  if (typeof codecOptions.gb18030 === "function") {
13510
13479
  this.gb18030 = codecOptions.gb18030();
13511
13480
  var commonThirdByteNodeIdx = this.decodeTables.length;
@@ -13532,8 +13501,9 @@ function requireDbcsCodec() {
13532
13501
  }
13533
13502
  var fourthByteNode = this.decodeTables[NODE_START - thirdByteNode[k]];
13534
13503
  for (var l = 48; l <= 57; l++) {
13535
- if (fourthByteNode[l] === UNASSIGNED)
13504
+ if (fourthByteNode[l] === UNASSIGNED) {
13536
13505
  fourthByteNode[l] = GB18030_CODE;
13506
+ }
13537
13507
  }
13538
13508
  }
13539
13509
  }
@@ -13543,20 +13513,25 @@ function requireDbcsCodec() {
13543
13513
  this.encodeTable = [];
13544
13514
  this.encodeTableSeq = [];
13545
13515
  var skipEncodeChars = {};
13546
- if (codecOptions.encodeSkipVals)
13516
+ if (codecOptions.encodeSkipVals) {
13547
13517
  for (var i2 = 0; i2 < codecOptions.encodeSkipVals.length; i2++) {
13548
13518
  var val = codecOptions.encodeSkipVals[i2];
13549
- if (typeof val === "number")
13519
+ if (typeof val === "number") {
13550
13520
  skipEncodeChars[val] = true;
13551
- else
13552
- for (var j = val.from; j <= val.to; j++)
13521
+ } else {
13522
+ for (var j = val.from; j <= val.to; j++) {
13553
13523
  skipEncodeChars[j] = true;
13524
+ }
13525
+ }
13554
13526
  }
13527
+ }
13555
13528
  this._fillEncodeTable(0, 0, skipEncodeChars);
13556
13529
  if (codecOptions.encodeAdd) {
13557
- for (var uChar in codecOptions.encodeAdd)
13558
- if (Object.prototype.hasOwnProperty.call(codecOptions.encodeAdd, uChar))
13530
+ for (var uChar in codecOptions.encodeAdd) {
13531
+ if (Object.prototype.hasOwnProperty.call(codecOptions.encodeAdd, uChar)) {
13559
13532
  this._setEncodeChar(uChar.charCodeAt(0), codecOptions.encodeAdd[uChar]);
13533
+ }
13534
+ }
13560
13535
  }
13561
13536
  this.defCharSB = this.encodeTable[0][iconv.defaultCharSingleByte.charCodeAt(0)];
13562
13537
  if (this.defCharSB === UNASSIGNED) this.defCharSB = this.encodeTable[0]["?"];
@@ -13566,10 +13541,12 @@ function requireDbcsCodec() {
13566
13541
  DBCSCodec.prototype.decoder = DBCSDecoder;
13567
13542
  DBCSCodec.prototype._getDecodeTrieNode = function(addr) {
13568
13543
  var bytes2 = [];
13569
- for (; addr > 0; addr >>>= 8)
13544
+ for (; addr > 0; addr >>>= 8) {
13570
13545
  bytes2.push(addr & 255);
13571
- if (bytes2.length == 0)
13546
+ }
13547
+ if (bytes2.length == 0) {
13572
13548
  bytes2.push(0);
13549
+ }
13573
13550
  var node = this.decodeTables[0];
13574
13551
  for (var i2 = bytes2.length - 1; i2 > 0; i2--) {
13575
13552
  var val = node[bytes2[i2]];
@@ -13578,8 +13555,9 @@ function requireDbcsCodec() {
13578
13555
  this.decodeTables.push(node = UNASSIGNED_NODE.slice(0));
13579
13556
  } else if (val <= NODE_START) {
13580
13557
  node = this.decodeTables[NODE_START - val];
13581
- } else
13558
+ } else {
13582
13559
  throw new Error("Overwrite byte in " + this.encodingName + ", addr: " + addr.toString(16));
13560
+ }
13583
13561
  }
13584
13562
  return node;
13585
13563
  };
@@ -13592,45 +13570,53 @@ function requireDbcsCodec() {
13592
13570
  if (typeof part === "string") {
13593
13571
  for (var l = 0; l < part.length; ) {
13594
13572
  var code = part.charCodeAt(l++);
13595
- if (55296 <= code && code < 56320) {
13573
+ if (code >= 55296 && code < 56320) {
13596
13574
  var codeTrail = part.charCodeAt(l++);
13597
- if (56320 <= codeTrail && codeTrail < 57344)
13575
+ if (codeTrail >= 56320 && codeTrail < 57344) {
13598
13576
  writeTable[curAddr++] = 65536 + (code - 55296) * 1024 + (codeTrail - 56320);
13599
- else
13577
+ } else {
13600
13578
  throw new Error("Incorrect surrogate pair in " + this.encodingName + " at chunk " + chunk[0]);
13601
- } else if (4080 < code && code <= 4095) {
13579
+ }
13580
+ } else if (code > 4080 && code <= 4095) {
13602
13581
  var len = 4095 - code + 2;
13603
13582
  var seq = [];
13604
- for (var m = 0; m < len; m++)
13583
+ for (var m = 0; m < len; m++) {
13605
13584
  seq.push(part.charCodeAt(l++));
13585
+ }
13606
13586
  writeTable[curAddr++] = SEQ_START - this.decodeTableSeq.length;
13607
13587
  this.decodeTableSeq.push(seq);
13608
- } else
13588
+ } else {
13609
13589
  writeTable[curAddr++] = code;
13590
+ }
13610
13591
  }
13611
13592
  } else if (typeof part === "number") {
13612
13593
  var charCode = writeTable[curAddr - 1] + 1;
13613
- for (var l = 0; l < part; l++)
13594
+ for (var l = 0; l < part; l++) {
13614
13595
  writeTable[curAddr++] = charCode++;
13615
- } else
13596
+ }
13597
+ } else {
13616
13598
  throw new Error("Incorrect type '" + typeof part + "' given in " + this.encodingName + " at chunk " + chunk[0]);
13599
+ }
13617
13600
  }
13618
- if (curAddr > 255)
13601
+ if (curAddr > 255) {
13619
13602
  throw new Error("Incorrect chunk in " + this.encodingName + " at addr " + chunk[0] + ": too long" + curAddr);
13603
+ }
13620
13604
  };
13621
13605
  DBCSCodec.prototype._getEncodeBucket = function(uCode) {
13622
13606
  var high = uCode >> 8;
13623
- if (this.encodeTable[high] === void 0)
13607
+ if (this.encodeTable[high] === void 0) {
13624
13608
  this.encodeTable[high] = UNASSIGNED_NODE.slice(0);
13609
+ }
13625
13610
  return this.encodeTable[high];
13626
13611
  };
13627
13612
  DBCSCodec.prototype._setEncodeChar = function(uCode, dbcsCode) {
13628
13613
  var bucket = this._getEncodeBucket(uCode);
13629
13614
  var low = uCode & 255;
13630
- if (bucket[low] <= SEQ_START)
13615
+ if (bucket[low] <= SEQ_START) {
13631
13616
  this.encodeTableSeq[SEQ_START - bucket[low]][DEF_CHAR] = dbcsCode;
13632
- else if (bucket[low] == UNASSIGNED)
13617
+ } else if (bucket[low] == UNASSIGNED) {
13633
13618
  bucket[low] = dbcsCode;
13619
+ }
13634
13620
  };
13635
13621
  DBCSCodec.prototype._setEncodeSequence = function(seq, dbcsCode) {
13636
13622
  var uCode = seq[0];
@@ -13647,12 +13633,13 @@ function requireDbcsCodec() {
13647
13633
  }
13648
13634
  for (var j = 1; j < seq.length - 1; j++) {
13649
13635
  var oldVal = node[uCode];
13650
- if (typeof oldVal === "object")
13636
+ if (typeof oldVal === "object") {
13651
13637
  node = oldVal;
13652
- else {
13638
+ } else {
13653
13639
  node = node[uCode] = {};
13654
- if (oldVal !== void 0)
13640
+ if (oldVal !== void 0) {
13655
13641
  node[DEF_CHAR] = oldVal;
13642
+ }
13656
13643
  }
13657
13644
  }
13658
13645
  uCode = seq[seq.length - 1];
@@ -13665,8 +13652,9 @@ function requireDbcsCodec() {
13665
13652
  for (var i2 = 0; i2 < 256; i2++) {
13666
13653
  var uCode = node[i2];
13667
13654
  var mbCode = prefix + i2;
13668
- if (skipEncodeChars[mbCode])
13655
+ if (skipEncodeChars[mbCode]) {
13669
13656
  continue;
13657
+ }
13670
13658
  if (uCode >= 0) {
13671
13659
  this._setEncodeChar(uCode, mbCode);
13672
13660
  hasValues = true;
@@ -13674,10 +13662,11 @@ function requireDbcsCodec() {
13674
13662
  var subNodeIdx = NODE_START - uCode;
13675
13663
  if (!subNodeEmpty[subNodeIdx]) {
13676
13664
  var newPrefix = mbCode << 8 >>> 0;
13677
- if (this._fillEncodeTable(subNodeIdx, newPrefix, skipEncodeChars))
13665
+ if (this._fillEncodeTable(subNodeIdx, newPrefix, skipEncodeChars)) {
13678
13666
  hasValues = true;
13679
- else
13667
+ } else {
13680
13668
  subNodeEmpty[subNodeIdx] = true;
13669
+ }
13681
13670
  }
13682
13671
  } else if (uCode <= SEQ_START) {
13683
13672
  this._setEncodeSequence(this.decodeTableSeq[SEQ_START - uCode], mbCode);
@@ -13695,7 +13684,12 @@ function requireDbcsCodec() {
13695
13684
  this.gb18030 = codec2.gb18030;
13696
13685
  }
13697
13686
  DBCSEncoder.prototype.write = function(str) {
13698
- var newBuf = Buffer2.alloc(str.length * (this.gb18030 ? 4 : 3)), leadSurrogate = this.leadSurrogate, seqObj = this.seqObj, nextChar = -1, i2 = 0, j = 0;
13687
+ var newBuf = Buffer2.alloc(str.length * (this.gb18030 ? 4 : 3));
13688
+ var leadSurrogate = this.leadSurrogate;
13689
+ var seqObj = this.seqObj;
13690
+ var nextChar = -1;
13691
+ var i2 = 0;
13692
+ var j = 0;
13699
13693
  while (true) {
13700
13694
  if (nextChar === -1) {
13701
13695
  if (i2 == str.length) break;
@@ -13704,7 +13698,7 @@ function requireDbcsCodec() {
13704
13698
  var uCode = nextChar;
13705
13699
  nextChar = -1;
13706
13700
  }
13707
- if (55296 <= uCode && uCode < 57344) {
13701
+ if (uCode >= 55296 && uCode < 57344) {
13708
13702
  if (uCode < 56320) {
13709
13703
  if (leadSurrogate === -1) {
13710
13704
  leadSurrogate = uCode;
@@ -13732,7 +13726,7 @@ function requireDbcsCodec() {
13732
13726
  if (typeof resCode === "object") {
13733
13727
  seqObj = resCode;
13734
13728
  continue;
13735
- } else if (typeof resCode == "number") {
13729
+ } else if (typeof resCode === "number") {
13736
13730
  dbcsCode = resCode;
13737
13731
  } else if (resCode == void 0) {
13738
13732
  resCode = seqObj[DEF_CHAR];
@@ -13744,8 +13738,9 @@ function requireDbcsCodec() {
13744
13738
  seqObj = void 0;
13745
13739
  } else if (uCode >= 0) {
13746
13740
  var subtable = this.encodeTable[uCode >> 8];
13747
- if (subtable !== void 0)
13741
+ if (subtable !== void 0) {
13748
13742
  dbcsCode = subtable[uCode & 255];
13743
+ }
13749
13744
  if (dbcsCode <= SEQ_START) {
13750
13745
  seqObj = this.encodeTableSeq[SEQ_START - dbcsCode];
13751
13746
  continue;
@@ -13765,8 +13760,9 @@ function requireDbcsCodec() {
13765
13760
  }
13766
13761
  }
13767
13762
  }
13768
- if (dbcsCode === UNASSIGNED)
13763
+ if (dbcsCode === UNASSIGNED) {
13769
13764
  dbcsCode = this.defaultCharSingleByte;
13765
+ }
13770
13766
  if (dbcsCode < 256) {
13771
13767
  newBuf[j++] = dbcsCode;
13772
13768
  } else if (dbcsCode < 65536) {
@@ -13788,9 +13784,11 @@ function requireDbcsCodec() {
13788
13784
  return newBuf.slice(0, j);
13789
13785
  };
13790
13786
  DBCSEncoder.prototype.end = function() {
13791
- if (this.leadSurrogate === -1 && this.seqObj === void 0)
13787
+ if (this.leadSurrogate === -1 && this.seqObj === void 0) {
13792
13788
  return;
13793
- var newBuf = Buffer2.alloc(10), j = 0;
13789
+ }
13790
+ var newBuf = Buffer2.alloc(10);
13791
+ var j = 0;
13794
13792
  if (this.seqObj) {
13795
13793
  var dbcsCode = this.seqObj[DEF_CHAR];
13796
13794
  if (dbcsCode !== void 0) {
@@ -13819,7 +13817,12 @@ function requireDbcsCodec() {
13819
13817
  this.gb18030 = codec2.gb18030;
13820
13818
  }
13821
13819
  DBCSDecoder.prototype.write = function(buf) {
13822
- var newBuf = Buffer2.alloc(buf.length * 2), nodeIdx = this.nodeIdx, prevBytes = this.prevBytes, prevOffset = this.prevBytes.length, seqStart = -this.prevBytes.length, uCode;
13820
+ var newBuf = Buffer2.alloc(buf.length * 2);
13821
+ var nodeIdx = this.nodeIdx;
13822
+ var prevBytes = this.prevBytes;
13823
+ var prevOffset = this.prevBytes.length;
13824
+ var seqStart = -this.prevBytes.length;
13825
+ var uCode;
13823
13826
  for (var i2 = 0, j = 0; i2 < buf.length; i2++) {
13824
13827
  var curByte = i2 >= 0 ? buf[i2] : prevBytes[i2 + prevOffset];
13825
13828
  var uCode = this.decodeTables[nodeIdx][curByte];
@@ -13846,8 +13849,9 @@ function requireDbcsCodec() {
13846
13849
  newBuf[j++] = uCode >> 8;
13847
13850
  }
13848
13851
  uCode = seq[seq.length - 1];
13849
- } else
13852
+ } else {
13850
13853
  throw new Error("iconv-lite internal error: invalid decoding table value " + uCode + " at " + nodeIdx + "/" + curByte);
13854
+ }
13851
13855
  if (uCode >= 65536) {
13852
13856
  uCode -= 65536;
13853
13857
  var uCodeLead = 55296 | uCode >> 10;
@@ -13871,29 +13875,33 @@ function requireDbcsCodec() {
13871
13875
  var bytesArr = this.prevBytes.slice(1);
13872
13876
  this.prevBytes = [];
13873
13877
  this.nodeIdx = 0;
13874
- if (bytesArr.length > 0)
13878
+ if (bytesArr.length > 0) {
13875
13879
  ret += this.write(bytesArr);
13880
+ }
13876
13881
  }
13877
13882
  this.prevBytes = [];
13878
13883
  this.nodeIdx = 0;
13879
13884
  return ret;
13880
13885
  };
13881
13886
  function findIdx(table, val) {
13882
- if (table[0] > val)
13887
+ if (table[0] > val) {
13883
13888
  return -1;
13884
- var l = 0, r = table.length;
13889
+ }
13890
+ var l = 0;
13891
+ var r = table.length;
13885
13892
  while (l < r - 1) {
13886
13893
  var mid = l + (r - l + 1 >> 1);
13887
- if (table[mid] <= val)
13894
+ if (table[mid] <= val) {
13888
13895
  l = mid;
13889
- else
13896
+ } else {
13890
13897
  r = mid;
13898
+ }
13891
13899
  }
13892
13900
  return l;
13893
13901
  }
13894
13902
  return dbcsCodec;
13895
13903
  }
13896
- const require$$0$2 = [
13904
+ const require$$0$1 = [
13897
13905
  [
13898
13906
  "0",
13899
13907
  "\0",
@@ -15224,7 +15232,7 @@ function requireDbcsData() {
15224
15232
  // == Japanese/ShiftJIS ====================================================
15225
15233
  // All japanese encodings are based on JIS X set of standards:
15226
15234
  // JIS X 0201 - Single-byte encoding of ASCII + ¥ + Kana chars at 0xA1-0xDF.
15227
- // JIS X 0208 - Main set of 6879 characters, placed in 94x94 plane, to be encoded by 2 bytes.
15235
+ // JIS X 0208 - Main set of 6879 characters, placed in 94x94 plane, to be encoded by 2 bytes.
15228
15236
  // Has several variations in 1978, 1983, 1990 and 1997.
15229
15237
  // JIS X 0212 - Supplementary plane of 6067 chars in 94x94 plane. 1990. Effectively dead.
15230
15238
  // JIS X 0213 - Extension and modern replacement of 0208 and 0212. Total chars: 11233.
@@ -15241,7 +15249,7 @@ function requireDbcsData() {
15241
15249
  // 0x8F, (0xA1-0xFE)x2 - 0212 plane (94x94).
15242
15250
  // * JIS X 208: 7-bit, direct encoding of 0208. Byte ranges: 0x21-0x7E (94 values). Uncommon.
15243
15251
  // Used as-is in ISO2022 family.
15244
- // * ISO2022-JP: Stateful encoding, with escape sequences to switch between ASCII,
15252
+ // * ISO2022-JP: Stateful encoding, with escape sequences to switch between ASCII,
15245
15253
  // 0201-1976 Roman, 0208-1978, 0208-1983.
15246
15254
  // * ISO2022-JP-1: Adds esc seq for 0212-1990.
15247
15255
  // * ISO2022-JP-2: Adds esc seq for GB2313-1980, KSX1001-1992, ISO8859-1, ISO8859-7.
@@ -15251,25 +15259,25 @@ function requireDbcsData() {
15251
15259
  // After JIS X 0213 appeared, Shift_JIS-2004, EUC-JISX0213 and ISO2022-JP-2004 followed, with just changing the planes.
15252
15260
  //
15253
15261
  // Overall, it seems that it's a mess :( http://www8.plala.or.jp/tkubota1/unicode-symbols-map2.html
15254
- "shiftjis": {
15262
+ shiftjis: {
15255
15263
  type: "_dbcs",
15256
15264
  table: function() {
15257
- return require$$0$2;
15265
+ return require$$0$1;
15258
15266
  },
15259
15267
  encodeAdd: { "¥": 92, "‾": 126 },
15260
15268
  encodeSkipVals: [{ from: 60736, to: 63808 }]
15261
15269
  },
15262
- "csshiftjis": "shiftjis",
15263
- "mskanji": "shiftjis",
15264
- "sjis": "shiftjis",
15265
- "windows31j": "shiftjis",
15266
- "ms31j": "shiftjis",
15267
- "xsjis": "shiftjis",
15268
- "windows932": "shiftjis",
15269
- "ms932": "shiftjis",
15270
- "932": "shiftjis",
15271
- "cp932": "shiftjis",
15272
- "eucjp": {
15270
+ csshiftjis: "shiftjis",
15271
+ mskanji: "shiftjis",
15272
+ sjis: "shiftjis",
15273
+ windows31j: "shiftjis",
15274
+ ms31j: "shiftjis",
15275
+ xsjis: "shiftjis",
15276
+ windows932: "shiftjis",
15277
+ ms932: "shiftjis",
15278
+ 932: "shiftjis",
15279
+ cp932: "shiftjis",
15280
+ eucjp: {
15273
15281
  type: "_dbcs",
15274
15282
  table: function() {
15275
15283
  return require$$1;
@@ -15283,37 +15291,37 @@ function requireDbcsData() {
15283
15291
  // http://en.wikipedia.org/wiki/GBK
15284
15292
  // We mostly implement W3C recommendation: https://www.w3.org/TR/encoding/#gbk-encoder
15285
15293
  // Oldest GB2312 (1981, ~7600 chars) is a subset of CP936
15286
- "gb2312": "cp936",
15287
- "gb231280": "cp936",
15288
- "gb23121980": "cp936",
15289
- "csgb2312": "cp936",
15290
- "csiso58gb231280": "cp936",
15291
- "euccn": "cp936",
15294
+ gb2312: "cp936",
15295
+ gb231280: "cp936",
15296
+ gb23121980: "cp936",
15297
+ csgb2312: "cp936",
15298
+ csiso58gb231280: "cp936",
15299
+ euccn: "cp936",
15292
15300
  // Microsoft's CP936 is a subset and approximation of GBK.
15293
- "windows936": "cp936",
15294
- "ms936": "cp936",
15295
- "936": "cp936",
15296
- "cp936": {
15301
+ windows936: "cp936",
15302
+ ms936: "cp936",
15303
+ 936: "cp936",
15304
+ cp936: {
15297
15305
  type: "_dbcs",
15298
15306
  table: function() {
15299
15307
  return require$$2;
15300
15308
  }
15301
15309
  },
15302
15310
  // GBK (~22000 chars) is an extension of CP936 that added user-mapped chars and some other.
15303
- "gbk": {
15311
+ gbk: {
15304
15312
  type: "_dbcs",
15305
15313
  table: function() {
15306
15314
  return require$$2.concat(require$$3);
15307
15315
  }
15308
15316
  },
15309
- "xgbk": "gbk",
15310
- "isoir58": "gbk",
15317
+ xgbk: "gbk",
15318
+ isoir58: "gbk",
15311
15319
  // GB18030 is an algorithmic extension of GBK.
15312
15320
  // Main source: https://www.w3.org/TR/encoding/#gbk-encoder
15313
15321
  // http://icu-project.org/docs/papers/gb18030.html
15314
15322
  // http://source.icu-project.org/repos/icu/data/trunk/charset/data/xml/gb-18030-2000.xml
15315
15323
  // http://www.khngai.com/chinese/charmap/tblgbk.php?page=0
15316
- "gb18030": {
15324
+ gb18030: {
15317
15325
  type: "_dbcs",
15318
15326
  table: function() {
15319
15327
  return require$$2.concat(require$$3);
@@ -15324,26 +15332,26 @@ function requireDbcsData() {
15324
15332
  encodeSkipVals: [128],
15325
15333
  encodeAdd: { "€": 41699 }
15326
15334
  },
15327
- "chinese": "gb18030",
15335
+ chinese: "gb18030",
15328
15336
  // == Korean ===============================================================
15329
15337
  // EUC-KR, KS_C_5601 and KS X 1001 are exactly the same.
15330
- "windows949": "cp949",
15331
- "ms949": "cp949",
15332
- "949": "cp949",
15333
- "cp949": {
15338
+ windows949: "cp949",
15339
+ ms949: "cp949",
15340
+ 949: "cp949",
15341
+ cp949: {
15334
15342
  type: "_dbcs",
15335
15343
  table: function() {
15336
15344
  return require$$5;
15337
15345
  }
15338
15346
  },
15339
- "cseuckr": "cp949",
15340
- "csksc56011987": "cp949",
15341
- "euckr": "cp949",
15342
- "isoir149": "cp949",
15343
- "korean": "cp949",
15344
- "ksc56011987": "cp949",
15345
- "ksc56011989": "cp949",
15346
- "ksc5601": "cp949",
15347
+ cseuckr: "cp949",
15348
+ csksc56011987: "cp949",
15349
+ euckr: "cp949",
15350
+ isoir149: "cp949",
15351
+ korean: "cp949",
15352
+ ksc56011987: "cp949",
15353
+ ksc56011989: "cp949",
15354
+ ksc5601: "cp949",
15347
15355
  // == Big5/Taiwan/Hong Kong ================================================
15348
15356
  // There are lots of tables for Big5 and cp950. Please see the following links for history:
15349
15357
  // http://moztw.org/docs/big5/ http://www.haible.de/bruno/charsets/conversion-tables/Big5.html
@@ -15352,7 +15360,7 @@ function requireDbcsData() {
15352
15360
  // * Windows CP 951: Microsoft variant of Big5-HKSCS-2001. Seems to be never public. http://me.abelcheung.org/articles/research/what-is-cp951/
15353
15361
  // * Big5-2003 (Taiwan standard) almost superset of cp950.
15354
15362
  // * Unicode-at-on (UAO) / Mozilla 1.8. Falling out of use on the Web. Not supported by other browsers.
15355
- // * Big5-HKSCS (-2001, -2004, -2008). Hong Kong standard.
15363
+ // * Big5-HKSCS (-2001, -2004, -2008). Hong Kong standard.
15356
15364
  // many unicode code points moved from PUA to Supplementary plane (U+2XXXX) over the years.
15357
15365
  // Plus, it has 4 combining sequences.
15358
15366
  // Seems that Mozilla refused to support it for 10 yrs. https://bugzilla.mozilla.org/show_bug.cgi?id=162431 https://bugzilla.mozilla.org/show_bug.cgi?id=310299
@@ -15363,21 +15371,21 @@ function requireDbcsData() {
15363
15371
  // In the encoder, it might make sense to support encoding old PUA mappings to Big5 bytes seq-s.
15364
15372
  // Official spec: http://www.ogcio.gov.hk/en/business/tech_promotion/ccli/terms/doc/2003cmp_2008.txt
15365
15373
  // http://www.ogcio.gov.hk/tc/business/tech_promotion/ccli/terms/doc/hkscs-2008-big5-iso.txt
15366
- //
15374
+ //
15367
15375
  // Current understanding of how to deal with Big5(-HKSCS) is in the Encoding Standard, http://encoding.spec.whatwg.org/#big5-encoder
15368
15376
  // Unicode mapping (http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/OTHER/BIG5.TXT) is said to be wrong.
15369
- "windows950": "cp950",
15370
- "ms950": "cp950",
15371
- "950": "cp950",
15372
- "cp950": {
15377
+ windows950: "cp950",
15378
+ ms950: "cp950",
15379
+ 950: "cp950",
15380
+ cp950: {
15373
15381
  type: "_dbcs",
15374
15382
  table: function() {
15375
15383
  return require$$6;
15376
15384
  }
15377
15385
  },
15378
15386
  // Big5 has many variations and is an extension of cp950. We use Encoding Standard's as a consensus.
15379
- "big5": "big5hkscs",
15380
- "big5hkscs": {
15387
+ big5: "big5hkscs",
15388
+ big5hkscs: {
15381
15389
  type: "_dbcs",
15382
15390
  table: function() {
15383
15391
  return require$$6.concat(require$$7);
@@ -15456,9 +15464,9 @@ function requireDbcsData() {
15456
15464
  41678
15457
15465
  ]
15458
15466
  },
15459
- "cnbig5": "big5hkscs",
15460
- "csbig5": "big5hkscs",
15461
- "xxbig5": "big5hkscs"
15467
+ cnbig5: "big5hkscs",
15468
+ csbig5: "big5hkscs",
15469
+ xxbig5: "big5hkscs"
15462
15470
  };
15463
15471
  return dbcsData;
15464
15472
  }
@@ -15467,6 +15475,7 @@ function requireEncodings() {
15467
15475
  if (hasRequiredEncodings) return encodings;
15468
15476
  hasRequiredEncodings = 1;
15469
15477
  (function(exports$1) {
15478
+ var mergeModules = requireMergeExports();
15470
15479
  var modules = [
15471
15480
  requireInternal(),
15472
15481
  requireUtf32(),
@@ -15480,9 +15489,7 @@ function requireEncodings() {
15480
15489
  ];
15481
15490
  for (var i = 0; i < modules.length; i++) {
15482
15491
  var module = modules[i];
15483
- for (var enc in module)
15484
- if (Object.prototype.hasOwnProperty.call(module, enc))
15485
- exports$1[enc] = module[enc];
15492
+ mergeModules(exports$1, module);
15486
15493
  }
15487
15494
  })(encodings);
15488
15495
  return encodings;
@@ -15493,8 +15500,8 @@ function requireStreams() {
15493
15500
  if (hasRequiredStreams) return streams;
15494
15501
  hasRequiredStreams = 1;
15495
15502
  var Buffer2 = requireSafer().Buffer;
15496
- streams = function(stream_module) {
15497
- var Transform = stream_module.Transform;
15503
+ streams = function(streamModule) {
15504
+ var Transform = streamModule.Transform;
15498
15505
  function IconvLiteEncoderStream(conv, options) {
15499
15506
  this.conv = conv;
15500
15507
  options = options || {};
@@ -15505,8 +15512,9 @@ function requireStreams() {
15505
15512
  constructor: { value: IconvLiteEncoderStream }
15506
15513
  });
15507
15514
  IconvLiteEncoderStream.prototype._transform = function(chunk, encoding2, done) {
15508
- if (typeof chunk != "string")
15515
+ if (typeof chunk !== "string") {
15509
15516
  return done(new Error("Iconv encoding stream needs strings as its input."));
15517
+ }
15510
15518
  try {
15511
15519
  var res = this.conv.write(chunk);
15512
15520
  if (res && res.length) this.push(res);
@@ -15545,8 +15553,9 @@ function requireStreams() {
15545
15553
  constructor: { value: IconvLiteDecoderStream }
15546
15554
  });
15547
15555
  IconvLiteDecoderStream.prototype._transform = function(chunk, encoding2, done) {
15548
- if (!Buffer2.isBuffer(chunk) && !(chunk instanceof Uint8Array))
15556
+ if (!Buffer2.isBuffer(chunk) && !(chunk instanceof Uint8Array)) {
15549
15557
  return done(new Error("Iconv decoding stream needs buffers as its input."));
15558
+ }
15550
15559
  try {
15551
15560
  var res = this.conv.write(chunk);
15552
15561
  if (res && res.length) this.push(res, this.encoding);
@@ -15588,7 +15597,9 @@ function requireLib$2() {
15588
15597
  hasRequiredLib$2 = 1;
15589
15598
  (function(module) {
15590
15599
  var Buffer2 = requireSafer().Buffer;
15591
- var bomHandling2 = requireBomHandling(), iconv = module.exports;
15600
+ var bomHandling2 = requireBomHandling();
15601
+ var mergeModules = requireMergeExports();
15602
+ var iconv = module.exports;
15592
15603
  iconv.encodings = null;
15593
15604
  iconv.defaultCharUnicode = "�";
15594
15605
  iconv.defaultCharSingleByte = "?";
@@ -15622,31 +15633,38 @@ function requireLib$2() {
15622
15633
  };
15623
15634
  iconv.toEncoding = iconv.encode;
15624
15635
  iconv.fromEncoding = iconv.decode;
15625
- iconv._codecDataCache = {};
15636
+ iconv._codecDataCache = { __proto__: null };
15626
15637
  iconv.getCodec = function getCodec(encoding2) {
15627
- if (!iconv.encodings)
15628
- iconv.encodings = requireEncodings();
15638
+ if (!iconv.encodings) {
15639
+ var raw = requireEncodings();
15640
+ iconv.encodings = { __proto__: null };
15641
+ mergeModules(iconv.encodings, raw);
15642
+ }
15629
15643
  var enc = iconv._canonicalizeEncoding(encoding2);
15630
15644
  var codecOptions = {};
15631
15645
  while (true) {
15632
15646
  var codec2 = iconv._codecDataCache[enc];
15633
- if (codec2)
15647
+ if (codec2) {
15634
15648
  return codec2;
15649
+ }
15635
15650
  var codecDef = iconv.encodings[enc];
15636
15651
  switch (typeof codecDef) {
15637
15652
  case "string":
15638
15653
  enc = codecDef;
15639
15654
  break;
15640
15655
  case "object":
15641
- for (var key2 in codecDef)
15656
+ for (var key2 in codecDef) {
15642
15657
  codecOptions[key2] = codecDef[key2];
15643
- if (!codecOptions.encodingName)
15658
+ }
15659
+ if (!codecOptions.encodingName) {
15644
15660
  codecOptions.encodingName = enc;
15661
+ }
15645
15662
  enc = codecDef.type;
15646
15663
  break;
15647
15664
  case "function":
15648
- if (!codecOptions.encodingName)
15665
+ if (!codecOptions.encodingName) {
15649
15666
  codecOptions.encodingName = enc;
15667
+ }
15650
15668
  codec2 = new codecDef(codecOptions, iconv);
15651
15669
  iconv._codecDataCache[codecOptions.encodingName] = codec2;
15652
15670
  return codec2;
@@ -15659,21 +15677,26 @@ function requireLib$2() {
15659
15677
  return ("" + encoding2).toLowerCase().replace(/:\d{4}$|[^0-9a-z]/g, "");
15660
15678
  };
15661
15679
  iconv.getEncoder = function getEncoder(encoding2, options) {
15662
- var codec2 = iconv.getCodec(encoding2), encoder = new codec2.encoder(options, codec2);
15663
- if (codec2.bomAware && options && options.addBOM)
15680
+ var codec2 = iconv.getCodec(encoding2);
15681
+ var encoder = new codec2.encoder(options, codec2);
15682
+ if (codec2.bomAware && options && options.addBOM) {
15664
15683
  encoder = new bomHandling2.PrependBOM(encoder, options);
15684
+ }
15665
15685
  return encoder;
15666
15686
  };
15667
15687
  iconv.getDecoder = function getDecoder(encoding2, options) {
15668
- var codec2 = iconv.getCodec(encoding2), decoder2 = new codec2.decoder(options, codec2);
15669
- if (codec2.bomAware && !(options && options.stripBOM === false))
15688
+ var codec2 = iconv.getCodec(encoding2);
15689
+ var decoder2 = new codec2.decoder(options, codec2);
15690
+ if (codec2.bomAware && !(options && options.stripBOM === false)) {
15670
15691
  decoder2 = new bomHandling2.StripBOM(decoder2, options);
15692
+ }
15671
15693
  return decoder2;
15672
15694
  };
15673
- iconv.enableStreamingAPI = function enableStreamingAPI(stream_module2) {
15674
- if (iconv.supportsStreams)
15695
+ iconv.enableStreamingAPI = function enableStreamingAPI(streamModule2) {
15696
+ if (iconv.supportsStreams) {
15675
15697
  return;
15676
- var streams2 = requireStreams()(stream_module2);
15698
+ }
15699
+ var streams2 = requireStreams()(streamModule2);
15677
15700
  iconv.IconvLiteEncoderStream = streams2.IconvLiteEncoderStream;
15678
15701
  iconv.IconvLiteDecoderStream = streams2.IconvLiteDecoderStream;
15679
15702
  iconv.encodeStream = function encodeStream(encoding2, options) {
@@ -15684,13 +15707,13 @@ function requireLib$2() {
15684
15707
  };
15685
15708
  iconv.supportsStreams = true;
15686
15709
  };
15687
- var stream_module;
15710
+ var streamModule;
15688
15711
  try {
15689
- stream_module = require("stream");
15712
+ streamModule = require("stream");
15690
15713
  } catch (e) {
15691
15714
  }
15692
- if (stream_module && stream_module.Transform) {
15693
- iconv.enableStreamingAPI(stream_module);
15715
+ if (streamModule && streamModule.Transform) {
15716
+ iconv.enableStreamingAPI(streamModule);
15694
15717
  } else {
15695
15718
  iconv.encodeStream = iconv.decodeStream = function() {
15696
15719
  throw new Error("iconv-lite Streaming API is not enabled. Use iconv.enableStreamingAPI(require('stream')); to enable it.");
@@ -15926,131 +15949,165 @@ function requireRawBody() {
15926
15949
  }
15927
15950
  return rawBody;
15928
15951
  }
15929
- var read_1;
15930
- var hasRequiredRead;
15931
- function requireRead() {
15932
- if (hasRequiredRead) return read_1;
15933
- hasRequiredRead = 1;
15934
- var createError = requireHttpErrors();
15935
- var getBody = requireRawBody();
15936
- var iconv = requireLib$2();
15937
- var onFinished2 = requireOnFinished();
15938
- var zlib = require$$4$1;
15939
- read_1 = read2;
15940
- function read2(req, res, next, parse3, debug, options) {
15941
- var length;
15942
- var opts = options;
15943
- var stream;
15944
- var encoding2 = opts.encoding !== null ? opts.encoding : null;
15945
- var verify = opts.verify;
15946
- try {
15947
- stream = contentstream(req, debug, opts.inflate);
15948
- length = stream.length;
15949
- stream.length = void 0;
15950
- } catch (err) {
15951
- return next(err);
15952
- }
15953
- opts.length = length;
15954
- opts.encoding = verify ? null : encoding2;
15955
- if (opts.encoding === null && encoding2 !== null && !iconv.encodingExists(encoding2)) {
15956
- return next(createError(415, 'unsupported charset "' + encoding2.toUpperCase() + '"', {
15957
- charset: encoding2.toLowerCase(),
15958
- type: "charset.unsupported"
15959
- }));
15960
- }
15961
- debug("read body");
15962
- getBody(stream, opts, function(error2, body) {
15963
- if (error2) {
15964
- var _error;
15965
- if (error2.type === "encoding.unsupported") {
15966
- _error = createError(415, 'unsupported charset "' + encoding2.toUpperCase() + '"', {
15967
- charset: encoding2.toLowerCase(),
15968
- type: "charset.unsupported"
15969
- });
15970
- } else {
15971
- _error = createError(400, error2);
15972
- }
15973
- if (stream !== req) {
15974
- req.unpipe();
15975
- stream.destroy();
15976
- }
15977
- dump(req, function onfinished() {
15978
- next(createError(400, _error));
15952
+ var onFinished = { exports: {} };
15953
+ var eeFirst;
15954
+ var hasRequiredEeFirst;
15955
+ function requireEeFirst() {
15956
+ if (hasRequiredEeFirst) return eeFirst;
15957
+ hasRequiredEeFirst = 1;
15958
+ eeFirst = first;
15959
+ function first(stuff, done) {
15960
+ if (!Array.isArray(stuff))
15961
+ throw new TypeError("arg must be an array of [ee, events...] arrays");
15962
+ var cleanups = [];
15963
+ for (var i = 0; i < stuff.length; i++) {
15964
+ var arr = stuff[i];
15965
+ if (!Array.isArray(arr) || arr.length < 2)
15966
+ throw new TypeError("each array member must be [ee, events...]");
15967
+ var ee = arr[0];
15968
+ for (var j = 1; j < arr.length; j++) {
15969
+ var event = arr[j];
15970
+ var fn = listener(event, callback);
15971
+ ee.on(event, fn);
15972
+ cleanups.push({
15973
+ ee,
15974
+ event,
15975
+ fn
15979
15976
  });
15980
- return;
15981
15977
  }
15982
- if (verify) {
15983
- try {
15984
- debug("verify body");
15985
- verify(req, res, body, encoding2);
15986
- } catch (err) {
15987
- next(createError(403, err, {
15988
- body,
15989
- type: err.type || "entity.verify.failed"
15990
- }));
15991
- return;
15992
- }
15978
+ }
15979
+ function callback() {
15980
+ cleanup();
15981
+ done.apply(null, arguments);
15982
+ }
15983
+ function cleanup() {
15984
+ var x;
15985
+ for (var i2 = 0; i2 < cleanups.length; i2++) {
15986
+ x = cleanups[i2];
15987
+ x.ee.removeListener(x.event, x.fn);
15993
15988
  }
15994
- var str = body;
15995
- try {
15996
- debug("parse body");
15997
- str = typeof body !== "string" && encoding2 !== null ? iconv.decode(body, encoding2) : body;
15998
- req.body = parse3(str, encoding2);
15999
- } catch (err) {
16000
- next(createError(400, err, {
16001
- body: str,
16002
- type: err.type || "entity.parse.failed"
16003
- }));
16004
- return;
15989
+ }
15990
+ function thunk(fn2) {
15991
+ done = fn2;
15992
+ }
15993
+ thunk.cancel = cleanup;
15994
+ return thunk;
15995
+ }
15996
+ function listener(event, done) {
15997
+ return function onevent(arg1) {
15998
+ var args = new Array(arguments.length);
15999
+ var ee = this;
16000
+ var err = event === "error" ? arg1 : null;
16001
+ for (var i = 0; i < args.length; i++) {
16002
+ args[i] = arguments[i];
16005
16003
  }
16006
- next();
16007
- });
16004
+ done(err, ee, event, args);
16005
+ };
16008
16006
  }
16009
- function contentstream(req, debug, inflate) {
16010
- var encoding2 = (req.headers["content-encoding"] || "identity").toLowerCase();
16011
- var length = req.headers["content-length"];
16012
- debug('content-encoding "%s"', encoding2);
16013
- if (inflate === false && encoding2 !== "identity") {
16014
- throw createError(415, "content encoding unsupported", {
16015
- encoding: encoding2,
16016
- type: "encoding.unsupported"
16017
- });
16007
+ return eeFirst;
16008
+ }
16009
+ var hasRequiredOnFinished;
16010
+ function requireOnFinished() {
16011
+ if (hasRequiredOnFinished) return onFinished.exports;
16012
+ hasRequiredOnFinished = 1;
16013
+ onFinished.exports = onFinished$1;
16014
+ onFinished.exports.isFinished = isFinished;
16015
+ var asyncHooks = tryRequireAsyncHooks();
16016
+ var first = requireEeFirst();
16017
+ var defer = typeof setImmediate === "function" ? setImmediate : function(fn) {
16018
+ process.nextTick(fn.bind.apply(fn, arguments));
16019
+ };
16020
+ function onFinished$1(msg, listener) {
16021
+ if (isFinished(msg) !== false) {
16022
+ defer(listener, null, msg);
16023
+ return msg;
16018
16024
  }
16019
- if (encoding2 === "identity") {
16020
- req.length = length;
16021
- return req;
16025
+ attachListener(msg, wrap(listener));
16026
+ return msg;
16027
+ }
16028
+ function isFinished(msg) {
16029
+ var socket = msg.socket;
16030
+ if (typeof msg.finished === "boolean") {
16031
+ return Boolean(msg.finished || socket && !socket.writable);
16022
16032
  }
16023
- var stream = createDecompressionStream(encoding2, debug);
16024
- req.pipe(stream);
16025
- return stream;
16033
+ if (typeof msg.complete === "boolean") {
16034
+ return Boolean(msg.upgrade || !socket || !socket.readable || msg.complete && !msg.readable);
16035
+ }
16036
+ return void 0;
16026
16037
  }
16027
- function createDecompressionStream(encoding2, debug) {
16028
- switch (encoding2) {
16029
- case "deflate":
16030
- debug("inflate body");
16031
- return zlib.createInflate();
16032
- case "gzip":
16033
- debug("gunzip body");
16034
- return zlib.createGunzip();
16035
- case "br":
16036
- debug("brotli decompress body");
16037
- return zlib.createBrotliDecompress();
16038
- default:
16039
- throw createError(415, 'unsupported content encoding "' + encoding2 + '"', {
16040
- encoding: encoding2,
16041
- type: "encoding.unsupported"
16042
- });
16038
+ function attachFinishedListener(msg, callback) {
16039
+ var eeMsg;
16040
+ var eeSocket;
16041
+ var finished = false;
16042
+ function onFinish(error2) {
16043
+ eeMsg.cancel();
16044
+ eeSocket.cancel();
16045
+ finished = true;
16046
+ callback(error2);
16047
+ }
16048
+ eeMsg = eeSocket = first([[msg, "end", "finish"]], onFinish);
16049
+ function onSocket(socket) {
16050
+ msg.removeListener("socket", onSocket);
16051
+ if (finished) return;
16052
+ if (eeMsg !== eeSocket) return;
16053
+ eeSocket = first([[socket, "error", "close"]], onFinish);
16054
+ }
16055
+ if (msg.socket) {
16056
+ onSocket(msg.socket);
16057
+ return;
16058
+ }
16059
+ msg.on("socket", onSocket);
16060
+ if (msg.socket === void 0) {
16061
+ patchAssignSocket(msg, onSocket);
16043
16062
  }
16044
16063
  }
16045
- function dump(req, callback) {
16046
- if (onFinished2.isFinished(req)) {
16047
- callback(null);
16048
- } else {
16049
- onFinished2(req, callback);
16050
- req.resume();
16064
+ function attachListener(msg, listener) {
16065
+ var attached = msg.__onFinished;
16066
+ if (!attached || !attached.queue) {
16067
+ attached = msg.__onFinished = createListener(msg);
16068
+ attachFinishedListener(msg, attached);
16051
16069
  }
16070
+ attached.queue.push(listener);
16052
16071
  }
16053
- return read_1;
16072
+ function createListener(msg) {
16073
+ function listener(err) {
16074
+ if (msg.__onFinished === listener) msg.__onFinished = null;
16075
+ if (!listener.queue) return;
16076
+ var queue2 = listener.queue;
16077
+ listener.queue = null;
16078
+ for (var i = 0; i < queue2.length; i++) {
16079
+ queue2[i](err, msg);
16080
+ }
16081
+ }
16082
+ listener.queue = [];
16083
+ return listener;
16084
+ }
16085
+ function patchAssignSocket(res, callback) {
16086
+ var assignSocket = res.assignSocket;
16087
+ if (typeof assignSocket !== "function") return;
16088
+ res.assignSocket = function _assignSocket(socket) {
16089
+ assignSocket.call(this, socket);
16090
+ callback(socket);
16091
+ };
16092
+ }
16093
+ function tryRequireAsyncHooks() {
16094
+ try {
16095
+ return require("async_hooks");
16096
+ } catch (e) {
16097
+ return {};
16098
+ }
16099
+ }
16100
+ function wrap(fn) {
16101
+ var res;
16102
+ if (asyncHooks.AsyncResource) {
16103
+ res = new asyncHooks.AsyncResource(fn.name || "bound-anonymous-fn");
16104
+ }
16105
+ if (!res || !res.runInAsyncScope) {
16106
+ return fn;
16107
+ }
16108
+ return res.runInAsyncScope.bind(res, fn, null);
16109
+ }
16110
+ return onFinished.exports;
16054
16111
  }
16055
16112
  var typeIs = { exports: {} };
16056
16113
  var contentType = {};
@@ -16158,7 +16215,7 @@ function requireContentType() {
16158
16215
  return contentType;
16159
16216
  }
16160
16217
  var mimeTypes = {};
16161
- const require$$0$1 = {
16218
+ const require$$0 = {
16162
16219
  "application/1d-interleaved-parityfec": { "source": "iana" },
16163
16220
  "application/3gpdash-qoe-report+xml": { "source": "iana", "charset": "UTF-8", "compressible": true },
16164
16221
  "application/3gpp-ims+xml": { "source": "iana", "compressible": true },
@@ -18687,7 +18744,7 @@ var hasRequiredMimeDb;
18687
18744
  function requireMimeDb() {
18688
18745
  if (hasRequiredMimeDb) return mimeDb;
18689
18746
  hasRequiredMimeDb = 1;
18690
- mimeDb = require$$0$1;
18747
+ mimeDb = require$$0;
18691
18748
  return mimeDb;
18692
18749
  }
18693
18750
  var mimeScore;
@@ -18715,6 +18772,10 @@ function requireMimeScore() {
18715
18772
  application: 1,
18716
18773
  // prefer font/woff over application/font-woff
18717
18774
  font: 2,
18775
+ // prefer video/mp4 over audio/mp4 over application/mp4
18776
+ // See https://www.rfc-editor.org/rfc/rfc4337.html#section-2
18777
+ audio: 2,
18778
+ video: 3,
18718
18779
  default: 0
18719
18780
  };
18720
18781
  mimeScore = function mimeScore2(mimeType, source2 = "default") {
@@ -19011,7 +19072,8 @@ function requireUtils$2() {
19011
19072
  var typeis = requireTypeIs();
19012
19073
  utils$2 = {
19013
19074
  getCharset,
19014
- normalizeOptions
19075
+ normalizeOptions,
19076
+ passthrough
19015
19077
  };
19016
19078
  function getCharset(req) {
19017
19079
  try {
@@ -19033,6 +19095,7 @@ function requireUtils$2() {
19033
19095
  var limit = typeof options?.limit !== "number" ? bytes2.parse(options?.limit || "100kb") : options?.limit;
19034
19096
  var type2 = options?.type || defaultType;
19035
19097
  var verify = options?.verify || false;
19098
+ var defaultCharset = options?.defaultCharset || "utf-8";
19036
19099
  if (verify !== false && typeof verify !== "function") {
19037
19100
  throw new TypeError("option verify must be function");
19038
19101
  }
@@ -19041,28 +19104,187 @@ function requireUtils$2() {
19041
19104
  inflate,
19042
19105
  limit,
19043
19106
  verify,
19107
+ defaultCharset,
19044
19108
  shouldParse
19045
19109
  };
19046
19110
  }
19111
+ function passthrough(value) {
19112
+ return value;
19113
+ }
19047
19114
  return utils$2;
19048
19115
  }
19116
+ var read_1;
19117
+ var hasRequiredRead;
19118
+ function requireRead() {
19119
+ if (hasRequiredRead) return read_1;
19120
+ hasRequiredRead = 1;
19121
+ var createError = requireHttpErrors();
19122
+ var getBody = requireRawBody();
19123
+ var iconv = requireLib$2();
19124
+ var onFinished2 = requireOnFinished();
19125
+ var zlib = require$$4$1;
19126
+ var hasBody = requireTypeIs().hasBody;
19127
+ var { getCharset } = requireUtils$2();
19128
+ read_1 = read2;
19129
+ function read2(req, res, next, parse3, debug, options) {
19130
+ if (onFinished2.isFinished(req)) {
19131
+ debug("body already parsed");
19132
+ next();
19133
+ return;
19134
+ }
19135
+ if (!("body" in req)) {
19136
+ req.body = void 0;
19137
+ }
19138
+ if (!hasBody(req)) {
19139
+ debug("skip empty body");
19140
+ next();
19141
+ return;
19142
+ }
19143
+ debug("content-type %j", req.headers["content-type"]);
19144
+ if (!options.shouldParse(req)) {
19145
+ debug("skip parsing");
19146
+ next();
19147
+ return;
19148
+ }
19149
+ var encoding2 = null;
19150
+ if (options?.skipCharset !== true) {
19151
+ encoding2 = getCharset(req) || options.defaultCharset;
19152
+ if (!!options?.isValidCharset && !options.isValidCharset(encoding2)) {
19153
+ debug("invalid charset");
19154
+ next(createError(415, 'unsupported charset "' + encoding2.toUpperCase() + '"', {
19155
+ charset: encoding2,
19156
+ type: "charset.unsupported"
19157
+ }));
19158
+ return;
19159
+ }
19160
+ }
19161
+ var length;
19162
+ var opts = options;
19163
+ var stream;
19164
+ var verify = opts.verify;
19165
+ try {
19166
+ stream = contentstream(req, debug, opts.inflate);
19167
+ length = stream.length;
19168
+ stream.length = void 0;
19169
+ } catch (err) {
19170
+ return next(err);
19171
+ }
19172
+ opts.length = length;
19173
+ opts.encoding = verify ? null : encoding2;
19174
+ if (opts.encoding === null && encoding2 !== null && !iconv.encodingExists(encoding2)) {
19175
+ return next(createError(415, 'unsupported charset "' + encoding2.toUpperCase() + '"', {
19176
+ charset: encoding2.toLowerCase(),
19177
+ type: "charset.unsupported"
19178
+ }));
19179
+ }
19180
+ debug("read body");
19181
+ getBody(stream, opts, function(error2, body) {
19182
+ if (error2) {
19183
+ var _error;
19184
+ if (error2.type === "encoding.unsupported") {
19185
+ _error = createError(415, 'unsupported charset "' + encoding2.toUpperCase() + '"', {
19186
+ charset: encoding2.toLowerCase(),
19187
+ type: "charset.unsupported"
19188
+ });
19189
+ } else {
19190
+ _error = createError(400, error2);
19191
+ }
19192
+ if (stream !== req) {
19193
+ req.unpipe();
19194
+ stream.destroy();
19195
+ }
19196
+ dump(req, function onfinished() {
19197
+ next(createError(400, _error));
19198
+ });
19199
+ return;
19200
+ }
19201
+ if (verify) {
19202
+ try {
19203
+ debug("verify body");
19204
+ verify(req, res, body, encoding2);
19205
+ } catch (err) {
19206
+ next(createError(403, err, {
19207
+ body,
19208
+ type: err.type || "entity.verify.failed"
19209
+ }));
19210
+ return;
19211
+ }
19212
+ }
19213
+ var str = body;
19214
+ try {
19215
+ debug("parse body");
19216
+ str = typeof body !== "string" && encoding2 !== null ? iconv.decode(body, encoding2) : body;
19217
+ req.body = parse3(str, encoding2);
19218
+ } catch (err) {
19219
+ next(createError(400, err, {
19220
+ body: str,
19221
+ type: err.type || "entity.parse.failed"
19222
+ }));
19223
+ return;
19224
+ }
19225
+ next();
19226
+ });
19227
+ }
19228
+ function contentstream(req, debug, inflate) {
19229
+ var encoding2 = (req.headers["content-encoding"] || "identity").toLowerCase();
19230
+ var length = req.headers["content-length"];
19231
+ debug('content-encoding "%s"', encoding2);
19232
+ if (inflate === false && encoding2 !== "identity") {
19233
+ throw createError(415, "content encoding unsupported", {
19234
+ encoding: encoding2,
19235
+ type: "encoding.unsupported"
19236
+ });
19237
+ }
19238
+ if (encoding2 === "identity") {
19239
+ req.length = length;
19240
+ return req;
19241
+ }
19242
+ var stream = createDecompressionStream(encoding2, debug);
19243
+ req.pipe(stream);
19244
+ return stream;
19245
+ }
19246
+ function createDecompressionStream(encoding2, debug) {
19247
+ switch (encoding2) {
19248
+ case "deflate":
19249
+ debug("inflate body");
19250
+ return zlib.createInflate();
19251
+ case "gzip":
19252
+ debug("gunzip body");
19253
+ return zlib.createGunzip();
19254
+ case "br":
19255
+ debug("brotli decompress body");
19256
+ return zlib.createBrotliDecompress();
19257
+ default:
19258
+ throw createError(415, 'unsupported content encoding "' + encoding2 + '"', {
19259
+ encoding: encoding2,
19260
+ type: "encoding.unsupported"
19261
+ });
19262
+ }
19263
+ }
19264
+ function dump(req, callback) {
19265
+ if (onFinished2.isFinished(req)) {
19266
+ callback(null);
19267
+ } else {
19268
+ onFinished2(req, callback);
19269
+ req.resume();
19270
+ }
19271
+ }
19272
+ return read_1;
19273
+ }
19049
19274
  var json_1;
19050
19275
  var hasRequiredJson;
19051
19276
  function requireJson() {
19052
19277
  if (hasRequiredJson) return json_1;
19053
19278
  hasRequiredJson = 1;
19054
- var createError = requireHttpErrors();
19055
- var debug = require$$0$7("body-parser:json");
19056
- var isFinished = requireOnFinished().isFinished;
19279
+ var debug = require$$0$6("body-parser:json");
19057
19280
  var read2 = requireRead();
19058
- var typeis = requireTypeIs();
19059
- var { getCharset, normalizeOptions } = requireUtils$2();
19281
+ var { normalizeOptions } = requireUtils$2();
19060
19282
  json_1 = json2;
19061
19283
  var FIRST_CHAR_REGEXP = /^[\x20\x09\x0a\x0d]*([^\x20\x09\x0a\x0d])/;
19062
19284
  var JSON_SYNTAX_CHAR = "#";
19063
19285
  var JSON_SYNTAX_REGEXP = /#+/g;
19064
19286
  function json2(options) {
19065
- var { inflate, limit, verify, shouldParse } = normalizeOptions(options, "application/json");
19287
+ const normalizedOptions = normalizeOptions(options, "application/json");
19066
19288
  var reviver = options?.reviver;
19067
19289
  var strict = options?.strict !== false;
19068
19290
  function parse3(body) {
@@ -19086,41 +19308,13 @@ function requireJson() {
19086
19308
  });
19087
19309
  }
19088
19310
  }
19311
+ const readOptions = {
19312
+ ...normalizedOptions,
19313
+ // assert charset per RFC 7159 sec 8.1
19314
+ isValidCharset: (charset2) => charset2.slice(0, 4) === "utf-"
19315
+ };
19089
19316
  return function jsonParser(req, res, next) {
19090
- if (isFinished(req)) {
19091
- debug("body already parsed");
19092
- next();
19093
- return;
19094
- }
19095
- if (!("body" in req)) {
19096
- req.body = void 0;
19097
- }
19098
- if (!typeis.hasBody(req)) {
19099
- debug("skip empty body");
19100
- next();
19101
- return;
19102
- }
19103
- debug("content-type %j", req.headers["content-type"]);
19104
- if (!shouldParse(req)) {
19105
- debug("skip parsing");
19106
- next();
19107
- return;
19108
- }
19109
- var charset2 = getCharset(req) || "utf-8";
19110
- if (charset2.slice(0, 4) !== "utf-") {
19111
- debug("invalid charset");
19112
- next(createError(415, 'unsupported charset "' + charset2.toUpperCase() + '"', {
19113
- charset: charset2,
19114
- type: "charset.unsupported"
19115
- }));
19116
- return;
19117
- }
19118
- read2(req, res, next, parse3, debug, {
19119
- encoding: charset2,
19120
- inflate,
19121
- limit,
19122
- verify
19123
- });
19317
+ read2(req, res, next, parse3, debug, readOptions);
19124
19318
  };
19125
19319
  }
19126
19320
  function createStrictSyntaxError(str, char) {
@@ -19167,43 +19361,19 @@ var hasRequiredRaw;
19167
19361
  function requireRaw() {
19168
19362
  if (hasRequiredRaw) return raw_1;
19169
19363
  hasRequiredRaw = 1;
19170
- var debug = require$$0$7("body-parser:raw");
19171
- var isFinished = requireOnFinished().isFinished;
19364
+ var debug = require$$0$6("body-parser:raw");
19172
19365
  var read2 = requireRead();
19173
- var typeis = requireTypeIs();
19174
- var { normalizeOptions } = requireUtils$2();
19366
+ var { normalizeOptions, passthrough } = requireUtils$2();
19175
19367
  raw_1 = raw;
19176
19368
  function raw(options) {
19177
- var { inflate, limit, verify, shouldParse } = normalizeOptions(options, "application/octet-stream");
19178
- function parse3(buf) {
19179
- return buf;
19180
- }
19369
+ const normalizedOptions = normalizeOptions(options, "application/octet-stream");
19370
+ const readOptions = {
19371
+ ...normalizedOptions,
19372
+ // Skip charset validation and parse the body as is
19373
+ skipCharset: true
19374
+ };
19181
19375
  return function rawParser(req, res, next) {
19182
- if (isFinished(req)) {
19183
- debug("body already parsed");
19184
- next();
19185
- return;
19186
- }
19187
- if (!("body" in req)) {
19188
- req.body = void 0;
19189
- }
19190
- if (!typeis.hasBody(req)) {
19191
- debug("skip empty body");
19192
- next();
19193
- return;
19194
- }
19195
- debug("content-type %j", req.headers["content-type"]);
19196
- if (!shouldParse(req)) {
19197
- debug("skip parsing");
19198
- next();
19199
- return;
19200
- }
19201
- read2(req, res, next, parse3, debug, {
19202
- encoding: null,
19203
- inflate,
19204
- limit,
19205
- verify
19206
- });
19376
+ read2(req, res, next, passthrough, debug, readOptions);
19207
19377
  };
19208
19378
  }
19209
19379
  return raw_1;
@@ -19213,45 +19383,14 @@ var hasRequiredText;
19213
19383
  function requireText() {
19214
19384
  if (hasRequiredText) return text_1;
19215
19385
  hasRequiredText = 1;
19216
- var debug = require$$0$7("body-parser:text");
19217
- var isFinished = requireOnFinished().isFinished;
19386
+ var debug = require$$0$6("body-parser:text");
19218
19387
  var read2 = requireRead();
19219
- var typeis = requireTypeIs();
19220
- var { getCharset, normalizeOptions } = requireUtils$2();
19388
+ var { normalizeOptions, passthrough } = requireUtils$2();
19221
19389
  text_1 = text;
19222
19390
  function text(options) {
19223
- var { inflate, limit, verify, shouldParse } = normalizeOptions(options, "text/plain");
19224
- var defaultCharset = options?.defaultCharset || "utf-8";
19225
- function parse3(buf) {
19226
- return buf;
19227
- }
19391
+ const normalizedOptions = normalizeOptions(options, "text/plain");
19228
19392
  return function textParser(req, res, next) {
19229
- if (isFinished(req)) {
19230
- debug("body already parsed");
19231
- next();
19232
- return;
19233
- }
19234
- if (!("body" in req)) {
19235
- req.body = void 0;
19236
- }
19237
- if (!typeis.hasBody(req)) {
19238
- debug("skip empty body");
19239
- next();
19240
- return;
19241
- }
19242
- debug("content-type %j", req.headers["content-type"]);
19243
- if (!shouldParse(req)) {
19244
- debug("skip parsing");
19245
- next();
19246
- return;
19247
- }
19248
- var charset2 = getCharset(req) || defaultCharset;
19249
- read2(req, res, next, parse3, debug, {
19250
- encoding: charset2,
19251
- inflate,
19252
- limit,
19253
- verify
19254
- });
19393
+ read2(req, res, next, passthrough, debug, normalizedOptions);
19255
19394
  };
19256
19395
  }
19257
19396
  return text_1;
@@ -19855,7 +19994,7 @@ function requireGetIntrinsic() {
19855
19994
  var throwTypeError = function() {
19856
19995
  throw new $TypeError();
19857
19996
  };
19858
- var ThrowTypeError = $gOPD ? function() {
19997
+ var ThrowTypeError = $gOPD ? (function() {
19859
19998
  try {
19860
19999
  arguments.callee;
19861
20000
  return throwTypeError;
@@ -19866,7 +20005,7 @@ function requireGetIntrinsic() {
19866
20005
  return throwTypeError;
19867
20006
  }
19868
20007
  }
19869
- }() : throwTypeError;
20008
+ })() : throwTypeError;
19870
20009
  var hasSymbols2 = requireHasSymbols()();
19871
20010
  var getProto2 = requireGetProto();
19872
20011
  var $ObjectGPO = requireObject_getPrototypeOf();
@@ -20377,13 +20516,13 @@ function requireUtils$1() {
20377
20516
  var formats2 = /* @__PURE__ */ requireFormats();
20378
20517
  var has = Object.prototype.hasOwnProperty;
20379
20518
  var isArray = Array.isArray;
20380
- var hexTable = function() {
20519
+ var hexTable = (function() {
20381
20520
  var array2 = [];
20382
20521
  for (var i = 0; i < 256; ++i) {
20383
20522
  array2.push("%" + ((i < 16 ? "0" : "") + i.toString(16)).toUpperCase());
20384
20523
  }
20385
20524
  return array2;
20386
- }();
20525
+ })();
20387
20526
  var compactQueue = function compactQueue2(queue2) {
20388
20527
  while (queue2.length > 1) {
20389
20528
  var item = queue2.pop();
@@ -21129,58 +21268,27 @@ function requireUrlencoded() {
21129
21268
  if (hasRequiredUrlencoded) return urlencoded_1;
21130
21269
  hasRequiredUrlencoded = 1;
21131
21270
  var createError = requireHttpErrors();
21132
- var debug = require$$0$7("body-parser:urlencoded");
21133
- var isFinished = requireOnFinished().isFinished;
21271
+ var debug = require$$0$6("body-parser:urlencoded");
21134
21272
  var read2 = requireRead();
21135
- var typeis = requireTypeIs();
21136
21273
  var qs = /* @__PURE__ */ requireLib$1();
21137
- var { getCharset, normalizeOptions } = requireUtils$2();
21274
+ var { normalizeOptions } = requireUtils$2();
21138
21275
  urlencoded_1 = urlencoded;
21139
21276
  function urlencoded(options) {
21140
- var { inflate, limit, verify, shouldParse } = normalizeOptions(options, "application/x-www-form-urlencoded");
21141
- var defaultCharset = options?.defaultCharset || "utf-8";
21142
- if (defaultCharset !== "utf-8" && defaultCharset !== "iso-8859-1") {
21277
+ const normalizedOptions = normalizeOptions(options, "application/x-www-form-urlencoded");
21278
+ if (normalizedOptions.defaultCharset !== "utf-8" && normalizedOptions.defaultCharset !== "iso-8859-1") {
21143
21279
  throw new TypeError("option defaultCharset must be either utf-8 or iso-8859-1");
21144
21280
  }
21145
21281
  var queryparse = createQueryParser(options);
21146
21282
  function parse3(body, encoding2) {
21147
21283
  return body.length ? queryparse(body, encoding2) : {};
21148
21284
  }
21285
+ const readOptions = {
21286
+ ...normalizedOptions,
21287
+ // assert charset
21288
+ isValidCharset: (charset2) => charset2 === "utf-8" || charset2 === "iso-8859-1"
21289
+ };
21149
21290
  return function urlencodedParser(req, res, next) {
21150
- if (isFinished(req)) {
21151
- debug("body already parsed");
21152
- next();
21153
- return;
21154
- }
21155
- if (!("body" in req)) {
21156
- req.body = void 0;
21157
- }
21158
- if (!typeis.hasBody(req)) {
21159
- debug("skip empty body");
21160
- next();
21161
- return;
21162
- }
21163
- debug("content-type %j", req.headers["content-type"]);
21164
- if (!shouldParse(req)) {
21165
- debug("skip parsing");
21166
- next();
21167
- return;
21168
- }
21169
- var charset2 = getCharset(req) || defaultCharset;
21170
- if (charset2 !== "utf-8" && charset2 !== "iso-8859-1") {
21171
- debug("invalid charset");
21172
- next(createError(415, 'unsupported charset "' + charset2.toUpperCase() + '"', {
21173
- charset: charset2,
21174
- type: "charset.unsupported"
21175
- }));
21176
- return;
21177
- }
21178
- read2(req, res, next, parse3, debug, {
21179
- encoding: charset2,
21180
- inflate,
21181
- limit,
21182
- verify
21183
- });
21291
+ read2(req, res, next, parse3, debug, readOptions);
21184
21292
  };
21185
21293
  }
21186
21294
  function createQueryParser(options) {
@@ -21231,8 +21339,14 @@ function requireUrlencoded() {
21231
21339
  };
21232
21340
  }
21233
21341
  function parameterCount(body, limit) {
21234
- var len = body.split("&").length;
21235
- return len > limit ? void 0 : len - 1;
21342
+ let count = 0;
21343
+ let index2 = -1;
21344
+ do {
21345
+ count++;
21346
+ if (count > limit) return void 0;
21347
+ index2 = body.indexOf("&", index2 + 1);
21348
+ } while (index2 !== -1);
21349
+ return count;
21236
21350
  }
21237
21351
  return urlencoded_1;
21238
21352
  }
@@ -21359,7 +21473,7 @@ var hasRequiredParseurl;
21359
21473
  function requireParseurl() {
21360
21474
  if (hasRequiredParseurl) return parseurl.exports;
21361
21475
  hasRequiredParseurl = 1;
21362
- var url2 = require$$0$8;
21476
+ var url2 = require$$0$7;
21363
21477
  var parse3 = url2.parse;
21364
21478
  var Url = url2.Url;
21365
21479
  parseurl.exports = parseurl$1;
@@ -21438,148 +21552,12 @@ function requireParseurl() {
21438
21552
  }
21439
21553
  return parseurl.exports;
21440
21554
  }
21441
- const require$$0 = {
21442
- "100": "Continue",
21443
- "101": "Switching Protocols",
21444
- "102": "Processing",
21445
- "103": "Early Hints",
21446
- "200": "OK",
21447
- "201": "Created",
21448
- "202": "Accepted",
21449
- "203": "Non-Authoritative Information",
21450
- "204": "No Content",
21451
- "205": "Reset Content",
21452
- "206": "Partial Content",
21453
- "207": "Multi-Status",
21454
- "208": "Already Reported",
21455
- "226": "IM Used",
21456
- "300": "Multiple Choices",
21457
- "301": "Moved Permanently",
21458
- "302": "Found",
21459
- "303": "See Other",
21460
- "304": "Not Modified",
21461
- "305": "Use Proxy",
21462
- "307": "Temporary Redirect",
21463
- "308": "Permanent Redirect",
21464
- "400": "Bad Request",
21465
- "401": "Unauthorized",
21466
- "402": "Payment Required",
21467
- "403": "Forbidden",
21468
- "404": "Not Found",
21469
- "405": "Method Not Allowed",
21470
- "406": "Not Acceptable",
21471
- "407": "Proxy Authentication Required",
21472
- "408": "Request Timeout",
21473
- "409": "Conflict",
21474
- "410": "Gone",
21475
- "411": "Length Required",
21476
- "412": "Precondition Failed",
21477
- "413": "Payload Too Large",
21478
- "414": "URI Too Long",
21479
- "415": "Unsupported Media Type",
21480
- "416": "Range Not Satisfiable",
21481
- "417": "Expectation Failed",
21482
- "418": "I'm a Teapot",
21483
- "421": "Misdirected Request",
21484
- "422": "Unprocessable Entity",
21485
- "423": "Locked",
21486
- "424": "Failed Dependency",
21487
- "425": "Too Early",
21488
- "426": "Upgrade Required",
21489
- "428": "Precondition Required",
21490
- "429": "Too Many Requests",
21491
- "431": "Request Header Fields Too Large",
21492
- "451": "Unavailable For Legal Reasons",
21493
- "500": "Internal Server Error",
21494
- "501": "Not Implemented",
21495
- "502": "Bad Gateway",
21496
- "503": "Service Unavailable",
21497
- "504": "Gateway Timeout",
21498
- "505": "HTTP Version Not Supported",
21499
- "506": "Variant Also Negotiates",
21500
- "507": "Insufficient Storage",
21501
- "508": "Loop Detected",
21502
- "509": "Bandwidth Limit Exceeded",
21503
- "510": "Not Extended",
21504
- "511": "Network Authentication Required"
21505
- };
21506
- var statuses;
21507
- var hasRequiredStatuses;
21508
- function requireStatuses() {
21509
- if (hasRequiredStatuses) return statuses;
21510
- hasRequiredStatuses = 1;
21511
- var codes = require$$0;
21512
- statuses = status;
21513
- status.message = codes;
21514
- status.code = createMessageToStatusCodeMap(codes);
21515
- status.codes = createStatusCodeList(codes);
21516
- status.redirect = {
21517
- 300: true,
21518
- 301: true,
21519
- 302: true,
21520
- 303: true,
21521
- 305: true,
21522
- 307: true,
21523
- 308: true
21524
- };
21525
- status.empty = {
21526
- 204: true,
21527
- 205: true,
21528
- 304: true
21529
- };
21530
- status.retry = {
21531
- 502: true,
21532
- 503: true,
21533
- 504: true
21534
- };
21535
- function createMessageToStatusCodeMap(codes2) {
21536
- var map2 = {};
21537
- Object.keys(codes2).forEach(function forEachCode(code) {
21538
- var message = codes2[code];
21539
- var status2 = Number(code);
21540
- map2[message.toLowerCase()] = status2;
21541
- });
21542
- return map2;
21543
- }
21544
- function createStatusCodeList(codes2) {
21545
- return Object.keys(codes2).map(function mapCode(code) {
21546
- return Number(code);
21547
- });
21548
- }
21549
- function getStatusCode(message) {
21550
- var msg = message.toLowerCase();
21551
- if (!Object.prototype.hasOwnProperty.call(status.code, msg)) {
21552
- throw new Error('invalid status message: "' + message + '"');
21553
- }
21554
- return status.code[msg];
21555
- }
21556
- function getStatusMessage(code) {
21557
- if (!Object.prototype.hasOwnProperty.call(status.message, code)) {
21558
- throw new Error("invalid status code: " + code);
21559
- }
21560
- return status.message[code];
21561
- }
21562
- function status(code) {
21563
- if (typeof code === "number") {
21564
- return getStatusMessage(code);
21565
- }
21566
- if (typeof code !== "string") {
21567
- throw new TypeError("code must be a number or string");
21568
- }
21569
- var n = parseInt(code, 10);
21570
- if (!isNaN(n)) {
21571
- return getStatusMessage(n);
21572
- }
21573
- return getStatusCode(code);
21574
- }
21575
- return statuses;
21576
- }
21577
21555
  var finalhandler_1;
21578
21556
  var hasRequiredFinalhandler;
21579
21557
  function requireFinalhandler() {
21580
21558
  if (hasRequiredFinalhandler) return finalhandler_1;
21581
21559
  hasRequiredFinalhandler = 1;
21582
- var debug = require$$0$7("finalhandler");
21560
+ var debug = require$$0$6("finalhandler");
21583
21561
  var encodeUrl = requireEncodeurl();
21584
21562
  var escapeHtml = requireEscapeHtml();
21585
21563
  var onFinished2 = requireOnFinished();
@@ -21706,7 +21684,7 @@ var hasRequiredView;
21706
21684
  function requireView() {
21707
21685
  if (hasRequiredView) return view;
21708
21686
  hasRequiredView = 1;
21709
- var debug = require$$0$7("express:view");
21687
+ var debug = require$$0$6("express:view");
21710
21688
  var path2 = path__default;
21711
21689
  var fs2 = fs__default;
21712
21690
  var dirname = path2.dirname;
@@ -21802,8 +21780,8 @@ function requireEtag() {
21802
21780
  if (hasRequiredEtag) return etag_1;
21803
21781
  hasRequiredEtag = 1;
21804
21782
  etag_1 = etag;
21805
- var crypto2 = require$$0$9;
21806
- var Stats = require$$0$4.Stats;
21783
+ var crypto2 = require$$0$8;
21784
+ var Stats = require$$0$3.Stats;
21807
21785
  var toString = Object.prototype.toString;
21808
21786
  function entitytag(entity) {
21809
21787
  if (entity.length === 0) {
@@ -21942,7 +21920,7 @@ function requireIpaddr() {
21942
21920
  }
21943
21921
  return defaultName;
21944
21922
  };
21945
- ipaddr2.IPv4 = function() {
21923
+ ipaddr2.IPv4 = (function() {
21946
21924
  function IPv4(octets) {
21947
21925
  var k, len, octet;
21948
21926
  if (octets.length !== 4) {
@@ -22027,7 +22005,7 @@ function requireIpaddr() {
22027
22005
  return 32 - cidr;
22028
22006
  };
22029
22007
  return IPv4;
22030
- }();
22008
+ })();
22031
22009
  ipv4Part = "(0?\\d+|0x[a-f0-9]+)";
22032
22010
  ipv4Regexes = {
22033
22011
  fourOctet: new RegExp("^" + ipv4Part + "\\." + ipv4Part + "\\." + ipv4Part + "\\." + ipv4Part + "$", "i"),
@@ -22043,7 +22021,7 @@ function requireIpaddr() {
22043
22021
  }
22044
22022
  };
22045
22023
  if (match = string2.match(ipv4Regexes.fourOctet)) {
22046
- return function() {
22024
+ return (function() {
22047
22025
  var k, len, ref2, results;
22048
22026
  ref2 = match.slice(1, 6);
22049
22027
  results = [];
@@ -22052,25 +22030,25 @@ function requireIpaddr() {
22052
22030
  results.push(parseIntAuto(part));
22053
22031
  }
22054
22032
  return results;
22055
- }();
22033
+ })();
22056
22034
  } else if (match = string2.match(ipv4Regexes.longValue)) {
22057
22035
  value = parseIntAuto(match[1]);
22058
22036
  if (value > 4294967295 || value < 0) {
22059
22037
  throw new Error("ipaddr: address outside defined range");
22060
22038
  }
22061
- return function() {
22039
+ return (function() {
22062
22040
  var k, results;
22063
22041
  results = [];
22064
22042
  for (shift = k = 0; k <= 24; shift = k += 8) {
22065
22043
  results.push(value >> shift & 255);
22066
22044
  }
22067
22045
  return results;
22068
- }().reverse();
22046
+ })().reverse();
22069
22047
  } else {
22070
22048
  return null;
22071
22049
  }
22072
22050
  };
22073
- ipaddr2.IPv6 = function() {
22051
+ ipaddr2.IPv6 = (function() {
22074
22052
  function IPv6(parts, zoneId) {
22075
22053
  var i, k, l, len, part, ref2;
22076
22054
  if (parts.length === 16) {
@@ -22130,7 +22108,7 @@ function requireIpaddr() {
22130
22108
  };
22131
22109
  IPv6.prototype.toNormalizedString = function() {
22132
22110
  var addr, part, suffix;
22133
- addr = function() {
22111
+ addr = (function() {
22134
22112
  var k, len, ref2, results;
22135
22113
  ref2 = this.parts;
22136
22114
  results = [];
@@ -22139,7 +22117,7 @@ function requireIpaddr() {
22139
22117
  results.push(part.toString(16));
22140
22118
  }
22141
22119
  return results;
22142
- }.call(this).join(":");
22120
+ }).call(this).join(":");
22143
22121
  suffix = "";
22144
22122
  if (this.zoneId) {
22145
22123
  suffix = "%" + this.zoneId;
@@ -22148,7 +22126,7 @@ function requireIpaddr() {
22148
22126
  };
22149
22127
  IPv6.prototype.toFixedLengthString = function() {
22150
22128
  var addr, part, suffix;
22151
- addr = function() {
22129
+ addr = (function() {
22152
22130
  var k, len, ref2, results;
22153
22131
  ref2 = this.parts;
22154
22132
  results = [];
@@ -22157,7 +22135,7 @@ function requireIpaddr() {
22157
22135
  results.push(part.toString(16).padStart(4, "0"));
22158
22136
  }
22159
22137
  return results;
22160
- }.call(this).join(":");
22138
+ }).call(this).join(":");
22161
22139
  suffix = "";
22162
22140
  if (this.zoneId) {
22163
22141
  suffix = "%" + this.zoneId;
@@ -22242,7 +22220,7 @@ function requireIpaddr() {
22242
22220
  return 128 - cidr;
22243
22221
  };
22244
22222
  return IPv6;
22245
- }();
22223
+ })();
22246
22224
  ipv6Part = "(?:[0-9a-f]+::?)+";
22247
22225
  zoneIndex = "%[0-9a-z]{1,}";
22248
22226
  ipv6Regexes = {
@@ -22286,7 +22264,7 @@ function requireIpaddr() {
22286
22264
  if (string2[string2.length - 1] === ":") {
22287
22265
  string2 = string2.slice(0, -1);
22288
22266
  }
22289
- parts = function() {
22267
+ parts = (function() {
22290
22268
  var k, len, ref2, results;
22291
22269
  ref2 = string2.split(":");
22292
22270
  results = [];
@@ -22295,7 +22273,7 @@ function requireIpaddr() {
22295
22273
  results.push(parseInt(part, 16));
22296
22274
  }
22297
22275
  return results;
22298
- }();
22276
+ })();
22299
22277
  return {
22300
22278
  parts,
22301
22279
  zoneId
@@ -22674,6 +22652,7 @@ function requireUtils() {
22674
22652
  var proxyaddr = requireProxyAddr();
22675
22653
  var qs = /* @__PURE__ */ requireLib$1();
22676
22654
  var querystring = require$$6$1;
22655
+ const { Buffer: Buffer2 } = require$$7$1;
22677
22656
  exports$1.methods = METHODS.map((method) => method.toLowerCase());
22678
22657
  exports$1.etag = createETagGenerator({ weak: false });
22679
22658
  exports$1.wetag = createETagGenerator({ weak: true });
@@ -22777,7 +22756,7 @@ function requireUtils() {
22777
22756
  };
22778
22757
  function createETagGenerator(options) {
22779
22758
  return function generateETag(body, encoding2) {
22780
- var buf = !Buffer.isBuffer(body) ? Buffer.from(body, encoding2) : body;
22759
+ var buf = !Buffer2.isBuffer(body) ? Buffer2.from(body, encoding2) : body;
22781
22760
  return etag(buf, options);
22782
22761
  };
22783
22762
  }
@@ -22884,7 +22863,7 @@ function requireDist() {
22884
22863
  if (hasRequiredDist) return dist;
22885
22864
  hasRequiredDist = 1;
22886
22865
  Object.defineProperty(dist, "__esModule", { value: true });
22887
- dist.TokenData = void 0;
22866
+ dist.PathError = dist.TokenData = void 0;
22888
22867
  dist.parse = parse3;
22889
22868
  dist.compile = compile;
22890
22869
  dist.match = match;
@@ -22894,7 +22873,6 @@ function requireDist() {
22894
22873
  const NOOP_VALUE = (value) => value;
22895
22874
  const ID_START = /^[$_\p{ID_Start}]$/u;
22896
22875
  const ID_CONTINUE = /^[$\u200c\u200d\p{ID_Continue}]$/u;
22897
- const DEBUG_URL = "https://git.new/pathToRegexpError";
22898
22876
  const SIMPLE_TOKENS = {
22899
22877
  // Groups.
22900
22878
  "{": "{",
@@ -22909,149 +22887,123 @@ function requireDist() {
22909
22887
  "!": "!"
22910
22888
  };
22911
22889
  function escapeText(str) {
22912
- return str.replace(/[{}()\[\]+?!:*]/g, "\\$&");
22890
+ return str.replace(/[{}()\[\]+?!:*\\]/g, "\\$&");
22913
22891
  }
22914
22892
  function escape2(str) {
22915
22893
  return str.replace(/[.+*?^${}()[\]|/\\]/g, "\\$&");
22916
22894
  }
22917
- function* lexer(str) {
22895
+ class TokenData {
22896
+ constructor(tokens, originalPath) {
22897
+ this.tokens = tokens;
22898
+ this.originalPath = originalPath;
22899
+ }
22900
+ }
22901
+ dist.TokenData = TokenData;
22902
+ class PathError extends TypeError {
22903
+ constructor(message, originalPath) {
22904
+ let text = message;
22905
+ if (originalPath)
22906
+ text += `: ${originalPath}`;
22907
+ text += `; visit https://git.new/pathToRegexpError for info`;
22908
+ super(text);
22909
+ this.originalPath = originalPath;
22910
+ }
22911
+ }
22912
+ dist.PathError = PathError;
22913
+ function parse3(str, options = {}) {
22914
+ const { encodePath = NOOP_VALUE } = options;
22918
22915
  const chars = [...str];
22919
- let i = 0;
22916
+ const tokens = [];
22917
+ let index2 = 0;
22918
+ let pos2 = 0;
22920
22919
  function name() {
22921
22920
  let value = "";
22922
- if (ID_START.test(chars[++i])) {
22923
- value += chars[i];
22924
- while (ID_CONTINUE.test(chars[++i])) {
22925
- value += chars[i];
22926
- }
22927
- } else if (chars[i] === '"') {
22928
- let pos2 = i;
22929
- while (i < chars.length) {
22930
- if (chars[++i] === '"') {
22931
- i++;
22932
- pos2 = 0;
22921
+ if (ID_START.test(chars[index2])) {
22922
+ do {
22923
+ value += chars[index2++];
22924
+ } while (ID_CONTINUE.test(chars[index2]));
22925
+ } else if (chars[index2] === '"') {
22926
+ let quoteStart = index2;
22927
+ while (index2++ < chars.length) {
22928
+ if (chars[index2] === '"') {
22929
+ index2++;
22930
+ quoteStart = 0;
22933
22931
  break;
22934
22932
  }
22935
- if (chars[i] === "\\") {
22936
- value += chars[++i];
22937
- } else {
22938
- value += chars[i];
22939
- }
22933
+ if (chars[index2] === "\\")
22934
+ index2++;
22935
+ value += chars[index2];
22940
22936
  }
22941
- if (pos2) {
22942
- throw new TypeError(`Unterminated quote at ${pos2}: ${DEBUG_URL}`);
22937
+ if (quoteStart) {
22938
+ throw new PathError(`Unterminated quote at index ${quoteStart}`, str);
22943
22939
  }
22944
22940
  }
22945
22941
  if (!value) {
22946
- throw new TypeError(`Missing parameter name at ${i}: ${DEBUG_URL}`);
22942
+ throw new PathError(`Missing parameter name at index ${index2}`, str);
22947
22943
  }
22948
22944
  return value;
22949
22945
  }
22950
- while (i < chars.length) {
22951
- const value = chars[i];
22946
+ while (index2 < chars.length) {
22947
+ const value = chars[index2];
22952
22948
  const type2 = SIMPLE_TOKENS[value];
22953
22949
  if (type2) {
22954
- yield { type: type2, index: i++, value };
22950
+ tokens.push({ type: type2, index: index2++, value });
22955
22951
  } else if (value === "\\") {
22956
- yield { type: "ESCAPED", index: i++, value: chars[i++] };
22952
+ tokens.push({ type: "escape", index: index2++, value: chars[index2++] });
22957
22953
  } else if (value === ":") {
22958
- const value2 = name();
22959
- yield { type: "PARAM", index: i, value: value2 };
22954
+ tokens.push({ type: "param", index: index2++, value: name() });
22960
22955
  } else if (value === "*") {
22961
- const value2 = name();
22962
- yield { type: "WILDCARD", index: i, value: value2 };
22956
+ tokens.push({ type: "wildcard", index: index2++, value: name() });
22963
22957
  } else {
22964
- yield { type: "CHAR", index: i, value: chars[i++] };
22965
- }
22966
- }
22967
- return { type: "END", index: i, value: "" };
22968
- }
22969
- class Iter {
22970
- constructor(tokens) {
22971
- this.tokens = tokens;
22972
- }
22973
- peek() {
22974
- if (!this._peek) {
22975
- const next = this.tokens.next();
22976
- this._peek = next.value;
22977
- }
22978
- return this._peek;
22979
- }
22980
- tryConsume(type2) {
22981
- const token2 = this.peek();
22982
- if (token2.type !== type2)
22983
- return;
22984
- this._peek = void 0;
22985
- return token2.value;
22986
- }
22987
- consume(type2) {
22988
- const value = this.tryConsume(type2);
22989
- if (value !== void 0)
22990
- return value;
22991
- const { type: nextType, index: index2 } = this.peek();
22992
- throw new TypeError(`Unexpected ${nextType} at ${index2}, expected ${type2}: ${DEBUG_URL}`);
22993
- }
22994
- text() {
22995
- let result = "";
22996
- let value;
22997
- while (value = this.tryConsume("CHAR") || this.tryConsume("ESCAPED")) {
22998
- result += value;
22958
+ tokens.push({ type: "char", index: index2++, value });
22999
22959
  }
23000
- return result;
23001
- }
23002
- }
23003
- class TokenData {
23004
- constructor(tokens) {
23005
- this.tokens = tokens;
23006
22960
  }
23007
- }
23008
- dist.TokenData = TokenData;
23009
- function parse3(str, options = {}) {
23010
- const { encodePath = NOOP_VALUE } = options;
23011
- const it2 = new Iter(lexer(str));
23012
- function consume(endType) {
23013
- const tokens2 = [];
22961
+ tokens.push({ type: "end", index: index2, value: "" });
22962
+ function consumeUntil(endType) {
22963
+ const output2 = [];
23014
22964
  while (true) {
23015
- const path2 = it2.text();
23016
- if (path2)
23017
- tokens2.push({ type: "text", value: encodePath(path2) });
23018
- const param = it2.tryConsume("PARAM");
23019
- if (param) {
23020
- tokens2.push({
23021
- type: "param",
23022
- name: param
22965
+ const token2 = tokens[pos2++];
22966
+ if (token2.type === endType)
22967
+ break;
22968
+ if (token2.type === "char" || token2.type === "escape") {
22969
+ let path2 = token2.value;
22970
+ let cur = tokens[pos2];
22971
+ while (cur.type === "char" || cur.type === "escape") {
22972
+ path2 += cur.value;
22973
+ cur = tokens[++pos2];
22974
+ }
22975
+ output2.push({
22976
+ type: "text",
22977
+ value: encodePath(path2)
23023
22978
  });
23024
22979
  continue;
23025
22980
  }
23026
- const wildcard = it2.tryConsume("WILDCARD");
23027
- if (wildcard) {
23028
- tokens2.push({
23029
- type: "wildcard",
23030
- name: wildcard
22981
+ if (token2.type === "param" || token2.type === "wildcard") {
22982
+ output2.push({
22983
+ type: token2.type,
22984
+ name: token2.value
23031
22985
  });
23032
22986
  continue;
23033
22987
  }
23034
- const open = it2.tryConsume("{");
23035
- if (open) {
23036
- tokens2.push({
22988
+ if (token2.type === "{") {
22989
+ output2.push({
23037
22990
  type: "group",
23038
- tokens: consume("}")
22991
+ tokens: consumeUntil("}")
23039
22992
  });
23040
22993
  continue;
23041
22994
  }
23042
- it2.consume(endType);
23043
- return tokens2;
22995
+ throw new PathError(`Unexpected ${token2.type} at index ${token2.index}, expected ${endType}`, str);
23044
22996
  }
22997
+ return output2;
23045
22998
  }
23046
- const tokens = consume("END");
23047
- return new TokenData(tokens);
22999
+ return new TokenData(consumeUntil("end"), str);
23048
23000
  }
23049
23001
  function compile(path2, options = {}) {
23050
23002
  const { encode: encode2 = encodeURIComponent, delimiter = DEFAULT_DELIMITER } = options;
23051
- const data = path2 instanceof TokenData ? path2 : parse3(path2, options);
23003
+ const data = typeof path2 === "object" ? path2 : parse3(path2, options);
23052
23004
  const fn = tokensToFunction(data.tokens, delimiter, encode2);
23053
- return function path3(data2 = {}) {
23054
- const [path4, ...missing] = fn(data2);
23005
+ return function path3(params = {}) {
23006
+ const [path4, ...missing] = fn(params);
23055
23007
  if (missing.length) {
23056
23008
  throw new TypeError(`Missing parameters: ${missing.join(", ")}`);
23057
23009
  }
@@ -23140,14 +23092,12 @@ function requireDist() {
23140
23092
  function pathToRegexp(path2, options = {}) {
23141
23093
  const { delimiter = DEFAULT_DELIMITER, end = true, sensitive = false, trailing = true } = options;
23142
23094
  const keys = [];
23143
- const sources = [];
23144
23095
  const flags = sensitive ? "" : "i";
23145
- const paths = Array.isArray(path2) ? path2 : [path2];
23146
- const items = paths.map((path3) => path3 instanceof TokenData ? path3 : parse3(path3, options));
23147
- for (const { tokens } of items) {
23148
- for (const seq of flatten2(tokens, 0, [])) {
23149
- const regexp2 = sequenceToRegExp(seq, delimiter, keys);
23150
- sources.push(regexp2);
23096
+ const sources = [];
23097
+ for (const input of pathsToArray(path2, [])) {
23098
+ const data = typeof input === "object" ? input : parse3(input, options);
23099
+ for (const tokens of flatten2(data.tokens, 0, [])) {
23100
+ sources.push(toRegExpSource(tokens, delimiter, keys, data.originalPath));
23151
23101
  }
23152
23102
  }
23153
23103
  let pattern2 = `^(?:${sources.join("|")})`;
@@ -23157,14 +23107,22 @@ function requireDist() {
23157
23107
  const regexp = new RegExp(pattern2, flags);
23158
23108
  return { regexp, keys };
23159
23109
  }
23110
+ function pathsToArray(paths, init2) {
23111
+ if (Array.isArray(paths)) {
23112
+ for (const p of paths)
23113
+ pathsToArray(p, init2);
23114
+ } else {
23115
+ init2.push(paths);
23116
+ }
23117
+ return init2;
23118
+ }
23160
23119
  function* flatten2(tokens, index2, init2) {
23161
23120
  if (index2 === tokens.length) {
23162
23121
  return yield init2;
23163
23122
  }
23164
23123
  const token2 = tokens[index2];
23165
23124
  if (token2.type === "group") {
23166
- const fork = init2.slice();
23167
- for (const seq of flatten2(token2.tokens, 0, fork)) {
23125
+ for (const seq of flatten2(token2.tokens, 0, init2.slice())) {
23168
23126
  yield* flatten2(tokens, index2 + 1, seq);
23169
23127
  }
23170
23128
  } else {
@@ -23172,12 +23130,11 @@ function requireDist() {
23172
23130
  }
23173
23131
  yield* flatten2(tokens, index2 + 1, init2);
23174
23132
  }
23175
- function sequenceToRegExp(tokens, delimiter, keys) {
23133
+ function toRegExpSource(tokens, delimiter, keys, originalPath) {
23176
23134
  let result = "";
23177
23135
  let backtrack = "";
23178
23136
  let isSafeSegmentParam = true;
23179
- for (let i = 0; i < tokens.length; i++) {
23180
- const token2 = tokens[i];
23137
+ for (const token2 of tokens) {
23181
23138
  if (token2.type === "text") {
23182
23139
  result += escape2(token2.value);
23183
23140
  backtrack += token2.value;
@@ -23186,7 +23143,7 @@ function requireDist() {
23186
23143
  }
23187
23144
  if (token2.type === "param" || token2.type === "wildcard") {
23188
23145
  if (!isSafeSegmentParam && !backtrack) {
23189
- throw new TypeError(`Missing text after "${token2.name}": ${DEBUG_URL}`);
23146
+ throw new PathError(`Missing text before "${token2.name}" ${token2.type}`, originalPath);
23190
23147
  }
23191
23148
  if (token2.type === "param") {
23192
23149
  result += `(${negate(delimiter, isSafeSegmentParam ? "" : backtrack)}+)`;
@@ -23212,32 +23169,46 @@ function requireDist() {
23212
23169
  }
23213
23170
  return `(?:(?!${escape2(backtrack)}|${escape2(delimiter)})[\\s\\S])`;
23214
23171
  }
23215
- function stringify3(data) {
23216
- return data.tokens.map(function stringifyToken(token2, index2, tokens) {
23217
- if (token2.type === "text")
23218
- return escapeText(token2.value);
23172
+ function stringifyTokens(tokens) {
23173
+ let value = "";
23174
+ let i = 0;
23175
+ function name(value2) {
23176
+ const isSafe = isNameSafe(value2) && isNextNameSafe(tokens[i]);
23177
+ return isSafe ? value2 : JSON.stringify(value2);
23178
+ }
23179
+ while (i < tokens.length) {
23180
+ const token2 = tokens[i++];
23181
+ if (token2.type === "text") {
23182
+ value += escapeText(token2.value);
23183
+ continue;
23184
+ }
23219
23185
  if (token2.type === "group") {
23220
- return `{${token2.tokens.map(stringifyToken).join("")}}`;
23186
+ value += `{${stringifyTokens(token2.tokens)}}`;
23187
+ continue;
23221
23188
  }
23222
- const isSafe = isNameSafe(token2.name) && isNextNameSafe(tokens[index2 + 1]);
23223
- const key2 = isSafe ? token2.name : JSON.stringify(token2.name);
23224
- if (token2.type === "param")
23225
- return `:${key2}`;
23226
- if (token2.type === "wildcard")
23227
- return `*${key2}`;
23228
- throw new TypeError(`Unexpected token: ${token2}`);
23229
- }).join("");
23189
+ if (token2.type === "param") {
23190
+ value += `:${name(token2.name)}`;
23191
+ continue;
23192
+ }
23193
+ if (token2.type === "wildcard") {
23194
+ value += `*${name(token2.name)}`;
23195
+ continue;
23196
+ }
23197
+ throw new TypeError(`Unknown token type: ${token2.type}`);
23198
+ }
23199
+ return value;
23200
+ }
23201
+ function stringify3(data) {
23202
+ return stringifyTokens(data.tokens);
23230
23203
  }
23231
23204
  function isNameSafe(name) {
23232
23205
  const [first, ...rest] = name;
23233
- if (!ID_START.test(first))
23234
- return false;
23235
- return rest.every((char) => ID_CONTINUE.test(char));
23206
+ return ID_START.test(first) && rest.every((char) => ID_CONTINUE.test(char));
23236
23207
  }
23237
23208
  function isNextNameSafe(token2) {
23238
- if ((token2 === null || token2 === void 0 ? void 0 : token2.type) !== "text")
23239
- return true;
23240
- return !ID_CONTINUE.test(token2.value[0]);
23209
+ if (token2 && token2.type === "text")
23210
+ return !ID_CONTINUE.test(token2.value[0]);
23211
+ return true;
23241
23212
  }
23242
23213
  return dist;
23243
23214
  }
@@ -23248,7 +23219,7 @@ function requireLayer() {
23248
23219
  hasRequiredLayer = 1;
23249
23220
  const isPromise2 = requireIsPromise();
23250
23221
  const pathRegexp = requireDist();
23251
- const debug = require$$0$7("router:layer");
23222
+ const debug = require$$0$6("router:layer");
23252
23223
  const deprecate = requireBrowser()("router");
23253
23224
  const TRAILING_SLASH_REGEXP = /\/+$/;
23254
23225
  const MATCHING_GROUP_REGEXP = /\((?:\?<(.*?)>)?(?!\?)/g;
@@ -23396,7 +23367,7 @@ var hasRequiredRoute;
23396
23367
  function requireRoute() {
23397
23368
  if (hasRequiredRoute) return route;
23398
23369
  hasRequiredRoute = 1;
23399
- const debug = require$$0$7("router:route");
23370
+ const debug = require$$0$6("router:route");
23400
23371
  const Layer = requireLayer();
23401
23372
  const { METHODS } = require$$2$4;
23402
23373
  const slice = Array.prototype.slice;
@@ -23520,7 +23491,7 @@ function requireRouter() {
23520
23491
  const { METHODS } = require$$2$4;
23521
23492
  const parseUrl = requireParseurl();
23522
23493
  const Route = requireRoute();
23523
- const debug = require$$0$7("router");
23494
+ const debug = require$$0$6("router");
23524
23495
  const deprecate = requireBrowser()("router");
23525
23496
  const slice = Array.prototype.slice;
23526
23497
  const flatten2 = Array.prototype.flat;
@@ -23914,7 +23885,7 @@ function requireApplication() {
23914
23885
  hasRequiredApplication = 1;
23915
23886
  (function(module, exports$1) {
23916
23887
  var finalhandler = requireFinalhandler();
23917
- var debug = require$$0$7("express:application");
23888
+ var debug = require$$0$6("express:application");
23918
23889
  var View = requireView();
23919
23890
  var http = require$$2$4;
23920
23891
  var methods2 = requireUtils().methods;
@@ -24150,7 +24121,7 @@ function requireApplication() {
24150
24121
  };
24151
24122
  app.listen = function listen() {
24152
24123
  var server = http.createServer(this);
24153
- var args = Array.prototype.slice.call(arguments);
24124
+ var args = slice.call(arguments);
24154
24125
  if (typeof args[args.length - 1] === "function") {
24155
24126
  var done = args[args.length - 1] = once2(args[args.length - 1]);
24156
24127
  server.once("error", done);
@@ -24960,9 +24931,8 @@ function requireRequest() {
24960
24931
  var accept = accepts2(this);
24961
24932
  return accept.charsets.apply(accept, arguments);
24962
24933
  };
24963
- req.acceptsLanguages = function() {
24964
- var accept = accepts2(this);
24965
- return accept.languages.apply(accept, arguments);
24934
+ req.acceptsLanguages = function(...languages) {
24935
+ return accepts2(this).languages(...languages);
24966
24936
  };
24967
24937
  req.range = function range2(size, options) {
24968
24938
  var range3 = this.get("Range");
@@ -24988,9 +24958,9 @@ function requireRequest() {
24988
24958
  return typeis(this, arr);
24989
24959
  };
24990
24960
  defineGetter(req, "protocol", function protocol() {
24991
- var proto = this.connection.encrypted ? "https" : "http";
24961
+ var proto = this.socket.encrypted ? "https" : "http";
24992
24962
  var trust = this.app.get("trust proxy fn");
24993
- if (!trust(this.connection.remoteAddress, 0)) {
24963
+ if (!trust(this.socket.remoteAddress, 0)) {
24994
24964
  return proto;
24995
24965
  }
24996
24966
  var header = this.get("X-Forwarded-Proto") || proto;
@@ -25023,7 +24993,7 @@ function requireRequest() {
25023
24993
  defineGetter(req, "host", function host() {
25024
24994
  var trust = this.app.get("trust proxy fn");
25025
24995
  var val = this.get("X-Forwarded-Host");
25026
- if (!val || !trust(this.connection.remoteAddress, 0)) {
24996
+ if (!val || !trust(this.socket.remoteAddress, 0)) {
25027
24997
  val = this.get("Host");
25028
24998
  } else if (val.indexOf(",") !== -1) {
25029
24999
  val = val.substring(0, val.indexOf(",")).trimRight();
@@ -25067,67 +25037,6 @@ function requireRequest() {
25067
25037
  return request;
25068
25038
  }
25069
25039
  var contentDisposition = { exports: {} };
25070
- var safeBuffer = { exports: {} };
25071
- var hasRequiredSafeBuffer;
25072
- function requireSafeBuffer() {
25073
- if (hasRequiredSafeBuffer) return safeBuffer.exports;
25074
- hasRequiredSafeBuffer = 1;
25075
- (function(module, exports$1) {
25076
- var buffer2 = require$$0$6;
25077
- var Buffer2 = buffer2.Buffer;
25078
- function copyProps(src, dst) {
25079
- for (var key2 in src) {
25080
- dst[key2] = src[key2];
25081
- }
25082
- }
25083
- if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) {
25084
- module.exports = buffer2;
25085
- } else {
25086
- copyProps(buffer2, exports$1);
25087
- exports$1.Buffer = SafeBuffer;
25088
- }
25089
- function SafeBuffer(arg, encodingOrOffset, length) {
25090
- return Buffer2(arg, encodingOrOffset, length);
25091
- }
25092
- SafeBuffer.prototype = Object.create(Buffer2.prototype);
25093
- copyProps(Buffer2, SafeBuffer);
25094
- SafeBuffer.from = function(arg, encodingOrOffset, length) {
25095
- if (typeof arg === "number") {
25096
- throw new TypeError("Argument must not be a number");
25097
- }
25098
- return Buffer2(arg, encodingOrOffset, length);
25099
- };
25100
- SafeBuffer.alloc = function(size, fill, encoding2) {
25101
- if (typeof size !== "number") {
25102
- throw new TypeError("Argument must be a number");
25103
- }
25104
- var buf = Buffer2(size);
25105
- if (fill !== void 0) {
25106
- if (typeof encoding2 === "string") {
25107
- buf.fill(fill, encoding2);
25108
- } else {
25109
- buf.fill(fill);
25110
- }
25111
- } else {
25112
- buf.fill(0);
25113
- }
25114
- return buf;
25115
- };
25116
- SafeBuffer.allocUnsafe = function(size) {
25117
- if (typeof size !== "number") {
25118
- throw new TypeError("Argument must be a number");
25119
- }
25120
- return Buffer2(size);
25121
- };
25122
- SafeBuffer.allocUnsafeSlow = function(size) {
25123
- if (typeof size !== "number") {
25124
- throw new TypeError("Argument must be a number");
25125
- }
25126
- return buffer2.SlowBuffer(size);
25127
- };
25128
- })(safeBuffer, safeBuffer.exports);
25129
- return safeBuffer.exports;
25130
- }
25131
25040
  var hasRequiredContentDisposition;
25132
25041
  function requireContentDisposition() {
25133
25042
  if (hasRequiredContentDisposition) return contentDisposition.exports;
@@ -25135,7 +25044,6 @@ function requireContentDisposition() {
25135
25044
  contentDisposition.exports = contentDisposition$1;
25136
25045
  contentDisposition.exports.parse = parse3;
25137
25046
  var basename = path$1.basename;
25138
- var Buffer2 = requireSafeBuffer().Buffer;
25139
25047
  var ENCODE_URL_ATTR_CHAR_REGEXP = /[\x00-\x20"'()*,/:;<=>?@[\\\]{}\x7f]/g;
25140
25048
  var HEX_ESCAPE_REGEXP = /%[0-9A-Fa-f]{2}/;
25141
25049
  var HEX_ESCAPE_REPLACE_REGEXP = /%([0-9A-Fa-f]{2})/g;
@@ -25215,7 +25123,7 @@ function requireContentDisposition() {
25215
25123
  break;
25216
25124
  case "utf-8":
25217
25125
  case "utf8":
25218
- value = Buffer2.from(binary, "binary").toString("utf8");
25126
+ value = Buffer.from(binary, "binary").toString("utf8");
25219
25127
  break;
25220
25128
  default:
25221
25129
  throw new TypeError("unsupported charset in extended field");
@@ -25297,7 +25205,7 @@ function requireCookieSignature() {
25297
25205
  if (hasRequiredCookieSignature) return cookieSignature;
25298
25206
  hasRequiredCookieSignature = 1;
25299
25207
  (function(exports$1) {
25300
- var crypto2 = require$$0$9;
25208
+ var crypto2 = require$$0$8;
25301
25209
  exports$1.sign = function(val, secret) {
25302
25210
  if ("string" != typeof val) throw new TypeError("Cookie value must be provided as a string.");
25303
25211
  if (null == secret) throw new TypeError("Secret key must be provided.");
@@ -25484,12 +25392,12 @@ function requireSend() {
25484
25392
  if (hasRequiredSend) return send_1;
25485
25393
  hasRequiredSend = 1;
25486
25394
  var createError = requireHttpErrors();
25487
- var debug = require$$0$7("send");
25395
+ var debug = require$$0$6("send");
25488
25396
  var encodeUrl = requireEncodeurl();
25489
25397
  var escapeHtml = requireEscapeHtml();
25490
25398
  var etag = requireEtag();
25491
25399
  var fresh = requireFresh();
25492
- var fs2 = require$$0$4;
25400
+ var fs2 = require$$0$3;
25493
25401
  var mime = requireMimeTypes();
25494
25402
  var ms2 = require$$8;
25495
25403
  var onFinished2 = requireOnFinished();
@@ -25968,6 +25876,7 @@ function requireResponse() {
25968
25876
  hasRequiredResponse = 1;
25969
25877
  var contentDisposition2 = requireContentDisposition();
25970
25878
  var createError = requireHttpErrors();
25879
+ var deprecate = requireBrowser()("express");
25971
25880
  var encodeUrl = requireEncodeurl();
25972
25881
  var escapeHtml = requireEscapeHtml();
25973
25882
  var http = require$$2$4;
@@ -25985,6 +25894,7 @@ function requireResponse() {
25985
25894
  var extname = path2.extname;
25986
25895
  var resolve2 = path2.resolve;
25987
25896
  var vary2 = requireVary();
25897
+ const { Buffer: Buffer2 } = require$$7$1;
25988
25898
  var res = Object.create(http.ServerResponse.prototype);
25989
25899
  response = res;
25990
25900
  res.status = function status(code) {
@@ -26048,12 +25958,12 @@ function requireResponse() {
26048
25958
  var generateETag = !this.get("ETag") && typeof etagFn === "function";
26049
25959
  var len;
26050
25960
  if (chunk !== void 0) {
26051
- if (Buffer.isBuffer(chunk)) {
25961
+ if (Buffer2.isBuffer(chunk)) {
26052
25962
  len = chunk.length;
26053
25963
  } else if (!generateETag && chunk.length < 1e3) {
26054
- len = Buffer.byteLength(chunk, encoding2);
25964
+ len = Buffer2.byteLength(chunk, encoding2);
26055
25965
  } else {
26056
- chunk = Buffer.from(chunk, encoding2);
25966
+ chunk = Buffer2.from(chunk, encoding2);
26057
25967
  encoding2 = void 0;
26058
25968
  len = chunk.length;
26059
25969
  }
@@ -26292,6 +26202,15 @@ function requireResponse() {
26292
26202
  status = arguments[0];
26293
26203
  address = arguments[1];
26294
26204
  }
26205
+ if (!address) {
26206
+ deprecate("Provide a url argument");
26207
+ }
26208
+ if (typeof address !== "string") {
26209
+ deprecate("Url must be a string");
26210
+ }
26211
+ if (typeof status !== "number") {
26212
+ deprecate("Status must be a number");
26213
+ }
26295
26214
  address = this.location(address).get("Location");
26296
26215
  this.format({
26297
26216
  text: function() {
@@ -26306,7 +26225,7 @@ function requireResponse() {
26306
26225
  }
26307
26226
  });
26308
26227
  this.status(status);
26309
- this.set("Content-Length", Buffer.byteLength(body));
26228
+ this.set("Content-Length", Buffer2.byteLength(body));
26310
26229
  if (this.req.method === "HEAD") {
26311
26230
  this.end();
26312
26231
  } else {
@@ -26430,7 +26349,7 @@ function requireServeStatic() {
26430
26349
  var parseUrl = requireParseurl();
26431
26350
  var resolve2 = path$1.resolve;
26432
26351
  var send = requireSend();
26433
- var url2 = require$$0$8;
26352
+ var url2 = require$$0$7;
26434
26353
  serveStatic_1 = serveStatic;
26435
26354
  function serveStatic(root2, options) {
26436
26355
  if (!root2) {
@@ -30220,7 +30139,7 @@ class DownloadFile extends BaseAction {
30220
30139
  } else {
30221
30140
  throw new Error("不存在任何文件, 无法下载");
30222
30141
  }
30223
- if (require$$0$4.existsSync(filePath)) {
30142
+ if (require$$0$3.existsSync(filePath)) {
30224
30143
  if (isRandomName) {
30225
30144
  const md5 = await calculateFileMD5(filePath);
30226
30145
  const newPath = path__default.join(TEMP_DIR, md5);
@@ -44620,7 +44539,7 @@ function _stringbool(Classes, _params) {
44620
44539
  type: "pipe",
44621
44540
  in: stringSchema,
44622
44541
  out: booleanSchema,
44623
- transform: (input, payload) => {
44542
+ transform: ((input, payload) => {
44624
44543
  let data = input;
44625
44544
  if (params.case !== "sensitive")
44626
44545
  data = data.toLowerCase();
@@ -44639,14 +44558,14 @@ function _stringbool(Classes, _params) {
44639
44558
  });
44640
44559
  return {};
44641
44560
  }
44642
- },
44643
- reverseTransform: (input, _payload) => {
44561
+ }),
44562
+ reverseTransform: ((input, _payload) => {
44644
44563
  if (input === true) {
44645
44564
  return truthyArray[0] || "true";
44646
44565
  } else {
44647
44566
  return falsyArray[0] || "false";
44648
44567
  }
44649
- },
44568
+ }),
44650
44569
  error: params.error
44651
44570
  });
44652
44571
  return codec2;
@@ -45809,10 +45728,10 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
45809
45728
  };
45810
45729
  inst.clone = (def2, params) => clone(inst, def2, params);
45811
45730
  inst.brand = () => inst;
45812
- inst.register = (reg, meta2) => {
45731
+ inst.register = ((reg, meta2) => {
45813
45732
  reg.add(inst, meta2);
45814
45733
  return inst;
45815
- };
45734
+ });
45816
45735
  inst.parse = (data, params) => parse2(inst, data, params, { callee: inst.parse });
45817
45736
  inst.safeParse = (data, params) => safeParse(inst, data, params);
45818
45737
  inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
@@ -55989,7 +55908,7 @@ class WebUIServer extends Service2 {
55989
55908
  connections = /* @__PURE__ */ new Set();
55990
55909
  currentPort;
55991
55910
  port = void 0;
55992
- static inject = ["app", "ntLoginApi", "ntFriendApi", "ntGroupApi"];
55911
+ static inject = ["ntLoginApi", "ntFriendApi", "ntGroupApi"];
55993
55912
  initServer() {
55994
55913
  this.app.use(express.static(feDistPath));
55995
55914
  this.app.use(express.json());
@@ -56144,7 +56063,11 @@ class WebUIServer extends Service2 {
56144
56063
  });
56145
56064
  this.app.get("/api/dashboard/stats", async (req, res) => {
56146
56065
  try {
56147
- const app = this.ctx.app;
56066
+ const app = this.ctx.get("app");
56067
+ if (!app) {
56068
+ res.status(503).json({ success: false, message: "服务尚未就绪,请等待登录完成" });
56069
+ return;
56070
+ }
56148
56071
  const friends = await this.ctx.ntFriendApi.getBuddyList();
56149
56072
  const groups = await this.ctx.ntGroupApi.getGroups(false);
56150
56073
  const qqInfo = await pmhq.getProcessInfo();
@@ -56251,6 +56174,7 @@ class WebUIServer extends Service2 {
56251
56174
  this.config = { onlyLocalhost: newConfig.onlyLocalhost, ...newConfig.webui };
56252
56175
  }
56253
56176
  async start() {
56177
+ console.log("webui start");
56254
56178
  if (!this.config?.enable) {
56255
56179
  return;
56256
56180
  }