Skip to content

feat: persist imported resource packs in IndexedDB with selection storage#47

Merged
Naptie merged 3 commits intomainfrom
copilot/store-resource-packs-locally
Mar 21, 2026
Merged

feat: persist imported resource packs in IndexedDB with selection storage#47
Naptie merged 3 commits intomainfrom
copilot/store-resource-packs-locally

Conversation

Copy link
Contributor

Copilot AI commented Mar 21, 2026

Resource packs were lost on page reload, requiring re-import and re-selection every session. Audio in resource packs is already FFmpeg-converted to WAV during import, so storing the post-conversion form eliminates re-processing on reload entirely.

Changes

  • New src/lib/services/respackStorage.ts — IndexedDB service (phizone_player database, resource_packs store) with saveRespack/loadAllRespacks/deleteRespack. Files are stored as {data: Blob, name, type} tuples and reconstructed as File objects on load. Selected pack ID persisted via localStorage.

  • src/routes/(app)/+page.svelte

    • Load stored packs from IndexedDB and restore selection before init()
    • addOrReplaceRespack() helper handles upsert + reactivity + async persistence
    • Select/delete handlers sync to localStorage/IndexedDB
    • Replaced commented-out _respackDB skeleton
  • i18n — Added saving_respack / loading_stored_respacks messages (en, zh)

Storage format

// File → StoredFile for IndexedDB structured clone compatibility
function fileToStored(file: File): StoredFile {
  return { data: file.slice(), name: file.name, type: file.type };
}

// StoredFile → File on reload
function storedToFile(stored: StoredFile): File {
  return new File([stored.data], stored.name, { type: stored.type });
}

Since audio is already WAV (48kHz stereo) post-import, canPlayType('audio/wav') passes on all browsers — no FFmpeg load or progress bar on reload.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cdn.jsdelivr.net
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/player/player/node_modules/.bin/../@inlang/paraglide-js/bin/run.js compile --project ./project.inlang (dns block)
  • eu.posthog.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/player/player/node_modules/.bin/../@inlang/paraglide-js/bin/run.js compile --project ./project.inlang (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

@vercel
Copy link

vercel bot commented Mar 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
player Ready Ready Preview, Comment Mar 21, 2026 0:17am

- Add respackStorage service using IndexedDB for storing resource packs
- Auto-load stored resource packs on page mount
- Save imported resource packs (with converted audio) to IndexedDB
- Persist selected resource pack ID in localStorage
- Remove stored resource packs from IndexedDB on deletion
- Handle de-duplication when re-importing existing packs
- Add i18n messages for saving/loading stored resource packs

Co-authored-by: Naptie <57532127+Naptie@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PhiZone/player/sessions/9a9239fc-1e4b-4616-a2c1-7b28f3770232
Copilot AI changed the title [WIP] Store imported resource packs locally using IndexedDB feat: persist imported resource packs in IndexedDB with selection storage Mar 21, 2026
Copilot AI requested a review from Naptie March 21, 2026 12:16
@Naptie Naptie marked this pull request as ready for review March 21, 2026 12:46
@Naptie Naptie merged commit a26fe57 into main Mar 21, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants