@music-library/core — platform-agnostic TypeScript shared by the web and
mobile clients: the API client, player state machine, auth/session logic,
favorites, storage abstraction, and the event bus.
It ships raw TypeScript source (no build step); consumers compile it themselves.
src/
api.ts typed API client for the backend
auth/ auth/session core (React context-friendly)
favorites/ favorites core
player/ player state, queue, progress
events.ts event bus
storage.ts storage abstraction (localStorage / AsyncStorage adapters live in the consumers)
index.ts package entrypoint
- frontend imports it directly via
file:../coreplus Vite/tsconfig aliases that resolve@music-library/corestraight to../core/src. - mobile can't follow symlinks out of its project root (Metro), so it
consumes a synced copy at
mobile/packages/music-library-core. The copy is regenerated bynpm run sync:core(also runs onpostinstall) and is gitignored — edit only this package, never the copy.
npm install
npx tsc -p tsconfig.json --noEmit # typecheck
# after changes, refresh the mobile copy:
cd ../mobile && npm run sync:coreValidate consumers after cross-cutting changes: npm run typecheck in
frontend/, npm run lint in mobile/.