mediabunny 1.17.2 → 1.17.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3207,6 +3207,7 @@ var Mediabunny = (() => {
3207
3207
  skip(byteCount) {
3208
3208
  this.bufferPos += byteCount;
3209
3209
  }
3210
+ /** Creates a new subslice of this slice whose byte range must be contained within this slice. */
3210
3211
  slice(filePos, length = this.end - filePos) {
3211
3212
  if (filePos < this.start || filePos + length > this.end) {
3212
3213
  throw new RangeError("Slicing outside of original slice.");
@@ -22164,7 +22165,8 @@ ${cue.notes ?? ""}`;
22164
22165
  let currentPos = 4;
22165
22166
  return this.metadataPromise ??= (async () => {
22166
22167
  while (this.reader.fileSize === null || currentPos < this.reader.fileSize) {
22167
- const sizeSlice = await this.reader.requestSlice(currentPos, 4);
22168
+ let sizeSlice = this.reader.requestSlice(currentPos, 4);
22169
+ if (sizeSlice instanceof Promise) sizeSlice = await sizeSlice;
22168
22170
  currentPos += 4;
22169
22171
  if (sizeSlice === null) {
22170
22172
  throw new Error(
@@ -22178,10 +22180,11 @@ ${cue.notes ?? ""}`;
22178
22180
  const metaBlockType = byte & 127;
22179
22181
  switch (metaBlockType) {
22180
22182
  case 0 /* STREAMINFO */: {
22181
- const streamInfoBlock = await this.reader.requestSlice(
22183
+ let streamInfoBlock = this.reader.requestSlice(
22182
22184
  currentPos,
22183
22185
  size
22184
22186
  );
22187
+ if (streamInfoBlock instanceof Promise) streamInfoBlock = await streamInfoBlock;
22185
22188
  assert(streamInfoBlock);
22186
22189
  if (streamInfoBlock === null) {
22187
22190
  throw new Error(
@@ -22217,25 +22220,24 @@ ${cue.notes ?? ""}`;
22217
22220
  break;
22218
22221
  }
22219
22222
  case 4 /* VORBIS_COMMENT */: {
22220
- const vorbisCommentBlock = await this.reader.requestSlice(
22223
+ let vorbisCommentBlock = this.reader.requestSlice(
22221
22224
  currentPos,
22222
22225
  size
22223
22226
  );
22227
+ if (vorbisCommentBlock instanceof Promise) vorbisCommentBlock = await vorbisCommentBlock;
22224
22228
  assert(vorbisCommentBlock);
22225
22229
  readVorbisComments(
22226
- vorbisCommentBlock.bytes.subarray(
22227
- vorbisCommentBlock.start,
22228
- vorbisCommentBlock.end
22229
- ),
22230
+ readBytes(vorbisCommentBlock, size),
22230
22231
  this.metadataTags
22231
22232
  );
22232
22233
  break;
22233
22234
  }
22234
22235
  case 6 /* PICTURE */: {
22235
- const pictureBlock = await this.reader.requestSlice(
22236
+ let pictureBlock = this.reader.requestSlice(
22236
22237
  currentPos,
22237
22238
  size
22238
22239
  );
22240
+ if (pictureBlock instanceof Promise) pictureBlock = await pictureBlock;
22239
22241
  assert(pictureBlock);
22240
22242
  const pictureType = readU32Be(pictureBlock);
22241
22243
  const mediaTypeLength = readU32Be(pictureBlock);
@@ -22538,10 +22540,11 @@ ${cue.notes ?? ""}`;
22538
22540
  if (options.metadataOnly) {
22539
22541
  data = PLACEHOLDER_DATA;
22540
22542
  } else {
22541
- const slice = await this.demuxer.reader.requestSlice(
22543
+ let slice = this.demuxer.reader.requestSlice(
22542
22544
  rawSample.byteOffset,
22543
22545
  rawSample.byteSize
22544
22546
  );
22547
+ if (slice instanceof Promise) slice = await slice;
22545
22548
  if (!slice) {
22546
22549
  return null;
22547
22550
  }