@svta/cml-id3 0.19.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/LICENSE +202 -0
- package/NOTICE +39 -0
- package/dist/DecodedId3Frame.d.ts +21 -0
- package/dist/DecodedId3Frame.d.ts.map +1 -0
- package/dist/DecodedId3Frame.js +2 -0
- package/dist/DecodedId3Frame.js.map +1 -0
- package/dist/ID3_SCHEME_ID_URI.d.ts +11 -0
- package/dist/ID3_SCHEME_ID_URI.d.ts.map +1 -0
- package/dist/ID3_SCHEME_ID_URI.js +11 -0
- package/dist/ID3_SCHEME_ID_URI.js.map +1 -0
- package/dist/Id3Frame.d.ts +9 -0
- package/dist/Id3Frame.d.ts.map +1 -0
- package/dist/Id3Frame.js +2 -0
- package/dist/Id3Frame.js.map +1 -0
- package/dist/canParseId3.d.ts +13 -0
- package/dist/canParseId3.d.ts.map +1 -0
- package/dist/canParseId3.js +18 -0
- package/dist/canParseId3.js.map +1 -0
- package/dist/getId3Data.d.ts +14 -0
- package/dist/getId3Data.d.ts.map +1 -0
- package/dist/getId3Data.js +35 -0
- package/dist/getId3Data.js.map +1 -0
- package/dist/getId3Frames.d.ts +13 -0
- package/dist/getId3Frames.d.ts.map +1 -0
- package/dist/getId3Frames.js +46 -0
- package/dist/getId3Frames.js.map +1 -0
- package/dist/getId3Timestamp.d.ts +12 -0
- package/dist/getId3Timestamp.d.ts.map +1 -0
- package/dist/getId3Timestamp.js +24 -0
- package/dist/getId3Timestamp.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/isId3TimestampFrame.d.ts +13 -0
- package/dist/isId3TimestampFrame.d.ts.map +1 -0
- package/dist/isId3TimestampFrame.js +16 -0
- package/dist/isId3TimestampFrame.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/util/RawFrame.d.ts +12 -0
- package/dist/util/RawFrame.d.ts.map +1 -0
- package/dist/util/RawFrame.js +2 -0
- package/dist/util/RawFrame.js.map +1 -0
- package/dist/util/decodeId3Frame.d.ts +14 -0
- package/dist/util/decodeId3Frame.d.ts.map +1 -0
- package/dist/util/decodeId3Frame.js +27 -0
- package/dist/util/decodeId3Frame.js.map +1 -0
- package/dist/util/decodeId3ImageFrame.d.ts +4 -0
- package/dist/util/decodeId3ImageFrame.d.ts.map +1 -0
- package/dist/util/decodeId3ImageFrame.js +46 -0
- package/dist/util/decodeId3ImageFrame.js.map +1 -0
- package/dist/util/decodeId3PrivFrame.d.ts +14 -0
- package/dist/util/decodeId3PrivFrame.d.ts.map +1 -0
- package/dist/util/decodeId3PrivFrame.js +23 -0
- package/dist/util/decodeId3PrivFrame.js.map +1 -0
- package/dist/util/decodeId3TextFrame.d.ts +14 -0
- package/dist/util/decodeId3TextFrame.d.ts.map +1 -0
- package/dist/util/decodeId3TextFrame.js +37 -0
- package/dist/util/decodeId3TextFrame.js.map +1 -0
- package/dist/util/decodeId3UrlFrame.d.ts +14 -0
- package/dist/util/decodeId3UrlFrame.d.ts.map +1 -0
- package/dist/util/decodeId3UrlFrame.js +35 -0
- package/dist/util/decodeId3UrlFrame.js.map +1 -0
- package/dist/util/getId3FrameData.d.ts +13 -0
- package/dist/util/getId3FrameData.d.ts.map +1 -0
- package/dist/util/getId3FrameData.js +24 -0
- package/dist/util/getId3FrameData.js.map +1 -0
- package/dist/util/isId3Footer.d.ts +13 -0
- package/dist/util/isId3Footer.d.ts.map +1 -0
- package/dist/util/isId3Footer.js +35 -0
- package/dist/util/isId3Footer.js.map +1 -0
- package/dist/util/isId3Header.d.ts +13 -0
- package/dist/util/isId3Header.d.ts.map +1 -0
- package/dist/util/isId3Header.js +45 -0
- package/dist/util/isId3Header.js.map +1 -0
- package/dist/util/readId3Size.d.ts +13 -0
- package/dist/util/readId3Size.d.ts.map +1 -0
- package/dist/util/readId3Size.js +20 -0
- package/dist/util/readId3Size.js.map +1 -0
- package/dist/util/readId3Timestamp.d.ts +13 -0
- package/dist/util/readId3Timestamp.d.ts.map +1 -0
- package/dist/util/readId3Timestamp.js +26 -0
- package/dist/util/readId3Timestamp.js.map +1 -0
- package/dist/util/toArrayBuffer.d.ts +4 -0
- package/dist/util/toArrayBuffer.d.ts.map +1 -0
- package/dist/util/toArrayBuffer.js +16 -0
- package/dist/util/toArrayBuffer.js.map +1 -0
- package/dist/util/utf8.d.ts +2 -0
- package/dist/util/utf8.d.ts.map +1 -0
- package/dist/util/utf8.js +31 -0
- package/dist/util/utf8.js.map +1 -0
- package/dist/util/utf8ArrayToStr.d.ts +12 -0
- package/dist/util/utf8ArrayToStr.d.ts.map +1 -0
- package/dist/util/utf8ArrayToStr.js +19 -0
- package/dist/util/utf8ArrayToStr.js.map +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isId3Footer.js","sourceRoot":"","sources":["../../src/util/isId3Footer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAAC,IAAgB,EAAE,MAAc;IAC3D;;OAEG;IACH,IAAI,MAAM,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChC,4BAA4B;QAC5B,IACC,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI;YACrB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,IAAI;YACzB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,IAAI,EACxB,CAAC;YACF,gCAAgC;YAChC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC;gBACxD,6BAA6B;gBAC7B,IACC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI;oBACvB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI;oBACvB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI;oBACvB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,EACtB,CAAC;oBACF,OAAO,IAAI,CAAC;gBACb,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["/**\n * Returns true if an ID3 footer can be found at offset in data\n *\n * @param data - The data to search in\n * @param offset - The offset at which to start searching\n *\n * @returns `true` if an ID3 footer is found\n *\n * @internal\n *\n */\nexport function isId3Footer(data: Uint8Array, offset: number): boolean {\n\t/*\n\t * The footer is a copy of the header, but with a different identifier\n\t */\n\tif (offset + 10 <= data.length) {\n\t\t// look for '3DI' identifier\n\t\tif (\n\t\t\tdata[offset] === 0x33 &&\n\t\t\tdata[offset + 1] === 0x44 &&\n\t\t\tdata[offset + 2] === 0x49\n\t\t) {\n\t\t\t// check version is within range\n\t\t\tif (data[offset + 3] < 0xff && data[offset + 4] < 0xff) {\n\t\t\t\t// check size is within range\n\t\t\t\tif (\n\t\t\t\t\tdata[offset + 6] < 0x80 &&\n\t\t\t\t\tdata[offset + 7] < 0x80 &&\n\t\t\t\t\tdata[offset + 8] < 0x80 &&\n\t\t\t\t\tdata[offset + 9] < 0x80\n\t\t\t\t) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn false;\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true if an ID3 header can be found at offset in data
|
|
3
|
+
*
|
|
4
|
+
* @param data - The data to search in
|
|
5
|
+
* @param offset - The offset at which to start searching
|
|
6
|
+
*
|
|
7
|
+
* @returns `true` if an ID3 header is found
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
export declare function isId3Header(data: Uint8Array, offset: number): boolean;
|
|
13
|
+
//# sourceMappingURL=isId3Header.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isId3Header.d.ts","sourceRoot":"","sources":["../../src/util/isId3Header.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAoCrE"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true if an ID3 header can be found at offset in data
|
|
3
|
+
*
|
|
4
|
+
* @param data - The data to search in
|
|
5
|
+
* @param offset - The offset at which to start searching
|
|
6
|
+
*
|
|
7
|
+
* @returns `true` if an ID3 header is found
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
export function isId3Header(data, offset) {
|
|
13
|
+
/*
|
|
14
|
+
* http://id3.org/id3v2.3.0
|
|
15
|
+
* [0] = 'I'
|
|
16
|
+
* [1] = 'D'
|
|
17
|
+
* [2] = '3'
|
|
18
|
+
* [3,4] = {Version}
|
|
19
|
+
* [5] = {Flags}
|
|
20
|
+
* [6-9] = {ID3 Size}
|
|
21
|
+
*
|
|
22
|
+
* An ID3v2 tag can be detected with the following pattern:
|
|
23
|
+
* $49 44 33 yy yy xx zz zz zz zz
|
|
24
|
+
* Where yy is less than $FF, xx is the 'flags' byte and zz is less than $80
|
|
25
|
+
*/
|
|
26
|
+
if (offset + 10 <= data.length) {
|
|
27
|
+
// look for 'ID3' identifier
|
|
28
|
+
if (data[offset] === 0x49 &&
|
|
29
|
+
data[offset + 1] === 0x44 &&
|
|
30
|
+
data[offset + 2] === 0x33) {
|
|
31
|
+
// check version is within range
|
|
32
|
+
if (data[offset + 3] < 0xff && data[offset + 4] < 0xff) {
|
|
33
|
+
// check size is within range
|
|
34
|
+
if (data[offset + 6] < 0x80 &&
|
|
35
|
+
data[offset + 7] < 0x80 &&
|
|
36
|
+
data[offset + 8] < 0x80 &&
|
|
37
|
+
data[offset + 9] < 0x80) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=isId3Header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isId3Header.js","sourceRoot":"","sources":["../../src/util/isId3Header.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAAC,IAAgB,EAAE,MAAc;IAC3D;;;;;;;;;;;;OAYG;IACH,IAAI,MAAM,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChC,4BAA4B;QAC5B,IACC,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI;YACrB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,IAAI;YACzB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,IAAI,EACxB,CAAC;YACF,gCAAgC;YAChC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC;gBACxD,6BAA6B;gBAC7B,IACC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI;oBACvB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI;oBACvB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI;oBACvB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,EACtB,CAAC;oBACF,OAAO,IAAI,CAAC;gBACb,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["/**\n * Returns true if an ID3 header can be found at offset in data\n *\n * @param data - The data to search in\n * @param offset - The offset at which to start searching\n *\n * @returns `true` if an ID3 header is found\n *\n * @internal\n *\n */\nexport function isId3Header(data: Uint8Array, offset: number): boolean {\n\t/*\n\t * http://id3.org/id3v2.3.0\n\t * [0] = 'I'\n\t * [1] = 'D'\n\t * [2] = '3'\n\t * [3,4] = {Version}\n\t * [5] = {Flags}\n\t * [6-9] = {ID3 Size}\n\t *\n\t * An ID3v2 tag can be detected with the following pattern:\n\t * $49 44 33 yy yy xx zz zz zz zz\n\t * Where yy is less than $FF, xx is the 'flags' byte and zz is less than $80\n\t */\n\tif (offset + 10 <= data.length) {\n\t\t// look for 'ID3' identifier\n\t\tif (\n\t\t\tdata[offset] === 0x49 &&\n\t\t\tdata[offset + 1] === 0x44 &&\n\t\t\tdata[offset + 2] === 0x33\n\t\t) {\n\t\t\t// check version is within range\n\t\t\tif (data[offset + 3] < 0xff && data[offset + 4] < 0xff) {\n\t\t\t\t// check size is within range\n\t\t\t\tif (\n\t\t\t\t\tdata[offset + 6] < 0x80 &&\n\t\t\t\t\tdata[offset + 7] < 0x80 &&\n\t\t\t\t\tdata[offset + 8] < 0x80 &&\n\t\t\t\t\tdata[offset + 9] < 0x80\n\t\t\t\t) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read ID3 size
|
|
3
|
+
*
|
|
4
|
+
* @param data - The data to read from
|
|
5
|
+
* @param offset - The offset at which to start reading
|
|
6
|
+
*
|
|
7
|
+
* @returns The size
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
export declare function readId3Size(data: Uint8Array, offset: number): number;
|
|
13
|
+
//# sourceMappingURL=readId3Size.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readId3Size.d.ts","sourceRoot":"","sources":["../../src/util/readId3Size.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAOpE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read ID3 size
|
|
3
|
+
*
|
|
4
|
+
* @param data - The data to read from
|
|
5
|
+
* @param offset - The offset at which to start reading
|
|
6
|
+
*
|
|
7
|
+
* @returns The size
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
export function readId3Size(data, offset) {
|
|
13
|
+
let size = 0;
|
|
14
|
+
size = (data[offset] & 0x7f) << 21;
|
|
15
|
+
size |= (data[offset + 1] & 0x7f) << 14;
|
|
16
|
+
size |= (data[offset + 2] & 0x7f) << 7;
|
|
17
|
+
size |= data[offset + 3] & 0x7f;
|
|
18
|
+
return size;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=readId3Size.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readId3Size.js","sourceRoot":"","sources":["../../src/util/readId3Size.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAAC,IAAgB,EAAE,MAAc;IAC3D,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IACnC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IACxC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;IAChC,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/**\n * Read ID3 size\n *\n * @param data - The data to read from\n * @param offset - The offset at which to start reading\n *\n * @returns The size\n *\n * @internal\n *\n */\nexport function readId3Size(data: Uint8Array, offset: number): number {\n\tlet size = 0;\n\tsize = (data[offset] & 0x7f) << 21;\n\tsize |= (data[offset + 1] & 0x7f) << 14;\n\tsize |= (data[offset + 2] & 0x7f) << 7;\n\tsize |= data[offset + 3] & 0x7f;\n\treturn size;\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DecodedId3Frame } from '../DecodedId3Frame.js';
|
|
2
|
+
/**
|
|
3
|
+
* Read a 33 bit timestamp from an ID3 frame.
|
|
4
|
+
*
|
|
5
|
+
* @param timeStampFrame - the ID3 frame
|
|
6
|
+
*
|
|
7
|
+
* @returns The timestamp
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
export declare function readId3Timestamp(timeStampFrame: DecodedId3Frame<ArrayBuffer>): number | undefined;
|
|
13
|
+
//# sourceMappingURL=readId3Timestamp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readId3Timestamp.d.ts","sourceRoot":"","sources":["../../src/util/readId3Timestamp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC/B,cAAc,EAAE,eAAe,CAAC,WAAW,CAAC,GAC1C,MAAM,GAAG,SAAS,CAkBpB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a 33 bit timestamp from an ID3 frame.
|
|
3
|
+
*
|
|
4
|
+
* @param timeStampFrame - the ID3 frame
|
|
5
|
+
*
|
|
6
|
+
* @returns The timestamp
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export function readId3Timestamp(timeStampFrame) {
|
|
12
|
+
if (timeStampFrame.data.byteLength === 8) {
|
|
13
|
+
const data = new Uint8Array(timeStampFrame.data);
|
|
14
|
+
// timestamp is 33 bit expressed as a big-endian eight-octet number,
|
|
15
|
+
// with the upper 31 bits set to zero.
|
|
16
|
+
const pts33Bit = data[3] & 0x1;
|
|
17
|
+
let timestamp = (data[4] << 23) + (data[5] << 15) + (data[6] << 7) + data[7];
|
|
18
|
+
timestamp /= 45;
|
|
19
|
+
if (pts33Bit) {
|
|
20
|
+
timestamp += 47721858.84;
|
|
21
|
+
} // 2^32 / 90
|
|
22
|
+
return Math.round(timestamp);
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=readId3Timestamp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readId3Timestamp.js","sourceRoot":"","sources":["../../src/util/readId3Timestamp.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAC/B,cAA4C;IAE5C,IAAI,cAAc,CAAC,IAAI,CAAC,UAAU,KAAK,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QACjD,oEAAoE;QACpE,sCAAsC;QACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;QAC/B,IAAI,SAAS,GACZ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAC9D,SAAS,IAAI,EAAE,CAAC;QAEhB,IAAI,QAAQ,EAAE,CAAC;YACd,SAAS,IAAI,WAAW,CAAC;QAC1B,CAAC,CAAC,YAAY;QAEd,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import type { DecodedId3Frame } from '../DecodedId3Frame.js';\n\n/**\n * Read a 33 bit timestamp from an ID3 frame.\n *\n * @param timeStampFrame - the ID3 frame\n *\n * @returns The timestamp\n *\n * @internal\n *\n */\nexport function readId3Timestamp(\n\ttimeStampFrame: DecodedId3Frame<ArrayBuffer>,\n): number | undefined {\n\tif (timeStampFrame.data.byteLength === 8) {\n\t\tconst data = new Uint8Array(timeStampFrame.data);\n\t\t// timestamp is 33 bit expressed as a big-endian eight-octet number,\n\t\t// with the upper 31 bits set to zero.\n\t\tconst pts33Bit = data[3] & 0x1;\n\t\tlet timestamp =\n\t\t\t(data[4] << 23) + (data[5] << 15) + (data[6] << 7) + data[7];\n\t\ttimestamp /= 45;\n\n\t\tif (pts33Bit) {\n\t\t\ttimestamp += 47721858.84;\n\t\t} // 2^32 / 90\n\n\t\treturn Math.round(timestamp);\n\t}\n\n\treturn undefined;\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | Uint8ClampedArray;
|
|
2
|
+
export declare function toArrayBuffer(view: ArrayBuffer | TypedArray): ArrayBuffer;
|
|
3
|
+
export {};
|
|
4
|
+
//# sourceMappingURL=toArrayBuffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toArrayBuffer.d.ts","sourceRoot":"","sources":["../../src/util/toArrayBuffer.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GACZ,SAAS,GACT,UAAU,GACV,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,iBAAiB,CAAC;AAErB,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,WAAW,CAczE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function toArrayBuffer(view) {
|
|
2
|
+
if (view instanceof ArrayBuffer) {
|
|
3
|
+
return view;
|
|
4
|
+
}
|
|
5
|
+
else {
|
|
6
|
+
if (view.byteOffset == 0 && view.byteLength == view.buffer.byteLength) {
|
|
7
|
+
// This is a TypedArray over the whole buffer.
|
|
8
|
+
return view.buffer;
|
|
9
|
+
}
|
|
10
|
+
// This is a 'view' on the buffer. Create a new buffer that only contains
|
|
11
|
+
// the data. Note that since this isn't an ArrayBuffer, the 'new' call
|
|
12
|
+
// will allocate a new buffer to hold the copy.
|
|
13
|
+
return new Uint8Array(view).buffer;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=toArrayBuffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toArrayBuffer.js","sourceRoot":"","sources":["../../src/util/toArrayBuffer.ts"],"names":[],"mappings":"AAWA,MAAM,UAAU,aAAa,CAAC,IAA8B;IAC3D,IAAI,IAAI,YAAY,WAAW,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC;IACb,CAAC;SACI,CAAC;QACL,IAAI,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YACvE,8CAA8C;YAC9C,OAAO,IAAI,CAAC,MAAqB,CAAC;QACnC,CAAC;QACD,0EAA0E;QAC1E,uEAAuE;QACvE,+CAA+C;QAC/C,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;IACpC,CAAC;AACF,CAAC","sourcesContent":["type TypedArray =\n\t| Int8Array\n\t| Uint8Array\n\t| Int16Array\n\t| Uint16Array\n\t| Int32Array\n\t| Uint32Array\n\t| Float32Array\n\t| Float64Array\n\t| Uint8ClampedArray;\n\nexport function toArrayBuffer(view: ArrayBuffer | TypedArray): ArrayBuffer {\n\tif (view instanceof ArrayBuffer) {\n\t\treturn view;\n\t}\n\telse {\n\t\tif (view.byteOffset == 0 && view.byteLength == view.buffer.byteLength) {\n\t\t\t// This is a TypedArray over the whole buffer.\n\t\t\treturn view.buffer as ArrayBuffer;\n\t\t}\n\t\t// This is a 'view' on the buffer. Create a new buffer that only contains\n\t\t// the data. Note that since this isn't an ArrayBuffer, the 'new' call\n\t\t// will allocate a new buffer to hold the copy.\n\t\treturn new Uint8Array(view).buffer;\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utf8.d.ts","sourceRoot":"","sources":["../../src/util/utf8.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CACtB,IAAI,EAAE,YAAY,EAClB,MAAM,GAAE,MAAU,EAClB,MAAM,GAAE,MAAiB,GACvB,UAAU,CAAC,WAAW,CAAC,CAEzB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export function toUint8(data, offset = 0, length = Infinity) {
|
|
2
|
+
return view(data, offset, length, Uint8Array);
|
|
3
|
+
}
|
|
4
|
+
function view(data, offset, length, Type) {
|
|
5
|
+
const buffer = unsafeGetArrayBuffer(data);
|
|
6
|
+
let bytesPerElement = 1;
|
|
7
|
+
if ('BYTES_PER_ELEMENT' in Type) {
|
|
8
|
+
bytesPerElement = Type.BYTES_PER_ELEMENT;
|
|
9
|
+
}
|
|
10
|
+
// Absolute end of the |data| view within |buffer|.
|
|
11
|
+
const dataOffset = isArrayBufferView(data) ? data.byteOffset : 0;
|
|
12
|
+
const dataEnd = ((dataOffset) + data.byteLength) / bytesPerElement;
|
|
13
|
+
// Absolute start of the result within |buffer|.
|
|
14
|
+
const rawStart = ((dataOffset) + offset) / bytesPerElement;
|
|
15
|
+
const start = Math.floor(Math.max(0, Math.min(rawStart, dataEnd)));
|
|
16
|
+
// Absolute end of the result within |buffer|.
|
|
17
|
+
const end = Math.floor(Math.min(start + Math.max(length, 0), dataEnd));
|
|
18
|
+
return new Type(buffer, start, end - start);
|
|
19
|
+
}
|
|
20
|
+
function unsafeGetArrayBuffer(view) {
|
|
21
|
+
if (view instanceof ArrayBuffer) {
|
|
22
|
+
return view;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return view.buffer;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function isArrayBufferView(obj) {
|
|
29
|
+
return obj && obj.buffer instanceof ArrayBuffer && obj.byteLength !== undefined && obj.byteOffset !== undefined;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=utf8.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utf8.js","sourceRoot":"","sources":["../../src/util/utf8.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,OAAO,CACtB,IAAkB,EAClB,SAAiB,CAAC,EAClB,SAAiB,QAAQ;IAEzB,OAAO,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,IAAI,CACZ,IAAkB,EAClB,MAAc,EACd,MAAc,EACd,IAAyE;IAEzE,MAAM,MAAM,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAC1C,IAAI,eAAe,GAAQ,CAAC,CAAC;IAC7B,IAAI,mBAAmB,IAAI,IAAI,EAAE,CAAC;QACjC,eAAe,GAAG,IAAI,CAAC,iBAAiB,CAAC;IAC1C,CAAC;IACD,mDAAmD;IACnD,MAAM,UAAU,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACjE,MAAM,OAAO,GAAG,CAAC,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,eAAe,CAAC;IACnE,gDAAgD;IAChD,MAAM,QAAQ,GAAG,CAAC,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,GAAG,eAAe,CAAC;IAC3D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACnE,8CAA8C;IAC9C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;IACvE,OAAO,IAAI,IAAI,CAAC,MAAqB,EAAE,KAAK,EAAE,GAAG,GAAG,KAAK,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAkB;IAC/C,IAAI,IAAI,YAAY,WAAW,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC;IACb,CAAC;SACI,CAAC;QACL,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;AACF,CAAC;AAED,SAAS,iBAAiB,CAAC,GAAQ;IAClC,OAAO,GAAG,IAAI,GAAG,CAAC,MAAM,YAAY,WAAW,IAAI,GAAG,CAAC,UAAU,KAAK,SAAS,IAAI,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC;AACjH,CAAC","sourcesContent":["export function toUint8(\n\tdata: BufferSource,\n\toffset: number = 0,\n\tlength: number = Infinity,\n): Uint8Array<ArrayBuffer> {\n\treturn view(data, offset, length, Uint8Array);\n}\n\nfunction view<T extends ArrayBufferView>(\n\tdata: BufferSource,\n\toffset: number,\n\tlength: number,\n\tType: { new(buffer: ArrayBuffer, byteOffset: number, length: number): T },\n): T {\n\tconst buffer = unsafeGetArrayBuffer(data);\n\tlet bytesPerElement: any = 1;\n\tif ('BYTES_PER_ELEMENT' in Type) {\n\t\tbytesPerElement = Type.BYTES_PER_ELEMENT;\n\t}\n\t// Absolute end of the |data| view within |buffer|.\n\tconst dataOffset = isArrayBufferView(data) ? data.byteOffset : 0;\n\tconst dataEnd = ((dataOffset) + data.byteLength) / bytesPerElement;\n\t// Absolute start of the result within |buffer|.\n\tconst rawStart = ((dataOffset) + offset) / bytesPerElement;\n\tconst start = Math.floor(Math.max(0, Math.min(rawStart, dataEnd)));\n\t// Absolute end of the result within |buffer|.\n\tconst end = Math.floor(Math.min(start + Math.max(length, 0), dataEnd));\n\treturn new Type(buffer as ArrayBuffer, start, end - start);\n}\n\nfunction unsafeGetArrayBuffer(view: BufferSource) {\n\tif (view instanceof ArrayBuffer) {\n\t\treturn view;\n\t}\n\telse {\n\t\treturn view.buffer;\n\t}\n}\n\nfunction isArrayBufferView(obj: any): obj is ArrayBufferView {\n\treturn obj && obj.buffer instanceof ArrayBuffer && obj.byteLength !== undefined && obj.byteOffset !== undefined;\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a UTF-8 array to a string.
|
|
3
|
+
*
|
|
4
|
+
* @param array - The UTF-8 array to convert
|
|
5
|
+
* @param exitOnNull - Whether to exit on the first null byte
|
|
6
|
+
*
|
|
7
|
+
* @returns The string
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare function utf8ArrayToStr(array: Uint8Array<ArrayBuffer>, exitOnNull?: boolean): string;
|
|
12
|
+
//# sourceMappingURL=utf8ArrayToStr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utf8ArrayToStr.d.ts","sourceRoot":"","sources":["../../src/util/utf8ArrayToStr.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC7B,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,EAC9B,UAAU,GAAE,OAAe,GACzB,MAAM,CAMR"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { decodeText } from '@svta/cml-utils/decodeText.js';
|
|
2
|
+
import { UTF_8 } from '@svta/cml-utils/UTF_8.js';
|
|
3
|
+
/**
|
|
4
|
+
* Converts a UTF-8 array to a string.
|
|
5
|
+
*
|
|
6
|
+
* @param array - The UTF-8 array to convert
|
|
7
|
+
* @param exitOnNull - Whether to exit on the first null byte
|
|
8
|
+
*
|
|
9
|
+
* @returns The string
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export function utf8ArrayToStr(array, exitOnNull = false) {
|
|
14
|
+
const byteLength = exitOnNull ? array.indexOf(0) : array.length;
|
|
15
|
+
const view = new DataView(array.buffer, array.byteOffset, byteLength);
|
|
16
|
+
const result = decodeText(view, { encoding: UTF_8 });
|
|
17
|
+
return exitOnNull ? result : result.replace(/\0/g, '');
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=utf8ArrayToStr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utf8ArrayToStr.js","sourceRoot":"","sources":["../../src/util/utf8ArrayToStr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAEjD;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAC7B,KAA8B,EAC9B,aAAsB,KAAK;IAE3B,MAAM,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;IAChE,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAc,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACnF,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IAErD,OAAO,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import { decodeText } from '@svta/cml-utils/decodeText.js';\nimport { UTF_8 } from '@svta/cml-utils/UTF_8.js';\n\n/**\n * Converts a UTF-8 array to a string.\n *\n * @param array - The UTF-8 array to convert\n * @param exitOnNull - Whether to exit on the first null byte\n *\n * @returns The string\n *\n * @internal\n */\nexport function utf8ArrayToStr(\n\tarray: Uint8Array<ArrayBuffer>,\n\texitOnNull: boolean = false,\n): string {\n\tconst byteLength = exitOnNull ? array.indexOf(0) : array.length;\n\tconst view = new DataView<ArrayBuffer>(array.buffer, array.byteOffset, byteLength);\n\tconst result = decodeText(view, { encoding: UTF_8 });\n\n\treturn exitOnNull ? result : result.replace(/\\0/g, '');\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@svta/cml-id3",
|
|
3
|
+
"version": "0.19.0",
|
|
4
|
+
"description": "ID3 tag parsing functionality",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"homepage": "https://github.com/streaming-video-technology-alliance/common-media-library",
|
|
8
|
+
"authors": "Casey Occhialini <1508707+littlespex@users.noreply.github.com>",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/streaming-video-technology-alliance/common-media-library.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/streaming-video-technology-alliance/common-media-library/issues"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public",
|
|
18
|
+
"registry": "https://registry.npmjs.org",
|
|
19
|
+
"provenance": true,
|
|
20
|
+
"scope": "svta"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist/**/*",
|
|
24
|
+
"NOTICE"
|
|
25
|
+
],
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js",
|
|
30
|
+
"default": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./*.js": {
|
|
33
|
+
"import": "./dist/*.js",
|
|
34
|
+
"default": "./dist/*.js"
|
|
35
|
+
},
|
|
36
|
+
"./*": {
|
|
37
|
+
"types": "./dist/*.d.ts",
|
|
38
|
+
"import": "./dist/*.js",
|
|
39
|
+
"default": "./dist/*.js"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"typesVersions": {
|
|
43
|
+
"*": {
|
|
44
|
+
"*": [
|
|
45
|
+
"dist/*",
|
|
46
|
+
"dist/cjs/*"
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"keywords": [
|
|
51
|
+
"Common Media Library",
|
|
52
|
+
"CML",
|
|
53
|
+
"ID3"
|
|
54
|
+
],
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "tsc",
|
|
57
|
+
"postbuild": "api-extractor run --local",
|
|
58
|
+
"test": "node --no-warnings --test **/*.test.ts",
|
|
59
|
+
"prepublishOnly": "npm run build"
|
|
60
|
+
},
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=20"
|
|
63
|
+
},
|
|
64
|
+
"devEngines": {
|
|
65
|
+
"runtime": {
|
|
66
|
+
"name": "node",
|
|
67
|
+
"version": ">=24",
|
|
68
|
+
"onFail": "error"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"peerDependencies": {
|
|
72
|
+
"@svta/cml-utils": "*"
|
|
73
|
+
}
|
|
74
|
+
}
|