@kangsicj/nexussync 1.6.4 → 1.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@
8
8
  // @icon https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/assets/icon.svg
9
9
  // @updateURL https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/dist/NexusSync.meta.js
10
10
  // @downloadURL https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/dist/NexusSync.user.js
11
- // @version 1.6.4
11
+ // @version 1.6.5
12
12
  // @description Watch any web video together in perfect sync: cinema mode, live AI subtitles & translation, chat bubbles with auto-translation, quick ink, cover, go-together to the next episode.
13
13
  // @description:ko 어떤 웹 영상이든 완벽한 싱크로 함께 보기: 시네마 모드, 실시간 AI 자막·번역, 자동 번역 말풍선 채팅, 잠깐 그리기, 가리기, 다음 화도 함께.
14
14
  // @match *://*/*
@@ -8,7 +8,7 @@
8
8
  // @icon https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/assets/icon.svg
9
9
  // @updateURL https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/dist/NexusSync.meta.js
10
10
  // @downloadURL https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/dist/NexusSync.user.js
11
- // @version 1.6.4
11
+ // @version 1.6.5
12
12
  // @description Watch any web video together in perfect sync: cinema mode, live AI subtitles & translation, chat bubbles with auto-translation, quick ink, cover, go-together to the next episode.
13
13
  // @description:ko 어떤 웹 영상이든 완벽한 싱크로 함께 보기: 시네마 모드, 실시간 AI 자막·번역, 자동 번역 말풍선 채팅, 잠깐 그리기, 가리기, 다음 화도 함께.
14
14
  // @match *://*/*
@@ -46,12 +46,12 @@
46
46
 
47
47
  // The version of the code that is actually running (the manager's metadata can lag
48
48
  // behind when an old copy is still installed).
49
- const NXU_VERSION = '1.6.4';
49
+ const NXU_VERSION = '1.6.5';
50
50
  // Rank used by the one-instance guard below and to tell newer builds apart in a room.
51
51
  // It is independent of the public version (1.0.0 is the first public release, after
52
52
  // private builds that reached ranks up to 10.2.0), so every older copy still installed
53
53
  // steps aside instead of this release.
54
- const NXU_RANK = '11.6.4';
54
+ const NXU_RANK = '11.6.5';
55
55
  const NXU_SESSION = Math.random().toString(36).slice(2, 10); // this page load // raise with every release
56
56
  // App icon (same artwork as assets/icon.svg / @icon), inlined so it shows offline too.
57
57
  const NXU_ICON = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTYgMjU2IiByb2xlPSJpbWciIGFyaWEtbGFiZWw9Ik5leHVzU3luYyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJueGJnIiB4MT0iMCIgeTE9IjAiIHgyPSIxIiB5Mj0iMSI+PHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjNWIyZWZmIi8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjZmY0ZmEzIi8+PC9saW5lYXJHcmFkaWVudD48cmFkaWFsR3JhZGllbnQgaWQ9Im54Z2xvdyIgY3g9IjAuODIiIGN5PSIwLjE0IiByPSIwLjciPjxzdG9wIG9mZnNldD0iMCIgc3RvcC1jb2xvcj0iIzdjZjlmZiIgc3RvcC1vcGFjaXR5PSIwLjU1Ii8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjN2NmOWZmIiBzdG9wLW9wYWNpdHk9IjAiLz48L3JhZGlhbEdyYWRpZW50PjxsaW5lYXJHcmFkaWVudCBpZD0ibnhwbGF5IiB4MT0iMCIgeTE9IjAiIHgyPSIxIiB5Mj0iMSI+PHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjZmZmZmZmIi8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjZmZlM2YxIi8+PC9saW5lYXJHcmFkaWVudD48Y2xpcFBhdGggaWQ9Im54ciI+PHJlY3Qgd2lkdGg9IjI1NiIgaGVpZ2h0PSIyNTYiIHJ4PSI1OCIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNueHIpIj48cmVjdCB3aWR0aD0iMjU2IiBoZWlnaHQ9IjI1NiIgZmlsbD0idXJsKCNueGJnKSIvPjxyZWN0IHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2IiBmaWxsPSJ1cmwoI254Z2xvdykiLz48ZyBmaWxsPSJub25lIiBzdHJva2U9IiNmZmZmZmYiIHN0cm9rZS13aWR0aD0iMTUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCI+PHBhdGggZD0iTTYwIDExNiBBNzAgNzAgMCAwIDEgMTc4IDcyIi8+PHBhdGggZD0iTTE5NiAxNDAgQTcwIDcwIDAgMCAxIDc4IDE4NCIvPjwvZz48cGF0aCBkPSJNMTg2IDUwIEwyMDAgOTIgTDE1NyA4NiBaIiBmaWxsPSIjZmZmZmZmIi8+PHBhdGggZD0iTTcwIDIwNiBMNTYgMTY0IEw5OSAxNzAgWiIgZmlsbD0iI2ZmZmZmZiIvPjxwYXRoIGQ9Ik0xMTAgOTIgUTEwNCA4OCAxMDQgOTYgTDEwNCAxNjAgUTEwNCAxNjggMTEwIDE2NCBMMTYyIDEzMiBRMTY4IDEyOCAxNjIgMTI0IFoiIGZpbGw9InVybCgjbnhwbGF5KSIvPjwvZz48L3N2Zz4=';
@@ -353,7 +353,7 @@
353
353
  return ['snap', 'env'].includes(data.op) && str(data.rid) && (data.img === undefined || data.img === null || (typeof data.img === 'string' && data.img.length < 90000 && data.img.startsWith('data:image/'))) && num(data.t) && arr(data.a) && arr(data.l) && arr(data.ts);
354
354
  }
355
355
  case 'NXU_CAPTION':
356
- return ['final', 'interim', 'clear'].includes(data.mode) && str(data.text) && str(data.original) && str(data.color) && num(data.size);
356
+ return ['final', 'interim', 'clear', 'sub'].includes(data.mode) && str(data.text) && str(data.original) && str(data.color) && num(data.size);
357
357
  default:
358
358
  return false;
359
359
  }
@@ -660,7 +660,7 @@
660
660
  inkClosing: 'Closing soon — move or tap to keep drawing',
661
661
  modeSitePlayer: 'Site player in use', modeNexusPlayer: 'NexusSync player in use', modeSiteHint: 'Change subtitles or the server in the site’s player, then switch.', modeSiteHintAuto: 'Cinema started by itself. Pick subtitles or a server in the site’s player first if needed, then switch.', modeNexusHint: 'Everything is controlled by NexusSync. The site’s own settings are one tap away.', modeUseNexus: 'Use NexusSync player', modeUseSite: 'Use site player', autoCinemaStopSite: 'No auto-cinema on this site', autoCinemaOnSite: 'Auto-cinema on for {site}', autoCinemaOffSite: 'Auto-cinema off for {site}', autoCinemaBtnOn: 'Auto-cinema: on (this site)', autoCinemaBtnOff: 'Auto-cinema: off (this site)', adGuardOn: 'Ad guard: on', adGuardOff: 'Ad guard: off', adGuardHid: 'Hid an ad / link laid over the video', adGuardPopup: 'Stopped an ad pop-up', ccPip: 'Picture-in-Picture (keep watching in a small window)', nextEpTitle: 'Up next', nextEpGo: 'Next episode', nextEpCancel: 'Stay on this episode', nextEpGoing: 'Next episode…', talkMenu: 'Chat', inkMenu: 'Quick sketch', quickEdit: 'Edit quick replies', quickEditHint: 'Separate with |', quickReset: 'Back to the default replies', save: 'Save',
662
662
  talkTitle: 'Chat bubble', talkPlaceholder: 'Say something…', talkReplyTo: '↩ Reply to {name}', talkClose: 'Close', talkSend: 'Send', talkFull: 'Open the chat history (every message so far)', talkHistory: 'History',
663
- inkTitle: 'Quick sketch (fades away)', inkHint: 'Draw on the screen — it fades in a few seconds', inkDone: 'Done', inkBubble: 'is sketching on the screen — tap to draw back',
663
+ inkTitle: 'Quick sketch (fades when you stop)', inkHint: 'Draw on the screen — it fades 10 seconds after you stop', inkDone: 'Done', inkBubble: 'is sketching on the screen — tap to draw back',
664
664
  you: 'You', roomBuffering: '⏳ {name} is loading… everyone waits', roomResume: '▶️ Everyone is ready — playing together', roomRate: '⏩ Speed {rate}x synced',
665
665
  youBuffering: '⏳ Your video is loading — the room waits for you', shieldResumeTitle: 'Tap to rejoin playback', shieldResumeText: 'The browser paused this video. Tap once to continue in sync with the room.',
666
666
  shieldResumeButton: 'RESUME ▶️', rateTitle: 'Playback speed (shared with the room)', rateSet: '⏩ Speed {rate}x', resynced: 'Re-synced with the room',
@@ -778,7 +778,7 @@
778
778
  inkClosing: '곧 닫혀요 — 계속 그리려면 움직이거나 눌러 주세요',
779
779
  modeSitePlayer: '사이트 플레이어 사용 중', modeNexusPlayer: 'NexusSync 플레이어 사용 중', modeSiteHint: '자막이나 서버는 사이트 플레이어에서 바꾼 뒤 전환하세요.', modeSiteHintAuto: '시네마 모드가 자동으로 켜졌어요. 필요하면 사이트 플레이어에서 자막·서버를 먼저 고른 뒤 전환하세요.', modeNexusHint: 'NexusSync가 모든 조작을 맡아요. 사이트 설정은 한 번 탭으로 돌아갈 수 있어요.', modeUseNexus: 'NexusSync 플레이어로', modeUseSite: '사이트 플레이어로', autoCinemaStopSite: '이 사이트는 자동 시네마 끄기', autoCinemaOnSite: '{site}에서 자동 시네마 켜짐', autoCinemaOffSite: '{site}에서 자동 시네마 꺼짐', autoCinemaBtnOn: '자동 시네마: 켬 (이 사이트)', autoCinemaBtnOff: '자동 시네마: 끔 (이 사이트)', adGuardOn: '광고 가리기: 켬', adGuardOff: '광고 가리기: 끔', adGuardHid: '영상 위에 덮인 광고·링크를 숨겼어요', adGuardPopup: '광고 팝업을 막았어요', ccPip: 'PiP (작은 창으로 계속 보기)', nextEpTitle: '다음 화', nextEpGo: '다음 화 보기', nextEpCancel: '이번 화에 머물기', nextEpGoing: '다음 화로 이동하는 중…', talkMenu: '말풍선 채팅', inkMenu: '잠깐 그리기', quickEdit: '빠른 답장 편집', quickEditHint: '| 로 구분', quickReset: '기본 답장으로', save: '저장',
780
780
  talkTitle: '말풍선 채팅', talkPlaceholder: '메시지 보내기…', talkReplyTo: '↩ {name} 님에게 답장', talkClose: '닫기', talkSend: '보내기', talkFull: '지금까지의 대화 기록 전체 보기', talkHistory: '대화 기록',
781
- inkTitle: '잠깐 그리기 (몇 초 뒤 사라짐)', inkHint: '화면에 그려 보세요 — 몇 초 뒤 사라져요', inkDone: '완료', inkBubble: '님이 화면에 그리고 있어요 — 탭해서 같이 그리기',
781
+ inkTitle: '잠깐 그리기 (멈추면 잠시 뒤 사라짐)', inkHint: '화면에 그려 보세요 — 그리기를 멈추고 10초 뒤 사라져요', inkDone: '완료', inkBubble: '님이 화면에 그리고 있어요 — 탭해서 같이 그리기',
782
782
  you: '나', roomBuffering: '⏳ {name} 기기 로딩 중… 모두 잠시 대기', roomResume: '▶️ 모두 준비됨 — 함께 재생합니다', roomRate: '⏩ {rate}배속 동기화',
783
783
  youBuffering: '⏳ 이 기기 영상 로딩 중 — 방이 기다려 줍니다', shieldResumeTitle: '탭해서 다시 재생', shieldResumeText: '브라우저가 이 영상을 멈췄습니다. 한 번 탭하면 방과 맞춰 이어서 재생합니다.',
784
784
  shieldResumeButton: '이어서 재생 ▶️', rateTitle: '재생 속도 (방 전체와 공유)', rateSet: '⏩ {rate}배속', resynced: '방과 다시 맞췄습니다',
@@ -1803,13 +1803,20 @@
1803
1803
  },
1804
1804
  _isSub(tr) { return tr && (tr.kind === 'subtitles' || tr.kind === 'captions'); },
1805
1805
  // Take over every subtitle track the browser is drawing; forget tracks the site turned off.
1806
+ nativeFullscreen(v, on) {
1807
+ if (v !== this.video) return;
1808
+ this._nativeFs = on;
1809
+ const showOwn = on && !(typeof SUBS !== 'undefined' && SUBS.active());
1810
+ for (const tr of this.owned) { try { tr.mode = showOwn ? 'showing' : 'hidden'; this._ours++; } catch (_) { } }
1811
+ if (!on) this.render();
1812
+ },
1806
1813
  _claim() {
1807
1814
  const v = this.video;
1808
- if (!v) return;
1815
+ if (!v || this._nativeFs) return;
1809
1816
  let list;
1810
1817
  try { list = [...v.textTracks]; } catch (_) { return; }
1811
1818
  for (const tr of list) {
1812
- if (!this._isSub(tr)) continue;
1819
+ if (!this._isSub(tr) || tr === v._nxuFsTrack) continue;
1813
1820
  if (tr.mode === 'showing') {
1814
1821
  try { tr.mode = 'hidden'; this._ours++; } catch (_) { continue; }
1815
1822
  if (!this.owned.has(tr)) { this.owned.add(tr); tr.addEventListener('cuechange', this._onCue); }
@@ -2155,6 +2162,77 @@
2155
2162
  // ───────────────────────── Caption mirror (child frames in element fullscreen)
2156
2163
  // When an embedded player is fullscreen, the top document cannot paint over it,
2157
2164
  // so the top frame forwards captions and this renders them inside the frame.
2165
+ // When the <video> element itself goes fullscreen (the site's or the browser's own
2166
+ // fullscreen button, a double-click on native controls, the iPhone's player), the browser
2167
+ // paints nothing but the video: no page layer can show text there. Whatever subtitles are
2168
+ // on screen then go into a text track of that video, which the browser does draw, and the
2169
+ // video's own tracks NexusSync had taken over are handed back while it lasts.
2170
+ const FS_SUBS = {
2171
+ video: null, _text: '', _ios: null,
2172
+ _fsVideo() {
2173
+ const fse = document.fullscreenElement || document.webkitFullscreenElement;
2174
+ if (fse && fse.tagName === 'VIDEO') return fse;
2175
+ return this._ios && this._ios.isConnected && this._ios.webkitDisplayingFullscreen !== false ? this._ios : null;
2176
+ },
2177
+ update() {
2178
+ const v = this._fsVideo();
2179
+ if (v === this.video) return;
2180
+ if (this.video) this._leave(this.video);
2181
+ this.video = v;
2182
+ if (v) {
2183
+ logDebug('Video fullscreen: subtitles move into a track of the video.', 'info');
2184
+ try { CUE_MIRROR.nativeFullscreen(v, true); } catch (_) { }
2185
+ this._show(this._text);
2186
+ }
2187
+ },
2188
+ // What NexusSync is showing right now ('' = nothing).
2189
+ feed(text) {
2190
+ text = String(text || '').trim();
2191
+ if (text === this._text && (!this.video || this._shown === text)) return;
2192
+ this._text = text;
2193
+ if (this.video) this._show(text);
2194
+ else if (IS_TOP && SUB_LAYOUT.mirrorFrame?.isConnected) {
2195
+ // The player sits in a frame that is fullscreen: the frame shows the lines itself.
2196
+ FRAME.postToFrame(SUB_LAYOUT.mirrorFrame, { type: 'NXU_CAPTION', mode: text ? 'sub' : 'clear', text, original: '', color: '', size: Math.round(22 * (typeof SUBS !== 'undefined' ? SUBS.size() : 1)) });
2197
+ }
2198
+ },
2199
+ showOn(v, text) { if (v !== this.video) { if (this.video) this._leave(this.video); this.video = v; } this._text = String(text || '').trim(); this._show(this._text); },
2200
+ _track(v) {
2201
+ if (v._nxuFsTrack) return v._nxuFsTrack;
2202
+ try { v._nxuFsTrack = v.addTextTrack('subtitles', 'NexusSync', (STORE.get('nxu_subtitle_language', '') || navigator.language || 'en').slice(0, 2)); } catch (_) { return null; }
2203
+ return v._nxuFsTrack;
2204
+ },
2205
+ _clear(tr) { try { [...(tr.cues || [])].forEach(c => tr.removeCue(c)); } catch (_) { } },
2206
+ _show(text) {
2207
+ const v = this.video;
2208
+ if (!v) return;
2209
+ const tr = this._track(v);
2210
+ if (!tr) return;
2211
+ this._shown = text;
2212
+ try { tr.mode = 'showing'; } catch (_) { }
2213
+ this._clear(tr);
2214
+ if (!text) return;
2215
+ const Cue = window.VTTCue || window.TextTrackCue;
2216
+ if (!Cue) return;
2217
+ try {
2218
+ const at = Number.isFinite(v.currentTime) ? v.currentTime : 0;
2219
+ // One cue that lasts until the text changes (replaced on every change).
2220
+ tr.addCue(new Cue(Math.max(0, at - 0.25), at + 6 * 3600, text));
2221
+ } catch (_) { }
2222
+ },
2223
+ _leave(v) {
2224
+ const tr = v._nxuFsTrack;
2225
+ if (tr) { this._clear(tr); try { tr.mode = 'disabled'; } catch (_) { } }
2226
+ this._shown = null;
2227
+ try { CUE_MIRROR.nativeFullscreen(v, false); } catch (_) { }
2228
+ }
2229
+ };
2230
+ document.addEventListener('fullscreenchange', () => FS_SUBS.update());
2231
+ document.addEventListener('webkitfullscreenchange', () => FS_SUBS.update());
2232
+ // iPhone/iPad native player: these events are sent to the <video> only.
2233
+ document.addEventListener('webkitbeginfullscreen', (ev) => { if (ev.target?.tagName === 'VIDEO') { FS_SUBS._ios = ev.target; FS_SUBS.update(); } }, true);
2234
+ document.addEventListener('webkitendfullscreen', (ev) => { if (ev.target === FS_SUBS._ios) { FS_SUBS._ios = null; FS_SUBS.update(); } }, true);
2235
+
2158
2236
  const CAPTION_MIRROR = {
2159
2237
  host: null,
2160
2238
  root: null,
@@ -2180,7 +2258,9 @@
2180
2258
  return this.root.querySelector('.box');
2181
2259
  },
2182
2260
  render(data) {
2183
- if (data.mode === 'clear') { this.remove(); return; }
2261
+ const fsv = document.fullscreenElement || document.webkitFullscreenElement;
2262
+ if ((fsv && fsv.tagName === 'VIDEO') || FS_SUBS._ios) { FS_SUBS.showOn(fsv && fsv.tagName === 'VIDEO' ? fsv : FS_SUBS._ios, data.mode === 'clear' ? '' : data.text); return; }
2263
+ if (data.mode === 'clear' || (data.mode === 'sub' && !data.text)) { this.remove(); return; }
2184
2264
  const box = this._ensure();
2185
2265
  if (!box) return;
2186
2266
  const size = Math.max(12, Math.min(48, data.size || 22));
@@ -2205,7 +2285,8 @@
2205
2285
  box.replaceChildren(card);
2206
2286
  }
2207
2287
  clearTimeout(this.timer);
2208
- this.timer = setTimeout(() => this.remove(), 15000);
2288
+ // Subtitles of a file or track stay until the next line; AI lines fade after 15 s.
2289
+ if (data.mode !== 'sub') this.timer = setTimeout(() => this.remove(), 15000);
2209
2290
  },
2210
2291
  remove() {
2211
2292
  clearTimeout(this.timer);
@@ -3767,6 +3848,7 @@
3767
3848
  if (slot) { slot.style.opacity = '0'; slot.replaceChildren(); }
3768
3849
  },
3769
3850
  _mirror(payload) {
3851
+ if (FS_SUBS.video && !SUBS.active()) { FS_SUBS.showOn(FS_SUBS.video, payload.mode === 'clear' ? '' : (payload.text || '') + (payload.original && payload.original !== payload.text ? '\n' + payload.original : '')); return; }
3770
3852
  const frame = SUB_LAYOUT.mirrorFrame;
3771
3853
  if (!frame || !frame.isConnected) return;
3772
3854
  FRAME.postToFrame(frame, { type: 'NXU_CAPTION', size: SUB_PREFS.size, text: '', original: '', color: '#00e676', ...payload });
@@ -7663,7 +7745,20 @@
7663
7745
  };
7664
7746
  const emojiInput = (ph, onEmoji) => {
7665
7747
  const inp = createEl('input', 'nx-compose-input nx-emoji-input', '', { type: 'text', maxlength: '16', placeholder: ph, autocomplete: 'off', enterkeyhint: 'done' });
7666
- inp.addEventListener('input', () => { const em = safeEmoji(inp.value); if (em && onEmoji(em)) inp.value = ''; });
7748
+ // Emoji keyboards with a search box (phones, Windows' emoji panel) are still in the
7749
+ // middle of composing when the emoji lands: taking it then and clearing the box made
7750
+ // the keyboard commit it a second time (two of the same emoji). Wait for the keyboard
7751
+ // to finish, and ignore the same emoji arriving again right away.
7752
+ let lastEm = '', lastAt = 0;
7753
+ const take = () => {
7754
+ const em = safeEmoji(inp.value);
7755
+ if (!em) return;
7756
+ if (em === lastEm && Date.now() - lastAt < 1200) { inp.value = ''; return; }
7757
+ if (onEmoji(em)) { lastEm = em; lastAt = Date.now(); inp.value = ''; }
7758
+ };
7759
+ inp.addEventListener('input', (ev) => { if (ev.isComposing || inp._composing) return; take(); });
7760
+ inp.addEventListener('compositionstart', () => { inp._composing = true; });
7761
+ inp.addEventListener('compositionend', () => { inp._composing = false; setTimeout(take, 0); });
7667
7762
  inp.addEventListener('keydown', (ev) => ev.stopPropagation());
7668
7763
  return inp;
7669
7764
  };
@@ -9724,8 +9819,12 @@
9724
9819
  // live on everyone's screen (on the same spot of the picture, whatever the device) and
9725
9820
  // fade out by themselves. Nothing is kept — the shared canvas (✏️) is for keeps.
9726
9821
  const INK = {
9727
- HOLD_MS: 3500,
9728
- FADE_MS: 1400,
9822
+ // A drawing stays as a whole while its author keeps drawing, and fades only when they
9823
+ // have stopped for a while (each stroke used to fade 3.5 s after it was drawn, so the
9824
+ // start of a picture vanished before it was finished).
9825
+ HOLD_MS: 10000,
9826
+ FADE_MS: 2000,
9827
+ MAX_PTS: 2000,
9729
9828
  strokes: new Map(), // id → { color, w, ref, pts: [[u,v]...], last }
9730
9829
  _canvas: null,
9731
9830
  _ctx: null,
@@ -9780,8 +9879,14 @@
9780
9879
  } else { x = u * window.innerWidth; y = v * window.innerHeight; }
9781
9880
  return clientToUi(x, y);
9782
9881
  };
9882
+ // Everyone's latest stroke activity: their whole drawing lives until then + HOLD.
9883
+ const lastBy = new Map();
9884
+ for (const [id, s] of this.strokes) {
9885
+ const who = id.split('-')[0];
9886
+ lastBy.set(who, Math.max(lastBy.get(who) || 0, s.live ? now : s.last));
9887
+ }
9783
9888
  for (const [id, s] of this.strokes) {
9784
- const age = now - s.last;
9889
+ const age = now - (lastBy.get(id.split('-')[0]) || s.last);
9785
9890
  const alpha = s.live ? 1 : age < this.HOLD_MS ? 1 : 1 - (age - this.HOLD_MS) / this.FADE_MS;
9786
9891
  if (alpha <= 0) { this.strokes.delete(id); continue; }
9787
9892
  if (s.pts.length < 1) continue;
@@ -9915,7 +10020,7 @@
9915
10020
  const p = this._norm(e.clientX, e.clientY, cur.ref);
9916
10021
  const q = s.pts[s.pts.length - 1];
9917
10022
  if (q && Math.abs(p[0] - q[0]) < 0.003 && Math.abs(p[1] - q[1]) < 0.003) return;
9918
- if (s.pts.length >= 400) return;
10023
+ if (s.pts.length >= this.MAX_PTS) return;
9919
10024
  s.pts.push(p);
9920
10025
  s.last = Date.now();
9921
10026
  this._kick();
@@ -9960,7 +10065,7 @@
9960
10065
  }
9961
10066
  }
9962
10067
  if (d.append && s.pts.length) pts.shift();
9963
- for (const p of pts) if (s.pts.length < 600) s.pts.push(p);
10068
+ for (const p of pts) if (s.pts.length < this.MAX_PTS) s.pts.push(p);
9964
10069
  s.last = Date.now();
9965
10070
  s.live = !d.end;
9966
10071
  if (!d.end) { clearTimeout(s.stale); s.stale = setTimeout(() => { s.live = false; s.last = Date.now(); this._kick(); }, 1500); }
@@ -10000,7 +10105,7 @@
10000
10105
  tracks() {
10001
10106
  const v = STATE.video;
10002
10107
  if (!v || !v.textTracks) return [];
10003
- return [...v.textTracks].filter(tr => tr.kind === 'subtitles' || tr.kind === 'captions');
10108
+ return [...v.textTracks].filter(tr => (tr.kind === 'subtitles' || tr.kind === 'captions') && tr !== v._nxuFsTrack);
10004
10109
  },
10005
10110
  active() { return this.layers.length > 0; },
10006
10111
  hasTrack(tr) { return this.layers.some(l => l.track === tr); },
@@ -10080,6 +10185,7 @@
10080
10185
  if (!force && sig === this._last && this._box?.isConnected) return;
10081
10186
  this._last = sig;
10082
10187
  const any = groups.some(g => g.text);
10188
+ FS_SUBS.feed(groups.filter(g => g.text).map(g => g.text.split('\n').filter(Boolean).slice(0, 3).join('\n')).join('\n'));
10083
10189
  const box = any ? this._ensureBox() : this._box;
10084
10190
  if (!box) return;
10085
10191
  const kids = [];
@@ -10092,6 +10198,7 @@
10092
10198
  _render(text) {
10093
10199
  if (text === this._last && this._box?.isConnected) return;
10094
10200
  this._last = text;
10201
+ FS_SUBS.feed(text);
10095
10202
  const box = text ? this._ensureBox() : this._box;
10096
10203
  if (!box) return;
10097
10204
  box.replaceChildren(...(text ? text.split('\n').filter(Boolean).slice(0, 4).map(line => createEl('span', 'nx-xsub-line', line)) : []));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kangsicj/nexussync",
3
- "version": "1.6.4",
3
+ "version": "1.6.5",
4
4
  "description": "Watch-together userscript: media sync, cinema mode, live AI subtitles, chat bubbles and quick ink for Violentmonkey, Tampermonkey and iOS Userscripts.",
5
5
  "keywords": [
6
6
  "userscript",