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.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +28 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -856,4 +856,10 @@ interface UseGameRecordingReturn {
|
|
|
856
856
|
*/
|
|
857
857
|
declare function useGameRecording({ getCanvasElement, }: UseGameRecordingProps): UseGameRecordingReturn;
|
|
858
858
|
|
|
859
|
-
|
|
859
|
+
/**
|
|
860
|
+
* Get a ROM blob from the browser cache
|
|
861
|
+
*/
|
|
862
|
+
declare function getCachedRom(romId: string): Promise<Blob | null>;
|
|
863
|
+
declare function fetchAndCacheRom(romId: string, url: string): Promise<Blob>;
|
|
864
|
+
|
|
865
|
+
export { ALL_BUTTONS, AchievementPopup, BUTTON_GROUPS, BUTTON_LABELS, type ButtonId, CONSOLE_CAPABILITIES, CONSOLE_KEYBOARD_OVERRIDES, type Cheat, type CheatModalProps, type ConsoleCapabilities, type ControlConfig, type ControlMapperProps, type ControlMapping, type ControllerBrand, DEFAULT_CONTROLS, DEFAULT_GAMEPAD, DEFAULT_KEYBOARD, DPAD_BUTTONS, type EmulatorStatus, FACE_BUTTONS, GamePlayer, type GamePlayerProps, type GamepadInfo, type GamepadMapping, type KeyboardMapping, PERFORMANCE_TIER_1_SYSTEMS, PERFORMANCE_TIER_2_SYSTEMS, type PlayerControlsProps, type PlayerIndex, type RAAchievement, type RACredentials, type RAGame, type RAGameExtended, type RAHardcodeRestrictions, RASidebar, type RAUser, RA_MEDIA_BASE, type RetroAchievementsConfig, SHADER_PRESETS, SHOULDER_BUTTONS, STANDARD_AXIS_MAP, STANDARD_GAMEPAD_BUTTONS, STICK_BUTTONS, SUPPORTED_EXTENSIONS, SYSTEMS, SYSTEM_BUTTONS, type SaveSlot, type SaveSlotModalProps, type ShaderPresetId, ShaderSelector, ShortcutsReference, type ShowToastOptions, type SpeedMultiplier, type StandardAxis, type SystemConfig, TRIGGER_BUTTONS, type Toast, ToastContainer, type ToastType, type UseGamepadOptions, type UseGamepadReturn, type UseNostalgistReturn, type UseToastReturn, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -856,4 +856,10 @@ interface UseGameRecordingReturn {
|
|
|
856
856
|
*/
|
|
857
857
|
declare function useGameRecording({ getCanvasElement, }: UseGameRecordingProps): UseGameRecordingReturn;
|
|
858
858
|
|
|
859
|
-
|
|
859
|
+
/**
|
|
860
|
+
* Get a ROM blob from the browser cache
|
|
861
|
+
*/
|
|
862
|
+
declare function getCachedRom(romId: string): Promise<Blob | null>;
|
|
863
|
+
declare function fetchAndCacheRom(romId: string, url: string): Promise<Blob>;
|
|
864
|
+
|
|
865
|
+
export { ALL_BUTTONS, AchievementPopup, BUTTON_GROUPS, BUTTON_LABELS, type ButtonId, CONSOLE_CAPABILITIES, CONSOLE_KEYBOARD_OVERRIDES, type Cheat, type CheatModalProps, type ConsoleCapabilities, type ControlConfig, type ControlMapperProps, type ControlMapping, type ControllerBrand, DEFAULT_CONTROLS, DEFAULT_GAMEPAD, DEFAULT_KEYBOARD, DPAD_BUTTONS, type EmulatorStatus, FACE_BUTTONS, GamePlayer, type GamePlayerProps, type GamepadInfo, type GamepadMapping, type KeyboardMapping, PERFORMANCE_TIER_1_SYSTEMS, PERFORMANCE_TIER_2_SYSTEMS, type PlayerControlsProps, type PlayerIndex, type RAAchievement, type RACredentials, type RAGame, type RAGameExtended, type RAHardcodeRestrictions, RASidebar, type RAUser, RA_MEDIA_BASE, type RetroAchievementsConfig, SHADER_PRESETS, SHOULDER_BUTTONS, STANDARD_AXIS_MAP, STANDARD_GAMEPAD_BUTTONS, STICK_BUTTONS, SUPPORTED_EXTENSIONS, SYSTEMS, SYSTEM_BUTTONS, type SaveSlot, type SaveSlotModalProps, type ShaderPresetId, ShaderSelector, ShortcutsReference, type ShowToastOptions, type SpeedMultiplier, type StandardAxis, type SystemConfig, TRIGGER_BUTTONS, type Toast, ToastContainer, type ToastType, type UseGamepadOptions, type UseGamepadReturn, type UseNostalgistReturn, type UseToastReturn, 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 };
|
package/dist/index.js
CHANGED
|
@@ -5662,22 +5662,36 @@ async function getCachedRom(romId) {
|
|
|
5662
5662
|
}
|
|
5663
5663
|
return null;
|
|
5664
5664
|
}
|
|
5665
|
+
var pendingFetches = /* @__PURE__ */ new Map();
|
|
5665
5666
|
async function fetchAndCacheRom(romId, url) {
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5667
|
+
if (pendingFetches.has(romId)) {
|
|
5668
|
+
console.log(`[Cache] Joining in-flight fetch for ${romId}`);
|
|
5669
|
+
return pendingFetches.get(romId);
|
|
5669
5670
|
}
|
|
5670
|
-
const
|
|
5671
|
-
if (typeof caches !== "undefined") {
|
|
5671
|
+
const fetchPromise = (async () => {
|
|
5672
5672
|
try {
|
|
5673
|
-
const
|
|
5674
|
-
|
|
5675
|
-
console.log(`[Cache]
|
|
5676
|
-
|
|
5677
|
-
|
|
5673
|
+
const cached = await getCachedRom(romId);
|
|
5674
|
+
if (cached) return cached;
|
|
5675
|
+
console.log(`[Cache] Fetching ROM ${romId}...`);
|
|
5676
|
+
const response = await fetch(url);
|
|
5677
|
+
if (!response.ok) throw new Error(`Failed to fetch ROM: ${response.statusText}`);
|
|
5678
|
+
const blob = await response.blob();
|
|
5679
|
+
if (typeof caches !== "undefined") {
|
|
5680
|
+
try {
|
|
5681
|
+
const cache = await caches.open(CACHE_NAME);
|
|
5682
|
+
await cache.put(romId, new Response(blob));
|
|
5683
|
+
console.log(`[Cache] Cached ROM ${romId}`);
|
|
5684
|
+
} catch (e) {
|
|
5685
|
+
console.warn("[Cache] Write failed:", e);
|
|
5686
|
+
}
|
|
5687
|
+
}
|
|
5688
|
+
return blob;
|
|
5689
|
+
} finally {
|
|
5690
|
+
pendingFetches.delete(romId);
|
|
5678
5691
|
}
|
|
5679
|
-
}
|
|
5680
|
-
|
|
5692
|
+
})();
|
|
5693
|
+
pendingFetches.set(romId, fetchPromise);
|
|
5694
|
+
return fetchPromise;
|
|
5681
5695
|
}
|
|
5682
5696
|
|
|
5683
5697
|
// src/hooks/emulator/useEmulatorCore.ts
|
|
@@ -8220,10 +8234,12 @@ exports.clearAllControls = clearAllControls;
|
|
|
8220
8234
|
exports.consoleHasButton = consoleHasButton;
|
|
8221
8235
|
exports.detectControllerBrand = detectControllerBrand;
|
|
8222
8236
|
exports.detectSystem = detectSystem;
|
|
8237
|
+
exports.fetchAndCacheRom = fetchAndCacheRom;
|
|
8223
8238
|
exports.formatGamepadButton = formatGamepadButton;
|
|
8224
8239
|
exports.formatKeyCode = formatKeyCode;
|
|
8225
8240
|
exports.gamepadToRetroArchConfig = gamepadToRetroArchConfig;
|
|
8226
8241
|
exports.getAchievementBadgeUrl = getAchievementBadgeUrl;
|
|
8242
|
+
exports.getCachedRom = getCachedRom;
|
|
8227
8243
|
exports.getConsoleButtons = getConsoleButtons;
|
|
8228
8244
|
exports.getConsoleCapabilities = getConsoleCapabilities;
|
|
8229
8245
|
exports.getConsoleKeyboardDefaults = getConsoleKeyboardDefaults;
|