@soffits/dsh-media-hub 0.10.2 → 0.11.1

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.1
4
+
5
+ - The page's words come from the language files each time it asks, not from a copy made when the plugin started. An update that only changed words (0.11.0's type badges) showed raw keys until DSH restarted.
6
+
7
+ ## 0.11.0
8
+
9
+ - Library is one list. The shows and the books you downloaded (My books) used to sit in two sections; they are now cards in the same list, each marked Show, Video, Audio or Book, and every card has a background. The top line counts both: the library's size, how much of the books' room you used, and what is free.
10
+
3
11
  ## 0.10.2
4
12
 
5
13
  - hls.js now loads. The page asked for it at the wrong address, so a browser that needed it (any Chromium one, since 0.10.1) never got past loading. Episodes that are still being made play there again.
package/dist/index.js CHANGED
@@ -12255,7 +12255,6 @@ async function readJson(req) {
12255
12255
  var STATUS = Object.freeze({ points: 402, invalid: 400, empty: 400, not_found: 404, unsupported: 501, outside: 403, in_use: 409, exists: 409, no_space: 507, source_failed: 424, unavailable: 503 });
12256
12256
  var errorBody = (error) => ({ error: { code: error?.code ?? "error", ...error?.reason ? { reason: error.reason } : {}, ...error?.points ? { points: error.points } : {}, message: error?.message ?? String(error) } });
12257
12257
  function createHandler({ connection, service, settings = () => ({ label: "", presence: {} }), localeDir = LOCALE_DIR, logger }) {
12258
- let locales;
12259
12258
  return async (req, res) => {
12260
12259
  const admitted = admitOwner(connection, req);
12261
12260
  if (!admitted.ok) return sendText(res, admitted.status, admitted.status === 401 ? "Sign in to DSH first." : "Forbidden.");
@@ -12324,7 +12323,7 @@ function createHandler({ connection, service, settings = () => ({ label: "", pre
12324
12323
  if (route === "POST library/seen") return sendJson(res, 200, hub.dismissNews((await readJson(req)).path));
12325
12324
  if (route === "POST library/cancel") return sendJson(res, 200, await hub.cancelDownload((await readJson(req)).path));
12326
12325
  if (route === "GET settings") return sendJson(res, 200, settings());
12327
- if (route === "GET locales") return sendJson(res, 200, await (locales ??= readLocales(localeDir, logger)));
12326
+ if (route === "GET locales") return sendJson(res, 200, await readLocales(localeDir, logger));
12328
12327
  if (route === "GET sources") return sendJson(res, 200, { sources: await hub.sources() });
12329
12328
  if (route === "GET trending") return sendJson(res, 200, await hub.trending(query("source"), query("kind")));
12330
12329
  if (route === "GET search") return sendJson(res, 200, await hub.search(query("source"), query("q"), query("kind") || void 0, Math.max(0, Number.parseInt(query("offset"), 10) || 0), parseFilters(query)));
package/locale/en.json CHANGED
@@ -26,9 +26,6 @@
26
26
  "book.converted": "converted",
27
27
  "book.onShelf": "On your shelf",
28
28
  "book.save": "Save {format}",
29
- "shelf.title": "My books",
30
- "shelf.empty": "Nothing yet. Find a book or novel in Discover and download it.",
31
- "shelf.usedOf": "{used} of {cap}",
32
29
  "shelf.removed": "Removed to save space; download it again any time.",
33
30
  "shelf.again": "Download again",
34
31
  "shelf.delete": "Delete",
@@ -136,7 +133,7 @@
136
133
  "rooms.closeQuestion": "Close this room?",
137
134
  "rooms.closeQuestionBusy": "{names} still in. Close?",
138
135
  "start.library": "Library",
139
- "start.libraryEmpty": "Nothing in the library yet. Find a show in Discover and save it, or ask the assistant.",
136
+ "start.libraryEmpty": "Nothing in the library yet. Find a show or book in Discover and save it, or ask the assistant.",
140
137
  "library.episodes.one": "{n} episode",
141
138
  "library.episodes.other": "{n} episodes",
142
139
  "library.cachedOf": "cached {n} of {total}",
@@ -180,6 +177,12 @@
180
177
  "library.episodesToggle": "Episodes",
181
178
  "library.playFrom": "Watch from this episode",
182
179
  "library.free": "{size} free",
180
+ "library.booksUsed": "Books {used}",
181
+ "library.booksUsedOf": "Books {used} of {cap}",
182
+ "type.show": "Show",
183
+ "type.video": "Video",
184
+ "type.audio": "Audio",
185
+ "type.book": "Book",
183
186
  "action.cancel": "Cancel",
184
187
  "action.delete": "Delete",
185
188
  "action.save": "Save",
package/locale/fr.json CHANGED
@@ -26,9 +26,6 @@
26
26
  "book.converted": "converti",
27
27
  "book.onShelf": "Dans votre bibliothèque",
28
28
  "book.save": "Enregistrer en {format}",
29
- "shelf.title": "Mes livres",
30
- "shelf.empty": "Rien pour l’instant. Trouvez un livre ou un roman dans Découvrir et téléchargez-le.",
31
- "shelf.usedOf": "{used} sur {cap}",
32
29
  "shelf.removed": "Retiré pour libérer de l’espace ; vous pouvez le retélécharger à tout moment.",
33
30
  "shelf.again": "Retélécharger",
34
31
  "shelf.delete": "Supprimer",
@@ -136,7 +133,7 @@
136
133
  "rooms.closeQuestion": "Fermer ce salon ?",
137
134
  "rooms.closeQuestionBusy": "{names} y sont encore. Fermer ?",
138
135
  "start.library": "Collection",
139
- "start.libraryEmpty": "La collection est vide. Trouvez une série dans Découvrir et ajoutez-la, ou demandez à l’assistant.",
136
+ "start.libraryEmpty": "La collection est vide. Trouvez une série ou un livre dans Découvrir et ajoutez-le, ou demandez à l’assistant.",
140
137
  "library.episodes.one": "{n} épisode",
141
138
  "library.episodes.other": "{n} épisodes",
142
139
  "library.cachedOf": "{n} sur {total} en cache",
@@ -180,6 +177,12 @@
180
177
  "library.episodesToggle": "Épisodes",
181
178
  "library.playFrom": "Regarder à partir de cet épisode",
182
179
  "library.free": "{size} libres",
180
+ "library.booksUsed": "Livres {used}",
181
+ "library.booksUsedOf": "Livres {used} sur {cap}",
182
+ "type.show": "Série",
183
+ "type.video": "Vidéo",
184
+ "type.audio": "Audio",
185
+ "type.book": "Livre",
183
186
  "action.cancel": "Annuler",
184
187
  "action.delete": "Supprimer",
185
188
  "action.save": "Enregistrer",
package/locale/zh.json CHANGED
@@ -26,9 +26,6 @@
26
26
  "book.converted": "转换",
27
27
  "book.onShelf": "已在书架",
28
28
  "book.save": "保存 {format}",
29
- "shelf.title": "我的书",
30
- "shelf.empty": "还没有书。在「发现」里找本书或小说下载吧。",
31
- "shelf.usedOf": "已用 {used},共 {cap}",
32
29
  "shelf.removed": "为了省空间已删掉文件,随时可以再下载。",
33
30
  "shelf.again": "重新下载",
34
31
  "shelf.delete": "删除",
@@ -136,7 +133,7 @@
136
133
  "rooms.closeQuestion": "关闭这个房间?",
137
134
  "rooms.closeQuestionBusy": "{names} 还在里面,关闭?",
138
135
  "start.library": "片库",
139
- "start.libraryEmpty": "片库还是空的。可以去「发现」找一部存进来,或者让助手准备。",
136
+ "start.libraryEmpty": "片库还是空的。可以去「发现」找一部剧或一本书存进来,或者让助手准备。",
140
137
  "library.episodes.one": "{n} 集",
141
138
  "library.episodes.other": "{n} 集",
142
139
  "library.cachedOf": "已缓存 {n}/{total} 集",
@@ -180,6 +177,12 @@
180
177
  "library.episodesToggle": "剧集",
181
178
  "library.playFrom": "从这一集开始看",
182
179
  "library.free": "剩余 {size}",
180
+ "library.booksUsed": "书 {used}",
181
+ "library.booksUsedOf": "书 {used} / {cap}",
182
+ "type.show": "剧集",
183
+ "type.video": "视频",
184
+ "type.audio": "有声书",
185
+ "type.book": "书籍",
183
186
  "action.cancel": "取消",
184
187
  "action.delete": "删除",
185
188
  "action.save": "保存",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soffits/dsh-media-hub",
3
- "version": "0.10.2",
3
+ "version": "0.11.1",
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",
package/web/books-view.js CHANGED
@@ -134,48 +134,46 @@ export function BookCard({ t, source, result }) {
134
134
  h('button', { type: 'button', className: 'vsync-btn vsync-primary', onClick: download }, h(Icon.Download, { size: 14 }), offered.length > 1 ? t('book.download') : fill(t('book.downloadAs'), { format: chosen.toUpperCase() })))))))
135
135
  }
136
136
 
137
- /** My books: what the signed-in person downloaded, to save again, fetch again or delete. */
138
- export function ShelfSection({ t }) {
137
+ /** What the signed-in person downloaded: the shelf as the Host answers it, and the one action on an entry (remove, fetch again). */
138
+ export function useShelf() {
139
139
  const changes = React.useContext(Changes)
140
140
  const [state, setState] = React.useState(null)
141
- const [confirm, setConfirm] = React.useState(null)
142
141
  const load = React.useCallback(async () => {
143
142
  const answer = await shelf()
144
143
  setState(answer)
145
144
  return answer
146
145
  }, [])
147
146
  React.useEffect(() => { load() }, [load, changes.shelf])
148
-
149
147
  const act = async (path, entry) => {
150
- setConfirm(null)
151
148
  await shelf(path, { entry: entry.entry })
152
149
  forgetShelf()
153
150
  await load()
154
151
  }
152
+ return { state, act }
153
+ }
155
154
 
156
- if (state === null) return null
157
- if (state.error) return h('section', { className: 'vsync-section' }, h('h2', null, t('shelf.title')), h('p', { className: 'vsync-error', role: 'alert' }, state.error))
158
- return h('section', { className: 'vsync-section vsync-shelf' },
159
- h('div', { className: 'vsync-sectionHead' },
160
- h('h2', null, t('shelf.title')),
161
- h('span', { className: 'vsync-note' }, state.capBytes > 0 ? fill(t('shelf.usedOf'), { used: bytes(t, state.usedBytes), cap: bytes(t, state.capBytes) }) : bytes(t, state.usedBytes))),
162
- state.entries.length === 0
163
- ? h('p', { className: 'vsync-empty' }, t('shelf.empty'))
164
- : h('ul', { className: 'vsync-rows' }, state.entries.map(entry => h('li', { key: entry.entry, className: 'vsync-card vsync-book vsync-shelfEntry' },
165
- h(Cover, { result: { ...entry, media: 'book' }, small: true }),
166
- h('div', { className: 'vsync-cardBody' },
167
- h('div', { className: 'vsync-cardHead' }, h('span', { className: 'vsync-rowTitle' }, entry.title || entry.id)),
168
- h('span', { className: 'vsync-rowMeta' }, [entry.author, entry.format.toUpperCase(), entry.bytes ? bytes(t, entry.bytes) : null, entry.converted ? t('book.converted') : null].filter(Boolean).map((part, n) => h('span', { key: n }, part))),
169
- entry.state === 'failed' && h('span', { className: 'vsync-error', role: 'alert' }, entry.error),
170
- entry.state === 'removed' && h('span', { className: 'vsync-note' }, t('shelf.removed')),
171
- h('div', { className: 'vsync-cardFoot' },
172
- h('span', { className: 'vsync-actions' },
173
- h(ChatButton, { t, onClick: () => startChat(t, entry, entry.source) }),
174
- confirm === entry.entry
175
- ? h(Confirm, { t, danger: true, question: t('shelf.deleteQuestion'), confirmLabel: t('shelf.delete'), onCancel: () => setConfirm(null), onConfirm: () => act('/remove', entry) })
176
- : h(React.Fragment, null,
177
- h('button', { type: 'button', className: 'vsync-btn', onClick: () => setConfirm(entry.entry) }, t('shelf.delete')),
178
- entry.state === 'fetching' && h('span', { className: 'vsync-pending', role: 'status' }, h(Spinner), t('book.fetching')),
179
- (entry.state === 'failed' || entry.state === 'removed') && h('button', { type: 'button', className: 'vsync-btn vsync-primary', onClick: () => act('/retry', entry) }, t('shelf.again')),
180
- entry.state === 'ready' && h(SaveLink, { t, entry })))))))))
155
+ /** One book of the shelf, as a card in the library: to save again, fetch again or delete. */
156
+ export function ShelfEntry({ t, entry, onAct }) {
157
+ const [confirming, setConfirming] = React.useState(false)
158
+ const act = async (path) => {
159
+ setConfirming(false)
160
+ await onAct(path, entry)
161
+ }
162
+ return h('li', { className: 'vsync-card vsync-book vsync-shelfEntry' },
163
+ h(Cover, { result: { ...entry, media: 'book' }, small: true }),
164
+ h('div', { className: 'vsync-cardBody' },
165
+ h('div', { className: 'vsync-cardHead' }, h('span', { className: 'vsync-rowTitle' }, entry.title || entry.id), h('span', { className: 'vsync-badge' }, t('type.book'))),
166
+ h('span', { className: 'vsync-rowMeta' }, [entry.author, entry.format.toUpperCase(), entry.bytes ? bytes(t, entry.bytes) : null, entry.converted ? t('book.converted') : null].filter(Boolean).map((part, n) => h('span', { key: n }, part))),
167
+ entry.state === 'failed' && h('span', { className: 'vsync-error', role: 'alert' }, entry.error),
168
+ entry.state === 'removed' && h('span', { className: 'vsync-note' }, t('shelf.removed')),
169
+ h('div', { className: 'vsync-cardFoot' },
170
+ h('span', { className: 'vsync-actions' },
171
+ h(ChatButton, { t, onClick: () => startChat(t, entry, entry.source) }),
172
+ confirming
173
+ ? h(Confirm, { t, danger: true, question: t('shelf.deleteQuestion'), confirmLabel: t('shelf.delete'), onCancel: () => setConfirming(false), onConfirm: () => act('/remove') })
174
+ : h(React.Fragment, null,
175
+ h('button', { type: 'button', className: 'vsync-btn', onClick: () => setConfirming(true) }, t('shelf.delete')),
176
+ entry.state === 'fetching' && h('span', { className: 'vsync-pending', role: 'status' }, h(Spinner), t('book.fetching')),
177
+ (entry.state === 'failed' || entry.state === 'removed') && h('button', { type: 'button', className: 'vsync-btn vsync-primary', onClick: () => act('/retry') }, t('shelf.again')),
178
+ entry.state === 'ready' && h(SaveLink, { t, entry }))))))
181
179
  }
@@ -3,6 +3,7 @@
3
3
  * watch state; starting or continuing a room; renaming, keeping and
4
4
  * deleting a show or one episode. Deleting asks first, in place.
5
5
  */
6
+ import { ShelfEntry, useShelf } from './books-view.js'
6
7
  import { Picture, WorkDetails } from './details.js'
7
8
  import { hasEpisodes, stoppedText } from './format.js'
8
9
  import { Confirm, DAY_MS, EPISODE_BYTES, Icon, Menu, React, api, asPersonPaying, bytes, clock, day, displayName, fill, h, plural, post, query, watchMark } from './ui.js'
@@ -208,7 +209,9 @@ function ShowRow({ t, show, days, onOpen, onChanged, onOpenWork }) {
208
209
  if (!answer.error) setMode('idle')
209
210
  },
210
211
  }, h('input', { className: 'vsync-field vsync-inline', value: name, autoFocus: true, 'aria-label': t('library.rename'), onChange: event => setName(event.target.value), onKeyDown: (event) => { if (event.key === 'Escape') { setMode('idle'); setName(show.name) } } }))
211
- : h('button', { type: 'button', className: 'vsync-rowTitle vsync-titleButton', onClick: () => setOpen(!open) }, show.kind === 'file' ? titleOf(show.name) : show.name),
212
+ : h('span', { className: 'vsync-cardHead' },
213
+ h('button', { type: 'button', className: 'vsync-rowTitle vsync-titleButton', onClick: () => setOpen(!open) }, show.kind === 'file' ? titleOf(show.name) : show.name),
214
+ h('span', { className: 'vsync-badge' }, t(show.media === 'audio' ? 'type.audio' : show.kind === 'file' ? 'type.video' : 'type.show'))),
212
215
  h('span', { className: 'vsync-rowMeta vsync-rowLead' }, lead.map((part, n) => h('span', { key: n }, part))),
213
216
  h('span', { className: 'vsync-rowMeta vsync-rowMuted' },
214
217
  rest.map((part, n) => h('span', { key: n }, part)),
@@ -221,15 +224,23 @@ function ShowRow({ t, show, days, onOpen, onChanged, onOpenWork }) {
221
224
  open && h(Episodes, { t, show, onStart: start, onChanged }))
222
225
  }
223
226
 
227
+ /** Everything the person keeps, in one list of cards, each marked with what it is: shows and videos from the library, then the books of their shelf. */
224
228
  export function LibrarySection({ t, library, onOpen, onChanged, onOpenWork }) {
225
229
  const shows = library?.shows ?? []
230
+ const { state: shelf, act } = useShelf()
231
+ const books = shelf?.entries ?? []
232
+ const loaded = library !== null && shelf !== null
226
233
  return h('section', { className: 'vsync-section', 'aria-labelledby': 'vsync-library' },
227
234
  h('div', { className: 'vsync-sectionHead' },
228
235
  h('h2', { id: 'vsync-library' }, t('start.library')),
229
- library && h('span', { className: 'vsync-sectionMeta' }, [
236
+ h('span', { className: 'vsync-sectionMeta' }, [
230
237
  shows.length > 0 && bytes(t, library.total),
231
- library.free !== null && fill(t('library.free'), { size: bytes(t, library.free) }),
238
+ books.length > 0 && fill(t(shelf.capBytes > 0 ? 'library.booksUsedOf' : 'library.booksUsed'), { used: bytes(t, shelf.usedBytes), cap: bytes(t, shelf.capBytes) }),
239
+ library?.free != null && fill(t('library.free'), { size: bytes(t, library.free) }),
232
240
  ].filter(Boolean).join(' · '))),
233
- library && shows.length === 0 && h('p', { className: 'vsync-empty' }, t('start.libraryEmpty')),
234
- h('ul', { className: 'vsync-rows' }, shows.map(show => h(ShowRow, { key: show.path, t, show, days: library.autoDeleteDays, onOpen, onChanged, onOpenWork }))))
241
+ shelf?.error && h('p', { className: 'vsync-error', role: 'alert' }, shelf.error),
242
+ loaded && shows.length === 0 && books.length === 0 && h('p', { className: 'vsync-empty' }, t('start.libraryEmpty')),
243
+ h('ul', { className: 'vsync-rows' },
244
+ shows.map(show => h(ShowRow, { key: show.path, t, show, days: library.autoDeleteDays, onOpen, onChanged, onOpenWork })),
245
+ books.map(entry => h(ShelfEntry, { key: entry.entry, t, entry, onAct: act }))))
235
246
  }
package/web/page.js CHANGED
@@ -3,7 +3,6 @@
3
3
  * room. client.js renders `Page` once this module has loaded. The tab, and
4
4
  * under Discover the source and category, live in the URL (web/nav.js).
5
5
  */
6
- import { ShelfSection } from './books-view.js'
7
6
  import { DiscoverView } from './discover-view.js'
8
7
  import { LibrarySection } from './library-view.js'
9
8
  import { clearNav, readNav, TABS, writeNav } from './nav.js'
@@ -69,8 +68,7 @@ function Home({ t, nav, go, onOpen, rooms, library, load }) {
69
68
  nav.tab === 'watching' && h('div', { id: 'vsync-panel-watching', role: 'tabpanel', 'aria-labelledby': 'vsync-tab-watching' },
70
69
  h(WatchingTab, { t, rooms, library, onOpen, onChanged: load, onGo: tab => go({ tab }), onOpenWork: (source, work) => go({ tab: 'discover', source, kind: work.kind ?? null, work: work.id }) })),
71
70
  nav.tab === 'library' && h('div', { id: 'vsync-panel-library', role: 'tabpanel', 'aria-labelledby': 'vsync-tab-library' },
72
- h(LibrarySection, { t, library, onOpen, onChanged: load, onOpenWork: (source, work) => go({ tab: 'discover', source, kind: work.kind ?? null, work: work.id }) }),
73
- h(ShelfSection, { t })),
71
+ h(LibrarySection, { t, library, onOpen, onChanged: load, onOpenWork: (source, work) => go({ tab: 'discover', source, kind: work.kind ?? null, work: work.id }) })),
74
72
  visitedDiscover && h('div', { id: 'vsync-panel-discover', role: 'tabpanel', 'aria-labelledby': 'vsync-tab-discover', hidden: nav.tab !== 'discover' },
75
73
  h(DiscoverView, { t, nav, onNav: go, onOpen, onSaved: load, onBack: () => (history.state?.[PUSHED] ? history.back() : go({ work: null }, { replace: true })) }))))
76
74
  }
package/web/panel.css CHANGED
@@ -9,7 +9,7 @@
9
9
  .vsync-note{margin:4px 0 0;color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:20px}
10
10
  .vsync-section{margin-bottom:28px}
11
11
  .vsync-section h2{margin:0 0 8px;color:var(--dsw-alias-label-secondary);font-size:13px;font-weight:500;line-height:20px}
12
- .vsync-rows{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px}
12
+ .vsync-rows{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:8px}
13
13
  .vsync-row{box-sizing:border-box;display:flex;align-items:center;gap:12px;width:100%;padding:8px;border-radius:12px}
14
14
  @media (hover:hover){.vsync-row:hover{background:var(--dsw-alias-interactive-bg-hover)}}
15
15
  .vsync-glyph{flex:none;width:16px;height:16px;color:var(--dsw-alias-label-tertiary)}
@@ -144,6 +144,8 @@
144
144
  .vsync-sectionHead h2{margin:0}
145
145
  .vsync-sectionMeta{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:20px;font-variant-numeric:tabular-nums}
146
146
  .vsync-show{list-style:none}
147
+ .vsync-show,.vsync-card{background:color-mix(in srgb,var(--dsw-alias-interactive-bg-hover) 45%,transparent)}
148
+ .vsync-show{box-sizing:border-box;padding:2px;border-radius:12px;box-shadow:inset 0 0 0 var(--dsh-hairline-width,.5px) var(--dsw-alias-border-l3)}
147
149
  .vsync-expand{flex:none;width:20px;height:28px;margin-right:-6px;padding:0;display:inline-flex;align-items:center;justify-content:center;border:none;border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-label-tertiary);cursor:pointer}
148
150
  .vsync-expand svg{width:12px;height:12px}
149
151
  .vsync-poster{flex:none;box-sizing:border-box;width:64px;height:36px;border-radius:6px;object-fit:cover;background:var(--dsw-alias-bg-layer-2,var(--dsw-alias-interactive-bg-hover))}