@soffits/dsh-media-hub 0.12.0 → 0.14.0

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
@@ -109,6 +109,7 @@
109
109
  "rooms.heading": "Open rooms",
110
110
  "room.tab.episodes": "Episodes",
111
111
  "room.tab.about": "About",
112
+ "room.tab.comments": "Comments",
112
113
  "room.nextSeason": "Next season: {title}",
113
114
  "room.state.playing": "playing",
114
115
  "room.state.paused": "paused",
@@ -231,6 +232,32 @@
231
232
  "quality.auto": "Auto",
232
233
  "quality.audio": "Audio only",
233
234
  "quality.height": "{n}p",
235
+ "quality.fromNext": "From the next episode on, for everyone in the room.",
236
+ "quality.changing": "Switching…",
237
+ "danmaku.label": "Danmaku",
238
+ "danmaku.count": "Danmaku {n}",
239
+ "danmaku.opacity": "Opacity",
240
+ "danmaku.area": "Area",
241
+ "danmaku.area.quarter": "Top quarter",
242
+ "danmaku.area.half": "Top half",
243
+ "danmaku.area.full": "Whole picture",
244
+ "danmaku.size": "Text size",
245
+ "danmaku.size.small": "Small",
246
+ "danmaku.size.medium": "Medium",
247
+ "danmaku.size.large": "Large",
248
+ "player.settings": "Player settings",
249
+ "player.full": "Full screen",
250
+ "player.exitFull": "Exit full screen",
251
+ "comments.loading": "Loading comments…",
252
+ "comments.none": "No comments yet.",
253
+ "comments.more": "More comments",
254
+ "comments.someone": "Someone",
255
+ "comments.rating": "Rated {score}",
256
+ "comments.likes": "{n} likes",
257
+ "comments.replies.one": "{n} reply",
258
+ "comments.replies.other": "{n} replies",
259
+ "comments.total.one": "{n} comment on the site",
260
+ "comments.total.other": "{n} comments on the site",
234
261
  "error.blocked": "The site turned this request away. It may block the network the hub uses; try again later.",
235
262
  "error.sign_in": "The site wants a signed-in account for this video. Ask whoever runs the hub to add one.",
236
263
  "error.not_found": "There's nothing to play at this address. Check the link.",
@@ -268,10 +295,8 @@
268
295
  "ratings.fine": "Fine",
269
296
  "ratings.not-for-me": "Not for me",
270
297
  "ratings.unfinished": "Didn't finish",
271
- "picks.heading": "Picks",
298
+ "picks.heading": "For you",
272
299
  "picks.hint": "Each with why it was picked",
273
- "feed.picks": "For you",
274
- "feed.picksHint": "Each with why it was picked",
275
300
  "feed.trending": "Trending",
276
301
  "feed.updated": "Updated {when}",
277
302
  "feed.all": "Show all",
package/locale/fr.json CHANGED
@@ -109,6 +109,7 @@
109
109
  "rooms.heading": "Salons ouverts",
110
110
  "room.tab.episodes": "Épisodes",
111
111
  "room.tab.about": "À propos",
112
+ "room.tab.comments": "Commentaires",
112
113
  "room.nextSeason": "Saison suivante : {title}",
113
114
  "room.state.playing": "en lecture",
114
115
  "room.state.paused": "en pause",
@@ -231,6 +232,32 @@
231
232
  "quality.auto": "Auto",
232
233
  "quality.audio": "Audio seul",
233
234
  "quality.height": "{n}p",
235
+ "quality.fromNext": "À partir de l’épisode suivant, pour toute la salle.",
236
+ "quality.changing": "Changement…",
237
+ "danmaku.label": "Danmaku",
238
+ "danmaku.count": "Danmaku {n}",
239
+ "danmaku.opacity": "Opacité",
240
+ "danmaku.area": "Zone",
241
+ "danmaku.area.quarter": "Quart du haut",
242
+ "danmaku.area.half": "Moitié du haut",
243
+ "danmaku.area.full": "Toute l’image",
244
+ "danmaku.size": "Taille du texte",
245
+ "danmaku.size.small": "Petite",
246
+ "danmaku.size.medium": "Moyenne",
247
+ "danmaku.size.large": "Grande",
248
+ "player.settings": "Réglages du lecteur",
249
+ "player.full": "Plein écran",
250
+ "player.exitFull": "Quitter le plein écran",
251
+ "comments.loading": "Chargement des commentaires…",
252
+ "comments.none": "Pas encore de commentaires.",
253
+ "comments.more": "Plus de commentaires",
254
+ "comments.someone": "Quelqu’un",
255
+ "comments.rating": "Note {score}",
256
+ "comments.likes": "{n} j’aime",
257
+ "comments.replies.one": "{n} réponse",
258
+ "comments.replies.other": "{n} réponses",
259
+ "comments.total.one": "{n} commentaire sur le site",
260
+ "comments.total.other": "{n} commentaires sur le site",
234
261
  "error.blocked": "Le site a refusé la demande. Il bloque peut-être le réseau du hub ; réessayez plus tard.",
235
262
  "error.sign_in": "Le site demande un compte connecté pour cette vidéo. Demandez à la personne qui gère le hub d'en ajouter un.",
236
263
  "error.not_found": "Il n'y a rien à lire à cette adresse. Vérifiez le lien.",
@@ -268,10 +295,8 @@
268
295
  "ratings.fine": "Bien",
269
296
  "ratings.not-for-me": "Pas pour moi",
270
297
  "ratings.unfinished": "Pas fini",
271
- "picks.heading": "Suggestions",
298
+ "picks.heading": "Pour vous",
272
299
  "picks.hint": "Chacune avec la raison du choix",
273
- "feed.picks": "Pour vous",
274
- "feed.picksHint": "Chaque suggestion avec sa raison",
275
300
  "feed.trending": "Tendances",
276
301
  "feed.updated": "Mis à jour {when}",
277
302
  "feed.all": "Tout afficher",
package/locale/zh.json CHANGED
@@ -109,6 +109,7 @@
109
109
  "rooms.heading": "正在进行的房间",
110
110
  "room.tab.episodes": "选集",
111
111
  "room.tab.about": "简介",
112
+ "room.tab.comments": "评论",
112
113
  "room.nextSeason": "下一季:{title}",
113
114
  "room.state.playing": "播放中",
114
115
  "room.state.paused": "已暂停",
@@ -231,6 +232,32 @@
231
232
  "quality.auto": "自动",
232
233
  "quality.audio": "仅音频",
233
234
  "quality.height": "{n}p",
235
+ "quality.fromNext": "从下一集起生效,房间里每个人都一样。",
236
+ "quality.changing": "正在切换…",
237
+ "danmaku.label": "弹幕",
238
+ "danmaku.count": "弹幕 {n}",
239
+ "danmaku.opacity": "不透明度",
240
+ "danmaku.area": "显示区域",
241
+ "danmaku.area.quarter": "1/4 屏",
242
+ "danmaku.area.half": "半屏",
243
+ "danmaku.area.full": "全屏",
244
+ "danmaku.size": "字号",
245
+ "danmaku.size.small": "小",
246
+ "danmaku.size.medium": "标准",
247
+ "danmaku.size.large": "大",
248
+ "player.settings": "播放设置",
249
+ "player.full": "全屏",
250
+ "player.exitFull": "退出全屏",
251
+ "comments.loading": "正在加载评论…",
252
+ "comments.none": "还没有评论。",
253
+ "comments.more": "更多评论",
254
+ "comments.someone": "某位观众",
255
+ "comments.rating": "评分 {score}",
256
+ "comments.likes": "{n} 赞",
257
+ "comments.replies.one": "{n} 条回复",
258
+ "comments.replies.other": "{n} 条回复",
259
+ "comments.total.one": "站内共 {n} 条评论",
260
+ "comments.total.other": "站内共 {n} 条评论",
234
261
  "error.blocked": "网站拒绝了这次请求,可能屏蔽了媒体中心所用的网络,稍后再试。",
235
262
  "error.sign_in": "这个视频需要登录账号才能看,请让管理媒体中心的人添加一个。",
236
263
  "error.not_found": "这个地址没有可播放的内容,检查一下链接。",
@@ -268,10 +295,8 @@
268
295
  "ratings.fine": "还行",
269
296
  "ratings.not-for-me": "不太喜欢",
270
297
  "ratings.unfinished": "没看完",
271
- "picks.heading": "推荐",
298
+ "picks.heading": "为你推荐",
272
299
  "picks.hint": "每部都写了推荐理由",
273
- "feed.picks": "为你推荐",
274
- "feed.picksHint": "每个都带着推荐的理由",
275
300
  "feed.trending": "热门",
276
301
  "feed.updated": "{when}更新",
277
302
  "feed.all": "显示全部",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soffits/dsh-media-hub",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
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",
@@ -75,6 +75,7 @@
75
75
  "@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.1",
76
76
  "@deepseek-ai/schemastery": "^3.19.0",
77
77
  "@soffits/dsh-ui-kit": "0.2.0",
78
+ "danmaku": "^2.0.10",
78
79
  "esbuild": "^0.28.2",
79
80
  "hls.js": "^1.7.4",
80
81
  "https-proxy-agent": "^9.1.0",
@@ -0,0 +1,55 @@
1
+ /**
2
+ * A room's Comments tab: what people wrote about the work on its site, read
3
+ * only, newest copy first from the hub (src/remarks.js), with more pages on
4
+ * request.
5
+ */
6
+ import { formatCount } from './format.js'
7
+ import { React, api, day, fill, h, plural } from './ui.js'
8
+
9
+ function Comment({ t, item }) {
10
+ return h('li', { className: 'vsync-comment' },
11
+ h('div', { className: 'vsync-commentHead' },
12
+ h('strong', { className: 'vsync-commentName' }, item.name || t('comments.someone')),
13
+ item.rating !== null && h('span', { className: 'vsync-commentRating' }, fill(t('comments.rating'), { score: item.rating })),
14
+ item.created && h('span', { className: 'vsync-commentDate' }, day(t, Date.parse(item.created)))),
15
+ h('p', { className: 'vsync-commentText' }, item.text),
16
+ (item.likes > 0 || item.replies > 0) && h('div', { className: 'vsync-commentStats' },
17
+ item.likes > 0 && h('span', null, fill(t('comments.likes'), { n: formatCount(item.likes, t.language) })),
18
+ item.replies > 0 && h('span', null, plural(t, 'comments.replies', item.replies))))
19
+ }
20
+
21
+ export function Comments({ t, roomId }) {
22
+ const [pages, setPages] = React.useState(null)
23
+ const [error, setError] = React.useState(null)
24
+ const [busy, setBusy] = React.useState(false)
25
+ const path = `rooms/${encodeURIComponent(roomId)}/comments`
26
+
27
+ React.useEffect(() => {
28
+ let live = true
29
+ api(path).then((answer) => {
30
+ if (!live) return
31
+ if (answer.error) setError(answer.error)
32
+ else setPages([answer])
33
+ })
34
+ return () => { live = false }
35
+ }, [path])
36
+
37
+ if (error !== null) return h('p', { className: 'vsync-commentNote' }, error)
38
+ if (pages === null) return h('p', { className: 'vsync-commentNote', role: 'status' }, t('comments.loading'))
39
+ const items = pages.flatMap(page => page.items)
40
+ const next = pages[pages.length - 1].next
41
+ const more = async () => {
42
+ setBusy(true)
43
+ const answer = await api(`${path}?cursor=${encodeURIComponent(next)}`)
44
+ setBusy(false)
45
+ if (answer.error) return setError(answer.error)
46
+ const seen = new Set(items.map(item => item.id))
47
+ return setPages([...pages, { ...answer, items: answer.items.filter(item => !seen.has(item.id)) }])
48
+ }
49
+ return h('div', { className: 'vsync-comments' },
50
+ pages[0].total > 0 && h('p', { className: 'vsync-commentNote' }, plural(t, 'comments.total', pages[0].total)),
51
+ items.length === 0
52
+ ? h('p', { className: 'vsync-commentNote' }, t('comments.none'))
53
+ : h('ul', { className: 'vsync-commentList' }, items.map(item => h(Comment, { key: item.id, t, item }))),
54
+ next && h('button', { type: 'button', className: 'vsync-btn', disabled: busy, onClick: more }, busy ? t('comments.loading') : t('comments.more')))
55
+ }
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Danmaku over the picture: the comments people posted at a moment of an
3
+ * episode fly across it in time with the <video> playing, through Danmaku
4
+ * (weizhenye/Danmaku, its DOM engine, served by the host as danmaku.mjs).
5
+ * How they show (on or off, how opaque, how much of the picture they may
6
+ * cover, how large) is each viewer's own choice, kept in this browser.
7
+ */
8
+ import { React, h } from './ui.js'
9
+
10
+ const SETTINGS_KEY = 'media-hub.danmaku'
11
+ /** Seconds a comment takes to cross the picture, whatever its width (the official apps use about this). */
12
+ const CROSS_SECONDS = 8
13
+ export const AREAS = Object.freeze([0.25, 0.5, 1])
14
+ export const SIZES = Object.freeze(['small', 'medium', 'large'])
15
+ export const OPACITIES = Object.freeze([0.25, 0.5, 0.75, 1])
16
+ const DEFAULTS = Object.freeze({ on: true, opacity: 0.75, area: 0.5, size: 'medium' })
17
+
18
+ function loadSettings() {
19
+ try {
20
+ const saved = JSON.parse(localStorage.getItem(SETTINGS_KEY) ?? '{}')
21
+ return {
22
+ on: typeof saved.on === 'boolean' ? saved.on : DEFAULTS.on,
23
+ opacity: OPACITIES.includes(saved.opacity) ? saved.opacity : DEFAULTS.opacity,
24
+ area: AREAS.includes(saved.area) ? saved.area : DEFAULTS.area,
25
+ size: SIZES.includes(saved.size) ? saved.size : DEFAULTS.size,
26
+ }
27
+ } catch {
28
+ return { ...DEFAULTS }
29
+ }
30
+ }
31
+
32
+ /** This viewer's danmaku settings and a way to change some of them. */
33
+ export function useDanmakuSettings() {
34
+ const [settings, setSettings] = React.useState(loadSettings)
35
+ const change = React.useCallback((patch) => {
36
+ setSettings((current) => {
37
+ const next = { ...current, ...patch }
38
+ try {
39
+ localStorage.setItem(SETTINGS_KEY, JSON.stringify(next))
40
+ } catch { /* private mode: the choice lasts for this page */ }
41
+ return next
42
+ })
43
+ }, [])
44
+ return [settings, change]
45
+ }
46
+
47
+ /**
48
+ * The layer over the stage. `media` is the <video> in front (the player swaps
49
+ * elements between episodes), `items` the episode's danmaku `[{ time, text }]`.
50
+ */
51
+ export function DanmakuLayer({ media, items, settings }) {
52
+ const box = React.useRef(null)
53
+ React.useEffect(() => {
54
+ const container = box.current
55
+ if (container === null || media === null || items.length === 0) return undefined
56
+ let engine = null
57
+ let gone = false
58
+ const fit = () => {
59
+ if (engine === null) return
60
+ engine.resize()
61
+ engine.speed = Math.max(60, container.offsetWidth / CROSS_SECONDS)
62
+ }
63
+ const watcher = new ResizeObserver(fit)
64
+ import(new URL('./danmaku.mjs', import.meta.url).href).then(({ default: Danmaku }) => {
65
+ if (gone) return
66
+ engine = new Danmaku({ container, media, engine: 'dom', comments: items.map(item => ({ text: item.text, time: item.time, mode: 'rtl' })) })
67
+ fit()
68
+ watcher.observe(container)
69
+ })
70
+ return () => {
71
+ gone = true
72
+ watcher.disconnect()
73
+ engine?.destroy()
74
+ }
75
+ }, [media, items])
76
+ return h('div', {
77
+ ref: box,
78
+ className: 'vsync-danmaku',
79
+ 'aria-hidden': 'true',
80
+ 'data-size': settings.size,
81
+ style: { opacity: settings.opacity, height: `${settings.area * 100}%` },
82
+ })
83
+ }
package/web/feed-view.js CHANGED
@@ -1,38 +1,36 @@
1
1
  /**
2
- * What Discover shows before a search, for the source and category picked:
3
- * "For you" (the recommender's picks, each with its reason) and one list per
4
- * board the source itself puts forward (its rank lists, new arrivals). Under
5
- * All sources the picks of every source are interleaved and each source's lists
6
- * follow, headed by the source. Both come from dated copies the plugin keeps
2
+ * What Discover shows before a search, for the source and category picked: one
3
+ * list per board the source itself puts forward (its rank lists, new arrivals).
4
+ * Under All sources each source's lists follow, headed by the source. Both come from dated copies the plugin keeps
7
5
  * (src/copies.js), so the page never waits on a site: while a copy is first
8
6
  * being made the area shows a loading state, and the plugin's change signal
9
- * brings the answer. A source that offers neither shows nothing.
7
+ * brings the answer. A source with no lists shows nothing.
10
8
  *
11
- * The works are the same cards as search results.
9
+ * The works are the same cards as search results; `PickedWork` is one under the
10
+ * reason it was picked (the Watching tab's picks).
12
11
  */
13
12
  import { BookCard } from './books-view.js'
14
13
  import { pick } from './i18n.js'
15
14
  import { Result } from './result-card.js'
16
- import { Changes, K, Spinner, api, asPerson, fillNodes, h, query, React } from './ui.js'
15
+ import { Changes, K, Spinner, api, fillNodes, h, query, React } from './ui.js'
17
16
 
18
17
  /** Works of a list shown before "Show all". */
19
18
  export const LIST_PREVIEW = 6
20
19
 
21
- /** What the plugin has for one source and category: its trending lists and this person's picks. */
22
- function useFeed(sourceId, kind, language) {
20
+ /** What the plugin has for one source and category: its trending lists. */
21
+ function useFeed(sourceId, kind) {
23
22
  const { discover } = React.useContext(Changes)
24
23
  const [feed, setFeed] = React.useState(null)
25
- const key = `${sourceId}|${kind}|${language}`
24
+ const key = `${sourceId}|${kind}`
26
25
  React.useEffect(() => {
27
26
  let live = true
28
27
  const asked = query({ source: sourceId, kind })
29
- Promise.all([api(`trending?${asked}`), asPerson(`picks?${asked}&${query({ language })}`)]).then(([trending, picks]) => {
28
+ api(`trending?${asked}`).then((trending) => {
30
29
  if (!live) return
31
30
  setFeed({
32
31
  key,
33
32
  trending: Array.isArray(trending.trending) ? trending.trending : [],
34
- picks: Array.isArray(picks.picks) ? picks.picks : [],
35
- loading: trending.loading === true || picks.loading === true,
33
+ loading: trending.loading === true,
36
34
  })
37
35
  })
38
36
  return () => { live = false }
@@ -53,27 +51,37 @@ function FeedSection({ id, title, hint, children }) {
53
51
  children)
54
52
  }
55
53
 
54
+ /** A work as the card of its kind: a book is downloaded in a format, anything else watched or listened to. */
55
+ export function WorkCard({ t, source, work, isBook, onOpen, onSaved, onFocus }) {
56
+ return isBook
57
+ ? h(BookCard, { t, source, result: work })
58
+ : h(Result, { t, source, result: work, onOpen, onSaved, onFocus })
59
+ }
60
+
61
+ /** One picked work under the reason it was picked. */
62
+ export function PickedWork({ t, source, work, why, onOpen, onSaved, onFocus }) {
63
+ if (source === undefined) return null
64
+ const book = source.kinds.find(kind => kind.id === work.kind)?.media === 'book'
65
+ return h('li', { className: 'vsync-feedPick' },
66
+ h('p', { className: 'vsync-pickWhy' }, h(K.Icon, { name: 'sparkles', size: 14, tone: 'violet' }), h('span', null, why)),
67
+ h('ul', { className: 'vsync-rows' }, h(WorkCard, { t, source, work, isBook: book, onOpen, onSaved, onFocus })))
68
+ }
69
+
56
70
  export function DiscoverFeed({ t, sourceId, kind, sourceOf, isBook, onOpen, onSaved, onFocus }) {
57
- const feed = useFeed(sourceId, kind ?? '', t.language)
71
+ const feed = useFeed(sourceId, kind ?? '')
58
72
  const [expanded, setExpanded] = React.useState(() => new Set())
59
73
  if (feed === null) return h(Skeleton, { t })
60
- const { trending, picks, loading } = feed
61
- if (trending.length === 0 && picks.length === 0) return loading ? h(Skeleton, { t }) : null
74
+ const { trending, loading } = feed
75
+ if (trending.length === 0) return loading ? h(Skeleton, { t }) : null
62
76
 
63
77
  const card = (work) => {
64
78
  const from = sourceOf(work.source)
65
79
  if (from === undefined) return null
66
- return isBook(work.kind, from)
67
- ? h(BookCard, { key: `${from.id}:${work.id}`, t, source: from, result: work })
68
- : h(Result, { key: `${from.id}:${work.id}`, t, source: from, result: work, onOpen, onSaved, onFocus })
80
+ return h(WorkCard, { key: `${from.id}:${work.id}`, t, source: from, work, isBook: isBook(work.kind, from), onOpen, onSaved, onFocus })
69
81
  }
70
82
  const merged = sourceId === 'all'
71
83
 
72
84
  return h('div', { className: 'vsync-feed' },
73
- picks.length > 0 && h(FeedSection, { id: 'vsync-feed-picks', title: t('feed.picks'), hint: t('feed.picksHint') },
74
- h('ul', { className: 'vsync-rows vsync-results' }, picks.map(entry => h('li', { key: `${entry.work.source}:${entry.work.id}`, className: 'vsync-feedPick' },
75
- h('p', { className: 'vsync-pickWhy' }, h(K.Icon, { name: 'sparkles', size: 14, tone: 'violet' }), h('span', null, entry.why)),
76
- h('ul', { className: 'vsync-rows' }, card(entry.work)))))),
77
85
  trending.flatMap(({ source: from, at, lists }) => lists.map((list) => {
78
86
  const id = `${from}:${list.id}`
79
87
  const name = pick(list.label, t.language).trim() || t('feed.trending')
package/web/page.js CHANGED
@@ -117,16 +117,18 @@ export function Page({ t, initialRoom }) {
117
117
  // The plugin announces every change of what the page shows (src/changes.js); the page re-reads then, and once when the stream (re)connects. No timer.
118
118
  const [shelf, setShelf] = React.useState(0)
119
119
  const [discover, setDiscover] = React.useState(0)
120
+ const [shows, setShows] = React.useState(0)
120
121
  const stream = K.useEventStream('api/media-hub/events', (message) => {
121
122
  if (message.what?.includes('shelf')) setShelf(count => count + 1)
122
123
  if (message.what?.includes('discover')) setDiscover(count => count + 1)
124
+ if (message.what?.includes('library')) setShows(count => count + 1)
123
125
  if (message.what?.some(kind => kind === 'library' || kind === 'rooms')) load()
124
126
  })
125
127
  React.useEffect(() => { if (stream === 'live') { load(); setShelf(count => count + 1) } }, [stream, load])
126
128
  React.useEffect(() => { load() }, [load])
127
129
 
128
130
  const known = React.useMemo(() => ({ library, rooms, reload: load }), [library, rooms, load])
129
- const changes = React.useMemo(() => ({ shelf, discover }), [shelf, discover])
131
+ const changes = React.useMemo(() => ({ shelf, discover, shows }), [shelf, discover, shows])
130
132
  return h(Changes.Provider, { value: changes }, h(Known.Provider, { value: known }, h(React.Fragment, null,
131
133
  roomId === null
132
134
  ? h(Home, { t, nav, go, onOpen: setRoomId, rooms, library, load })
package/web/panel.css CHANGED
@@ -49,7 +49,8 @@
49
49
  .vsync-member[data-wait=loading]:before{background:var(--dsw-alias-state-warning-primary,#d29922)}
50
50
  .vsync-status{flex:none;color:var(--dsw-alias-label-tertiary);font-size:12px}
51
51
  .vsync-body{flex:1;min-height:0;display:flex}
52
- .vsync-stageWrap{position:relative;flex:1;min-width:0;display:flex;background:#000}
52
+ .vsync-player{flex:1;min-width:0;display:flex;flex-direction:column;background:#000}
53
+ .vsync-stageWrap{position:relative;flex:1;min-width:0;min-height:0;display:flex;background:#000}
53
54
  .vsync-stage{flex:1;min-width:0;display:flex}
54
55
  .vsync-media{flex:1;width:100%;height:100%;border:0;display:block;background:#000;object-fit:contain}
55
56
  .vsync-overlay{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;color:rgba(255,255,255,.72);font-size:13px;pointer-events:none}
@@ -86,7 +87,7 @@
86
87
  .vsync-episode[aria-current=true] .vsync-episodeNo{color:inherit}
87
88
  .vsync-episodeTitle{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
88
89
  .vsync-episodeState{flex:none;color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400}
89
- @media (width<=900px){.vsync-body{flex-direction:column}.vsync-stageWrap{flex:none;aspect-ratio:16/9}.vsync-episodes{width:auto;flex:1;border-left:0;border-top:.5px solid var(--dsw-alias-border-l4)}.vsync-members .vsync-memberName{display:none}}
90
+ @media (width<=900px){.vsync-body{flex-direction:column}.vsync-player{flex:none}.vsync-stageWrap{flex:none;aspect-ratio:16/9}.vsync-episodes{width:auto;flex:1;border-left:0;border-top:.5px solid var(--dsw-alias-border-l4)}.vsync-members .vsync-memberName{display:none}}
90
91
  /* Search */
91
92
  .vsync-search{position:relative;display:flex;gap:8px;align-items:center;margin-bottom:10px}
92
93
  .vsync-searchIcon{position:absolute;left:12px;top:10px;width:16px;height:16px;color:var(--dsw-alias-label-tertiary);pointer-events:none}
@@ -346,19 +347,10 @@
346
347
  .vsync-ccRecap p{margin:0}
347
348
  .vsync-ccRecapHead{display:flex;align-items:center;gap:6px;font-size:12px;font-weight:500;color:var(--dsw-alias-label-tertiary)}
348
349
  .vsync-ccRecapText{margin-top:4px!important;line-height:22px}
349
- .vsync-ccActions,.vsync-pickActions,.vsync-rateAnswers{display:flex;flex-wrap:wrap;gap:8px}
350
+ .vsync-ccActions,.vsync-rateAnswers{display:flex;flex-wrap:wrap;gap:8px}
350
351
  .vsync-rate{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px;padding:12px 16px}
351
352
  .vsync-rateHead{display:flex;align-items:center;gap:12px;min-width:0}
352
353
  .vsync-rateText{min-width:0}
353
- .vsync-pickGrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:12px}
354
- .vsync-pickCard{display:flex;gap:12px;padding:12px}
355
- .vsync-pickCover{flex:none;width:76px;height:114px;border-radius:8px;object-fit:cover}
356
- .vsync-pickBody{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px}
357
- .vsync-pickOpen{flex:none;padding:0;border:0;background:none;cursor:pointer;border-radius:8px}
358
- .vsync-pickTitle{padding:0;border:0;background:none;color:inherit;font:inherit;font-weight:600;line-height:20px;text-align:start;overflow-wrap:anywhere;cursor:pointer}
359
- @media (hover:hover){.vsync-pickTitle:hover{text-decoration:underline}}
360
- .vsync-pickCard{transition:transform .15s ease}.vsync-pickCard:active{transform:scale(.99)}
361
- @media (prefers-reduced-motion:reduce){.vsync-pickCard{transition:none}}
362
354
  .vsync-pickWhy{display:flex;gap:6px;font-size:13px;line-height:19px;color:var(--dsw-alias-label-secondary)}
363
355
  .vsync-pickWhy .uk-icon{margin-top:2px}
364
356
  .vsync-feed{margin-top:8px}
@@ -366,13 +358,38 @@
366
358
  .vsync-feedPick{list-style:none;display:flex;flex-direction:column;gap:4px}
367
359
  .vsync-feedPick .vsync-pickWhy{margin:0 4px}
368
360
  .vsync-feedSection .vsync-more{display:flex;margin-top:0}
369
- .vsync-pickActions{margin-top:auto;padding-top:6px}
370
361
  @media (width<=640px){.vsync-cc{flex-direction:column;gap:14px}.vsync-ccPoster{width:112px;height:150px}.vsync-ccStrip .uk-segmentsLabelled{flex-wrap:wrap;row-gap:4px}.vsync-ccStrip .uk-segments{flex-basis:100%}}
371
362
  /* Interface chrome is not selectable and pictures don't drag; titles, recaps and reasons stay selectable. */
372
- .vsync-pageTabs,.vsync-ccActions,.vsync-rateAnswers,.vsync-pickActions,.vsync-ccLive,.vsync-sectionMeta,.vsync-sectionHead h2,.vsync-actions,.vsync-tabCount,.vsync-ccStrip,.vsync-rateHead .uk-tile{user-select:none;-webkit-user-select:none}
363
+ .vsync-pageTabs,.vsync-ccActions,.vsync-rateAnswers,.vsync-ccLive,.vsync-sectionMeta,.vsync-sectionHead h2,.vsync-actions,.vsync-tabCount,.vsync-ccStrip,.vsync-rateHead .uk-tile{user-select:none;-webkit-user-select:none}
373
364
  .vsync-page img{-webkit-user-drag:none;user-select:none;-webkit-user-select:none}
374
- .vsync-ccActions .uk-touch,.vsync-pickActions .uk-touch,.vsync-rateAnswers .uk-touch{font-size:13px}
365
+ .vsync-ccActions .uk-touch .uk-touch,.vsync-rateAnswers .uk-touch{font-size:13px}
375
366
  /* Points offer: an extra's price at the moment of the action */
376
367
  .vsync-pointsOffer{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);z-index:40;display:flex;align-items:center;gap:12px;max-width:min(560px,calc(100% - 32px));padding:10px 12px 10px 16px;border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-bg-layer-1,var(--dsw-alias-bg-base));box-shadow:var(--dsw-shadow-lv3)}
377
368
  .vsync-pointsText{flex:1;min-width:0;font-size:13px;line-height:19px;color:var(--dsw-alias-label-primary)}
378
369
  @media (width<=767px){.vsync-pointsOffer{flex-wrap:wrap;bottom:12px}.vsync-pointsOffer>.vsync-actions{margin-left:auto}}
370
+ /* Player bar, danmaku, full screen */
371
+ .vsync-playerBar{flex:none;display:flex;align-items:center;gap:8px;padding:6px 12px;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);border-bottom:.5px solid var(--dsw-alias-border-l4)}
372
+ .vsync-grow{flex:1}
373
+ .vsync-danmakuToggle[aria-checked=true]{color:var(--dsw-alias-state-business-primary);box-shadow:inset 0 0 0 var(--dsh-hairline-width,.5px) var(--dsw-alias-state-business-primary)}
374
+ .vsync-danmakuToggle[aria-checked=false]{color:var(--dsw-alias-label-tertiary)}
375
+ .vsync-popover{position:absolute;right:0;bottom:calc(100% + 6px);z-index:30;box-sizing:border-box;width:min(320px,calc(100vw - 24px));display:flex;flex-direction:column;gap:14px;padding:14px;border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-bg-layer-1,var(--dsw-alias-bg-base));color:var(--dsw-alias-label-primary);box-shadow:var(--dsw-shadow-lv3)}
376
+ .vsync-setting{display:flex;flex-direction:column;gap:6px}
377
+ .vsync-settingLabel{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px}
378
+ .vsync-settingChoices{display:flex;flex-wrap:wrap;gap:6px}
379
+ .vsync-settingNote{margin:6px 0 0;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}
380
+ .vsync-danmaku{position:absolute;top:0;left:0;right:0;z-index:1;overflow:hidden;pointer-events:none;color:#fff;font-size:20px;font-weight:600;line-height:1.3;text-shadow:0 0 2px rgba(0,0,0,.9),0 1px 2px rgba(0,0,0,.6)}
381
+ .vsync-danmaku[data-size=small]{font-size:15px}
382
+ .vsync-danmaku[data-size=large]{font-size:26px}
383
+ @media (width<=640px){.vsync-danmaku{font-size:15px}.vsync-danmaku[data-size=small]{font-size:12px}.vsync-danmaku[data-size=large]{font-size:19px}}
384
+ .vsync-player:fullscreen,.vsync-player[data-covering=true]{width:100%;height:100%}
385
+ .vsync-player[data-covering=true]{position:fixed;inset:0;z-index:1000;height:100dvh}
386
+ .vsync-player:fullscreen .vsync-stageWrap,.vsync-player[data-covering=true] .vsync-stageWrap{flex:1;aspect-ratio:auto}
387
+ .vsync-player:fullscreen .vsync-playerBar,.vsync-player[data-covering=true] .vsync-playerBar{background:#000;color:#fff;border-bottom:0;padding-bottom:max(6px,env(safe-area-inset-bottom))}
388
+ /* Comments */
389
+ .vsync-comments{flex:1;min-height:0;overflow:auto;display:flex;flex-direction:column;align-items:flex-start;gap:10px;padding:8px 16px 16px}
390
+ .vsync-commentNote{margin:0;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}
391
+ .vsync-commentList{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:16px;align-self:stretch}
392
+ .vsync-commentHead{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 8px;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}
393
+ .vsync-commentName{color:var(--dsw-alias-label-secondary);font-weight:500}
394
+ .vsync-commentText{margin:4px 0 0;color:var(--dsw-alias-label-primary);font-size:13px;line-height:20px;white-space:pre-wrap;overflow-wrap:anywhere}
395
+ .vsync-commentStats{display:flex;gap:12px;margin-top:4px;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * The row under the picture, as phone players have it: danmaku on or off,
3
+ * how they show and the show's quality behind one settings button, and full
4
+ * screen with the danmaku kept on top.
5
+ */
6
+ import { AREAS, OPACITIES, SIZES } from './danmaku-layer.js'
7
+ import { Icon, Popover, React, fill, h, qualityLabel } from './ui.js'
8
+
9
+ /** One choice among a few, as chips. */
10
+ function Choice({ label, options, value, onChange }) {
11
+ return h('div', { className: 'vsync-setting' },
12
+ h('span', { className: 'vsync-settingLabel' }, label),
13
+ h('div', { className: 'vsync-settingChoices', role: 'group', 'aria-label': label }, options.map(option => h('button', {
14
+ key: option.value,
15
+ type: 'button',
16
+ className: 'vsync-chip',
17
+ 'aria-pressed': String(option.value === value),
18
+ onClick: () => onChange(option.value),
19
+ }, option.label))))
20
+ }
21
+
22
+ const percent = value => `${Math.round(value * 100)}%`
23
+ /** The words for AREAS, in its order. */
24
+ const AREA_WORDS = Object.freeze(['quarter', 'half', 'full'])
25
+
26
+ /**
27
+ * @param {object} props
28
+ * @param {{ on: boolean, opacity: number, area: number, size: string }} props.settings - this viewer's danmaku settings
29
+ * @param {(patch: object) => void} props.onSettings
30
+ * @param {boolean} props.danmaku - whether the show's source has danmaku
31
+ * @param {number | null} props.count - how many the episode has, once known
32
+ * @param {{ value: string, choices: string[], onChange: (quality: string) => void, busy: boolean } | null} props.quality
33
+ * @param {boolean} props.full - whether the player fills the screen
34
+ * @param {() => void} props.onFull
35
+ */
36
+ export function PlayerBar({ t, settings, onSettings, danmaku, count, quality, full, onFull }) {
37
+ const danmakuSettings = danmaku && settings.on && [
38
+ h(Choice, { key: 'opacity', label: t('danmaku.opacity'), value: settings.opacity, onChange: opacity => onSettings({ opacity }), options: OPACITIES.map(value => ({ value, label: percent(value) })) }),
39
+ h(Choice, { key: 'area', label: t('danmaku.area'), value: settings.area, onChange: area => onSettings({ area }), options: AREAS.map((value, n) => ({ value, label: t(`danmaku.area.${AREA_WORDS[n]}`) })) }),
40
+ h(Choice, { key: 'size', label: t('danmaku.size'), value: settings.size, onChange: size => onSettings({ size }), options: SIZES.map(value => ({ value, label: t(`danmaku.size.${value}`) })) }),
41
+ ]
42
+ const qualityChoice = quality !== null && h('div', { key: 'quality', className: 'vsync-settingGroup' },
43
+ h(Choice, { label: t('quality.label'), value: quality.value, onChange: quality.onChange, options: quality.choices.map(value => ({ value, label: qualityLabel(t, value) })) }),
44
+ h('p', { className: 'vsync-settingNote' }, quality.busy ? t('quality.changing') : t('quality.fromNext')))
45
+ const hasSettings = Boolean(danmakuSettings) || Boolean(qualityChoice)
46
+ return h('div', { className: 'vsync-playerBar' },
47
+ danmaku && h('button', {
48
+ type: 'button',
49
+ className: 'vsync-btn vsync-danmakuToggle',
50
+ role: 'switch',
51
+ 'aria-checked': String(settings.on),
52
+ onClick: () => onSettings({ on: !settings.on }),
53
+ }, h(Icon.Danmaku), settings.on && count !== null ? fill(t('danmaku.count'), { n: count }) : t('danmaku.label')),
54
+ h('span', { className: 'vsync-grow' }),
55
+ hasSettings && h(Popover, { label: t('player.settings'), icon: h(Icon.Settings) }, danmakuSettings, qualityChoice),
56
+ h('button', { type: 'button', className: 'vsync-icon', 'aria-label': t(full ? 'player.exitFull' : 'player.full'), title: t(full ? 'player.exitFull' : 'player.full'), 'aria-pressed': String(full), onClick: onFull }, h(full ? Icon.Shrink : Icon.Expand)))
57
+ }
package/web/player.js CHANGED
@@ -698,6 +698,8 @@ export function joinRoom({ base, roomId, name, language = '', trackLabel = label
698
698
 
699
699
  return {
700
700
  clientId,
701
+ /** The <video> in front, which danmaku follow (the player swaps elements between episodes); null before one plays. */
702
+ get media() { return player?.element ?? null },
701
703
  /** Switch the room to an episode. */
702
704
  select(index) {
703
705
  op({ op: 'select', index })