koin.js 1.0.6 → 1.0.7

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.mjs CHANGED
@@ -5656,22 +5656,36 @@ async function getCachedRom(romId) {
5656
5656
  }
5657
5657
  return null;
5658
5658
  }
5659
+ var pendingFetches = /* @__PURE__ */ new Map();
5659
5660
  async function fetchAndCacheRom(romId, url) {
5660
- const response = await fetch(url);
5661
- if (!response.ok) {
5662
- throw new Error(`Failed to fetch ROM: ${response.statusText}`);
5661
+ if (pendingFetches.has(romId)) {
5662
+ console.log(`[Cache] Joining in-flight fetch for ${romId}`);
5663
+ return pendingFetches.get(romId);
5663
5664
  }
5664
- const blob = await response.blob();
5665
- if (typeof caches !== "undefined") {
5665
+ const fetchPromise = (async () => {
5666
5666
  try {
5667
- const cache = await caches.open(CACHE_NAME);
5668
- await cache.put(romId, new Response(blob));
5669
- console.log(`[Cache] Cached ROM ${romId}`);
5670
- } catch (e) {
5671
- console.warn("[Cache] Write failed:", e);
5667
+ const cached = await getCachedRom(romId);
5668
+ if (cached) return cached;
5669
+ console.log(`[Cache] Fetching ROM ${romId}...`);
5670
+ const response = await fetch(url);
5671
+ if (!response.ok) throw new Error(`Failed to fetch ROM: ${response.statusText}`);
5672
+ const blob = await response.blob();
5673
+ if (typeof caches !== "undefined") {
5674
+ try {
5675
+ const cache = await caches.open(CACHE_NAME);
5676
+ await cache.put(romId, new Response(blob));
5677
+ console.log(`[Cache] Cached ROM ${romId}`);
5678
+ } catch (e) {
5679
+ console.warn("[Cache] Write failed:", e);
5680
+ }
5681
+ }
5682
+ return blob;
5683
+ } finally {
5684
+ pendingFetches.delete(romId);
5672
5685
  }
5673
- }
5674
- return blob;
5686
+ })();
5687
+ pendingFetches.set(romId, fetchPromise);
5688
+ return fetchPromise;
5675
5689
  }
5676
5690
 
5677
5691
  // src/hooks/emulator/useEmulatorCore.ts
@@ -8181,6 +8195,6 @@ var ShortcutsReference = memo(function ShortcutsReference2({
8181
8195
  });
8182
8196
  var ShortcutsReference_default = ShortcutsReference;
8183
8197
 
8184
- export { ALL_BUTTONS, AchievementPopup, BUTTON_GROUPS, BUTTON_LABELS, CONSOLE_CAPABILITIES, CONSOLE_KEYBOARD_OVERRIDES, DEFAULT_CONTROLS, DEFAULT_GAMEPAD, DEFAULT_KEYBOARD, DPAD_BUTTONS, FACE_BUTTONS, GamePlayer_default as GamePlayer, PERFORMANCE_TIER_1_SYSTEMS, PERFORMANCE_TIER_2_SYSTEMS, RASidebar, RA_MEDIA_BASE, SHADER_PRESETS, SHOULDER_BUTTONS, STANDARD_AXIS_MAP, STANDARD_GAMEPAD_BUTTONS, STICK_BUTTONS, SUPPORTED_EXTENSIONS, SYSTEMS, SYSTEM_BUTTONS, ShaderSelector_default as ShaderSelector, ShortcutsReference_default as ShortcutsReference, TRIGGER_BUTTONS, ToastContainer, buildRetroArchConfig, clearAllControls, consoleHasButton, detectControllerBrand, detectSystem, formatGamepadButton, formatKeyCode, gamepadToRetroArchConfig, getAchievementBadgeUrl, getConsoleButtons, getConsoleCapabilities, getConsoleKeyboardDefaults, getCore, getDBSystemNames, getFullGamepadMapping, getFullKeyboardMapping, getSupportedExtensions, getSystem, getSystemByDbName, getSystemByKey, getSystemFromExtension, getSystemsList, getUserAvatarUrl, isSystemSupported, keyboardToRetroArchConfig, loadAllGamepadMappings, loadGamepadMapping, loadKeyboardMapping, normalizeSystemKey, saveGamepadMapping, saveKeyboardMapping, systemsMatch, useGameRecording, useGamepad, useNostalgist, useToast };
8198
+ export { ALL_BUTTONS, AchievementPopup, BUTTON_GROUPS, BUTTON_LABELS, CONSOLE_CAPABILITIES, CONSOLE_KEYBOARD_OVERRIDES, DEFAULT_CONTROLS, DEFAULT_GAMEPAD, DEFAULT_KEYBOARD, DPAD_BUTTONS, FACE_BUTTONS, GamePlayer_default as GamePlayer, PERFORMANCE_TIER_1_SYSTEMS, PERFORMANCE_TIER_2_SYSTEMS, RASidebar, RA_MEDIA_BASE, SHADER_PRESETS, SHOULDER_BUTTONS, STANDARD_AXIS_MAP, STANDARD_GAMEPAD_BUTTONS, STICK_BUTTONS, SUPPORTED_EXTENSIONS, SYSTEMS, SYSTEM_BUTTONS, ShaderSelector_default as ShaderSelector, ShortcutsReference_default as ShortcutsReference, TRIGGER_BUTTONS, ToastContainer, buildRetroArchConfig, clearAllControls, consoleHasButton, detectControllerBrand, detectSystem, fetchAndCacheRom, formatGamepadButton, formatKeyCode, gamepadToRetroArchConfig, getAchievementBadgeUrl, getCachedRom, getConsoleButtons, getConsoleCapabilities, getConsoleKeyboardDefaults, getCore, getDBSystemNames, getFullGamepadMapping, getFullKeyboardMapping, getSupportedExtensions, getSystem, getSystemByDbName, getSystemByKey, getSystemFromExtension, getSystemsList, getUserAvatarUrl, isSystemSupported, keyboardToRetroArchConfig, loadAllGamepadMappings, loadGamepadMapping, loadKeyboardMapping, normalizeSystemKey, saveGamepadMapping, saveKeyboardMapping, systemsMatch, useGameRecording, useGamepad, useNostalgist, useToast };
8185
8199
  //# sourceMappingURL=index.mjs.map
8186
8200
  //# sourceMappingURL=index.mjs.map