(engine: VisualNovelEngine)
| 217 | // ============================================================================ |
| 218 | |
| 219 | export async function audioBufferSpace(engine: VisualNovelEngine): Promise<Space | null> { |
| 220 | // If we already know IndexedDB isn't available, skip |
| 221 | if (engine._indexedDBAvailable === false) { |
| 222 | return null; |
| 223 | } |
| 224 | |
| 225 | if (!engine._audioBufferSpace) { |
| 226 | try { |
| 227 | engine._audioBufferSpace = new Space(SpaceAdapter.IndexedDB, { |
| 228 | name: `${Text.friendly(engine.setting('Name') as string)}_AudioCache`, |
| 229 | version: '1', |
| 230 | store: 'decodedAudio' |
| 231 | } as ConstructorParameters<typeof Space>[1]); |
| 232 | |
| 233 | await engine._audioBufferSpace.open(); |
| 234 | engine._indexedDBAvailable = true; |
| 235 | } catch (error) { |
| 236 | console.warn('IndexedDB not available for audio caching. Audio will still work but won\'t persist across sessions:', error); |
| 237 | engine._indexedDBAvailable = false; |
| 238 | return null; |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | return engine._audioBufferSpace; |
| 243 | } |
| 244 | |
| 245 | export function isIndexedDBAvailable(engine: VisualNovelEngine): boolean | null { |
| 246 | return engine._indexedDBAvailable; |
no test coverage detected