@soffits/dsh-media-hub 0.11.1 → 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 +4 -0
- package/package.json +1 -1
- package/web/books-view.js +20 -19
- package/web/library-card.js +42 -0
- package/web/library-view.js +27 -29
- package/web/panel.css +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
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
|
+
|
|
3
7
|
## 0.11.1
|
|
4
8
|
|
|
5
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.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soffits/dsh-media-hub",
|
|
3
|
-
"version": "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 {
|
|
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
|
|
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
|
-
|
|
163
|
-
h(
|
|
164
|
-
h('
|
|
165
|
-
h(
|
|
166
|
-
h('span', { className: 'vsync-
|
|
167
|
-
entry.state === 'failed' && h('
|
|
168
|
-
entry.state === '
|
|
169
|
-
h('
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
+
}
|
package/web/library-view.js
CHANGED
|
@@ -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
|
-
|
|
197
|
-
h('
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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}
|