@soffits/dsh-media-hub 0.11.0 → 0.12.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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.12.0
4
+
5
+ - A show and a book look the same in the Library. Every item is one card: the same cover slot, a title with its type, one line of facts (a show's rating, status and progress; a book's author, format and size), tags, and the actions in the same place, with Delete under the … menu for books as it is for shows.
6
+
7
+ ## 0.11.1
8
+
9
+ - 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.
10
+
3
11
  ## 0.11.0
4
12
 
5
13
  - 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.
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soffits/dsh-media-hub",
3
- "version": "0.11.0",
3
+ "version": "0.12.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",
package/web/books-view.js CHANGED
@@ -12,7 +12,8 @@
12
12
  */
13
13
  import { Cover } from './details.js'
14
14
  import { offeredFormats } from './formats.js'
15
- import { Changes, Confirm, Icon, Spinner, bytes, canChat, chatAbout, fill, h, languageName, React, shelf, shelfUrl } from './ui.js'
15
+ import { LibraryCard, LibraryCover } from './library-card.js'
16
+ import { Changes, Confirm, Icon, Menu, Spinner, bytes, canChat, chatAbout, fill, h, languageName, React, shelf, shelfUrl } from './ui.js'
16
17
 
17
18
 
18
19
  export const FORMATS = ['', 'epub', 'pdf', 'txt', 'azw3', 'mobi']
@@ -152,28 +153,28 @@ export function useShelf() {
152
153
  return { state, act }
153
154
  }
154
155
 
155
- /** One book of the shelf, as a card in the library: to save again, fetch again or delete. */
156
+ /** One book of the shelf, as a library card like any other item: to save again, fetch again or delete. */
156
157
  export function ShelfEntry({ t, entry, onAct }) {
157
158
  const [confirming, setConfirming] = React.useState(false)
158
159
  const act = async (path) => {
159
160
  setConfirming(false)
160
161
  await onAct(path, entry)
161
162
  }
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 }))))))
163
+ const actions = confirming
164
+ ? h(Confirm, { t, danger: true, question: t('shelf.deleteQuestion'), confirmLabel: t('shelf.delete'), onCancel: () => setConfirming(false), onConfirm: () => act('/remove') })
165
+ : h('span', { className: 'vsync-actions' },
166
+ h(ChatButton, { t, onClick: () => startChat(t, entry, entry.source) }),
167
+ entry.state === 'fetching' && h('span', { className: 'vsync-pending', role: 'status' }, h(Spinner), t('book.fetching')),
168
+ (entry.state === 'failed' || entry.state === 'removed') && h('button', { type: 'button', className: 'vsync-btn vsync-primary', onClick: () => act('/retry') }, t('shelf.again')),
169
+ entry.state === 'ready' && h(SaveLink, { t, entry }),
170
+ h(Menu, { label: t('library.more'), items: [{ label: t('shelf.delete'), danger: true, onSelect: () => setConfirming(true) }] }))
171
+ return h(LibraryCard, {
172
+ cover: h(LibraryCover, { pictures: [entry.cover], icon: h(Icon.Book, { size: 18 }) }),
173
+ title: h('span', { className: 'vsync-rowTitle' }, entry.title || entry.id),
174
+ badge: t('type.book'),
175
+ lead: [entry.author, entry.format.toUpperCase(), entry.bytes ? bytes(t, entry.bytes) : null].filter(Boolean),
176
+ rest: [entry.converted ? t('book.converted') : null, entry.state === 'removed' ? t('shelf.removed') : null].filter(Boolean),
177
+ aside: entry.state === 'failed' && h('span', { className: 'vsync-error', role: 'alert' }, entry.error),
178
+ actions,
179
+ })
179
180
  }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * The one card every library item is shown in, whatever it is: a cover, a title with its type, a line of facts, a
3
+ * muted line, tags, what to show beside them, the actions, and room below for what opens out (episodes, details).
4
+ * Shows and books differ only in what they put in these places.
5
+ */
6
+ import { Icon, React, h } from './ui.js'
7
+ import { Picture } from './details.js'
8
+
9
+ /** The cover slot: the item's own picture when it has one, else a quiet icon, in the same size for every kind. */
10
+ export function LibraryCover({ pictures, icon }) {
11
+ return h(Picture, { pictures, className: 'vsync-poster vsync-libCover', emptyClassName: 'vsync-poster vsync-libCover vsync-posterEmpty', icon })
12
+ }
13
+
14
+ /**
15
+ * @param {object} props
16
+ * @param {React.ReactNode} props.cover - a LibraryCover
17
+ * @param {React.ReactNode} props.title - the title (a button, or a form while renaming)
18
+ * @param {string} props.badge - what kind of item it is, in words
19
+ * @param {string[]} props.lead - the short line of facts
20
+ * @param {React.ReactNode[]} [props.rest] - the muted line
21
+ * @param {string[]} [props.tags]
22
+ * @param {React.ReactNode} [props.aside] - under the tags: a details toggle, an error
23
+ * @param {React.ReactNode} props.actions - the buttons, or a confirmation in their place
24
+ * @param {{ open: boolean, label: string, onToggle: () => void } | null} [props.expand] - the chevron of an item that opens out
25
+ * @param {React.ReactNode} [props.below] - what opens out
26
+ */
27
+ export function LibraryCard({ cover, title, badge, lead, rest = [], tags = [], aside = null, actions, expand = null, below = null }) {
28
+ return h('li', { className: 'vsync-show' },
29
+ h('div', { className: 'vsync-row' },
30
+ expand
31
+ ? h('button', { type: 'button', className: 'vsync-expand', 'aria-expanded': String(expand.open), 'aria-label': expand.label, onClick: expand.onToggle }, h(Icon.Chevron, { open: expand.open }))
32
+ : h('span', { className: 'vsync-expand', 'aria-hidden': true }),
33
+ cover,
34
+ h('span', { className: 'vsync-rowText' },
35
+ h('span', { className: 'vsync-cardHead' }, title, h('span', { className: 'vsync-badge' }, badge)),
36
+ h('span', { className: 'vsync-rowMeta vsync-rowLead' }, lead.map((part, n) => h('span', { key: n }, part))),
37
+ rest.length > 0 && h('span', { className: 'vsync-rowMeta vsync-rowMuted' }, rest.map((part, n) => h('span', { key: n }, part))),
38
+ tags.length > 0 && h('span', { className: 'vsync-tags' }, tags.map(tag => h('span', { key: tag, className: 'vsync-tag' }, tag))),
39
+ aside),
40
+ actions),
41
+ below)
42
+ }
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { ShelfEntry, useShelf } from './books-view.js'
7
7
  import { Picture, WorkDetails } from './details.js'
8
+ import { LibraryCard, LibraryCover } from './library-card.js'
8
9
  import { hasEpisodes, stoppedText } from './format.js'
9
10
  import { Confirm, DAY_MS, EPISODE_BYTES, Icon, Menu, React, api, asPersonPaying, bytes, clock, day, displayName, fill, h, plural, post, query, watchMark } from './ui.js'
10
11
 
@@ -193,35 +194,32 @@ function ShowRow({ t, show, days, onOpen, onChanged, onOpenWork }) {
193
194
  }))
194
195
  }
195
196
 
196
- return h('li', { className: 'vsync-show' },
197
- h('div', { className: 'vsync-row' },
198
- hasEpisodes(episodeCount(show))
199
- ? h('button', { type: 'button', className: 'vsync-expand', 'aria-expanded': String(open), 'aria-label': t('library.episodesToggle'), onClick: () => setOpen(!open) }, h(Icon.Chevron, { open }))
200
- : h('span', { className: 'vsync-expand', 'aria-hidden': true }),
201
- h(Poster, { show }),
202
- h('span', { className: 'vsync-rowText' },
203
- mode === 'rename'
204
- ? h('form', {
205
- id: `vsync-rename-${show.path}`,
206
- onSubmit: async (event) => {
207
- event.preventDefault()
208
- const answer = await act(async () => post('library/rename', await asViewer(t, { path: show.path, name })))
209
- if (!answer.error) setMode('idle')
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) } } }))
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'))),
215
- h('span', { className: 'vsync-rowMeta vsync-rowLead' }, lead.map((part, n) => h('span', { key: n }, part))),
216
- h('span', { className: 'vsync-rowMeta vsync-rowMuted' },
217
- rest.map((part, n) => h('span', { key: n }, part)),
218
- show.deletesAt !== null && h('span', { key: 'countdown' }, h(Countdown, { t, show, days, onChanged }))),
219
- show.work?.tags?.length > 0 && h('span', { className: 'vsync-tags' }, show.work.tags.slice(0, 5).map(tag => h('span', { key: tag, className: 'vsync-tag' }, tag))),
220
- show.work && h('button', { type: 'button', className: 'vsync-metaButton vsync-detailsToggle', 'aria-expanded': String(details), onClick: () => setDetails(!details) }, h(Icon.Chevron, { size: 12, open: details }), ' ', t(details ? 'search.hideDetails' : 'search.details')),
221
- error && h('span', { className: 'vsync-error', role: 'alert' }, error)),
222
- actions),
223
- details && show.work && h('div', { className: 'vsync-showDetails' }, h(WorkDetails, { t, info: show.work, source: show.source.source, onFocus: work => onOpenWork(show.source.source, work) })),
224
- open && h(Episodes, { t, show, onStart: start, onChanged }))
197
+ const title = mode === 'rename'
198
+ ? h('form', {
199
+ id: `vsync-rename-${show.path}`,
200
+ onSubmit: async (event) => {
201
+ event.preventDefault()
202
+ const answer = await act(async () => post('library/rename', await asViewer(t, { path: show.path, name })))
203
+ if (!answer.error) setMode('idle')
204
+ },
205
+ }, 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) } } }))
206
+ : h('button', { type: 'button', className: 'vsync-rowTitle vsync-titleButton', onClick: () => setOpen(!open) }, show.kind === 'file' ? titleOf(show.name) : show.name)
207
+ return h(LibraryCard, {
208
+ cover: h(LibraryCover, { pictures: [show.work?.cover, show.frame], icon: show.media === 'audio' ? h(Icon.Audio, { size: 18 }) : h(Icon.Film, { size: 18 }) }),
209
+ title,
210
+ badge: t(show.media === 'audio' ? 'type.audio' : show.kind === 'file' ? 'type.video' : 'type.show'),
211
+ lead,
212
+ rest: [...rest, show.deletesAt !== null && h(Countdown, { key: 'countdown', t, show, days, onChanged })].filter(Boolean),
213
+ tags: show.work?.tags?.slice(0, 5) ?? [],
214
+ aside: h(React.Fragment, null,
215
+ show.work && h('button', { type: 'button', className: 'vsync-metaButton vsync-detailsToggle', 'aria-expanded': String(details), onClick: () => setDetails(!details) }, h(Icon.Chevron, { size: 12, open: details }), ' ', t(details ? 'search.hideDetails' : 'search.details')),
216
+ error && h('span', { className: 'vsync-error', role: 'alert' }, error)),
217
+ actions,
218
+ expand: hasEpisodes(episodeCount(show)) ? { open, label: t('library.episodesToggle'), onToggle: () => setOpen(!open) } : null,
219
+ below: h(React.Fragment, null,
220
+ details && show.work && h('div', { className: 'vsync-showDetails' }, h(WorkDetails, { t, info: show.work, source: show.source.source, onFocus: work => onOpenWork(show.source.source, work) })),
221
+ open && h(Episodes, { t, show, onStart: start, onChanged })),
222
+ })
225
223
  }
226
224
 
227
225
  /** 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. */
package/web/panel.css CHANGED
@@ -200,6 +200,8 @@
200
200
  @media (width<=767px){.vsync-segment{display:flex}.vsync-seg{flex:1 0 auto}}
201
201
  /* Library details, room preview, avatars, room side tabs */
202
202
  .vsync-posterCover{width:36px;height:48px;object-fit:cover;border-radius:6px}
203
+ .vsync-poster.vsync-libCover{width:48px;height:64px;object-fit:cover;border-radius:6px}
204
+ .vsync-posterEmpty.vsync-libCover{background:var(--dsw-alias-interactive-bg-hover)}
203
205
  .vsync-showDetails{padding:4px 8px 12px 48px}
204
206
  .vsync-detailsToggle{align-self:flex-start}
205
207
  .vsync-preview{flex:none;width:96px;height:54px;border-radius:8px;object-fit:cover;background:var(--dsw-alias-interactive-bg-hover)}
@@ -247,8 +249,10 @@
247
249
  .vsync-row>.vsync-rowText{flex:1 1 0;min-width:0}
248
250
  .vsync-row>.vsync-actions,.vsync-row>.vsync-confirm{flex:1 1 100%;margin-left:0}
249
251
  .vsync-row>.vsync-actions .vsync-btn{flex:1;height:36px}
252
+ .vsync-row>.vsync-actions .vsync-ask{flex:0 0 40px;padding:0}
250
253
  .vsync-posterCover{width:56px;height:75px}
251
254
  .vsync-poster{width:96px;height:54px}
255
+ .vsync-poster.vsync-libCover{width:56px;height:75px}
252
256
  .vsync-preview{width:96px;height:54px}
253
257
  .vsync-showDetails{padding:4px 0 12px}
254
258
  .vsync-rowTitle{white-space:normal}