mediabunny 1.56.2 → 1.56.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundles/mediabunny.cjs +168 -17
- package/dist/bundles/mediabunny.min.cjs +9 -9
- package/dist/bundles/mediabunny.min.mjs +9 -9
- package/dist/bundles/mediabunny.mjs +168 -17
- package/dist/bundles/mediabunny.node.cjs +168 -17
- package/dist/modules/src/id3.d.ts.map +1 -1
- package/dist/modules/src/id3.js +1 -1
- package/dist/modules/src/isobmff/isobmff-reader.js +1 -1
- package/dist/modules/src/misc.d.ts +26 -2
- package/dist/modules/src/misc.d.ts.map +1 -1
- package/dist/modules/src/misc.js +160 -0
- package/dist/modules/src/source.d.ts.map +1 -1
- package/dist/modules/src/source.js +34 -17
- package/dist/modules/src/tsconfig.tsbuildinfo +1 -1
- package/dist/modules/src/wave/riff-writer.d.ts.map +1 -1
- package/dist/modules/src/wave/riff-writer.js +2 -1
- package/package.json +1 -1
- package/src/id3.ts +1 -0
- package/src/isobmff/isobmff-reader.ts +1 -1
- package/src/misc.ts +162 -0
- package/src/source.ts +43 -22
- package/src/wave/riff-writer.ts +2 -1
|
@@ -312,6 +312,139 @@ var Mediabunny = (() => {
|
|
|
312
312
|
return new DataView(source);
|
|
313
313
|
}
|
|
314
314
|
};
|
|
315
|
+
var TextEncoder = typeof globalThis.TextEncoder !== "undefined" ? globalThis.TextEncoder : class TextEncoder2 {
|
|
316
|
+
constructor() {
|
|
317
|
+
this.encoding = "utf-8";
|
|
318
|
+
}
|
|
319
|
+
encode(input = "") {
|
|
320
|
+
const bytes2 = new Uint8Array(3 * input.length);
|
|
321
|
+
let n = 0;
|
|
322
|
+
for (let i = 0; i < input.length; i++) {
|
|
323
|
+
let c = input.charCodeAt(i);
|
|
324
|
+
if (c < 128) {
|
|
325
|
+
bytes2[n++] = c;
|
|
326
|
+
} else if (c < 2048) {
|
|
327
|
+
bytes2[n++] = 192 | c >> 6;
|
|
328
|
+
bytes2[n++] = 128 | c & 63;
|
|
329
|
+
} else if (c < 55296 || c > 57343) {
|
|
330
|
+
bytes2[n++] = 224 | c >> 12;
|
|
331
|
+
bytes2[n++] = 128 | c >> 6 & 63;
|
|
332
|
+
bytes2[n++] = 128 | c & 63;
|
|
333
|
+
} else {
|
|
334
|
+
const next = i + 1 < input.length ? input.charCodeAt(i + 1) : 0;
|
|
335
|
+
if (c < 56320 && next >= 56320 && next <= 57343) {
|
|
336
|
+
c = 65536 + (c - 55296 << 10) + (next - 56320);
|
|
337
|
+
i++;
|
|
338
|
+
bytes2[n++] = 240 | c >> 18;
|
|
339
|
+
bytes2[n++] = 128 | c >> 12 & 63;
|
|
340
|
+
bytes2[n++] = 128 | c >> 6 & 63;
|
|
341
|
+
bytes2[n++] = 128 | c & 63;
|
|
342
|
+
} else {
|
|
343
|
+
bytes2[n++] = 239;
|
|
344
|
+
bytes2[n++] = 191;
|
|
345
|
+
bytes2[n++] = 189;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return bytes2.slice(0, n);
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
var TextDecoder = typeof globalThis.TextDecoder !== "undefined" ? globalThis.TextDecoder : class TextDecoder2 {
|
|
353
|
+
constructor(label = "utf-8") {
|
|
354
|
+
const normalized = label.trim().toLowerCase();
|
|
355
|
+
if (normalized === "utf-8" || normalized === "utf8" || normalized === "unicode-1-1-utf-8") {
|
|
356
|
+
this.encoding = "utf-8";
|
|
357
|
+
} else if (normalized === "utf-16le" || normalized === "utf-16") {
|
|
358
|
+
this.encoding = "utf-16le";
|
|
359
|
+
} else if (normalized === "utf-16be") {
|
|
360
|
+
this.encoding = "utf-16be";
|
|
361
|
+
} else {
|
|
362
|
+
throw new RangeError(`The encoding label provided ('${label}') is invalid.`);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
decode(input) {
|
|
366
|
+
const bytes2 = input ? toUint8Array(input) : new Uint8Array(0);
|
|
367
|
+
const units = [];
|
|
368
|
+
if (this.encoding === "utf-8") {
|
|
369
|
+
let i = bytes2.length >= 3 && bytes2[0] === 239 && bytes2[1] === 187 && bytes2[2] === 191 ? 3 : 0;
|
|
370
|
+
while (i < bytes2.length) {
|
|
371
|
+
const lead = bytes2[i];
|
|
372
|
+
if (lead < 128) {
|
|
373
|
+
units.push(lead);
|
|
374
|
+
i++;
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
let continuationCount;
|
|
378
|
+
let codePoint;
|
|
379
|
+
if (lead >= 194 && lead < 224) {
|
|
380
|
+
continuationCount = 1;
|
|
381
|
+
codePoint = lead & 31;
|
|
382
|
+
} else if (lead >= 224 && lead < 240) {
|
|
383
|
+
continuationCount = 2;
|
|
384
|
+
codePoint = lead & 15;
|
|
385
|
+
} else if (lead >= 240 && lead < 245) {
|
|
386
|
+
continuationCount = 3;
|
|
387
|
+
codePoint = lead & 7;
|
|
388
|
+
} else {
|
|
389
|
+
units.push(65533);
|
|
390
|
+
i++;
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
let lowerBound = lead === 224 ? 160 : lead === 240 ? 144 : 128;
|
|
394
|
+
let upperBound = lead === 237 ? 159 : lead === 244 ? 143 : 191;
|
|
395
|
+
let j = 1;
|
|
396
|
+
for (; j <= continuationCount; j++) {
|
|
397
|
+
const byte = i + j < bytes2.length ? bytes2[i + j] : 0;
|
|
398
|
+
if (byte < lowerBound || byte > upperBound) {
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
codePoint = codePoint << 6 | byte & 63;
|
|
402
|
+
lowerBound = 128;
|
|
403
|
+
upperBound = 191;
|
|
404
|
+
}
|
|
405
|
+
i += j;
|
|
406
|
+
if (j <= continuationCount) {
|
|
407
|
+
units.push(65533);
|
|
408
|
+
} else if (codePoint >= 65536) {
|
|
409
|
+
codePoint -= 65536;
|
|
410
|
+
units.push(55296 | codePoint >> 10, 56320 | codePoint & 1023);
|
|
411
|
+
} else {
|
|
412
|
+
units.push(codePoint);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
} else {
|
|
416
|
+
const littleEndian = this.encoding === "utf-16le";
|
|
417
|
+
const bomLow = littleEndian ? 255 : 254;
|
|
418
|
+
const bomHigh = littleEndian ? 254 : 255;
|
|
419
|
+
let i = bytes2.length >= 2 && bytes2[0] === bomLow && bytes2[1] === bomHigh ? 2 : 0;
|
|
420
|
+
while (i + 1 < bytes2.length) {
|
|
421
|
+
const unit = littleEndian ? bytes2[i] | bytes2[i + 1] << 8 : bytes2[i] << 8 | bytes2[i + 1];
|
|
422
|
+
i += 2;
|
|
423
|
+
if (unit >= 55296 && unit <= 56319) {
|
|
424
|
+
const next = i + 1 < bytes2.length ? littleEndian ? bytes2[i] | bytes2[i + 1] << 8 : bytes2[i] << 8 | bytes2[i + 1] : -1;
|
|
425
|
+
if (next >= 56320 && next <= 57343) {
|
|
426
|
+
units.push(unit, next);
|
|
427
|
+
i += 2;
|
|
428
|
+
} else {
|
|
429
|
+
units.push(65533);
|
|
430
|
+
}
|
|
431
|
+
} else if (unit >= 56320 && unit <= 57343) {
|
|
432
|
+
units.push(65533);
|
|
433
|
+
} else {
|
|
434
|
+
units.push(unit);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
if (i < bytes2.length) {
|
|
438
|
+
units.push(65533);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
let result = "";
|
|
442
|
+
for (let i = 0; i < units.length; i += 8192) {
|
|
443
|
+
result += String.fromCharCode(...units.slice(i, i + 8192));
|
|
444
|
+
}
|
|
445
|
+
return result;
|
|
446
|
+
}
|
|
447
|
+
};
|
|
315
448
|
var textDecoder = /* @__PURE__ */ new TextDecoder();
|
|
316
449
|
var textEncoder = /* @__PURE__ */ new TextEncoder();
|
|
317
450
|
var isIso88591Compatible = (text) => {
|
|
@@ -17752,6 +17885,8 @@ var Mediabunny = (() => {
|
|
|
17752
17885
|
);
|
|
17753
17886
|
}
|
|
17754
17887
|
super();
|
|
17888
|
+
/** @internal */
|
|
17889
|
+
this._readers = /* @__PURE__ */ new Set();
|
|
17755
17890
|
this._options = options;
|
|
17756
17891
|
this._orchestrator = new ReadOrchestrator({
|
|
17757
17892
|
maxCacheSize: options.maxCacheSize ?? 8 * 2 ** 20,
|
|
@@ -17796,6 +17931,9 @@ var Mediabunny = (() => {
|
|
|
17796
17931
|
let data = this._options.read(worker.currentPos, originalTargetPos);
|
|
17797
17932
|
if (isThenable(data)) data = await data;
|
|
17798
17933
|
if (worker.aborted) {
|
|
17934
|
+
if (data instanceof ReadableStream) {
|
|
17935
|
+
await data.cancel();
|
|
17936
|
+
}
|
|
17799
17937
|
break;
|
|
17800
17938
|
}
|
|
17801
17939
|
if (data instanceof Uint8Array) {
|
|
@@ -17809,25 +17947,33 @@ var Mediabunny = (() => {
|
|
|
17809
17947
|
this._orchestrator.supplyWorkerData(worker, data);
|
|
17810
17948
|
} else if (data instanceof ReadableStream) {
|
|
17811
17949
|
const reader = data.getReader();
|
|
17812
|
-
|
|
17813
|
-
|
|
17814
|
-
|
|
17815
|
-
|
|
17816
|
-
|
|
17817
|
-
|
|
17950
|
+
this._readers.add(reader);
|
|
17951
|
+
try {
|
|
17952
|
+
while (worker.currentPos < originalTargetPos && !worker.aborted) {
|
|
17953
|
+
const { done, value } = await reader.read();
|
|
17954
|
+
if (done) {
|
|
17955
|
+
if (worker.currentPos < originalTargetPos) {
|
|
17956
|
+
throw new Error(
|
|
17957
|
+
`ReadableStream returned by options.read ended before supplying enough data. Requested ${originalTargetPos - originalCurrentPos} bytes, but got ${worker.currentPos - originalCurrentPos}`
|
|
17958
|
+
);
|
|
17959
|
+
}
|
|
17960
|
+
break;
|
|
17961
|
+
}
|
|
17962
|
+
if (!(value instanceof Uint8Array)) {
|
|
17963
|
+
throw new TypeError(
|
|
17964
|
+
"ReadableStream returned by options.read must yield Uint8Array chunks."
|
|
17818
17965
|
);
|
|
17819
17966
|
}
|
|
17820
|
-
|
|
17821
|
-
|
|
17822
|
-
|
|
17823
|
-
|
|
17824
|
-
|
|
17825
|
-
|
|
17826
|
-
break;
|
|
17967
|
+
if (worker.aborted) {
|
|
17968
|
+
break;
|
|
17969
|
+
}
|
|
17970
|
+
const data2 = toUint8Array(value);
|
|
17971
|
+
this._dispatchRead(worker.currentPos, worker.currentPos + data2.length);
|
|
17972
|
+
this._orchestrator.supplyWorkerData(worker, data2);
|
|
17827
17973
|
}
|
|
17828
|
-
|
|
17829
|
-
this.
|
|
17830
|
-
|
|
17974
|
+
} finally {
|
|
17975
|
+
this._readers.delete(reader);
|
|
17976
|
+
reader.releaseLock();
|
|
17831
17977
|
}
|
|
17832
17978
|
} else {
|
|
17833
17979
|
throw new TypeError("options.read must return or resolve to a Uint8Array or a ReadableStream.");
|
|
@@ -17838,6 +17984,11 @@ var Mediabunny = (() => {
|
|
|
17838
17984
|
/** @internal */
|
|
17839
17985
|
_dispose() {
|
|
17840
17986
|
this._orchestrator.dispose();
|
|
17987
|
+
for (const reader of this._readers) {
|
|
17988
|
+
void reader.cancel().catch(() => {
|
|
17989
|
+
});
|
|
17990
|
+
}
|
|
17991
|
+
this._readers.clear();
|
|
17841
17992
|
this._options.dispose?.();
|
|
17842
17993
|
}
|
|
17843
17994
|
};
|
|
@@ -34213,7 +34364,7 @@ ${cue.notes ?? ""}`;
|
|
|
34213
34364
|
this.writer.write(this.helper);
|
|
34214
34365
|
}
|
|
34215
34366
|
writeAscii(text) {
|
|
34216
|
-
this.writer.write(
|
|
34367
|
+
this.writer.write(textEncoder.encode(text));
|
|
34217
34368
|
}
|
|
34218
34369
|
};
|
|
34219
34370
|
|