@soffits/dsh-media-hub 0.15.1 → 0.15.3

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.
package/locale/en.json CHANGED
@@ -310,6 +310,8 @@
310
310
  "points.newSeries": "Start a new series",
311
311
  "points.newSeriesAbout": "Begin watching a series that is new to the library. Going on with one stays free.",
312
312
  "points.bingeNight": "Binge night",
313
- "points.bingeNightAbout": "Start watching late at night, as often as you like, until morning."
313
+ "points.bingeNightAbout": "Start watching late at night, as often as you like, until morning.",
314
+ "page.crashed": "This page stopped working.",
315
+ "page.reload": "Reload"
314
316
  }
315
317
  }
package/locale/fr.json CHANGED
@@ -310,6 +310,8 @@
310
310
  "points.newSeries": "Commencer une nouvelle série",
311
311
  "points.newSeriesAbout": "Commencer une série qui n’est pas encore dans la bibliothèque. Continuer une série reste gratuit.",
312
312
  "points.bingeNight": "Nuit de marathon",
313
- "points.bingeNightAbout": "Lancer des épisodes tard dans la nuit, autant que vous voulez, jusqu’au matin."
313
+ "points.bingeNightAbout": "Lancer des épisodes tard dans la nuit, autant que vous voulez, jusqu’au matin.",
314
+ "page.crashed": "Cette page a cessé de fonctionner.",
315
+ "page.reload": "Recharger"
314
316
  }
315
317
  }
package/locale/zh.json CHANGED
@@ -310,6 +310,8 @@
310
310
  "points.newSeries": "开一部新剧",
311
311
  "points.newSeriesAbout": "开始看一部库里还没有的剧。接着看已有的剧不花分。",
312
312
  "points.bingeNight": "通宵追剧夜",
313
- "points.bingeNightAbout": "深夜开播,想看几次都行,到早上为止。"
313
+ "points.bingeNightAbout": "深夜开播,想看几次都行,到早上为止。",
314
+ "page.crashed": "页面出错了。",
315
+ "page.reload": "重新加载"
314
316
  }
315
317
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soffits/dsh-media-hub",
3
- "version": "0.15.1",
3
+ "version": "0.15.3",
4
4
  "description": "A media hub for DeepSeek Harness: search shows, novels, ebooks and papers across sources, watch together in sync, and download books in the format you want onto your own shelf.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Catches an error thrown while the page draws, so the panel says what broke and offers a reload
3
+ * (which also picks up modules changed by an update) instead of going blank.
4
+ */
5
+ export function createBoundary(React) {
6
+ const h = React.createElement
7
+ return class PageBoundary extends React.Component {
8
+ constructor(props) {
9
+ super(props)
10
+ this.state = { error: null }
11
+ }
12
+
13
+ static getDerivedStateFromError(error) {
14
+ return { error }
15
+ }
16
+
17
+ componentDidCatch(error, info) {
18
+ console.error('[media-hub] the page crashed: %s', error?.message, info?.componentStack ?? '')
19
+ }
20
+
21
+ render() {
22
+ const { error } = this.state
23
+ if (error === null) return this.props.children
24
+ const { t } = this.props
25
+ return h('div', { className: 'vsync-crash', role: 'alert' },
26
+ h('p', null, t('page.crashed')),
27
+ h('p', { className: 'vsync-error' }, String(error?.message ?? error)),
28
+ h('button', { type: 'button', className: 'vsync-crash-reload', onClick: () => location.reload() }, t('page.reload')))
29
+ }
30
+ }
31
+ }
@@ -185,7 +185,7 @@ function ShowRow({ t, show, days, onOpen, onChanged, onOpenWork }) {
185
185
  { label: t('library.rename'), onSelect: () => setMode('rename') },
186
186
  show.sourced && !show.pinned && show.episodes < show.total && { label: t('library.downloadAll'), onSelect: () => setMode('pin') },
187
187
  show.pinned && { label: t('library.stopOffline'), onSelect: () => act(async () => post('library/pin', await asViewer(t, { path: show.path, pinned: false }))) },
188
- days > 0 && show.deletesAt === null && { label: fill(t('library.startCountdown'), { n: days }), onSelect: () => act(async () => post('library/countdown', await asViewer(t, { path: show.path }))) },
188
+ show.autoDeletes && show.deletesAt === null && { label: fill(t('library.startCountdown'), { n: days }), onSelect: () => act(async () => post('library/countdown', await asViewer(t, { path: show.path }))) },
189
189
  show.source?.source && show.sourced && { label: t(show.follow ? 'follow.stop' : 'follow.follow'), onSelect: () => act(() => post('follow', { source: show.source.source, id: show.source.id, follow: !show.follow })) },
190
190
  show.download?.status === 'failed' && { label: t('library.retry'), onSelect: () => act(() => post('library/retry', { path: show.path })) },
191
191
  show.download?.active && { label: t('library.stopDownload'), onSelect: () => act(() => post('library/cancel', { path: show.path })) },
package/web/panel.css CHANGED
@@ -1,5 +1,6 @@
1
1
  /* Video Sync page styles. Only the host theme tokens (--dsw-*), except the player's stage. */
2
2
  .vsync-page{width:100%;min-width:0;height:100%;min-height:0;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-base);font-size:14px;line-height:1.6;display:flex;flex-direction:column;overflow:hidden}
3
+ .vsync-crash{padding:24px;display:flex;flex-direction:column;align-items:flex-start;gap:8px}
3
4
  .vsync-scroll{flex:1;min-height:0;overflow:auto;scrollbar-gutter:stable;--dsh-scrollbar-width:9px;--dsh-scrollbar-thumb-border:2px}
4
5
  .vsync-content{max-width:960px;margin:0 auto;padding:0 clamp(24px,4vw,48px) 48px}
5
6
  @media (width<=767px){.vsync-content{padding-inline:20px}}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * What a press on the picture does, as players have it: a mouse click plays
3
+ * or pauses, a double click goes full screen, and a tap leaves it to the
4
+ * browser (its first tap shows the controls). Presses on the browser's own
5
+ * control bar along the bottom are its own. Pure.
6
+ */
7
+
8
+ /** How tall the browser's control bar is at most, from the bottom of the picture (CSS pixels). */
9
+ export const CONTROLS_HEIGHT = 56
10
+ /** How long a click waits to see whether it is the first half of a double click. */
11
+ export const DOUBLE_CLICK_MS = 250
12
+
13
+ /**
14
+ * @param {{ pointerType: string, y: number, height: number, toggledByBrowser: boolean }} press - `y` from the
15
+ * picture's top; `toggledByBrowser`: the element already changed between playing and paused for this press
16
+ * @returns {'toggle' | 'none'}
17
+ */
18
+ export function pictureClick({ pointerType, y, height, toggledByBrowser }) {
19
+ if (pointerType !== 'mouse' || toggledByBrowser) return 'none'
20
+ return y < height - CONTROLS_HEIGHT ? 'toggle' : 'none'
21
+ }
package/web/player.js CHANGED
@@ -16,6 +16,7 @@ import { DRIFT, clockOffset, correction, expectedPosition, preloadDue } from './
16
16
  import { canStart, offerTap, shouldPrime } from './readiness.js'
17
17
  import { playsHlsNatively } from './hls-engine.js'
18
18
  import { defaultCaption, parseCaption } from './captions.js'
19
+ import { DOUBLE_CLICK_MS, pictureClick } from './picture-click.js'
19
20
 
20
21
  /** Reconcile the player with the room this often. */
21
22
  const TICK_MS = 500
@@ -52,7 +53,7 @@ const PRIME_LIMIT_MS = 5000
52
53
  const swapKeepsPlayPermission = () => !('webkitSupportsPresentationMode' in HTMLVideoElement.prototype)
53
54
 
54
55
  /** An HTML <video> as a media hub player, with hls.js where the browser's own HLS is not the one to use (web/hls-engine.js). */
55
- function createVideoPlayer(stage, events, { base, language, trackLabel }) {
56
+ function createVideoPlayer(stage, events, { base, language, trackLabel, onFullScreen }) {
56
57
  let video = null
57
58
  let hls = null
58
59
  let src = null
@@ -101,6 +102,29 @@ function createVideoPlayer(stage, events, { base, language, trackLabel }) {
101
102
  if (expect.rate !== null && Math.abs(el.playbackRate - expect.rate) < 1e-6) return
102
103
  events.onRate?.(el.playbackRate)
103
104
  })
105
+ // A click on the picture plays or pauses (through the element, so the room hears it like any play or pause),
106
+ // a double click goes full screen; the browser keeps taps and its own control bar.
107
+ let press = null
108
+ let clickTimer = null
109
+ el.addEventListener('pointerdown', (event) => { press = { pointerType: event.pointerType, paused: el.paused } })
110
+ el.addEventListener('click', (event) => {
111
+ if (!front() || press === null) return
112
+ const pressed = press
113
+ const y = event.clientY - el.getBoundingClientRect().top
114
+ clearTimeout(clickTimer)
115
+ clickTimer = setTimeout(() => {
116
+ if (pictureClick({ pointerType: pressed.pointerType, y, height: el.clientHeight, toggledByBrowser: el.paused !== pressed.paused }) === 'toggle') {
117
+ if (el.paused) Promise.resolve(el.play()).catch(() => {})
118
+ else el.pause()
119
+ }
120
+ }, DOUBLE_CLICK_MS)
121
+ })
122
+ el.addEventListener('dblclick', (event) => {
123
+ if (!front() || press?.pointerType !== 'mouse') return
124
+ clearTimeout(clickTimer)
125
+ event.preventDefault()
126
+ onFullScreen?.()
127
+ })
104
128
  el.addEventListener('ended', () => { if (front()) events.onEnded?.() })
105
129
  el.addEventListener('loadedmetadata', () => { if (front() && Number.isFinite(el.duration)) events.onDuration?.(el.duration) })
106
130
  el.addEventListener('error', () => { if (front()) events.onError?.(el.error?.message || 'This video could not be played.') })
@@ -328,7 +352,7 @@ function tabClientId() {
328
352
  * @param {(view: object) => void} options.onUpdate - connection, room, members, needsGesture, drift
329
353
  * @param {(event: object) => void} options.onEvent - { kind: 'action', last } | { kind: 'joined' | 'left', name }
330
354
  */
331
- export function joinRoom({ base, roomId, name, language = '', trackLabel = label => label, stage, onUpdate, onEvent }) {
355
+ export function joinRoom({ base, roomId, name, language = '', trackLabel = label => label, stage, onUpdate, onEvent, onFullScreen }) {
332
356
  const clientId = tabClientId()
333
357
  const samples = []
334
358
  let offset = null
@@ -566,7 +590,7 @@ export function joinRoom({ base, roomId, name, language = '', trackLabel = label
566
590
 
567
591
  function ensurePlayer() {
568
592
  if (player !== null) return player
569
- player = createVideoPlayer(stage, events, { base, language, trackLabel })
593
+ player = createVideoPlayer(stage, events, { base, language, trackLabel, onFullScreen })
570
594
  loadedIndex = null
571
595
  return player
572
596
  }
package/web/room-view.js CHANGED
@@ -78,6 +78,8 @@ export function RoomView({ t, roomId, onLeave, onOpen }) {
78
78
  const [danmaku, setDanmaku] = React.useState({ index: null, items: NO_DANMAKU })
79
79
  const [qualityBusy, setQualityBusy] = React.useState(false)
80
80
  const screen = useFullScreen(playerBox)
81
+ const toggleFull = React.useRef(screen.toggle)
82
+ toggleFull.current = screen.toggle
81
83
  const session = React.useRef(null)
82
84
  const [view, setView] = React.useState({ connection: 'connecting', room: null, members: [], needsGesture: false })
83
85
  const [toasts, setToasts] = React.useState([])
@@ -107,6 +109,7 @@ export function RoomView({ t, roomId, onLeave, onOpen }) {
107
109
  stage: stage.current,
108
110
  onUpdate: setView,
109
111
  onEvent: event => toast(toastText(t, event)),
112
+ onFullScreen: () => toggleFull.current(),
110
113
  })
111
114
  }
112
115
  start().catch(error => toast(error.message))