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
@@ -9,9 +9,9 @@ export interface IParserLoader {
9
9
  extensions: string[];
10
10
  parserType: ParserType;
11
11
  /**
12
- * Lazy load the parser
12
+ * Lazy load the parser implementation class.
13
13
  */
14
- load(metadata: INativeMetadataCollector, tokenizer: ITokenizer, options: IOptions): Promise<ITokenParser>;
14
+ load(): Promise<new (metadata: INativeMetadataCollector, tokenizer: ITokenizer, options: IOptions) => ITokenParser>;
15
15
  }
16
16
  export interface ITokenParser {
17
17
  /**
@@ -85,7 +85,8 @@ export class ParserFactory {
85
85
  // Parser found, execute parser
86
86
  debug(`Loading ${parserLoader.parserType} parser...`);
87
87
  const metadata = new MetadataCollector(opts);
88
- const parser = await parserLoader.load(metadata, tokenizer, opts ?? {});
88
+ const ParserImpl = await parserLoader.load();
89
+ const parser = new ParserImpl(metadata, tokenizer, opts ?? {});
89
90
  debug(`Parser ${parserLoader.parserType} loaded`);
90
91
  await parser.parse();
91
92
  return metadata.toCommonMetadata();
@@ -1,8 +1,8 @@
1
1
  export const aiffParserLoader = {
2
2
  parserType: 'aiff',
3
3
  extensions: ['.aif', 'aiff', 'aifc'],
4
- async load(metadata, tokenizer, options) {
5
- return new (await import('./AiffParser.js')).AIFFParser(metadata, tokenizer, options);
4
+ async load() {
5
+ return (await import('./AiffParser.js')).AIFFParser;
6
6
  }
7
7
  };
8
8
  //# sourceMappingURL=AiffLoader.js.map
@@ -40,8 +40,8 @@ export interface ICommon {
40
40
  compressionName?: string;
41
41
  }
42
42
  export declare class Common implements IGetToken<ICommon> {
43
- private isAifc;
44
43
  len: number;
44
+ private isAifc;
45
45
  constructor(header: iff.IChunkHeader, isAifc: boolean);
46
46
  get(buf: Uint8Array, off: number): ICommon;
47
47
  }
@@ -52,12 +52,13 @@ export interface IFooter {
52
52
  fields: number;
53
53
  flags: ITagFlags;
54
54
  }
55
- export declare enum DataType {
56
- text_utf8 = 0,
57
- binary = 1,
58
- external_info = 2,
59
- reserved = 3
60
- }
55
+ export declare const DataType: {
56
+ text_utf8: number;
57
+ binary: number;
58
+ external_info: number;
59
+ reserved: number;
60
+ };
61
+ export type DataType = typeof DataType[keyof typeof DataType];
61
62
  /**
62
63
  * APE_DESCRIPTOR: defines the sizes (and offsets) of all the pieces, as well as the MD5 checksum
63
64
  */
@@ -1,12 +1,11 @@
1
1
  import * as Token from 'token-types';
2
2
  import { FourCcToken } from '../common/FourCC.js';
3
- export var DataType;
4
- (function (DataType) {
5
- DataType[DataType["text_utf8"] = 0] = "text_utf8";
6
- DataType[DataType["binary"] = 1] = "binary";
7
- DataType[DataType["external_info"] = 2] = "external_info";
8
- DataType[DataType["reserved"] = 3] = "reserved";
9
- })(DataType || (DataType = {}));
3
+ export const DataType = {
4
+ text_utf8: 0,
5
+ binary: 1,
6
+ external_info: 2,
7
+ reserved: 3
8
+ };
10
9
  /**
11
10
  * APE_DESCRIPTOR: defines the sizes (and offsets) of all the pieces, as well as the MD5 checksum
12
11
  */
@@ -1,8 +1,8 @@
1
1
  export const apeParserLoader = {
2
2
  parserType: 'apev2',
3
3
  extensions: ['.ape'],
4
- async load(metadata, tokenizer, options) {
5
- return new (await import('./APEv2Parser.js')).APEv2Parser(metadata, tokenizer, options);
4
+ async load() {
5
+ return (await import('./APEv2Parser.js')).APEv2Parser;
6
6
  }
7
7
  };
8
8
  //# sourceMappingURL=Apev2Loader.js.map
@@ -1,8 +1,8 @@
1
1
  export const asfParserLoader = {
2
2
  parserType: 'asf',
3
3
  extensions: ['.asf'],
4
- async load(metadata, tokenizer, options) {
5
- return new (await import('./AsfParser.js')).AsfParser(metadata, tokenizer, options);
4
+ async load() {
5
+ return (await import('./AsfParser.js')).AsfParser;
6
6
  }
7
7
  };
8
8
  //# sourceMappingURL=AsfLoader.js.map
@@ -10,13 +10,7 @@ declare const AsfContentParseError_base: {
10
10
  stack?: string;
11
11
  };
12
12
  captureStackTrace(targetObject: object, constructorOpt?: Function): void;
13
- prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite /**
14
- * Specifies the amount of time to buffer data before starting to play the file, in millisecond units.
15
- * If this value is nonzero, the Play Duration field and all of the payload Presentation Time fields have been offset
16
- * by this amount. Therefore, player software must subtract the value in the preroll field from the play duration and
17
- * presentation times to calculate their actual values. It follows that all payload Presentation Time fields need to
18
- * be at least this value.
19
- */[]) => any) | undefined;
13
+ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
20
14
  stackTraceLimit: number;
21
15
  };
22
16
  export declare class AsfContentParseError extends AsfContentParseError_base {
@@ -24,32 +18,33 @@ export declare class AsfContentParseError extends AsfContentParseError_base {
24
18
  /**
25
19
  * Data Type: Specifies the type of information being stored. The following values are recognized.
26
20
  */
27
- export declare enum DataType {
21
+ export declare const DataType: {
28
22
  /**
29
23
  * Unicode string. The data consists of a sequence of Unicode characters.
30
24
  */
31
- UnicodeString = 0,
25
+ UnicodeString: number;
32
26
  /**
33
27
  * BYTE array. The type of data is implementation-specific.
34
28
  */
35
- ByteArray = 1,
29
+ ByteArray: number;
36
30
  /**
37
31
  * BOOL. The data is 2 bytes long and should be interpreted as a 16-bit unsigned integer. Only 0x0000 or 0x0001 are permitted values.
38
32
  */
39
- Bool = 2,
33
+ Bool: number;
40
34
  /**
41
35
  * DWORD. The data is 4 bytes long and should be interpreted as a 32-bit unsigned integer.
42
36
  */
43
- DWord = 3,
37
+ DWord: number;
44
38
  /**
45
39
  * QWORD. The data is 8 bytes long and should be interpreted as a 64-bit unsigned integer.
46
40
  */
47
- QWord = 4,
41
+ QWord: number;
48
42
  /**
49
43
  * WORD. The data is 2 bytes long and should be interpreted as a 16-bit unsigned integer.
50
44
  */
51
- Word = 5
52
- }
45
+ Word: number;
46
+ };
47
+ export type DataType = typeof DataType[keyof typeof DataType];
53
48
  /**
54
49
  * Ref: https://msdn.microsoft.com/en-us/library/windows/desktop/ee663575
55
50
  */
@@ -322,8 +317,8 @@ export interface IWmPicture extends IPicture {
322
317
  * Ref: https://msdn.microsoft.com/en-us/library/windows/desktop/dd757977(v=vs.85).aspx
323
318
  */
324
319
  export declare class WmPictureToken implements IGetToken<IWmPicture> {
325
- len: number;
326
320
  static fromBuffer(buffer: Uint8Array): IWmPicture;
321
+ len: number;
327
322
  constructor(len: number);
328
323
  get(buffer: Uint8Array, offset: number): IWmPicture;
329
324
  }
@@ -10,33 +10,32 @@ export class AsfContentParseError extends makeUnexpectedFileContentError('ASF')
10
10
  /**
11
11
  * Data Type: Specifies the type of information being stored. The following values are recognized.
12
12
  */
13
- export var DataType;
14
- (function (DataType) {
13
+ export const DataType = {
15
14
  /**
16
15
  * Unicode string. The data consists of a sequence of Unicode characters.
17
16
  */
18
- DataType[DataType["UnicodeString"] = 0] = "UnicodeString";
17
+ UnicodeString: 0,
19
18
  /**
20
19
  * BYTE array. The type of data is implementation-specific.
21
20
  */
22
- DataType[DataType["ByteArray"] = 1] = "ByteArray";
21
+ ByteArray: 1,
23
22
  /**
24
23
  * BOOL. The data is 2 bytes long and should be interpreted as a 16-bit unsigned integer. Only 0x0000 or 0x0001 are permitted values.
25
24
  */
26
- DataType[DataType["Bool"] = 2] = "Bool";
25
+ Bool: 2,
27
26
  /**
28
27
  * DWORD. The data is 4 bytes long and should be interpreted as a 32-bit unsigned integer.
29
28
  */
30
- DataType[DataType["DWord"] = 3] = "DWord";
29
+ DWord: 3,
31
30
  /**
32
31
  * QWORD. The data is 8 bytes long and should be interpreted as a 64-bit unsigned integer.
33
32
  */
34
- DataType[DataType["QWord"] = 4] = "QWord";
33
+ QWord: 4,
35
34
  /**
36
35
  * WORD. The data is 2 bytes long and should be interpreted as a 16-bit unsigned integer.
37
36
  */
38
- DataType[DataType["Word"] = 5] = "Word";
39
- })(DataType || (DataType = {}));
37
+ Word: 5
38
+ };
40
39
  /**
41
40
  * Token for: 3. ASF top-level Header Object
42
41
  * Ref: http://drang.s4.xrea.com/program/tips/id3tag/wmp/03_asf_top_level_header_object.html#3
package/lib/asf/GUID.d.ts CHANGED
@@ -13,7 +13,6 @@
13
13
  * - https://github.com/dji-sdk/FFmpeg/blob/master/libavformat/asf.c
14
14
  */
15
15
  export default class GUID {
16
- str: string;
17
16
  static HeaderObject: GUID;
18
17
  static DataObject: GUID;
19
18
  static SimpleIndexObject: GUID;
@@ -77,6 +76,7 @@ export default class GUID {
77
76
  * @returns Encoded Binary GUID
78
77
  */
79
78
  static encode(str: string): Uint8Array;
79
+ str: string;
80
80
  constructor(str: string);
81
81
  equals(guid: GUID): boolean;
82
82
  toBin(): Uint8Array;
@@ -19,14 +19,14 @@ export interface IGenericTagMapper {
19
19
  mapGenericTag(tag: ITag, warnings: INativeMetadataCollector): generic.IGenericTag | null;
20
20
  }
21
21
  export declare class CommonTagMapper implements IGenericTagMapper {
22
- tagTypes: generic.TagType[];
23
- tagMap: generic.INativeTagMap;
24
22
  static maxRatingScore: number;
25
23
  static toIntOrNull(str: string): number | null;
26
24
  static normalizeTrack(origVal: number | string): {
27
25
  no: number | null;
28
26
  of: number | null;
29
27
  };
28
+ tagTypes: generic.TagType[];
29
+ tagMap: generic.INativeTagMap;
30
30
  constructor(tagTypes: generic.TagType[], tagMap: generic.INativeTagMap);
31
31
  /**
32
32
  * Process and set common tags
@@ -21,7 +21,7 @@ export interface ITagInfo {
21
21
  export interface ITagInfoMap {
22
22
  [index: string]: ITagInfo;
23
23
  }
24
- export declare const commonTags: ITagInfoMap;
24
+ export declare const commonTagsKeys: (keyof ICommonTagsResult)[];
25
25
  /**
26
26
  * @param alias Name of common tag
27
27
  * @returns {boolean|*} true if given alias is mapped as a singleton', otherwise false
@@ -1,16 +1,19 @@
1
- export const commonTags = {
2
- year: { multiple: false },
3
- track: { multiple: false },
4
- disk: { multiple: false },
5
- title: { multiple: false },
6
- artist: { multiple: false },
1
+ const defaultTagInfo = {
2
+ multiple: false,
3
+ };
4
+ const commonTags = {
5
+ year: defaultTagInfo,
6
+ track: defaultTagInfo,
7
+ disk: defaultTagInfo,
8
+ title: defaultTagInfo,
9
+ artist: defaultTagInfo,
7
10
  artists: { multiple: true, unique: true },
8
- albumartist: { multiple: false },
9
- album: { multiple: false },
10
- date: { multiple: false },
11
- originaldate: { multiple: false },
12
- originalyear: { multiple: false },
13
- releasedate: { multiple: false },
11
+ albumartist: defaultTagInfo,
12
+ album: defaultTagInfo,
13
+ date: defaultTagInfo,
14
+ originaldate: defaultTagInfo,
15
+ originalyear: defaultTagInfo,
16
+ releasedate: defaultTagInfo,
14
17
  comment: { multiple: true, unique: false },
15
18
  genre: { multiple: true, unique: true },
16
19
  picture: { multiple: true, unique: true },
@@ -33,84 +36,85 @@ export const commonTags = {
33
36
  djmixer: { multiple: true, unique: true },
34
37
  mixer: { multiple: true, unique: true },
35
38
  label: { multiple: true, unique: true },
36
- grouping: { multiple: false },
39
+ grouping: defaultTagInfo,
37
40
  subtitle: { multiple: true },
38
- discsubtitle: { multiple: false },
39
- totaltracks: { multiple: false },
40
- totaldiscs: { multiple: false },
41
- compilation: { multiple: false },
41
+ discsubtitle: defaultTagInfo,
42
+ totaltracks: defaultTagInfo,
43
+ totaldiscs: defaultTagInfo,
44
+ compilation: defaultTagInfo,
42
45
  rating: { multiple: true },
43
- bpm: { multiple: false },
44
- mood: { multiple: false },
45
- media: { multiple: false },
46
+ bpm: defaultTagInfo,
47
+ mood: defaultTagInfo,
48
+ media: defaultTagInfo,
46
49
  catalognumber: { multiple: true, unique: true },
47
- tvShow: { multiple: false },
48
- tvShowSort: { multiple: false },
49
- tvSeason: { multiple: false },
50
- tvEpisode: { multiple: false },
51
- tvEpisodeId: { multiple: false },
52
- tvNetwork: { multiple: false },
53
- podcast: { multiple: false },
54
- podcasturl: { multiple: false },
55
- releasestatus: { multiple: false },
50
+ tvShow: defaultTagInfo,
51
+ tvShowSort: defaultTagInfo,
52
+ tvSeason: defaultTagInfo,
53
+ tvEpisode: defaultTagInfo,
54
+ tvEpisodeId: defaultTagInfo,
55
+ tvNetwork: defaultTagInfo,
56
+ podcast: defaultTagInfo,
57
+ podcasturl: defaultTagInfo,
58
+ releasestatus: defaultTagInfo,
56
59
  releasetype: { multiple: true },
57
- releasecountry: { multiple: false },
58
- script: { multiple: false },
59
- language: { multiple: false },
60
- copyright: { multiple: false },
61
- license: { multiple: false },
62
- encodedby: { multiple: false },
63
- encodersettings: { multiple: false },
64
- gapless: { multiple: false },
65
- barcode: { multiple: false },
60
+ releasecountry: defaultTagInfo,
61
+ script: defaultTagInfo,
62
+ language: defaultTagInfo,
63
+ copyright: defaultTagInfo,
64
+ license: defaultTagInfo,
65
+ encodedby: defaultTagInfo,
66
+ encodersettings: defaultTagInfo,
67
+ gapless: defaultTagInfo,
68
+ barcode: defaultTagInfo,
66
69
  isrc: { multiple: true },
67
- asin: { multiple: false },
68
- musicbrainz_recordingid: { multiple: false },
69
- musicbrainz_trackid: { multiple: false },
70
- musicbrainz_albumid: { multiple: false },
70
+ asin: defaultTagInfo,
71
+ musicbrainz_recordingid: defaultTagInfo,
72
+ musicbrainz_trackid: defaultTagInfo,
73
+ musicbrainz_albumid: defaultTagInfo,
71
74
  musicbrainz_artistid: { multiple: true },
72
75
  musicbrainz_albumartistid: { multiple: true },
73
- musicbrainz_releasegroupid: { multiple: false },
74
- musicbrainz_workid: { multiple: false },
75
- musicbrainz_trmid: { multiple: false },
76
- musicbrainz_discid: { multiple: false },
77
- acoustid_id: { multiple: false },
78
- acoustid_fingerprint: { multiple: false },
79
- musicip_puid: { multiple: false },
80
- musicip_fingerprint: { multiple: false },
81
- website: { multiple: false },
76
+ musicbrainz_releasegroupid: defaultTagInfo,
77
+ musicbrainz_workid: defaultTagInfo,
78
+ musicbrainz_trmid: defaultTagInfo,
79
+ musicbrainz_discid: defaultTagInfo,
80
+ acoustid_id: defaultTagInfo,
81
+ acoustid_fingerprint: defaultTagInfo,
82
+ musicip_puid: defaultTagInfo,
83
+ musicip_fingerprint: defaultTagInfo,
84
+ website: defaultTagInfo,
82
85
  'performer:instrument': { multiple: true, unique: true },
83
- averageLevel: { multiple: false },
84
- peakLevel: { multiple: false },
86
+ averageLevel: defaultTagInfo,
87
+ peakLevel: defaultTagInfo,
85
88
  notes: { multiple: true, unique: false },
86
- key: { multiple: false },
87
- originalalbum: { multiple: false },
88
- originalartist: { multiple: false },
89
+ key: defaultTagInfo,
90
+ originalalbum: defaultTagInfo,
91
+ originalartist: defaultTagInfo,
89
92
  discogs_artist_id: { multiple: true, unique: true },
90
- discogs_release_id: { multiple: false },
91
- discogs_label_id: { multiple: false },
92
- discogs_master_release_id: { multiple: false },
93
- discogs_votes: { multiple: false },
94
- discogs_rating: { multiple: false },
95
- replaygain_track_peak: { multiple: false },
96
- replaygain_track_gain: { multiple: false },
97
- replaygain_album_peak: { multiple: false },
98
- replaygain_album_gain: { multiple: false },
99
- replaygain_track_minmax: { multiple: false },
100
- replaygain_album_minmax: { multiple: false },
101
- replaygain_undo: { multiple: false },
93
+ discogs_release_id: defaultTagInfo,
94
+ discogs_label_id: defaultTagInfo,
95
+ discogs_master_release_id: defaultTagInfo,
96
+ discogs_votes: defaultTagInfo,
97
+ discogs_rating: defaultTagInfo,
98
+ replaygain_track_peak: defaultTagInfo,
99
+ replaygain_track_gain: defaultTagInfo,
100
+ replaygain_album_peak: defaultTagInfo,
101
+ replaygain_album_gain: defaultTagInfo,
102
+ replaygain_track_minmax: defaultTagInfo,
103
+ replaygain_album_minmax: defaultTagInfo,
104
+ replaygain_undo: defaultTagInfo,
102
105
  description: { multiple: true },
103
- longDescription: { multiple: false },
106
+ longDescription: defaultTagInfo,
104
107
  category: { multiple: true },
105
- hdVideo: { multiple: false },
108
+ hdVideo: defaultTagInfo,
106
109
  keywords: { multiple: true },
107
- movement: { multiple: false },
108
- movementIndex: { multiple: false },
109
- movementTotal: { multiple: false },
110
- podcastId: { multiple: false },
111
- showMovement: { multiple: false },
112
- stik: { multiple: false }
110
+ movement: defaultTagInfo,
111
+ movementIndex: defaultTagInfo,
112
+ movementTotal: defaultTagInfo,
113
+ podcastId: defaultTagInfo,
114
+ showMovement: defaultTagInfo,
115
+ stik: defaultTagInfo
113
116
  };
117
+ export const commonTagsKeys = /* @__PURE__ */ Object.keys(commonTags);
114
118
  /**
115
119
  * @param alias Name of common tag
116
120
  * @returns {boolean|*} true if given alias is mapped as a singleton', otherwise false
@@ -30,7 +30,6 @@ export interface INativeMetadataCollector extends IWarningCollector {
30
30
  * Responsible for triggering async updates
31
31
  */
32
32
  export declare class MetadataCollector implements INativeMetadataCollector {
33
- private opts?;
34
33
  readonly format: IFormat;
35
34
  readonly native: INativeTags;
36
35
  readonly common: ICommonTagsResult;
@@ -44,7 +43,8 @@ export declare class MetadataCollector implements INativeMetadataCollector {
44
43
  */
45
44
  private readonly originPriority;
46
45
  private tagMapper;
47
- constructor(opts?: IOptions | undefined);
46
+ private opts?;
47
+ constructor(opts?: IOptions);
48
48
  /**
49
49
  * @returns {boolean} true if one or more tags have been found
50
50
  */
@@ -1,4 +1,4 @@
1
- import { TrackType } from '../type.js';
1
+ import { TrackTypeValueToKeyMap } from '../type.js';
2
2
  import initDebug from 'debug';
3
3
  import { isSingleton, isUnique } from './GenericTagTypes.js';
4
4
  import { CombinedTagMapper } from './CombinedTagMapper.js';
@@ -14,7 +14,6 @@ const TagPriority = ['matroska', 'APEv2', 'vorbis', 'ID3v2.4', 'ID3v2.3', 'ID3v2
14
14
  */
15
15
  export class MetadataCollector {
16
16
  constructor(opts) {
17
- this.opts = opts;
18
17
  this.format = {
19
18
  tagTypes: [],
20
19
  trackInfo: []
@@ -37,6 +36,7 @@ export class MetadataCollector {
37
36
  */
38
37
  this.originPriority = {};
39
38
  this.tagMapper = new CombinedTagMapper();
39
+ this.opts = opts;
40
40
  let priority = 1;
41
41
  for (const tagType of TagPriority) {
42
42
  this.originPriority[tagType] = priority++;
@@ -51,7 +51,7 @@ export class MetadataCollector {
51
51
  return Object.keys(this.native).length > 0;
52
52
  }
53
53
  addStreamInfo(streamInfo) {
54
- debug(`streamInfo: type=${streamInfo.type ? TrackType[streamInfo.type] : '?'}, codec=${streamInfo.codecName}`);
54
+ debug(`streamInfo: type=${streamInfo.type ? TrackTypeValueToKeyMap[streamInfo.type] : '?'}, codec=${streamInfo.codecName}`);
55
55
  this.format.trackInfo.push(streamInfo);
56
56
  }
57
57
  setFormat(key, value) {
package/lib/core.d.ts CHANGED
@@ -57,3 +57,8 @@ export declare function ratingToStars(rating: number | undefined): number;
57
57
  */
58
58
  export declare function selectCover(pictures?: IPicture[]): IPicture | null;
59
59
  export declare function scanAppendingHeaders(tokenizer: IRandomAccessTokenizer, options?: IPrivateOptions): Promise<void>;
60
+ /**
61
+ * Implementation only available when loaded as Node.js
62
+ * This method will throw an Error, always.
63
+ */
64
+ export declare function parseFile(filePath: string, options?: IOptions): Promise<IAudioMetadata>;
package/lib/core.js CHANGED
@@ -103,4 +103,11 @@ export async function scanAppendingHeaders(tokenizer, options = {}) {
103
103
  }
104
104
  options.apeHeader = await APEv2Parser.findApeFooterOffset(tokenizer, apeOffset);
105
105
  }
106
+ /**
107
+ * Implementation only available when loaded as Node.js
108
+ * This method will throw an Error, always.
109
+ */
110
+ export async function parseFile(filePath, options = {}) {
111
+ throw new Error('To load Web API File objects use parseBlob instead. For loading files, you need to import with the "node" condition is set.');
112
+ }
106
113
  //# sourceMappingURL=core.js.map
@@ -1,8 +1,8 @@
1
1
  export const dsdiffParserLoader = {
2
2
  parserType: 'dsdiff',
3
3
  extensions: ['.dff'],
4
- async load(metadata, tokenizer, options) {
5
- return new (await import('./DsdiffParser.js')).DsdiffParser(metadata, tokenizer, options);
4
+ async load() {
5
+ return (await import('./DsdiffParser.js')).DsdiffParser;
6
6
  }
7
7
  };
8
8
  //# sourceMappingURL=DsdiffLoader.js.map
@@ -34,15 +34,16 @@ export interface IDsdChunk {
34
34
  * Common chunk DSD header: the 'chunk name (Four-CC)' & chunk size
35
35
  */
36
36
  export declare const DsdChunk: IGetToken<IDsdChunk>;
37
- export declare enum ChannelType {
38
- mono = 1,
39
- stereo = 2,
40
- channels = 3,
41
- quad = 4,
42
- '4 channels' = 5,
43
- '5 channels' = 6,
44
- '5.1 channels' = 7
45
- }
37
+ export declare const ChannelType: {
38
+ mono: number;
39
+ stereo: number;
40
+ channels: number;
41
+ quad: number;
42
+ '4 channels': number;
43
+ '5 channels': number;
44
+ '5.1 channels': number;
45
+ };
46
+ export type ChannelType = typeof ChannelType[keyof typeof ChannelType];
46
47
  /**
47
48
  * Interface to format chunk payload chunk
48
49
  */
@@ -21,16 +21,15 @@ export const DsdChunk = {
21
21
  };
22
22
  }
23
23
  };
24
- export var ChannelType;
25
- (function (ChannelType) {
26
- ChannelType[ChannelType["mono"] = 1] = "mono";
27
- ChannelType[ChannelType["stereo"] = 2] = "stereo";
28
- ChannelType[ChannelType["channels"] = 3] = "channels";
29
- ChannelType[ChannelType["quad"] = 4] = "quad";
30
- ChannelType[ChannelType["4 channels"] = 5] = "4 channels";
31
- ChannelType[ChannelType["5 channels"] = 6] = "5 channels";
32
- ChannelType[ChannelType["5.1 channels"] = 7] = "5.1 channels";
33
- })(ChannelType || (ChannelType = {}));
24
+ export const ChannelType = {
25
+ mono: 1,
26
+ stereo: 2,
27
+ channels: 3,
28
+ quad: 4,
29
+ '4 channels': 5,
30
+ '5 channels': 6,
31
+ '5.1 channels': 7
32
+ };
34
33
  /**
35
34
  * Common chunk DSD header: the 'chunk name (Four-CC)' & chunk size
36
35
  */
@@ -1,8 +1,8 @@
1
1
  export const dsfParserLoader = {
2
2
  parserType: 'dsf',
3
3
  extensions: ['.dsf'],
4
- async load(metadata, tokenizer, options) {
5
- return new (await import('./DsfParser.js')).DsfParser(metadata, tokenizer, options);
4
+ async load() {
5
+ return (await import('./DsfParser.js')).DsfParser;
6
6
  }
7
7
  };
8
8
  //# sourceMappingURL=DsfLoader.js.map
@@ -21,13 +21,14 @@ export interface ILinkedElementType extends IElementType {
21
21
  [id: number]: ILinkedElementType;
22
22
  };
23
23
  }
24
- export declare enum ParseAction {
25
- ReadNext = 0,// Continue reading the next elements
26
- IgnoreElement = 2,// Ignore (do not read) this element
27
- SkipSiblings = 3,// Skip all remaining elements at the same level
28
- TerminateParsing = 4,// Terminate the parsing process
29
- SkipElement = 5
30
- }
24
+ export declare const ParseAction: {
25
+ readonly ReadNext: 0;
26
+ readonly IgnoreElement: 2;
27
+ readonly SkipSiblings: 3;
28
+ readonly TerminateParsing: 4;
29
+ readonly SkipElement: 5;
30
+ };
31
+ export type ParseAction = typeof ParseAction[keyof typeof ParseAction];
31
32
  /**
32
33
  * @return true, to quit the parser
33
34
  */
@@ -43,11 +44,11 @@ export type IElementListener = {
43
44
  * WEBM VP8 AUDIO FILE
44
45
  */
45
46
  export declare class EbmlIterator {
46
- private tokenizer;
47
47
  private padding;
48
48
  private parserMap;
49
49
  private ebmlMaxIDLength;
50
50
  private ebmlMaxSizeLength;
51
+ private tokenizer;
51
52
  /**
52
53
  * @param {ITokenizer} tokenizer Input
53
54
  * @param tokenizer