@prisma/migrate 6.5.0-dev.1 → 6.5.0-dev.2

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.
Files changed (102) hide show
  1. package/dist/CLI.js +3 -4
  2. package/dist/Migrate.js +6 -7
  3. package/dist/SchemaEngine.js +6 -7
  4. package/dist/bin.js +116 -146
  5. package/dist/{chunk-WOOPRG54.js → chunk-255BRND3.js} +7 -14
  6. package/dist/{chunk-75EIHNAH.js → chunk-2NMFKGXM.js} +5 -6
  7. package/dist/chunk-3WC4XD74.js +98 -0
  8. package/dist/chunk-4EV2RVXY.js +226 -0
  9. package/dist/{chunk-YWWOSXMY.js → chunk-4JQIX6O7.js} +7 -15
  10. package/dist/{chunk-M5YNQ2NP.js → chunk-6DFJIBJX.js} +5 -12
  11. package/dist/{chunk-SGCF5OHF.js → chunk-7CQBDP4H.js} +6 -13
  12. package/dist/{chunk-7IT2ZO3D.js → chunk-AHJ2N6BJ.js} +3 -9
  13. package/dist/chunk-C2PR6JQR.js +266 -0
  14. package/dist/chunk-CTPONE6G.js +65 -0
  15. package/dist/{chunk-DUCG3NRP.js → chunk-D74DU52C.js} +633 -806
  16. package/dist/{chunk-UVNSK22K.js → chunk-DDHPSYC4.js} +122 -130
  17. package/dist/{chunk-CUDKD32S.js → chunk-DIAO4W7O.js} +11 -17
  18. package/dist/{chunk-XJQP3B4W.js → chunk-DJMFXNR4.js} +7 -15
  19. package/dist/{chunk-YD7GG4WS.js → chunk-FRTPDRF2.js} +66 -74
  20. package/dist/chunk-HIFVDK2U.js +96 -0
  21. package/dist/chunk-I4EY55DC.js +195 -0
  22. package/dist/{chunk-WLJHGKMK.js → chunk-IHDN3L3R.js} +7 -8
  23. package/dist/{chunk-V5LEZ5BX.js → chunk-IIBRYI63.js} +634 -807
  24. package/dist/{chunk-INC2OACE.js → chunk-JFKDSUIE.js} +3 -9
  25. package/dist/{chunk-V7DE6JTG.js → chunk-JZ75RIMZ.js} +3 -9
  26. package/dist/{chunk-AAATUOV6.js → chunk-L6KOIJJ5.js} +53 -59
  27. package/dist/{chunk-GN5BY5N2.js → chunk-LGYRZ6CV.js} +4 -10
  28. package/dist/chunk-LVLRGTYH.js +148 -0
  29. package/dist/{chunk-CQQQ436N.js → chunk-MATFO4ZW.js} +186 -200
  30. package/dist/{chunk-IFCV5MY4.js → chunk-OCQGHQED.js} +5 -11
  31. package/dist/chunk-ORL3LJOT.js +470 -0
  32. package/dist/{chunk-Q7ACZDDT.js → chunk-QOPTDDIH.js} +5 -12
  33. package/dist/chunk-QTAIWPLH.js +78 -0
  34. package/dist/{chunk-35LAJN5S.js → chunk-RP2N6UXA.js} +23 -29
  35. package/dist/chunk-RQFGRXJI.js +174 -0
  36. package/dist/{chunk-QBK5XTJE.js → chunk-RR6BKMNO.js} +3 -9
  37. package/dist/{chunk-ILJRJJ3S.js → chunk-RTGQXNX6.js} +3 -9
  38. package/dist/chunk-SKRR5WT4.js +76 -0
  39. package/dist/chunk-TM3ETZES.js +153 -0
  40. package/dist/{chunk-KPUNMK5W.js → chunk-TWPTG4XS.js} +5 -12
  41. package/dist/{chunk-6QFE3AWR.js → chunk-UP6FVCDK.js} +6 -13
  42. package/dist/{chunk-YKUZUAXA.js → chunk-V3ZMNXZC.js} +16 -23
  43. package/dist/chunk-WLPX3672.js +365 -0
  44. package/dist/chunk-WNH2ACJS.js +122 -0
  45. package/dist/chunk-XSNOKQTD.js +347 -0
  46. package/dist/{chunk-X6XGFLEF.js → chunk-YZVZCC3I.js} +25 -30
  47. package/dist/commands/DbCommand.js +3 -4
  48. package/dist/commands/DbDrop.js +9 -9
  49. package/dist/commands/DbExecute.js +7 -8
  50. package/dist/commands/DbPull.js +18 -19
  51. package/dist/commands/DbPush.js +12 -13
  52. package/dist/commands/DbSeed.js +4 -5
  53. package/dist/commands/MigrateCommand.js +3 -4
  54. package/dist/commands/MigrateDeploy.js +13 -14
  55. package/dist/commands/MigrateDev.js +17 -18
  56. package/dist/commands/MigrateDiff.js +8 -9
  57. package/dist/commands/MigrateReset.js +15 -16
  58. package/dist/commands/MigrateResolve.js +11 -12
  59. package/dist/commands/MigrateStatus.js +11 -12
  60. package/dist/index.js +60 -77
  61. package/dist/{multipart-parser-73VM3J4A.js → multipart-parser-NDLECNMN.js} +527 -561
  62. package/dist/utils/byline.js +5 -6
  63. package/dist/utils/captureStdout.js +2 -3
  64. package/dist/utils/countModelsAndTypes.js +2 -3
  65. package/dist/utils/ensureDatabaseExists.js +8 -9
  66. package/dist/utils/errors.js +8 -9
  67. package/dist/utils/flagErrors.js +5 -5
  68. package/dist/utils/getDatabaseVersionSafe.js +6 -7
  69. package/dist/utils/getSchemaPathAndPrint.js +4 -5
  70. package/dist/utils/handleEvaluateDataloss.js +3 -4
  71. package/dist/utils/introspectSql.js +6 -6
  72. package/dist/utils/isSchemaEmpty.js +2 -3
  73. package/dist/utils/printDatasource.js +3 -4
  74. package/dist/utils/printDatasources.js +3 -4
  75. package/dist/utils/printFiles.js +5 -6
  76. package/dist/utils/printIntrospectedSchema.js +2 -3
  77. package/dist/utils/printMigrationId.js +4 -5
  78. package/dist/utils/promptForMigrationName.js +2 -3
  79. package/dist/utils/removeSchemaFiles.js +2 -3
  80. package/dist/utils/replaceOrAddDatasource.js +2 -3
  81. package/dist/utils/replaceOrAddDatasource.test.js +7 -8
  82. package/dist/utils/saveSchemaFiles.js +2 -3
  83. package/dist/utils/seed.js +6 -7
  84. package/dist/utils/spinner.js +2 -3
  85. package/dist/utils/unixSocket.js +2 -3
  86. package/dist/views/handleViewsIO.js +2 -3
  87. package/package.json +6 -6
  88. package/dist/chunk-26XQQ4AG.js +0 -386
  89. package/dist/chunk-2RSEPJFX.js +0 -165
  90. package/dist/chunk-4B2LXK4R.js +0 -207
  91. package/dist/chunk-4UJBOCZJ.js +0 -130
  92. package/dist/chunk-5HZLCY6X.js +0 -161
  93. package/dist/chunk-6TE2RIPN.js +0 -80
  94. package/dist/chunk-7S3Q4MCN.js +0 -480
  95. package/dist/chunk-AOX7CJAS.js +0 -234
  96. package/dist/chunk-FF3526PX.js +0 -279
  97. package/dist/chunk-FUSFURVP.js +0 -86
  98. package/dist/chunk-GCTCQLOF.js +0 -365
  99. package/dist/chunk-K44VNAFW.js +0 -189
  100. package/dist/chunk-O4BT6W33.js +0 -104
  101. package/dist/chunk-TKAGMA5K.js +0 -72
  102. package/dist/chunk-U374EXYQ.js +0 -106
@@ -16,11 +16,11 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var multipart_parser_73VM3J4A_exports = {};
20
- __export(multipart_parser_73VM3J4A_exports, {
19
+ var multipart_parser_NDLECNMN_exports = {};
20
+ __export(multipart_parser_NDLECNMN_exports, {
21
21
  toFormData: () => toFormData
22
22
  });
23
- module.exports = __toCommonJS(multipart_parser_73VM3J4A_exports);
23
+ module.exports = __toCommonJS(multipart_parser_NDLECNMN_exports);
24
24
  var import_chunk_WWAWV7DQ = require("./chunk-WWAWV7DQ.js");
25
25
  var import_node_fs = require("node:fs");
26
26
  var require_node_domexception = (0, import_chunk_WWAWV7DQ.__commonJS)({
@@ -3891,6 +3891,9 @@ var require_streams = (0, import_chunk_WWAWV7DQ.__commonJS)({
3891
3891
  }
3892
3892
  }
3893
3893
  });
3894
+ var import_node_domexception = (0, import_chunk_WWAWV7DQ.__toESM)(require_node_domexception(), 1);
3895
+ var import_streams = (0, import_chunk_WWAWV7DQ.__toESM)(require_streams(), 1);
3896
+ var POOL_SIZE = 65536;
3894
3897
  async function* toIterator(parts, clone = true) {
3895
3898
  for (const part of parts) {
3896
3899
  if ("stream" in part) {
@@ -3925,308 +3928,541 @@ async function* toIterator(parts, clone = true) {
3925
3928
  }
3926
3929
  }
3927
3930
  }
3928
- var import_streams, POOL_SIZE, _parts, _type, _size, _endings, _a, _Blob, Blob, fetch_blob_default;
3929
- var init_fetch_blob = (0, import_chunk_WWAWV7DQ.__esm)({
3930
- "../../node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/index.js"() {
3931
- "use strict";
3932
- import_streams = (0, import_chunk_WWAWV7DQ.__toESM)(require_streams(), 1);
3933
- POOL_SIZE = 65536;
3934
- _Blob = (_a = class {
3935
- /**
3936
- * The Blob() constructor returns a new Blob object. The content
3937
- * of the blob consists of the concatenation of the values given
3938
- * in the parameter array.
3939
- *
3940
- * @param {*} blobParts
3941
- * @param {{ type?: string, endings?: string }} [options]
3942
- */
3943
- constructor(blobParts = [], options = {}) {
3944
- (0, import_chunk_WWAWV7DQ.__privateAdd)(this, _parts, []);
3945
- (0, import_chunk_WWAWV7DQ.__privateAdd)(this, _type, "");
3946
- (0, import_chunk_WWAWV7DQ.__privateAdd)(this, _size, 0);
3947
- (0, import_chunk_WWAWV7DQ.__privateAdd)(this, _endings, "transparent");
3948
- if (typeof blobParts !== "object" || blobParts === null) {
3949
- throw new TypeError("Failed to construct 'Blob': The provided value cannot be converted to a sequence.");
3950
- }
3951
- if (typeof blobParts[Symbol.iterator] !== "function") {
3952
- throw new TypeError("Failed to construct 'Blob': The object must have a callable @@iterator property.");
3953
- }
3954
- if (typeof options !== "object" && typeof options !== "function") {
3955
- throw new TypeError("Failed to construct 'Blob': parameter 2 cannot convert to dictionary.");
3956
- }
3957
- if (options === null) options = {};
3958
- const encoder = new TextEncoder();
3959
- for (const element of blobParts) {
3960
- let part;
3961
- if (ArrayBuffer.isView(element)) {
3962
- part = new Uint8Array(element.buffer.slice(element.byteOffset, element.byteOffset + element.byteLength));
3963
- } else if (element instanceof ArrayBuffer) {
3964
- part = new Uint8Array(element.slice(0));
3965
- } else if (element instanceof _a) {
3966
- part = element;
3967
- } else {
3968
- part = encoder.encode(`${element}`);
3969
- }
3970
- (0, import_chunk_WWAWV7DQ.__privateSet)(this, _size, (0, import_chunk_WWAWV7DQ.__privateGet)(this, _size) + (ArrayBuffer.isView(part) ? part.byteLength : part.size));
3971
- (0, import_chunk_WWAWV7DQ.__privateGet)(this, _parts).push(part);
3972
- }
3973
- (0, import_chunk_WWAWV7DQ.__privateSet)(this, _endings, `${options.endings === void 0 ? "transparent" : options.endings}`);
3974
- const type = options.type === void 0 ? "" : String(options.type);
3975
- (0, import_chunk_WWAWV7DQ.__privateSet)(this, _type, /^[\x20-\x7E]*$/.test(type) ? type : "");
3976
- }
3977
- /**
3978
- * The Blob interface's size property returns the
3979
- * size of the Blob in bytes.
3980
- */
3981
- get size() {
3982
- return (0, import_chunk_WWAWV7DQ.__privateGet)(this, _size);
3983
- }
3984
- /**
3985
- * The type property of a Blob object returns the MIME type of the file.
3986
- */
3987
- get type() {
3988
- return (0, import_chunk_WWAWV7DQ.__privateGet)(this, _type);
3989
- }
3990
- /**
3991
- * The text() method in the Blob interface returns a Promise
3992
- * that resolves with a string containing the contents of
3993
- * the blob, interpreted as UTF-8.
3994
- *
3995
- * @return {Promise<string>}
3996
- */
3997
- async text() {
3998
- const decoder = new TextDecoder();
3999
- let str = "";
4000
- for await (const part of toIterator((0, import_chunk_WWAWV7DQ.__privateGet)(this, _parts), false)) {
4001
- str += decoder.decode(part, { stream: true });
4002
- }
4003
- str += decoder.decode();
4004
- return str;
4005
- }
4006
- /**
4007
- * The arrayBuffer() method in the Blob interface returns a
4008
- * Promise that resolves with the contents of the blob as
4009
- * binary data contained in an ArrayBuffer.
4010
- *
4011
- * @return {Promise<ArrayBuffer>}
4012
- */
4013
- async arrayBuffer() {
4014
- const data = new Uint8Array(this.size);
4015
- let offset = 0;
4016
- for await (const chunk of toIterator((0, import_chunk_WWAWV7DQ.__privateGet)(this, _parts), false)) {
4017
- data.set(chunk, offset);
4018
- offset += chunk.length;
4019
- }
4020
- return data.buffer;
4021
- }
4022
- stream() {
4023
- const it = toIterator((0, import_chunk_WWAWV7DQ.__privateGet)(this, _parts), true);
4024
- return new globalThis.ReadableStream({
4025
- // @ts-ignore
4026
- type: "bytes",
4027
- async pull(ctrl) {
4028
- const chunk = await it.next();
4029
- chunk.done ? ctrl.close() : ctrl.enqueue(chunk.value);
4030
- },
4031
- async cancel() {
4032
- await it.return();
4033
- }
4034
- });
4035
- }
4036
- /**
4037
- * The Blob interface's slice() method creates and returns a
4038
- * new Blob object which contains data from a subset of the
4039
- * blob on which it's called.
4040
- *
4041
- * @param {number} [start]
4042
- * @param {number} [end]
4043
- * @param {string} [type]
4044
- */
4045
- slice(start = 0, end = this.size, type = "") {
4046
- const { size } = this;
4047
- let relativeStart = start < 0 ? Math.max(size + start, 0) : Math.min(start, size);
4048
- let relativeEnd = end < 0 ? Math.max(size + end, 0) : Math.min(end, size);
4049
- const span = Math.max(relativeEnd - relativeStart, 0);
4050
- const parts = (0, import_chunk_WWAWV7DQ.__privateGet)(this, _parts);
4051
- const blobParts = [];
4052
- let added = 0;
4053
- for (const part of parts) {
4054
- if (added >= span) {
4055
- break;
4056
- }
4057
- const size2 = ArrayBuffer.isView(part) ? part.byteLength : part.size;
4058
- if (relativeStart && size2 <= relativeStart) {
4059
- relativeStart -= size2;
4060
- relativeEnd -= size2;
4061
- } else {
4062
- let chunk;
4063
- if (ArrayBuffer.isView(part)) {
4064
- chunk = part.subarray(relativeStart, Math.min(size2, relativeEnd));
4065
- added += chunk.byteLength;
4066
- } else {
4067
- chunk = part.slice(relativeStart, Math.min(size2, relativeEnd));
4068
- added += chunk.size;
4069
- }
4070
- relativeEnd -= size2;
4071
- blobParts.push(chunk);
4072
- relativeStart = 0;
4073
- }
4074
- }
4075
- const blob = new _a([], { type: String(type).toLowerCase() });
4076
- (0, import_chunk_WWAWV7DQ.__privateSet)(blob, _size, span);
4077
- (0, import_chunk_WWAWV7DQ.__privateSet)(blob, _parts, blobParts);
4078
- return blob;
4079
- }
4080
- get [Symbol.toStringTag]() {
4081
- return "Blob";
3931
+ var _parts, _type, _size, _endings, _a;
3932
+ var _Blob = (_a = class {
3933
+ /**
3934
+ * The Blob() constructor returns a new Blob object. The content
3935
+ * of the blob consists of the concatenation of the values given
3936
+ * in the parameter array.
3937
+ *
3938
+ * @param {*} blobParts
3939
+ * @param {{ type?: string, endings?: string }} [options]
3940
+ */
3941
+ constructor(blobParts = [], options = {}) {
3942
+ (0, import_chunk_WWAWV7DQ.__privateAdd)(this, _parts, []);
3943
+ (0, import_chunk_WWAWV7DQ.__privateAdd)(this, _type, "");
3944
+ (0, import_chunk_WWAWV7DQ.__privateAdd)(this, _size, 0);
3945
+ (0, import_chunk_WWAWV7DQ.__privateAdd)(this, _endings, "transparent");
3946
+ if (typeof blobParts !== "object" || blobParts === null) {
3947
+ throw new TypeError("Failed to construct 'Blob': The provided value cannot be converted to a sequence.");
3948
+ }
3949
+ if (typeof blobParts[Symbol.iterator] !== "function") {
3950
+ throw new TypeError("Failed to construct 'Blob': The object must have a callable @@iterator property.");
3951
+ }
3952
+ if (typeof options !== "object" && typeof options !== "function") {
3953
+ throw new TypeError("Failed to construct 'Blob': parameter 2 cannot convert to dictionary.");
3954
+ }
3955
+ if (options === null) options = {};
3956
+ const encoder = new TextEncoder();
3957
+ for (const element of blobParts) {
3958
+ let part;
3959
+ if (ArrayBuffer.isView(element)) {
3960
+ part = new Uint8Array(element.buffer.slice(element.byteOffset, element.byteOffset + element.byteLength));
3961
+ } else if (element instanceof ArrayBuffer) {
3962
+ part = new Uint8Array(element.slice(0));
3963
+ } else if (element instanceof _a) {
3964
+ part = element;
3965
+ } else {
3966
+ part = encoder.encode(`${element}`);
4082
3967
  }
4083
- static [Symbol.hasInstance](object) {
4084
- return object && typeof object === "object" && typeof object.constructor === "function" && (typeof object.stream === "function" || typeof object.arrayBuffer === "function") && /^(Blob|File)$/.test(object[Symbol.toStringTag]);
3968
+ (0, import_chunk_WWAWV7DQ.__privateSet)(this, _size, (0, import_chunk_WWAWV7DQ.__privateGet)(this, _size) + (ArrayBuffer.isView(part) ? part.byteLength : part.size));
3969
+ (0, import_chunk_WWAWV7DQ.__privateGet)(this, _parts).push(part);
3970
+ }
3971
+ (0, import_chunk_WWAWV7DQ.__privateSet)(this, _endings, `${options.endings === void 0 ? "transparent" : options.endings}`);
3972
+ const type = options.type === void 0 ? "" : String(options.type);
3973
+ (0, import_chunk_WWAWV7DQ.__privateSet)(this, _type, /^[\x20-\x7E]*$/.test(type) ? type : "");
3974
+ }
3975
+ /**
3976
+ * The Blob interface's size property returns the
3977
+ * size of the Blob in bytes.
3978
+ */
3979
+ get size() {
3980
+ return (0, import_chunk_WWAWV7DQ.__privateGet)(this, _size);
3981
+ }
3982
+ /**
3983
+ * The type property of a Blob object returns the MIME type of the file.
3984
+ */
3985
+ get type() {
3986
+ return (0, import_chunk_WWAWV7DQ.__privateGet)(this, _type);
3987
+ }
3988
+ /**
3989
+ * The text() method in the Blob interface returns a Promise
3990
+ * that resolves with a string containing the contents of
3991
+ * the blob, interpreted as UTF-8.
3992
+ *
3993
+ * @return {Promise<string>}
3994
+ */
3995
+ async text() {
3996
+ const decoder = new TextDecoder();
3997
+ let str = "";
3998
+ for await (const part of toIterator((0, import_chunk_WWAWV7DQ.__privateGet)(this, _parts), false)) {
3999
+ str += decoder.decode(part, { stream: true });
4000
+ }
4001
+ str += decoder.decode();
4002
+ return str;
4003
+ }
4004
+ /**
4005
+ * The arrayBuffer() method in the Blob interface returns a
4006
+ * Promise that resolves with the contents of the blob as
4007
+ * binary data contained in an ArrayBuffer.
4008
+ *
4009
+ * @return {Promise<ArrayBuffer>}
4010
+ */
4011
+ async arrayBuffer() {
4012
+ const data = new Uint8Array(this.size);
4013
+ let offset = 0;
4014
+ for await (const chunk of toIterator((0, import_chunk_WWAWV7DQ.__privateGet)(this, _parts), false)) {
4015
+ data.set(chunk, offset);
4016
+ offset += chunk.length;
4017
+ }
4018
+ return data.buffer;
4019
+ }
4020
+ stream() {
4021
+ const it = toIterator((0, import_chunk_WWAWV7DQ.__privateGet)(this, _parts), true);
4022
+ return new globalThis.ReadableStream({
4023
+ // @ts-ignore
4024
+ type: "bytes",
4025
+ async pull(ctrl) {
4026
+ const chunk = await it.next();
4027
+ chunk.done ? ctrl.close() : ctrl.enqueue(chunk.value);
4028
+ },
4029
+ async cancel() {
4030
+ await it.return();
4085
4031
  }
4086
- }, _parts = /* @__PURE__ */ new WeakMap(), _type = /* @__PURE__ */ new WeakMap(), _size = /* @__PURE__ */ new WeakMap(), _endings = /* @__PURE__ */ new WeakMap(), _a);
4087
- Object.defineProperties(_Blob.prototype, {
4088
- size: { enumerable: true },
4089
- type: { enumerable: true },
4090
- slice: { enumerable: true }
4091
4032
  });
4092
- Blob = _Blob;
4093
- fetch_blob_default = Blob;
4094
4033
  }
4095
- });
4096
- var _lastModified, _name, _a2, _File, File, file_default;
4097
- var init_file = (0, import_chunk_WWAWV7DQ.__esm)({
4098
- "../../node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/file.js"() {
4099
- "use strict";
4100
- init_fetch_blob();
4101
- _File = (_a2 = class extends fetch_blob_default {
4102
- /**
4103
- * @param {*[]} fileBits
4104
- * @param {string} fileName
4105
- * @param {{lastModified?: number, type?: string}} options
4106
- */
4107
- // @ts-ignore
4108
- constructor(fileBits, fileName, options = {}) {
4109
- if (arguments.length < 2) {
4110
- throw new TypeError(`Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`);
4111
- }
4112
- super(fileBits, options);
4113
- (0, import_chunk_WWAWV7DQ.__privateAdd)(this, _lastModified, 0);
4114
- (0, import_chunk_WWAWV7DQ.__privateAdd)(this, _name, "");
4115
- if (options === null) options = {};
4116
- const lastModified = options.lastModified === void 0 ? Date.now() : Number(options.lastModified);
4117
- if (!Number.isNaN(lastModified)) {
4118
- (0, import_chunk_WWAWV7DQ.__privateSet)(this, _lastModified, lastModified);
4034
+ /**
4035
+ * The Blob interface's slice() method creates and returns a
4036
+ * new Blob object which contains data from a subset of the
4037
+ * blob on which it's called.
4038
+ *
4039
+ * @param {number} [start]
4040
+ * @param {number} [end]
4041
+ * @param {string} [type]
4042
+ */
4043
+ slice(start = 0, end = this.size, type = "") {
4044
+ const { size } = this;
4045
+ let relativeStart = start < 0 ? Math.max(size + start, 0) : Math.min(start, size);
4046
+ let relativeEnd = end < 0 ? Math.max(size + end, 0) : Math.min(end, size);
4047
+ const span = Math.max(relativeEnd - relativeStart, 0);
4048
+ const parts = (0, import_chunk_WWAWV7DQ.__privateGet)(this, _parts);
4049
+ const blobParts = [];
4050
+ let added = 0;
4051
+ for (const part of parts) {
4052
+ if (added >= span) {
4053
+ break;
4054
+ }
4055
+ const size2 = ArrayBuffer.isView(part) ? part.byteLength : part.size;
4056
+ if (relativeStart && size2 <= relativeStart) {
4057
+ relativeStart -= size2;
4058
+ relativeEnd -= size2;
4059
+ } else {
4060
+ let chunk;
4061
+ if (ArrayBuffer.isView(part)) {
4062
+ chunk = part.subarray(relativeStart, Math.min(size2, relativeEnd));
4063
+ added += chunk.byteLength;
4064
+ } else {
4065
+ chunk = part.slice(relativeStart, Math.min(size2, relativeEnd));
4066
+ added += chunk.size;
4119
4067
  }
4120
- (0, import_chunk_WWAWV7DQ.__privateSet)(this, _name, String(fileName));
4121
- }
4122
- get name() {
4123
- return (0, import_chunk_WWAWV7DQ.__privateGet)(this, _name);
4124
- }
4125
- get lastModified() {
4126
- return (0, import_chunk_WWAWV7DQ.__privateGet)(this, _lastModified);
4127
- }
4128
- get [Symbol.toStringTag]() {
4129
- return "File";
4130
- }
4131
- static [Symbol.hasInstance](object) {
4132
- return !!object && object instanceof fetch_blob_default && /^(File)$/.test(object[Symbol.toStringTag]);
4068
+ relativeEnd -= size2;
4069
+ blobParts.push(chunk);
4070
+ relativeStart = 0;
4133
4071
  }
4134
- }, _lastModified = /* @__PURE__ */ new WeakMap(), _name = /* @__PURE__ */ new WeakMap(), _a2);
4135
- File = _File;
4136
- file_default = File;
4072
+ }
4073
+ const blob = new _a([], { type: String(type).toLowerCase() });
4074
+ (0, import_chunk_WWAWV7DQ.__privateSet)(blob, _size, span);
4075
+ (0, import_chunk_WWAWV7DQ.__privateSet)(blob, _parts, blobParts);
4076
+ return blob;
4137
4077
  }
4138
- });
4139
- var import_node_domexception, stat;
4140
- var init_from = (0, import_chunk_WWAWV7DQ.__esm)({
4141
- "../../node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/from.js"() {
4142
- "use strict";
4143
- import_node_domexception = (0, import_chunk_WWAWV7DQ.__toESM)(require_node_domexception(), 1);
4144
- init_file();
4145
- init_fetch_blob();
4146
- ({ stat } = import_node_fs.promises);
4078
+ get [Symbol.toStringTag]() {
4079
+ return "Blob";
4147
4080
  }
4081
+ static [Symbol.hasInstance](object) {
4082
+ return object && typeof object === "object" && typeof object.constructor === "function" && (typeof object.stream === "function" || typeof object.arrayBuffer === "function") && /^(Blob|File)$/.test(object[Symbol.toStringTag]);
4083
+ }
4084
+ }, _parts = /* @__PURE__ */ new WeakMap(), _type = /* @__PURE__ */ new WeakMap(), _size = /* @__PURE__ */ new WeakMap(), _endings = /* @__PURE__ */ new WeakMap(), _a);
4085
+ Object.defineProperties(_Blob.prototype, {
4086
+ size: { enumerable: true },
4087
+ type: { enumerable: true },
4088
+ slice: { enumerable: true }
4148
4089
  });
4149
- var t, i, h, m, f, x, _d, _a3, FormData;
4150
- var init_esm_min = (0, import_chunk_WWAWV7DQ.__esm)({
4151
- "../../node_modules/.pnpm/formdata-polyfill@4.0.10/node_modules/formdata-polyfill/esm.min.js"() {
4152
- "use strict";
4153
- init_fetch_blob();
4154
- init_file();
4155
- ({ toStringTag: t, iterator: i, hasInstance: h } = Symbol);
4156
- m = "append,set,get,getAll,delete,keys,values,entries,forEach,constructor".split(",");
4157
- f = (a, b, c) => (a += "", /^(Blob|File)$/.test(b && b[t]) ? [(c = c !== void 0 ? c + "" : b[t] == "File" ? b.name : "blob", a), b.name !== c || b[t] == "blob" ? new file_default([b], c, b) : b] : [a, b + ""]);
4158
- x = (n, a, e) => {
4159
- if (a.length < e) {
4160
- throw new TypeError(`Failed to execute '${n}' on 'FormData': ${e} arguments required, but only ${a.length} present.`);
4161
- }
4090
+ var Blob = _Blob;
4091
+ var fetch_blob_default = Blob;
4092
+ var _lastModified, _name, _a2;
4093
+ var _File = (_a2 = class extends fetch_blob_default {
4094
+ /**
4095
+ * @param {*[]} fileBits
4096
+ * @param {string} fileName
4097
+ * @param {{lastModified?: number, type?: string}} options
4098
+ */
4099
+ // @ts-ignore
4100
+ constructor(fileBits, fileName, options = {}) {
4101
+ if (arguments.length < 2) {
4102
+ throw new TypeError(`Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`);
4103
+ }
4104
+ super(fileBits, options);
4105
+ (0, import_chunk_WWAWV7DQ.__privateAdd)(this, _lastModified, 0);
4106
+ (0, import_chunk_WWAWV7DQ.__privateAdd)(this, _name, "");
4107
+ if (options === null) options = {};
4108
+ const lastModified = options.lastModified === void 0 ? Date.now() : Number(options.lastModified);
4109
+ if (!Number.isNaN(lastModified)) {
4110
+ (0, import_chunk_WWAWV7DQ.__privateSet)(this, _lastModified, lastModified);
4111
+ }
4112
+ (0, import_chunk_WWAWV7DQ.__privateSet)(this, _name, String(fileName));
4113
+ }
4114
+ get name() {
4115
+ return (0, import_chunk_WWAWV7DQ.__privateGet)(this, _name);
4116
+ }
4117
+ get lastModified() {
4118
+ return (0, import_chunk_WWAWV7DQ.__privateGet)(this, _lastModified);
4119
+ }
4120
+ get [Symbol.toStringTag]() {
4121
+ return "File";
4122
+ }
4123
+ static [Symbol.hasInstance](object) {
4124
+ return !!object && object instanceof fetch_blob_default && /^(File)$/.test(object[Symbol.toStringTag]);
4125
+ }
4126
+ }, _lastModified = /* @__PURE__ */ new WeakMap(), _name = /* @__PURE__ */ new WeakMap(), _a2);
4127
+ var File = _File;
4128
+ var file_default = File;
4129
+ var { stat } = import_node_fs.promises;
4130
+ var { toStringTag: t, iterator: i, hasInstance: h } = Symbol;
4131
+ var m = "append,set,get,getAll,delete,keys,values,entries,forEach,constructor".split(",");
4132
+ var f = (a, b, c) => (a += "", /^(Blob|File)$/.test(b && b[t]) ? [(c = c !== void 0 ? c + "" : b[t] == "File" ? b.name : "blob", a), b.name !== c || b[t] == "blob" ? new file_default([b], c, b) : b] : [a, b + ""]);
4133
+ var x = (n, a, e) => {
4134
+ if (a.length < e) {
4135
+ throw new TypeError(`Failed to execute '${n}' on 'FormData': ${e} arguments required, but only ${a.length} present.`);
4136
+ }
4137
+ };
4138
+ var _d, _a3;
4139
+ var FormData = (_a3 = class {
4140
+ constructor(...a) {
4141
+ (0, import_chunk_WWAWV7DQ.__privateAdd)(this, _d, []);
4142
+ if (a.length) throw new TypeError(`Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'.`);
4143
+ }
4144
+ get [t]() {
4145
+ return "FormData";
4146
+ }
4147
+ [i]() {
4148
+ return this.entries();
4149
+ }
4150
+ static [h](o) {
4151
+ return o && typeof o === "object" && o[t] === "FormData" && !m.some((m2) => typeof o[m2] != "function");
4152
+ }
4153
+ append(...a) {
4154
+ x("append", arguments, 2);
4155
+ (0, import_chunk_WWAWV7DQ.__privateGet)(this, _d).push(f(...a));
4156
+ }
4157
+ delete(a) {
4158
+ x("delete", arguments, 1);
4159
+ a += "";
4160
+ (0, import_chunk_WWAWV7DQ.__privateSet)(this, _d, (0, import_chunk_WWAWV7DQ.__privateGet)(this, _d).filter(([b]) => b !== a));
4161
+ }
4162
+ get(a) {
4163
+ x("get", arguments, 1);
4164
+ a += "";
4165
+ for (var b = (0, import_chunk_WWAWV7DQ.__privateGet)(this, _d), l = b.length, c = 0; c < l; c++) if (b[c][0] === a) return b[c][1];
4166
+ return null;
4167
+ }
4168
+ getAll(a, b) {
4169
+ x("getAll", arguments, 1);
4170
+ b = [];
4171
+ a += "";
4172
+ (0, import_chunk_WWAWV7DQ.__privateGet)(this, _d).forEach((c) => c[0] === a && b.push(c[1]));
4173
+ return b;
4174
+ }
4175
+ has(a) {
4176
+ x("has", arguments, 1);
4177
+ a += "";
4178
+ return (0, import_chunk_WWAWV7DQ.__privateGet)(this, _d).some((b) => b[0] === a);
4179
+ }
4180
+ forEach(a, b) {
4181
+ x("forEach", arguments, 1);
4182
+ for (var [c, d] of this) a.call(b, d, c, this);
4183
+ }
4184
+ set(...a) {
4185
+ x("set", arguments, 2);
4186
+ var b = [], c = true;
4187
+ a = f(...a);
4188
+ (0, import_chunk_WWAWV7DQ.__privateGet)(this, _d).forEach((d) => {
4189
+ d[0] === a[0] ? c && (c = !b.push(a)) : b.push(d);
4190
+ });
4191
+ c && b.push(a);
4192
+ (0, import_chunk_WWAWV7DQ.__privateSet)(this, _d, b);
4193
+ }
4194
+ *entries() {
4195
+ yield* (0, import_chunk_WWAWV7DQ.__privateGet)(this, _d);
4196
+ }
4197
+ *keys() {
4198
+ for (var [a] of this) yield a;
4199
+ }
4200
+ *values() {
4201
+ for (var [, a] of this) yield a;
4202
+ }
4203
+ }, _d = /* @__PURE__ */ new WeakMap(), _a3);
4204
+ var s = 0;
4205
+ var S = {
4206
+ START_BOUNDARY: s++,
4207
+ HEADER_FIELD_START: s++,
4208
+ HEADER_FIELD: s++,
4209
+ HEADER_VALUE_START: s++,
4210
+ HEADER_VALUE: s++,
4211
+ HEADER_VALUE_ALMOST_DONE: s++,
4212
+ HEADERS_ALMOST_DONE: s++,
4213
+ PART_DATA_START: s++,
4214
+ PART_DATA: s++,
4215
+ END: s++
4216
+ };
4217
+ var f2 = 1;
4218
+ var F = {
4219
+ PART_BOUNDARY: f2,
4220
+ LAST_BOUNDARY: f2 *= 2
4221
+ };
4222
+ var LF = 10;
4223
+ var CR = 13;
4224
+ var SPACE = 32;
4225
+ var HYPHEN = 45;
4226
+ var COLON = 58;
4227
+ var A = 97;
4228
+ var Z = 122;
4229
+ var lower = (c) => c | 32;
4230
+ var noop = () => {
4231
+ };
4232
+ var MultipartParser = class {
4233
+ /**
4234
+ * @param {string} boundary
4235
+ */
4236
+ constructor(boundary) {
4237
+ this.index = 0;
4238
+ this.flags = 0;
4239
+ this.onHeaderEnd = noop;
4240
+ this.onHeaderField = noop;
4241
+ this.onHeadersEnd = noop;
4242
+ this.onHeaderValue = noop;
4243
+ this.onPartBegin = noop;
4244
+ this.onPartData = noop;
4245
+ this.onPartEnd = noop;
4246
+ this.boundaryChars = {};
4247
+ boundary = "\r\n--" + boundary;
4248
+ const ui8a = new Uint8Array(boundary.length);
4249
+ for (let i2 = 0; i2 < boundary.length; i2++) {
4250
+ ui8a[i2] = boundary.charCodeAt(i2);
4251
+ this.boundaryChars[ui8a[i2]] = true;
4252
+ }
4253
+ this.boundary = ui8a;
4254
+ this.lookbehind = new Uint8Array(this.boundary.length + 8);
4255
+ this.state = S.START_BOUNDARY;
4256
+ }
4257
+ /**
4258
+ * @param {Uint8Array} data
4259
+ */
4260
+ write(data) {
4261
+ let i2 = 0;
4262
+ const length_ = data.length;
4263
+ let previousIndex = this.index;
4264
+ let { lookbehind, boundary, boundaryChars, index, state, flags } = this;
4265
+ const boundaryLength = this.boundary.length;
4266
+ const boundaryEnd = boundaryLength - 1;
4267
+ const bufferLength = data.length;
4268
+ let c;
4269
+ let cl;
4270
+ const mark = (name) => {
4271
+ this[name + "Mark"] = i2;
4162
4272
  };
4163
- FormData = (_a3 = class {
4164
- constructor(...a) {
4165
- (0, import_chunk_WWAWV7DQ.__privateAdd)(this, _d, []);
4166
- if (a.length) throw new TypeError(`Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'.`);
4167
- }
4168
- get [t]() {
4169
- return "FormData";
4170
- }
4171
- [i]() {
4172
- return this.entries();
4173
- }
4174
- static [h](o) {
4175
- return o && typeof o === "object" && o[t] === "FormData" && !m.some((m2) => typeof o[m2] != "function");
4176
- }
4177
- append(...a) {
4178
- x("append", arguments, 2);
4179
- (0, import_chunk_WWAWV7DQ.__privateGet)(this, _d).push(f(...a));
4180
- }
4181
- delete(a) {
4182
- x("delete", arguments, 1);
4183
- a += "";
4184
- (0, import_chunk_WWAWV7DQ.__privateSet)(this, _d, (0, import_chunk_WWAWV7DQ.__privateGet)(this, _d).filter(([b]) => b !== a));
4185
- }
4186
- get(a) {
4187
- x("get", arguments, 1);
4188
- a += "";
4189
- for (var b = (0, import_chunk_WWAWV7DQ.__privateGet)(this, _d), l = b.length, c = 0; c < l; c++) if (b[c][0] === a) return b[c][1];
4190
- return null;
4191
- }
4192
- getAll(a, b) {
4193
- x("getAll", arguments, 1);
4194
- b = [];
4195
- a += "";
4196
- (0, import_chunk_WWAWV7DQ.__privateGet)(this, _d).forEach((c) => c[0] === a && b.push(c[1]));
4197
- return b;
4198
- }
4199
- has(a) {
4200
- x("has", arguments, 1);
4201
- a += "";
4202
- return (0, import_chunk_WWAWV7DQ.__privateGet)(this, _d).some((b) => b[0] === a);
4203
- }
4204
- forEach(a, b) {
4205
- x("forEach", arguments, 1);
4206
- for (var [c, d] of this) a.call(b, d, c, this);
4207
- }
4208
- set(...a) {
4209
- x("set", arguments, 2);
4210
- var b = [], c = true;
4211
- a = f(...a);
4212
- (0, import_chunk_WWAWV7DQ.__privateGet)(this, _d).forEach((d) => {
4213
- d[0] === a[0] ? c && (c = !b.push(a)) : b.push(d);
4214
- });
4215
- c && b.push(a);
4216
- (0, import_chunk_WWAWV7DQ.__privateSet)(this, _d, b);
4217
- }
4218
- *entries() {
4219
- yield* (0, import_chunk_WWAWV7DQ.__privateGet)(this, _d);
4273
+ const clear = (name) => {
4274
+ delete this[name + "Mark"];
4275
+ };
4276
+ const callback = (callbackSymbol, start, end, ui8a) => {
4277
+ if (start === void 0 || start !== end) {
4278
+ this[callbackSymbol](ui8a && ui8a.subarray(start, end));
4220
4279
  }
4221
- *keys() {
4222
- for (var [a] of this) yield a;
4280
+ };
4281
+ const dataCallback = (name, clear2) => {
4282
+ const markSymbol = name + "Mark";
4283
+ if (!(markSymbol in this)) {
4284
+ return;
4285
+ }
4286
+ if (clear2) {
4287
+ callback(name, this[markSymbol], i2, data);
4288
+ delete this[markSymbol];
4289
+ } else {
4290
+ callback(name, this[markSymbol], data.length, data);
4291
+ this[markSymbol] = 0;
4223
4292
  }
4224
- *values() {
4225
- for (var [, a] of this) yield a;
4293
+ };
4294
+ for (i2 = 0; i2 < length_; i2++) {
4295
+ c = data[i2];
4296
+ switch (state) {
4297
+ case S.START_BOUNDARY:
4298
+ if (index === boundary.length - 2) {
4299
+ if (c === HYPHEN) {
4300
+ flags |= F.LAST_BOUNDARY;
4301
+ } else if (c !== CR) {
4302
+ return;
4303
+ }
4304
+ index++;
4305
+ break;
4306
+ } else if (index - 1 === boundary.length - 2) {
4307
+ if (flags & F.LAST_BOUNDARY && c === HYPHEN) {
4308
+ state = S.END;
4309
+ flags = 0;
4310
+ } else if (!(flags & F.LAST_BOUNDARY) && c === LF) {
4311
+ index = 0;
4312
+ callback("onPartBegin");
4313
+ state = S.HEADER_FIELD_START;
4314
+ } else {
4315
+ return;
4316
+ }
4317
+ break;
4318
+ }
4319
+ if (c !== boundary[index + 2]) {
4320
+ index = -2;
4321
+ }
4322
+ if (c === boundary[index + 2]) {
4323
+ index++;
4324
+ }
4325
+ break;
4326
+ case S.HEADER_FIELD_START:
4327
+ state = S.HEADER_FIELD;
4328
+ mark("onHeaderField");
4329
+ index = 0;
4330
+ // falls through
4331
+ case S.HEADER_FIELD:
4332
+ if (c === CR) {
4333
+ clear("onHeaderField");
4334
+ state = S.HEADERS_ALMOST_DONE;
4335
+ break;
4336
+ }
4337
+ index++;
4338
+ if (c === HYPHEN) {
4339
+ break;
4340
+ }
4341
+ if (c === COLON) {
4342
+ if (index === 1) {
4343
+ return;
4344
+ }
4345
+ dataCallback("onHeaderField", true);
4346
+ state = S.HEADER_VALUE_START;
4347
+ break;
4348
+ }
4349
+ cl = lower(c);
4350
+ if (cl < A || cl > Z) {
4351
+ return;
4352
+ }
4353
+ break;
4354
+ case S.HEADER_VALUE_START:
4355
+ if (c === SPACE) {
4356
+ break;
4357
+ }
4358
+ mark("onHeaderValue");
4359
+ state = S.HEADER_VALUE;
4360
+ // falls through
4361
+ case S.HEADER_VALUE:
4362
+ if (c === CR) {
4363
+ dataCallback("onHeaderValue", true);
4364
+ callback("onHeaderEnd");
4365
+ state = S.HEADER_VALUE_ALMOST_DONE;
4366
+ }
4367
+ break;
4368
+ case S.HEADER_VALUE_ALMOST_DONE:
4369
+ if (c !== LF) {
4370
+ return;
4371
+ }
4372
+ state = S.HEADER_FIELD_START;
4373
+ break;
4374
+ case S.HEADERS_ALMOST_DONE:
4375
+ if (c !== LF) {
4376
+ return;
4377
+ }
4378
+ callback("onHeadersEnd");
4379
+ state = S.PART_DATA_START;
4380
+ break;
4381
+ case S.PART_DATA_START:
4382
+ state = S.PART_DATA;
4383
+ mark("onPartData");
4384
+ // falls through
4385
+ case S.PART_DATA:
4386
+ previousIndex = index;
4387
+ if (index === 0) {
4388
+ i2 += boundaryEnd;
4389
+ while (i2 < bufferLength && !(data[i2] in boundaryChars)) {
4390
+ i2 += boundaryLength;
4391
+ }
4392
+ i2 -= boundaryEnd;
4393
+ c = data[i2];
4394
+ }
4395
+ if (index < boundary.length) {
4396
+ if (boundary[index] === c) {
4397
+ if (index === 0) {
4398
+ dataCallback("onPartData", true);
4399
+ }
4400
+ index++;
4401
+ } else {
4402
+ index = 0;
4403
+ }
4404
+ } else if (index === boundary.length) {
4405
+ index++;
4406
+ if (c === CR) {
4407
+ flags |= F.PART_BOUNDARY;
4408
+ } else if (c === HYPHEN) {
4409
+ flags |= F.LAST_BOUNDARY;
4410
+ } else {
4411
+ index = 0;
4412
+ }
4413
+ } else if (index - 1 === boundary.length) {
4414
+ if (flags & F.PART_BOUNDARY) {
4415
+ index = 0;
4416
+ if (c === LF) {
4417
+ flags &= ~F.PART_BOUNDARY;
4418
+ callback("onPartEnd");
4419
+ callback("onPartBegin");
4420
+ state = S.HEADER_FIELD_START;
4421
+ break;
4422
+ }
4423
+ } else if (flags & F.LAST_BOUNDARY) {
4424
+ if (c === HYPHEN) {
4425
+ callback("onPartEnd");
4426
+ state = S.END;
4427
+ flags = 0;
4428
+ } else {
4429
+ index = 0;
4430
+ }
4431
+ } else {
4432
+ index = 0;
4433
+ }
4434
+ }
4435
+ if (index > 0) {
4436
+ lookbehind[index - 1] = c;
4437
+ } else if (previousIndex > 0) {
4438
+ const _lookbehind = new Uint8Array(lookbehind.buffer, lookbehind.byteOffset, lookbehind.byteLength);
4439
+ callback("onPartData", 0, previousIndex, _lookbehind);
4440
+ previousIndex = 0;
4441
+ mark("onPartData");
4442
+ i2--;
4443
+ }
4444
+ break;
4445
+ case S.END:
4446
+ break;
4447
+ default:
4448
+ throw new Error(`Unexpected state entered: ${state}`);
4226
4449
  }
4227
- }, _d = /* @__PURE__ */ new WeakMap(), _a3);
4450
+ }
4451
+ dataCallback("onHeaderField");
4452
+ dataCallback("onHeaderValue");
4453
+ dataCallback("onPartData");
4454
+ this.index = index;
4455
+ this.state = state;
4456
+ this.flags = flags;
4228
4457
  }
4229
- });
4458
+ end() {
4459
+ if (this.state === S.HEADER_FIELD_START && this.index === 0 || this.state === S.PART_DATA && this.index === this.boundary.length) {
4460
+ this.onPartEnd();
4461
+ } else if (this.state !== S.END) {
4462
+ throw new Error("MultipartParser.end(): stream ended unexpectedly");
4463
+ }
4464
+ }
4465
+ };
4230
4466
  function _fileName(headerValue) {
4231
4467
  const m2 = headerValue.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);
4232
4468
  if (!m2) {
@@ -4314,276 +4550,6 @@ async function toFormData(Body, ct) {
4314
4550
  parser.end();
4315
4551
  return formData;
4316
4552
  }
4317
- var s, S, f2, F, LF, CR, SPACE, HYPHEN, COLON, A, Z, lower, noop, MultipartParser;
4318
- var init_multipart_parser = (0, import_chunk_WWAWV7DQ.__esm)({
4319
- "../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/multipart-parser.js"() {
4320
- init_from();
4321
- init_esm_min();
4322
- s = 0;
4323
- S = {
4324
- START_BOUNDARY: s++,
4325
- HEADER_FIELD_START: s++,
4326
- HEADER_FIELD: s++,
4327
- HEADER_VALUE_START: s++,
4328
- HEADER_VALUE: s++,
4329
- HEADER_VALUE_ALMOST_DONE: s++,
4330
- HEADERS_ALMOST_DONE: s++,
4331
- PART_DATA_START: s++,
4332
- PART_DATA: s++,
4333
- END: s++
4334
- };
4335
- f2 = 1;
4336
- F = {
4337
- PART_BOUNDARY: f2,
4338
- LAST_BOUNDARY: f2 *= 2
4339
- };
4340
- LF = 10;
4341
- CR = 13;
4342
- SPACE = 32;
4343
- HYPHEN = 45;
4344
- COLON = 58;
4345
- A = 97;
4346
- Z = 122;
4347
- lower = (c) => c | 32;
4348
- noop = () => {
4349
- };
4350
- MultipartParser = class {
4351
- /**
4352
- * @param {string} boundary
4353
- */
4354
- constructor(boundary) {
4355
- this.index = 0;
4356
- this.flags = 0;
4357
- this.onHeaderEnd = noop;
4358
- this.onHeaderField = noop;
4359
- this.onHeadersEnd = noop;
4360
- this.onHeaderValue = noop;
4361
- this.onPartBegin = noop;
4362
- this.onPartData = noop;
4363
- this.onPartEnd = noop;
4364
- this.boundaryChars = {};
4365
- boundary = "\r\n--" + boundary;
4366
- const ui8a = new Uint8Array(boundary.length);
4367
- for (let i2 = 0; i2 < boundary.length; i2++) {
4368
- ui8a[i2] = boundary.charCodeAt(i2);
4369
- this.boundaryChars[ui8a[i2]] = true;
4370
- }
4371
- this.boundary = ui8a;
4372
- this.lookbehind = new Uint8Array(this.boundary.length + 8);
4373
- this.state = S.START_BOUNDARY;
4374
- }
4375
- /**
4376
- * @param {Uint8Array} data
4377
- */
4378
- write(data) {
4379
- let i2 = 0;
4380
- const length_ = data.length;
4381
- let previousIndex = this.index;
4382
- let { lookbehind, boundary, boundaryChars, index, state, flags } = this;
4383
- const boundaryLength = this.boundary.length;
4384
- const boundaryEnd = boundaryLength - 1;
4385
- const bufferLength = data.length;
4386
- let c;
4387
- let cl;
4388
- const mark = (name) => {
4389
- this[name + "Mark"] = i2;
4390
- };
4391
- const clear = (name) => {
4392
- delete this[name + "Mark"];
4393
- };
4394
- const callback = (callbackSymbol, start, end, ui8a) => {
4395
- if (start === void 0 || start !== end) {
4396
- this[callbackSymbol](ui8a && ui8a.subarray(start, end));
4397
- }
4398
- };
4399
- const dataCallback = (name, clear2) => {
4400
- const markSymbol = name + "Mark";
4401
- if (!(markSymbol in this)) {
4402
- return;
4403
- }
4404
- if (clear2) {
4405
- callback(name, this[markSymbol], i2, data);
4406
- delete this[markSymbol];
4407
- } else {
4408
- callback(name, this[markSymbol], data.length, data);
4409
- this[markSymbol] = 0;
4410
- }
4411
- };
4412
- for (i2 = 0; i2 < length_; i2++) {
4413
- c = data[i2];
4414
- switch (state) {
4415
- case S.START_BOUNDARY:
4416
- if (index === boundary.length - 2) {
4417
- if (c === HYPHEN) {
4418
- flags |= F.LAST_BOUNDARY;
4419
- } else if (c !== CR) {
4420
- return;
4421
- }
4422
- index++;
4423
- break;
4424
- } else if (index - 1 === boundary.length - 2) {
4425
- if (flags & F.LAST_BOUNDARY && c === HYPHEN) {
4426
- state = S.END;
4427
- flags = 0;
4428
- } else if (!(flags & F.LAST_BOUNDARY) && c === LF) {
4429
- index = 0;
4430
- callback("onPartBegin");
4431
- state = S.HEADER_FIELD_START;
4432
- } else {
4433
- return;
4434
- }
4435
- break;
4436
- }
4437
- if (c !== boundary[index + 2]) {
4438
- index = -2;
4439
- }
4440
- if (c === boundary[index + 2]) {
4441
- index++;
4442
- }
4443
- break;
4444
- case S.HEADER_FIELD_START:
4445
- state = S.HEADER_FIELD;
4446
- mark("onHeaderField");
4447
- index = 0;
4448
- // falls through
4449
- case S.HEADER_FIELD:
4450
- if (c === CR) {
4451
- clear("onHeaderField");
4452
- state = S.HEADERS_ALMOST_DONE;
4453
- break;
4454
- }
4455
- index++;
4456
- if (c === HYPHEN) {
4457
- break;
4458
- }
4459
- if (c === COLON) {
4460
- if (index === 1) {
4461
- return;
4462
- }
4463
- dataCallback("onHeaderField", true);
4464
- state = S.HEADER_VALUE_START;
4465
- break;
4466
- }
4467
- cl = lower(c);
4468
- if (cl < A || cl > Z) {
4469
- return;
4470
- }
4471
- break;
4472
- case S.HEADER_VALUE_START:
4473
- if (c === SPACE) {
4474
- break;
4475
- }
4476
- mark("onHeaderValue");
4477
- state = S.HEADER_VALUE;
4478
- // falls through
4479
- case S.HEADER_VALUE:
4480
- if (c === CR) {
4481
- dataCallback("onHeaderValue", true);
4482
- callback("onHeaderEnd");
4483
- state = S.HEADER_VALUE_ALMOST_DONE;
4484
- }
4485
- break;
4486
- case S.HEADER_VALUE_ALMOST_DONE:
4487
- if (c !== LF) {
4488
- return;
4489
- }
4490
- state = S.HEADER_FIELD_START;
4491
- break;
4492
- case S.HEADERS_ALMOST_DONE:
4493
- if (c !== LF) {
4494
- return;
4495
- }
4496
- callback("onHeadersEnd");
4497
- state = S.PART_DATA_START;
4498
- break;
4499
- case S.PART_DATA_START:
4500
- state = S.PART_DATA;
4501
- mark("onPartData");
4502
- // falls through
4503
- case S.PART_DATA:
4504
- previousIndex = index;
4505
- if (index === 0) {
4506
- i2 += boundaryEnd;
4507
- while (i2 < bufferLength && !(data[i2] in boundaryChars)) {
4508
- i2 += boundaryLength;
4509
- }
4510
- i2 -= boundaryEnd;
4511
- c = data[i2];
4512
- }
4513
- if (index < boundary.length) {
4514
- if (boundary[index] === c) {
4515
- if (index === 0) {
4516
- dataCallback("onPartData", true);
4517
- }
4518
- index++;
4519
- } else {
4520
- index = 0;
4521
- }
4522
- } else if (index === boundary.length) {
4523
- index++;
4524
- if (c === CR) {
4525
- flags |= F.PART_BOUNDARY;
4526
- } else if (c === HYPHEN) {
4527
- flags |= F.LAST_BOUNDARY;
4528
- } else {
4529
- index = 0;
4530
- }
4531
- } else if (index - 1 === boundary.length) {
4532
- if (flags & F.PART_BOUNDARY) {
4533
- index = 0;
4534
- if (c === LF) {
4535
- flags &= ~F.PART_BOUNDARY;
4536
- callback("onPartEnd");
4537
- callback("onPartBegin");
4538
- state = S.HEADER_FIELD_START;
4539
- break;
4540
- }
4541
- } else if (flags & F.LAST_BOUNDARY) {
4542
- if (c === HYPHEN) {
4543
- callback("onPartEnd");
4544
- state = S.END;
4545
- flags = 0;
4546
- } else {
4547
- index = 0;
4548
- }
4549
- } else {
4550
- index = 0;
4551
- }
4552
- }
4553
- if (index > 0) {
4554
- lookbehind[index - 1] = c;
4555
- } else if (previousIndex > 0) {
4556
- const _lookbehind = new Uint8Array(lookbehind.buffer, lookbehind.byteOffset, lookbehind.byteLength);
4557
- callback("onPartData", 0, previousIndex, _lookbehind);
4558
- previousIndex = 0;
4559
- mark("onPartData");
4560
- i2--;
4561
- }
4562
- break;
4563
- case S.END:
4564
- break;
4565
- default:
4566
- throw new Error(`Unexpected state entered: ${state}`);
4567
- }
4568
- }
4569
- dataCallback("onHeaderField");
4570
- dataCallback("onHeaderValue");
4571
- dataCallback("onPartData");
4572
- this.index = index;
4573
- this.state = state;
4574
- this.flags = flags;
4575
- }
4576
- end() {
4577
- if (this.state === S.HEADER_FIELD_START && this.index === 0 || this.state === S.PART_DATA && this.index === this.boundary.length) {
4578
- this.onPartEnd();
4579
- } else if (this.state !== S.END) {
4580
- throw new Error("MultipartParser.end(): stream ended unexpectedly");
4581
- }
4582
- }
4583
- };
4584
- }
4585
- });
4586
- init_multipart_parser();
4587
4553
  /*! Bundled license information:
4588
4554
 
4589
4555
  node-domexception/index.js: