music-metadata 7.12.5 → 8.0.1

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 (152) hide show
  1. package/README.md +47 -31
  2. package/lib/ParserFactory.d.ts +3 -3
  3. package/lib/ParserFactory.js +37 -41
  4. package/lib/aiff/AiffParser.d.ts +2 -2
  5. package/lib/aiff/AiffParser.js +25 -17
  6. package/lib/aiff/AiffToken.d.ts +3 -2
  7. package/lib/aiff/AiffToken.js +13 -12
  8. package/lib/apev2/APEv2Parser.d.ts +5 -5
  9. package/lib/apev2/APEv2Parser.js +29 -32
  10. package/lib/apev2/APEv2TagMapper.d.ts +1 -1
  11. package/lib/apev2/APEv2TagMapper.js +2 -6
  12. package/lib/apev2/APEv2Token.d.ts +1 -1
  13. package/lib/apev2/APEv2Token.js +13 -19
  14. package/lib/asf/AsfObject.d.ts +5 -4
  15. package/lib/asf/AsfObject.js +42 -56
  16. package/lib/asf/AsfParser.d.ts +1 -1
  17. package/lib/asf/AsfParser.js +15 -19
  18. package/lib/asf/AsfTagMapper.d.ts +2 -2
  19. package/lib/asf/AsfTagMapper.js +2 -6
  20. package/lib/asf/AsfUtil.d.ts +3 -2
  21. package/lib/asf/AsfUtil.js +4 -7
  22. package/lib/asf/GUID.d.ts +1 -1
  23. package/lib/asf/GUID.js +1 -4
  24. package/lib/browser.js +99 -0
  25. package/lib/common/BasicParser.d.ts +4 -4
  26. package/lib/common/BasicParser.js +1 -5
  27. package/lib/common/CaseInsensitiveTagMap.d.ts +3 -3
  28. package/lib/common/CaseInsensitiveTagMap.js +2 -6
  29. package/lib/common/CombinedTagMapper.d.ts +4 -4
  30. package/lib/common/CombinedTagMapper.js +20 -24
  31. package/lib/common/FourCC.d.ts +1 -1
  32. package/lib/common/FourCC.js +3 -6
  33. package/lib/common/GenericTagMapper.d.ts +4 -4
  34. package/lib/common/GenericTagMapper.js +2 -6
  35. package/lib/common/GenericTagTypes.js +5 -10
  36. package/lib/common/MetadataCollector.d.ts +2 -2
  37. package/lib/common/MetadataCollector.js +20 -25
  38. package/lib/common/RandomFileReader.d.ts +2 -2
  39. package/lib/common/RandomFileReader.js +2 -6
  40. package/lib/common/RandomUint8ArrayReader.d.ts +1 -1
  41. package/lib/common/RandomUint8ArrayReader.js +1 -5
  42. package/lib/common/Util.d.ts +1 -1
  43. package/lib/common/Util.js +11 -25
  44. package/lib/core.d.ts +4 -4
  45. package/lib/core.js +18 -28
  46. package/lib/dsdiff/DsdiffParser.d.ts +1 -1
  47. package/lib/dsdiff/DsdiffParser.js +24 -28
  48. package/lib/dsdiff/DsdiffToken.d.ts +3 -3
  49. package/lib/dsdiff/DsdiffToken.js +4 -7
  50. package/lib/dsf/DsfChunk.d.ts +1 -1
  51. package/lib/dsf/DsfChunk.js +8 -11
  52. package/lib/dsf/DsfParser.d.ts +1 -1
  53. package/lib/dsf/DsfParser.js +13 -17
  54. package/lib/flac/FlacParser.d.ts +5 -5
  55. package/lib/flac/FlacParser.js +22 -26
  56. package/lib/id3v1/ID3v1Parser.d.ts +2 -2
  57. package/lib/id3v1/ID3v1Parser.js +16 -21
  58. package/lib/id3v1/ID3v1TagMap.d.ts +1 -1
  59. package/lib/id3v1/ID3v1TagMap.js +2 -6
  60. package/lib/id3v2/AbstractID3Parser.d.ts +2 -2
  61. package/lib/id3v2/AbstractID3Parser.js +13 -17
  62. package/lib/id3v2/FrameParser.d.ts +2 -2
  63. package/lib/id3v2/FrameParser.js +12 -17
  64. package/lib/id3v2/ID3v22TagMapper.d.ts +2 -2
  65. package/lib/id3v2/ID3v22TagMapper.js +4 -8
  66. package/lib/id3v2/ID3v24TagMapper.d.ts +3 -3
  67. package/lib/id3v2/ID3v24TagMapper.js +5 -9
  68. package/lib/id3v2/ID3v2Parser.d.ts +3 -3
  69. package/lib/id3v2/ID3v2Parser.js +10 -14
  70. package/lib/id3v2/ID3v2Token.d.ts +2 -2
  71. package/lib/id3v2/ID3v2Token.js +9 -12
  72. package/lib/iff/index.d.ts +1 -1
  73. package/lib/iff/index.js +4 -7
  74. package/lib/index.d.ts +4 -28
  75. package/lib/index.js +14 -44
  76. package/lib/lyrics3/Lyrics3.d.ts +1 -1
  77. package/lib/lyrics3/Lyrics3.js +3 -7
  78. package/lib/matroska/MatroskaDtd.d.ts +1 -1
  79. package/lib/matroska/MatroskaDtd.js +111 -114
  80. package/lib/matroska/MatroskaParser.d.ts +5 -5
  81. package/lib/matroska/MatroskaParser.js +20 -24
  82. package/lib/matroska/MatroskaTagMapper.d.ts +1 -1
  83. package/lib/matroska/MatroskaTagMapper.js +2 -6
  84. package/lib/matroska/types.d.ts +1 -1
  85. package/lib/matroska/types.js +6 -9
  86. package/lib/mp4/Atom.d.ts +2 -2
  87. package/lib/mp4/Atom.js +4 -8
  88. package/lib/mp4/AtomToken.d.ts +2 -2
  89. package/lib/mp4/AtomToken.js +29 -44
  90. package/lib/mp4/MP4Parser.d.ts +2 -2
  91. package/lib/mp4/MP4Parser.js +12 -16
  92. package/lib/mp4/MP4TagMapper.d.ts +1 -1
  93. package/lib/mp4/MP4TagMapper.js +4 -8
  94. package/lib/mpeg/ExtendedLameHeader.d.ts +2 -2
  95. package/lib/mpeg/ExtendedLameHeader.js +6 -9
  96. package/lib/mpeg/MpegParser.d.ts +1 -1
  97. package/lib/mpeg/MpegParser.js +17 -21
  98. package/lib/mpeg/ReplayGainDataFormat.d.ts +1 -1
  99. package/lib/mpeg/ReplayGainDataFormat.js +2 -5
  100. package/lib/mpeg/XingTag.d.ts +3 -3
  101. package/lib/mpeg/XingTag.js +9 -13
  102. package/lib/musepack/index.d.ts +1 -1
  103. package/lib/musepack/index.js +10 -12
  104. package/lib/musepack/sv7/BitReader.d.ts +1 -1
  105. package/lib/musepack/sv7/BitReader.js +2 -6
  106. package/lib/musepack/sv7/MpcSv7Parser.d.ts +1 -1
  107. package/lib/musepack/sv7/MpcSv7Parser.js +9 -13
  108. package/lib/musepack/sv7/StreamVersion7.d.ts +1 -1
  109. package/lib/musepack/sv7/StreamVersion7.js +3 -6
  110. package/lib/musepack/sv8/MpcSv8Parser.d.ts +1 -1
  111. package/lib/musepack/sv8/MpcSv8Parser.js +9 -13
  112. package/lib/musepack/sv8/StreamVersion8.d.ts +1 -1
  113. package/lib/musepack/sv8/StreamVersion8.js +5 -9
  114. package/lib/ogg/Ogg.js +1 -2
  115. package/lib/ogg/OggParser.d.ts +3 -3
  116. package/lib/ogg/OggParser.js +19 -24
  117. package/lib/ogg/opus/Opus.d.ts +1 -1
  118. package/lib/ogg/opus/Opus.js +2 -6
  119. package/lib/ogg/opus/OpusParser.d.ts +6 -6
  120. package/lib/ogg/opus/OpusParser.js +4 -8
  121. package/lib/ogg/speex/Speex.d.ts +1 -1
  122. package/lib/ogg/speex/Speex.js +3 -6
  123. package/lib/ogg/speex/SpeexParser.d.ts +6 -6
  124. package/lib/ogg/speex/SpeexParser.js +5 -9
  125. package/lib/ogg/theora/Theora.d.ts +1 -1
  126. package/lib/ogg/theora/Theora.js +2 -5
  127. package/lib/ogg/theora/TheoraParser.d.ts +5 -5
  128. package/lib/ogg/theora/TheoraParser.js +5 -9
  129. package/lib/ogg/vorbis/Vorbis.d.ts +3 -3
  130. package/lib/ogg/vorbis/Vorbis.js +6 -10
  131. package/lib/ogg/vorbis/VorbisDecoder.js +2 -6
  132. package/lib/ogg/vorbis/VorbisParser.d.ts +11 -11
  133. package/lib/ogg/vorbis/VorbisParser.js +18 -22
  134. package/lib/ogg/vorbis/VorbisTagMapper.d.ts +2 -2
  135. package/lib/ogg/vorbis/VorbisTagMapper.js +3 -7
  136. package/lib/riff/RiffChunk.d.ts +3 -3
  137. package/lib/riff/RiffChunk.js +3 -7
  138. package/lib/riff/RiffInfoTagMap.d.ts +2 -2
  139. package/lib/riff/RiffInfoTagMap.js +4 -8
  140. package/lib/type.d.ts +6 -5
  141. package/lib/type.js +1 -5
  142. package/lib/wav/BwfChunk.d.ts +1 -1
  143. package/lib/wav/BwfChunk.js +8 -11
  144. package/lib/wav/WaveChunk.d.ts +3 -3
  145. package/lib/wav/WaveChunk.js +4 -9
  146. package/lib/wav/WaveParser.d.ts +2 -2
  147. package/lib/wav/WaveParser.js +17 -21
  148. package/lib/wavpack/WavPackParser.d.ts +1 -1
  149. package/lib/wavpack/WavPackParser.js +17 -21
  150. package/lib/wavpack/WavPackToken.d.ts +1 -1
  151. package/lib/wavpack/WavPackToken.js +4 -8
  152. package/package.json +29 -41
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BitReader = void 0;
4
- const Token = require("token-types");
5
- class BitReader {
1
+ import * as Token from 'token-types';
2
+ export class BitReader {
6
3
  constructor(tokenizer) {
7
4
  this.tokenizer = tokenizer;
8
5
  this.pos = 0;
@@ -51,4 +48,3 @@ class BitReader {
51
48
  return this.read(remainder);
52
49
  }
53
50
  }
54
- exports.BitReader = BitReader;
@@ -1,4 +1,4 @@
1
- import { BasicParser } from '../../common/BasicParser';
1
+ import { BasicParser } from '../../common/BasicParser.js';
2
2
  export declare class MpcSv7Parser extends BasicParser {
3
3
  private bitreader;
4
4
  private audioLength;
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MpcSv7Parser = void 0;
4
- const debug_1 = require("debug");
5
- const BasicParser_1 = require("../../common/BasicParser");
6
- const APEv2Parser_1 = require("../../apev2/APEv2Parser");
7
- const BitReader_1 = require("./BitReader");
8
- const SV7 = require("./StreamVersion7");
9
- const debug = (0, debug_1.default)('music-metadata:parser:musepack');
10
- class MpcSv7Parser 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 { BitReader } from './BitReader.js';
5
+ import * as SV7 from './StreamVersion7.js';
6
+ const debug = initDebug('music-metadata:parser:musepack');
7
+ export class MpcSv7Parser extends BasicParser {
11
8
  constructor() {
12
9
  super(...arguments);
13
10
  this.audioLength = 0;
@@ -23,13 +20,13 @@ class MpcSv7Parser extends BasicParser_1.BasicParser {
23
20
  this.metadata.setFormat('numberOfSamples', numberOfSamples);
24
21
  this.duration = numberOfSamples / header.sampleFrequency;
25
22
  this.metadata.setFormat('duration', this.duration);
26
- this.bitreader = new BitReader_1.BitReader(this.tokenizer);
23
+ this.bitreader = new BitReader(this.tokenizer);
27
24
  this.metadata.setFormat('numberOfChannels', header.midSideStereo || header.intensityStereo ? 2 : 1);
28
25
  const version = await this.bitreader.read(8);
29
26
  this.metadata.setFormat('codec', (version / 100).toFixed(2));
30
27
  await this.skipAudioData(header.frameCount);
31
28
  debug(`End of audio stream, switching to APEv2, offset=${this.tokenizer.position}`);
32
- return APEv2Parser_1.APEv2Parser.tryParseApeHeader(this.metadata, this.tokenizer, this.options);
29
+ return APEv2Parser.tryParseApeHeader(this.metadata, this.tokenizer, this.options);
33
30
  }
34
31
  async skipAudioData(frameCount) {
35
32
  while (frameCount-- > 0) {
@@ -43,4 +40,3 @@ class MpcSv7Parser extends BasicParser_1.BasicParser {
43
40
  this.metadata.setFormat('bitrate', this.audioLength / this.duration);
44
41
  }
45
42
  }
46
- exports.MpcSv7Parser = MpcSv7Parser;
@@ -1,4 +1,4 @@
1
- import { IGetToken } from 'strtok3/lib/core';
1
+ import { IGetToken } from 'strtok3/core';
2
2
  /**
3
3
  * MusePack stream version 7 format specification
4
4
  * http://trac.musepack.net/musepack/wiki/SV7Specification
@@ -1,12 +1,9 @@
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
  * BASIC STRUCTURE
8
5
  */
9
- exports.Header = {
6
+ export const Header = {
10
7
  len: 6 * 4,
11
8
  get: (buf, off) => {
12
9
  const header = {
@@ -1,4 +1,4 @@
1
- import { BasicParser } from '../../common/BasicParser';
1
+ import { BasicParser } from '../../common/BasicParser.js';
2
2
  export declare class MpcSv8Parser extends BasicParser {
3
3
  private audioLength;
4
4
  parse(): Promise<void>;
@@ -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,4 +1,4 @@
1
- import { ITokenizer } from 'strtok3/lib/core';
1
+ import { ITokenizer } from 'strtok3/core';
2
2
  export interface IPacketHeader {
3
3
  key: string;
4
4
  payloadLength: number;
@@ -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,6 +1,6 @@
1
- import { IGetToken } from 'strtok3/lib/core';
2
- import { BasicParser } from '../common/BasicParser';
3
- import * as Ogg from './Ogg';
1
+ import { IGetToken } from 'strtok3/core';
2
+ import { BasicParser } from '../common/BasicParser.js';
3
+ import * as Ogg from './Ogg.js';
4
4
  export declare class SegmentTable implements IGetToken<Ogg.ISegmentTable> {
5
5
  private static sum;
6
6
  len: number;
@@ -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,4 +1,4 @@
1
- import { IGetToken } from 'strtok3/lib/core';
1
+ import { IGetToken } from 'strtok3/core';
2
2
  /**
3
3
  * Opus ID Header interface
4
4
  * Ref: https://wiki.xiph.org/OggOpus#ID_Header
@@ -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,9 +1,9 @@
1
- /// <reference types="node" />
2
- import { ITokenizer } from 'strtok3/lib/core';
3
- import { IPageHeader } from '../Ogg';
4
- import { VorbisParser } from '../vorbis/VorbisParser';
5
- import { IOptions } from '../../type';
6
- import { INativeMetadataCollector } from '../../common/MetadataCollector';
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { ITokenizer } from 'strtok3/core';
3
+ import { IPageHeader } from '../Ogg.js';
4
+ import { VorbisParser } from '../vorbis/VorbisParser.js';
5
+ import { IOptions } from '../../type.js';
6
+ import { INativeMetadataCollector } from '../../common/MetadataCollector.js';
7
7
  /**
8
8
  * Opus parser
9
9
  * Internet Engineering Task Force (IETF) - RFC 6716
@@ -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,4 +1,4 @@
1
- import { IGetToken } from 'strtok3/lib/core';
1
+ import { IGetToken } from 'strtok3/core';
2
2
  /**
3
3
  * Speex Header Packet
4
4
  * Ref: https://www.speex.org/docs/manual/speex-manual/node8.html#SECTION00830000000000000000
@@ -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,9 +1,9 @@
1
- /// <reference types="node" />
2
- import { ITokenizer } from 'strtok3/lib/core';
3
- import { IPageHeader } from '../Ogg';
4
- import { VorbisParser } from '../vorbis/VorbisParser';
5
- import { IOptions } from '../../type';
6
- import { INativeMetadataCollector } from '../../common/MetadataCollector';
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { ITokenizer } from 'strtok3/core';
3
+ import { IPageHeader } from '../Ogg.js';
4
+ import { VorbisParser } from '../vorbis/VorbisParser.js';
5
+ import { IOptions } from '../../type.js';
6
+ import { INativeMetadataCollector } from '../../common/MetadataCollector.js';
7
7
  /**
8
8
  * Speex, RFC 5574
9
9
  * Ref:
@@ -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,4 +1,4 @@
1
- import { IGetToken } from 'strtok3/lib/core';
1
+ import { IGetToken } from 'strtok3/core';
2
2
  /**
3
3
  * 6.2 Identification Header
4
4
  * Ref: https://theora.org/doc/Theora.pdf: 6.2 Identification Header Decode
@@ -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,8 +1,8 @@
1
- /// <reference types="node" />
2
- import { ITokenizer } from 'strtok3/lib/core';
3
- import { IOptions } from '../../type';
4
- import { INativeMetadataCollector } from '../../common/MetadataCollector';
5
- import * as Ogg from '../Ogg';
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { ITokenizer } from 'strtok3/core';
3
+ import * as Ogg from '../Ogg.js';
4
+ import { IOptions } from '../../type.js';
5
+ import { INativeMetadataCollector } from '../../common/MetadataCollector.js';
6
6
  /**
7
7
  * Ref:
8
8
  * - https://theora.org/doc/Theora.pdf
@@ -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,6 +1,6 @@
1
- /// <reference types="node" />
2
- import { IGetToken } from 'strtok3/lib/core';
3
- import { IPicture } from '../../type';
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { IPicture } from '../../type.js';
3
+ import { IGetToken } from 'strtok3/core';
4
4
  /**
5
5
  * Interface to parsed result of METADATA_BLOCK_PICTURE
6
6
  * Ref: https://wiki.xiph.org/VorbisComment#METADATA_BLOCK_PICTURE
@@ -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,13 +1,13 @@
1
- /// <reference types="node" />
2
- import { IOptions } from '../../type';
3
- import { INativeMetadataCollector } from '../../common/MetadataCollector';
4
- import * as Ogg from '../Ogg';
5
- import { IVorbisPicture } from './Vorbis';
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { IVorbisPicture } from './Vorbis.js';
3
+ import { IPageConsumer, IPageHeader } from '../Ogg.js';
4
+ import { IOptions } from '../../type.js';
5
+ import { INativeMetadataCollector } from '../../common/MetadataCollector.js';
6
6
  /**
7
7
  * Vorbis 1 Parser.
8
8
  * Used by OggParser
9
9
  */
10
- export declare class VorbisParser implements Ogg.IPageConsumer {
10
+ export declare class VorbisParser implements IPageConsumer {
11
11
  protected metadata: INativeMetadataCollector;
12
12
  protected options: IOptions;
13
13
  private pageSegments;
@@ -17,17 +17,17 @@ export declare class VorbisParser implements Ogg.IPageConsumer {
17
17
  * @param header Ogg Page Header
18
18
  * @param pageData Page data
19
19
  */
20
- parsePage(header: Ogg.IPageHeader, pageData: Buffer): void;
20
+ parsePage(header: IPageHeader, pageData: Buffer): void;
21
21
  flush(): void;
22
22
  parseUserComment(pageData: Buffer, offset: number): number;
23
23
  addTag(id: string, value: string | IVorbisPicture): void;
24
- calculateDuration(header: Ogg.IPageHeader): void;
24
+ calculateDuration(header: IPageHeader): void;
25
25
  /**
26
26
  * Parse first Ogg/Vorbis page
27
- * @param {IPageHeader} header
28
- * @param {Buffer} pageData
27
+ * @param header
28
+ * @param pageData
29
29
  */
30
- protected parseFirstPage(header: Ogg.IPageHeader, pageData: Buffer): void;
30
+ protected parseFirstPage(header: IPageHeader, pageData: Buffer): void;
31
31
  protected parseFullPage(pageData: Buffer): void;
32
32
  /**
33
33
  * Ref: https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-840005.2