mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 07:15:47 +00:00
3dc50a2ef0
* refactor(orbit): extract constants, helpers, and state math First extraction step of the utils/orbit.ts split. Pure, no-I/O code moves into utils/orbit/ submodules; utils/orbit.ts becomes a re-export shim so every call site outside this directory keeps importing from '../utils/orbit' unchanged. - utils/orbit/constants.ts: ORBIT_HEARTBEAT_ALIVE_MS, ORBIT_ORPHAN_TTL_MS, ORBIT_SHUFFLE_INTERVAL_MS, ORBIT_REMOVED_TTL_MS. - utils/orbit/helpers.ts: generateSessionId, serialiseOrbitState + OrbitStateTooLarge, serialiseOutboxMeta, suggestionKey, parseOutboxPlaylistName. - utils/orbit/stateMath.ts: patchOrbitState, maybeShuffleQueue, effectiveShuffleIntervalMs, computeOrbitDriftMs, applyOutboxSnapshotsToState, OutboxSnapshot type. utils/orbit.ts: 989 → 806 LOC. * refactor(orbit): extract remote I/O + share link Pull readOrbitState / writeOrbitState / writeOrbitHeartbeat / findSessionPlaylistId into utils/orbit/remote.ts. Pull parseOrbitShareLink / buildOrbitShareLink + OrbitShareLink into utils/orbit/shareLink.ts. Re-exported from the orbit.ts shim. utils/orbit.ts: 806 → 721 LOC. * refactor(orbit): extract host lifecycle Pull startOrbitSession, endOrbitSession, triggerOrbitShuffleNow, updateOrbitSettings, hostEnqueueToOrbit (and the StartOrbitArgs interface) into utils/orbit/host.ts. Re-exported from the orbit.ts shim. utils/orbit.ts: 721 → 546 LOC. * refactor(orbit): extract host moderation Pull kickOrbitParticipant, removeOrbitParticipant, and setOrbitSuggestionBlocked into utils/orbit/moderation.ts. Re-exported from the orbit.ts shim. utils/orbit.ts: 546 → 422 LOC. * refactor(orbit): extract guest lifecycle + suggest pipeline Pull joinOrbitSession / leaveOrbitSession (+ OrbitJoinError), the suggest gate (evaluateOrbitSuggestGate / OrbitSuggestGateReason / OrbitSuggestBlockedError / suggestOrbitTrack), and the host-side approve / decline reactions into utils/orbit/guest.ts. Re-exported from the orbit.ts shim. utils/orbit.ts: 422 → 244 LOC. * refactor(orbit): extract sweep + cleanup, collapse shim Pull sweepGuestOutboxes (+ private listGuestOutboxes / readOutbox) into utils/orbit/sweep.ts and cleanupOrphanedOrbitPlaylists into utils/orbit/cleanup.ts. utils/orbit.ts collapses to a pure re-export shim — every external import path stays the same, the file just lists which symbol lives in which submodule. utils/orbit.ts: 244 → 77 LOC. Full split: 989 LOC monolith → 10 single-concern modules, none over 210 LOC.
78 lines
2.2 KiB
TypeScript
78 lines
2.2 KiB
TypeScript
/**
|
|
* Orbit — multi-user listen-together feature.
|
|
*
|
|
* This file is a re-export shim. Implementation lives under `utils/orbit/`:
|
|
*
|
|
* - `constants.ts` — cadence + TTL ms values.
|
|
* - `helpers.ts` — pure utilities (id gen, serialisation, key fns).
|
|
* - `stateMath.ts` — pure state transforms (shuffle, drift, sweep merge).
|
|
* - `remote.ts` — Navidrome playlist comment I/O.
|
|
* - `shareLink.ts` — invite magic-string encode/decode.
|
|
* - `host.ts` — host session lifecycle (start, end, settings, enqueue).
|
|
* - `moderation.ts` — host kicks / soft-removes / mutes.
|
|
* - `guest.ts` — guest join/leave + suggestion pipeline + host
|
|
* approve/decline reactions.
|
|
* - `sweep.ts` — host-side outbox sweep loop.
|
|
* - `cleanup.ts` — app-start orphan playlist sweep.
|
|
*
|
|
* Importers everywhere else in the codebase keep using `'../utils/orbit'`;
|
|
* this shim re-exports every public symbol unchanged.
|
|
*/
|
|
|
|
export {
|
|
ORBIT_HEARTBEAT_ALIVE_MS,
|
|
ORBIT_ORPHAN_TTL_MS,
|
|
ORBIT_REMOVED_TTL_MS,
|
|
ORBIT_SHUFFLE_INTERVAL_MS,
|
|
} from './orbit/constants';
|
|
export {
|
|
generateSessionId,
|
|
OrbitStateTooLarge,
|
|
serialiseOrbitState,
|
|
suggestionKey,
|
|
} from './orbit/helpers';
|
|
export {
|
|
applyOutboxSnapshotsToState,
|
|
computeOrbitDriftMs,
|
|
effectiveShuffleIntervalMs,
|
|
maybeShuffleQueue,
|
|
patchOrbitState,
|
|
} from './orbit/stateMath';
|
|
export {
|
|
findSessionPlaylistId,
|
|
readOrbitState,
|
|
writeOrbitHeartbeat,
|
|
writeOrbitState,
|
|
} from './orbit/remote';
|
|
export {
|
|
buildOrbitShareLink,
|
|
parseOrbitShareLink,
|
|
type OrbitShareLink,
|
|
} from './orbit/shareLink';
|
|
export {
|
|
endOrbitSession,
|
|
hostEnqueueToOrbit,
|
|
startOrbitSession,
|
|
triggerOrbitShuffleNow,
|
|
updateOrbitSettings,
|
|
type StartOrbitArgs,
|
|
} from './orbit/host';
|
|
export {
|
|
kickOrbitParticipant,
|
|
removeOrbitParticipant,
|
|
setOrbitSuggestionBlocked,
|
|
} from './orbit/moderation';
|
|
export {
|
|
approveOrbitSuggestion,
|
|
declineOrbitSuggestion,
|
|
evaluateOrbitSuggestGate,
|
|
joinOrbitSession,
|
|
leaveOrbitSession,
|
|
OrbitJoinError,
|
|
OrbitSuggestBlockedError,
|
|
suggestOrbitTrack,
|
|
type OrbitSuggestGateReason,
|
|
} from './orbit/guest';
|
|
export { sweepGuestOutboxes } from './orbit/sweep';
|
|
export { cleanupOrphanedOrbitPlaylists } from './orbit/cleanup';
|