mediabunny 1.40.1 → 1.41.0
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 +48 -8
- package/dist/bundles/mediabunny.min.cjs +8 -8
- package/dist/bundles/mediabunny.min.mjs +8 -8
- package/dist/bundles/mediabunny.mjs +48 -8
- package/dist/mediabunny.d.ts +4 -3
- package/dist/modules/src/id3.d.ts.map +1 -1
- package/dist/modules/src/id3.js +53 -8
- package/dist/modules/src/metadata.d.ts +4 -3
- package/dist/modules/src/metadata.d.ts.map +1 -1
- package/dist/modules/src/metadata.js +5 -2
- package/dist/modules/src/misc.d.ts +1 -0
- package/dist/modules/src/misc.d.ts.map +1 -1
- package/dist/modules/src/misc.js +6 -0
- package/dist/modules/src/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/id3.ts +54 -7
- package/src/metadata.ts +9 -4
- package/src/misc.ts +7 -0
|
@@ -837,6 +837,9 @@ var Mediabunny = (() => {
|
|
|
837
837
|
timerId: timer.id
|
|
838
838
|
});
|
|
839
839
|
};
|
|
840
|
+
var isRecordStringString = (value) => {
|
|
841
|
+
return value !== null && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype && Object.values(value).every((x) => typeof x === "string");
|
|
842
|
+
};
|
|
840
843
|
|
|
841
844
|
// src/metadata.ts
|
|
842
845
|
var RichImageData = class {
|
|
@@ -940,9 +943,9 @@ var Mediabunny = (() => {
|
|
|
940
943
|
throw new TypeError("tags.raw, when provided, must be an object.");
|
|
941
944
|
}
|
|
942
945
|
for (const value of Object.values(tags.raw)) {
|
|
943
|
-
if (value !== null && typeof value !== "string" && !(value instanceof Uint8Array) && !(value instanceof RichImageData) && !(value instanceof AttachedFile)) {
|
|
946
|
+
if (value !== null && typeof value !== "string" && !(value instanceof Uint8Array) && !(value instanceof RichImageData) && !(value instanceof AttachedFile) && !isRecordStringString(value)) {
|
|
944
947
|
throw new TypeError(
|
|
945
|
-
"Each value in tags.raw must be a string, Uint8Array, RichImageData, AttachedFile, or null."
|
|
948
|
+
"Each value in tags.raw must be a string, Uint8Array, RichImageData, AttachedFile, Record<string, string>, or null."
|
|
946
949
|
);
|
|
947
950
|
}
|
|
948
951
|
}
|
|
@@ -19306,7 +19309,13 @@ var Mediabunny = (() => {
|
|
|
19306
19309
|
reader.ununsynchronizeRegion(reader.pos, frameEndPos);
|
|
19307
19310
|
}
|
|
19308
19311
|
tags.raw ??= {};
|
|
19309
|
-
if (frame.id
|
|
19312
|
+
if (frame.id === "TXXX") {
|
|
19313
|
+
const txxx = tags.raw["TXXX"] ??= {};
|
|
19314
|
+
const encoding = reader.readId3V2TextEncoding();
|
|
19315
|
+
const description = reader.readId3V2Text(encoding, frameEndPos);
|
|
19316
|
+
const value = reader.readId3V2Text(encoding, frameEndPos);
|
|
19317
|
+
txxx[description] ??= value;
|
|
19318
|
+
} else if (frame.id[0] === "T") {
|
|
19310
19319
|
tags.raw[frame.id] ??= reader.readId3V2EncodingAndText(frameEndPos);
|
|
19311
19320
|
} else {
|
|
19312
19321
|
tags.raw[frame.id] ??= reader.readBytes(frame.size);
|
|
@@ -19808,12 +19817,44 @@ var Mediabunny = (() => {
|
|
|
19808
19817
|
}
|
|
19809
19818
|
let bytes2;
|
|
19810
19819
|
if (typeof value === "string") {
|
|
19811
|
-
const
|
|
19812
|
-
|
|
19813
|
-
|
|
19814
|
-
|
|
19820
|
+
const useIso88591 = isIso88591Compatible(value);
|
|
19821
|
+
if (useIso88591) {
|
|
19822
|
+
bytes2 = new Uint8Array(value.length + 2);
|
|
19823
|
+
bytes2[0] = 0 /* ISO_8859_1 */;
|
|
19824
|
+
for (let i = 0; i < value.length; i++) {
|
|
19825
|
+
bytes2[i + 1] = value.charCodeAt(i);
|
|
19826
|
+
}
|
|
19827
|
+
} else {
|
|
19828
|
+
const encoded = textEncoder.encode(value);
|
|
19829
|
+
bytes2 = new Uint8Array(encoded.byteLength + 2);
|
|
19830
|
+
bytes2[0] = 3 /* UTF_8 */;
|
|
19831
|
+
bytes2.set(encoded, 1);
|
|
19832
|
+
}
|
|
19815
19833
|
} else if (value instanceof Uint8Array) {
|
|
19816
19834
|
bytes2 = value;
|
|
19835
|
+
} else if (key === "TXXX" && isRecordStringString(value)) {
|
|
19836
|
+
for (const description in value) {
|
|
19837
|
+
const frameValue = value[description];
|
|
19838
|
+
const useIso88591 = isIso88591Compatible(description) && isIso88591Compatible(frameValue);
|
|
19839
|
+
const descriptionDataLength = useIso88591 ? description.length : textEncoder.encode(description).byteLength;
|
|
19840
|
+
const valueData = useIso88591 ? null : textEncoder.encode(frameValue);
|
|
19841
|
+
const valueDataLength = useIso88591 ? frameValue.length : valueData.byteLength;
|
|
19842
|
+
const frameSize = 1 + descriptionDataLength + 1 + valueDataLength;
|
|
19843
|
+
this.writeAscii("TXXX");
|
|
19844
|
+
this.writeSynchsafeU32(frameSize);
|
|
19845
|
+
this.writeU16(0);
|
|
19846
|
+
this.writeU8(useIso88591 ? 0 /* ISO_8859_1 */ : 3 /* UTF_8 */);
|
|
19847
|
+
if (useIso88591) {
|
|
19848
|
+
this.writeIsoString(description);
|
|
19849
|
+
for (let i = 0; i < frameValue.length; i++) {
|
|
19850
|
+
this.writeU8(frameValue.charCodeAt(i));
|
|
19851
|
+
}
|
|
19852
|
+
} else {
|
|
19853
|
+
this.writeUtf8String(description);
|
|
19854
|
+
this.writer.write(valueData);
|
|
19855
|
+
}
|
|
19856
|
+
}
|
|
19857
|
+
continue;
|
|
19817
19858
|
} else {
|
|
19818
19859
|
continue;
|
|
19819
19860
|
}
|
|
@@ -19856,7 +19897,6 @@ var Mediabunny = (() => {
|
|
|
19856
19897
|
for (let i = 0; i < text.length; i++) {
|
|
19857
19898
|
bytes2[i] = text.charCodeAt(i);
|
|
19858
19899
|
}
|
|
19859
|
-
bytes2[text.length] = 0;
|
|
19860
19900
|
this.writer.write(bytes2);
|
|
19861
19901
|
}
|
|
19862
19902
|
writeUtf8String(text) {
|