music-metadata 11.0.1 → 11.0.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.
Files changed (62) hide show
  1. package/lib/ParserFactory.d.ts +2 -2
  2. package/lib/ParserFactory.js +2 -1
  3. package/lib/aiff/AiffLoader.js +2 -2
  4. package/lib/aiff/AiffToken.d.ts +1 -1
  5. package/lib/apev2/APEv2Token.d.ts +7 -6
  6. package/lib/apev2/APEv2Token.js +6 -7
  7. package/lib/apev2/Apev2Loader.js +2 -2
  8. package/lib/asf/AsfLoader.js +2 -2
  9. package/lib/asf/AsfObject.d.ts +11 -16
  10. package/lib/asf/AsfObject.js +8 -9
  11. package/lib/asf/GUID.d.ts +1 -1
  12. package/lib/common/GenericTagMapper.d.ts +2 -2
  13. package/lib/common/GenericTagTypes.d.ts +1 -1
  14. package/lib/common/GenericTagTypes.js +80 -76
  15. package/lib/common/MetadataCollector.d.ts +2 -2
  16. package/lib/common/MetadataCollector.js +3 -3
  17. package/lib/core.d.ts +5 -0
  18. package/lib/core.js +7 -0
  19. package/lib/dsdiff/DsdiffLoader.js +2 -2
  20. package/lib/dsf/DsfChunk.d.ts +10 -9
  21. package/lib/dsf/DsfChunk.js +9 -10
  22. package/lib/dsf/DsfLoader.js +2 -2
  23. package/lib/ebml/EbmlIterator.d.ts +9 -8
  24. package/lib/ebml/EbmlIterator.js +8 -9
  25. package/lib/ebml/types.d.ts +9 -8
  26. package/lib/ebml/types.js +8 -9
  27. package/lib/flac/FlacLoader.js +2 -2
  28. package/lib/flac/FlacParser.js +9 -10
  29. package/lib/id3v2/ID3v2Token.d.ts +39 -37
  30. package/lib/id3v2/ID3v2Token.js +37 -40
  31. package/lib/matroska/MatroskaLoader.js +2 -2
  32. package/lib/matroska/types.d.ts +22 -20
  33. package/lib/matroska/types.js +27 -20
  34. package/lib/mp4/Atom.d.ts +3 -3
  35. package/lib/mp4/AtomToken.d.ts +0 -4
  36. package/lib/mp4/AtomToken.js +1 -5
  37. package/lib/mp4/Mp4Loader.js +2 -2
  38. package/lib/mpeg/MpegLoader.js +2 -2
  39. package/lib/mpeg/ReplayGainDataFormat.d.ts +14 -12
  40. package/lib/mpeg/ReplayGainDataFormat.js +12 -14
  41. package/lib/musepack/MusepackLoader.js +2 -2
  42. package/lib/musepack/sv7/BitReader.d.ts +1 -1
  43. package/lib/musepack/sv7/BitReader.js +1 -1
  44. package/lib/musepack/sv8/MpcSv8Parser.js +1 -0
  45. package/lib/musepack/sv8/StreamVersion8.d.ts +4 -2
  46. package/lib/musepack/sv8/StreamVersion8.js +8 -2
  47. package/lib/ogg/OggLoader.js +2 -2
  48. package/lib/ogg/opus/Opus.js +1 -1
  49. package/lib/ogg/opus/OpusParser.d.ts +1 -1
  50. package/lib/ogg/opus/OpusParser.js +1 -1
  51. package/lib/ogg/vorbis/Vorbis.d.ts +1 -1
  52. package/lib/ogg/vorbis/VorbisParser.d.ts +1 -1
  53. package/lib/ogg/vorbis/VorbisParser.js +1 -1
  54. package/lib/riff/RiffChunk.d.ts +1 -1
  55. package/lib/type.d.ts +1 -1
  56. package/lib/type.js +1 -1
  57. package/lib/wav/WaveChunk.d.ts +31 -15
  58. package/lib/wav/WaveChunk.js +30 -16
  59. package/lib/wav/WaveLoader.js +2 -2
  60. package/lib/wav/WaveParser.js +1 -1
  61. package/lib/wavpack/WavPackLoader.js +2 -2
  62. package/package.json +7 -5
@@ -2,47 +2,45 @@ import * as common from '../common/Util.js';
2
2
  /**
3
3
  * https://github.com/Borewit/music-metadata/wiki/Replay-Gain-Data-Format#name-code
4
4
  */
5
- var NameCode;
6
- (function (NameCode) {
5
+ const NameCode = {
7
6
  /**
8
7
  * not set
9
8
  */
10
- NameCode[NameCode["not_set"] = 0] = "not_set";
9
+ not_set: 0,
11
10
  /**
12
11
  * Radio Gain Adjustment
13
12
  */
14
- NameCode[NameCode["radio"] = 1] = "radio";
13
+ radio: 1,
15
14
  /**
16
15
  * Audiophile Gain Adjustment
17
16
  */
18
- NameCode[NameCode["audiophile"] = 2] = "audiophile";
19
- })(NameCode || (NameCode = {}));
17
+ audiophile: 2
18
+ };
20
19
  /**
21
20
  * https://github.com/Borewit/music-metadata/wiki/Replay-Gain-Data-Format#originator-code
22
21
  */
23
- var ReplayGainOriginator;
24
- (function (ReplayGainOriginator) {
22
+ const ReplayGainOriginator = {
25
23
  /**
26
24
  * Replay Gain unspecified
27
25
  */
28
- ReplayGainOriginator[ReplayGainOriginator["unspecified"] = 0] = "unspecified";
26
+ unspecified: 0,
29
27
  /**
30
28
  * Replay Gain pre-set by artist/producer/mastering engineer
31
29
  */
32
- ReplayGainOriginator[ReplayGainOriginator["engineer"] = 1] = "engineer";
30
+ engineer: 1,
33
31
  /**
34
32
  * Replay Gain set by user
35
33
  */
36
- ReplayGainOriginator[ReplayGainOriginator["user"] = 2] = "user";
34
+ user: 2,
37
35
  /**
38
36
  * Replay Gain determined automatically, as described on this site
39
37
  */
40
- ReplayGainOriginator[ReplayGainOriginator["automatic"] = 3] = "automatic";
38
+ automatic: 3,
41
39
  /**
42
40
  * Set by simple RMS average
43
41
  */
44
- ReplayGainOriginator[ReplayGainOriginator["rms_average"] = 4] = "rms_average";
45
- })(ReplayGainOriginator || (ReplayGainOriginator = {}));
42
+ rms_average: 4
43
+ };
46
44
  /**
47
45
  * Replay Gain Data Format
48
46
  *
@@ -1,8 +1,8 @@
1
1
  export const musepackParserLoader = {
2
2
  parserType: 'musepack',
3
3
  extensions: ['.mpc'],
4
- async load(metadata, tokenizer, options) {
5
- return new (await import('./MusepackParser.js')).MusepackParser(metadata, tokenizer, options);
4
+ async load() {
5
+ return (await import('./MusepackParser.js')).MusepackParser;
6
6
  }
7
7
  };
8
8
  //# sourceMappingURL=MusepackLoader.js.map
@@ -1,8 +1,8 @@
1
1
  import type { ITokenizer } from 'strtok3';
2
2
  export declare class BitReader {
3
- private tokenizer;
4
3
  pos: number;
5
4
  private dword;
5
+ private tokenizer;
6
6
  constructor(tokenizer: ITokenizer);
7
7
  /**
8
8
  *
@@ -1,9 +1,9 @@
1
1
  import * as Token from 'token-types';
2
2
  export class BitReader {
3
3
  constructor(tokenizer) {
4
- this.tokenizer = tokenizer;
5
4
  this.pos = 0;
6
5
  this.dword = null;
6
+ this.tokenizer = tokenizer;
7
7
  }
8
8
  /**
9
9
  *
@@ -50,6 +50,7 @@ export class MpcSv8Parser extends BasicParser {
50
50
  default:
51
51
  throw new MusepackContentError(`Unexpected header: ${header.key}`);
52
52
  }
53
+ // biome-ignore lint/correctness/noConstantCondition: break is handled in the switch statement
53
54
  } while (true);
54
55
  }
55
56
  }
@@ -31,8 +31,10 @@ interface IStreamHeader extends IStreamHeader1, IStreamHeader3 {
31
31
  beginningOfSilence: number;
32
32
  }
33
33
  export declare class StreamReader {
34
- private tokenizer;
35
- constructor(tokenizer: ITokenizer);
34
+ private _tokenizer;
35
+ get tokenizer(): ITokenizer;
36
+ set tokenizer(value: ITokenizer);
37
+ constructor(_tokenizer: ITokenizer);
36
38
  readPacketHeader(): Promise<IPacketHeader>;
37
39
  readStreamHeader(size: number): Promise<IStreamHeader>;
38
40
  private readVariableSizeField;
@@ -33,8 +33,14 @@ const SH_part3 = {
33
33
  }
34
34
  };
35
35
  export class StreamReader {
36
- constructor(tokenizer) {
37
- this.tokenizer = tokenizer;
36
+ get tokenizer() {
37
+ return this._tokenizer;
38
+ }
39
+ set tokenizer(value) {
40
+ this._tokenizer = value;
41
+ }
42
+ constructor(_tokenizer) {
43
+ this._tokenizer = _tokenizer;
38
44
  }
39
45
  async readPacketHeader() {
40
46
  const key = await this.tokenizer.readToken(PacketKey);
@@ -1,8 +1,8 @@
1
1
  export const oggParserLoader = {
2
2
  parserType: 'ogg',
3
3
  extensions: ['.ogg', '.ogv', '.oga', '.ogm', '.ogx', '.opus', '.spx'],
4
- async load(metadata, tokenizer, options) {
5
- return new (await import('./OggParser.js')).OggParser(metadata, tokenizer, options);
4
+ async load() {
5
+ return (await import('./OggParser.js')).OggParser;
6
6
  }
7
7
  };
8
8
  //# sourceMappingURL=OggLoader.js.map
@@ -8,10 +8,10 @@ export class OpusContentError extends makeUnexpectedFileContentError('Opus') {
8
8
  */
9
9
  export class IdHeader {
10
10
  constructor(len) {
11
- this.len = len;
12
11
  if (len < 19) {
13
12
  throw new OpusContentError('ID-header-page 0 should be at least 19 bytes long');
14
13
  }
14
+ this.len = len;
15
15
  }
16
16
  get(buf, off) {
17
17
  return {
@@ -9,9 +9,9 @@ import type { INativeMetadataCollector } from '../../common/MetadataCollector.js
9
9
  * Used by OggParser
10
10
  */
11
11
  export declare class OpusParser extends VorbisParser {
12
- private tokenizer;
13
12
  private idHeader;
14
13
  private lastPos;
14
+ private tokenizer;
15
15
  constructor(metadata: INativeMetadataCollector, options: IOptions, tokenizer: ITokenizer);
16
16
  /**
17
17
  * Parse first Opus Ogg page
@@ -10,9 +10,9 @@ import { OpusContentError } from './Opus.js';
10
10
  export class OpusParser extends VorbisParser {
11
11
  constructor(metadata, options, tokenizer) {
12
12
  super(metadata, options);
13
- this.tokenizer = tokenizer;
14
13
  this.idHeader = null;
15
14
  this.lastPos = -1;
15
+ this.tokenizer = tokenizer;
16
16
  }
17
17
  /**
18
18
  * Parse first Opus Ogg page
@@ -20,9 +20,9 @@ export interface IVorbisPicture extends IPicture {
20
20
  * // ToDo: move to ID3 / APIC?
21
21
  */
22
22
  export declare class VorbisPictureToken implements IGetToken<IVorbisPicture> {
23
- len: number;
24
23
  static fromBase64(base64str: string): IVorbisPicture;
25
24
  static fromBuffer(buffer: Uint8Array): IVorbisPicture;
25
+ len: number;
26
26
  constructor(len: number);
27
27
  get(buffer: Uint8Array, offset: number): IVorbisPicture;
28
28
  }
@@ -21,9 +21,9 @@ export declare class VorbisContentError extends VorbisContentError_base {
21
21
  * Used by OggParser
22
22
  */
23
23
  export declare class VorbisParser implements IPageConsumer {
24
+ private pageSegments;
24
25
  protected metadata: INativeMetadataCollector;
25
26
  protected options: IOptions;
26
- private pageSegments;
27
27
  constructor(metadata: INativeMetadataCollector, options: IOptions);
28
28
  /**
29
29
  * Vorbis 1 parser
@@ -12,9 +12,9 @@ export class VorbisContentError extends makeUnexpectedFileContentError('Vorbis')
12
12
  */
13
13
  export class VorbisParser {
14
14
  constructor(metadata, options) {
15
+ this.pageSegments = [];
15
16
  this.metadata = metadata;
16
17
  this.options = options;
17
- this.pageSegments = [];
18
18
  }
19
19
  /**
20
20
  * Vorbis 1 parser
@@ -9,8 +9,8 @@ export declare const Header: IGetToken<IChunkHeader>;
9
9
  * Token to parse RIFF-INFO tag value
10
10
  */
11
11
  export declare class ListInfoTagValue implements IGetToken<string> {
12
- private tagHeader;
13
12
  len: number;
13
+ private tagHeader;
14
14
  constructor(tagHeader: IChunkHeader);
15
15
  get(buf: Uint8Array, off: number): string;
16
16
  }
package/lib/type.d.ts CHANGED
@@ -2,7 +2,7 @@ import type { TagType } from './common/GenericTagTypes.js';
2
2
  import type { IFooter } from './apev2/APEv2Token.js';
3
3
  import type { TrackType } from './matroska/types.js';
4
4
  import type { LyricsContentType, TimestampFormat } from './id3v2/ID3v2Token.js';
5
- export { TrackType } from './matroska/types.js';
5
+ export { TrackType, TrackTypeValueToKeyMap } from './matroska/types.js';
6
6
  export { LyricsContentType, TimestampFormat } from './id3v2/ID3v2Token.js';
7
7
  export type AnyTagValue = unknown;
8
8
  /**
package/lib/type.js CHANGED
@@ -1,3 +1,3 @@
1
- export { TrackType } from './matroska/types.js';
1
+ export { TrackType, TrackTypeValueToKeyMap } from './matroska/types.js';
2
2
  export { LyricsContentType, TimestampFormat } from './id3v2/ID3v2Token.js';
3
3
  //# sourceMappingURL=type.js.map
@@ -17,21 +17,37 @@ export declare class WaveContentError extends WaveContentError_base {
17
17
  /**
18
18
  * Ref: https://msdn.microsoft.com/en-us/library/windows/desktop/dd317599(v=vs.85).aspx
19
19
  */
20
- export declare enum WaveFormat {
21
- PCM = 1,
22
- ADPCM = 2,
23
- IEEE_FLOAT = 3,
24
- MPEG_ADTS_AAC = 5632,
25
- MPEG_LOAS = 5634,
26
- RAW_AAC1 = 255,
27
- DOLBY_AC3_SPDIF = 146,
28
- DVM = 8192,
29
- RAW_SPORT = 576,
30
- ESST_AC3 = 577,
31
- DRM = 9,
32
- DTS2 = 8193,
33
- MPEG = 80
34
- }
20
+ export declare const WaveFormat: {
21
+ PCM: number;
22
+ ADPCM: number;
23
+ IEEE_FLOAT: number;
24
+ MPEG_ADTS_AAC: number;
25
+ MPEG_LOAS: number;
26
+ RAW_AAC1: number;
27
+ DOLBY_AC3_SPDIF: number;
28
+ DVM: number;
29
+ RAW_SPORT: number;
30
+ ESST_AC3: number;
31
+ DRM: number;
32
+ DTS2: number;
33
+ MPEG: number;
34
+ };
35
+ export type WaveFormat = typeof WaveFormat[keyof typeof WaveFormat];
36
+ export declare const WaveFormatNameMap: {
37
+ [WaveFormat.PCM]: string;
38
+ [WaveFormat.ADPCM]: string;
39
+ [WaveFormat.IEEE_FLOAT]: string;
40
+ [WaveFormat.MPEG_ADTS_AAC]: string;
41
+ [WaveFormat.MPEG_LOAS]: string;
42
+ [WaveFormat.RAW_AAC1]: string;
43
+ [WaveFormat.DOLBY_AC3_SPDIF]: string;
44
+ [WaveFormat.DVM]: string;
45
+ [WaveFormat.RAW_SPORT]: string;
46
+ [WaveFormat.ESST_AC3]: string;
47
+ [WaveFormat.DRM]: string;
48
+ [WaveFormat.DTS2]: string;
49
+ [WaveFormat.MPEG]: string;
50
+ };
35
51
  /**
36
52
  * "fmt" sub-chunk describes the sound data's format
37
53
  * Ref: http://soundfile.sapp.org/doc/WaveFormat
@@ -5,24 +5,38 @@ export class WaveContentError extends makeUnexpectedFileContentError('Wave') {
5
5
  /**
6
6
  * Ref: https://msdn.microsoft.com/en-us/library/windows/desktop/dd317599(v=vs.85).aspx
7
7
  */
8
- export var WaveFormat;
9
- (function (WaveFormat) {
10
- WaveFormat[WaveFormat["PCM"] = 1] = "PCM";
8
+ export const WaveFormat = {
9
+ PCM: 0x0001,
11
10
  // MPEG-4 and AAC Audio Types
12
- WaveFormat[WaveFormat["ADPCM"] = 2] = "ADPCM";
13
- WaveFormat[WaveFormat["IEEE_FLOAT"] = 3] = "IEEE_FLOAT";
14
- WaveFormat[WaveFormat["MPEG_ADTS_AAC"] = 5632] = "MPEG_ADTS_AAC";
15
- WaveFormat[WaveFormat["MPEG_LOAS"] = 5634] = "MPEG_LOAS";
16
- WaveFormat[WaveFormat["RAW_AAC1"] = 255] = "RAW_AAC1";
11
+ ADPCM: 0x0002,
12
+ IEEE_FLOAT: 0x0003,
13
+ MPEG_ADTS_AAC: 0x1600,
14
+ MPEG_LOAS: 0x1602,
15
+ RAW_AAC1: 0x00FF,
17
16
  // Dolby Audio Types
18
- WaveFormat[WaveFormat["DOLBY_AC3_SPDIF"] = 146] = "DOLBY_AC3_SPDIF";
19
- WaveFormat[WaveFormat["DVM"] = 8192] = "DVM";
20
- WaveFormat[WaveFormat["RAW_SPORT"] = 576] = "RAW_SPORT";
21
- WaveFormat[WaveFormat["ESST_AC3"] = 577] = "ESST_AC3";
22
- WaveFormat[WaveFormat["DRM"] = 9] = "DRM";
23
- WaveFormat[WaveFormat["DTS2"] = 8193] = "DTS2";
24
- WaveFormat[WaveFormat["MPEG"] = 80] = "MPEG";
25
- })(WaveFormat || (WaveFormat = {}));
17
+ DOLBY_AC3_SPDIF: 0x0092,
18
+ DVM: 0x2000,
19
+ RAW_SPORT: 0x0240,
20
+ ESST_AC3: 0x0241,
21
+ DRM: 0x0009,
22
+ DTS2: 0x2001,
23
+ MPEG: 0x0050
24
+ };
25
+ export const WaveFormatNameMap = {
26
+ [WaveFormat.PCM]: 'PCM',
27
+ [WaveFormat.ADPCM]: 'ADPCM',
28
+ [WaveFormat.IEEE_FLOAT]: 'IEEE_FLOAT',
29
+ [WaveFormat.MPEG_ADTS_AAC]: 'MPEG_ADTS_AAC',
30
+ [WaveFormat.MPEG_LOAS]: 'MPEG_LOAS',
31
+ [WaveFormat.RAW_AAC1]: 'RAW_AAC1',
32
+ [WaveFormat.DOLBY_AC3_SPDIF]: 'DOLBY_AC3_SPDIF',
33
+ [WaveFormat.DVM]: 'DVM',
34
+ [WaveFormat.RAW_SPORT]: 'RAW_SPORT',
35
+ [WaveFormat.ESST_AC3]: 'ESST_AC3',
36
+ [WaveFormat.DRM]: 'DRM',
37
+ [WaveFormat.DTS2]: 'DTS2',
38
+ [WaveFormat.MPEG]: 'MPEG'
39
+ };
26
40
  /**
27
41
  * format chunk; chunk-id is "fmt "
28
42
  * http://soundfile.sapp.org/doc/WaveFormat/
@@ -1,8 +1,8 @@
1
1
  export const riffParserLoader = {
2
2
  parserType: 'riff',
3
3
  extensions: ['.wav', 'wave', '.bwf'],
4
- async load(metadata, tokenizer, options) {
5
- return new (await import('./WaveParser.js')).WaveParser(metadata, tokenizer, options);
4
+ async load() {
5
+ return (await import('./WaveParser.js')).WaveParser;
6
6
  }
7
7
  };
8
8
  //# sourceMappingURL=WaveLoader.js.map
@@ -66,7 +66,7 @@ export class WaveParser extends BasicParser {
66
66
  break;
67
67
  case 'fmt ': { // The Util Chunk, non-PCM Formats
68
68
  const fmt = await this.tokenizer.readToken(new WaveChunk.Format(header));
69
- let subFormat = WaveChunk.WaveFormat[fmt.wFormatTag];
69
+ let subFormat = WaveChunk.WaveFormatNameMap[fmt.wFormatTag];
70
70
  if (!subFormat) {
71
71
  debug(`WAVE/non-PCM format=${fmt.wFormatTag}`);
72
72
  subFormat = `non-PCM (${fmt.wFormatTag})`;
@@ -1,8 +1,8 @@
1
1
  export const wavpackParserLoader = {
2
2
  parserType: 'wavpack',
3
3
  extensions: ['.wv', '.wvp'],
4
- async load(metadata, tokenizer, options) {
5
- return new (await import('./WavPackParser.js')).WavPackParser(metadata, tokenizer, options);
4
+ async load() {
5
+ return (await import('./WavPackParser.js')).WavPackParser;
6
6
  }
7
7
  };
8
8
  //# sourceMappingURL=WavPackLoader.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "music-metadata",
3
3
  "description": "Music metadata parser for Node.js, supporting virtual any audio and tag format.",
4
- "version": "11.0.1",
4
+ "version": "11.0.3",
5
5
  "author": {
6
6
  "name": "Borewit",
7
7
  "url": "https://github.com/Borewit"
@@ -16,6 +16,7 @@
16
16
  "url": "https://buymeacoffee.com/borewit"
17
17
  }
18
18
  ],
19
+ "sideEffects": false,
19
20
  "type": "module",
20
21
  "exports": {
21
22
  "node": {
@@ -99,7 +100,8 @@
99
100
  "build": "yarn run clean && yarn compile && yarn run doc-gen",
100
101
  "test-coverage": "c8 yarn run test",
101
102
  "send-codacy": "c8 report --reporter=text-lcov | codacy-coverage",
102
- "doc-gen": "yarn node doc-gen/gen.js"
103
+ "doc-gen": "yarn node doc-gen/gen.js",
104
+ "typecheck": "tsc --project ./lib/tsconfig.json --noEmit && tsc --project ./test/tsconfig.json --noEmit"
103
105
  },
104
106
  "dependencies": {
105
107
  "@tokenizer/token": "^0.3.0",
@@ -114,13 +116,13 @@
114
116
  },
115
117
  "devDependencies": {
116
118
  "@biomejs/biome": "1.9.4",
117
- "@types/chai": "^5.2.0",
119
+ "@types/chai": "^5.2.1",
118
120
  "@types/chai-as-promised": "^8.0.2",
119
121
  "@types/content-type": "^1.1.8",
120
122
  "@types/debug": "^4.1.12",
121
123
  "@types/media-typer": "^1.1.3",
122
124
  "@types/mocha": "^10.0.10",
123
- "@types/node": "^22.13.10",
125
+ "@types/node": "^22.13.13",
124
126
  "c8": "^10.1.3",
125
127
  "chai": "^5.2.0",
126
128
  "chai-as-promised": "^8.0.1",
@@ -143,5 +145,5 @@
143
145
  "bugs": {
144
146
  "url": "https://github.com/Borewit/music-metadata/issues"
145
147
  },
146
- "packageManager": "yarn@4.6.0"
148
+ "packageManager": "yarn@4.8.1"
147
149
  }