@soffits/dsh-media-hub 0.13.0 → 0.15.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/CHANGELOG.md +11 -0
- package/README.md +2 -1
- package/client.js +13 -0
- package/dist/danmaku.mjs +561 -0
- package/dist/index.js +377 -201
- package/locale/en.json +31 -8
- package/locale/fr.json +30 -7
- package/locale/zh.json +29 -6
- package/package.json +3 -1
- package/web/comments-view.js +55 -0
- package/web/danmaku-layer.js +83 -0
- package/web/page.js +5 -31
- package/web/panel.css +29 -6
- package/web/player-bar.js +57 -0
- package/web/player.js +2 -0
- package/web/result-card.js +1 -3
- package/web/room-view.js +105 -38
- package/web/ui.js +40 -18
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.",
|
|
@@ -280,13 +307,9 @@
|
|
|
280
307
|
"continue.play": "Play",
|
|
281
308
|
"library.continueAt": "continue at {time}",
|
|
282
309
|
"library.viewerStoppedAt": "{name} stopped at {time}",
|
|
283
|
-
"points.newSeries": "
|
|
284
|
-
"points.
|
|
285
|
-
"points.
|
|
286
|
-
"points.
|
|
287
|
-
"points.pending": "{name} is waiting for approval.",
|
|
288
|
-
"points.buy": "Buy",
|
|
289
|
-
"points.notNow": "Not now",
|
|
290
|
-
"points.ok": "OK"
|
|
310
|
+
"points.newSeries": "Start a new series",
|
|
311
|
+
"points.newSeriesAbout": "Begin watching a series that is new to the library. Going on with one stays free.",
|
|
312
|
+
"points.bingeNight": "Binge night",
|
|
313
|
+
"points.bingeNightAbout": "Start watching late at night, as often as you like, until morning."
|
|
291
314
|
}
|
|
292
315
|
}
|
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.",
|
|
@@ -281,12 +308,8 @@
|
|
|
281
308
|
"library.continueAt": "reprendre à {time}",
|
|
282
309
|
"library.viewerStoppedAt": "{name} s’est arrêté·e à {time}",
|
|
283
310
|
"points.newSeries": "Commencer une nouvelle série",
|
|
284
|
-
"points.
|
|
285
|
-
"points.
|
|
286
|
-
"points.
|
|
287
|
-
"points.pending": "{name} attend un accord.",
|
|
288
|
-
"points.buy": "Acheter",
|
|
289
|
-
"points.notNow": "Pas maintenant",
|
|
290
|
-
"points.ok": "OK"
|
|
311
|
+
"points.newSeriesAbout": "Commencer une série qui n’est pas encore dans la bibliothèque. Continuer une série reste gratuit.",
|
|
312
|
+
"points.bingeNight": "Nuit de marathon",
|
|
313
|
+
"points.bingeNightAbout": "Lancer des épisodes tard dans la nuit, autant que vous voulez, jusqu’au matin."
|
|
291
314
|
}
|
|
292
315
|
}
|
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": "这个地址没有可播放的内容,检查一下链接。",
|
|
@@ -281,12 +308,8 @@
|
|
|
281
308
|
"library.continueAt": "从 {time} 继续",
|
|
282
309
|
"library.viewerStoppedAt": "{name}看到 {time}",
|
|
283
310
|
"points.newSeries": "开一部新剧",
|
|
311
|
+
"points.newSeriesAbout": "开始看一部库里还没有的剧。接着看已有的剧不花分。",
|
|
284
312
|
"points.bingeNight": "通宵追剧夜",
|
|
285
|
-
"points.
|
|
286
|
-
"points.short": "{name}要 {cost} 分,还差 {gap} 分。",
|
|
287
|
-
"points.pending": "{name}还在等批准。",
|
|
288
|
-
"points.buy": "兑换",
|
|
289
|
-
"points.notNow": "先不了",
|
|
290
|
-
"points.ok": "好"
|
|
313
|
+
"points.bingeNightAbout": "深夜开播,想看几次都行,到早上为止。"
|
|
291
314
|
}
|
|
292
315
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soffits/dsh-media-hub",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.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",
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"@deepseek-ai/dsh-client-locale",
|
|
58
58
|
"@soffits/dsh-ui-actions",
|
|
59
59
|
"@soffits/dsh-ui-kit",
|
|
60
|
+
"@soffits/dsh-points",
|
|
60
61
|
"@deepseek-ai/dsh-client-ui-layout",
|
|
61
62
|
"@deepseek-ai/dsh-client-ui-sidebar"
|
|
62
63
|
]
|
|
@@ -75,6 +76,7 @@
|
|
|
75
76
|
"@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.1",
|
|
76
77
|
"@deepseek-ai/schemastery": "^3.19.0",
|
|
77
78
|
"@soffits/dsh-ui-kit": "0.2.0",
|
|
79
|
+
"danmaku": "^2.0.10",
|
|
78
80
|
"esbuild": "^0.28.2",
|
|
79
81
|
"hls.js": "^1.7.4",
|
|
80
82
|
"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/page.js
CHANGED
|
@@ -8,7 +8,7 @@ import { LibrarySection } from './library-view.js'
|
|
|
8
8
|
import { clearNav, readNav, TABS, writeNav } from './nav.js'
|
|
9
9
|
import { RoomView } from './room-view.js'
|
|
10
10
|
import { WatchingTab, withNews } from './watching-view.js'
|
|
11
|
-
import { Changes, K, Known, P, api,
|
|
11
|
+
import { Changes, K, Known, P, api, h, React, setWords } from './ui.js'
|
|
12
12
|
|
|
13
13
|
/** Marks the history entries this page added, so a back control knows going back stays on the page. */
|
|
14
14
|
const PUSHED = 'vsyncPushed'
|
|
@@ -73,33 +73,6 @@ function Home({ t, nav, go, onOpen, rooms, library, load }) {
|
|
|
73
73
|
h(DiscoverView, { t, nav, onNav: go, onOpen, onSaved: load, onBack: () => (history.state?.[PUSHED] ? history.back() : go({ work: null }, { replace: true })) }))))
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
/** The page's words for the extras the hub sells (src/points.js EXTRAS), by item key; another item keeps its shop name. */
|
|
77
|
-
const EXTRA_WORDS = Object.freeze({ 'media:new_series': 'points.newSeries', 'media:binge_night': 'points.bingeNight' })
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* The offer of an extra at the moment of the action: its price and the person's balance, and Buy when they can.
|
|
81
|
-
* One at a time; `asPersonPaying` (ui.js) waits for the answer.
|
|
82
|
-
*/
|
|
83
|
-
function PointsOffer({ t }) {
|
|
84
|
-
const [ask, setAsk] = React.useState(null)
|
|
85
|
-
React.useEffect(() => {
|
|
86
|
-
setOffer(points => new Promise(resolve => setAsk({ points, resolve })))
|
|
87
|
-
return () => setOffer(null)
|
|
88
|
-
}, [])
|
|
89
|
-
if (ask === null) return null
|
|
90
|
-
const { points, resolve } = ask
|
|
91
|
-
const done = (yes) => { setAsk(null); resolve(yes) }
|
|
92
|
-
const name = EXTRA_WORDS[points.item] ? t(EXTRA_WORDS[points.item]) : points.name
|
|
93
|
-
const key = points.pending ? 'points.pending' : points.affordable ? 'points.offer' : 'points.short'
|
|
94
|
-
return h('div', { className: 'vsync-pointsOffer', role: 'alertdialog', 'aria-live': 'polite' },
|
|
95
|
-
h('span', { className: 'vsync-pointsText' }, fill(t(key), { name, cost: points.cost, balance: points.balance, gap: points.gap })),
|
|
96
|
-
h('span', { className: 'vsync-actions' },
|
|
97
|
-
points.affordable && !points.pending
|
|
98
|
-
? [h('button', { key: 'no', type: 'button', className: 'vsync-btn', onClick: () => done(false) }, t('points.notNow')),
|
|
99
|
-
h('button', { key: 'yes', type: 'button', className: 'vsync-btn vsync-primary', autoFocus: true, onClick: () => done(true) }, t('points.buy'))]
|
|
100
|
-
: h('button', { type: 'button', className: 'vsync-btn', autoFocus: true, onClick: () => done(false) }, t('points.ok'))))
|
|
101
|
-
}
|
|
102
|
-
|
|
103
76
|
export function Page({ t, initialRoom }) {
|
|
104
77
|
setWords(t)
|
|
105
78
|
const [roomId, setRoomId] = React.useState(initialRoom)
|
|
@@ -117,19 +90,20 @@ export function Page({ t, initialRoom }) {
|
|
|
117
90
|
// 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
91
|
const [shelf, setShelf] = React.useState(0)
|
|
119
92
|
const [discover, setDiscover] = React.useState(0)
|
|
93
|
+
const [shows, setShows] = React.useState(0)
|
|
120
94
|
const stream = K.useEventStream('api/media-hub/events', (message) => {
|
|
121
95
|
if (message.what?.includes('shelf')) setShelf(count => count + 1)
|
|
122
96
|
if (message.what?.includes('discover')) setDiscover(count => count + 1)
|
|
97
|
+
if (message.what?.includes('library')) setShows(count => count + 1)
|
|
123
98
|
if (message.what?.some(kind => kind === 'library' || kind === 'rooms')) load()
|
|
124
99
|
})
|
|
125
100
|
React.useEffect(() => { if (stream === 'live') { load(); setShelf(count => count + 1) } }, [stream, load])
|
|
126
101
|
React.useEffect(() => { load() }, [load])
|
|
127
102
|
|
|
128
103
|
const known = React.useMemo(() => ({ library, rooms, reload: load }), [library, rooms, load])
|
|
129
|
-
const changes = React.useMemo(() => ({ shelf, discover }), [shelf, discover])
|
|
104
|
+
const changes = React.useMemo(() => ({ shelf, discover, shows }), [shelf, discover, shows])
|
|
130
105
|
return h(Changes.Provider, { value: changes }, h(Known.Provider, { value: known }, h(React.Fragment, null,
|
|
131
106
|
roomId === null
|
|
132
107
|
? h(Home, { t, nav, go, onOpen: setRoomId, rooms, library, load })
|
|
133
|
-
: h(RoomView, { key: roomId, t, roomId, onLeave: () => setRoomId(null), onOpen: setRoomId })
|
|
134
|
-
h(PointsOffer, { t }))))
|
|
108
|
+
: h(RoomView, { key: roomId, t, roomId, onLeave: () => setRoomId(null), onOpen: setRoomId }))))
|
|
135
109
|
}
|
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-
|
|
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}
|
|
@@ -362,7 +363,29 @@
|
|
|
362
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}
|
|
363
364
|
.vsync-page img{-webkit-user-drag:none;user-select:none;-webkit-user-select:none}
|
|
364
365
|
.vsync-ccActions .uk-touch .uk-touch,.vsync-rateAnswers .uk-touch{font-size:13px}
|
|
365
|
-
/*
|
|
366
|
-
.vsync-
|
|
367
|
-
.vsync-
|
|
368
|
-
|
|
366
|
+
/* Player bar, danmaku, full screen */
|
|
367
|
+
.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)}
|
|
368
|
+
.vsync-grow{flex:1}
|
|
369
|
+
.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)}
|
|
370
|
+
.vsync-danmakuToggle[aria-checked=false]{color:var(--dsw-alias-label-tertiary)}
|
|
371
|
+
.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)}
|
|
372
|
+
.vsync-setting{display:flex;flex-direction:column;gap:6px}
|
|
373
|
+
.vsync-settingLabel{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px}
|
|
374
|
+
.vsync-settingChoices{display:flex;flex-wrap:wrap;gap:6px}
|
|
375
|
+
.vsync-settingNote{margin:6px 0 0;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}
|
|
376
|
+
.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)}
|
|
377
|
+
.vsync-danmaku[data-size=small]{font-size:15px}
|
|
378
|
+
.vsync-danmaku[data-size=large]{font-size:26px}
|
|
379
|
+
@media (width<=640px){.vsync-danmaku{font-size:15px}.vsync-danmaku[data-size=small]{font-size:12px}.vsync-danmaku[data-size=large]{font-size:19px}}
|
|
380
|
+
.vsync-player:fullscreen,.vsync-player[data-covering=true]{width:100%;height:100%}
|
|
381
|
+
.vsync-player[data-covering=true]{position:fixed;inset:0;z-index:1000;height:100dvh}
|
|
382
|
+
.vsync-player:fullscreen .vsync-stageWrap,.vsync-player[data-covering=true] .vsync-stageWrap{flex:1;aspect-ratio:auto}
|
|
383
|
+
.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))}
|
|
384
|
+
/* Comments */
|
|
385
|
+
.vsync-comments{flex:1;min-height:0;overflow:auto;display:flex;flex-direction:column;align-items:flex-start;gap:10px;padding:8px 16px 16px}
|
|
386
|
+
.vsync-commentNote{margin:0;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}
|
|
387
|
+
.vsync-commentList{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:16px;align-self:stretch}
|
|
388
|
+
.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}
|
|
389
|
+
.vsync-commentName{color:var(--dsw-alias-label-secondary);font-weight:500}
|
|
390
|
+
.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}
|
|
391
|
+
.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 })
|
package/web/result-card.js
CHANGED
|
@@ -9,13 +9,11 @@ import { Cover, WorkDetails, glance, infoOf } from './details.js'
|
|
|
9
9
|
import { FollowButton } from './follow.js'
|
|
10
10
|
import { hasEpisodes, resumeLabel } from './format.js'
|
|
11
11
|
import { useKnownWork } from './known.js'
|
|
12
|
-
import { Confirm, EPISODE_BYTES, Icon, React, Spinner, asPersonPaying, bytes, chatAbout, clock, displayName, fill, h } from './ui.js'
|
|
12
|
+
import { Confirm, EPISODE_BYTES, Icon, React, Spinner, asPersonPaying, bytes, chatAbout, clock, displayName, fill, h, qualityLabel } from './ui.js'
|
|
13
13
|
|
|
14
14
|
/** Episodes fetched ahead of the one being watched; the Host's `cacheAhead` default, for the size hint. */
|
|
15
15
|
const WINDOW_EPISODES = 6
|
|
16
16
|
|
|
17
|
-
/** The words for a quality a source offers: auto, audio, or a height. */
|
|
18
|
-
const qualityLabel = (t, quality) => (/^\d+$/.test(quality) ? fill(t('quality.height'), { n: quality }) : t(`quality.${quality}`))
|
|
19
17
|
|
|
20
18
|
/** How the episodes are fetched, for a source that offers a choice (Link); its first choice (auto) is the default. */
|
|
21
19
|
function QualityPicker({ t, qualities, value, onChange }) {
|