@prisma/migrate 6.6.0-integration-feat-orm-693-d1-driver-create-migration-adapter-using-new-http-binding.4 → 6.6.0-integration-mcp.1

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 (34) hide show
  1. package/dist/bin.js +14 -14
  2. package/dist/{chunk-EJUXYFV3.js → chunk-BYRRPHGM.js} +206 -3
  3. package/dist/{chunk-CKRN45WP.js → chunk-FJ22R36R.js} +6 -6
  4. package/dist/{chunk-B4SUSDC2.js → chunk-GBMQW4HZ.js} +6 -6
  5. package/dist/{chunk-UWQXMKQO.js → chunk-KF6K4EE5.js} +297 -2135
  6. package/dist/{chunk-O723A5JE.js → chunk-LVDALRAV.js} +6 -6
  7. package/dist/{chunk-L53C3AX3.js → chunk-PPOA6UUS.js} +296 -2134
  8. package/dist/{chunk-TGV6QGEF.js → chunk-QVMYNWAN.js} +191 -37
  9. package/dist/{chunk-5LKIRKDL.js → chunk-XPJHNEKB.js} +12 -12
  10. package/dist/{chunk-QJT4H5N6.js → chunk-ZJ4IDCRR.js} +4 -4
  11. package/dist/commands/DbPull.js +3 -3
  12. package/dist/commands/DbSeed.js +3 -3
  13. package/dist/commands/MigrateDev.js +3 -3
  14. package/dist/commands/MigrateDiff.js +3 -3
  15. package/dist/commands/MigrateReset.js +3 -3
  16. package/dist/index.js +14 -17
  17. package/dist/internals/src/cli/directoryConfig.d.ts +1 -1
  18. package/dist/internals/src/cli/getSchema.d.ts +3 -28
  19. package/dist/internals/src/cli/hashes.d.ts +1 -2
  20. package/dist/internals/src/cli/schemaContext.d.ts +4 -3
  21. package/dist/internals/src/index.d.ts +1 -1
  22. package/dist/migrate/src/index.d.ts +0 -1
  23. package/dist/{multipart-parser-ASKQAOL4-WZ47HU6G.js → multipart-parser-AOASR4DL-AXIJXW2B.js} +702 -228
  24. package/dist/{multipart-parser-QCI3Y5IB.js → multipart-parser-GQA7KJYT.js} +687 -213
  25. package/dist/open-KDTCMDK7.js +530 -0
  26. package/dist/utils/seed.js +3 -3
  27. package/dist/utils/setupCockroach.js +2 -2
  28. package/dist/utils/setupMSSQL.js +21636 -30315
  29. package/dist/utils/setupMongo.js +3327 -834
  30. package/dist/utils/setupPostgres.js +2 -2
  31. package/package.json +8 -8
  32. package/dist/chunk-GKDFIHM2.js +0 -45
  33. package/dist/migrate/src/utils/getSchemaPathAndPrint.d.ts +0 -10
  34. package/dist/utils/getSchemaPathAndPrint.js +0 -27
@@ -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_ASKQAOL4_WZ47HU6G_exports = {};
20
- __export(multipart_parser_ASKQAOL4_WZ47HU6G_exports, {
21
- default: () => multipart_parser_ASKQAOL4_WZ47HU6G_default
19
+ var multipart_parser_AOASR4DL_AXIJXW2B_exports = {};
20
+ __export(multipart_parser_AOASR4DL_AXIJXW2B_exports, {
21
+ default: () => multipart_parser_AOASR4DL_AXIJXW2B_default
22
22
  });
23
- module.exports = __toCommonJS(multipart_parser_ASKQAOL4_WZ47HU6G_exports);
23
+ module.exports = __toCommonJS(multipart_parser_AOASR4DL_AXIJXW2B_exports);
24
24
  var import_chunk_2ESYSVXG = require("./chunk-2ESYSVXG.js");
25
25
  var require_chunk_QGM4M3NI = (0, import_chunk_2ESYSVXG.__commonJS)({
26
26
  "../fetch-engine/dist/chunk-QGM4M3NI.js"(exports, module2) {
@@ -82,8 +82,8 @@ var require_chunk_QGM4M3NI = (0, import_chunk_2ESYSVXG.__commonJS)({
82
82
  ));
83
83
  }
84
84
  });
85
- var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
86
- "../fetch-engine/dist/chunk-RXM4EBGR.js"(exports, module2) {
85
+ var require_chunk_BYDIRBHB = (0, import_chunk_2ESYSVXG.__commonJS)({
86
+ "../fetch-engine/dist/chunk-BYDIRBHB.js"(exports, module2) {
87
87
  "use strict";
88
88
  var __defProp2 = Object.defineProperty;
89
89
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -102,51 +102,47 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
102
102
  return to;
103
103
  };
104
104
  var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
105
- var chunk_RXM4EBGR_exports = {};
106
- __export2(chunk_RXM4EBGR_exports, {
105
+ var chunk_BYDIRBHB_exports = {};
106
+ __export2(chunk_BYDIRBHB_exports, {
107
107
  FormData: () => FormData,
108
108
  fetch_blob_default: () => fetch_blob_default,
109
109
  file_default: () => file_default,
110
110
  formDataToBlob: () => formDataToBlob
111
111
  });
112
- module2.exports = __toCommonJS2(chunk_RXM4EBGR_exports);
112
+ module2.exports = __toCommonJS2(chunk_BYDIRBHB_exports);
113
113
  var import_chunk_QGM4M3NI = require_chunk_QGM4M3NI();
114
114
  var import_node_fs = (0, import_chunk_2ESYSVXG.__require)("node:fs");
115
115
  var require_ponyfill_es2018 = (0, import_chunk_QGM4M3NI.__commonJS)({
116
- "../../node_modules/.pnpm/web-streams-polyfill@3.2.1/node_modules/web-streams-polyfill/dist/ponyfill.es2018.js"(exports2, module22) {
116
+ "../../node_modules/.pnpm/web-streams-polyfill@3.3.3/node_modules/web-streams-polyfill/dist/ponyfill.es2018.js"(exports2, module22) {
117
117
  "use strict";
118
118
  (function(global2, factory) {
119
119
  typeof exports2 === "object" && typeof module22 !== "undefined" ? factory(exports2) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2.WebStreamsPolyfill = {}));
120
120
  })(exports2, function(exports22) {
121
121
  "use strict";
122
- const SymbolPolyfill = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? Symbol : (description) => `Symbol(${description})`;
123
122
  function noop() {
124
123
  return void 0;
125
124
  }
126
- function getGlobals() {
127
- if (typeof self !== "undefined") {
128
- return self;
129
- } else if (typeof window !== "undefined") {
130
- return window;
131
- } else if (typeof global !== "undefined") {
132
- return global;
133
- }
134
- return void 0;
135
- }
136
- const globals = getGlobals();
137
125
  function typeIsObject(x2) {
138
126
  return typeof x2 === "object" && x2 !== null || typeof x2 === "function";
139
127
  }
140
128
  const rethrowAssertionErrorRejection = noop;
129
+ function setFunctionName(fn, name) {
130
+ try {
131
+ Object.defineProperty(fn, "name", {
132
+ value: name,
133
+ configurable: true
134
+ });
135
+ } catch (_a2) {
136
+ }
137
+ }
141
138
  const originalPromise = Promise;
142
139
  const originalPromiseThen = Promise.prototype.then;
143
- const originalPromiseResolve = Promise.resolve.bind(originalPromise);
144
140
  const originalPromiseReject = Promise.reject.bind(originalPromise);
145
141
  function newPromise(executor) {
146
142
  return new originalPromise(executor);
147
143
  }
148
144
  function promiseResolvedWith(value) {
149
- return originalPromiseResolve(value);
145
+ return newPromise((resolve) => resolve(value));
150
146
  }
151
147
  function promiseRejectedWith(reason) {
152
148
  return originalPromiseReject(reason);
@@ -169,14 +165,15 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
169
165
  function setPromiseIsHandledToTrue(promise) {
170
166
  PerformPromiseThen(promise, void 0, rethrowAssertionErrorRejection);
171
167
  }
172
- const queueMicrotask = (() => {
173
- const globalQueueMicrotask = globals && globals.queueMicrotask;
174
- if (typeof globalQueueMicrotask === "function") {
175
- return globalQueueMicrotask;
168
+ let _queueMicrotask = (callback) => {
169
+ if (typeof queueMicrotask === "function") {
170
+ _queueMicrotask = queueMicrotask;
171
+ } else {
172
+ const resolvedPromise = promiseResolvedWith(void 0);
173
+ _queueMicrotask = (cb) => PerformPromiseThen(resolvedPromise, cb);
176
174
  }
177
- const resolvedPromise = promiseResolvedWith(void 0);
178
- return (fn) => PerformPromiseThen(resolvedPromise, fn);
179
- })();
175
+ return _queueMicrotask(callback);
176
+ };
180
177
  function reflectCall(F, V, args) {
181
178
  if (typeof F !== "function") {
182
179
  throw new TypeError("Argument is not a function");
@@ -280,6 +277,11 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
280
277
  return front._elements[cursor];
281
278
  }
282
279
  }
280
+ const AbortSteps = Symbol("[[AbortSteps]]");
281
+ const ErrorSteps = Symbol("[[ErrorSteps]]");
282
+ const CancelSteps = Symbol("[[CancelSteps]]");
283
+ const PullSteps = Symbol("[[PullSteps]]");
284
+ const ReleaseSteps = Symbol("[[ReleaseSteps]]");
283
285
  function ReadableStreamReaderGenericInitialize(reader, stream) {
284
286
  reader._ownerReadableStream = stream;
285
287
  stream._reader = reader;
@@ -296,12 +298,14 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
296
298
  return ReadableStreamCancel(stream, reason);
297
299
  }
298
300
  function ReadableStreamReaderGenericRelease(reader) {
299
- if (reader._ownerReadableStream._state === "readable") {
301
+ const stream = reader._ownerReadableStream;
302
+ if (stream._state === "readable") {
300
303
  defaultReaderClosedPromiseReject(reader, new TypeError(`Reader was released and can no longer be used to monitor the stream's closedness`));
301
304
  } else {
302
305
  defaultReaderClosedPromiseResetToRejected(reader, new TypeError(`Reader was released and can no longer be used to monitor the stream's closedness`));
303
306
  }
304
- reader._ownerReadableStream._reader = void 0;
307
+ stream._readableStreamController[ReleaseSteps]();
308
+ stream._reader = void 0;
305
309
  reader._ownerReadableStream = void 0;
306
310
  }
307
311
  function readerLockException(name) {
@@ -341,10 +345,6 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
341
345
  reader._closedPromise_resolve = void 0;
342
346
  reader._closedPromise_reject = void 0;
343
347
  }
344
- const AbortSteps = SymbolPolyfill("[[AbortSteps]]");
345
- const ErrorSteps = SymbolPolyfill("[[ErrorSteps]]");
346
- const CancelSteps = SymbolPolyfill("[[CancelSteps]]");
347
- const PullSteps = SymbolPolyfill("[[PullSteps]]");
348
348
  const NumberIsFinite = Number.isFinite || function(x2) {
349
349
  return typeof x2 === "number" && isFinite(x2);
350
350
  };
@@ -515,10 +515,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
515
515
  if (this._ownerReadableStream === void 0) {
516
516
  return;
517
517
  }
518
- if (this._readRequests.length > 0) {
519
- throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");
520
- }
521
- ReadableStreamReaderGenericRelease(this);
518
+ ReadableStreamDefaultReaderRelease(this);
522
519
  }
523
520
  }
524
521
  Object.defineProperties(ReadableStreamDefaultReader.prototype, {
@@ -527,8 +524,11 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
527
524
  releaseLock: { enumerable: true },
528
525
  closed: { enumerable: true }
529
526
  });
530
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
531
- Object.defineProperty(ReadableStreamDefaultReader.prototype, SymbolPolyfill.toStringTag, {
527
+ setFunctionName(ReadableStreamDefaultReader.prototype.cancel, "cancel");
528
+ setFunctionName(ReadableStreamDefaultReader.prototype.read, "read");
529
+ setFunctionName(ReadableStreamDefaultReader.prototype.releaseLock, "releaseLock");
530
+ if (typeof Symbol.toStringTag === "symbol") {
531
+ Object.defineProperty(ReadableStreamDefaultReader.prototype, Symbol.toStringTag, {
532
532
  value: "ReadableStreamDefaultReader",
533
533
  configurable: true
534
534
  });
@@ -553,6 +553,18 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
553
553
  stream._readableStreamController[PullSteps](readRequest);
554
554
  }
555
555
  }
556
+ function ReadableStreamDefaultReaderRelease(reader) {
557
+ ReadableStreamReaderGenericRelease(reader);
558
+ const e2 = new TypeError("Reader was released");
559
+ ReadableStreamDefaultReaderErrorReadRequests(reader, e2);
560
+ }
561
+ function ReadableStreamDefaultReaderErrorReadRequests(reader, e2) {
562
+ const readRequests = reader._readRequests;
563
+ reader._readRequests = new SimpleQueue();
564
+ readRequests.forEach((readRequest) => {
565
+ readRequest._errorSteps(e2);
566
+ });
567
+ }
556
568
  function defaultReaderBrandCheckException(name) {
557
569
  return new TypeError(`ReadableStreamDefaultReader.prototype.${name} can only be used on a ReadableStreamDefaultReader`);
558
570
  }
@@ -579,9 +591,6 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
579
591
  return Promise.resolve({ value: void 0, done: true });
580
592
  }
581
593
  const reader = this._reader;
582
- if (reader._ownerReadableStream === void 0) {
583
- return promiseRejectedWith(readerLockException("iterate"));
584
- }
585
594
  let resolvePromise;
586
595
  let rejectPromise;
587
596
  const promise = newPromise((resolve, reject) => {
@@ -591,7 +600,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
591
600
  const readRequest = {
592
601
  _chunkSteps: (chunk) => {
593
602
  this._ongoingPromise = void 0;
594
- queueMicrotask(() => resolvePromise({ value: chunk, done: false }));
603
+ _queueMicrotask(() => resolvePromise({ value: chunk, done: false }));
595
604
  },
596
605
  _closeSteps: () => {
597
606
  this._ongoingPromise = void 0;
@@ -615,9 +624,6 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
615
624
  }
616
625
  this._isFinished = true;
617
626
  const reader = this._reader;
618
- if (reader._ownerReadableStream === void 0) {
619
- return promiseRejectedWith(readerLockException("finish iterating"));
620
- }
621
627
  if (!this._preventCancel) {
622
628
  const result = ReadableStreamReaderGenericCancel(reader, value);
623
629
  ReadableStreamReaderGenericRelease(reader);
@@ -641,9 +647,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
641
647
  return this._asyncIteratorImpl.return(value);
642
648
  }
643
649
  };
644
- if (AsyncIteratorPrototype !== void 0) {
645
- Object.setPrototypeOf(ReadableStreamAsyncIteratorPrototype, AsyncIteratorPrototype);
646
- }
650
+ Object.setPrototypeOf(ReadableStreamAsyncIteratorPrototype, AsyncIteratorPrototype);
647
651
  function AcquireReadableStreamAsyncIterator(stream, preventCancel) {
648
652
  const reader = AcquireReadableStreamDefaultReader(stream);
649
653
  const impl = new ReadableStreamAsyncIteratorImpl(reader, preventCancel);
@@ -660,7 +664,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
660
664
  }
661
665
  try {
662
666
  return x2._asyncIteratorImpl instanceof ReadableStreamAsyncIteratorImpl;
663
- } catch (_a) {
667
+ } catch (_a2) {
664
668
  return false;
665
669
  }
666
670
  }
@@ -670,18 +674,31 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
670
674
  const NumberIsNaN = Number.isNaN || function(x2) {
671
675
  return x2 !== x2;
672
676
  };
677
+ var _a, _b, _c;
673
678
  function CreateArrayFromList(elements) {
674
679
  return elements.slice();
675
680
  }
676
681
  function CopyDataBlockBytes(dest, destOffset, src, srcOffset, n) {
677
682
  new Uint8Array(dest).set(new Uint8Array(src, srcOffset, n), destOffset);
678
683
  }
679
- function TransferArrayBuffer(O) {
680
- return O;
681
- }
682
- function IsDetachedBuffer(O) {
683
- return false;
684
- }
684
+ let TransferArrayBuffer = (O) => {
685
+ if (typeof O.transfer === "function") {
686
+ TransferArrayBuffer = (buffer) => buffer.transfer();
687
+ } else if (typeof structuredClone === "function") {
688
+ TransferArrayBuffer = (buffer) => structuredClone(buffer, { transfer: [buffer] });
689
+ } else {
690
+ TransferArrayBuffer = (buffer) => buffer;
691
+ }
692
+ return TransferArrayBuffer(O);
693
+ };
694
+ let IsDetachedBuffer = (O) => {
695
+ if (typeof O.detached === "boolean") {
696
+ IsDetachedBuffer = (buffer) => buffer.detached;
697
+ } else {
698
+ IsDetachedBuffer = (buffer) => buffer.byteLength === 0;
699
+ }
700
+ return IsDetachedBuffer(O);
701
+ };
685
702
  function ArrayBufferSlice(buffer, begin, end) {
686
703
  if (buffer.slice) {
687
704
  return buffer.slice(begin, end);
@@ -691,6 +708,63 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
691
708
  CopyDataBlockBytes(slice, 0, buffer, begin, length);
692
709
  return slice;
693
710
  }
711
+ function GetMethod(receiver, prop) {
712
+ const func = receiver[prop];
713
+ if (func === void 0 || func === null) {
714
+ return void 0;
715
+ }
716
+ if (typeof func !== "function") {
717
+ throw new TypeError(`${String(prop)} is not a function`);
718
+ }
719
+ return func;
720
+ }
721
+ function CreateAsyncFromSyncIterator(syncIteratorRecord) {
722
+ const syncIterable = {
723
+ [Symbol.iterator]: () => syncIteratorRecord.iterator
724
+ };
725
+ const asyncIterator = async function* () {
726
+ return yield* syncIterable;
727
+ }();
728
+ const nextMethod = asyncIterator.next;
729
+ return { iterator: asyncIterator, nextMethod, done: false };
730
+ }
731
+ const SymbolAsyncIterator = (_c = (_a = Symbol.asyncIterator) !== null && _a !== void 0 ? _a : (_b = Symbol.for) === null || _b === void 0 ? void 0 : _b.call(Symbol, "Symbol.asyncIterator")) !== null && _c !== void 0 ? _c : "@@asyncIterator";
732
+ function GetIterator(obj, hint = "sync", method) {
733
+ if (method === void 0) {
734
+ if (hint === "async") {
735
+ method = GetMethod(obj, SymbolAsyncIterator);
736
+ if (method === void 0) {
737
+ const syncMethod = GetMethod(obj, Symbol.iterator);
738
+ const syncIteratorRecord = GetIterator(obj, "sync", syncMethod);
739
+ return CreateAsyncFromSyncIterator(syncIteratorRecord);
740
+ }
741
+ } else {
742
+ method = GetMethod(obj, Symbol.iterator);
743
+ }
744
+ }
745
+ if (method === void 0) {
746
+ throw new TypeError("The object is not iterable");
747
+ }
748
+ const iterator = reflectCall(method, obj, []);
749
+ if (!typeIsObject(iterator)) {
750
+ throw new TypeError("The iterator method must return an object");
751
+ }
752
+ const nextMethod = iterator.next;
753
+ return { iterator, nextMethod, done: false };
754
+ }
755
+ function IteratorNext(iteratorRecord) {
756
+ const result = reflectCall(iteratorRecord.nextMethod, iteratorRecord.iterator, []);
757
+ if (!typeIsObject(result)) {
758
+ throw new TypeError("The iterator.next() method must return an object");
759
+ }
760
+ return result;
761
+ }
762
+ function IteratorComplete(iterResult) {
763
+ return Boolean(iterResult.done);
764
+ }
765
+ function IteratorValue(iterResult) {
766
+ return iterResult.value;
767
+ }
694
768
  function IsNonNegativeNumber(v) {
695
769
  if (typeof v !== "number") {
696
770
  return false;
@@ -730,6 +804,18 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
730
804
  container._queue = new SimpleQueue();
731
805
  container._queueTotalSize = 0;
732
806
  }
807
+ function isDataViewConstructor(ctor) {
808
+ return ctor === DataView;
809
+ }
810
+ function isDataView(view) {
811
+ return isDataViewConstructor(view.constructor);
812
+ }
813
+ function arrayBufferViewElementSize(ctor) {
814
+ if (isDataViewConstructor(ctor)) {
815
+ return 1;
816
+ }
817
+ return ctor.BYTES_PER_ELEMENT;
818
+ }
733
819
  class ReadableStreamBYOBRequest {
734
820
  constructor() {
735
821
  throw new TypeError("Illegal constructor");
@@ -752,7 +838,9 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
752
838
  if (this._associatedReadableByteStreamController === void 0) {
753
839
  throw new TypeError("This BYOB request has been invalidated");
754
840
  }
755
- if (IsDetachedBuffer(this._view.buffer)) ;
841
+ if (IsDetachedBuffer(this._view.buffer)) {
842
+ throw new TypeError(`The BYOB request's buffer has been detached and so cannot be used as a response`);
843
+ }
756
844
  ReadableByteStreamControllerRespond(this._associatedReadableByteStreamController, bytesWritten);
757
845
  }
758
846
  respondWithNewView(view) {
@@ -766,7 +854,9 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
766
854
  if (this._associatedReadableByteStreamController === void 0) {
767
855
  throw new TypeError("This BYOB request has been invalidated");
768
856
  }
769
- if (IsDetachedBuffer(view.buffer)) ;
857
+ if (IsDetachedBuffer(view.buffer)) {
858
+ throw new TypeError("The given view's buffer has been detached and so cannot be used as a response");
859
+ }
770
860
  ReadableByteStreamControllerRespondWithNewView(this._associatedReadableByteStreamController, view);
771
861
  }
772
862
  }
@@ -775,8 +865,10 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
775
865
  respondWithNewView: { enumerable: true },
776
866
  view: { enumerable: true }
777
867
  });
778
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
779
- Object.defineProperty(ReadableStreamBYOBRequest.prototype, SymbolPolyfill.toStringTag, {
868
+ setFunctionName(ReadableStreamBYOBRequest.prototype.respond, "respond");
869
+ setFunctionName(ReadableStreamBYOBRequest.prototype.respondWithNewView, "respondWithNewView");
870
+ if (typeof Symbol.toStringTag === "symbol") {
871
+ Object.defineProperty(ReadableStreamBYOBRequest.prototype, Symbol.toStringTag, {
780
872
  value: "ReadableStreamBYOBRequest",
781
873
  configurable: true
782
874
  });
@@ -865,11 +957,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
865
957
  [PullSteps](readRequest) {
866
958
  const stream = this._controlledReadableByteStream;
867
959
  if (this._queueTotalSize > 0) {
868
- const entry = this._queue.shift();
869
- this._queueTotalSize -= entry.byteLength;
870
- ReadableByteStreamControllerHandleQueueDrain(this);
871
- const view = new Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);
872
- readRequest._chunkSteps(view);
960
+ ReadableByteStreamControllerFillReadRequestFromQueue(this, readRequest);
873
961
  return;
874
962
  }
875
963
  const autoAllocateChunkSize = this._autoAllocateChunkSize;
@@ -887,6 +975,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
887
975
  byteOffset: 0,
888
976
  byteLength: autoAllocateChunkSize,
889
977
  bytesFilled: 0,
978
+ minimumFill: 1,
890
979
  elementSize: 1,
891
980
  viewConstructor: Uint8Array,
892
981
  readerType: "default"
@@ -896,6 +985,15 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
896
985
  ReadableStreamAddReadRequest(stream, readRequest);
897
986
  ReadableByteStreamControllerCallPullIfNeeded(this);
898
987
  }
988
+ /** @internal */
989
+ [ReleaseSteps]() {
990
+ if (this._pendingPullIntos.length > 0) {
991
+ const firstPullInto = this._pendingPullIntos.peek();
992
+ firstPullInto.readerType = "none";
993
+ this._pendingPullIntos = new SimpleQueue();
994
+ this._pendingPullIntos.push(firstPullInto);
995
+ }
996
+ }
899
997
  }
900
998
  Object.defineProperties(ReadableByteStreamController.prototype, {
901
999
  close: { enumerable: true },
@@ -904,8 +1002,11 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
904
1002
  byobRequest: { enumerable: true },
905
1003
  desiredSize: { enumerable: true }
906
1004
  });
907
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
908
- Object.defineProperty(ReadableByteStreamController.prototype, SymbolPolyfill.toStringTag, {
1005
+ setFunctionName(ReadableByteStreamController.prototype.close, "close");
1006
+ setFunctionName(ReadableByteStreamController.prototype.enqueue, "enqueue");
1007
+ setFunctionName(ReadableByteStreamController.prototype.error, "error");
1008
+ if (typeof Symbol.toStringTag === "symbol") {
1009
+ Object.defineProperty(ReadableByteStreamController.prototype, Symbol.toStringTag, {
909
1010
  value: "ReadableByteStreamController",
910
1011
  configurable: true
911
1012
  });
@@ -945,8 +1046,10 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
945
1046
  controller._pullAgain = false;
946
1047
  ReadableByteStreamControllerCallPullIfNeeded(controller);
947
1048
  }
1049
+ return null;
948
1050
  }, (e2) => {
949
1051
  ReadableByteStreamControllerError(controller, e2);
1052
+ return null;
950
1053
  });
951
1054
  }
952
1055
  function ReadableByteStreamControllerClearPendingPullIntos(controller) {
@@ -974,15 +1077,30 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
974
1077
  controller._queue.push({ buffer, byteOffset, byteLength });
975
1078
  controller._queueTotalSize += byteLength;
976
1079
  }
1080
+ function ReadableByteStreamControllerEnqueueClonedChunkToQueue(controller, buffer, byteOffset, byteLength) {
1081
+ let clonedChunk;
1082
+ try {
1083
+ clonedChunk = ArrayBufferSlice(buffer, byteOffset, byteOffset + byteLength);
1084
+ } catch (cloneE) {
1085
+ ReadableByteStreamControllerError(controller, cloneE);
1086
+ throw cloneE;
1087
+ }
1088
+ ReadableByteStreamControllerEnqueueChunkToQueue(controller, clonedChunk, 0, byteLength);
1089
+ }
1090
+ function ReadableByteStreamControllerEnqueueDetachedPullIntoToQueue(controller, firstDescriptor) {
1091
+ if (firstDescriptor.bytesFilled > 0) {
1092
+ ReadableByteStreamControllerEnqueueClonedChunkToQueue(controller, firstDescriptor.buffer, firstDescriptor.byteOffset, firstDescriptor.bytesFilled);
1093
+ }
1094
+ ReadableByteStreamControllerShiftPendingPullInto(controller);
1095
+ }
977
1096
  function ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) {
978
- const elementSize = pullIntoDescriptor.elementSize;
979
- const currentAlignedBytes = pullIntoDescriptor.bytesFilled - pullIntoDescriptor.bytesFilled % elementSize;
980
1097
  const maxBytesToCopy = Math.min(controller._queueTotalSize, pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled);
981
1098
  const maxBytesFilled = pullIntoDescriptor.bytesFilled + maxBytesToCopy;
982
- const maxAlignedBytes = maxBytesFilled - maxBytesFilled % elementSize;
983
1099
  let totalBytesToCopyRemaining = maxBytesToCopy;
984
1100
  let ready = false;
985
- if (maxAlignedBytes > currentAlignedBytes) {
1101
+ const remainderBytes = maxBytesFilled % pullIntoDescriptor.elementSize;
1102
+ const maxAlignedBytes = maxBytesFilled - remainderBytes;
1103
+ if (maxAlignedBytes >= pullIntoDescriptor.minimumFill) {
986
1104
  totalBytesToCopyRemaining = maxAlignedBytes - pullIntoDescriptor.bytesFilled;
987
1105
  ready = true;
988
1106
  }
@@ -1035,20 +1153,36 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
1035
1153
  }
1036
1154
  }
1037
1155
  }
1038
- function ReadableByteStreamControllerPullInto(controller, view, readIntoRequest) {
1039
- const stream = controller._controlledReadableByteStream;
1040
- let elementSize = 1;
1041
- if (view.constructor !== DataView) {
1042
- elementSize = view.constructor.BYTES_PER_ELEMENT;
1156
+ function ReadableByteStreamControllerProcessReadRequestsUsingQueue(controller) {
1157
+ const reader = controller._controlledReadableByteStream._reader;
1158
+ while (reader._readRequests.length > 0) {
1159
+ if (controller._queueTotalSize === 0) {
1160
+ return;
1161
+ }
1162
+ const readRequest = reader._readRequests.shift();
1163
+ ReadableByteStreamControllerFillReadRequestFromQueue(controller, readRequest);
1043
1164
  }
1165
+ }
1166
+ function ReadableByteStreamControllerPullInto(controller, view, min, readIntoRequest) {
1167
+ const stream = controller._controlledReadableByteStream;
1044
1168
  const ctor = view.constructor;
1045
- const buffer = TransferArrayBuffer(view.buffer);
1169
+ const elementSize = arrayBufferViewElementSize(ctor);
1170
+ const { byteOffset, byteLength } = view;
1171
+ const minimumFill = min * elementSize;
1172
+ let buffer;
1173
+ try {
1174
+ buffer = TransferArrayBuffer(view.buffer);
1175
+ } catch (e2) {
1176
+ readIntoRequest._errorSteps(e2);
1177
+ return;
1178
+ }
1046
1179
  const pullIntoDescriptor = {
1047
1180
  buffer,
1048
1181
  bufferByteLength: buffer.byteLength,
1049
- byteOffset: view.byteOffset,
1050
- byteLength: view.byteLength,
1182
+ byteOffset,
1183
+ byteLength,
1051
1184
  bytesFilled: 0,
1185
+ minimumFill,
1052
1186
  elementSize,
1053
1187
  viewConstructor: ctor,
1054
1188
  readerType: "byob"
@@ -1082,6 +1216,9 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
1082
1216
  ReadableByteStreamControllerCallPullIfNeeded(controller);
1083
1217
  }
1084
1218
  function ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor) {
1219
+ if (firstDescriptor.readerType === "none") {
1220
+ ReadableByteStreamControllerShiftPendingPullInto(controller);
1221
+ }
1085
1222
  const stream = controller._controlledReadableByteStream;
1086
1223
  if (ReadableStreamHasBYOBReader(stream)) {
1087
1224
  while (ReadableStreamGetNumReadIntoRequests(stream) > 0) {
@@ -1092,15 +1229,19 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
1092
1229
  }
1093
1230
  function ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, pullIntoDescriptor) {
1094
1231
  ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesWritten, pullIntoDescriptor);
1095
- if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize) {
1232
+ if (pullIntoDescriptor.readerType === "none") {
1233
+ ReadableByteStreamControllerEnqueueDetachedPullIntoToQueue(controller, pullIntoDescriptor);
1234
+ ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
1235
+ return;
1236
+ }
1237
+ if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.minimumFill) {
1096
1238
  return;
1097
1239
  }
1098
1240
  ReadableByteStreamControllerShiftPendingPullInto(controller);
1099
1241
  const remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize;
1100
1242
  if (remainderSize > 0) {
1101
1243
  const end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
1102
- const remainder = ArrayBufferSlice(pullIntoDescriptor.buffer, end - remainderSize, end);
1103
- ReadableByteStreamControllerEnqueueChunkToQueue(controller, remainder, 0, remainder.byteLength);
1244
+ ReadableByteStreamControllerEnqueueClonedChunkToQueue(controller, pullIntoDescriptor.buffer, end - remainderSize, remainderSize);
1104
1245
  }
1105
1246
  pullIntoDescriptor.bytesFilled -= remainderSize;
1106
1247
  ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableByteStream, pullIntoDescriptor);
@@ -1111,7 +1252,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
1111
1252
  ReadableByteStreamControllerInvalidateBYOBRequest(controller);
1112
1253
  const state = controller._controlledReadableByteStream._state;
1113
1254
  if (state === "closed") {
1114
- ReadableByteStreamControllerRespondInClosedState(controller);
1255
+ ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor);
1115
1256
  } else {
1116
1257
  ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor);
1117
1258
  }
@@ -1159,7 +1300,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
1159
1300
  }
1160
1301
  if (controller._pendingPullIntos.length > 0) {
1161
1302
  const firstPendingPullInto = controller._pendingPullIntos.peek();
1162
- if (firstPendingPullInto.bytesFilled > 0) {
1303
+ if (firstPendingPullInto.bytesFilled % firstPendingPullInto.elementSize !== 0) {
1163
1304
  const e2 = new TypeError("Insufficient bytes to fill elements in the given buffer");
1164
1305
  ReadableByteStreamControllerError(controller, e2);
1165
1306
  throw e2;
@@ -1173,17 +1314,24 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
1173
1314
  if (controller._closeRequested || stream._state !== "readable") {
1174
1315
  return;
1175
1316
  }
1176
- const buffer = chunk.buffer;
1177
- const byteOffset = chunk.byteOffset;
1178
- const byteLength = chunk.byteLength;
1317
+ const { buffer, byteOffset, byteLength } = chunk;
1318
+ if (IsDetachedBuffer(buffer)) {
1319
+ throw new TypeError("chunk's buffer is detached and so cannot be enqueued");
1320
+ }
1179
1321
  const transferredBuffer = TransferArrayBuffer(buffer);
1180
1322
  if (controller._pendingPullIntos.length > 0) {
1181
1323
  const firstPendingPullInto = controller._pendingPullIntos.peek();
1182
- if (IsDetachedBuffer(firstPendingPullInto.buffer)) ;
1324
+ if (IsDetachedBuffer(firstPendingPullInto.buffer)) {
1325
+ throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk");
1326
+ }
1327
+ ReadableByteStreamControllerInvalidateBYOBRequest(controller);
1183
1328
  firstPendingPullInto.buffer = TransferArrayBuffer(firstPendingPullInto.buffer);
1329
+ if (firstPendingPullInto.readerType === "none") {
1330
+ ReadableByteStreamControllerEnqueueDetachedPullIntoToQueue(controller, firstPendingPullInto);
1331
+ }
1184
1332
  }
1185
- ReadableByteStreamControllerInvalidateBYOBRequest(controller);
1186
1333
  if (ReadableStreamHasDefaultReader(stream)) {
1334
+ ReadableByteStreamControllerProcessReadRequestsUsingQueue(controller);
1187
1335
  if (ReadableStreamGetNumReadRequests(stream) === 0) {
1188
1336
  ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
1189
1337
  } else {
@@ -1211,6 +1359,13 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
1211
1359
  ReadableByteStreamControllerClearAlgorithms(controller);
1212
1360
  ReadableStreamError(stream, e2);
1213
1361
  }
1362
+ function ReadableByteStreamControllerFillReadRequestFromQueue(controller, readRequest) {
1363
+ const entry = controller._queue.shift();
1364
+ controller._queueTotalSize -= entry.byteLength;
1365
+ ReadableByteStreamControllerHandleQueueDrain(controller);
1366
+ const view = new Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);
1367
+ readRequest._chunkSteps(view);
1368
+ }
1214
1369
  function ReadableByteStreamControllerGetBYOBRequest(controller) {
1215
1370
  if (controller._byobRequest === null && controller._pendingPullIntos.length > 0) {
1216
1371
  const firstDescriptor = controller._pendingPullIntos.peek();
@@ -1293,23 +1448,31 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
1293
1448
  uponPromise(promiseResolvedWith(startResult), () => {
1294
1449
  controller._started = true;
1295
1450
  ReadableByteStreamControllerCallPullIfNeeded(controller);
1451
+ return null;
1296
1452
  }, (r2) => {
1297
1453
  ReadableByteStreamControllerError(controller, r2);
1454
+ return null;
1298
1455
  });
1299
1456
  }
1300
1457
  function SetUpReadableByteStreamControllerFromUnderlyingSource(stream, underlyingByteSource, highWaterMark) {
1301
1458
  const controller = Object.create(ReadableByteStreamController.prototype);
1302
- let startAlgorithm = () => void 0;
1303
- let pullAlgorithm = () => promiseResolvedWith(void 0);
1304
- let cancelAlgorithm = () => promiseResolvedWith(void 0);
1459
+ let startAlgorithm;
1460
+ let pullAlgorithm;
1461
+ let cancelAlgorithm;
1305
1462
  if (underlyingByteSource.start !== void 0) {
1306
1463
  startAlgorithm = () => underlyingByteSource.start(controller);
1464
+ } else {
1465
+ startAlgorithm = () => void 0;
1307
1466
  }
1308
1467
  if (underlyingByteSource.pull !== void 0) {
1309
1468
  pullAlgorithm = () => underlyingByteSource.pull(controller);
1469
+ } else {
1470
+ pullAlgorithm = () => promiseResolvedWith(void 0);
1310
1471
  }
1311
1472
  if (underlyingByteSource.cancel !== void 0) {
1312
1473
  cancelAlgorithm = (reason) => underlyingByteSource.cancel(reason);
1474
+ } else {
1475
+ cancelAlgorithm = () => promiseResolvedWith(void 0);
1313
1476
  }
1314
1477
  const autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize;
1315
1478
  if (autoAllocateChunkSize === 0) {
@@ -1327,6 +1490,28 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
1327
1490
  function byteStreamControllerBrandCheckException(name) {
1328
1491
  return new TypeError(`ReadableByteStreamController.prototype.${name} can only be used on a ReadableByteStreamController`);
1329
1492
  }
1493
+ function convertReaderOptions(options, context) {
1494
+ assertDictionary(options, context);
1495
+ const mode = options === null || options === void 0 ? void 0 : options.mode;
1496
+ return {
1497
+ mode: mode === void 0 ? void 0 : convertReadableStreamReaderMode(mode, `${context} has member 'mode' that`)
1498
+ };
1499
+ }
1500
+ function convertReadableStreamReaderMode(mode, context) {
1501
+ mode = `${mode}`;
1502
+ if (mode !== "byob") {
1503
+ throw new TypeError(`${context} '${mode}' is not a valid enumeration value for ReadableStreamReaderMode`);
1504
+ }
1505
+ return mode;
1506
+ }
1507
+ function convertByobReadOptions(options, context) {
1508
+ var _a2;
1509
+ assertDictionary(options, context);
1510
+ const min = (_a2 = options === null || options === void 0 ? void 0 : options.min) !== null && _a2 !== void 0 ? _a2 : 1;
1511
+ return {
1512
+ min: convertUnsignedLongLongWithEnforceRange(min, `${context} has member 'min' that`)
1513
+ };
1514
+ }
1330
1515
  function AcquireReadableStreamBYOBReader(stream) {
1331
1516
  return new ReadableStreamBYOBReader(stream);
1332
1517
  }
@@ -1390,12 +1575,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
1390
1575
  }
1391
1576
  return ReadableStreamReaderGenericCancel(this, reason);
1392
1577
  }
1393
- /**
1394
- * Attempts to reads bytes into view, and returns a promise resolved with the result.
1395
- *
1396
- * If reading a chunk causes the queue to become empty, more data will be pulled from the underlying source.
1397
- */
1398
- read(view) {
1578
+ read(view, rawOptions = {}) {
1399
1579
  if (!IsReadableStreamBYOBReader(this)) {
1400
1580
  return promiseRejectedWith(byobReaderBrandCheckException("read"));
1401
1581
  }
@@ -1408,7 +1588,26 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
1408
1588
  if (view.buffer.byteLength === 0) {
1409
1589
  return promiseRejectedWith(new TypeError(`view's buffer must have non-zero byteLength`));
1410
1590
  }
1411
- if (IsDetachedBuffer(view.buffer)) ;
1591
+ if (IsDetachedBuffer(view.buffer)) {
1592
+ return promiseRejectedWith(new TypeError("view's buffer has been detached"));
1593
+ }
1594
+ let options;
1595
+ try {
1596
+ options = convertByobReadOptions(rawOptions, "options");
1597
+ } catch (e2) {
1598
+ return promiseRejectedWith(e2);
1599
+ }
1600
+ const min = options.min;
1601
+ if (min === 0) {
1602
+ return promiseRejectedWith(new TypeError("options.min must be greater than 0"));
1603
+ }
1604
+ if (!isDataView(view)) {
1605
+ if (min > view.length) {
1606
+ return promiseRejectedWith(new RangeError("options.min must be less than or equal to view's length"));
1607
+ }
1608
+ } else if (min > view.byteLength) {
1609
+ return promiseRejectedWith(new RangeError("options.min must be less than or equal to view's byteLength"));
1610
+ }
1412
1611
  if (this._ownerReadableStream === void 0) {
1413
1612
  return promiseRejectedWith(readerLockException("read from"));
1414
1613
  }
@@ -1423,7 +1622,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
1423
1622
  _closeSteps: (chunk) => resolvePromise({ value: chunk, done: true }),
1424
1623
  _errorSteps: (e2) => rejectPromise(e2)
1425
1624
  };
1426
- ReadableStreamBYOBReaderRead(this, view, readIntoRequest);
1625
+ ReadableStreamBYOBReaderRead(this, view, min, readIntoRequest);
1427
1626
  return promise;
1428
1627
  }
1429
1628
  /**
@@ -1442,10 +1641,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
1442
1641
  if (this._ownerReadableStream === void 0) {
1443
1642
  return;
1444
1643
  }
1445
- if (this._readIntoRequests.length > 0) {
1446
- throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");
1447
- }
1448
- ReadableStreamReaderGenericRelease(this);
1644
+ ReadableStreamBYOBReaderRelease(this);
1449
1645
  }
1450
1646
  }
1451
1647
  Object.defineProperties(ReadableStreamBYOBReader.prototype, {
@@ -1454,8 +1650,11 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
1454
1650
  releaseLock: { enumerable: true },
1455
1651
  closed: { enumerable: true }
1456
1652
  });
1457
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
1458
- Object.defineProperty(ReadableStreamBYOBReader.prototype, SymbolPolyfill.toStringTag, {
1653
+ setFunctionName(ReadableStreamBYOBReader.prototype.cancel, "cancel");
1654
+ setFunctionName(ReadableStreamBYOBReader.prototype.read, "read");
1655
+ setFunctionName(ReadableStreamBYOBReader.prototype.releaseLock, "releaseLock");
1656
+ if (typeof Symbol.toStringTag === "symbol") {
1657
+ Object.defineProperty(ReadableStreamBYOBReader.prototype, Symbol.toStringTag, {
1459
1658
  value: "ReadableStreamBYOBReader",
1460
1659
  configurable: true
1461
1660
  });
@@ -1469,15 +1668,27 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
1469
1668
  }
1470
1669
  return x2 instanceof ReadableStreamBYOBReader;
1471
1670
  }
1472
- function ReadableStreamBYOBReaderRead(reader, view, readIntoRequest) {
1671
+ function ReadableStreamBYOBReaderRead(reader, view, min, readIntoRequest) {
1473
1672
  const stream = reader._ownerReadableStream;
1474
1673
  stream._disturbed = true;
1475
1674
  if (stream._state === "errored") {
1476
1675
  readIntoRequest._errorSteps(stream._storedError);
1477
1676
  } else {
1478
- ReadableByteStreamControllerPullInto(stream._readableStreamController, view, readIntoRequest);
1677
+ ReadableByteStreamControllerPullInto(stream._readableStreamController, view, min, readIntoRequest);
1479
1678
  }
1480
1679
  }
1680
+ function ReadableStreamBYOBReaderRelease(reader) {
1681
+ ReadableStreamReaderGenericRelease(reader);
1682
+ const e2 = new TypeError("Reader was released");
1683
+ ReadableStreamBYOBReaderErrorReadIntoRequests(reader, e2);
1684
+ }
1685
+ function ReadableStreamBYOBReaderErrorReadIntoRequests(reader, e2) {
1686
+ const readIntoRequests = reader._readIntoRequests;
1687
+ reader._readIntoRequests = new SimpleQueue();
1688
+ readIntoRequests.forEach((readIntoRequest) => {
1689
+ readIntoRequest._errorSteps(e2);
1690
+ });
1691
+ }
1481
1692
  function byobReaderBrandCheckException(name) {
1482
1693
  return new TypeError(`ReadableStreamBYOBReader.prototype.${name} can only be used on a ReadableStreamBYOBReader`);
1483
1694
  }
@@ -1553,7 +1764,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
1553
1764
  }
1554
1765
  try {
1555
1766
  return typeof value.aborted === "boolean";
1556
- } catch (_a) {
1767
+ } catch (_a2) {
1557
1768
  return false;
1558
1769
  }
1559
1770
  }
@@ -1650,8 +1861,11 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
1650
1861
  getWriter: { enumerable: true },
1651
1862
  locked: { enumerable: true }
1652
1863
  });
1653
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
1654
- Object.defineProperty(WritableStream.prototype, SymbolPolyfill.toStringTag, {
1864
+ setFunctionName(WritableStream.prototype.abort, "abort");
1865
+ setFunctionName(WritableStream.prototype.close, "close");
1866
+ setFunctionName(WritableStream.prototype.getWriter, "getWriter");
1867
+ if (typeof Symbol.toStringTag === "symbol") {
1868
+ Object.defineProperty(WritableStream.prototype, Symbol.toStringTag, {
1655
1869
  value: "WritableStream",
1656
1870
  configurable: true
1657
1871
  });
@@ -1694,12 +1908,12 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
1694
1908
  return true;
1695
1909
  }
1696
1910
  function WritableStreamAbort(stream, reason) {
1697
- var _a;
1911
+ var _a2;
1698
1912
  if (stream._state === "closed" || stream._state === "errored") {
1699
1913
  return promiseResolvedWith(void 0);
1700
1914
  }
1701
1915
  stream._writableStreamController._abortReason = reason;
1702
- (_a = stream._writableStreamController._abortController) === null || _a === void 0 ? void 0 : _a.abort();
1916
+ (_a2 = stream._writableStreamController._abortController) === null || _a2 === void 0 ? void 0 : _a2.abort(reason);
1703
1917
  const state = stream._state;
1704
1918
  if (state === "closed" || state === "errored") {
1705
1919
  return promiseResolvedWith(void 0);
@@ -1799,9 +2013,11 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
1799
2013
  uponPromise(promise, () => {
1800
2014
  abortRequest._resolve();
1801
2015
  WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
2016
+ return null;
1802
2017
  }, (reason) => {
1803
2018
  abortRequest._reject(reason);
1804
2019
  WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
2020
+ return null;
1805
2021
  });
1806
2022
  }
1807
2023
  function WritableStreamFinishInFlightWrite(stream) {
@@ -2016,8 +2232,12 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
2016
2232
  desiredSize: { enumerable: true },
2017
2233
  ready: { enumerable: true }
2018
2234
  });
2019
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
2020
- Object.defineProperty(WritableStreamDefaultWriter.prototype, SymbolPolyfill.toStringTag, {
2235
+ setFunctionName(WritableStreamDefaultWriter.prototype.abort, "abort");
2236
+ setFunctionName(WritableStreamDefaultWriter.prototype.close, "close");
2237
+ setFunctionName(WritableStreamDefaultWriter.prototype.releaseLock, "releaseLock");
2238
+ setFunctionName(WritableStreamDefaultWriter.prototype.write, "write");
2239
+ if (typeof Symbol.toStringTag === "symbol") {
2240
+ Object.defineProperty(WritableStreamDefaultWriter.prototype, Symbol.toStringTag, {
2021
2241
  value: "WritableStreamDefaultWriter",
2022
2242
  configurable: true
2023
2243
  });
@@ -2167,8 +2387,8 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
2167
2387
  signal: { enumerable: true },
2168
2388
  error: { enumerable: true }
2169
2389
  });
2170
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
2171
- Object.defineProperty(WritableStreamDefaultController.prototype, SymbolPolyfill.toStringTag, {
2390
+ if (typeof Symbol.toStringTag === "symbol") {
2391
+ Object.defineProperty(WritableStreamDefaultController.prototype, Symbol.toStringTag, {
2172
2392
  value: "WritableStreamDefaultController",
2173
2393
  configurable: true
2174
2394
  });
@@ -2203,28 +2423,38 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
2203
2423
  uponPromise(startPromise, () => {
2204
2424
  controller._started = true;
2205
2425
  WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
2426
+ return null;
2206
2427
  }, (r2) => {
2207
2428
  controller._started = true;
2208
2429
  WritableStreamDealWithRejection(stream, r2);
2430
+ return null;
2209
2431
  });
2210
2432
  }
2211
2433
  function SetUpWritableStreamDefaultControllerFromUnderlyingSink(stream, underlyingSink, highWaterMark, sizeAlgorithm) {
2212
2434
  const controller = Object.create(WritableStreamDefaultController.prototype);
2213
- let startAlgorithm = () => void 0;
2214
- let writeAlgorithm = () => promiseResolvedWith(void 0);
2215
- let closeAlgorithm = () => promiseResolvedWith(void 0);
2216
- let abortAlgorithm = () => promiseResolvedWith(void 0);
2435
+ let startAlgorithm;
2436
+ let writeAlgorithm;
2437
+ let closeAlgorithm;
2438
+ let abortAlgorithm;
2217
2439
  if (underlyingSink.start !== void 0) {
2218
2440
  startAlgorithm = () => underlyingSink.start(controller);
2441
+ } else {
2442
+ startAlgorithm = () => void 0;
2219
2443
  }
2220
2444
  if (underlyingSink.write !== void 0) {
2221
2445
  writeAlgorithm = (chunk) => underlyingSink.write(chunk, controller);
2446
+ } else {
2447
+ writeAlgorithm = () => promiseResolvedWith(void 0);
2222
2448
  }
2223
2449
  if (underlyingSink.close !== void 0) {
2224
2450
  closeAlgorithm = () => underlyingSink.close();
2451
+ } else {
2452
+ closeAlgorithm = () => promiseResolvedWith(void 0);
2225
2453
  }
2226
2454
  if (underlyingSink.abort !== void 0) {
2227
2455
  abortAlgorithm = (reason) => underlyingSink.abort(reason);
2456
+ } else {
2457
+ abortAlgorithm = () => promiseResolvedWith(void 0);
2228
2458
  }
2229
2459
  SetUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm);
2230
2460
  }
@@ -2299,8 +2529,10 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
2299
2529
  WritableStreamDefaultControllerClearAlgorithms(controller);
2300
2530
  uponPromise(sinkClosePromise, () => {
2301
2531
  WritableStreamFinishInFlightClose(stream);
2532
+ return null;
2302
2533
  }, (reason) => {
2303
2534
  WritableStreamFinishInFlightCloseWithError(stream, reason);
2535
+ return null;
2304
2536
  });
2305
2537
  }
2306
2538
  function WritableStreamDefaultControllerProcessWrite(controller, chunk) {
@@ -2316,11 +2548,13 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
2316
2548
  WritableStreamUpdateBackpressure(stream, backpressure);
2317
2549
  }
2318
2550
  WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
2551
+ return null;
2319
2552
  }, (reason) => {
2320
2553
  if (stream._state === "writable") {
2321
2554
  WritableStreamDefaultControllerClearAlgorithms(controller);
2322
2555
  }
2323
2556
  WritableStreamFinishInFlightWriteWithError(stream, reason);
2557
+ return null;
2324
2558
  });
2325
2559
  }
2326
2560
  function WritableStreamDefaultControllerGetBackpressure(controller) {
@@ -2421,19 +2655,36 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
2421
2655
  writer._readyPromise_reject = void 0;
2422
2656
  writer._readyPromiseState = "fulfilled";
2423
2657
  }
2424
- const NativeDOMException = typeof DOMException !== "undefined" ? DOMException : void 0;
2658
+ function getGlobals() {
2659
+ if (typeof globalThis !== "undefined") {
2660
+ return globalThis;
2661
+ } else if (typeof self !== "undefined") {
2662
+ return self;
2663
+ } else if (typeof global !== "undefined") {
2664
+ return global;
2665
+ }
2666
+ return void 0;
2667
+ }
2668
+ const globals = getGlobals();
2425
2669
  function isDOMExceptionConstructor(ctor) {
2426
2670
  if (!(typeof ctor === "function" || typeof ctor === "object")) {
2427
2671
  return false;
2428
2672
  }
2673
+ if (ctor.name !== "DOMException") {
2674
+ return false;
2675
+ }
2429
2676
  try {
2430
2677
  new ctor();
2431
2678
  return true;
2432
- } catch (_a) {
2679
+ } catch (_a2) {
2433
2680
  return false;
2434
2681
  }
2435
2682
  }
2436
- function createDOMExceptionPolyfill() {
2683
+ function getFromGlobal() {
2684
+ const ctor = globals === null || globals === void 0 ? void 0 : globals.DOMException;
2685
+ return isDOMExceptionConstructor(ctor) ? ctor : void 0;
2686
+ }
2687
+ function createPolyfill() {
2437
2688
  const ctor = function DOMException3(message, name) {
2438
2689
  this.message = message || "";
2439
2690
  this.name = name || "Error";
@@ -2441,11 +2692,12 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
2441
2692
  Error.captureStackTrace(this, this.constructor);
2442
2693
  }
2443
2694
  };
2695
+ setFunctionName(ctor, "DOMException");
2444
2696
  ctor.prototype = Object.create(Error.prototype);
2445
2697
  Object.defineProperty(ctor.prototype, "constructor", { value: ctor, writable: true, configurable: true });
2446
2698
  return ctor;
2447
2699
  }
2448
- const DOMException$1 = isDOMExceptionConstructor(NativeDOMException) ? NativeDOMException : createDOMExceptionPolyfill();
2700
+ const DOMException2 = getFromGlobal() || createPolyfill();
2449
2701
  function ReadableStreamPipeTo(source, dest, preventClose, preventAbort, preventCancel, signal) {
2450
2702
  const reader = AcquireReadableStreamDefaultReader(source);
2451
2703
  const writer = AcquireWritableStreamDefaultWriter(dest);
@@ -2456,7 +2708,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
2456
2708
  let abortAlgorithm;
2457
2709
  if (signal !== void 0) {
2458
2710
  abortAlgorithm = () => {
2459
- const error = new DOMException$1("Aborted", "AbortError");
2711
+ const error = signal.reason !== void 0 ? signal.reason : new DOMException2("Aborted", "AbortError");
2460
2712
  const actions = [];
2461
2713
  if (!preventAbort) {
2462
2714
  actions.push(() => {
@@ -2517,6 +2769,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
2517
2769
  } else {
2518
2770
  shutdown(true, storedError);
2519
2771
  }
2772
+ return null;
2520
2773
  });
2521
2774
  isOrBecomesErrored(dest, writer._closedPromise, (storedError) => {
2522
2775
  if (!preventCancel) {
@@ -2524,6 +2777,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
2524
2777
  } else {
2525
2778
  shutdown(true, storedError);
2526
2779
  }
2780
+ return null;
2527
2781
  });
2528
2782
  isOrBecomesClosed(source, reader._closedPromise, () => {
2529
2783
  if (!preventClose) {
@@ -2531,6 +2785,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
2531
2785
  } else {
2532
2786
  shutdown();
2533
2787
  }
2788
+ return null;
2534
2789
  });
2535
2790
  if (WritableStreamCloseQueuedOrInFlight(dest) || dest._state === "closed") {
2536
2791
  const destClosed = new TypeError("the destination writable stream closed before all data could be piped to it");
@@ -2571,6 +2826,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
2571
2826
  }
2572
2827
  function doTheRest() {
2573
2828
  uponPromise(action(), () => finalize(originalIsError, originalError), (newError) => finalize(true, newError));
2829
+ return null;
2574
2830
  }
2575
2831
  }
2576
2832
  function shutdown(isError, error) {
@@ -2595,6 +2851,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
2595
2851
  } else {
2596
2852
  resolve(void 0);
2597
2853
  }
2854
+ return null;
2598
2855
  }
2599
2856
  });
2600
2857
  }
@@ -2667,6 +2924,9 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
2667
2924
  ReadableStreamDefaultControllerCallPullIfNeeded(this);
2668
2925
  }
2669
2926
  }
2927
+ /** @internal */
2928
+ [ReleaseSteps]() {
2929
+ }
2670
2930
  }
2671
2931
  Object.defineProperties(ReadableStreamDefaultController.prototype, {
2672
2932
  close: { enumerable: true },
@@ -2674,8 +2934,11 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
2674
2934
  error: { enumerable: true },
2675
2935
  desiredSize: { enumerable: true }
2676
2936
  });
2677
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
2678
- Object.defineProperty(ReadableStreamDefaultController.prototype, SymbolPolyfill.toStringTag, {
2937
+ setFunctionName(ReadableStreamDefaultController.prototype.close, "close");
2938
+ setFunctionName(ReadableStreamDefaultController.prototype.enqueue, "enqueue");
2939
+ setFunctionName(ReadableStreamDefaultController.prototype.error, "error");
2940
+ if (typeof Symbol.toStringTag === "symbol") {
2941
+ Object.defineProperty(ReadableStreamDefaultController.prototype, Symbol.toStringTag, {
2679
2942
  value: "ReadableStreamDefaultController",
2680
2943
  configurable: true
2681
2944
  });
@@ -2706,8 +2969,10 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
2706
2969
  controller._pullAgain = false;
2707
2970
  ReadableStreamDefaultControllerCallPullIfNeeded(controller);
2708
2971
  }
2972
+ return null;
2709
2973
  }, (e2) => {
2710
2974
  ReadableStreamDefaultControllerError(controller, e2);
2975
+ return null;
2711
2976
  });
2712
2977
  }
2713
2978
  function ReadableStreamDefaultControllerShouldCallPull(controller) {
@@ -2817,23 +3082,31 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
2817
3082
  uponPromise(promiseResolvedWith(startResult), () => {
2818
3083
  controller._started = true;
2819
3084
  ReadableStreamDefaultControllerCallPullIfNeeded(controller);
3085
+ return null;
2820
3086
  }, (r2) => {
2821
3087
  ReadableStreamDefaultControllerError(controller, r2);
3088
+ return null;
2822
3089
  });
2823
3090
  }
2824
3091
  function SetUpReadableStreamDefaultControllerFromUnderlyingSource(stream, underlyingSource, highWaterMark, sizeAlgorithm) {
2825
3092
  const controller = Object.create(ReadableStreamDefaultController.prototype);
2826
- let startAlgorithm = () => void 0;
2827
- let pullAlgorithm = () => promiseResolvedWith(void 0);
2828
- let cancelAlgorithm = () => promiseResolvedWith(void 0);
3093
+ let startAlgorithm;
3094
+ let pullAlgorithm;
3095
+ let cancelAlgorithm;
2829
3096
  if (underlyingSource.start !== void 0) {
2830
3097
  startAlgorithm = () => underlyingSource.start(controller);
3098
+ } else {
3099
+ startAlgorithm = () => void 0;
2831
3100
  }
2832
3101
  if (underlyingSource.pull !== void 0) {
2833
3102
  pullAlgorithm = () => underlyingSource.pull(controller);
3103
+ } else {
3104
+ pullAlgorithm = () => promiseResolvedWith(void 0);
2834
3105
  }
2835
3106
  if (underlyingSource.cancel !== void 0) {
2836
3107
  cancelAlgorithm = (reason) => underlyingSource.cancel(reason);
3108
+ } else {
3109
+ cancelAlgorithm = () => promiseResolvedWith(void 0);
2837
3110
  }
2838
3111
  SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm);
2839
3112
  }
@@ -2868,7 +3141,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
2868
3141
  reading = true;
2869
3142
  const readRequest = {
2870
3143
  _chunkSteps: (chunk) => {
2871
- queueMicrotask(() => {
3144
+ _queueMicrotask(() => {
2872
3145
  readAgain = false;
2873
3146
  const chunk1 = chunk;
2874
3147
  const chunk2 = chunk;
@@ -2933,6 +3206,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
2933
3206
  if (!canceled1 || !canceled2) {
2934
3207
  resolveCancelPromise(void 0);
2935
3208
  }
3209
+ return null;
2936
3210
  });
2937
3211
  return [branch1, branch2];
2938
3212
  }
@@ -2954,13 +3228,14 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
2954
3228
  function forwardReaderError(thisReader) {
2955
3229
  uponRejection(thisReader._closedPromise, (r2) => {
2956
3230
  if (thisReader !== reader) {
2957
- return;
3231
+ return null;
2958
3232
  }
2959
3233
  ReadableByteStreamControllerError(branch1._readableStreamController, r2);
2960
3234
  ReadableByteStreamControllerError(branch2._readableStreamController, r2);
2961
3235
  if (!canceled1 || !canceled2) {
2962
3236
  resolveCancelPromise(void 0);
2963
3237
  }
3238
+ return null;
2964
3239
  });
2965
3240
  }
2966
3241
  function pullWithDefaultReader() {
@@ -2971,7 +3246,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
2971
3246
  }
2972
3247
  const readRequest = {
2973
3248
  _chunkSteps: (chunk) => {
2974
- queueMicrotask(() => {
3249
+ _queueMicrotask(() => {
2975
3250
  readAgainForBranch1 = false;
2976
3251
  readAgainForBranch2 = false;
2977
3252
  const chunk1 = chunk;
@@ -3034,7 +3309,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
3034
3309
  const otherBranch = forBranch2 ? branch1 : branch2;
3035
3310
  const readIntoRequest = {
3036
3311
  _chunkSteps: (chunk) => {
3037
- queueMicrotask(() => {
3312
+ _queueMicrotask(() => {
3038
3313
  readAgainForBranch1 = false;
3039
3314
  readAgainForBranch2 = false;
3040
3315
  const byobCanceled = forBranch2 ? canceled2 : canceled1;
@@ -3090,7 +3365,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
3090
3365
  reading = false;
3091
3366
  }
3092
3367
  };
3093
- ReadableStreamBYOBReaderRead(reader, view, readIntoRequest);
3368
+ ReadableStreamBYOBReaderRead(reader, view, 1, readIntoRequest);
3094
3369
  }
3095
3370
  function pull1Algorithm() {
3096
3371
  if (reading) {
@@ -3148,6 +3423,100 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
3148
3423
  forwardReaderError(reader);
3149
3424
  return [branch1, branch2];
3150
3425
  }
3426
+ function isReadableStreamLike(stream) {
3427
+ return typeIsObject(stream) && typeof stream.getReader !== "undefined";
3428
+ }
3429
+ function ReadableStreamFrom(source) {
3430
+ if (isReadableStreamLike(source)) {
3431
+ return ReadableStreamFromDefaultReader(source.getReader());
3432
+ }
3433
+ return ReadableStreamFromIterable(source);
3434
+ }
3435
+ function ReadableStreamFromIterable(asyncIterable) {
3436
+ let stream;
3437
+ const iteratorRecord = GetIterator(asyncIterable, "async");
3438
+ const startAlgorithm = noop;
3439
+ function pullAlgorithm() {
3440
+ let nextResult;
3441
+ try {
3442
+ nextResult = IteratorNext(iteratorRecord);
3443
+ } catch (e2) {
3444
+ return promiseRejectedWith(e2);
3445
+ }
3446
+ const nextPromise = promiseResolvedWith(nextResult);
3447
+ return transformPromiseWith(nextPromise, (iterResult) => {
3448
+ if (!typeIsObject(iterResult)) {
3449
+ throw new TypeError("The promise returned by the iterator.next() method must fulfill with an object");
3450
+ }
3451
+ const done = IteratorComplete(iterResult);
3452
+ if (done) {
3453
+ ReadableStreamDefaultControllerClose(stream._readableStreamController);
3454
+ } else {
3455
+ const value = IteratorValue(iterResult);
3456
+ ReadableStreamDefaultControllerEnqueue(stream._readableStreamController, value);
3457
+ }
3458
+ });
3459
+ }
3460
+ function cancelAlgorithm(reason) {
3461
+ const iterator = iteratorRecord.iterator;
3462
+ let returnMethod;
3463
+ try {
3464
+ returnMethod = GetMethod(iterator, "return");
3465
+ } catch (e2) {
3466
+ return promiseRejectedWith(e2);
3467
+ }
3468
+ if (returnMethod === void 0) {
3469
+ return promiseResolvedWith(void 0);
3470
+ }
3471
+ let returnResult;
3472
+ try {
3473
+ returnResult = reflectCall(returnMethod, iterator, [reason]);
3474
+ } catch (e2) {
3475
+ return promiseRejectedWith(e2);
3476
+ }
3477
+ const returnPromise = promiseResolvedWith(returnResult);
3478
+ return transformPromiseWith(returnPromise, (iterResult) => {
3479
+ if (!typeIsObject(iterResult)) {
3480
+ throw new TypeError("The promise returned by the iterator.return() method must fulfill with an object");
3481
+ }
3482
+ return void 0;
3483
+ });
3484
+ }
3485
+ stream = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, 0);
3486
+ return stream;
3487
+ }
3488
+ function ReadableStreamFromDefaultReader(reader) {
3489
+ let stream;
3490
+ const startAlgorithm = noop;
3491
+ function pullAlgorithm() {
3492
+ let readPromise;
3493
+ try {
3494
+ readPromise = reader.read();
3495
+ } catch (e2) {
3496
+ return promiseRejectedWith(e2);
3497
+ }
3498
+ return transformPromiseWith(readPromise, (readResult) => {
3499
+ if (!typeIsObject(readResult)) {
3500
+ throw new TypeError("The promise returned by the reader.read() method must fulfill with an object");
3501
+ }
3502
+ if (readResult.done) {
3503
+ ReadableStreamDefaultControllerClose(stream._readableStreamController);
3504
+ } else {
3505
+ const value = readResult.value;
3506
+ ReadableStreamDefaultControllerEnqueue(stream._readableStreamController, value);
3507
+ }
3508
+ });
3509
+ }
3510
+ function cancelAlgorithm(reason) {
3511
+ try {
3512
+ return promiseResolvedWith(reader.cancel(reason));
3513
+ } catch (e2) {
3514
+ return promiseRejectedWith(e2);
3515
+ }
3516
+ }
3517
+ stream = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, 0);
3518
+ return stream;
3519
+ }
3151
3520
  function convertUnderlyingDefaultOrByteSource(source, context) {
3152
3521
  assertDictionary(source, context);
3153
3522
  const original = source;
@@ -3183,20 +3552,6 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
3183
3552
  }
3184
3553
  return type;
3185
3554
  }
3186
- function convertReaderOptions(options, context) {
3187
- assertDictionary(options, context);
3188
- const mode = options === null || options === void 0 ? void 0 : options.mode;
3189
- return {
3190
- mode: mode === void 0 ? void 0 : convertReadableStreamReaderMode(mode, `${context} has member 'mode' that`)
3191
- };
3192
- }
3193
- function convertReadableStreamReaderMode(mode, context) {
3194
- mode = `${mode}`;
3195
- if (mode !== "byob") {
3196
- throw new TypeError(`${context} '${mode}' is not a valid enumeration value for ReadableStreamReaderMode`);
3197
- }
3198
- return mode;
3199
- }
3200
3555
  function convertIteratorOptions(options, context) {
3201
3556
  assertDictionary(options, context);
3202
3557
  const preventCancel = options === null || options === void 0 ? void 0 : options.preventCancel;
@@ -3355,7 +3710,22 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
3355
3710
  const options = convertIteratorOptions(rawOptions, "First parameter");
3356
3711
  return AcquireReadableStreamAsyncIterator(this, options.preventCancel);
3357
3712
  }
3713
+ [SymbolAsyncIterator](options) {
3714
+ return this.values(options);
3715
+ }
3716
+ /**
3717
+ * Creates a new ReadableStream wrapping the provided iterable or async iterable.
3718
+ *
3719
+ * This can be used to adapt various kinds of objects into a readable stream,
3720
+ * such as an array, an async generator, or a Node.js readable stream.
3721
+ */
3722
+ static from(asyncIterable) {
3723
+ return ReadableStreamFrom(asyncIterable);
3724
+ }
3358
3725
  }
3726
+ Object.defineProperties(ReadableStream2, {
3727
+ from: { enumerable: true }
3728
+ });
3359
3729
  Object.defineProperties(ReadableStream2.prototype, {
3360
3730
  cancel: { enumerable: true },
3361
3731
  getReader: { enumerable: true },
@@ -3365,19 +3735,24 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
3365
3735
  values: { enumerable: true },
3366
3736
  locked: { enumerable: true }
3367
3737
  });
3368
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
3369
- Object.defineProperty(ReadableStream2.prototype, SymbolPolyfill.toStringTag, {
3738
+ setFunctionName(ReadableStream2.from, "from");
3739
+ setFunctionName(ReadableStream2.prototype.cancel, "cancel");
3740
+ setFunctionName(ReadableStream2.prototype.getReader, "getReader");
3741
+ setFunctionName(ReadableStream2.prototype.pipeThrough, "pipeThrough");
3742
+ setFunctionName(ReadableStream2.prototype.pipeTo, "pipeTo");
3743
+ setFunctionName(ReadableStream2.prototype.tee, "tee");
3744
+ setFunctionName(ReadableStream2.prototype.values, "values");
3745
+ if (typeof Symbol.toStringTag === "symbol") {
3746
+ Object.defineProperty(ReadableStream2.prototype, Symbol.toStringTag, {
3370
3747
  value: "ReadableStream",
3371
3748
  configurable: true
3372
3749
  });
3373
3750
  }
3374
- if (typeof SymbolPolyfill.asyncIterator === "symbol") {
3375
- Object.defineProperty(ReadableStream2.prototype, SymbolPolyfill.asyncIterator, {
3376
- value: ReadableStream2.prototype.values,
3377
- writable: true,
3378
- configurable: true
3379
- });
3380
- }
3751
+ Object.defineProperty(ReadableStream2.prototype, SymbolAsyncIterator, {
3752
+ value: ReadableStream2.prototype.values,
3753
+ writable: true,
3754
+ configurable: true
3755
+ });
3381
3756
  function CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark = 1, sizeAlgorithm = () => 1) {
3382
3757
  const stream = Object.create(ReadableStream2.prototype);
3383
3758
  InitializeReadableStream(stream);
@@ -3424,10 +3799,11 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
3424
3799
  ReadableStreamClose(stream);
3425
3800
  const reader = stream._reader;
3426
3801
  if (reader !== void 0 && IsReadableStreamBYOBReader(reader)) {
3427
- reader._readIntoRequests.forEach((readIntoRequest) => {
3802
+ const readIntoRequests = reader._readIntoRequests;
3803
+ reader._readIntoRequests = new SimpleQueue();
3804
+ readIntoRequests.forEach((readIntoRequest) => {
3428
3805
  readIntoRequest._closeSteps(void 0);
3429
3806
  });
3430
- reader._readIntoRequests = new SimpleQueue();
3431
3807
  }
3432
3808
  const sourceCancelPromise = stream._readableStreamController[CancelSteps](reason);
3433
3809
  return transformPromiseWith(sourceCancelPromise, noop);
@@ -3440,10 +3816,11 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
3440
3816
  }
3441
3817
  defaultReaderClosedPromiseResolve(reader);
3442
3818
  if (IsReadableStreamDefaultReader(reader)) {
3443
- reader._readRequests.forEach((readRequest) => {
3819
+ const readRequests = reader._readRequests;
3820
+ reader._readRequests = new SimpleQueue();
3821
+ readRequests.forEach((readRequest) => {
3444
3822
  readRequest._closeSteps();
3445
3823
  });
3446
- reader._readRequests = new SimpleQueue();
3447
3824
  }
3448
3825
  }
3449
3826
  function ReadableStreamError(stream, e2) {
@@ -3455,15 +3832,9 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
3455
3832
  }
3456
3833
  defaultReaderClosedPromiseReject(reader, e2);
3457
3834
  if (IsReadableStreamDefaultReader(reader)) {
3458
- reader._readRequests.forEach((readRequest) => {
3459
- readRequest._errorSteps(e2);
3460
- });
3461
- reader._readRequests = new SimpleQueue();
3835
+ ReadableStreamDefaultReaderErrorReadRequests(reader, e2);
3462
3836
  } else {
3463
- reader._readIntoRequests.forEach((readIntoRequest) => {
3464
- readIntoRequest._errorSteps(e2);
3465
- });
3466
- reader._readIntoRequests = new SimpleQueue();
3837
+ ReadableStreamBYOBReaderErrorReadIntoRequests(reader, e2);
3467
3838
  }
3468
3839
  }
3469
3840
  function streamBrandCheckException$1(name) {
@@ -3480,13 +3851,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
3480
3851
  const byteLengthSizeFunction = (chunk) => {
3481
3852
  return chunk.byteLength;
3482
3853
  };
3483
- try {
3484
- Object.defineProperty(byteLengthSizeFunction, "name", {
3485
- value: "size",
3486
- configurable: true
3487
- });
3488
- } catch (_a) {
3489
- }
3854
+ setFunctionName(byteLengthSizeFunction, "size");
3490
3855
  class ByteLengthQueuingStrategy {
3491
3856
  constructor(options) {
3492
3857
  assertRequiredArgument(options, 1, "ByteLengthQueuingStrategy");
@@ -3516,8 +3881,8 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
3516
3881
  highWaterMark: { enumerable: true },
3517
3882
  size: { enumerable: true }
3518
3883
  });
3519
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
3520
- Object.defineProperty(ByteLengthQueuingStrategy.prototype, SymbolPolyfill.toStringTag, {
3884
+ if (typeof Symbol.toStringTag === "symbol") {
3885
+ Object.defineProperty(ByteLengthQueuingStrategy.prototype, Symbol.toStringTag, {
3521
3886
  value: "ByteLengthQueuingStrategy",
3522
3887
  configurable: true
3523
3888
  });
@@ -3537,13 +3902,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
3537
3902
  const countSizeFunction = () => {
3538
3903
  return 1;
3539
3904
  };
3540
- try {
3541
- Object.defineProperty(countSizeFunction, "name", {
3542
- value: "size",
3543
- configurable: true
3544
- });
3545
- } catch (_a) {
3546
- }
3905
+ setFunctionName(countSizeFunction, "size");
3547
3906
  class CountQueuingStrategy {
3548
3907
  constructor(options) {
3549
3908
  assertRequiredArgument(options, 1, "CountQueuingStrategy");
@@ -3574,8 +3933,8 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
3574
3933
  highWaterMark: { enumerable: true },
3575
3934
  size: { enumerable: true }
3576
3935
  });
3577
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
3578
- Object.defineProperty(CountQueuingStrategy.prototype, SymbolPolyfill.toStringTag, {
3936
+ if (typeof Symbol.toStringTag === "symbol") {
3937
+ Object.defineProperty(CountQueuingStrategy.prototype, Symbol.toStringTag, {
3579
3938
  value: "CountQueuingStrategy",
3580
3939
  configurable: true
3581
3940
  });
@@ -3594,12 +3953,14 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
3594
3953
  }
3595
3954
  function convertTransformer(original, context) {
3596
3955
  assertDictionary(original, context);
3956
+ const cancel = original === null || original === void 0 ? void 0 : original.cancel;
3597
3957
  const flush = original === null || original === void 0 ? void 0 : original.flush;
3598
3958
  const readableType = original === null || original === void 0 ? void 0 : original.readableType;
3599
3959
  const start = original === null || original === void 0 ? void 0 : original.start;
3600
3960
  const transform = original === null || original === void 0 ? void 0 : original.transform;
3601
3961
  const writableType = original === null || original === void 0 ? void 0 : original.writableType;
3602
3962
  return {
3963
+ cancel: cancel === void 0 ? void 0 : convertTransformerCancelCallback(cancel, original, `${context} has member 'cancel' that`),
3603
3964
  flush: flush === void 0 ? void 0 : convertTransformerFlushCallback(flush, original, `${context} has member 'flush' that`),
3604
3965
  readableType,
3605
3966
  start: start === void 0 ? void 0 : convertTransformerStartCallback(start, original, `${context} has member 'start' that`),
@@ -3619,6 +3980,10 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
3619
3980
  assertFunction(fn, context);
3620
3981
  return (chunk, controller) => promiseCall(fn, original, [chunk, controller]);
3621
3982
  }
3983
+ function convertTransformerCancelCallback(fn, original, context) {
3984
+ assertFunction(fn, context);
3985
+ return (reason) => promiseCall(fn, original, [reason]);
3986
+ }
3622
3987
  class TransformStream {
3623
3988
  constructor(rawTransformer = {}, rawWritableStrategy = {}, rawReadableStrategy = {}) {
3624
3989
  if (rawTransformer === void 0) {
@@ -3672,8 +4037,8 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
3672
4037
  readable: { enumerable: true },
3673
4038
  writable: { enumerable: true }
3674
4039
  });
3675
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
3676
- Object.defineProperty(TransformStream.prototype, SymbolPolyfill.toStringTag, {
4040
+ if (typeof Symbol.toStringTag === "symbol") {
4041
+ Object.defineProperty(TransformStream.prototype, Symbol.toStringTag, {
3677
4042
  value: "TransformStream",
3678
4043
  configurable: true
3679
4044
  });
@@ -3696,8 +4061,7 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
3696
4061
  return TransformStreamDefaultSourcePullAlgorithm(stream);
3697
4062
  }
3698
4063
  function cancelAlgorithm(reason) {
3699
- TransformStreamErrorWritableAndUnblockWrite(stream, reason);
3700
- return promiseResolvedWith(void 0);
4064
+ return TransformStreamDefaultSourceCancelAlgorithm(stream, reason);
3701
4065
  }
3702
4066
  stream._readable = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
3703
4067
  stream._backpressure = void 0;
@@ -3722,6 +4086,9 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
3722
4086
  function TransformStreamErrorWritableAndUnblockWrite(stream, e2) {
3723
4087
  TransformStreamDefaultControllerClearAlgorithms(stream._transformStreamController);
3724
4088
  WritableStreamDefaultControllerErrorIfNeeded(stream._writable._writableStreamController, e2);
4089
+ TransformStreamUnblockWrite(stream);
4090
+ }
4091
+ function TransformStreamUnblockWrite(stream) {
3725
4092
  if (stream._backpressure) {
3726
4093
  TransformStreamSetBackpressure(stream, false);
3727
4094
  }
@@ -3782,8 +4149,11 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
3782
4149
  terminate: { enumerable: true },
3783
4150
  desiredSize: { enumerable: true }
3784
4151
  });
3785
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
3786
- Object.defineProperty(TransformStreamDefaultController.prototype, SymbolPolyfill.toStringTag, {
4152
+ setFunctionName(TransformStreamDefaultController.prototype.enqueue, "enqueue");
4153
+ setFunctionName(TransformStreamDefaultController.prototype.error, "error");
4154
+ setFunctionName(TransformStreamDefaultController.prototype.terminate, "terminate");
4155
+ if (typeof Symbol.toStringTag === "symbol") {
4156
+ Object.defineProperty(TransformStreamDefaultController.prototype, Symbol.toStringTag, {
3787
4157
  value: "TransformStreamDefaultController",
3788
4158
  configurable: true
3789
4159
  });
@@ -3797,34 +4167,49 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
3797
4167
  }
3798
4168
  return x2 instanceof TransformStreamDefaultController;
3799
4169
  }
3800
- function SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm) {
4170
+ function SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm, cancelAlgorithm) {
3801
4171
  controller._controlledTransformStream = stream;
3802
4172
  stream._transformStreamController = controller;
3803
4173
  controller._transformAlgorithm = transformAlgorithm;
3804
4174
  controller._flushAlgorithm = flushAlgorithm;
4175
+ controller._cancelAlgorithm = cancelAlgorithm;
4176
+ controller._finishPromise = void 0;
4177
+ controller._finishPromise_resolve = void 0;
4178
+ controller._finishPromise_reject = void 0;
3805
4179
  }
3806
4180
  function SetUpTransformStreamDefaultControllerFromTransformer(stream, transformer) {
3807
4181
  const controller = Object.create(TransformStreamDefaultController.prototype);
3808
- let transformAlgorithm = (chunk) => {
3809
- try {
3810
- TransformStreamDefaultControllerEnqueue(controller, chunk);
3811
- return promiseResolvedWith(void 0);
3812
- } catch (transformResultE) {
3813
- return promiseRejectedWith(transformResultE);
3814
- }
3815
- };
3816
- let flushAlgorithm = () => promiseResolvedWith(void 0);
4182
+ let transformAlgorithm;
4183
+ let flushAlgorithm;
4184
+ let cancelAlgorithm;
3817
4185
  if (transformer.transform !== void 0) {
3818
4186
  transformAlgorithm = (chunk) => transformer.transform(chunk, controller);
4187
+ } else {
4188
+ transformAlgorithm = (chunk) => {
4189
+ try {
4190
+ TransformStreamDefaultControllerEnqueue(controller, chunk);
4191
+ return promiseResolvedWith(void 0);
4192
+ } catch (transformResultE) {
4193
+ return promiseRejectedWith(transformResultE);
4194
+ }
4195
+ };
3819
4196
  }
3820
4197
  if (transformer.flush !== void 0) {
3821
4198
  flushAlgorithm = () => transformer.flush(controller);
4199
+ } else {
4200
+ flushAlgorithm = () => promiseResolvedWith(void 0);
4201
+ }
4202
+ if (transformer.cancel !== void 0) {
4203
+ cancelAlgorithm = (reason) => transformer.cancel(reason);
4204
+ } else {
4205
+ cancelAlgorithm = () => promiseResolvedWith(void 0);
3822
4206
  }
3823
- SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm);
4207
+ SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm, cancelAlgorithm);
3824
4208
  }
3825
4209
  function TransformStreamDefaultControllerClearAlgorithms(controller) {
3826
4210
  controller._transformAlgorithm = void 0;
3827
4211
  controller._flushAlgorithm = void 0;
4212
+ controller._cancelAlgorithm = void 0;
3828
4213
  }
3829
4214
  function TransformStreamDefaultControllerEnqueue(controller, chunk) {
3830
4215
  const stream = controller._controlledTransformStream;
@@ -3876,31 +4261,112 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
3876
4261
  return TransformStreamDefaultControllerPerformTransform(controller, chunk);
3877
4262
  }
3878
4263
  function TransformStreamDefaultSinkAbortAlgorithm(stream, reason) {
3879
- TransformStreamError(stream, reason);
3880
- return promiseResolvedWith(void 0);
4264
+ const controller = stream._transformStreamController;
4265
+ if (controller._finishPromise !== void 0) {
4266
+ return controller._finishPromise;
4267
+ }
4268
+ const readable = stream._readable;
4269
+ controller._finishPromise = newPromise((resolve, reject) => {
4270
+ controller._finishPromise_resolve = resolve;
4271
+ controller._finishPromise_reject = reject;
4272
+ });
4273
+ const cancelPromise = controller._cancelAlgorithm(reason);
4274
+ TransformStreamDefaultControllerClearAlgorithms(controller);
4275
+ uponPromise(cancelPromise, () => {
4276
+ if (readable._state === "errored") {
4277
+ defaultControllerFinishPromiseReject(controller, readable._storedError);
4278
+ } else {
4279
+ ReadableStreamDefaultControllerError(readable._readableStreamController, reason);
4280
+ defaultControllerFinishPromiseResolve(controller);
4281
+ }
4282
+ return null;
4283
+ }, (r2) => {
4284
+ ReadableStreamDefaultControllerError(readable._readableStreamController, r2);
4285
+ defaultControllerFinishPromiseReject(controller, r2);
4286
+ return null;
4287
+ });
4288
+ return controller._finishPromise;
3881
4289
  }
3882
4290
  function TransformStreamDefaultSinkCloseAlgorithm(stream) {
3883
- const readable = stream._readable;
3884
4291
  const controller = stream._transformStreamController;
4292
+ if (controller._finishPromise !== void 0) {
4293
+ return controller._finishPromise;
4294
+ }
4295
+ const readable = stream._readable;
4296
+ controller._finishPromise = newPromise((resolve, reject) => {
4297
+ controller._finishPromise_resolve = resolve;
4298
+ controller._finishPromise_reject = reject;
4299
+ });
3885
4300
  const flushPromise = controller._flushAlgorithm();
3886
4301
  TransformStreamDefaultControllerClearAlgorithms(controller);
3887
- return transformPromiseWith(flushPromise, () => {
4302
+ uponPromise(flushPromise, () => {
3888
4303
  if (readable._state === "errored") {
3889
- throw readable._storedError;
4304
+ defaultControllerFinishPromiseReject(controller, readable._storedError);
4305
+ } else {
4306
+ ReadableStreamDefaultControllerClose(readable._readableStreamController);
4307
+ defaultControllerFinishPromiseResolve(controller);
3890
4308
  }
3891
- ReadableStreamDefaultControllerClose(readable._readableStreamController);
4309
+ return null;
3892
4310
  }, (r2) => {
3893
- TransformStreamError(stream, r2);
3894
- throw readable._storedError;
4311
+ ReadableStreamDefaultControllerError(readable._readableStreamController, r2);
4312
+ defaultControllerFinishPromiseReject(controller, r2);
4313
+ return null;
3895
4314
  });
4315
+ return controller._finishPromise;
3896
4316
  }
3897
4317
  function TransformStreamDefaultSourcePullAlgorithm(stream) {
3898
4318
  TransformStreamSetBackpressure(stream, false);
3899
4319
  return stream._backpressureChangePromise;
3900
4320
  }
4321
+ function TransformStreamDefaultSourceCancelAlgorithm(stream, reason) {
4322
+ const controller = stream._transformStreamController;
4323
+ if (controller._finishPromise !== void 0) {
4324
+ return controller._finishPromise;
4325
+ }
4326
+ const writable = stream._writable;
4327
+ controller._finishPromise = newPromise((resolve, reject) => {
4328
+ controller._finishPromise_resolve = resolve;
4329
+ controller._finishPromise_reject = reject;
4330
+ });
4331
+ const cancelPromise = controller._cancelAlgorithm(reason);
4332
+ TransformStreamDefaultControllerClearAlgorithms(controller);
4333
+ uponPromise(cancelPromise, () => {
4334
+ if (writable._state === "errored") {
4335
+ defaultControllerFinishPromiseReject(controller, writable._storedError);
4336
+ } else {
4337
+ WritableStreamDefaultControllerErrorIfNeeded(writable._writableStreamController, reason);
4338
+ TransformStreamUnblockWrite(stream);
4339
+ defaultControllerFinishPromiseResolve(controller);
4340
+ }
4341
+ return null;
4342
+ }, (r2) => {
4343
+ WritableStreamDefaultControllerErrorIfNeeded(writable._writableStreamController, r2);
4344
+ TransformStreamUnblockWrite(stream);
4345
+ defaultControllerFinishPromiseReject(controller, r2);
4346
+ return null;
4347
+ });
4348
+ return controller._finishPromise;
4349
+ }
3901
4350
  function defaultControllerBrandCheckException(name) {
3902
4351
  return new TypeError(`TransformStreamDefaultController.prototype.${name} can only be used on a TransformStreamDefaultController`);
3903
4352
  }
4353
+ function defaultControllerFinishPromiseResolve(controller) {
4354
+ if (controller._finishPromise_resolve === void 0) {
4355
+ return;
4356
+ }
4357
+ controller._finishPromise_resolve();
4358
+ controller._finishPromise_resolve = void 0;
4359
+ controller._finishPromise_reject = void 0;
4360
+ }
4361
+ function defaultControllerFinishPromiseReject(controller, reason) {
4362
+ if (controller._finishPromise_reject === void 0) {
4363
+ return;
4364
+ }
4365
+ setPromiseIsHandledToTrue(controller._finishPromise);
4366
+ controller._finishPromise_reject(reason);
4367
+ controller._finishPromise_resolve = void 0;
4368
+ controller._finishPromise_reject = void 0;
4369
+ }
3904
4370
  function streamBrandCheckException(name) {
3905
4371
  return new TypeError(`TransformStream.prototype.${name} can only be used on a TransformStream`);
3906
4372
  }
@@ -3917,7 +4383,6 @@ var require_chunk_RXM4EBGR = (0, import_chunk_2ESYSVXG.__commonJS)({
3917
4383
  exports22.WritableStream = WritableStream;
3918
4384
  exports22.WritableStreamDefaultController = WritableStreamDefaultController;
3919
4385
  exports22.WritableStreamDefaultWriter = WritableStreamDefaultWriter;
3920
- Object.defineProperty(exports22, "__esModule", { value: true });
3921
4386
  });
3922
4387
  }
3923
4388
  });
@@ -4305,8 +4770,8 @@ Content-Type: ${v.type || "application/octet-stream"}\r
4305
4770
  var { stat } = import_node_fs.promises;
4306
4771
  }
4307
4772
  });
4308
- var require_multipart_parser_ASKQAOL4 = (0, import_chunk_2ESYSVXG.__commonJS)({
4309
- "../fetch-engine/dist/multipart-parser-ASKQAOL4.js"(exports, module2) {
4773
+ var require_multipart_parser_AOASR4DL = (0, import_chunk_2ESYSVXG.__commonJS)({
4774
+ "../fetch-engine/dist/multipart-parser-AOASR4DL.js"(exports, module2) {
4310
4775
  var __defProp2 = Object.defineProperty;
4311
4776
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
4312
4777
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
@@ -4324,12 +4789,12 @@ var require_multipart_parser_ASKQAOL4 = (0, import_chunk_2ESYSVXG.__commonJS)({
4324
4789
  return to;
4325
4790
  };
4326
4791
  var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
4327
- var multipart_parser_ASKQAOL4_exports = {};
4328
- __export2(multipart_parser_ASKQAOL4_exports, {
4792
+ var multipart_parser_AOASR4DL_exports = {};
4793
+ __export2(multipart_parser_AOASR4DL_exports, {
4329
4794
  toFormData: () => toFormData
4330
4795
  });
4331
- module2.exports = __toCommonJS2(multipart_parser_ASKQAOL4_exports);
4332
- var import_chunk_RXM4EBGR = require_chunk_RXM4EBGR();
4796
+ module2.exports = __toCommonJS2(multipart_parser_AOASR4DL_exports);
4797
+ var import_chunk_BYDIRBHB = require_chunk_BYDIRBHB();
4333
4798
  var import_chunk_QGM4M3NI = require_chunk_QGM4M3NI();
4334
4799
  var s = 0;
4335
4800
  var S = {
@@ -4622,7 +5087,7 @@ var require_multipart_parser_ASKQAOL4 = (0, import_chunk_2ESYSVXG.__commonJS)({
4622
5087
  let contentType;
4623
5088
  let filename;
4624
5089
  const entryChunks = [];
4625
- const formData = new import_chunk_RXM4EBGR.FormData();
5090
+ const formData = new import_chunk_BYDIRBHB.FormData();
4626
5091
  const onPartData = (ui8a) => {
4627
5092
  entryValue += decoder.decode(ui8a, { stream: true });
4628
5093
  };
@@ -4630,7 +5095,7 @@ var require_multipart_parser_ASKQAOL4 = (0, import_chunk_2ESYSVXG.__commonJS)({
4630
5095
  entryChunks.push(ui8a);
4631
5096
  };
4632
5097
  const appendFileToFormData = () => {
4633
- const file = new import_chunk_RXM4EBGR.file_default(entryChunks, filename, { type: contentType });
5098
+ const file = new import_chunk_BYDIRBHB.file_default(entryChunks, filename, { type: contentType });
4634
5099
  formData.append(entryName, file);
4635
5100
  };
4636
5101
  const appendEntryToFormData = () => {
@@ -4682,9 +5147,18 @@ var require_multipart_parser_ASKQAOL4 = (0, import_chunk_2ESYSVXG.__commonJS)({
4682
5147
  }
4683
5148
  }
4684
5149
  });
4685
- var multipart_parser_ASKQAOL4_WZ47HU6G_default = require_multipart_parser_ASKQAOL4();
5150
+ var multipart_parser_AOASR4DL_AXIJXW2B_default = require_multipart_parser_AOASR4DL();
4686
5151
  /*! Bundled license information:
4687
5152
 
5153
+ web-streams-polyfill/dist/ponyfill.es2018.js:
5154
+ (**
5155
+ * @license
5156
+ * web-streams-polyfill v3.3.3
5157
+ * Copyright 2024 Mattias Buelens, Diwank Singh Tomer and other contributors.
5158
+ * This code is released under the MIT license.
5159
+ * SPDX-License-Identifier: MIT
5160
+ *)
5161
+
4688
5162
  node-domexception/index.js:
4689
5163
  (*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> *)
4690
5164