music-metadata 7.12.6 → 8.0.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.
Files changed (154) hide show
  1. package/README.md +47 -31
  2. package/lib/ParserFactory.js +37 -41
  3. package/lib/aiff/AiffParser.js +12 -16
  4. package/lib/aiff/AiffToken.js +4 -8
  5. package/lib/apev2/APEv2Parser.js +29 -32
  6. package/lib/apev2/APEv2TagMapper.js +2 -6
  7. package/lib/apev2/APEv2Token.js +13 -19
  8. package/lib/asf/AsfObject.js +42 -56
  9. package/lib/asf/AsfParser.js +15 -19
  10. package/lib/asf/AsfTagMapper.js +2 -6
  11. package/lib/asf/AsfUtil.js +4 -7
  12. package/lib/asf/GUID.js +1 -4
  13. package/lib/common/BasicParser.js +1 -5
  14. package/lib/common/CaseInsensitiveTagMap.js +2 -6
  15. package/lib/common/CombinedTagMapper.js +20 -24
  16. package/lib/common/FourCC.js +3 -6
  17. package/lib/common/GenericTagMapper.js +2 -6
  18. package/lib/common/GenericTagTypes.js +5 -10
  19. package/lib/common/MetadataCollector.js +20 -25
  20. package/lib/common/RandomFileReader.js +2 -6
  21. package/lib/common/RandomUint8ArrayReader.js +1 -5
  22. package/lib/common/Util.js +11 -25
  23. package/lib/core.js +18 -28
  24. package/lib/dsdiff/DsdiffParser.js +24 -28
  25. package/lib/dsdiff/DsdiffToken.js +4 -7
  26. package/lib/dsf/DsfChunk.js +8 -11
  27. package/lib/dsf/DsfParser.js +13 -17
  28. package/lib/flac/FlacParser.js +22 -26
  29. package/lib/id3v1/ID3v1Parser.js +16 -21
  30. package/lib/id3v1/ID3v1TagMap.js +2 -6
  31. package/lib/id3v2/AbstractID3Parser.js +13 -17
  32. package/lib/id3v2/FrameParser.js +12 -17
  33. package/lib/id3v2/ID3v22TagMapper.js +4 -8
  34. package/lib/id3v2/ID3v24TagMapper.js +5 -9
  35. package/lib/id3v2/ID3v2Parser.js +10 -14
  36. package/lib/id3v2/ID3v2Token.js +9 -12
  37. package/lib/iff/index.js +4 -7
  38. package/lib/index.js +14 -44
  39. package/lib/lyrics3/Lyrics3.js +3 -7
  40. package/lib/matroska/MatroskaDtd.js +111 -114
  41. package/lib/matroska/MatroskaParser.js +20 -24
  42. package/lib/matroska/MatroskaTagMapper.js +2 -6
  43. package/lib/matroska/types.js +6 -9
  44. package/lib/mp4/Atom.js +4 -8
  45. package/lib/mp4/AtomToken.js +29 -44
  46. package/lib/mp4/MP4Parser.js +12 -16
  47. package/lib/mp4/MP4TagMapper.js +4 -8
  48. package/lib/mpeg/ExtendedLameHeader.js +6 -9
  49. package/lib/mpeg/MpegParser.js +17 -21
  50. package/lib/mpeg/ReplayGainDataFormat.js +2 -5
  51. package/lib/mpeg/XingTag.js +9 -13
  52. package/lib/musepack/index.js +10 -12
  53. package/lib/musepack/sv7/BitReader.js +2 -6
  54. package/lib/musepack/sv7/MpcSv7Parser.js +9 -13
  55. package/lib/musepack/sv7/StreamVersion7.js +3 -6
  56. package/lib/musepack/sv8/MpcSv8Parser.js +9 -13
  57. package/lib/musepack/sv8/StreamVersion8.js +5 -9
  58. package/lib/ogg/Ogg.js +1 -2
  59. package/lib/ogg/OggParser.js +19 -24
  60. package/lib/ogg/opus/Opus.js +2 -6
  61. package/lib/ogg/opus/OpusParser.js +4 -8
  62. package/lib/ogg/speex/Speex.js +3 -6
  63. package/lib/ogg/speex/SpeexParser.js +5 -9
  64. package/lib/ogg/theora/Theora.js +2 -5
  65. package/lib/ogg/theora/TheoraParser.js +5 -9
  66. package/lib/ogg/vorbis/Vorbis.js +6 -10
  67. package/lib/ogg/vorbis/VorbisDecoder.js +2 -6
  68. package/lib/ogg/vorbis/VorbisParser.js +18 -22
  69. package/lib/ogg/vorbis/VorbisTagMapper.js +3 -7
  70. package/lib/riff/RiffChunk.js +3 -7
  71. package/lib/riff/RiffInfoTagMap.js +4 -8
  72. package/lib/type.js +1 -5
  73. package/lib/wav/BwfChunk.js +8 -11
  74. package/lib/wav/WaveChunk.js +4 -9
  75. package/lib/wav/WaveParser.js +17 -21
  76. package/lib/wavpack/WavPackParser.js +17 -21
  77. package/lib/wavpack/WavPackToken.js +4 -8
  78. package/package.json +23 -33
  79. package/lib/ParserFactory.d.ts +0 -48
  80. package/lib/aiff/AiffParser.d.ts +0 -14
  81. package/lib/aiff/AiffToken.d.ts +0 -22
  82. package/lib/apev2/APEv2Parser.d.ts +0 -30
  83. package/lib/apev2/APEv2TagMapper.d.ts +0 -4
  84. package/lib/apev2/APEv2Token.d.ts +0 -100
  85. package/lib/asf/AsfObject.d.ts +0 -319
  86. package/lib/asf/AsfParser.d.ts +0 -17
  87. package/lib/asf/AsfTagMapper.d.ts +0 -7
  88. package/lib/asf/AsfUtil.d.ts +0 -13
  89. package/lib/asf/GUID.d.ts +0 -84
  90. package/lib/common/BasicParser.d.ts +0 -17
  91. package/lib/common/CaseInsensitiveTagMap.d.ts +0 -10
  92. package/lib/common/CombinedTagMapper.d.ts +0 -19
  93. package/lib/common/FourCC.d.ts +0 -6
  94. package/lib/common/GenericTagMapper.d.ts +0 -51
  95. package/lib/common/GenericTagTypes.d.ts +0 -33
  96. package/lib/common/MetadataCollector.d.ts +0 -76
  97. package/lib/common/RandomFileReader.d.ts +0 -22
  98. package/lib/common/RandomUint8ArrayReader.d.ts +0 -18
  99. package/lib/common/Util.d.ts +0 -57
  100. package/lib/core.d.ts +0 -48
  101. package/lib/dsdiff/DsdiffParser.d.ts +0 -14
  102. package/lib/dsdiff/DsdiffToken.d.ts +0 -9
  103. package/lib/dsf/DsfChunk.d.ts +0 -86
  104. package/lib/dsf/DsfParser.d.ts +0 -9
  105. package/lib/flac/FlacParser.d.ts +0 -28
  106. package/lib/id3v1/ID3v1Parser.d.ts +0 -13
  107. package/lib/id3v1/ID3v1TagMap.d.ts +0 -4
  108. package/lib/id3v2/AbstractID3Parser.d.ts +0 -17
  109. package/lib/id3v2/FrameParser.d.ts +0 -31
  110. package/lib/id3v2/ID3v22TagMapper.d.ts +0 -9
  111. package/lib/id3v2/ID3v24TagMapper.d.ts +0 -14
  112. package/lib/id3v2/ID3v2Parser.d.ts +0 -28
  113. package/lib/id3v2/ID3v2Token.d.ts +0 -73
  114. package/lib/iff/index.d.ts +0 -33
  115. package/lib/index.d.ts +0 -45
  116. package/lib/lyrics3/Lyrics3.d.ts +0 -3
  117. package/lib/matroska/MatroskaDtd.d.ts +0 -8
  118. package/lib/matroska/MatroskaParser.d.ts +0 -37
  119. package/lib/matroska/MatroskaTagMapper.d.ts +0 -4
  120. package/lib/matroska/types.d.ts +0 -175
  121. package/lib/mp4/Atom.d.ts +0 -16
  122. package/lib/mp4/AtomToken.d.ts +0 -395
  123. package/lib/mp4/MP4Parser.d.ts +0 -30
  124. package/lib/mp4/MP4TagMapper.d.ts +0 -5
  125. package/lib/mpeg/ExtendedLameHeader.d.ts +0 -27
  126. package/lib/mpeg/MpegParser.d.ts +0 -49
  127. package/lib/mpeg/ReplayGainDataFormat.d.ts +0 -55
  128. package/lib/mpeg/XingTag.d.ts +0 -45
  129. package/lib/musepack/index.d.ts +0 -5
  130. package/lib/musepack/sv7/BitReader.d.ts +0 -13
  131. package/lib/musepack/sv7/MpcSv7Parser.d.ts +0 -8
  132. package/lib/musepack/sv7/StreamVersion7.d.ts +0 -28
  133. package/lib/musepack/sv8/MpcSv8Parser.d.ts +0 -6
  134. package/lib/musepack/sv8/StreamVersion8.d.ts +0 -40
  135. package/lib/ogg/Ogg.d.ts +0 -72
  136. package/lib/ogg/OggParser.d.ts +0 -23
  137. package/lib/ogg/opus/Opus.d.ts +0 -48
  138. package/lib/ogg/opus/OpusParser.d.ts +0 -25
  139. package/lib/ogg/speex/Speex.d.ts +0 -36
  140. package/lib/ogg/speex/SpeexParser.d.ts +0 -22
  141. package/lib/ogg/theora/Theora.d.ts +0 -20
  142. package/lib/ogg/theora/TheoraParser.d.ts +0 -28
  143. package/lib/ogg/vorbis/Vorbis.d.ts +0 -69
  144. package/lib/ogg/vorbis/VorbisDecoder.d.ts +0 -12
  145. package/lib/ogg/vorbis/VorbisParser.d.ts +0 -36
  146. package/lib/ogg/vorbis/VorbisTagMapper.d.ts +0 -7
  147. package/lib/riff/RiffChunk.d.ts +0 -16
  148. package/lib/riff/RiffInfoTagMap.d.ts +0 -10
  149. package/lib/type.d.ts +0 -592
  150. package/lib/wav/BwfChunk.d.ts +0 -17
  151. package/lib/wav/WaveChunk.d.ts +0 -64
  152. package/lib/wav/WaveParser.d.ts +0 -24
  153. package/lib/wavpack/WavPackParser.d.ts +0 -14
  154. package/lib/wavpack/WavPackToken.d.ts +0 -64
@@ -1,19 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MpcSv8Parser = void 0;
4
- const debug_1 = require("debug");
5
- const BasicParser_1 = require("../../common/BasicParser");
6
- const APEv2Parser_1 = require("../../apev2/APEv2Parser");
7
- const FourCC_1 = require("../../common/FourCC");
8
- const SV8 = require("./StreamVersion8");
9
- const debug = (0, debug_1.default)('music-metadata:parser:musepack');
10
- class MpcSv8Parser extends BasicParser_1.BasicParser {
1
+ import initDebug from 'debug';
2
+ import { BasicParser } from '../../common/BasicParser.js';
3
+ import { APEv2Parser } from '../../apev2/APEv2Parser.js';
4
+ import { FourCcToken } from '../../common/FourCC.js';
5
+ import * as SV8 from './StreamVersion8.js';
6
+ const debug = initDebug('music-metadata:parser:musepack');
7
+ export class MpcSv8Parser extends BasicParser {
11
8
  constructor() {
12
9
  super(...arguments);
13
10
  this.audioLength = 0;
14
11
  }
15
12
  async parse() {
16
- const signature = await this.tokenizer.readToken(FourCC_1.FourCcToken);
13
+ const signature = await this.tokenizer.readToken(FourCcToken);
17
14
  if (signature !== 'MPCK')
18
15
  throw new Error('Invalid Magic number');
19
16
  this.metadata.setFormat('container', 'Musepack, SV8');
@@ -45,11 +42,10 @@ class MpcSv8Parser extends BasicParser_1.BasicParser {
45
42
  break;
46
43
  case 'SE': // Stream End
47
44
  this.metadata.setFormat('bitrate', this.audioLength * 8 / this.metadata.format.duration);
48
- return APEv2Parser_1.APEv2Parser.tryParseApeHeader(this.metadata, this.tokenizer, this.options);
45
+ return APEv2Parser.tryParseApeHeader(this.metadata, this.tokenizer, this.options);
49
46
  default:
50
47
  throw new Error(`Unexpected header: ${header.key}`);
51
48
  }
52
49
  } while (true);
53
50
  }
54
51
  }
55
- exports.MpcSv8Parser = MpcSv8Parser;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StreamReader = void 0;
4
- const Token = require("token-types");
5
- const debug_1 = require("debug");
6
- const util = require("../../common/Util");
7
- const debug = (0, debug_1.default)('music-metadata:parser:musepack:sv8');
1
+ import * as Token from 'token-types';
2
+ import initDebug from 'debug';
3
+ import * as util from '../../common/Util.js';
4
+ const debug = initDebug('music-metadata:parser:musepack:sv8');
8
5
  const PacketKey = new Token.StringType(2, 'binary');
9
6
  /**
10
7
  * Stream Header Packet part 1
@@ -35,7 +32,7 @@ const SH_part3 = {
35
32
  };
36
33
  }
37
34
  };
38
- class StreamReader {
35
+ export class StreamReader {
39
36
  constructor(tokenizer) {
40
37
  this.tokenizer = tokenizer;
41
38
  }
@@ -77,4 +74,3 @@ class StreamReader {
77
74
  return this.readVariableSizeField(len + 1, n << 7);
78
75
  }
79
76
  }
80
- exports.StreamReader = StreamReader;
package/lib/ogg/Ogg.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OggParser = exports.SegmentTable = void 0;
4
- const Token = require("token-types");
5
- const core_1 = require("strtok3/lib/core");
6
- const debug_1 = require("debug");
7
- const util = require("../common/Util");
8
- const FourCC_1 = require("../common/FourCC");
9
- const BasicParser_1 = require("../common/BasicParser");
10
- const VorbisParser_1 = require("./vorbis/VorbisParser");
11
- const OpusParser_1 = require("./opus/OpusParser");
12
- const SpeexParser_1 = require("./speex/SpeexParser");
13
- const TheoraParser_1 = require("./theora/TheoraParser");
14
- const debug = (0, debug_1.default)('music-metadata:parser:ogg');
15
- class SegmentTable {
1
+ import * as Token from 'token-types';
2
+ import { EndOfStreamError } from 'strtok3/core';
3
+ import initDebug from 'debug';
4
+ import * as util from '../common/Util.js';
5
+ import { FourCcToken } from '../common/FourCC.js';
6
+ import { BasicParser } from '../common/BasicParser.js';
7
+ import { VorbisParser } from './vorbis/VorbisParser.js';
8
+ import { OpusParser } from './opus/OpusParser.js';
9
+ import { SpeexParser } from './speex/SpeexParser.js';
10
+ import { TheoraParser } from './theora/TheoraParser.js';
11
+ const debug = initDebug('music-metadata:parser:ogg');
12
+ export class SegmentTable {
16
13
  constructor(header) {
17
14
  this.len = header.page_segments;
18
15
  }
@@ -29,11 +26,10 @@ class SegmentTable {
29
26
  };
30
27
  }
31
28
  }
32
- exports.SegmentTable = SegmentTable;
33
29
  /**
34
30
  * Parser for Ogg logical bitstream framing
35
31
  */
36
- class OggParser extends BasicParser_1.BasicParser {
32
+ export class OggParser extends BasicParser {
37
33
  /**
38
34
  * Parse page
39
35
  * @returns {Promise<void>}
@@ -59,20 +55,20 @@ class OggParser extends BasicParser_1.BasicParser {
59
55
  switch (id) {
60
56
  case '\x01vorbis': // Ogg/Vorbis
61
57
  debug('Set page consumer to Ogg/Vorbis');
62
- this.pageConsumer = new VorbisParser_1.VorbisParser(this.metadata, this.options);
58
+ this.pageConsumer = new VorbisParser(this.metadata, this.options);
63
59
  break;
64
60
  case 'OpusHea': // Ogg/Opus
65
61
  debug('Set page consumer to Ogg/Opus');
66
- this.pageConsumer = new OpusParser_1.OpusParser(this.metadata, this.options, this.tokenizer);
62
+ this.pageConsumer = new OpusParser(this.metadata, this.options, this.tokenizer);
67
63
  break;
68
64
  case 'Speex ': // Ogg/Speex
69
65
  debug('Set page consumer to Ogg/Speex');
70
- this.pageConsumer = new SpeexParser_1.SpeexParser(this.metadata, this.options, this.tokenizer);
66
+ this.pageConsumer = new SpeexParser(this.metadata, this.options, this.tokenizer);
71
67
  break;
72
68
  case 'fishead':
73
69
  case '\x00theora': // Ogg/Theora
74
70
  debug('Set page consumer to Ogg/Theora');
75
- this.pageConsumer = new TheoraParser_1.TheoraParser(this.metadata, this.options, this.tokenizer);
71
+ this.pageConsumer = new TheoraParser(this.metadata, this.options, this.tokenizer);
76
72
  break;
77
73
  default:
78
74
  throw new Error('gg audio-codec not recognized (id=' + id + ')');
@@ -82,7 +78,7 @@ class OggParser extends BasicParser_1.BasicParser {
82
78
  } while (!header.headerType.lastPage);
83
79
  }
84
80
  catch (err) {
85
- if (err instanceof core_1.EndOfStreamError) {
81
+ if (err instanceof EndOfStreamError) {
86
82
  this.metadata.addWarning('Last OGG-page is not marked with last-page flag');
87
83
  debug(`End-of-stream`);
88
84
  this.metadata.addWarning('Last OGG-page is not marked with last-page flag');
@@ -103,12 +99,11 @@ class OggParser extends BasicParser_1.BasicParser {
103
99
  }
104
100
  }
105
101
  }
106
- exports.OggParser = OggParser;
107
102
  OggParser.Header = {
108
103
  len: 27,
109
104
  get: (buf, off) => {
110
105
  return {
111
- capturePattern: FourCC_1.FourCcToken.get(buf, off),
106
+ capturePattern: FourCcToken.get(buf, off),
112
107
  version: Token.UINT8.get(buf, off + 4),
113
108
  headerType: {
114
109
  continued: util.getBit(buf, off + 5, 0),
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IdHeader = void 0;
4
- const Token = require("token-types");
1
+ import * as Token from 'token-types';
5
2
  /**
6
3
  * Opus ID Header parser
7
4
  * Ref: https://wiki.xiph.org/OggOpus#ID_Header
8
5
  */
9
- class IdHeader {
6
+ export class IdHeader {
10
7
  constructor(len) {
11
8
  this.len = len;
12
9
  if (len < 19) {
@@ -25,4 +22,3 @@ class IdHeader {
25
22
  };
26
23
  }
27
24
  }
28
- exports.IdHeader = IdHeader;
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OpusParser = void 0;
4
- const Token = require("token-types");
5
- const VorbisParser_1 = require("../vorbis/VorbisParser");
6
- const Opus = require("./Opus");
1
+ import * as Token from 'token-types';
2
+ import { VorbisParser } from '../vorbis/VorbisParser.js';
3
+ import * as Opus from './Opus.js';
7
4
  /**
8
5
  * Opus parser
9
6
  * Internet Engineering Task Force (IETF) - RFC 6716
10
7
  * Used by OggParser
11
8
  */
12
- class OpusParser extends VorbisParser_1.VorbisParser {
9
+ export class OpusParser extends VorbisParser {
13
10
  constructor(metadata, options, tokenizer) {
14
11
  super(metadata, options);
15
12
  this.tokenizer = tokenizer;
@@ -53,4 +50,3 @@ class OpusParser extends VorbisParser_1.VorbisParser {
53
50
  }
54
51
  }
55
52
  }
56
- exports.OpusParser = OpusParser;
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Header = void 0;
4
- const Token = require("token-types");
5
- const util = require("../../common/Util");
1
+ import * as Token from 'token-types';
2
+ import * as util from '../../common/Util.js';
6
3
  /**
7
4
  * Speex Header Packet
8
5
  * Ref: https://www.speex.org/docs/manual/speex-manual/node8.html#SECTION00830000000000000000
9
6
  */
10
- exports.Header = {
7
+ export const Header = {
11
8
  len: 80,
12
9
  get: (buf, off) => {
13
10
  return {
@@ -1,17 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SpeexParser = void 0;
4
- const debug_1 = require("debug");
5
- const VorbisParser_1 = require("../vorbis/VorbisParser");
6
- const Speex = require("./Speex");
7
- const debug = (0, debug_1.default)('music-metadata:parser:ogg:speex');
1
+ import initDebug from 'debug';
2
+ import { VorbisParser } from '../vorbis/VorbisParser.js';
3
+ import * as Speex from './Speex.js';
4
+ const debug = initDebug('music-metadata:parser:ogg:speex');
8
5
  /**
9
6
  * Speex, RFC 5574
10
7
  * Ref:
11
8
  * - https://www.speex.org/docs/manual/speex-manual/
12
9
  * - https://tools.ietf.org/html/rfc5574
13
10
  */
14
- class SpeexParser extends VorbisParser_1.VorbisParser {
11
+ export class SpeexParser extends VorbisParser {
15
12
  constructor(metadata, options, tokenizer) {
16
13
  super(metadata, options);
17
14
  this.tokenizer = tokenizer;
@@ -32,4 +29,3 @@ class SpeexParser extends VorbisParser_1.VorbisParser {
32
29
  }
33
30
  }
34
31
  }
35
- exports.SpeexParser = SpeexParser;
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IdentificationHeader = void 0;
4
- const Token = require("token-types");
1
+ import * as Token from 'token-types';
5
2
  /**
6
3
  * 6.2 Identification Header
7
4
  * Ref: https://theora.org/doc/Theora.pdf: 6.2 Identification Header Decode
8
5
  */
9
- exports.IdentificationHeader = {
6
+ export const IdentificationHeader = {
10
7
  len: 42,
11
8
  get: (buf, off) => {
12
9
  return {
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TheoraParser = void 0;
4
- const debug_1 = require("debug");
5
- const Theora_1 = require("./Theora");
6
- const debug = (0, debug_1.default)('music-metadata:parser:ogg:theora');
1
+ import initDebug from 'debug';
2
+ import { IdentificationHeader } from './Theora.js';
3
+ const debug = initDebug('music-metadata:parser:ogg:theora');
7
4
  /**
8
5
  * Ref:
9
6
  * - https://theora.org/doc/Theora.pdf
10
7
  */
11
- class TheoraParser {
8
+ export class TheoraParser {
12
9
  constructor(metadata, options, tokenizer) {
13
10
  this.metadata = metadata;
14
11
  this.tokenizer = tokenizer;
@@ -37,8 +34,7 @@ class TheoraParser {
37
34
  parseFirstPage(header, pageData) {
38
35
  debug('First Ogg/Theora page');
39
36
  this.metadata.setFormat('codec', 'Theora');
40
- const idHeader = Theora_1.IdentificationHeader.get(pageData, 0);
37
+ const idHeader = IdentificationHeader.get(pageData, 0);
41
38
  this.metadata.setFormat('bitrate', idHeader.nombr);
42
39
  }
43
40
  }
44
- exports.TheoraParser = TheoraParser;
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IdentificationHeader = exports.CommonHeader = exports.VorbisPictureToken = void 0;
4
- const Token = require("token-types");
5
- const ID3v2Token_1 = require("../../id3v2/ID3v2Token");
1
+ import * as Token from 'token-types';
2
+ import { AttachedPictureType } from '../../id3v2/ID3v2Token.js';
6
3
  /**
7
4
  * Parse the METADATA_BLOCK_PICTURE
8
5
  * Ref: https://wiki.xiph.org/VorbisComment#METADATA_BLOCK_PICTURE
9
6
  * Ref: https://xiph.org/flac/format.html#metadata_block_picture
10
7
  * // ToDo: move to ID3 / APIC?
11
8
  */
12
- class VorbisPictureToken {
9
+ export class VorbisPictureToken {
13
10
  constructor(len) {
14
11
  this.len = len;
15
12
  }
@@ -21,7 +18,7 @@ class VorbisPictureToken {
21
18
  return pic.get(buffer, 0);
22
19
  }
23
20
  get(buffer, offset) {
24
- const type = ID3v2Token_1.AttachedPictureType[Token.UINT32_BE.get(buffer, offset)];
21
+ const type = AttachedPictureType[Token.UINT32_BE.get(buffer, offset)];
25
22
  const mimeLen = Token.UINT32_BE.get(buffer, offset += 4);
26
23
  const format = buffer.toString('utf-8', offset += 4, offset + mimeLen);
27
24
  const descLen = Token.UINT32_BE.get(buffer, offset += mimeLen);
@@ -44,12 +41,11 @@ class VorbisPictureToken {
44
41
  };
45
42
  }
46
43
  }
47
- exports.VorbisPictureToken = VorbisPictureToken;
48
44
  /**
49
45
  * Comment header decoder
50
46
  * Ref: https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-620004.2.1
51
47
  */
52
- exports.CommonHeader = {
48
+ export const CommonHeader = {
53
49
  len: 7,
54
50
  get: (buf, off) => {
55
51
  return {
@@ -62,7 +58,7 @@ exports.CommonHeader = {
62
58
  * Identification header decoder
63
59
  * Ref: https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-630004.2.2
64
60
  */
65
- exports.IdentificationHeader = {
61
+ export const IdentificationHeader = {
66
62
  len: 23,
67
63
  get: (uint8Array, off) => {
68
64
  const dataView = new DataView(uint8Array.buffer, uint8Array.byteOffset);
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VorbisDecoder = void 0;
4
- const Token = require("token-types");
5
- class VorbisDecoder {
1
+ import * as Token from 'token-types';
2
+ export class VorbisDecoder {
6
3
  constructor(data, offset) {
7
4
  this.data = data;
8
5
  this.offset = offset;
@@ -29,4 +26,3 @@ class VorbisDecoder {
29
26
  };
30
27
  }
31
28
  }
32
- exports.VorbisDecoder = VorbisDecoder;
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VorbisParser = void 0;
4
- const Token = require("token-types");
5
- const debug_1 = require("debug");
6
- const VorbisDecoder_1 = require("./VorbisDecoder");
7
- const Vorbis_1 = require("./Vorbis");
8
- const debug = (0, debug_1.default)('music-metadata:parser:ogg:vorbis1');
1
+ import * as Token from 'token-types';
2
+ import debugInit from 'debug';
3
+ import { VorbisDecoder } from './VorbisDecoder.js';
4
+ import { CommonHeader, IdentificationHeader, VorbisPictureToken } from './Vorbis.js';
5
+ const debug = debugInit('music-metadata:parser:ogg:vorbis1');
9
6
  /**
10
7
  * Vorbis 1 Parser.
11
8
  * Used by OggParser
12
9
  */
13
- class VorbisParser {
10
+ export class VorbisParser {
14
11
  constructor(metadata, options) {
15
12
  this.metadata = metadata;
16
13
  this.options = options;
@@ -28,7 +25,7 @@ class VorbisParser {
28
25
  else {
29
26
  if (header.headerType.continued) {
30
27
  if (this.pageSegments.length === 0) {
31
- throw new Error("Cannot continue on previous page");
28
+ throw new Error('Cannot continue on previous page');
32
29
  }
33
30
  this.pageSegments.push(pageData);
34
31
  }
@@ -50,7 +47,7 @@ class VorbisParser {
50
47
  this.parseFullPage(Buffer.concat(this.pageSegments));
51
48
  }
52
49
  parseUserComment(pageData, offset) {
53
- const decoder = new VorbisDecoder_1.VorbisDecoder(pageData, offset);
50
+ const decoder = new VorbisDecoder(pageData, offset);
54
51
  const tag = decoder.parseUserComment();
55
52
  this.addTag(tag.key, tag.value);
56
53
  return tag.len;
@@ -61,7 +58,7 @@ class VorbisParser {
61
58
  debug(`Ignore picture`);
62
59
  return;
63
60
  }
64
- value = Vorbis_1.VorbisPictureToken.fromBase64(value);
61
+ value = VorbisPictureToken.fromBase64(value);
65
62
  debug(`Push picture: id=${id}, format=${value.format}`);
66
63
  }
67
64
  else {
@@ -78,33 +75,33 @@ class VorbisParser {
78
75
  }
79
76
  /**
80
77
  * Parse first Ogg/Vorbis page
81
- * @param {IPageHeader} header
82
- * @param {Buffer} pageData
78
+ * @param header
79
+ * @param pageData
83
80
  */
84
81
  parseFirstPage(header, pageData) {
85
82
  this.metadata.setFormat('codec', 'Vorbis I');
86
- debug("Parse first page");
83
+ debug('Parse first page');
87
84
  // Parse Vorbis common header
88
- const commonHeader = Vorbis_1.CommonHeader.get(pageData, 0);
85
+ const commonHeader = CommonHeader.get(pageData, 0);
89
86
  if (commonHeader.vorbis !== 'vorbis')
90
87
  throw new Error('Metadata does not look like Vorbis');
91
88
  if (commonHeader.packetType === 1) {
92
- const idHeader = Vorbis_1.IdentificationHeader.get(pageData, Vorbis_1.CommonHeader.len);
89
+ const idHeader = IdentificationHeader.get(pageData, CommonHeader.len);
93
90
  this.metadata.setFormat('sampleRate', idHeader.sampleRate);
94
91
  this.metadata.setFormat('bitrate', idHeader.bitrateNominal);
95
92
  this.metadata.setFormat('numberOfChannels', idHeader.channelMode);
96
- debug("sample-rate=%s[hz], bitrate=%s[b/s], channel-mode=%s", idHeader.sampleRate, idHeader.bitrateNominal, idHeader.channelMode);
93
+ debug('sample-rate=%s[hz], bitrate=%s[b/s], channel-mode=%s', idHeader.sampleRate, idHeader.bitrateNominal, idHeader.channelMode);
97
94
  }
98
95
  else
99
96
  throw new Error('First Ogg page should be type 1: the identification header');
100
97
  }
101
98
  parseFullPage(pageData) {
102
99
  // New page
103
- const commonHeader = Vorbis_1.CommonHeader.get(pageData, 0);
104
- debug("Parse full page: type=%s, byteLength=%s", commonHeader.packetType, pageData.byteLength);
100
+ const commonHeader = CommonHeader.get(pageData, 0);
101
+ debug('Parse full page: type=%s, byteLength=%s', commonHeader.packetType, pageData.byteLength);
105
102
  switch (commonHeader.packetType) {
106
103
  case 3: // type 3: comment header
107
- return this.parseUserCommentList(pageData, Vorbis_1.CommonHeader.len);
104
+ return this.parseUserCommentList(pageData, CommonHeader.len);
108
105
  case 1: // type 1: the identification header
109
106
  case 5: // type 5: setup header type
110
107
  break; // ignore
@@ -125,4 +122,3 @@ class VorbisParser {
125
122
  }
126
123
  }
127
124
  }
128
- exports.VorbisParser = VorbisParser;
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VorbisTagMapper = void 0;
4
- const GenericTagMapper_1 = require("../../common/GenericTagMapper");
1
+ import { CommonTagMapper } from '../../common/GenericTagMapper.js';
5
2
  /**
6
3
  * Vorbis tag mappings
7
4
  *
@@ -111,11 +108,11 @@ const vorbisTagMap = {
111
108
  REPLAYGAIN_ALBUM_MINMAX: 'replaygain_album_minmax',
112
109
  REPLAYGAIN_UNDO: 'replaygain_undo'
113
110
  };
114
- class VorbisTagMapper extends GenericTagMapper_1.CommonTagMapper {
111
+ export class VorbisTagMapper extends CommonTagMapper {
115
112
  static toRating(email, rating) {
116
113
  return {
117
114
  source: email ? email.toLowerCase() : email,
118
- rating: parseFloat(rating) * GenericTagMapper_1.CommonTagMapper.maxRatingScore
115
+ rating: parseFloat(rating) * CommonTagMapper.maxRatingScore
119
116
  };
120
117
  }
121
118
  constructor() {
@@ -129,5 +126,4 @@ class VorbisTagMapper extends GenericTagMapper_1.CommonTagMapper {
129
126
  }
130
127
  }
131
128
  }
132
- exports.VorbisTagMapper = VorbisTagMapper;
133
129
  //# sourceMappingURL=VorbisTagMapper.js.map
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ListInfoTagValue = exports.Header = void 0;
4
- const Token = require("token-types");
1
+ import * as Token from 'token-types';
5
2
  /**
6
3
  * Common RIFF chunk header
7
4
  */
8
- exports.Header = {
5
+ export const Header = {
9
6
  len: 8,
10
7
  get: (buf, off) => {
11
8
  return {
@@ -19,7 +16,7 @@ exports.Header = {
19
16
  /**
20
17
  * Token to parse RIFF-INFO tag value
21
18
  */
22
- class ListInfoTagValue {
19
+ export class ListInfoTagValue {
23
20
  constructor(tagHeader) {
24
21
  this.tagHeader = tagHeader;
25
22
  this.len = tagHeader.chunkSize;
@@ -29,4 +26,3 @@ class ListInfoTagValue {
29
26
  return new Token.StringType(this.tagHeader.chunkSize, 'ascii').get(buf, off);
30
27
  }
31
28
  }
32
- exports.ListInfoTagValue = ListInfoTagValue;
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RiffInfoTagMapper = exports.riffInfoTagMap = void 0;
4
- const GenericTagMapper_1 = require("../common/GenericTagMapper");
1
+ import { CommonTagMapper } from '../common/GenericTagMapper.js';
5
2
  /**
6
3
  * RIFF Info Tags; part of the EXIF 2.3
7
4
  * Ref: http://owl.phy.queensu.ca/~phil/exiftool/TagNames/RIFF.html#Info
8
5
  */
9
- exports.riffInfoTagMap = {
6
+ export const riffInfoTagMap = {
10
7
  IART: 'artist',
11
8
  ICRD: 'date',
12
9
  INAM: 'title',
@@ -29,10 +26,9 @@ exports.riffInfoTagMap = {
29
26
  IMED: 'media',
30
27
  IRPD: 'album' // Product, where the file was intended for
31
28
  };
32
- class RiffInfoTagMapper extends GenericTagMapper_1.CommonTagMapper {
29
+ export class RiffInfoTagMapper extends CommonTagMapper {
33
30
  constructor() {
34
- super(['exif'], exports.riffInfoTagMap);
31
+ super(['exif'], riffInfoTagMap);
35
32
  }
36
33
  }
37
- exports.RiffInfoTagMapper = RiffInfoTagMapper;
38
34
  //# sourceMappingURL=RiffInfoTagMap.js.map
package/lib/type.js CHANGED
@@ -1,6 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TrackType = void 0;
4
- var types_1 = require("./matroska/types");
5
- Object.defineProperty(exports, "TrackType", { enumerable: true, get: function () { return types_1.TrackType; } });
1
+ export { TrackType } from './matroska/types.js';
6
2
  //# sourceMappingURL=type.js.map
@@ -1,21 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BroadcastAudioExtensionChunk = void 0;
4
- const Token = require("token-types");
5
- const Util_1 = require("../common/Util");
1
+ import * as Token from 'token-types';
2
+ import { stripNulls } from '../common/Util.js';
6
3
  /**
7
4
  * Broadcast Audio Extension Chunk
8
5
  * Ref: https://tech.ebu.ch/docs/tech/tech3285.pdf
9
6
  */
10
- exports.BroadcastAudioExtensionChunk = {
7
+ export const BroadcastAudioExtensionChunk = {
11
8
  len: 420,
12
9
  get: (uint8array, off) => {
13
10
  return {
14
- description: (0, Util_1.stripNulls)(new Token.StringType(256, 'ascii').get(uint8array, off)).trim(),
15
- originator: (0, Util_1.stripNulls)(new Token.StringType(32, 'ascii').get(uint8array, off + 256)).trim(),
16
- originatorReference: (0, Util_1.stripNulls)(new Token.StringType(32, 'ascii').get(uint8array, off + 288)).trim(),
17
- originationDate: (0, Util_1.stripNulls)(new Token.StringType(10, 'ascii').get(uint8array, off + 320)).trim(),
18
- originationTime: (0, Util_1.stripNulls)(new Token.StringType(8, 'ascii').get(uint8array, off + 330)).trim(),
11
+ description: stripNulls(new Token.StringType(256, 'ascii').get(uint8array, off)).trim(),
12
+ originator: stripNulls(new Token.StringType(32, 'ascii').get(uint8array, off + 256)).trim(),
13
+ originatorReference: stripNulls(new Token.StringType(32, 'ascii').get(uint8array, off + 288)).trim(),
14
+ originationDate: stripNulls(new Token.StringType(10, 'ascii').get(uint8array, off + 320)).trim(),
15
+ originationTime: stripNulls(new Token.StringType(8, 'ascii').get(uint8array, off + 330)).trim(),
19
16
  timeReferenceLow: Token.UINT32_LE.get(uint8array, off + 338),
20
17
  timeReferenceHigh: Token.UINT32_LE.get(uint8array, off + 342),
21
18
  version: Token.UINT16_LE.get(uint8array, off + 346),
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FactChunk = exports.Format = exports.WaveFormat = void 0;
4
1
  /**
5
2
  * Ref: https://msdn.microsoft.com/en-us/library/windows/desktop/dd317599(v=vs.85).aspx
6
3
  */
7
- var WaveFormat;
4
+ export var WaveFormat;
8
5
  (function (WaveFormat) {
9
6
  WaveFormat[WaveFormat["PCM"] = 1] = "PCM";
10
7
  // MPEG-4 and AAC Audio Types
@@ -21,12 +18,12 @@ var WaveFormat;
21
18
  WaveFormat[WaveFormat["DRM"] = 9] = "DRM";
22
19
  WaveFormat[WaveFormat["DTS2"] = 8193] = "DTS2";
23
20
  WaveFormat[WaveFormat["MPEG"] = 80] = "MPEG";
24
- })(WaveFormat = exports.WaveFormat || (exports.WaveFormat = {}));
21
+ })(WaveFormat = WaveFormat || (WaveFormat = {}));
25
22
  /**
26
23
  * format chunk; chunk-id is "fmt "
27
24
  * http://soundfile.sapp.org/doc/WaveFormat/
28
25
  */
29
- class Format {
26
+ export class Format {
30
27
  constructor(header) {
31
28
  if (header.chunkSize < 16)
32
29
  throw new Error('Invalid chunk size');
@@ -43,13 +40,12 @@ class Format {
43
40
  };
44
41
  }
45
42
  }
46
- exports.Format = Format;
47
43
  /**
48
44
  * Fact chunk; chunk-id is "fact"
49
45
  * http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html
50
46
  * http://www.recordingblogs.com/wiki/fact-chunk-of-a-wave-file
51
47
  */
52
- class FactChunk {
48
+ export class FactChunk {
53
49
  constructor(header) {
54
50
  if (header.chunkSize < 4) {
55
51
  throw new Error('Invalid fact chunk size.');
@@ -62,4 +58,3 @@ class FactChunk {
62
58
  };
63
59
  }
64
60
  }
65
- exports.FactChunk = FactChunk;