mirror of
https://github.com/Shik3i/KoalaSync.git
synced 2026-07-27 12:29:35 +00:00
55c2d4ed0d
Adds a new toggleable feature that detects episode transitions via mediaTitle mutation (loadeddata/MutationObserver), pauses the video, and waits for all room peers to load the same episode before executing a coordinated Force Sync play at 0:00. Protocol: - Add EPISODE_LOBBY and EPISODE_READY events to shared/constants.js - Add EPISODE_LOBBY_TIMEOUT (60s) constant - Relay both new events in server/index.js Content Script (content.js): - Layered detection: loadeddata + MutationObserver src-change + heartbeat - Debounced onEpisodeTransition() sends signal ONLY; no eager pause - PAUSE_FOR_LOBBY handler pauses only after background confirms feature enabled - startLobbyPoll() polls title match without premature pause for non-initiators - checkAndReportLobbyReady() pauses and sends EPISODE_READY_LOCAL on match - CONTENT_BOOT recovery for re-injection after hard navigation Background (background.js): - Episode lobby state persisted in chrome.storage.session with recovery - EPISODE_CHANGED: checks setting, creates lobby, sends PAUSE_FOR_LOBBY to tab - EPISODE_LOBBY/READY server event handlers with dedup logic - 60s timeout cancels lobby (Option B) with Chrome failure notification - Peer departure handled: removes from readyPeers, re-checks completion - executeEpisodeLobby() reuses existing Force Sync pipeline at targetTime 0.0 - Lobby cleared on LEAVE_ROOM; status exposed in GET_STATUS Popup: - Auto-Sync Next Episode toggle in Settings tab (default: off, opt-in) - Episode Lobby status card in Sync tab with peer readiness display - LOBBY_UPDATE message handler for real-time UI updates Bumps APP_VERSION and manifest to 1.2.0
45 lines
1.5 KiB
JavaScript
45 lines
1.5 KiB
JavaScript
/**
|
|
* KoalaSync Shared Constants & Protocol Definitions
|
|
*
|
|
* ⚠️ WARNING: This is the SINGLE SOURCE OF TRUTH.
|
|
* If you edit this file, you MUST run /scripts/sync-constants.bat
|
|
* to propagate changes to the extension and relay server.
|
|
*/
|
|
|
|
export const PROTOCOL_VERSION = "1.0.0";
|
|
export const APP_VERSION = "1.2.0";
|
|
|
|
export const OFFICIAL_SERVER_URL = 'wss://sync.shik3i.net';
|
|
export const OFFICIAL_LANDING_PAGE_URL = 'https://koalasync.shik3i.net';
|
|
export const OFFICIAL_SERVER_TOKEN = '62170b705234c4f4807a9b22420bb93cf1a2aacfa4c5d3b47804482babb8eb50';
|
|
|
|
export const EVENTS = {
|
|
// Connection & Room
|
|
JOIN_ROOM: "join_room",
|
|
LEAVE_ROOM: "leave_room",
|
|
ROOM_DATA: "room_data", // Server -> Client: current room state
|
|
ERROR: "error",
|
|
|
|
// Media Control
|
|
PLAY: "play",
|
|
PAUSE: "pause",
|
|
SEEK: "seek",
|
|
|
|
// Sync Coordination
|
|
PEER_STATUS: "peer_status", // Heartbeat from peers
|
|
FORCE_SYNC_PREPARE: "force_sync_prepare",
|
|
FORCE_SYNC_ACK: "force_sync_ack",
|
|
FORCE_SYNC_EXECUTE: "force_sync_execute",
|
|
EVENT_ACK: "event_ack",
|
|
GET_ROOMS: "get_rooms",
|
|
ROOM_LIST: "room_list",
|
|
|
|
// Episode Auto-Sync
|
|
EPISODE_LOBBY: "episode_lobby", // Broadcast: waiting for everyone on this episode
|
|
EPISODE_READY: "episode_ready" // Response: loaded the episode and paused at 0:00
|
|
};
|
|
|
|
export const HEARTBEAT_INTERVAL = 15000; // 15s
|
|
export const FORCE_SYNC_TIMEOUT = 5000; // 5s timeout for ACKs
|
|
export const EPISODE_LOBBY_TIMEOUT = 60000; // 60s timeout for episode lobby
|