@novely/core 0.46.4 → 0.47.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.
package/dist/index.d.ts CHANGED
@@ -251,6 +251,7 @@ declare const getLanguage: (languages: string[]) => string;
251
251
 
252
252
  type NovelyAsset = {
253
253
  readonly source: string;
254
+ readonly id: string;
254
255
  readonly type: 'audio' | 'image';
255
256
  };
256
257
  type Thenable<T> = T | Promise<T>;
@@ -2661,6 +2661,7 @@ var Novely = (() => {
2661
2661
  loadImageFormatsSupport();
2662
2662
 
2663
2663
  // src/asset.ts
2664
+ var generateRandomId = () => Math.random().toString(36);
2664
2665
  var getType = memoize(
2665
2666
  (extensions) => {
2666
2667
  if (extensions.every((extension) => HOWLER_SUPPORTED_FILE_FORMATS.has(extension))) {
@@ -2714,7 +2715,8 @@ var Novely = (() => {
2714
2715
  },
2715
2716
  get type() {
2716
2717
  return type;
2717
- }
2718
+ },
2719
+ id: generateRandomId()
2718
2720
  };
2719
2721
  },
2720
2722
  {
@@ -2725,16 +2727,28 @@ var Novely = (() => {
2725
2727
  return assetPrivate(variants);
2726
2728
  };
2727
2729
  asset.image = (source) => {
2728
- return {
2730
+ if (assetPrivate.cache.has(source)) {
2731
+ return assetPrivate.cache.get(source);
2732
+ }
2733
+ const asset2 = {
2729
2734
  type: "image",
2730
- source
2735
+ source,
2736
+ id: generateRandomId()
2731
2737
  };
2738
+ assetPrivate.cache.set(source, asset2);
2739
+ return asset2;
2732
2740
  };
2733
2741
  asset.audio = (source) => {
2734
- return {
2742
+ if (assetPrivate.cache.has(source)) {
2743
+ return assetPrivate.cache.get(source);
2744
+ }
2745
+ const asset2 = {
2735
2746
  type: "audio",
2736
- source
2747
+ source,
2748
+ id: generateRandomId()
2737
2749
  };
2750
+ assetPrivate.cache.set(source, asset2);
2751
+ return asset2;
2738
2752
  };
2739
2753
  return __toCommonJS(src_exports);
2740
2754
  })();