@prisma/internals 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 (85) hide show
  1. package/dist/{chunk-GIOVJ5SL.js → chunk-226NCPFJ.js} +8 -8
  2. package/dist/{chunk-TV34NMBZ.js → chunk-2H6XXXKO.js} +15 -12
  3. package/dist/{chunk-EPXBOIA5.js → chunk-2I3VYCA7.js} +5 -5
  4. package/dist/{chunk-2QTAK7KO.js → chunk-2LDG4PID.js} +5 -5
  5. package/dist/{chunk-JOIIWB3U.js → chunk-2LOGW45F.js} +68 -33
  6. package/dist/{chunk-KB5DKCI4.js → chunk-3GYXMWBM.js} +7 -7
  7. package/dist/{chunk-75AJJ2SV.js → chunk-5UX7SDF4.js} +5 -5
  8. package/dist/{chunk-FQ7QE2EZ.js → chunk-6NIWKOQM.js} +5 -5
  9. package/dist/{chunk-GHQCAB3L.js → chunk-6TAXYMS3.js} +8 -8
  10. package/dist/{chunk-DG3K2SNH.js → chunk-A4UZ4UKB.js} +66 -127
  11. package/dist/{chunk-PQE76XRR.js → chunk-AP52B62F.js} +5 -5
  12. package/dist/{chunk-HG3YOAAE.js → chunk-AXD7KB4D.js} +5 -5
  13. package/dist/chunk-DYV47NUW.js +796 -0
  14. package/dist/{chunk-DKSUHQGA.js → chunk-EKESIUIK.js} +7 -7
  15. package/dist/{chunk-VVXXJDPA.js → chunk-FAPPXX7W.js} +8 -8
  16. package/dist/{chunk-OB2FZR3M.js → chunk-FAQHAUBK.js} +7 -7
  17. package/dist/{chunk-BTWAF3S4.js → chunk-GV244NDE.js} +7 -7
  18. package/dist/{chunk-D4VDA2TZ.js → chunk-IRWX4FCC.js} +6 -6
  19. package/dist/{chunk-IDINCQMN.js → chunk-IWTEX7EE.js} +9 -780
  20. package/dist/{chunk-XKIMYV5V.js → chunk-J27QTOYA.js} +5 -5
  21. package/dist/{chunk-NVNI2SRU.js → chunk-KNNTV7IN.js} +687 -213
  22. package/dist/{chunk-AZI6RPIA.js → chunk-L2SLJQ2Z.js} +5 -5
  23. package/dist/{chunk-55SEKKR3.js → chunk-LWBLVV7Y.js} +8 -8
  24. package/dist/{chunk-5AI4FIZ3.js → chunk-MEOOYUIZ.js} +10 -10
  25. package/dist/{chunk-TQFONRJP.js → chunk-MXAUURHG.js} +5 -5
  26. package/dist/{chunk-QGJH4P4N.js → chunk-OQ2NRV2Y.js} +5 -5
  27. package/dist/{chunk-U4BGZ3NX.js → chunk-OUQPIJFQ.js} +5 -5
  28. package/dist/{chunk-MSQTODVE.js → chunk-OYKZ24UT.js} +8 -8
  29. package/dist/{chunk-EWWOTVR3.js → chunk-PE6DXWOX.js} +6 -6
  30. package/dist/{chunk-XQSHUIJ5.js → chunk-PING5S2U.js} +8 -8
  31. package/dist/{chunk-HX2VLZFY.js → chunk-PWGQKUJW.js} +66 -127
  32. package/dist/{chunk-K5W6WZ6E.js → chunk-R4ZFFYJA.js} +238 -2734
  33. package/dist/{chunk-3DQANJMY.js → chunk-SAAMENIS.js} +7 -7
  34. package/dist/{chunk-LHESHKC2.js → chunk-SNSJWJTA.js} +5 -5
  35. package/dist/{chunk-YR5KNFKN.js → chunk-SUOMIRLO.js} +6 -6
  36. package/dist/{chunk-75BIJ5PX.js → chunk-UB2X7DGZ.js} +9 -9
  37. package/dist/{chunk-VVPSLVOR.js → chunk-URRVX2VQ.js} +3 -4
  38. package/dist/{chunk-EZI6235B.js → chunk-VTJOX6HO.js} +5 -5
  39. package/dist/{chunk-ABTIXQDX.js → chunk-VYJSNZF3.js} +4 -4
  40. package/dist/{chunk-POCSNJFA.js → chunk-W2PA2Y65.js} +5 -5
  41. package/dist/{chunk-ETYWYJBX.js → chunk-WF5LZFJS.js} +12 -12
  42. package/dist/cli/checkUnsupportedDataProxy.js +33 -32
  43. package/dist/cli/directoryConfig.d.ts +1 -1
  44. package/dist/cli/directoryConfig.js +2 -2
  45. package/dist/cli/getSchema.d.ts +3 -28
  46. package/dist/cli/getSchema.js +36 -36
  47. package/dist/cli/hashes.d.ts +1 -2
  48. package/dist/cli/hashes.js +33 -32
  49. package/dist/cli/schemaContext.d.ts +4 -3
  50. package/dist/cli/schemaContext.js +33 -32
  51. package/dist/engine-commands/errorHelpers.js +4 -4
  52. package/dist/engine-commands/formatSchema.js +32 -31
  53. package/dist/engine-commands/getConfig.js +10 -10
  54. package/dist/engine-commands/getDmmf.js +7 -7
  55. package/dist/engine-commands/getEngineVersion.js +7 -6
  56. package/dist/engine-commands/getEnginesMetaInfo.js +9 -8
  57. package/dist/engine-commands/index.js +43 -42
  58. package/dist/engine-commands/lintSchema.js +8 -8
  59. package/dist/engine-commands/mergeSchemas.js +7 -7
  60. package/dist/engine-commands/validate.js +7 -7
  61. package/dist/errorReporting.js +6 -6
  62. package/dist/get-generators/generatorResolvers/generatorResolvers.js +32 -31
  63. package/dist/get-generators/generatorResolvers/prisma-client-js/auto-installation/findPrismaClientDir.js +3 -3
  64. package/dist/get-generators/generatorResolvers/prisma-client-js/auto-installation/runPackageCmd.js +3 -3
  65. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/checkTypeScriptVersion.js +32 -31
  66. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/resolve.js +3 -3
  67. package/dist/get-generators/generatorResolvers/prisma-client-js/prismaClientResolver.js +33 -32
  68. package/dist/get-generators/getGenerators.js +35 -34
  69. package/dist/get-generators/utils/getBinaryPathsByVersion.js +4 -3
  70. package/dist/getPackedPackage.js +5 -4
  71. package/dist/index.d.ts +1 -1
  72. package/dist/index.js +75 -75
  73. package/dist/{multipart-parser-3AFJFP6K.js → multipart-parser-UV3WZSWW.js} +6 -6
  74. package/dist/resolveBinary.js +8 -7
  75. package/dist/schemaEngineCommands.js +10 -9
  76. package/dist/sendPanic.js +4 -4
  77. package/dist/utils/cloudflareD1.js +3 -3
  78. package/dist/utils/fs-functional.js +10 -10
  79. package/dist/utils/fs-utils.js +8 -8
  80. package/dist/utils/getEnvPaths.js +32 -31
  81. package/dist/utils/getVersionFromPackageJson.js +3 -3
  82. package/dist/utils/handlePanic.js +5 -5
  83. package/dist/utils/loadEnvFile.js +32 -31
  84. package/dist/wasm.js +4 -4
  85. package/package.json +11 -11
@@ -16,51 +16,47 @@ 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 chunk_NVNI2SRU_exports = {};
20
- __export(chunk_NVNI2SRU_exports, {
19
+ var chunk_KNNTV7IN_exports = {};
20
+ __export(chunk_KNNTV7IN_exports, {
21
21
  FormData: () => FormData,
22
22
  fetch_blob_default: () => fetch_blob_default,
23
23
  file_default: () => file_default,
24
24
  formDataToBlob: () => formDataToBlob
25
25
  });
26
- module.exports = __toCommonJS(chunk_NVNI2SRU_exports);
26
+ module.exports = __toCommonJS(chunk_KNNTV7IN_exports);
27
27
  var import_chunk_4VNS5WPM = require("./chunk-4VNS5WPM.js");
28
28
  var import_node_fs = require("node:fs");
29
29
  var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
30
- "../../node_modules/.pnpm/web-streams-polyfill@3.2.1/node_modules/web-streams-polyfill/dist/ponyfill.es2018.js"(exports, module2) {
30
+ "../../node_modules/.pnpm/web-streams-polyfill@3.3.3/node_modules/web-streams-polyfill/dist/ponyfill.es2018.js"(exports, module2) {
31
31
  "use strict";
32
32
  (function(global2, factory) {
33
33
  typeof exports === "object" && typeof module2 !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2.WebStreamsPolyfill = {}));
34
34
  })(exports, function(exports2) {
35
35
  "use strict";
36
- const SymbolPolyfill = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? Symbol : (description) => `Symbol(${description})`;
37
36
  function noop() {
38
37
  return void 0;
39
38
  }
40
- function getGlobals() {
41
- if (typeof self !== "undefined") {
42
- return self;
43
- } else if (typeof window !== "undefined") {
44
- return window;
45
- } else if (typeof global !== "undefined") {
46
- return global;
47
- }
48
- return void 0;
49
- }
50
- const globals = getGlobals();
51
39
  function typeIsObject(x2) {
52
40
  return typeof x2 === "object" && x2 !== null || typeof x2 === "function";
53
41
  }
54
42
  const rethrowAssertionErrorRejection = noop;
43
+ function setFunctionName(fn, name) {
44
+ try {
45
+ Object.defineProperty(fn, "name", {
46
+ value: name,
47
+ configurable: true
48
+ });
49
+ } catch (_a2) {
50
+ }
51
+ }
55
52
  const originalPromise = Promise;
56
53
  const originalPromiseThen = Promise.prototype.then;
57
- const originalPromiseResolve = Promise.resolve.bind(originalPromise);
58
54
  const originalPromiseReject = Promise.reject.bind(originalPromise);
59
55
  function newPromise(executor) {
60
56
  return new originalPromise(executor);
61
57
  }
62
58
  function promiseResolvedWith(value) {
63
- return originalPromiseResolve(value);
59
+ return newPromise((resolve) => resolve(value));
64
60
  }
65
61
  function promiseRejectedWith(reason) {
66
62
  return originalPromiseReject(reason);
@@ -83,14 +79,15 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
83
79
  function setPromiseIsHandledToTrue(promise) {
84
80
  PerformPromiseThen(promise, void 0, rethrowAssertionErrorRejection);
85
81
  }
86
- const queueMicrotask = (() => {
87
- const globalQueueMicrotask = globals && globals.queueMicrotask;
88
- if (typeof globalQueueMicrotask === "function") {
89
- return globalQueueMicrotask;
82
+ let _queueMicrotask = (callback) => {
83
+ if (typeof queueMicrotask === "function") {
84
+ _queueMicrotask = queueMicrotask;
85
+ } else {
86
+ const resolvedPromise = promiseResolvedWith(void 0);
87
+ _queueMicrotask = (cb) => PerformPromiseThen(resolvedPromise, cb);
90
88
  }
91
- const resolvedPromise = promiseResolvedWith(void 0);
92
- return (fn) => PerformPromiseThen(resolvedPromise, fn);
93
- })();
89
+ return _queueMicrotask(callback);
90
+ };
94
91
  function reflectCall(F, V, args) {
95
92
  if (typeof F !== "function") {
96
93
  throw new TypeError("Argument is not a function");
@@ -194,6 +191,11 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
194
191
  return front._elements[cursor];
195
192
  }
196
193
  }
194
+ const AbortSteps = Symbol("[[AbortSteps]]");
195
+ const ErrorSteps = Symbol("[[ErrorSteps]]");
196
+ const CancelSteps = Symbol("[[CancelSteps]]");
197
+ const PullSteps = Symbol("[[PullSteps]]");
198
+ const ReleaseSteps = Symbol("[[ReleaseSteps]]");
197
199
  function ReadableStreamReaderGenericInitialize(reader, stream) {
198
200
  reader._ownerReadableStream = stream;
199
201
  stream._reader = reader;
@@ -210,12 +212,14 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
210
212
  return ReadableStreamCancel(stream, reason);
211
213
  }
212
214
  function ReadableStreamReaderGenericRelease(reader) {
213
- if (reader._ownerReadableStream._state === "readable") {
215
+ const stream = reader._ownerReadableStream;
216
+ if (stream._state === "readable") {
214
217
  defaultReaderClosedPromiseReject(reader, new TypeError(`Reader was released and can no longer be used to monitor the stream's closedness`));
215
218
  } else {
216
219
  defaultReaderClosedPromiseResetToRejected(reader, new TypeError(`Reader was released and can no longer be used to monitor the stream's closedness`));
217
220
  }
218
- reader._ownerReadableStream._reader = void 0;
221
+ stream._readableStreamController[ReleaseSteps]();
222
+ stream._reader = void 0;
219
223
  reader._ownerReadableStream = void 0;
220
224
  }
221
225
  function readerLockException(name) {
@@ -255,10 +259,6 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
255
259
  reader._closedPromise_resolve = void 0;
256
260
  reader._closedPromise_reject = void 0;
257
261
  }
258
- const AbortSteps = SymbolPolyfill("[[AbortSteps]]");
259
- const ErrorSteps = SymbolPolyfill("[[ErrorSteps]]");
260
- const CancelSteps = SymbolPolyfill("[[CancelSteps]]");
261
- const PullSteps = SymbolPolyfill("[[PullSteps]]");
262
262
  const NumberIsFinite = Number.isFinite || function(x2) {
263
263
  return typeof x2 === "number" && isFinite(x2);
264
264
  };
@@ -429,10 +429,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
429
429
  if (this._ownerReadableStream === void 0) {
430
430
  return;
431
431
  }
432
- if (this._readRequests.length > 0) {
433
- throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");
434
- }
435
- ReadableStreamReaderGenericRelease(this);
432
+ ReadableStreamDefaultReaderRelease(this);
436
433
  }
437
434
  }
438
435
  Object.defineProperties(ReadableStreamDefaultReader.prototype, {
@@ -441,8 +438,11 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
441
438
  releaseLock: { enumerable: true },
442
439
  closed: { enumerable: true }
443
440
  });
444
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
445
- Object.defineProperty(ReadableStreamDefaultReader.prototype, SymbolPolyfill.toStringTag, {
441
+ setFunctionName(ReadableStreamDefaultReader.prototype.cancel, "cancel");
442
+ setFunctionName(ReadableStreamDefaultReader.prototype.read, "read");
443
+ setFunctionName(ReadableStreamDefaultReader.prototype.releaseLock, "releaseLock");
444
+ if (typeof Symbol.toStringTag === "symbol") {
445
+ Object.defineProperty(ReadableStreamDefaultReader.prototype, Symbol.toStringTag, {
446
446
  value: "ReadableStreamDefaultReader",
447
447
  configurable: true
448
448
  });
@@ -467,6 +467,18 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
467
467
  stream._readableStreamController[PullSteps](readRequest);
468
468
  }
469
469
  }
470
+ function ReadableStreamDefaultReaderRelease(reader) {
471
+ ReadableStreamReaderGenericRelease(reader);
472
+ const e2 = new TypeError("Reader was released");
473
+ ReadableStreamDefaultReaderErrorReadRequests(reader, e2);
474
+ }
475
+ function ReadableStreamDefaultReaderErrorReadRequests(reader, e2) {
476
+ const readRequests = reader._readRequests;
477
+ reader._readRequests = new SimpleQueue();
478
+ readRequests.forEach((readRequest) => {
479
+ readRequest._errorSteps(e2);
480
+ });
481
+ }
470
482
  function defaultReaderBrandCheckException(name) {
471
483
  return new TypeError(`ReadableStreamDefaultReader.prototype.${name} can only be used on a ReadableStreamDefaultReader`);
472
484
  }
@@ -493,9 +505,6 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
493
505
  return Promise.resolve({ value: void 0, done: true });
494
506
  }
495
507
  const reader = this._reader;
496
- if (reader._ownerReadableStream === void 0) {
497
- return promiseRejectedWith(readerLockException("iterate"));
498
- }
499
508
  let resolvePromise;
500
509
  let rejectPromise;
501
510
  const promise = newPromise((resolve, reject) => {
@@ -505,7 +514,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
505
514
  const readRequest = {
506
515
  _chunkSteps: (chunk) => {
507
516
  this._ongoingPromise = void 0;
508
- queueMicrotask(() => resolvePromise({ value: chunk, done: false }));
517
+ _queueMicrotask(() => resolvePromise({ value: chunk, done: false }));
509
518
  },
510
519
  _closeSteps: () => {
511
520
  this._ongoingPromise = void 0;
@@ -529,9 +538,6 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
529
538
  }
530
539
  this._isFinished = true;
531
540
  const reader = this._reader;
532
- if (reader._ownerReadableStream === void 0) {
533
- return promiseRejectedWith(readerLockException("finish iterating"));
534
- }
535
541
  if (!this._preventCancel) {
536
542
  const result = ReadableStreamReaderGenericCancel(reader, value);
537
543
  ReadableStreamReaderGenericRelease(reader);
@@ -555,9 +561,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
555
561
  return this._asyncIteratorImpl.return(value);
556
562
  }
557
563
  };
558
- if (AsyncIteratorPrototype !== void 0) {
559
- Object.setPrototypeOf(ReadableStreamAsyncIteratorPrototype, AsyncIteratorPrototype);
560
- }
564
+ Object.setPrototypeOf(ReadableStreamAsyncIteratorPrototype, AsyncIteratorPrototype);
561
565
  function AcquireReadableStreamAsyncIterator(stream, preventCancel) {
562
566
  const reader = AcquireReadableStreamDefaultReader(stream);
563
567
  const impl = new ReadableStreamAsyncIteratorImpl(reader, preventCancel);
@@ -574,7 +578,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
574
578
  }
575
579
  try {
576
580
  return x2._asyncIteratorImpl instanceof ReadableStreamAsyncIteratorImpl;
577
- } catch (_a) {
581
+ } catch (_a2) {
578
582
  return false;
579
583
  }
580
584
  }
@@ -584,18 +588,31 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
584
588
  const NumberIsNaN = Number.isNaN || function(x2) {
585
589
  return x2 !== x2;
586
590
  };
591
+ var _a, _b, _c;
587
592
  function CreateArrayFromList(elements) {
588
593
  return elements.slice();
589
594
  }
590
595
  function CopyDataBlockBytes(dest, destOffset, src, srcOffset, n) {
591
596
  new Uint8Array(dest).set(new Uint8Array(src, srcOffset, n), destOffset);
592
597
  }
593
- function TransferArrayBuffer(O) {
594
- return O;
595
- }
596
- function IsDetachedBuffer(O) {
597
- return false;
598
- }
598
+ let TransferArrayBuffer = (O) => {
599
+ if (typeof O.transfer === "function") {
600
+ TransferArrayBuffer = (buffer) => buffer.transfer();
601
+ } else if (typeof structuredClone === "function") {
602
+ TransferArrayBuffer = (buffer) => structuredClone(buffer, { transfer: [buffer] });
603
+ } else {
604
+ TransferArrayBuffer = (buffer) => buffer;
605
+ }
606
+ return TransferArrayBuffer(O);
607
+ };
608
+ let IsDetachedBuffer = (O) => {
609
+ if (typeof O.detached === "boolean") {
610
+ IsDetachedBuffer = (buffer) => buffer.detached;
611
+ } else {
612
+ IsDetachedBuffer = (buffer) => buffer.byteLength === 0;
613
+ }
614
+ return IsDetachedBuffer(O);
615
+ };
599
616
  function ArrayBufferSlice(buffer, begin, end) {
600
617
  if (buffer.slice) {
601
618
  return buffer.slice(begin, end);
@@ -605,6 +622,63 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
605
622
  CopyDataBlockBytes(slice, 0, buffer, begin, length);
606
623
  return slice;
607
624
  }
625
+ function GetMethod(receiver, prop) {
626
+ const func = receiver[prop];
627
+ if (func === void 0 || func === null) {
628
+ return void 0;
629
+ }
630
+ if (typeof func !== "function") {
631
+ throw new TypeError(`${String(prop)} is not a function`);
632
+ }
633
+ return func;
634
+ }
635
+ function CreateAsyncFromSyncIterator(syncIteratorRecord) {
636
+ const syncIterable = {
637
+ [Symbol.iterator]: () => syncIteratorRecord.iterator
638
+ };
639
+ const asyncIterator = async function* () {
640
+ return yield* syncIterable;
641
+ }();
642
+ const nextMethod = asyncIterator.next;
643
+ return { iterator: asyncIterator, nextMethod, done: false };
644
+ }
645
+ 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";
646
+ function GetIterator(obj, hint = "sync", method) {
647
+ if (method === void 0) {
648
+ if (hint === "async") {
649
+ method = GetMethod(obj, SymbolAsyncIterator);
650
+ if (method === void 0) {
651
+ const syncMethod = GetMethod(obj, Symbol.iterator);
652
+ const syncIteratorRecord = GetIterator(obj, "sync", syncMethod);
653
+ return CreateAsyncFromSyncIterator(syncIteratorRecord);
654
+ }
655
+ } else {
656
+ method = GetMethod(obj, Symbol.iterator);
657
+ }
658
+ }
659
+ if (method === void 0) {
660
+ throw new TypeError("The object is not iterable");
661
+ }
662
+ const iterator = reflectCall(method, obj, []);
663
+ if (!typeIsObject(iterator)) {
664
+ throw new TypeError("The iterator method must return an object");
665
+ }
666
+ const nextMethod = iterator.next;
667
+ return { iterator, nextMethod, done: false };
668
+ }
669
+ function IteratorNext(iteratorRecord) {
670
+ const result = reflectCall(iteratorRecord.nextMethod, iteratorRecord.iterator, []);
671
+ if (!typeIsObject(result)) {
672
+ throw new TypeError("The iterator.next() method must return an object");
673
+ }
674
+ return result;
675
+ }
676
+ function IteratorComplete(iterResult) {
677
+ return Boolean(iterResult.done);
678
+ }
679
+ function IteratorValue(iterResult) {
680
+ return iterResult.value;
681
+ }
608
682
  function IsNonNegativeNumber(v) {
609
683
  if (typeof v !== "number") {
610
684
  return false;
@@ -644,6 +718,18 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
644
718
  container._queue = new SimpleQueue();
645
719
  container._queueTotalSize = 0;
646
720
  }
721
+ function isDataViewConstructor(ctor) {
722
+ return ctor === DataView;
723
+ }
724
+ function isDataView(view) {
725
+ return isDataViewConstructor(view.constructor);
726
+ }
727
+ function arrayBufferViewElementSize(ctor) {
728
+ if (isDataViewConstructor(ctor)) {
729
+ return 1;
730
+ }
731
+ return ctor.BYTES_PER_ELEMENT;
732
+ }
647
733
  class ReadableStreamBYOBRequest {
648
734
  constructor() {
649
735
  throw new TypeError("Illegal constructor");
@@ -666,7 +752,9 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
666
752
  if (this._associatedReadableByteStreamController === void 0) {
667
753
  throw new TypeError("This BYOB request has been invalidated");
668
754
  }
669
- if (IsDetachedBuffer(this._view.buffer)) ;
755
+ if (IsDetachedBuffer(this._view.buffer)) {
756
+ throw new TypeError(`The BYOB request's buffer has been detached and so cannot be used as a response`);
757
+ }
670
758
  ReadableByteStreamControllerRespond(this._associatedReadableByteStreamController, bytesWritten);
671
759
  }
672
760
  respondWithNewView(view) {
@@ -680,7 +768,9 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
680
768
  if (this._associatedReadableByteStreamController === void 0) {
681
769
  throw new TypeError("This BYOB request has been invalidated");
682
770
  }
683
- if (IsDetachedBuffer(view.buffer)) ;
771
+ if (IsDetachedBuffer(view.buffer)) {
772
+ throw new TypeError("The given view's buffer has been detached and so cannot be used as a response");
773
+ }
684
774
  ReadableByteStreamControllerRespondWithNewView(this._associatedReadableByteStreamController, view);
685
775
  }
686
776
  }
@@ -689,8 +779,10 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
689
779
  respondWithNewView: { enumerable: true },
690
780
  view: { enumerable: true }
691
781
  });
692
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
693
- Object.defineProperty(ReadableStreamBYOBRequest.prototype, SymbolPolyfill.toStringTag, {
782
+ setFunctionName(ReadableStreamBYOBRequest.prototype.respond, "respond");
783
+ setFunctionName(ReadableStreamBYOBRequest.prototype.respondWithNewView, "respondWithNewView");
784
+ if (typeof Symbol.toStringTag === "symbol") {
785
+ Object.defineProperty(ReadableStreamBYOBRequest.prototype, Symbol.toStringTag, {
694
786
  value: "ReadableStreamBYOBRequest",
695
787
  configurable: true
696
788
  });
@@ -779,11 +871,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
779
871
  [PullSteps](readRequest) {
780
872
  const stream = this._controlledReadableByteStream;
781
873
  if (this._queueTotalSize > 0) {
782
- const entry = this._queue.shift();
783
- this._queueTotalSize -= entry.byteLength;
784
- ReadableByteStreamControllerHandleQueueDrain(this);
785
- const view = new Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);
786
- readRequest._chunkSteps(view);
874
+ ReadableByteStreamControllerFillReadRequestFromQueue(this, readRequest);
787
875
  return;
788
876
  }
789
877
  const autoAllocateChunkSize = this._autoAllocateChunkSize;
@@ -801,6 +889,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
801
889
  byteOffset: 0,
802
890
  byteLength: autoAllocateChunkSize,
803
891
  bytesFilled: 0,
892
+ minimumFill: 1,
804
893
  elementSize: 1,
805
894
  viewConstructor: Uint8Array,
806
895
  readerType: "default"
@@ -810,6 +899,15 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
810
899
  ReadableStreamAddReadRequest(stream, readRequest);
811
900
  ReadableByteStreamControllerCallPullIfNeeded(this);
812
901
  }
902
+ /** @internal */
903
+ [ReleaseSteps]() {
904
+ if (this._pendingPullIntos.length > 0) {
905
+ const firstPullInto = this._pendingPullIntos.peek();
906
+ firstPullInto.readerType = "none";
907
+ this._pendingPullIntos = new SimpleQueue();
908
+ this._pendingPullIntos.push(firstPullInto);
909
+ }
910
+ }
813
911
  }
814
912
  Object.defineProperties(ReadableByteStreamController.prototype, {
815
913
  close: { enumerable: true },
@@ -818,8 +916,11 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
818
916
  byobRequest: { enumerable: true },
819
917
  desiredSize: { enumerable: true }
820
918
  });
821
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
822
- Object.defineProperty(ReadableByteStreamController.prototype, SymbolPolyfill.toStringTag, {
919
+ setFunctionName(ReadableByteStreamController.prototype.close, "close");
920
+ setFunctionName(ReadableByteStreamController.prototype.enqueue, "enqueue");
921
+ setFunctionName(ReadableByteStreamController.prototype.error, "error");
922
+ if (typeof Symbol.toStringTag === "symbol") {
923
+ Object.defineProperty(ReadableByteStreamController.prototype, Symbol.toStringTag, {
823
924
  value: "ReadableByteStreamController",
824
925
  configurable: true
825
926
  });
@@ -859,8 +960,10 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
859
960
  controller._pullAgain = false;
860
961
  ReadableByteStreamControllerCallPullIfNeeded(controller);
861
962
  }
963
+ return null;
862
964
  }, (e2) => {
863
965
  ReadableByteStreamControllerError(controller, e2);
966
+ return null;
864
967
  });
865
968
  }
866
969
  function ReadableByteStreamControllerClearPendingPullIntos(controller) {
@@ -888,15 +991,30 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
888
991
  controller._queue.push({ buffer, byteOffset, byteLength });
889
992
  controller._queueTotalSize += byteLength;
890
993
  }
994
+ function ReadableByteStreamControllerEnqueueClonedChunkToQueue(controller, buffer, byteOffset, byteLength) {
995
+ let clonedChunk;
996
+ try {
997
+ clonedChunk = ArrayBufferSlice(buffer, byteOffset, byteOffset + byteLength);
998
+ } catch (cloneE) {
999
+ ReadableByteStreamControllerError(controller, cloneE);
1000
+ throw cloneE;
1001
+ }
1002
+ ReadableByteStreamControllerEnqueueChunkToQueue(controller, clonedChunk, 0, byteLength);
1003
+ }
1004
+ function ReadableByteStreamControllerEnqueueDetachedPullIntoToQueue(controller, firstDescriptor) {
1005
+ if (firstDescriptor.bytesFilled > 0) {
1006
+ ReadableByteStreamControllerEnqueueClonedChunkToQueue(controller, firstDescriptor.buffer, firstDescriptor.byteOffset, firstDescriptor.bytesFilled);
1007
+ }
1008
+ ReadableByteStreamControllerShiftPendingPullInto(controller);
1009
+ }
891
1010
  function ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) {
892
- const elementSize = pullIntoDescriptor.elementSize;
893
- const currentAlignedBytes = pullIntoDescriptor.bytesFilled - pullIntoDescriptor.bytesFilled % elementSize;
894
1011
  const maxBytesToCopy = Math.min(controller._queueTotalSize, pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled);
895
1012
  const maxBytesFilled = pullIntoDescriptor.bytesFilled + maxBytesToCopy;
896
- const maxAlignedBytes = maxBytesFilled - maxBytesFilled % elementSize;
897
1013
  let totalBytesToCopyRemaining = maxBytesToCopy;
898
1014
  let ready = false;
899
- if (maxAlignedBytes > currentAlignedBytes) {
1015
+ const remainderBytes = maxBytesFilled % pullIntoDescriptor.elementSize;
1016
+ const maxAlignedBytes = maxBytesFilled - remainderBytes;
1017
+ if (maxAlignedBytes >= pullIntoDescriptor.minimumFill) {
900
1018
  totalBytesToCopyRemaining = maxAlignedBytes - pullIntoDescriptor.bytesFilled;
901
1019
  ready = true;
902
1020
  }
@@ -949,20 +1067,36 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
949
1067
  }
950
1068
  }
951
1069
  }
952
- function ReadableByteStreamControllerPullInto(controller, view, readIntoRequest) {
953
- const stream = controller._controlledReadableByteStream;
954
- let elementSize = 1;
955
- if (view.constructor !== DataView) {
956
- elementSize = view.constructor.BYTES_PER_ELEMENT;
1070
+ function ReadableByteStreamControllerProcessReadRequestsUsingQueue(controller) {
1071
+ const reader = controller._controlledReadableByteStream._reader;
1072
+ while (reader._readRequests.length > 0) {
1073
+ if (controller._queueTotalSize === 0) {
1074
+ return;
1075
+ }
1076
+ const readRequest = reader._readRequests.shift();
1077
+ ReadableByteStreamControllerFillReadRequestFromQueue(controller, readRequest);
957
1078
  }
1079
+ }
1080
+ function ReadableByteStreamControllerPullInto(controller, view, min, readIntoRequest) {
1081
+ const stream = controller._controlledReadableByteStream;
958
1082
  const ctor = view.constructor;
959
- const buffer = TransferArrayBuffer(view.buffer);
1083
+ const elementSize = arrayBufferViewElementSize(ctor);
1084
+ const { byteOffset, byteLength } = view;
1085
+ const minimumFill = min * elementSize;
1086
+ let buffer;
1087
+ try {
1088
+ buffer = TransferArrayBuffer(view.buffer);
1089
+ } catch (e2) {
1090
+ readIntoRequest._errorSteps(e2);
1091
+ return;
1092
+ }
960
1093
  const pullIntoDescriptor = {
961
1094
  buffer,
962
1095
  bufferByteLength: buffer.byteLength,
963
- byteOffset: view.byteOffset,
964
- byteLength: view.byteLength,
1096
+ byteOffset,
1097
+ byteLength,
965
1098
  bytesFilled: 0,
1099
+ minimumFill,
966
1100
  elementSize,
967
1101
  viewConstructor: ctor,
968
1102
  readerType: "byob"
@@ -996,6 +1130,9 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
996
1130
  ReadableByteStreamControllerCallPullIfNeeded(controller);
997
1131
  }
998
1132
  function ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor) {
1133
+ if (firstDescriptor.readerType === "none") {
1134
+ ReadableByteStreamControllerShiftPendingPullInto(controller);
1135
+ }
999
1136
  const stream = controller._controlledReadableByteStream;
1000
1137
  if (ReadableStreamHasBYOBReader(stream)) {
1001
1138
  while (ReadableStreamGetNumReadIntoRequests(stream) > 0) {
@@ -1006,15 +1143,19 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
1006
1143
  }
1007
1144
  function ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, pullIntoDescriptor) {
1008
1145
  ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesWritten, pullIntoDescriptor);
1009
- if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize) {
1146
+ if (pullIntoDescriptor.readerType === "none") {
1147
+ ReadableByteStreamControllerEnqueueDetachedPullIntoToQueue(controller, pullIntoDescriptor);
1148
+ ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
1149
+ return;
1150
+ }
1151
+ if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.minimumFill) {
1010
1152
  return;
1011
1153
  }
1012
1154
  ReadableByteStreamControllerShiftPendingPullInto(controller);
1013
1155
  const remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize;
1014
1156
  if (remainderSize > 0) {
1015
1157
  const end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
1016
- const remainder = ArrayBufferSlice(pullIntoDescriptor.buffer, end - remainderSize, end);
1017
- ReadableByteStreamControllerEnqueueChunkToQueue(controller, remainder, 0, remainder.byteLength);
1158
+ ReadableByteStreamControllerEnqueueClonedChunkToQueue(controller, pullIntoDescriptor.buffer, end - remainderSize, remainderSize);
1018
1159
  }
1019
1160
  pullIntoDescriptor.bytesFilled -= remainderSize;
1020
1161
  ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableByteStream, pullIntoDescriptor);
@@ -1025,7 +1166,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
1025
1166
  ReadableByteStreamControllerInvalidateBYOBRequest(controller);
1026
1167
  const state = controller._controlledReadableByteStream._state;
1027
1168
  if (state === "closed") {
1028
- ReadableByteStreamControllerRespondInClosedState(controller);
1169
+ ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor);
1029
1170
  } else {
1030
1171
  ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor);
1031
1172
  }
@@ -1073,7 +1214,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
1073
1214
  }
1074
1215
  if (controller._pendingPullIntos.length > 0) {
1075
1216
  const firstPendingPullInto = controller._pendingPullIntos.peek();
1076
- if (firstPendingPullInto.bytesFilled > 0) {
1217
+ if (firstPendingPullInto.bytesFilled % firstPendingPullInto.elementSize !== 0) {
1077
1218
  const e2 = new TypeError("Insufficient bytes to fill elements in the given buffer");
1078
1219
  ReadableByteStreamControllerError(controller, e2);
1079
1220
  throw e2;
@@ -1087,17 +1228,24 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
1087
1228
  if (controller._closeRequested || stream._state !== "readable") {
1088
1229
  return;
1089
1230
  }
1090
- const buffer = chunk.buffer;
1091
- const byteOffset = chunk.byteOffset;
1092
- const byteLength = chunk.byteLength;
1231
+ const { buffer, byteOffset, byteLength } = chunk;
1232
+ if (IsDetachedBuffer(buffer)) {
1233
+ throw new TypeError("chunk's buffer is detached and so cannot be enqueued");
1234
+ }
1093
1235
  const transferredBuffer = TransferArrayBuffer(buffer);
1094
1236
  if (controller._pendingPullIntos.length > 0) {
1095
1237
  const firstPendingPullInto = controller._pendingPullIntos.peek();
1096
- if (IsDetachedBuffer(firstPendingPullInto.buffer)) ;
1238
+ if (IsDetachedBuffer(firstPendingPullInto.buffer)) {
1239
+ throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk");
1240
+ }
1241
+ ReadableByteStreamControllerInvalidateBYOBRequest(controller);
1097
1242
  firstPendingPullInto.buffer = TransferArrayBuffer(firstPendingPullInto.buffer);
1243
+ if (firstPendingPullInto.readerType === "none") {
1244
+ ReadableByteStreamControllerEnqueueDetachedPullIntoToQueue(controller, firstPendingPullInto);
1245
+ }
1098
1246
  }
1099
- ReadableByteStreamControllerInvalidateBYOBRequest(controller);
1100
1247
  if (ReadableStreamHasDefaultReader(stream)) {
1248
+ ReadableByteStreamControllerProcessReadRequestsUsingQueue(controller);
1101
1249
  if (ReadableStreamGetNumReadRequests(stream) === 0) {
1102
1250
  ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
1103
1251
  } else {
@@ -1125,6 +1273,13 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
1125
1273
  ReadableByteStreamControllerClearAlgorithms(controller);
1126
1274
  ReadableStreamError(stream, e2);
1127
1275
  }
1276
+ function ReadableByteStreamControllerFillReadRequestFromQueue(controller, readRequest) {
1277
+ const entry = controller._queue.shift();
1278
+ controller._queueTotalSize -= entry.byteLength;
1279
+ ReadableByteStreamControllerHandleQueueDrain(controller);
1280
+ const view = new Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);
1281
+ readRequest._chunkSteps(view);
1282
+ }
1128
1283
  function ReadableByteStreamControllerGetBYOBRequest(controller) {
1129
1284
  if (controller._byobRequest === null && controller._pendingPullIntos.length > 0) {
1130
1285
  const firstDescriptor = controller._pendingPullIntos.peek();
@@ -1207,23 +1362,31 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
1207
1362
  uponPromise(promiseResolvedWith(startResult), () => {
1208
1363
  controller._started = true;
1209
1364
  ReadableByteStreamControllerCallPullIfNeeded(controller);
1365
+ return null;
1210
1366
  }, (r2) => {
1211
1367
  ReadableByteStreamControllerError(controller, r2);
1368
+ return null;
1212
1369
  });
1213
1370
  }
1214
1371
  function SetUpReadableByteStreamControllerFromUnderlyingSource(stream, underlyingByteSource, highWaterMark) {
1215
1372
  const controller = Object.create(ReadableByteStreamController.prototype);
1216
- let startAlgorithm = () => void 0;
1217
- let pullAlgorithm = () => promiseResolvedWith(void 0);
1218
- let cancelAlgorithm = () => promiseResolvedWith(void 0);
1373
+ let startAlgorithm;
1374
+ let pullAlgorithm;
1375
+ let cancelAlgorithm;
1219
1376
  if (underlyingByteSource.start !== void 0) {
1220
1377
  startAlgorithm = () => underlyingByteSource.start(controller);
1378
+ } else {
1379
+ startAlgorithm = () => void 0;
1221
1380
  }
1222
1381
  if (underlyingByteSource.pull !== void 0) {
1223
1382
  pullAlgorithm = () => underlyingByteSource.pull(controller);
1383
+ } else {
1384
+ pullAlgorithm = () => promiseResolvedWith(void 0);
1224
1385
  }
1225
1386
  if (underlyingByteSource.cancel !== void 0) {
1226
1387
  cancelAlgorithm = (reason) => underlyingByteSource.cancel(reason);
1388
+ } else {
1389
+ cancelAlgorithm = () => promiseResolvedWith(void 0);
1227
1390
  }
1228
1391
  const autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize;
1229
1392
  if (autoAllocateChunkSize === 0) {
@@ -1241,6 +1404,28 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
1241
1404
  function byteStreamControllerBrandCheckException(name) {
1242
1405
  return new TypeError(`ReadableByteStreamController.prototype.${name} can only be used on a ReadableByteStreamController`);
1243
1406
  }
1407
+ function convertReaderOptions(options, context) {
1408
+ assertDictionary(options, context);
1409
+ const mode = options === null || options === void 0 ? void 0 : options.mode;
1410
+ return {
1411
+ mode: mode === void 0 ? void 0 : convertReadableStreamReaderMode(mode, `${context} has member 'mode' that`)
1412
+ };
1413
+ }
1414
+ function convertReadableStreamReaderMode(mode, context) {
1415
+ mode = `${mode}`;
1416
+ if (mode !== "byob") {
1417
+ throw new TypeError(`${context} '${mode}' is not a valid enumeration value for ReadableStreamReaderMode`);
1418
+ }
1419
+ return mode;
1420
+ }
1421
+ function convertByobReadOptions(options, context) {
1422
+ var _a2;
1423
+ assertDictionary(options, context);
1424
+ const min = (_a2 = options === null || options === void 0 ? void 0 : options.min) !== null && _a2 !== void 0 ? _a2 : 1;
1425
+ return {
1426
+ min: convertUnsignedLongLongWithEnforceRange(min, `${context} has member 'min' that`)
1427
+ };
1428
+ }
1244
1429
  function AcquireReadableStreamBYOBReader(stream) {
1245
1430
  return new ReadableStreamBYOBReader(stream);
1246
1431
  }
@@ -1304,12 +1489,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
1304
1489
  }
1305
1490
  return ReadableStreamReaderGenericCancel(this, reason);
1306
1491
  }
1307
- /**
1308
- * Attempts to reads bytes into view, and returns a promise resolved with the result.
1309
- *
1310
- * If reading a chunk causes the queue to become empty, more data will be pulled from the underlying source.
1311
- */
1312
- read(view) {
1492
+ read(view, rawOptions = {}) {
1313
1493
  if (!IsReadableStreamBYOBReader(this)) {
1314
1494
  return promiseRejectedWith(byobReaderBrandCheckException("read"));
1315
1495
  }
@@ -1322,7 +1502,26 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
1322
1502
  if (view.buffer.byteLength === 0) {
1323
1503
  return promiseRejectedWith(new TypeError(`view's buffer must have non-zero byteLength`));
1324
1504
  }
1325
- if (IsDetachedBuffer(view.buffer)) ;
1505
+ if (IsDetachedBuffer(view.buffer)) {
1506
+ return promiseRejectedWith(new TypeError("view's buffer has been detached"));
1507
+ }
1508
+ let options;
1509
+ try {
1510
+ options = convertByobReadOptions(rawOptions, "options");
1511
+ } catch (e2) {
1512
+ return promiseRejectedWith(e2);
1513
+ }
1514
+ const min = options.min;
1515
+ if (min === 0) {
1516
+ return promiseRejectedWith(new TypeError("options.min must be greater than 0"));
1517
+ }
1518
+ if (!isDataView(view)) {
1519
+ if (min > view.length) {
1520
+ return promiseRejectedWith(new RangeError("options.min must be less than or equal to view's length"));
1521
+ }
1522
+ } else if (min > view.byteLength) {
1523
+ return promiseRejectedWith(new RangeError("options.min must be less than or equal to view's byteLength"));
1524
+ }
1326
1525
  if (this._ownerReadableStream === void 0) {
1327
1526
  return promiseRejectedWith(readerLockException("read from"));
1328
1527
  }
@@ -1337,7 +1536,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
1337
1536
  _closeSteps: (chunk) => resolvePromise({ value: chunk, done: true }),
1338
1537
  _errorSteps: (e2) => rejectPromise(e2)
1339
1538
  };
1340
- ReadableStreamBYOBReaderRead(this, view, readIntoRequest);
1539
+ ReadableStreamBYOBReaderRead(this, view, min, readIntoRequest);
1341
1540
  return promise;
1342
1541
  }
1343
1542
  /**
@@ -1356,10 +1555,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
1356
1555
  if (this._ownerReadableStream === void 0) {
1357
1556
  return;
1358
1557
  }
1359
- if (this._readIntoRequests.length > 0) {
1360
- throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");
1361
- }
1362
- ReadableStreamReaderGenericRelease(this);
1558
+ ReadableStreamBYOBReaderRelease(this);
1363
1559
  }
1364
1560
  }
1365
1561
  Object.defineProperties(ReadableStreamBYOBReader.prototype, {
@@ -1368,8 +1564,11 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
1368
1564
  releaseLock: { enumerable: true },
1369
1565
  closed: { enumerable: true }
1370
1566
  });
1371
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
1372
- Object.defineProperty(ReadableStreamBYOBReader.prototype, SymbolPolyfill.toStringTag, {
1567
+ setFunctionName(ReadableStreamBYOBReader.prototype.cancel, "cancel");
1568
+ setFunctionName(ReadableStreamBYOBReader.prototype.read, "read");
1569
+ setFunctionName(ReadableStreamBYOBReader.prototype.releaseLock, "releaseLock");
1570
+ if (typeof Symbol.toStringTag === "symbol") {
1571
+ Object.defineProperty(ReadableStreamBYOBReader.prototype, Symbol.toStringTag, {
1373
1572
  value: "ReadableStreamBYOBReader",
1374
1573
  configurable: true
1375
1574
  });
@@ -1383,15 +1582,27 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
1383
1582
  }
1384
1583
  return x2 instanceof ReadableStreamBYOBReader;
1385
1584
  }
1386
- function ReadableStreamBYOBReaderRead(reader, view, readIntoRequest) {
1585
+ function ReadableStreamBYOBReaderRead(reader, view, min, readIntoRequest) {
1387
1586
  const stream = reader._ownerReadableStream;
1388
1587
  stream._disturbed = true;
1389
1588
  if (stream._state === "errored") {
1390
1589
  readIntoRequest._errorSteps(stream._storedError);
1391
1590
  } else {
1392
- ReadableByteStreamControllerPullInto(stream._readableStreamController, view, readIntoRequest);
1591
+ ReadableByteStreamControllerPullInto(stream._readableStreamController, view, min, readIntoRequest);
1393
1592
  }
1394
1593
  }
1594
+ function ReadableStreamBYOBReaderRelease(reader) {
1595
+ ReadableStreamReaderGenericRelease(reader);
1596
+ const e2 = new TypeError("Reader was released");
1597
+ ReadableStreamBYOBReaderErrorReadIntoRequests(reader, e2);
1598
+ }
1599
+ function ReadableStreamBYOBReaderErrorReadIntoRequests(reader, e2) {
1600
+ const readIntoRequests = reader._readIntoRequests;
1601
+ reader._readIntoRequests = new SimpleQueue();
1602
+ readIntoRequests.forEach((readIntoRequest) => {
1603
+ readIntoRequest._errorSteps(e2);
1604
+ });
1605
+ }
1395
1606
  function byobReaderBrandCheckException(name) {
1396
1607
  return new TypeError(`ReadableStreamBYOBReader.prototype.${name} can only be used on a ReadableStreamBYOBReader`);
1397
1608
  }
@@ -1467,7 +1678,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
1467
1678
  }
1468
1679
  try {
1469
1680
  return typeof value.aborted === "boolean";
1470
- } catch (_a) {
1681
+ } catch (_a2) {
1471
1682
  return false;
1472
1683
  }
1473
1684
  }
@@ -1564,8 +1775,11 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
1564
1775
  getWriter: { enumerable: true },
1565
1776
  locked: { enumerable: true }
1566
1777
  });
1567
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
1568
- Object.defineProperty(WritableStream.prototype, SymbolPolyfill.toStringTag, {
1778
+ setFunctionName(WritableStream.prototype.abort, "abort");
1779
+ setFunctionName(WritableStream.prototype.close, "close");
1780
+ setFunctionName(WritableStream.prototype.getWriter, "getWriter");
1781
+ if (typeof Symbol.toStringTag === "symbol") {
1782
+ Object.defineProperty(WritableStream.prototype, Symbol.toStringTag, {
1569
1783
  value: "WritableStream",
1570
1784
  configurable: true
1571
1785
  });
@@ -1608,12 +1822,12 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
1608
1822
  return true;
1609
1823
  }
1610
1824
  function WritableStreamAbort(stream, reason) {
1611
- var _a;
1825
+ var _a2;
1612
1826
  if (stream._state === "closed" || stream._state === "errored") {
1613
1827
  return promiseResolvedWith(void 0);
1614
1828
  }
1615
1829
  stream._writableStreamController._abortReason = reason;
1616
- (_a = stream._writableStreamController._abortController) === null || _a === void 0 ? void 0 : _a.abort();
1830
+ (_a2 = stream._writableStreamController._abortController) === null || _a2 === void 0 ? void 0 : _a2.abort(reason);
1617
1831
  const state = stream._state;
1618
1832
  if (state === "closed" || state === "errored") {
1619
1833
  return promiseResolvedWith(void 0);
@@ -1713,9 +1927,11 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
1713
1927
  uponPromise(promise, () => {
1714
1928
  abortRequest._resolve();
1715
1929
  WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
1930
+ return null;
1716
1931
  }, (reason) => {
1717
1932
  abortRequest._reject(reason);
1718
1933
  WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
1934
+ return null;
1719
1935
  });
1720
1936
  }
1721
1937
  function WritableStreamFinishInFlightWrite(stream) {
@@ -1930,8 +2146,12 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
1930
2146
  desiredSize: { enumerable: true },
1931
2147
  ready: { enumerable: true }
1932
2148
  });
1933
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
1934
- Object.defineProperty(WritableStreamDefaultWriter.prototype, SymbolPolyfill.toStringTag, {
2149
+ setFunctionName(WritableStreamDefaultWriter.prototype.abort, "abort");
2150
+ setFunctionName(WritableStreamDefaultWriter.prototype.close, "close");
2151
+ setFunctionName(WritableStreamDefaultWriter.prototype.releaseLock, "releaseLock");
2152
+ setFunctionName(WritableStreamDefaultWriter.prototype.write, "write");
2153
+ if (typeof Symbol.toStringTag === "symbol") {
2154
+ Object.defineProperty(WritableStreamDefaultWriter.prototype, Symbol.toStringTag, {
1935
2155
  value: "WritableStreamDefaultWriter",
1936
2156
  configurable: true
1937
2157
  });
@@ -2081,8 +2301,8 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
2081
2301
  signal: { enumerable: true },
2082
2302
  error: { enumerable: true }
2083
2303
  });
2084
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
2085
- Object.defineProperty(WritableStreamDefaultController.prototype, SymbolPolyfill.toStringTag, {
2304
+ if (typeof Symbol.toStringTag === "symbol") {
2305
+ Object.defineProperty(WritableStreamDefaultController.prototype, Symbol.toStringTag, {
2086
2306
  value: "WritableStreamDefaultController",
2087
2307
  configurable: true
2088
2308
  });
@@ -2117,28 +2337,38 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
2117
2337
  uponPromise(startPromise, () => {
2118
2338
  controller._started = true;
2119
2339
  WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
2340
+ return null;
2120
2341
  }, (r2) => {
2121
2342
  controller._started = true;
2122
2343
  WritableStreamDealWithRejection(stream, r2);
2344
+ return null;
2123
2345
  });
2124
2346
  }
2125
2347
  function SetUpWritableStreamDefaultControllerFromUnderlyingSink(stream, underlyingSink, highWaterMark, sizeAlgorithm) {
2126
2348
  const controller = Object.create(WritableStreamDefaultController.prototype);
2127
- let startAlgorithm = () => void 0;
2128
- let writeAlgorithm = () => promiseResolvedWith(void 0);
2129
- let closeAlgorithm = () => promiseResolvedWith(void 0);
2130
- let abortAlgorithm = () => promiseResolvedWith(void 0);
2349
+ let startAlgorithm;
2350
+ let writeAlgorithm;
2351
+ let closeAlgorithm;
2352
+ let abortAlgorithm;
2131
2353
  if (underlyingSink.start !== void 0) {
2132
2354
  startAlgorithm = () => underlyingSink.start(controller);
2355
+ } else {
2356
+ startAlgorithm = () => void 0;
2133
2357
  }
2134
2358
  if (underlyingSink.write !== void 0) {
2135
2359
  writeAlgorithm = (chunk) => underlyingSink.write(chunk, controller);
2360
+ } else {
2361
+ writeAlgorithm = () => promiseResolvedWith(void 0);
2136
2362
  }
2137
2363
  if (underlyingSink.close !== void 0) {
2138
2364
  closeAlgorithm = () => underlyingSink.close();
2365
+ } else {
2366
+ closeAlgorithm = () => promiseResolvedWith(void 0);
2139
2367
  }
2140
2368
  if (underlyingSink.abort !== void 0) {
2141
2369
  abortAlgorithm = (reason) => underlyingSink.abort(reason);
2370
+ } else {
2371
+ abortAlgorithm = () => promiseResolvedWith(void 0);
2142
2372
  }
2143
2373
  SetUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm);
2144
2374
  }
@@ -2213,8 +2443,10 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
2213
2443
  WritableStreamDefaultControllerClearAlgorithms(controller);
2214
2444
  uponPromise(sinkClosePromise, () => {
2215
2445
  WritableStreamFinishInFlightClose(stream);
2446
+ return null;
2216
2447
  }, (reason) => {
2217
2448
  WritableStreamFinishInFlightCloseWithError(stream, reason);
2449
+ return null;
2218
2450
  });
2219
2451
  }
2220
2452
  function WritableStreamDefaultControllerProcessWrite(controller, chunk) {
@@ -2230,11 +2462,13 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
2230
2462
  WritableStreamUpdateBackpressure(stream, backpressure);
2231
2463
  }
2232
2464
  WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
2465
+ return null;
2233
2466
  }, (reason) => {
2234
2467
  if (stream._state === "writable") {
2235
2468
  WritableStreamDefaultControllerClearAlgorithms(controller);
2236
2469
  }
2237
2470
  WritableStreamFinishInFlightWriteWithError(stream, reason);
2471
+ return null;
2238
2472
  });
2239
2473
  }
2240
2474
  function WritableStreamDefaultControllerGetBackpressure(controller) {
@@ -2335,19 +2569,36 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
2335
2569
  writer._readyPromise_reject = void 0;
2336
2570
  writer._readyPromiseState = "fulfilled";
2337
2571
  }
2338
- const NativeDOMException = typeof DOMException !== "undefined" ? DOMException : void 0;
2572
+ function getGlobals() {
2573
+ if (typeof globalThis !== "undefined") {
2574
+ return globalThis;
2575
+ } else if (typeof self !== "undefined") {
2576
+ return self;
2577
+ } else if (typeof global !== "undefined") {
2578
+ return global;
2579
+ }
2580
+ return void 0;
2581
+ }
2582
+ const globals = getGlobals();
2339
2583
  function isDOMExceptionConstructor(ctor) {
2340
2584
  if (!(typeof ctor === "function" || typeof ctor === "object")) {
2341
2585
  return false;
2342
2586
  }
2587
+ if (ctor.name !== "DOMException") {
2588
+ return false;
2589
+ }
2343
2590
  try {
2344
2591
  new ctor();
2345
2592
  return true;
2346
- } catch (_a) {
2593
+ } catch (_a2) {
2347
2594
  return false;
2348
2595
  }
2349
2596
  }
2350
- function createDOMExceptionPolyfill() {
2597
+ function getFromGlobal() {
2598
+ const ctor = globals === null || globals === void 0 ? void 0 : globals.DOMException;
2599
+ return isDOMExceptionConstructor(ctor) ? ctor : void 0;
2600
+ }
2601
+ function createPolyfill() {
2351
2602
  const ctor = function DOMException3(message, name) {
2352
2603
  this.message = message || "";
2353
2604
  this.name = name || "Error";
@@ -2355,11 +2606,12 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
2355
2606
  Error.captureStackTrace(this, this.constructor);
2356
2607
  }
2357
2608
  };
2609
+ setFunctionName(ctor, "DOMException");
2358
2610
  ctor.prototype = Object.create(Error.prototype);
2359
2611
  Object.defineProperty(ctor.prototype, "constructor", { value: ctor, writable: true, configurable: true });
2360
2612
  return ctor;
2361
2613
  }
2362
- const DOMException$1 = isDOMExceptionConstructor(NativeDOMException) ? NativeDOMException : createDOMExceptionPolyfill();
2614
+ const DOMException2 = getFromGlobal() || createPolyfill();
2363
2615
  function ReadableStreamPipeTo(source, dest, preventClose, preventAbort, preventCancel, signal) {
2364
2616
  const reader = AcquireReadableStreamDefaultReader(source);
2365
2617
  const writer = AcquireWritableStreamDefaultWriter(dest);
@@ -2370,7 +2622,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
2370
2622
  let abortAlgorithm;
2371
2623
  if (signal !== void 0) {
2372
2624
  abortAlgorithm = () => {
2373
- const error = new DOMException$1("Aborted", "AbortError");
2625
+ const error = signal.reason !== void 0 ? signal.reason : new DOMException2("Aborted", "AbortError");
2374
2626
  const actions = [];
2375
2627
  if (!preventAbort) {
2376
2628
  actions.push(() => {
@@ -2431,6 +2683,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
2431
2683
  } else {
2432
2684
  shutdown(true, storedError);
2433
2685
  }
2686
+ return null;
2434
2687
  });
2435
2688
  isOrBecomesErrored(dest, writer._closedPromise, (storedError) => {
2436
2689
  if (!preventCancel) {
@@ -2438,6 +2691,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
2438
2691
  } else {
2439
2692
  shutdown(true, storedError);
2440
2693
  }
2694
+ return null;
2441
2695
  });
2442
2696
  isOrBecomesClosed(source, reader._closedPromise, () => {
2443
2697
  if (!preventClose) {
@@ -2445,6 +2699,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
2445
2699
  } else {
2446
2700
  shutdown();
2447
2701
  }
2702
+ return null;
2448
2703
  });
2449
2704
  if (WritableStreamCloseQueuedOrInFlight(dest) || dest._state === "closed") {
2450
2705
  const destClosed = new TypeError("the destination writable stream closed before all data could be piped to it");
@@ -2485,6 +2740,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
2485
2740
  }
2486
2741
  function doTheRest() {
2487
2742
  uponPromise(action(), () => finalize(originalIsError, originalError), (newError) => finalize(true, newError));
2743
+ return null;
2488
2744
  }
2489
2745
  }
2490
2746
  function shutdown(isError, error) {
@@ -2509,6 +2765,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
2509
2765
  } else {
2510
2766
  resolve(void 0);
2511
2767
  }
2768
+ return null;
2512
2769
  }
2513
2770
  });
2514
2771
  }
@@ -2581,6 +2838,9 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
2581
2838
  ReadableStreamDefaultControllerCallPullIfNeeded(this);
2582
2839
  }
2583
2840
  }
2841
+ /** @internal */
2842
+ [ReleaseSteps]() {
2843
+ }
2584
2844
  }
2585
2845
  Object.defineProperties(ReadableStreamDefaultController.prototype, {
2586
2846
  close: { enumerable: true },
@@ -2588,8 +2848,11 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
2588
2848
  error: { enumerable: true },
2589
2849
  desiredSize: { enumerable: true }
2590
2850
  });
2591
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
2592
- Object.defineProperty(ReadableStreamDefaultController.prototype, SymbolPolyfill.toStringTag, {
2851
+ setFunctionName(ReadableStreamDefaultController.prototype.close, "close");
2852
+ setFunctionName(ReadableStreamDefaultController.prototype.enqueue, "enqueue");
2853
+ setFunctionName(ReadableStreamDefaultController.prototype.error, "error");
2854
+ if (typeof Symbol.toStringTag === "symbol") {
2855
+ Object.defineProperty(ReadableStreamDefaultController.prototype, Symbol.toStringTag, {
2593
2856
  value: "ReadableStreamDefaultController",
2594
2857
  configurable: true
2595
2858
  });
@@ -2620,8 +2883,10 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
2620
2883
  controller._pullAgain = false;
2621
2884
  ReadableStreamDefaultControllerCallPullIfNeeded(controller);
2622
2885
  }
2886
+ return null;
2623
2887
  }, (e2) => {
2624
2888
  ReadableStreamDefaultControllerError(controller, e2);
2889
+ return null;
2625
2890
  });
2626
2891
  }
2627
2892
  function ReadableStreamDefaultControllerShouldCallPull(controller) {
@@ -2731,23 +2996,31 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
2731
2996
  uponPromise(promiseResolvedWith(startResult), () => {
2732
2997
  controller._started = true;
2733
2998
  ReadableStreamDefaultControllerCallPullIfNeeded(controller);
2999
+ return null;
2734
3000
  }, (r2) => {
2735
3001
  ReadableStreamDefaultControllerError(controller, r2);
3002
+ return null;
2736
3003
  });
2737
3004
  }
2738
3005
  function SetUpReadableStreamDefaultControllerFromUnderlyingSource(stream, underlyingSource, highWaterMark, sizeAlgorithm) {
2739
3006
  const controller = Object.create(ReadableStreamDefaultController.prototype);
2740
- let startAlgorithm = () => void 0;
2741
- let pullAlgorithm = () => promiseResolvedWith(void 0);
2742
- let cancelAlgorithm = () => promiseResolvedWith(void 0);
3007
+ let startAlgorithm;
3008
+ let pullAlgorithm;
3009
+ let cancelAlgorithm;
2743
3010
  if (underlyingSource.start !== void 0) {
2744
3011
  startAlgorithm = () => underlyingSource.start(controller);
3012
+ } else {
3013
+ startAlgorithm = () => void 0;
2745
3014
  }
2746
3015
  if (underlyingSource.pull !== void 0) {
2747
3016
  pullAlgorithm = () => underlyingSource.pull(controller);
3017
+ } else {
3018
+ pullAlgorithm = () => promiseResolvedWith(void 0);
2748
3019
  }
2749
3020
  if (underlyingSource.cancel !== void 0) {
2750
3021
  cancelAlgorithm = (reason) => underlyingSource.cancel(reason);
3022
+ } else {
3023
+ cancelAlgorithm = () => promiseResolvedWith(void 0);
2751
3024
  }
2752
3025
  SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm);
2753
3026
  }
@@ -2782,7 +3055,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
2782
3055
  reading = true;
2783
3056
  const readRequest = {
2784
3057
  _chunkSteps: (chunk) => {
2785
- queueMicrotask(() => {
3058
+ _queueMicrotask(() => {
2786
3059
  readAgain = false;
2787
3060
  const chunk1 = chunk;
2788
3061
  const chunk2 = chunk;
@@ -2847,6 +3120,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
2847
3120
  if (!canceled1 || !canceled2) {
2848
3121
  resolveCancelPromise(void 0);
2849
3122
  }
3123
+ return null;
2850
3124
  });
2851
3125
  return [branch1, branch2];
2852
3126
  }
@@ -2868,13 +3142,14 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
2868
3142
  function forwardReaderError(thisReader) {
2869
3143
  uponRejection(thisReader._closedPromise, (r2) => {
2870
3144
  if (thisReader !== reader) {
2871
- return;
3145
+ return null;
2872
3146
  }
2873
3147
  ReadableByteStreamControllerError(branch1._readableStreamController, r2);
2874
3148
  ReadableByteStreamControllerError(branch2._readableStreamController, r2);
2875
3149
  if (!canceled1 || !canceled2) {
2876
3150
  resolveCancelPromise(void 0);
2877
3151
  }
3152
+ return null;
2878
3153
  });
2879
3154
  }
2880
3155
  function pullWithDefaultReader() {
@@ -2885,7 +3160,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
2885
3160
  }
2886
3161
  const readRequest = {
2887
3162
  _chunkSteps: (chunk) => {
2888
- queueMicrotask(() => {
3163
+ _queueMicrotask(() => {
2889
3164
  readAgainForBranch1 = false;
2890
3165
  readAgainForBranch2 = false;
2891
3166
  const chunk1 = chunk;
@@ -2948,7 +3223,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
2948
3223
  const otherBranch = forBranch2 ? branch1 : branch2;
2949
3224
  const readIntoRequest = {
2950
3225
  _chunkSteps: (chunk) => {
2951
- queueMicrotask(() => {
3226
+ _queueMicrotask(() => {
2952
3227
  readAgainForBranch1 = false;
2953
3228
  readAgainForBranch2 = false;
2954
3229
  const byobCanceled = forBranch2 ? canceled2 : canceled1;
@@ -3004,7 +3279,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
3004
3279
  reading = false;
3005
3280
  }
3006
3281
  };
3007
- ReadableStreamBYOBReaderRead(reader, view, readIntoRequest);
3282
+ ReadableStreamBYOBReaderRead(reader, view, 1, readIntoRequest);
3008
3283
  }
3009
3284
  function pull1Algorithm() {
3010
3285
  if (reading) {
@@ -3062,6 +3337,100 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
3062
3337
  forwardReaderError(reader);
3063
3338
  return [branch1, branch2];
3064
3339
  }
3340
+ function isReadableStreamLike(stream) {
3341
+ return typeIsObject(stream) && typeof stream.getReader !== "undefined";
3342
+ }
3343
+ function ReadableStreamFrom(source) {
3344
+ if (isReadableStreamLike(source)) {
3345
+ return ReadableStreamFromDefaultReader(source.getReader());
3346
+ }
3347
+ return ReadableStreamFromIterable(source);
3348
+ }
3349
+ function ReadableStreamFromIterable(asyncIterable) {
3350
+ let stream;
3351
+ const iteratorRecord = GetIterator(asyncIterable, "async");
3352
+ const startAlgorithm = noop;
3353
+ function pullAlgorithm() {
3354
+ let nextResult;
3355
+ try {
3356
+ nextResult = IteratorNext(iteratorRecord);
3357
+ } catch (e2) {
3358
+ return promiseRejectedWith(e2);
3359
+ }
3360
+ const nextPromise = promiseResolvedWith(nextResult);
3361
+ return transformPromiseWith(nextPromise, (iterResult) => {
3362
+ if (!typeIsObject(iterResult)) {
3363
+ throw new TypeError("The promise returned by the iterator.next() method must fulfill with an object");
3364
+ }
3365
+ const done = IteratorComplete(iterResult);
3366
+ if (done) {
3367
+ ReadableStreamDefaultControllerClose(stream._readableStreamController);
3368
+ } else {
3369
+ const value = IteratorValue(iterResult);
3370
+ ReadableStreamDefaultControllerEnqueue(stream._readableStreamController, value);
3371
+ }
3372
+ });
3373
+ }
3374
+ function cancelAlgorithm(reason) {
3375
+ const iterator = iteratorRecord.iterator;
3376
+ let returnMethod;
3377
+ try {
3378
+ returnMethod = GetMethod(iterator, "return");
3379
+ } catch (e2) {
3380
+ return promiseRejectedWith(e2);
3381
+ }
3382
+ if (returnMethod === void 0) {
3383
+ return promiseResolvedWith(void 0);
3384
+ }
3385
+ let returnResult;
3386
+ try {
3387
+ returnResult = reflectCall(returnMethod, iterator, [reason]);
3388
+ } catch (e2) {
3389
+ return promiseRejectedWith(e2);
3390
+ }
3391
+ const returnPromise = promiseResolvedWith(returnResult);
3392
+ return transformPromiseWith(returnPromise, (iterResult) => {
3393
+ if (!typeIsObject(iterResult)) {
3394
+ throw new TypeError("The promise returned by the iterator.return() method must fulfill with an object");
3395
+ }
3396
+ return void 0;
3397
+ });
3398
+ }
3399
+ stream = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, 0);
3400
+ return stream;
3401
+ }
3402
+ function ReadableStreamFromDefaultReader(reader) {
3403
+ let stream;
3404
+ const startAlgorithm = noop;
3405
+ function pullAlgorithm() {
3406
+ let readPromise;
3407
+ try {
3408
+ readPromise = reader.read();
3409
+ } catch (e2) {
3410
+ return promiseRejectedWith(e2);
3411
+ }
3412
+ return transformPromiseWith(readPromise, (readResult) => {
3413
+ if (!typeIsObject(readResult)) {
3414
+ throw new TypeError("The promise returned by the reader.read() method must fulfill with an object");
3415
+ }
3416
+ if (readResult.done) {
3417
+ ReadableStreamDefaultControllerClose(stream._readableStreamController);
3418
+ } else {
3419
+ const value = readResult.value;
3420
+ ReadableStreamDefaultControllerEnqueue(stream._readableStreamController, value);
3421
+ }
3422
+ });
3423
+ }
3424
+ function cancelAlgorithm(reason) {
3425
+ try {
3426
+ return promiseResolvedWith(reader.cancel(reason));
3427
+ } catch (e2) {
3428
+ return promiseRejectedWith(e2);
3429
+ }
3430
+ }
3431
+ stream = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, 0);
3432
+ return stream;
3433
+ }
3065
3434
  function convertUnderlyingDefaultOrByteSource(source, context) {
3066
3435
  assertDictionary(source, context);
3067
3436
  const original = source;
@@ -3097,20 +3466,6 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
3097
3466
  }
3098
3467
  return type;
3099
3468
  }
3100
- function convertReaderOptions(options, context) {
3101
- assertDictionary(options, context);
3102
- const mode = options === null || options === void 0 ? void 0 : options.mode;
3103
- return {
3104
- mode: mode === void 0 ? void 0 : convertReadableStreamReaderMode(mode, `${context} has member 'mode' that`)
3105
- };
3106
- }
3107
- function convertReadableStreamReaderMode(mode, context) {
3108
- mode = `${mode}`;
3109
- if (mode !== "byob") {
3110
- throw new TypeError(`${context} '${mode}' is not a valid enumeration value for ReadableStreamReaderMode`);
3111
- }
3112
- return mode;
3113
- }
3114
3469
  function convertIteratorOptions(options, context) {
3115
3470
  assertDictionary(options, context);
3116
3471
  const preventCancel = options === null || options === void 0 ? void 0 : options.preventCancel;
@@ -3269,7 +3624,22 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
3269
3624
  const options = convertIteratorOptions(rawOptions, "First parameter");
3270
3625
  return AcquireReadableStreamAsyncIterator(this, options.preventCancel);
3271
3626
  }
3627
+ [SymbolAsyncIterator](options) {
3628
+ return this.values(options);
3629
+ }
3630
+ /**
3631
+ * Creates a new ReadableStream wrapping the provided iterable or async iterable.
3632
+ *
3633
+ * This can be used to adapt various kinds of objects into a readable stream,
3634
+ * such as an array, an async generator, or a Node.js readable stream.
3635
+ */
3636
+ static from(asyncIterable) {
3637
+ return ReadableStreamFrom(asyncIterable);
3638
+ }
3272
3639
  }
3640
+ Object.defineProperties(ReadableStream2, {
3641
+ from: { enumerable: true }
3642
+ });
3273
3643
  Object.defineProperties(ReadableStream2.prototype, {
3274
3644
  cancel: { enumerable: true },
3275
3645
  getReader: { enumerable: true },
@@ -3279,19 +3649,24 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
3279
3649
  values: { enumerable: true },
3280
3650
  locked: { enumerable: true }
3281
3651
  });
3282
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
3283
- Object.defineProperty(ReadableStream2.prototype, SymbolPolyfill.toStringTag, {
3652
+ setFunctionName(ReadableStream2.from, "from");
3653
+ setFunctionName(ReadableStream2.prototype.cancel, "cancel");
3654
+ setFunctionName(ReadableStream2.prototype.getReader, "getReader");
3655
+ setFunctionName(ReadableStream2.prototype.pipeThrough, "pipeThrough");
3656
+ setFunctionName(ReadableStream2.prototype.pipeTo, "pipeTo");
3657
+ setFunctionName(ReadableStream2.prototype.tee, "tee");
3658
+ setFunctionName(ReadableStream2.prototype.values, "values");
3659
+ if (typeof Symbol.toStringTag === "symbol") {
3660
+ Object.defineProperty(ReadableStream2.prototype, Symbol.toStringTag, {
3284
3661
  value: "ReadableStream",
3285
3662
  configurable: true
3286
3663
  });
3287
3664
  }
3288
- if (typeof SymbolPolyfill.asyncIterator === "symbol") {
3289
- Object.defineProperty(ReadableStream2.prototype, SymbolPolyfill.asyncIterator, {
3290
- value: ReadableStream2.prototype.values,
3291
- writable: true,
3292
- configurable: true
3293
- });
3294
- }
3665
+ Object.defineProperty(ReadableStream2.prototype, SymbolAsyncIterator, {
3666
+ value: ReadableStream2.prototype.values,
3667
+ writable: true,
3668
+ configurable: true
3669
+ });
3295
3670
  function CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark = 1, sizeAlgorithm = () => 1) {
3296
3671
  const stream = Object.create(ReadableStream2.prototype);
3297
3672
  InitializeReadableStream(stream);
@@ -3338,10 +3713,11 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
3338
3713
  ReadableStreamClose(stream);
3339
3714
  const reader = stream._reader;
3340
3715
  if (reader !== void 0 && IsReadableStreamBYOBReader(reader)) {
3341
- reader._readIntoRequests.forEach((readIntoRequest) => {
3716
+ const readIntoRequests = reader._readIntoRequests;
3717
+ reader._readIntoRequests = new SimpleQueue();
3718
+ readIntoRequests.forEach((readIntoRequest) => {
3342
3719
  readIntoRequest._closeSteps(void 0);
3343
3720
  });
3344
- reader._readIntoRequests = new SimpleQueue();
3345
3721
  }
3346
3722
  const sourceCancelPromise = stream._readableStreamController[CancelSteps](reason);
3347
3723
  return transformPromiseWith(sourceCancelPromise, noop);
@@ -3354,10 +3730,11 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
3354
3730
  }
3355
3731
  defaultReaderClosedPromiseResolve(reader);
3356
3732
  if (IsReadableStreamDefaultReader(reader)) {
3357
- reader._readRequests.forEach((readRequest) => {
3733
+ const readRequests = reader._readRequests;
3734
+ reader._readRequests = new SimpleQueue();
3735
+ readRequests.forEach((readRequest) => {
3358
3736
  readRequest._closeSteps();
3359
3737
  });
3360
- reader._readRequests = new SimpleQueue();
3361
3738
  }
3362
3739
  }
3363
3740
  function ReadableStreamError(stream, e2) {
@@ -3369,15 +3746,9 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
3369
3746
  }
3370
3747
  defaultReaderClosedPromiseReject(reader, e2);
3371
3748
  if (IsReadableStreamDefaultReader(reader)) {
3372
- reader._readRequests.forEach((readRequest) => {
3373
- readRequest._errorSteps(e2);
3374
- });
3375
- reader._readRequests = new SimpleQueue();
3749
+ ReadableStreamDefaultReaderErrorReadRequests(reader, e2);
3376
3750
  } else {
3377
- reader._readIntoRequests.forEach((readIntoRequest) => {
3378
- readIntoRequest._errorSteps(e2);
3379
- });
3380
- reader._readIntoRequests = new SimpleQueue();
3751
+ ReadableStreamBYOBReaderErrorReadIntoRequests(reader, e2);
3381
3752
  }
3382
3753
  }
3383
3754
  function streamBrandCheckException$1(name) {
@@ -3394,13 +3765,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
3394
3765
  const byteLengthSizeFunction = (chunk) => {
3395
3766
  return chunk.byteLength;
3396
3767
  };
3397
- try {
3398
- Object.defineProperty(byteLengthSizeFunction, "name", {
3399
- value: "size",
3400
- configurable: true
3401
- });
3402
- } catch (_a) {
3403
- }
3768
+ setFunctionName(byteLengthSizeFunction, "size");
3404
3769
  class ByteLengthQueuingStrategy {
3405
3770
  constructor(options) {
3406
3771
  assertRequiredArgument(options, 1, "ByteLengthQueuingStrategy");
@@ -3430,8 +3795,8 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
3430
3795
  highWaterMark: { enumerable: true },
3431
3796
  size: { enumerable: true }
3432
3797
  });
3433
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
3434
- Object.defineProperty(ByteLengthQueuingStrategy.prototype, SymbolPolyfill.toStringTag, {
3798
+ if (typeof Symbol.toStringTag === "symbol") {
3799
+ Object.defineProperty(ByteLengthQueuingStrategy.prototype, Symbol.toStringTag, {
3435
3800
  value: "ByteLengthQueuingStrategy",
3436
3801
  configurable: true
3437
3802
  });
@@ -3451,13 +3816,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
3451
3816
  const countSizeFunction = () => {
3452
3817
  return 1;
3453
3818
  };
3454
- try {
3455
- Object.defineProperty(countSizeFunction, "name", {
3456
- value: "size",
3457
- configurable: true
3458
- });
3459
- } catch (_a) {
3460
- }
3819
+ setFunctionName(countSizeFunction, "size");
3461
3820
  class CountQueuingStrategy {
3462
3821
  constructor(options) {
3463
3822
  assertRequiredArgument(options, 1, "CountQueuingStrategy");
@@ -3488,8 +3847,8 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
3488
3847
  highWaterMark: { enumerable: true },
3489
3848
  size: { enumerable: true }
3490
3849
  });
3491
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
3492
- Object.defineProperty(CountQueuingStrategy.prototype, SymbolPolyfill.toStringTag, {
3850
+ if (typeof Symbol.toStringTag === "symbol") {
3851
+ Object.defineProperty(CountQueuingStrategy.prototype, Symbol.toStringTag, {
3493
3852
  value: "CountQueuingStrategy",
3494
3853
  configurable: true
3495
3854
  });
@@ -3508,12 +3867,14 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
3508
3867
  }
3509
3868
  function convertTransformer(original, context) {
3510
3869
  assertDictionary(original, context);
3870
+ const cancel = original === null || original === void 0 ? void 0 : original.cancel;
3511
3871
  const flush = original === null || original === void 0 ? void 0 : original.flush;
3512
3872
  const readableType = original === null || original === void 0 ? void 0 : original.readableType;
3513
3873
  const start = original === null || original === void 0 ? void 0 : original.start;
3514
3874
  const transform = original === null || original === void 0 ? void 0 : original.transform;
3515
3875
  const writableType = original === null || original === void 0 ? void 0 : original.writableType;
3516
3876
  return {
3877
+ cancel: cancel === void 0 ? void 0 : convertTransformerCancelCallback(cancel, original, `${context} has member 'cancel' that`),
3517
3878
  flush: flush === void 0 ? void 0 : convertTransformerFlushCallback(flush, original, `${context} has member 'flush' that`),
3518
3879
  readableType,
3519
3880
  start: start === void 0 ? void 0 : convertTransformerStartCallback(start, original, `${context} has member 'start' that`),
@@ -3533,6 +3894,10 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
3533
3894
  assertFunction(fn, context);
3534
3895
  return (chunk, controller) => promiseCall(fn, original, [chunk, controller]);
3535
3896
  }
3897
+ function convertTransformerCancelCallback(fn, original, context) {
3898
+ assertFunction(fn, context);
3899
+ return (reason) => promiseCall(fn, original, [reason]);
3900
+ }
3536
3901
  class TransformStream {
3537
3902
  constructor(rawTransformer = {}, rawWritableStrategy = {}, rawReadableStrategy = {}) {
3538
3903
  if (rawTransformer === void 0) {
@@ -3586,8 +3951,8 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
3586
3951
  readable: { enumerable: true },
3587
3952
  writable: { enumerable: true }
3588
3953
  });
3589
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
3590
- Object.defineProperty(TransformStream.prototype, SymbolPolyfill.toStringTag, {
3954
+ if (typeof Symbol.toStringTag === "symbol") {
3955
+ Object.defineProperty(TransformStream.prototype, Symbol.toStringTag, {
3591
3956
  value: "TransformStream",
3592
3957
  configurable: true
3593
3958
  });
@@ -3610,8 +3975,7 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
3610
3975
  return TransformStreamDefaultSourcePullAlgorithm(stream);
3611
3976
  }
3612
3977
  function cancelAlgorithm(reason) {
3613
- TransformStreamErrorWritableAndUnblockWrite(stream, reason);
3614
- return promiseResolvedWith(void 0);
3978
+ return TransformStreamDefaultSourceCancelAlgorithm(stream, reason);
3615
3979
  }
3616
3980
  stream._readable = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
3617
3981
  stream._backpressure = void 0;
@@ -3636,6 +4000,9 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
3636
4000
  function TransformStreamErrorWritableAndUnblockWrite(stream, e2) {
3637
4001
  TransformStreamDefaultControllerClearAlgorithms(stream._transformStreamController);
3638
4002
  WritableStreamDefaultControllerErrorIfNeeded(stream._writable._writableStreamController, e2);
4003
+ TransformStreamUnblockWrite(stream);
4004
+ }
4005
+ function TransformStreamUnblockWrite(stream) {
3639
4006
  if (stream._backpressure) {
3640
4007
  TransformStreamSetBackpressure(stream, false);
3641
4008
  }
@@ -3696,8 +4063,11 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
3696
4063
  terminate: { enumerable: true },
3697
4064
  desiredSize: { enumerable: true }
3698
4065
  });
3699
- if (typeof SymbolPolyfill.toStringTag === "symbol") {
3700
- Object.defineProperty(TransformStreamDefaultController.prototype, SymbolPolyfill.toStringTag, {
4066
+ setFunctionName(TransformStreamDefaultController.prototype.enqueue, "enqueue");
4067
+ setFunctionName(TransformStreamDefaultController.prototype.error, "error");
4068
+ setFunctionName(TransformStreamDefaultController.prototype.terminate, "terminate");
4069
+ if (typeof Symbol.toStringTag === "symbol") {
4070
+ Object.defineProperty(TransformStreamDefaultController.prototype, Symbol.toStringTag, {
3701
4071
  value: "TransformStreamDefaultController",
3702
4072
  configurable: true
3703
4073
  });
@@ -3711,34 +4081,49 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
3711
4081
  }
3712
4082
  return x2 instanceof TransformStreamDefaultController;
3713
4083
  }
3714
- function SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm) {
4084
+ function SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm, cancelAlgorithm) {
3715
4085
  controller._controlledTransformStream = stream;
3716
4086
  stream._transformStreamController = controller;
3717
4087
  controller._transformAlgorithm = transformAlgorithm;
3718
4088
  controller._flushAlgorithm = flushAlgorithm;
4089
+ controller._cancelAlgorithm = cancelAlgorithm;
4090
+ controller._finishPromise = void 0;
4091
+ controller._finishPromise_resolve = void 0;
4092
+ controller._finishPromise_reject = void 0;
3719
4093
  }
3720
4094
  function SetUpTransformStreamDefaultControllerFromTransformer(stream, transformer) {
3721
4095
  const controller = Object.create(TransformStreamDefaultController.prototype);
3722
- let transformAlgorithm = (chunk) => {
3723
- try {
3724
- TransformStreamDefaultControllerEnqueue(controller, chunk);
3725
- return promiseResolvedWith(void 0);
3726
- } catch (transformResultE) {
3727
- return promiseRejectedWith(transformResultE);
3728
- }
3729
- };
3730
- let flushAlgorithm = () => promiseResolvedWith(void 0);
4096
+ let transformAlgorithm;
4097
+ let flushAlgorithm;
4098
+ let cancelAlgorithm;
3731
4099
  if (transformer.transform !== void 0) {
3732
4100
  transformAlgorithm = (chunk) => transformer.transform(chunk, controller);
4101
+ } else {
4102
+ transformAlgorithm = (chunk) => {
4103
+ try {
4104
+ TransformStreamDefaultControllerEnqueue(controller, chunk);
4105
+ return promiseResolvedWith(void 0);
4106
+ } catch (transformResultE) {
4107
+ return promiseRejectedWith(transformResultE);
4108
+ }
4109
+ };
3733
4110
  }
3734
4111
  if (transformer.flush !== void 0) {
3735
4112
  flushAlgorithm = () => transformer.flush(controller);
4113
+ } else {
4114
+ flushAlgorithm = () => promiseResolvedWith(void 0);
4115
+ }
4116
+ if (transformer.cancel !== void 0) {
4117
+ cancelAlgorithm = (reason) => transformer.cancel(reason);
4118
+ } else {
4119
+ cancelAlgorithm = () => promiseResolvedWith(void 0);
3736
4120
  }
3737
- SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm);
4121
+ SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm, cancelAlgorithm);
3738
4122
  }
3739
4123
  function TransformStreamDefaultControllerClearAlgorithms(controller) {
3740
4124
  controller._transformAlgorithm = void 0;
3741
4125
  controller._flushAlgorithm = void 0;
4126
+ controller._cancelAlgorithm = void 0;
3742
4127
  }
3743
4128
  function TransformStreamDefaultControllerEnqueue(controller, chunk) {
3744
4129
  const stream = controller._controlledTransformStream;
@@ -3790,31 +4175,112 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
3790
4175
  return TransformStreamDefaultControllerPerformTransform(controller, chunk);
3791
4176
  }
3792
4177
  function TransformStreamDefaultSinkAbortAlgorithm(stream, reason) {
3793
- TransformStreamError(stream, reason);
3794
- return promiseResolvedWith(void 0);
4178
+ const controller = stream._transformStreamController;
4179
+ if (controller._finishPromise !== void 0) {
4180
+ return controller._finishPromise;
4181
+ }
4182
+ const readable = stream._readable;
4183
+ controller._finishPromise = newPromise((resolve, reject) => {
4184
+ controller._finishPromise_resolve = resolve;
4185
+ controller._finishPromise_reject = reject;
4186
+ });
4187
+ const cancelPromise = controller._cancelAlgorithm(reason);
4188
+ TransformStreamDefaultControllerClearAlgorithms(controller);
4189
+ uponPromise(cancelPromise, () => {
4190
+ if (readable._state === "errored") {
4191
+ defaultControllerFinishPromiseReject(controller, readable._storedError);
4192
+ } else {
4193
+ ReadableStreamDefaultControllerError(readable._readableStreamController, reason);
4194
+ defaultControllerFinishPromiseResolve(controller);
4195
+ }
4196
+ return null;
4197
+ }, (r2) => {
4198
+ ReadableStreamDefaultControllerError(readable._readableStreamController, r2);
4199
+ defaultControllerFinishPromiseReject(controller, r2);
4200
+ return null;
4201
+ });
4202
+ return controller._finishPromise;
3795
4203
  }
3796
4204
  function TransformStreamDefaultSinkCloseAlgorithm(stream) {
3797
- const readable = stream._readable;
3798
4205
  const controller = stream._transformStreamController;
4206
+ if (controller._finishPromise !== void 0) {
4207
+ return controller._finishPromise;
4208
+ }
4209
+ const readable = stream._readable;
4210
+ controller._finishPromise = newPromise((resolve, reject) => {
4211
+ controller._finishPromise_resolve = resolve;
4212
+ controller._finishPromise_reject = reject;
4213
+ });
3799
4214
  const flushPromise = controller._flushAlgorithm();
3800
4215
  TransformStreamDefaultControllerClearAlgorithms(controller);
3801
- return transformPromiseWith(flushPromise, () => {
4216
+ uponPromise(flushPromise, () => {
3802
4217
  if (readable._state === "errored") {
3803
- throw readable._storedError;
4218
+ defaultControllerFinishPromiseReject(controller, readable._storedError);
4219
+ } else {
4220
+ ReadableStreamDefaultControllerClose(readable._readableStreamController);
4221
+ defaultControllerFinishPromiseResolve(controller);
3804
4222
  }
3805
- ReadableStreamDefaultControllerClose(readable._readableStreamController);
4223
+ return null;
3806
4224
  }, (r2) => {
3807
- TransformStreamError(stream, r2);
3808
- throw readable._storedError;
4225
+ ReadableStreamDefaultControllerError(readable._readableStreamController, r2);
4226
+ defaultControllerFinishPromiseReject(controller, r2);
4227
+ return null;
3809
4228
  });
4229
+ return controller._finishPromise;
3810
4230
  }
3811
4231
  function TransformStreamDefaultSourcePullAlgorithm(stream) {
3812
4232
  TransformStreamSetBackpressure(stream, false);
3813
4233
  return stream._backpressureChangePromise;
3814
4234
  }
4235
+ function TransformStreamDefaultSourceCancelAlgorithm(stream, reason) {
4236
+ const controller = stream._transformStreamController;
4237
+ if (controller._finishPromise !== void 0) {
4238
+ return controller._finishPromise;
4239
+ }
4240
+ const writable = stream._writable;
4241
+ controller._finishPromise = newPromise((resolve, reject) => {
4242
+ controller._finishPromise_resolve = resolve;
4243
+ controller._finishPromise_reject = reject;
4244
+ });
4245
+ const cancelPromise = controller._cancelAlgorithm(reason);
4246
+ TransformStreamDefaultControllerClearAlgorithms(controller);
4247
+ uponPromise(cancelPromise, () => {
4248
+ if (writable._state === "errored") {
4249
+ defaultControllerFinishPromiseReject(controller, writable._storedError);
4250
+ } else {
4251
+ WritableStreamDefaultControllerErrorIfNeeded(writable._writableStreamController, reason);
4252
+ TransformStreamUnblockWrite(stream);
4253
+ defaultControllerFinishPromiseResolve(controller);
4254
+ }
4255
+ return null;
4256
+ }, (r2) => {
4257
+ WritableStreamDefaultControllerErrorIfNeeded(writable._writableStreamController, r2);
4258
+ TransformStreamUnblockWrite(stream);
4259
+ defaultControllerFinishPromiseReject(controller, r2);
4260
+ return null;
4261
+ });
4262
+ return controller._finishPromise;
4263
+ }
3815
4264
  function defaultControllerBrandCheckException(name) {
3816
4265
  return new TypeError(`TransformStreamDefaultController.prototype.${name} can only be used on a TransformStreamDefaultController`);
3817
4266
  }
4267
+ function defaultControllerFinishPromiseResolve(controller) {
4268
+ if (controller._finishPromise_resolve === void 0) {
4269
+ return;
4270
+ }
4271
+ controller._finishPromise_resolve();
4272
+ controller._finishPromise_resolve = void 0;
4273
+ controller._finishPromise_reject = void 0;
4274
+ }
4275
+ function defaultControllerFinishPromiseReject(controller, reason) {
4276
+ if (controller._finishPromise_reject === void 0) {
4277
+ return;
4278
+ }
4279
+ setPromiseIsHandledToTrue(controller._finishPromise);
4280
+ controller._finishPromise_reject(reason);
4281
+ controller._finishPromise_resolve = void 0;
4282
+ controller._finishPromise_reject = void 0;
4283
+ }
3818
4284
  function streamBrandCheckException(name) {
3819
4285
  return new TypeError(`TransformStream.prototype.${name} can only be used on a TransformStream`);
3820
4286
  }
@@ -3831,7 +4297,6 @@ var require_ponyfill_es2018 = (0, import_chunk_4VNS5WPM.__commonJS)({
3831
4297
  exports2.WritableStream = WritableStream;
3832
4298
  exports2.WritableStreamDefaultController = WritableStreamDefaultController;
3833
4299
  exports2.WritableStreamDefaultWriter = WritableStreamDefaultWriter;
3834
- Object.defineProperty(exports2, "__esModule", { value: true });
3835
4300
  });
3836
4301
  }
3837
4302
  });
@@ -4219,6 +4684,15 @@ var import_node_domexception = (0, import_chunk_4VNS5WPM.__toESM)(require_node_d
4219
4684
  var { stat } = import_node_fs.promises;
4220
4685
  /*! Bundled license information:
4221
4686
 
4687
+ web-streams-polyfill/dist/ponyfill.es2018.js:
4688
+ (**
4689
+ * @license
4690
+ * web-streams-polyfill v3.3.3
4691
+ * Copyright 2024 Mattias Buelens, Diwank Singh Tomer and other contributors.
4692
+ * This code is released under the MIT license.
4693
+ * SPDX-License-Identifier: MIT
4694
+ *)
4695
+
4222
4696
  node-domexception/index.js:
4223
4697
  (*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> *)
4224
4698