taglib-wasm 2.0.0 → 2.2.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 (71) hide show
  1. package/dist/index.browser.d.ts +1 -1
  2. package/dist/index.browser.d.ts.map +1 -1
  3. package/dist/index.browser.js +64 -12
  4. package/dist/index.d.ts +2 -2
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +7 -5
  7. package/dist/simple.browser.js +105 -13
  8. package/dist/src/constants/properties.d.ts +14 -0
  9. package/dist/src/constants/properties.d.ts.map +1 -1
  10. package/dist/src/constants/specialized-properties.d.ts +14 -0
  11. package/dist/src/constants/specialized-properties.d.ts.map +1 -1
  12. package/dist/src/constants/specialized-properties.js +22 -0
  13. package/dist/src/constants/utilities.d.ts +13 -0
  14. package/dist/src/constants/utilities.d.ts.map +1 -1
  15. package/dist/src/constants/utilities.js +9 -1
  16. package/dist/src/folder-api/folder-operations.d.ts +2 -30
  17. package/dist/src/folder-api/folder-operations.d.ts.map +1 -1
  18. package/dist/src/folder-api/folder-operations.js +1 -36
  19. package/dist/src/folder-api/index.d.ts +2 -2
  20. package/dist/src/folder-api/index.d.ts.map +1 -1
  21. package/dist/src/folder-api/index.js +2 -7
  22. package/dist/src/folder-api/types.d.ts +0 -21
  23. package/dist/src/folder-api/types.d.ts.map +1 -1
  24. package/dist/src/folder-api/types.js +1 -13
  25. package/dist/src/msgpack/decoder.d.ts +2 -2
  26. package/dist/src/msgpack/decoder.d.ts.map +1 -1
  27. package/dist/src/msgpack/encoder.js +5 -3
  28. package/dist/src/msgpack/index.d.ts +1 -1
  29. package/dist/src/msgpack/index.d.ts.map +1 -1
  30. package/dist/src/msgpack/types.d.ts +10 -0
  31. package/dist/src/msgpack/types.d.ts.map +1 -1
  32. package/dist/src/msgpack/utils.d.ts +2 -1
  33. package/dist/src/msgpack/utils.d.ts.map +1 -1
  34. package/dist/src/runtime/module-loader-browser.d.ts.map +1 -1
  35. package/dist/src/runtime/platform-io.js +1 -1
  36. package/dist/src/runtime/unified-loader/module-loading.d.ts.map +1 -1
  37. package/dist/src/runtime/unified-loader/module-loading.js +1 -1
  38. package/dist/src/runtime/wasi-adapter/file-handle.d.ts.map +1 -1
  39. package/dist/src/runtime/wasi-adapter/file-handle.js +12 -3
  40. package/dist/src/runtime/wasi-fs-deno.d.ts.map +1 -1
  41. package/dist/src/runtime/wasi-fs-deno.js +1 -1
  42. package/dist/src/simple/batch-operations.d.ts +57 -2
  43. package/dist/src/simple/batch-operations.d.ts.map +1 -1
  44. package/dist/src/simple/batch-operations.js +55 -5
  45. package/dist/src/simple/index.d.ts +2 -2
  46. package/dist/src/simple/index.d.ts.map +1 -1
  47. package/dist/src/simple/index.js +6 -2
  48. package/dist/src/simple/tag-operations.d.ts +5 -1
  49. package/dist/src/simple/tag-operations.d.ts.map +1 -1
  50. package/dist/src/simple/tag-operations.js +5 -2
  51. package/dist/src/taglib/embind-adapter.d.ts.map +1 -1
  52. package/dist/src/types/metadata-mappings.d.ts +1 -1
  53. package/dist/src/types/metadata-mappings.d.ts.map +1 -1
  54. package/dist/src/types/metadata-mappings.js +5 -0
  55. package/dist/src/types/tags.d.ts +13 -0
  56. package/dist/src/types/tags.d.ts.map +1 -1
  57. package/dist/src/utils/mirror-fields.d.ts +2 -0
  58. package/dist/src/utils/mirror-fields.d.ts.map +1 -1
  59. package/dist/src/utils/mirror-fields.js +11 -3
  60. package/dist/src/utils/node-fs.d.ts +10 -10
  61. package/dist/src/utils/node-fs.d.ts.map +1 -1
  62. package/dist/src/utils/node-fs.js +2 -1
  63. package/dist/src/utils/tag-mapping.d.ts +1 -1
  64. package/dist/src/utils/tag-mapping.d.ts.map +1 -1
  65. package/dist/src/utils/tag-mapping.js +17 -3
  66. package/dist/src/version.d.ts +1 -1
  67. package/dist/src/version.js +1 -1
  68. package/dist/taglib-wasi.wasm +0 -0
  69. package/dist/taglib-web.wasm +0 -0
  70. package/dist/taglib-wrapper.js +1 -1
  71. package/package.json +6 -6
@@ -13,7 +13,7 @@ export { isNamedAudioInput } from "./src/types/audio-formats.js";
13
13
  export { EnvironmentError, FileOperationError, InvalidFormatError, isEnvironmentError, isFileOperationError, isInvalidFormatError, isMemoryError, isMetadataError, isTagLibError, isUnsupportedFormatError, MemoryError, MetadataError, SUPPORTED_FORMATS, TagLibError, TagLibInitializationError, UnsupportedFormatError, } from "./src/errors.js";
14
14
  export type { TagLibErrorCode } from "./src/errors.js";
15
15
  export { addPicture, applyCoverArt, applyPictures, applyTags, applyTagsToFile, type BatchItem, type BatchOptions, type BatchResult, clearPictures, clearTags, type FileMetadata, findPictureByType, isValidAudioFile, readCoverArt, readFormat, readMetadata, readMetadataBatch, readPictureMetadata, readPictures, readProperties, readPropertiesBatch, readTags, readTagsBatch, replacePictureByType, setBufferMode, } from "./src/simple/index.js";
16
- export { FormatMappings, getAllProperties, getAllPropertyKeys, getPropertiesByFormat, getPropertyMetadata, isValidProperty, PROPERTIES, } from "./src/constants.js";
16
+ export { FormatMappings, getAllProperties, getAllPropertyKeys, getPropertiesByFormat, getPropertyMetadata, isValidProperty, PROPERTIES, propertyValue, propertyValues, } from "./src/constants.js";
17
17
  export type { PropertyMetadata } from "./src/constants/property-types.js";
18
18
  export { canvasToPicture, createPictureDownloadURL, createPictureGallery, dataURLToPicture, displayPicture, imageFileToPicture, pictureToDataURL, setCoverArtFromCanvas, } from "./src/web-utils/index.js";
19
19
  export type { AudioCodec, AudioFileInput, AudioProperties, BitrateControlMode, ContainerFormat, ExtendedTag, FieldMapping, FileType, NamedAudioInput, OpenOptions, Picture, PictureType, PropertyMap, Tag, TagInput, } from "./src/types.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../index.browser.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,YAAY,EACV,SAAS,EACT,cAAc,GACf,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,E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AAe,EACf,WAAW,EACX,OAAO,EACP,WAAW,EACX,WAAW,EACX,GAAG,EACH,QAAQ,GACT,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACrE,YAAY,EACV,iBAAiB,EACjB,SAAS,GACV,MAAM,qCAAqC,CAAC;AAG7C,YAAY,EACV,MAAM,EACN,cAAc,EACd,UAAU,GACX,MAAM,uCAAuC,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAG1E,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC9D,YAAY,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC"}
1
+ {"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../index.browser.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,YAAY,EACV,SAAS,EACT,cAAc,GACf,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACtE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,eAAe,EACf,aAAa,EACb,wBAAwB,EACxB,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,yBAAyB,EACzB,sBAAsB,GACvB,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V,MAAM,EACN,cAAc,EACd,UAAU,GACX,MAAM,uCAAuC,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAG1E,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC9D,YAAY,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC"}
@@ -1,8 +1,13 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __getOwnPropNames = Object.getOwnPropertyNames;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
- var __esm = (fn, res) => function __init() {
5
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
4
+ var __esm = (fn, res, err) => function __init() {
5
+ if (err) throw err[0];
6
+ try {
7
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
8
+ } catch (e) {
9
+ throw err = [e], e;
10
+ }
6
11
  };
7
12
  var __export = (target, all) => {
8
13
  for (var name in all)
@@ -1382,6 +1387,28 @@ var init_specialized_properties = __esm({
1382
1387
  mp4: "----:com.apple.iTunes:MusicBrainz Album Type"
1383
1388
  }
1384
1389
  },
1390
+ releaseCountry: {
1391
+ key: "RELEASECOUNTRY",
1392
+ description: "Release country (ISO 3166-1 code, e.g. 'US'). TagLib 2.3.1 translates the RELEASECOUNTRY key per format: ID3v2 TXXX 'MUSICBRAINZ ALBUM RELEASE COUNTRY' (TagLib's description casing; an uppercase TXXX:RELEASECOUNTRY description also reads back), MP4 freeform atom 'MusicBrainz Album Release Country', APEv2 raw RELEASECOUNTRY, ASF 'MusicBrainz/Album Release Country', WAV ICNT, Vorbis/Matroska raw RELEASECOUNTRY",
1393
+ type: "string",
1394
+ supportedFormats: [
1395
+ "ID3v2",
1396
+ "MP4",
1397
+ "Vorbis",
1398
+ "APE",
1399
+ "ASF",
1400
+ "Matroska",
1401
+ "WAV"
1402
+ ],
1403
+ mappings: {
1404
+ id3v2: {
1405
+ frame: "TXXX",
1406
+ description: "MusicBrainz Album Release Country"
1407
+ },
1408
+ vorbis: "RELEASECOUNTRY",
1409
+ mp4: "----:com.apple.iTunes:MusicBrainz Album Release Country"
1410
+ }
1411
+ },
1385
1412
  itunesAdvisory: {
1386
1413
  key: "ITUNESADVISORY",
1387
1414
  description: "Content advisory in the ITUNESADVISORY convention ('1' = explicit, '2' = clean, '0' = unspecified). On MP4 the value is stored in the native rtng atom and surfaced here. The typed tri-state lives on ExtendedTag.advisory; aliases CONTENTADVISORY and EXPLICIT resolve here",
@@ -2760,8 +2787,9 @@ var init_mirror_fields = __esm({
2760
2787
  });
2761
2788
 
2762
2789
  // src/utils/tag-mapping.ts
2763
- function readExtendedTag(audioFile) {
2764
- const tag = mapPropertiesToExtendedTag(audioFile.properties());
2790
+ function readExtendedTag(audioFile, includeProperties) {
2791
+ const props = audioFile.properties();
2792
+ const tag = mapPropertiesToExtendedTag(props);
2765
2793
  const pictures = audioFile.getPictures();
2766
2794
  if (pictures.length > 0) tag.pictures = pictures;
2767
2795
  const ratings = audioFile.getRatings();
@@ -2776,6 +2804,18 @@ function readExtendedTag(audioFile) {
2776
2804
  if (bextData !== void 0) tag.bextData = bextData;
2777
2805
  const ixml = audioFile.getIxml();
2778
2806
  if (ixml !== void 0) tag.ixml = ixml;
2807
+ if (includeProperties !== void 0 && includeProperties.length > 0) {
2808
+ const extraProperties = {};
2809
+ for (const wireKey of includeProperties) {
2810
+ const values = props[fromTagLibKey(wireKey)]?.filter((v) => v !== "");
2811
+ if (values !== void 0 && values.length > 0) {
2812
+ extraProperties[wireKey] = values;
2813
+ }
2814
+ }
2815
+ if (Object.keys(extraProperties).length > 0) {
2816
+ tag.extraProperties = extraProperties;
2817
+ }
2818
+ }
2779
2819
  return tag;
2780
2820
  }
2781
2821
  function mapPropertiesToExtendedTag(props) {
@@ -2824,7 +2864,7 @@ function mapPropertiesToExtendedTag(props) {
2824
2864
  const num = parseLeadingInt(values[0]);
2825
2865
  if (num !== void 0) tag[camelKey] = num;
2826
2866
  } else if (camelKey === "compilation") {
2827
- tag[camelKey] = values[0] === "1";
2867
+ tag[camelKey] = values[0] === "1" || values[0] === "true";
2828
2868
  } else if (camelKey === "itunesAdvisory") {
2829
2869
  tag[camelKey] = values;
2830
2870
  if (values[0] === "1") tag.advisory = "explicit";
@@ -2895,6 +2935,7 @@ function normalizeTagInput(input) {
2895
2935
  }
2896
2936
  for (const [field, val] of Object.entries(input)) {
2897
2937
  if (BASIC_FIELDS.has(field) || val === void 0) continue;
2938
+ if (field === "extraProperties") continue;
2898
2939
  if (field === "compilation") {
2899
2940
  props[field] = [val ? "1" : "0"];
2900
2941
  } else if (field === "advisory") {
@@ -2961,7 +3002,7 @@ var VERSION;
2961
3002
  var init_version = __esm({
2962
3003
  "src/version.ts"() {
2963
3004
  "use strict";
2964
- VERSION = "2.0.0";
3005
+ VERSION = "2.2.0";
2965
3006
  }
2966
3007
  });
2967
3008
 
@@ -3316,8 +3357,11 @@ async function withAudioFileSaveToFile(file, fn) {
3316
3357
  }
3317
3358
 
3318
3359
  // src/simple/tag-operations.ts
3319
- async function readTags(file) {
3320
- return withAudioFile(file, (audioFile) => readExtendedTag(audioFile));
3360
+ async function readTags(file, options = {}) {
3361
+ return withAudioFile(
3362
+ file,
3363
+ (audioFile) => readExtendedTag(audioFile, options.includeProperties)
3364
+ );
3321
3365
  }
3322
3366
  async function applyTags(file, tags) {
3323
3367
  return withAudioFileSave(file, (audioFile) => {
@@ -3495,7 +3539,7 @@ async function readTagsBatch(files, options = {}) {
3495
3539
  return executeBatch(
3496
3540
  files,
3497
3541
  options,
3498
- (audioFile) => readExtendedTag(audioFile)
3542
+ (audioFile) => readExtendedTag(audioFile, options.includeProperties)
3499
3543
  );
3500
3544
  }
3501
3545
  async function readPropertiesBatch(files, options = {}) {
@@ -3524,7 +3568,7 @@ function extractDynamics(audioFile) {
3524
3568
  if (appleSoundCheck) dynamics.appleSoundCheck = appleSoundCheck;
3525
3569
  return Object.keys(dynamics).length > 0 ? dynamics : void 0;
3526
3570
  }
3527
- async function readMetadata(file) {
3571
+ async function readMetadata(file, options = {}) {
3528
3572
  const taglib = await getTagLib();
3529
3573
  const audioFile = await taglib.open(file);
3530
3574
  try {
@@ -3545,7 +3589,7 @@ async function readMetadata(file) {
3545
3589
  }
3546
3590
  const dynamics = extractDynamics(audioFile);
3547
3591
  return {
3548
- tags: readExtendedTag(audioFile),
3592
+ tags: readExtendedTag(audioFile, options.includeProperties),
3549
3593
  properties: audioFile.audioProperties(),
3550
3594
  hasCoverArt: audioFile.getPictures().length > 0,
3551
3595
  ...dynamics !== void 0 ? { dynamics } : {}
@@ -3558,7 +3602,7 @@ async function readMetadataBatch(files, options = {}) {
3558
3602
  return executeBatch(files, options, (audioFile) => {
3559
3603
  const dynamics = extractDynamics(audioFile);
3560
3604
  return {
3561
- tags: readExtendedTag(audioFile),
3605
+ tags: readExtendedTag(audioFile, options.includeProperties),
3562
3606
  properties: audioFile.audioProperties(),
3563
3607
  hasCoverArt: audioFile.getPictures().length > 0,
3564
3608
  ...dynamics !== void 0 ? { dynamics } : {}
@@ -3644,6 +3688,12 @@ function getPropertiesByFormat(format) {
3644
3688
  (key) => PROPERTIES[key].supportedFormats.includes(format)
3645
3689
  );
3646
3690
  }
3691
+ function propertyValues(props, key) {
3692
+ return props[key] ?? [];
3693
+ }
3694
+ function propertyValue(props, key) {
3695
+ return props[key]?.[0];
3696
+ }
3647
3697
 
3648
3698
  // src/web-utils/data-url.ts
3649
3699
  init_classes();
@@ -3833,6 +3883,8 @@ export {
3833
3883
  isValidProperty,
3834
3884
  loadTagLibModule,
3835
3885
  pictureToDataURL,
3886
+ propertyValue,
3887
+ propertyValues,
3836
3888
  readCoverArt,
3837
3889
  readFormat,
3838
3890
  readMetadata,
package/dist/index.d.ts CHANGED
@@ -40,10 +40,10 @@ export { EnvironmentError, FileOperationError, InvalidFormatError, isEnvironment
40
40
  export type { TagLibErrorCode } from "./src/errors.js";
41
41
  export { initializeForDenoCompile, isDenoCompiled, prepareWasmForEmbedding, } from "./src/deno-compile.js";
42
42
  export { addPicture, applyCoverArt, applyPictures, applyTags, applyTagsToFile, type BatchItem, type BatchOptions, type BatchResult, clearPictures, clearTags, type FileMetadata, findPictureByType, isValidAudioFile, readCoverArt, readFormat, readMetadata, readMetadataBatch, readPictureMetadata, readPictures, readProperties, readPropertiesBatch, readTags, readTagsBatch, replacePictureByType, setBufferMode, } from "./src/simple/index.js";
43
- export { FormatMappings, getAllProperties, getAllPropertyKeys, getPropertiesByFormat, getPropertyMetadata, isValidProperty, PROPERTIES, } from "./src/constants.js";
43
+ export { FormatMappings, getAllProperties, getAllPropertyKeys, getPropertiesByFormat, getPropertyMetadata, isValidProperty, PROPERTIES, propertyValue, propertyValues, } from "./src/constants.js";
44
44
  export type { PropertyMetadata } from "./src/constants/property-types.js";
45
45
  export { copyCoverArt, exportAllPictures, exportCoverArt, exportPictureByType, findCoverArtFiles, importCoverArt, importPictureWithType, loadPictureFromFile, savePictureToFile, } from "./src/file-utils/index.js";
46
- export { type AlbumDisc, type AlbumGroup, type AlbumGroupingResult, type AlbumGroupItem, type AlbumGroupKey, type AudioDynamics, type AudioFileMetadata, type DiscConfidence, type DiscFolderInfo, discFolderInfo, type DuplicateGroup, exportFolderMetadata, findDuplicates, type FolderScanItem, type FolderScanOptions, type FolderScanResult, type FolderUpdateItem, type FolderUpdateResult, groupAlbums, type GroupAlbumsOptions, scanFolder, scanForAlbums, type ScanForAlbumsOptions, updateFolderTags, } from "./src/folder-api/index.js";
46
+ export { type AlbumDisc, type AlbumGroup, type AlbumGroupingResult, type AlbumGroupItem, type AlbumGroupKey, type AudioDynamics, type AudioFileMetadata, type DiscConfidence, type DiscFolderInfo, discFolderInfo, type DuplicateGroup, exportFolderMetadata, findDuplicates, type FolderScanItem, type FolderScanOptions, type FolderScanResult, groupAlbums, type GroupAlbumsOptions, scanFolder, scanForAlbums, type ScanForAlbumsOptions, } from "./src/folder-api/index.js";
47
47
  export { canvasToPicture, createPictureDownloadURL, createPictureGallery, dataURLToPicture, displayPicture, imageFileToPicture, pictureToDataURL, setCoverArtFromCanvas, } from "./src/web-utils/index.js";
48
48
  export type { AudioCodec, AudioFileInput, AudioProperties, BitrateControlMode, BroadcastAudioExtension, Chapter, ContainerFormat, ExtendedTag, FieldMapping, FileType, NamedAudioInput, OpenOptions, Picture, PictureType, PropertyMap, SetChaptersOptions, Tag, TagInput, } from "./src/types.js";
49
49
  export { BITRATE_CONTROL_MODE_NAMES, BITRATE_CONTROL_MODE_VALUES, PICTURE_TYPE_NAMES, PICTURE_TYPE_VALUES, } from "./src/types.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAGH,YAAY,EACV,SAAS,EACT,cAAc,GACf,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACtE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,eAAe,EACf,aAAa,EACb,wBAAwB,EACxB,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGvD,OAAO,EACL,wBAAwB,EACxB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,CAAC;AACpD,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAG1E,OAAO,KAAK,GAAG,MAAM,mBAAmB,CAAC;AAGzC,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC9D,YAAY,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC"}
package/dist/index.js CHANGED
@@ -54,7 +54,9 @@ import {
54
54
  getPropertiesByFormat,
55
55
  getPropertyMetadata,
56
56
  isValidProperty,
57
- PROPERTIES
57
+ PROPERTIES,
58
+ propertyValue,
59
+ propertyValues
58
60
  } from "./src/constants.js";
59
61
  import {
60
62
  copyCoverArt,
@@ -73,8 +75,7 @@ import {
73
75
  findDuplicates,
74
76
  groupAlbums,
75
77
  scanFolder,
76
- scanForAlbums,
77
- updateFolderTags
78
+ scanForAlbums
78
79
  } from "./src/folder-api/index.js";
79
80
  import {
80
81
  canvasToPicture,
@@ -161,6 +162,8 @@ export {
161
162
  loadTagLibModule,
162
163
  pictureToDataURL,
163
164
  prepareWasmForEmbedding,
165
+ propertyValue,
166
+ propertyValues,
164
167
  readCoverArt,
165
168
  readFormat,
166
169
  readMetadata,
@@ -176,6 +179,5 @@ export {
176
179
  scanFolder,
177
180
  scanForAlbums,
178
181
  setBufferMode,
179
- setCoverArtFromCanvas,
180
- updateFolderTags
182
+ setCoverArtFromCanvas
181
183
  };
@@ -1,8 +1,13 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __getOwnPropNames = Object.getOwnPropertyNames;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
- var __esm = (fn, res) => function __init() {
5
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
4
+ var __esm = (fn, res, err) => function __init() {
5
+ if (err) throw err[0];
6
+ try {
7
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
8
+ } catch (e) {
9
+ throw err = [e], e;
10
+ }
6
11
  };
7
12
  var __export = (target, all) => {
8
13
  for (var name in all)
@@ -1314,6 +1319,28 @@ var init_specialized_properties = __esm({
1314
1319
  mp4: "----:com.apple.iTunes:MusicBrainz Album Type"
1315
1320
  }
1316
1321
  },
1322
+ releaseCountry: {
1323
+ key: "RELEASECOUNTRY",
1324
+ description: "Release country (ISO 3166-1 code, e.g. 'US'). TagLib 2.3.1 translates the RELEASECOUNTRY key per format: ID3v2 TXXX 'MUSICBRAINZ ALBUM RELEASE COUNTRY' (TagLib's description casing; an uppercase TXXX:RELEASECOUNTRY description also reads back), MP4 freeform atom 'MusicBrainz Album Release Country', APEv2 raw RELEASECOUNTRY, ASF 'MusicBrainz/Album Release Country', WAV ICNT, Vorbis/Matroska raw RELEASECOUNTRY",
1325
+ type: "string",
1326
+ supportedFormats: [
1327
+ "ID3v2",
1328
+ "MP4",
1329
+ "Vorbis",
1330
+ "APE",
1331
+ "ASF",
1332
+ "Matroska",
1333
+ "WAV"
1334
+ ],
1335
+ mappings: {
1336
+ id3v2: {
1337
+ frame: "TXXX",
1338
+ description: "MusicBrainz Album Release Country"
1339
+ },
1340
+ vorbis: "RELEASECOUNTRY",
1341
+ mp4: "----:com.apple.iTunes:MusicBrainz Album Release Country"
1342
+ }
1343
+ },
1317
1344
  itunesAdvisory: {
1318
1345
  key: "ITUNESADVISORY",
1319
1346
  description: "Content advisory in the ITUNESADVISORY convention ('1' = explicit, '2' = clean, '0' = unspecified). On MP4 the value is stored in the native rtng atom and surfaced here. The typed tri-state lives on ExtendedTag.advisory; aliases CONTENTADVISORY and EXPLICIT resolve here",
@@ -2692,8 +2719,9 @@ var init_mirror_fields = __esm({
2692
2719
  });
2693
2720
 
2694
2721
  // src/utils/tag-mapping.ts
2695
- function readExtendedTag(audioFile) {
2696
- const tag = mapPropertiesToExtendedTag(audioFile.properties());
2722
+ function readExtendedTag(audioFile, includeProperties) {
2723
+ const props = audioFile.properties();
2724
+ const tag = mapPropertiesToExtendedTag(props);
2697
2725
  const pictures = audioFile.getPictures();
2698
2726
  if (pictures.length > 0) tag.pictures = pictures;
2699
2727
  const ratings = audioFile.getRatings();
@@ -2708,6 +2736,18 @@ function readExtendedTag(audioFile) {
2708
2736
  if (bextData !== void 0) tag.bextData = bextData;
2709
2737
  const ixml = audioFile.getIxml();
2710
2738
  if (ixml !== void 0) tag.ixml = ixml;
2739
+ if (includeProperties !== void 0 && includeProperties.length > 0) {
2740
+ const extraProperties = {};
2741
+ for (const wireKey of includeProperties) {
2742
+ const values = props[fromTagLibKey(wireKey)]?.filter((v) => v !== "");
2743
+ if (values !== void 0 && values.length > 0) {
2744
+ extraProperties[wireKey] = values;
2745
+ }
2746
+ }
2747
+ if (Object.keys(extraProperties).length > 0) {
2748
+ tag.extraProperties = extraProperties;
2749
+ }
2750
+ }
2711
2751
  return tag;
2712
2752
  }
2713
2753
  function mapPropertiesToExtendedTag(props) {
@@ -2756,7 +2796,7 @@ function mapPropertiesToExtendedTag(props) {
2756
2796
  const num = parseLeadingInt(values[0]);
2757
2797
  if (num !== void 0) tag[camelKey] = num;
2758
2798
  } else if (camelKey === "compilation") {
2759
- tag[camelKey] = values[0] === "1";
2799
+ tag[camelKey] = values[0] === "1" || values[0] === "true";
2760
2800
  } else if (camelKey === "itunesAdvisory") {
2761
2801
  tag[camelKey] = values;
2762
2802
  if (values[0] === "1") tag.advisory = "explicit";
@@ -2827,6 +2867,7 @@ function normalizeTagInput(input) {
2827
2867
  }
2828
2868
  for (const [field, val] of Object.entries(input)) {
2829
2869
  if (BASIC_FIELDS.has(field) || val === void 0) continue;
2870
+ if (field === "extraProperties") continue;
2830
2871
  if (field === "compilation") {
2831
2872
  props[field] = [val ? "1" : "0"];
2832
2873
  } else if (field === "advisory") {
@@ -2893,7 +2934,7 @@ var VERSION;
2893
2934
  var init_version = __esm({
2894
2935
  "src/version.ts"() {
2895
2936
  "use strict";
2896
- VERSION = "2.0.0";
2937
+ VERSION = "2.2.0";
2897
2938
  }
2898
2939
  });
2899
2940
 
@@ -3242,8 +3283,11 @@ async function withAudioFileSaveToFile(file, fn) {
3242
3283
  }
3243
3284
 
3244
3285
  // src/simple/tag-operations.ts
3245
- async function readTags(file) {
3246
- return withAudioFile(file, (audioFile) => readExtendedTag(audioFile));
3286
+ async function readTags(file, options = {}) {
3287
+ return withAudioFile(
3288
+ file,
3289
+ (audioFile) => readExtendedTag(audioFile, options.includeProperties)
3290
+ );
3247
3291
  }
3248
3292
  async function applyTags(file, tags) {
3249
3293
  return withAudioFileSave(file, (audioFile) => {
@@ -3421,7 +3465,7 @@ async function readTagsBatch(files, options = {}) {
3421
3465
  return executeBatch(
3422
3466
  files,
3423
3467
  options,
3424
- (audioFile) => readExtendedTag(audioFile)
3468
+ (audioFile) => readExtendedTag(audioFile, options.includeProperties)
3425
3469
  );
3426
3470
  }
3427
3471
  async function readPropertiesBatch(files, options = {}) {
@@ -3450,7 +3494,7 @@ function extractDynamics(audioFile) {
3450
3494
  if (appleSoundCheck) dynamics.appleSoundCheck = appleSoundCheck;
3451
3495
  return Object.keys(dynamics).length > 0 ? dynamics : void 0;
3452
3496
  }
3453
- async function readMetadata(file) {
3497
+ async function readMetadata(file, options = {}) {
3454
3498
  const taglib = await getTagLib();
3455
3499
  const audioFile = await taglib.open(file);
3456
3500
  try {
@@ -3471,7 +3515,7 @@ async function readMetadata(file) {
3471
3515
  }
3472
3516
  const dynamics = extractDynamics(audioFile);
3473
3517
  return {
3474
- tags: readExtendedTag(audioFile),
3518
+ tags: readExtendedTag(audioFile, options.includeProperties),
3475
3519
  properties: audioFile.audioProperties(),
3476
3520
  hasCoverArt: audioFile.getPictures().length > 0,
3477
3521
  ...dynamics !== void 0 ? { dynamics } : {}
@@ -3484,13 +3528,59 @@ async function readMetadataBatch(files, options = {}) {
3484
3528
  return executeBatch(files, options, (audioFile) => {
3485
3529
  const dynamics = extractDynamics(audioFile);
3486
3530
  return {
3487
- tags: readExtendedTag(audioFile),
3531
+ tags: readExtendedTag(audioFile, options.includeProperties),
3488
3532
  properties: audioFile.audioProperties(),
3489
3533
  hasCoverArt: audioFile.getPictures().length > 0,
3490
3534
  ...dynamics !== void 0 ? { dynamics } : {}
3491
3535
  };
3492
3536
  });
3493
3537
  }
3538
+ function entryPath(entry) {
3539
+ return typeof entry === "string" ? entry : entry.path;
3540
+ }
3541
+ async function executeWriteBatch(entries, options, writer) {
3542
+ if (entries.length === 0) return { items: [], duration: 0 };
3543
+ await getTagLib();
3544
+ const startTime = Date.now();
3545
+ const { concurrency = 4, continueOnError = true, onProgress, signal } = options;
3546
+ const items = new Array(entries.length);
3547
+ let processed = 0;
3548
+ const total = entries.length;
3549
+ for (let i = 0; i < entries.length; i += concurrency) {
3550
+ signal?.throwIfAborted();
3551
+ const chunk = entries.slice(i, i + concurrency);
3552
+ const chunkPromises = chunk.map(async (entry, idx) => {
3553
+ const index = i + idx;
3554
+ const path = entryPath(entry);
3555
+ try {
3556
+ await writer(path);
3557
+ items[index] = { status: "ok", path, data: void 0 };
3558
+ } catch (error) {
3559
+ const err = error instanceof Error ? error : new Error(String(error));
3560
+ items[index] = { status: "error", path, error: err };
3561
+ if (!continueOnError) throw err;
3562
+ }
3563
+ processed++;
3564
+ onProgress?.(processed, total, path);
3565
+ });
3566
+ await Promise.all(chunkPromises);
3567
+ }
3568
+ return { items, duration: Date.now() - startTime };
3569
+ }
3570
+ async function writeTagsBatch(updates, options = {}) {
3571
+ const byPath = new Map(updates.map((u) => [u.path, u]));
3572
+ return executeWriteBatch(updates, options, (path) => {
3573
+ const update = byPath.get(path);
3574
+ return applyTagsToFile(path, update.tags);
3575
+ });
3576
+ }
3577
+ async function editTagsBatch(files, mutator, options = {}) {
3578
+ return executeWriteBatch(
3579
+ files,
3580
+ options,
3581
+ (path) => withAudioFileSaveToFile(path, mutator)
3582
+ );
3583
+ }
3494
3584
 
3495
3585
  // src/simple/index.ts
3496
3586
  init_types2();
@@ -3504,6 +3594,7 @@ export {
3504
3594
  applyTagsToFile,
3505
3595
  clearPictures,
3506
3596
  clearTags,
3597
+ editTagsBatch,
3507
3598
  findPictureByType,
3508
3599
  getTagLib,
3509
3600
  isValidAudioFile,
@@ -3518,5 +3609,6 @@ export {
3518
3609
  readTags,
3519
3610
  readTagsBatch,
3520
3611
  replacePictureByType,
3521
- setBufferMode
3612
+ setBufferMode,
3613
+ writeTagsBatch
3522
3614
  };
@@ -311,6 +311,20 @@ export declare const PROPERTIES: {
311
311
  readonly mp4: "----:com.apple.iTunes:MusicBrainz Album Type";
312
312
  };
313
313
  };
314
+ readonly releaseCountry: {
315
+ readonly key: "RELEASECOUNTRY";
316
+ readonly description: "Release country (ISO 3166-1 code, e.g. 'US'). TagLib 2.3.1 translates the RELEASECOUNTRY key per format: ID3v2 TXXX 'MUSICBRAINZ ALBUM RELEASE COUNTRY' (TagLib's description casing; an uppercase TXXX:RELEASECOUNTRY description also reads back), MP4 freeform atom 'MusicBrainz Album Release Country', APEv2 raw RELEASECOUNTRY, ASF 'MusicBrainz/Album Release Country', WAV ICNT, Vorbis/Matroska raw RELEASECOUNTRY";
317
+ readonly type: "string";
318
+ readonly supportedFormats: readonly ["ID3v2", "MP4", "Vorbis", "APE", "ASF", "Matroska", "WAV"];
319
+ readonly mappings: {
320
+ readonly id3v2: {
321
+ readonly frame: "TXXX";
322
+ readonly description: "MusicBrainz Album Release Country";
323
+ };
324
+ readonly vorbis: "RELEASECOUNTRY";
325
+ readonly mp4: "----:com.apple.iTunes:MusicBrainz Album Release Country";
326
+ };
327
+ };
314
328
  readonly itunesAdvisory: {
315
329
  readonly key: "ITUNESADVISORY";
316
330
  readonly description: "Content advisory in the ITUNESADVISORY convention ('1' = explicit, '2' = clean, '0' = unspecified). On MP4 the value is stored in the native rtng atom and surfaced here. The typed tri-state lives on ExtendedTag.advisory; aliases CONTENTADVISORY and EXPLICIT resolve here";
@@ -1 +1 @@
1
- {"version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IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE/D;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAOzE;AAED,mGAAmG;AACnG,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,qEAAqE;AACrE,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GACrB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CASnB;AAGD,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -73,6 +73,20 @@ export declare const SPECIALIZED_PROPERTIES: {
73
73
  readonly mp4: "----:com.apple.iTunes:MusicBrainz Album Type";
74
74
  };
75
75
  };
76
+ readonly releaseCountry: {
77
+ readonly key: "RELEASECOUNTRY";
78
+ readonly description: "Release country (ISO 3166-1 code, e.g. 'US'). TagLib 2.3.1 translates the RELEASECOUNTRY key per format: ID3v2 TXXX 'MUSICBRAINZ ALBUM RELEASE COUNTRY' (TagLib's description casing; an uppercase TXXX:RELEASECOUNTRY description also reads back), MP4 freeform atom 'MusicBrainz Album Release Country', APEv2 raw RELEASECOUNTRY, ASF 'MusicBrainz/Album Release Country', WAV ICNT, Vorbis/Matroska raw RELEASECOUNTRY";
79
+ readonly type: "string";
80
+ readonly supportedFormats: readonly ["ID3v2", "MP4", "Vorbis", "APE", "ASF", "Matroska", "WAV"];
81
+ readonly mappings: {
82
+ readonly id3v2: {
83
+ readonly frame: "TXXX";
84
+ readonly description: "MusicBrainz Album Release Country";
85
+ };
86
+ readonly vorbis: "RELEASECOUNTRY";
87
+ readonly mp4: "----:com.apple.iTunes:MusicBrainz Album Release Country";
88
+ };
89
+ };
76
90
  readonly itunesAdvisory: {
77
91
  readonly key: "ITUNESADVISORY";
78
92
  readonly description: "Content advisory in the ITUNESADVISORY convention ('1' = explicit, '2' = clean, '0' = unspecified). On MP4 the value is stored in the native rtng atom and surfaced here. The typed tri-state lives on ExtendedTag.advisory; aliases CONTENTADVISORY and EXPLICIT resolve here";
@@ -1 +1 @@
1
- {"version":3,"file":"specialized-properties.d.ts","sourceRoot":"","sources":["../../../src/constants/specialized-properties.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAwLjC;;;;;;;;OAQG;;;;;;;;;;;;;;;CAYK,CAAC"}
1
+ {"version":3,"file":"specialized-properties.d.ts","sourceRoot":"","sources":["../../../src/constants/specialized-properties.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA+MjC;;;;;;;;OAQG;;;;;;;;;;;;;;;CAYK,CAAC"}
@@ -62,6 +62,28 @@ const SPECIALIZED_PROPERTIES = {
62
62
  mp4: "----:com.apple.iTunes:MusicBrainz Album Type"
63
63
  }
64
64
  },
65
+ releaseCountry: {
66
+ key: "RELEASECOUNTRY",
67
+ description: "Release country (ISO 3166-1 code, e.g. 'US'). TagLib 2.3.1 translates the RELEASECOUNTRY key per format: ID3v2 TXXX 'MUSICBRAINZ ALBUM RELEASE COUNTRY' (TagLib's description casing; an uppercase TXXX:RELEASECOUNTRY description also reads back), MP4 freeform atom 'MusicBrainz Album Release Country', APEv2 raw RELEASECOUNTRY, ASF 'MusicBrainz/Album Release Country', WAV ICNT, Vorbis/Matroska raw RELEASECOUNTRY",
68
+ type: "string",
69
+ supportedFormats: [
70
+ "ID3v2",
71
+ "MP4",
72
+ "Vorbis",
73
+ "APE",
74
+ "ASF",
75
+ "Matroska",
76
+ "WAV"
77
+ ],
78
+ mappings: {
79
+ id3v2: {
80
+ frame: "TXXX",
81
+ description: "MusicBrainz Album Release Country"
82
+ },
83
+ vorbis: "RELEASECOUNTRY",
84
+ mp4: "----:com.apple.iTunes:MusicBrainz Album Release Country"
85
+ }
86
+ },
65
87
  itunesAdvisory: {
66
88
  key: "ITUNESADVISORY",
67
89
  description: "Content advisory in the ITUNESADVISORY convention ('1' = explicit, '2' = clean, '0' = unspecified). On MP4 the value is stored in the native rtng atom and surfaced here. The typed tri-state lives on ExtendedTag.advisory; aliases CONTENTADVISORY and EXPLICIT resolve here",
@@ -1,4 +1,5 @@
1
1
  import { PROPERTIES, type PropertyKey } from "./properties.js";
2
+ import type { PropertyMap } from "../types/tags.js";
2
3
  import type { PropertyMetadata } from "./property-types.js";
3
4
  /**
4
5
  * Type guard to check if a string is a valid property key
@@ -23,4 +24,16 @@ export declare function getAllProperties(): readonly [
23
24
  * Filter properties by supported format
24
25
  */
25
26
  export declare function getPropertiesByFormat(format: string): PropertyKey[];
27
+ /**
28
+ * All values for a property key in a PropertyMap; `[]` when absent
29
+ * (taglib-lk8u). Removes the narrowing filter at the call site: the map's
30
+ * index signature must admit undefined, so a bare read is
31
+ * `string[] | undefined` even for known keys.
32
+ */
33
+ export declare function propertyValues(props: PropertyMap, key: string): string[];
34
+ /**
35
+ * First value for a property key in a PropertyMap; `undefined` when absent.
36
+ * The common single-value read, without the `?.[0]` at every call site.
37
+ */
38
+ export declare function propertyValue(props: PropertyMap, key: string): string | undefined;
26
39
  //# sourceMappingURL=utilities.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../../src/constants/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,WAAW,CAE/D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,WAAW,EACvD,GAAG,EAAE,CAAC,GACL,gBAAgB,GAAG,SAAS,CAE9B;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,SAAS,WAAW,EAAE,CAE3D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,SAAS;IAC3C,WAAW;IACX,OAAO,UAAU,CAAC,WAAW,CAAC;CAC/B,EAAE,CAKF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE,CAInE"}
1
+ {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../../src/constants/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,WAAW,CAE/D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,WAAW,EACvD,GAAG,EAAE,CAAC,GACL,gBAAgB,GAAG,SAAS,CAE9B;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,SAAS,WAAW,EAAE,CAE3D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,SAAS;IAC3C,WAAW;IACX,OAAO,UAAU,CAAC,WAAW,CAAC;CAC/B,EAAE,CAKF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE,CAInE;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAExE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,WAAW,EAClB,GAAG,EAAE,MAAM,GACV,MAAM,GAAG,SAAS,CAEpB"}
@@ -16,10 +16,18 @@ function getPropertiesByFormat(format) {
16
16
  (key) => PROPERTIES[key].supportedFormats.includes(format)
17
17
  );
18
18
  }
19
+ function propertyValues(props, key) {
20
+ return props[key] ?? [];
21
+ }
22
+ function propertyValue(props, key) {
23
+ return props[key]?.[0];
24
+ }
19
25
  export {
20
26
  getAllProperties,
21
27
  getAllPropertyKeys,
22
28
  getPropertiesByFormat,
23
29
  getPropertyMetadata,
24
- isValidProperty
30
+ isValidProperty,
31
+ propertyValue,
32
+ propertyValues
25
33
  };