@soffits/dsh-media-hub 0.9.0 → 0.10.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 +5 -0
- package/README.md +2 -2
- package/dist/index.js +191 -59
- package/locale/en.json +7 -0
- package/locale/fr.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +1 -1
- package/web/discover-view.js +4 -1
- package/web/feed-view.js +89 -0
- package/web/page.js +3 -1
- package/web/panel.css +5 -0
- package/web/presence-view.js +3 -2
- package/web/ui.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.0
|
|
4
|
+
|
|
5
|
+
- Discover shows something before you search. Under the picked source and category it lists what the source itself puts forward (a source's rank lists and new arrivals, from the new optional `trending` verb of [docs/source-protocol.md](docs/source-protocol.md), asked for the kinds configured with `"trending": true`) and, when a `recommender` is set, *For you*: picks with the reason for each, narrowed to the source and category (the recommender now also gets `--source`, `--kind` and `--language`). Under *All sources* the picks are interleaved and each source's lists stay under its name. Link has neither.
|
|
6
|
+
- Both are dated local copies, rendered at once and asked again in the background when someone looks and the copy is about a day old (a failing source is left alone for an hour, the old copy stays), so the page never waits on a site. The Watching tab's picks use the same copies instead of waiting for the recommender.
|
|
7
|
+
- The default sources declare trending for Fanqie's dramas, audiobooks and novels and for bookfetch's ebooks. A source whose command lacks the verb just shows no lists.
|
|
3
8
|
## 0.9.0
|
|
4
9
|
|
|
5
10
|
- Points extras (`points` setting, [docs/points-protocol.md](docs/points-protocol.md)): with a points extension, the people it plays with pay points for starting a series that is new to the hub and for a binge night (starting to watch late at night, one ticket for the whole night). The page shows the price and their balance at that moment and buys on *Buy*; going on with a series, later seasons, films, single videos and rooms already playing stay free. Without an extension, or for anyone it doesn't play with, nothing changes.
|
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ The bundle adds two rows: `media-hub` (the page, shelves, rooms, media) and `med
|
|
|
30
30
|
|
|
31
31
|
## Use
|
|
32
32
|
|
|
33
|
-
- **From the page**: open **Media** in the sidebar (the `label` setting renames it). Three tabs: **Watching** (the default) lists the rooms opened to others, with who is in them and the episode, with copying a room's link or closing it, and the shows someone started, to continue; **Library** manages the shows and starts or continues one; **Discover** searches: pick a source (*All sources*, every configured one, or *Link* to paste the address of a video or playlist), then one of that source's categories, then search. The tab, source and category are in the page's URL (`?vs-tab=library`, `?vs-tab=discover&vs-source=<id>&vs-kind=<id>`), so a refresh and the back button keep them and a link can open a tab directly; the last source and category are remembered per browser.
|
|
33
|
+
- **From the page**: open **Media** in the sidebar (the `label` setting renames it). Three tabs: **Watching** (the default) lists the rooms opened to others, with who is in them and the episode, with copying a room's link or closing it, and the shows someone started, to continue; **Library** manages the shows and starts or continues one; **Discover** searches: pick a source (*All sources*, every configured one, or *Link* to paste the address of a video or playlist), then one of that source's categories, then search. Before any search it shows what the sources put forward for that category (their rank lists and new arrivals, from a source's `trending` verb) and, when a `recommender` is set, *For you*: picks with the reason for each. Both are kept as dated copies and refreshed in the background about daily, so the page never waits on a site; *All sources* merges the picks and lists each source's boards under its name; Link has neither. The tab, source and category are in the page's URL (`?vs-tab=library`, `?vs-tab=discover&vs-source=<id>&vs-kind=<id>`), so a refresh and the back button keep them and a link can open a tab directly; the last source and category are remembered per browser.
|
|
34
34
|
- **Watching**: a card at the top for the show someone is in now, or the one you watched last, over its blurred cover: who is in the room, where it stands, a strip of its episodes (watched, now, on disk), and joining them, or continuing alone, or *Watch together* to open it to others. Optional parts, each off until switched on in `presence`: *So far*, a recap without spoilers kept with the show; *How was it?*, one tap that writes a rating into the watch log for a show finished or removed lately; and *Picks*, works a recommender extension suggests, each with its reason. Steps suggested for a show (written through the tool's `annotate`) show on the card when [@soffits/dsh-ui-actions](https://github.com/soffits/dsh-ui-actions) is installed.
|
|
35
35
|
- **From the assistant**: `videosync` with `action: start` and `source: local` plus `path`, `source: link` plus `url` (and `quality`), or `source: <source id>` plus `id` (and `offline: true` to keep every episode), returns a link to send. `list` and `close` manage rooms, `library` lists the shows, `history` summarises the watch log (shows, episodes finished, where each viewer stopped, with whom, when).
|
|
36
36
|
|
|
@@ -67,7 +67,7 @@ The page follows DSH's language setting. It ships in English, French and Chinese
|
|
|
67
67
|
| `cookies` | `[]` | Signed-in accounts for sites, by host: a list of `{ hosts, hostsFile, accounts }`, hosts written as in `proxies`. Each account is `{ person, name, file, userAgent, share }`: `file` a Netscape cookies file of a signed-in session (kept fresh by whatever holds that session; the hub only reads it and gives yt-dlp a private copy per run), `userAgent` the User-Agent that session uses, `person` the owner's sign-in id (empty for the default account everyone without their own uses), `name` what the page shows, `share` whether others without an account of their own may use it. A lookup or download uses the account of the person asking, else the default, else a shared one; a room uses the account of whoever opened it. |
|
|
68
68
|
| `bookCacheGb` | `5` | Most disk (GB) downloaded books may use; past it the least recently used files go and stay on their shelves to fetch again. `0` is no limit. |
|
|
69
69
|
| `converter` | `ebook-convert` | Calibre's converter; when installed, books can be downloaded in formats their source lacks. Empty turns conversion off. |
|
|
70
|
-
| `sources` | `fanqie`, `bookfetch` | The sources: a list of `{ id, label, kinds: [{ id, label, media }], filters, command: [program, ...fixed arguments], env }`; `label` is the source's name in Discover's picker and each kind's `label` its category, each a string or `{ "<tag>": "text" }` like the sidebar's; left empty, the page uses its own words for that id (`source.name.<id>`, `kind.<id>` in `locale/`), else the id; `media` is `video`, `audio` or `book
|
|
70
|
+
| `sources` | `fanqie`, `bookfetch` | The sources: a list of `{ id, label, kinds: [{ id, label, media, trending }], filters, command: [program, ...fixed arguments], env }`; `label` is the source's name in Discover's picker and each kind's `label` its category, each a string or `{ "<tag>": "text" }` like the sidebar's; left empty, the page uses its own words for that id (`source.name.<id>`, `kind.<id>` in `locale/`), else the id; `media` is `video`, `audio` or `book`, `trending` (default false) says the command's `trending` verb answers for that kind; `filters` lists the search filters the command understands (`language`, `format`, `year`). The list replaces the default, so keep the default entries when adding one; an empty list turns sources off. See [docs/source-protocol.md](docs/source-protocol.md). |
|
|
71
71
|
|
|
72
72
|
The tools row takes `agentName` (shown as who opened the assistant's rooms) and `waitSeconds` (how long `start` waits for the first episode to be ready).
|
|
73
73
|
|
package/dist/index.js
CHANGED
|
@@ -10704,6 +10704,7 @@ var lastLine = (text3) => text3.trim().split("\n").filter(Boolean).pop() ?? "";
|
|
|
10704
10704
|
|
|
10705
10705
|
// src/sources/command.js
|
|
10706
10706
|
var SEARCH_LIMIT = 12;
|
|
10707
|
+
var TRENDING_LIMIT = 20;
|
|
10707
10708
|
var QUERY_TIMEOUT_MS = 6e4;
|
|
10708
10709
|
var COVER_TIMEOUT_MS = 3e4;
|
|
10709
10710
|
var ID = /^[^\s\0]{1,200}$/;
|
|
@@ -10771,6 +10772,28 @@ function parseSearch(document2, kinds) {
|
|
|
10771
10772
|
const kindIds = new Set(kinds.map((kind) => kind.id));
|
|
10772
10773
|
return document2.results.map((raw) => resultOf(raw, kindIds)).filter((result) => result !== null);
|
|
10773
10774
|
}
|
|
10775
|
+
var MAX_LISTS = 6;
|
|
10776
|
+
function labelOf(value) {
|
|
10777
|
+
if (typeof value === "string" && value.trim() !== "") return value.trim();
|
|
10778
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
10779
|
+
const entries = Object.entries(value).filter(([tag, words]) => typeof tag === "string" && typeof words === "string" && words.trim() !== "");
|
|
10780
|
+
if (entries.length > 0) return Object.fromEntries(entries.map(([tag, words]) => [tag, words.trim()]));
|
|
10781
|
+
}
|
|
10782
|
+
return null;
|
|
10783
|
+
}
|
|
10784
|
+
function parseTrending(document2, kinds, kind) {
|
|
10785
|
+
const kindIds = new Set(kinds.map((entry) => entry.id));
|
|
10786
|
+
const raw = Array.isArray(document2?.lists) ? document2.lists : Array.isArray(document2?.results) ? [{ id: "trending", results: document2.results }] : null;
|
|
10787
|
+
if (raw === null) throw sourceError2("source_failed", "the trending answer has no lists");
|
|
10788
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10789
|
+
return raw.slice(0, MAX_LISTS).flatMap((list, index) => {
|
|
10790
|
+
const results = Array.isArray(list?.results) ? list.results.map((item) => resultOf(item, kindIds)).filter((result) => result !== null && result.kind === kind) : [];
|
|
10791
|
+
const id = text(list?.id) || `list-${index + 1}`;
|
|
10792
|
+
if (results.length === 0 || seen.has(id)) return [];
|
|
10793
|
+
seen.add(id);
|
|
10794
|
+
return [{ id, label: labelOf(list?.label), results }];
|
|
10795
|
+
});
|
|
10796
|
+
}
|
|
10774
10797
|
function nextOffset(document2, offset = 0) {
|
|
10775
10798
|
return Number.isInteger(document2?.next) && document2.next > offset ? document2.next : null;
|
|
10776
10799
|
}
|
|
@@ -10850,6 +10873,11 @@ function createCommandSource(definition, { logger, cwd }) {
|
|
|
10850
10873
|
const document2 = await query(["search", "--kind", kind, "--limit", String(limit), ...paging, ...filterArgs(filters, understood), "--json", "--", q]);
|
|
10851
10874
|
return { results: parseSearch(document2, kinds).filter((result) => result.kind === kind), next: nextOffset(document2, offset) };
|
|
10852
10875
|
},
|
|
10876
|
+
/** What the site itself puts forward for a kind that declares `trending`: lists of works, in the site's order. */
|
|
10877
|
+
async trending(kind, { limit = TRENDING_LIMIT } = {}) {
|
|
10878
|
+
if (!kinds.some((entry) => entry.id === kind && entry.trending === true)) throw sourceError2("invalid", `${name2()} has no trending list for ${kind}`);
|
|
10879
|
+
return parseTrending(await query(["trending", "--kind", kind, "--limit", String(limit), "--json"]), kinds, kind);
|
|
10880
|
+
},
|
|
10853
10881
|
async info(id) {
|
|
10854
10882
|
if (!ID.test(String(id))) throw sourceError2("invalid", `not a ${name2()} id`);
|
|
10855
10883
|
return parseInfo(await query(["info", "--json", "--", String(id)]));
|
|
@@ -11938,7 +11966,8 @@ var SourceConfig = Schema.object({
|
|
|
11938
11966
|
kinds: Schema.array(Schema.object({
|
|
11939
11967
|
id: Schema.string().pattern(/^[a-z0-9][a-z0-9_-]{0,31}$/).description("What the command's search --kind takes."),
|
|
11940
11968
|
label: Label.default("").description("Name of the category chip: a string, or { <tag>: text } per language. Empty uses the page's own words for this kind id (kind.<id> in locale/), else the id."),
|
|
11941
|
-
media: Schema.union(MEDIA.map((media) => Schema.const(media))).default("video").description("What a work of this kind is: video or audio (episodes, watched or listened to together in a room) or book (one file, downloaded in a format).")
|
|
11969
|
+
media: Schema.union(MEDIA.map((media) => Schema.const(media))).default("video").description("What a work of this kind is: video or audio (episodes, watched or listened to together in a room) or book (one file, downloaded in a format)."),
|
|
11970
|
+
trending: Schema.boolean().default(false).description("Whether the command's trending verb answers for this kind (docs/source-protocol.md): its rank lists and new arrivals, shown on Discover before a search.")
|
|
11942
11971
|
})).description("What the source can search for; at least one."),
|
|
11943
11972
|
filters: Schema.array(Schema.union(FILTERS.map((filter) => Schema.const(filter)))).default([]).description("Search filters the command understands (docs/source-protocol.md). The hub filters the answers by language, format, year and size itself as well."),
|
|
11944
11973
|
command: Schema.array(Schema.string()).min(1).description("The command and its fixed arguments, one entry per word; the plugin adds the protocol verbs after them."),
|
|
@@ -11966,14 +11995,14 @@ var CookieRule = Schema.object({
|
|
|
11966
11995
|
var DEFAULT_SOURCES = Object.freeze([
|
|
11967
11996
|
{
|
|
11968
11997
|
id: "fanqie",
|
|
11969
|
-
kinds: [{ id: "drama", media: "video" }, { id: "audio", media: "audio" }, { id: "novel", media: "book" }],
|
|
11998
|
+
kinds: [{ id: "drama", media: "video", trending: true }, { id: "audio", media: "audio", trending: true }, { id: "novel", media: "book", trending: true }],
|
|
11970
11999
|
filters: [],
|
|
11971
12000
|
command: ["fanqie"],
|
|
11972
12001
|
env: {}
|
|
11973
12002
|
},
|
|
11974
12003
|
{
|
|
11975
12004
|
id: "bookfetch",
|
|
11976
|
-
kinds: [{ id: "ebook", media: "book" }, { id: "paper", media: "book" }],
|
|
12005
|
+
kinds: [{ id: "ebook", media: "book", trending: true }, { id: "paper", media: "book" }],
|
|
11977
12006
|
filters: ["language", "format", "year"],
|
|
11978
12007
|
command: ["bookfetch", "source"],
|
|
11979
12008
|
env: {}
|
|
@@ -12297,6 +12326,7 @@ function createHandler({ connection, service, settings = () => ({ label: "", pre
|
|
|
12297
12326
|
if (route === "GET settings") return sendJson(res, 200, settings());
|
|
12298
12327
|
if (route === "GET locales") return sendJson(res, 200, await (locales ??= readLocales(localeDir, logger)));
|
|
12299
12328
|
if (route === "GET sources") return sendJson(res, 200, { sources: await hub.sources() });
|
|
12329
|
+
if (route === "GET trending") return sendJson(res, 200, await hub.trending(query("source"), query("kind")));
|
|
12300
12330
|
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)));
|
|
12301
12331
|
}
|
|
12302
12332
|
return sendText(res, 404, "Not found.");
|
|
@@ -14008,53 +14038,34 @@ function parsePicks(document2, hasSource, limit = PICKS_LIMIT) {
|
|
|
14008
14038
|
const out = [];
|
|
14009
14039
|
const seen = /* @__PURE__ */ new Set();
|
|
14010
14040
|
for (const pick5 of document2.picks) {
|
|
14011
|
-
const
|
|
14041
|
+
const raw = pick5?.work;
|
|
14012
14042
|
const why = typeof pick5?.why === "string" ? pick5.why.trim().slice(0, MAX_WHY_CHARS) : "";
|
|
14013
|
-
if (typeof
|
|
14014
|
-
const
|
|
14043
|
+
if (typeof raw?.source !== "string" || !hasSource(raw.source) || why === "") continue;
|
|
14044
|
+
const work = resultOf(raw, null);
|
|
14045
|
+
if (work === null || work.title === "") continue;
|
|
14046
|
+
const key = `${raw.source}\0${work.id}`;
|
|
14015
14047
|
if (seen.has(key)) continue;
|
|
14016
14048
|
seen.add(key);
|
|
14017
|
-
out.push({
|
|
14018
|
-
work: {
|
|
14019
|
-
source: work.source,
|
|
14020
|
-
id: work.id,
|
|
14021
|
-
title: work.title.slice(0, 200),
|
|
14022
|
-
kind: typeof work.kind === "string" ? work.kind : null,
|
|
14023
|
-
year: Number.isInteger(work.year) ? work.year : null,
|
|
14024
|
-
score: Number.isFinite(work.score) ? work.score : null,
|
|
14025
|
-
scoreLabel: typeof work.scoreLabel === "string" ? work.scoreLabel.slice(0, 40) : "",
|
|
14026
|
-
cover: typeof work.cover === "string" ? work.cover : null,
|
|
14027
|
-
url: typeof work.url === "string" ? work.url : null
|
|
14028
|
-
},
|
|
14029
|
-
why
|
|
14030
|
-
});
|
|
14049
|
+
out.push({ work: { ...work, source: raw.source, scoreLabel: typeof raw.scoreLabel === "string" ? raw.scoreLabel.slice(0, 40) : "" }, why });
|
|
14031
14050
|
if (out.length >= limit) break;
|
|
14032
14051
|
}
|
|
14033
14052
|
return out;
|
|
14034
14053
|
}
|
|
14035
|
-
function
|
|
14036
|
-
const
|
|
14037
|
-
|
|
14038
|
-
|
|
14039
|
-
|
|
14040
|
-
|
|
14041
|
-
|
|
14042
|
-
|
|
14043
|
-
|
|
14044
|
-
|
|
14045
|
-
|
|
14046
|
-
|
|
14047
|
-
|
|
14048
|
-
|
|
14049
|
-
|
|
14050
|
-
const picks = await ask(person).catch((error) => {
|
|
14051
|
-
logger.warn("the recommender gave no picks: %s", error.message);
|
|
14052
|
-
return [];
|
|
14053
|
-
});
|
|
14054
|
-
cached.set(person.key, { at: now(), picks });
|
|
14055
|
-
return picks;
|
|
14056
|
-
}
|
|
14057
|
-
};
|
|
14054
|
+
async function recommend({ command, env = {}, cwd, hasSource }, { person, source, kind, language, limit = PICKS_LIMIT }) {
|
|
14055
|
+
const argv = [
|
|
14056
|
+
...command,
|
|
14057
|
+
"recommend",
|
|
14058
|
+
"--json",
|
|
14059
|
+
"--limit",
|
|
14060
|
+
String(limit),
|
|
14061
|
+
...person.id ? ["--person", person.id] : [],
|
|
14062
|
+
...source ? ["--source", source] : [],
|
|
14063
|
+
...kind ? ["--kind", kind] : [],
|
|
14064
|
+
...language ? ["--language", language] : []
|
|
14065
|
+
];
|
|
14066
|
+
const result = await run(argv, { timeoutMs: PICKS_TIMEOUT_MS, cwd, env });
|
|
14067
|
+
if (result.code !== 0) throw new Error(`exit ${result.code}: ${result.stderr.trim().split("\n").pop() ?? ""}`);
|
|
14068
|
+
return parsePicks(JSON.parse(result.stdout), hasSource, limit);
|
|
14058
14069
|
}
|
|
14059
14070
|
|
|
14060
14071
|
// src/shows.js
|
|
@@ -14763,10 +14774,132 @@ function createChanges({ intervalMs = 300 } = {}) {
|
|
|
14763
14774
|
};
|
|
14764
14775
|
}
|
|
14765
14776
|
|
|
14766
|
-
// src/
|
|
14777
|
+
// src/copies.js
|
|
14778
|
+
import { mkdir as mkdir10, readFile as readFile11, rename as rename8, writeFile as writeFile7 } from "node:fs/promises";
|
|
14779
|
+
import { dirname as dirname6 } from "node:path";
|
|
14767
14780
|
var DAY_MS3 = 864e5;
|
|
14768
14781
|
var HOUR_MS = 36e5;
|
|
14769
|
-
function
|
|
14782
|
+
function createCopies({ file, changed, logger, maxAgeMs = DAY_MS3, retryMs = HOUR_MS, parallel = 2, now = Date.now }) {
|
|
14783
|
+
const copies = /* @__PURE__ */ new Map();
|
|
14784
|
+
const flying = /* @__PURE__ */ new Set();
|
|
14785
|
+
const failedAt = /* @__PURE__ */ new Map();
|
|
14786
|
+
const waiting = [];
|
|
14787
|
+
let running = 0;
|
|
14788
|
+
let saving = Promise.resolve();
|
|
14789
|
+
const loaded = readFile11(file, "utf8").then((text3) => {
|
|
14790
|
+
for (const [key, copy] of Object.entries(JSON.parse(text3))) copies.set(key, copy);
|
|
14791
|
+
}).catch((error) => {
|
|
14792
|
+
if (error.code !== "ENOENT") logger.warn("the saved copies of Discover could not be read: %s", error.message);
|
|
14793
|
+
});
|
|
14794
|
+
function save() {
|
|
14795
|
+
saving = saving.then(async () => {
|
|
14796
|
+
await mkdir10(dirname6(file), { recursive: true });
|
|
14797
|
+
await writeFile7(`${file}.part`, JSON.stringify(Object.fromEntries(copies)));
|
|
14798
|
+
await rename8(`${file}.part`, file);
|
|
14799
|
+
}).catch((error) => logger.warn("the copies of Discover could not be saved: %s", error.message));
|
|
14800
|
+
return saving;
|
|
14801
|
+
}
|
|
14802
|
+
function pump() {
|
|
14803
|
+
while (running < parallel && waiting.length > 0) {
|
|
14804
|
+
running += 1;
|
|
14805
|
+
waiting.shift()().finally(() => {
|
|
14806
|
+
running -= 1;
|
|
14807
|
+
pump();
|
|
14808
|
+
});
|
|
14809
|
+
}
|
|
14810
|
+
}
|
|
14811
|
+
function ask(key, produce) {
|
|
14812
|
+
flying.add(key);
|
|
14813
|
+
waiting.push(async () => {
|
|
14814
|
+
try {
|
|
14815
|
+
copies.set(key, { at: now(), value: await produce() });
|
|
14816
|
+
failedAt.delete(key);
|
|
14817
|
+
await save();
|
|
14818
|
+
changed();
|
|
14819
|
+
} catch (error) {
|
|
14820
|
+
failedAt.set(key, now());
|
|
14821
|
+
logger.warn("no new copy of %s: %s", key, error.message);
|
|
14822
|
+
changed();
|
|
14823
|
+
} finally {
|
|
14824
|
+
flying.delete(key);
|
|
14825
|
+
}
|
|
14826
|
+
});
|
|
14827
|
+
pump();
|
|
14828
|
+
}
|
|
14829
|
+
return {
|
|
14830
|
+
/**
|
|
14831
|
+
* @param {string} key
|
|
14832
|
+
* @param {() => Promise<unknown>} produce - the outside answer, asked only when the copy is missing or old
|
|
14833
|
+
* @returns {Promise<{ at: number | null, value: unknown, loading: boolean }>} `loading`: no copy yet and one is on its way; `failed`: no copy and the last ask failed
|
|
14834
|
+
*/
|
|
14835
|
+
async get(key, produce) {
|
|
14836
|
+
await loaded;
|
|
14837
|
+
const copy = copies.get(key);
|
|
14838
|
+
const old = copy === void 0 || now() - copy.at >= maxAgeMs;
|
|
14839
|
+
if (old && !flying.has(key) && now() - (failedAt.get(key) ?? -Infinity) >= retryMs) ask(key, produce);
|
|
14840
|
+
return { at: copy?.at ?? null, value: copy?.value ?? null, loading: copy === void 0 && flying.has(key), failed: copy === void 0 && failedAt.has(key) };
|
|
14841
|
+
}
|
|
14842
|
+
};
|
|
14843
|
+
}
|
|
14844
|
+
|
|
14845
|
+
// src/discover.js
|
|
14846
|
+
var DISCOVER_PICKS = 12;
|
|
14847
|
+
var notFound = (message) => Object.assign(new Error(message), { code: "not_found" });
|
|
14848
|
+
function createDiscover({ copies, sources, covers, recommender }) {
|
|
14849
|
+
async function sourcesFor(sourceId, kind, ability) {
|
|
14850
|
+
if (sourceId !== ALL_SOURCES) {
|
|
14851
|
+
const one = sources.get(sourceId);
|
|
14852
|
+
if (one === void 0) throw notFound(`no source ${String(sourceId)}`);
|
|
14853
|
+
return [one];
|
|
14854
|
+
}
|
|
14855
|
+
const found = [];
|
|
14856
|
+
for (const one of sources.values()) {
|
|
14857
|
+
if (one.kinds.some((entry) => entry.id === kind && ability(entry)) && await one.available()) found.push(one);
|
|
14858
|
+
}
|
|
14859
|
+
return found;
|
|
14860
|
+
}
|
|
14861
|
+
const withCovers = (one, work) => ({ ...covers.decorate(one.id, work), source: one.id });
|
|
14862
|
+
return {
|
|
14863
|
+
/**
|
|
14864
|
+
* @returns {Promise<{ trending: { source: string, at: number, lists: object[] }[], loading: boolean }>} `loading`: some source has no copy yet
|
|
14865
|
+
*/
|
|
14866
|
+
async trending(sourceId, kind) {
|
|
14867
|
+
const wanted = (await sourcesFor(sourceId, kind, (entry) => entry.trending === true)).filter((one) => typeof one.trending === "function" && one.kinds.some((entry) => entry.id === kind && entry.trending === true));
|
|
14868
|
+
const copy = await Promise.all(wanted.map((one) => copies.get(`trending|${one.id}|${kind}`, () => one.trending(kind))));
|
|
14869
|
+
return {
|
|
14870
|
+
trending: wanted.flatMap((one, index) => copy[index].value === null ? [] : [{
|
|
14871
|
+
source: one.id,
|
|
14872
|
+
at: copy[index].at,
|
|
14873
|
+
lists: copy[index].value.map((list) => ({ ...list, results: list.results.map((work) => withCovers(one, work)) }))
|
|
14874
|
+
}]),
|
|
14875
|
+
loading: copy.some((entry) => entry.loading)
|
|
14876
|
+
};
|
|
14877
|
+
},
|
|
14878
|
+
/**
|
|
14879
|
+
* A person's picks for a source and category (merged under All sources), or without either (the Watching tab).
|
|
14880
|
+
* @returns {Promise<{ picks: object[], loading: boolean }>}
|
|
14881
|
+
*/
|
|
14882
|
+
async picks(person, { source: sourceId = "", kind = "", language = "" } = {}) {
|
|
14883
|
+
if (recommender.command.length === 0) return { picks: [], loading: false };
|
|
14884
|
+
const narrowed = sourceId !== "";
|
|
14885
|
+
const targets = narrowed ? await sourcesFor(sourceId, kind, () => true) : [null];
|
|
14886
|
+
const copy = await Promise.all(targets.map((one) => copies.get(
|
|
14887
|
+
`picks|${person.key}|${one?.id ?? "*"}|${narrowed ? kind : "*"}|${language}`,
|
|
14888
|
+
() => recommend(recommender, { person, source: one?.id, kind: narrowed ? kind : void 0, language, limit: narrowed ? DISCOVER_PICKS : PICKS_LIMIT })
|
|
14889
|
+
)));
|
|
14890
|
+
const lists = copy.map((entry, index) => (entry.value ?? []).filter((pick5) => targets[index] === null || pick5.work.source === targets[index].id && (kind === "" || pick5.work.kind === kind)));
|
|
14891
|
+
return {
|
|
14892
|
+
picks: interleave(lists).map((pick5) => ({ ...pick5, work: withCovers(sources.get(pick5.work.source), pick5.work) })).slice(0, narrowed ? DISCOVER_PICKS : PICKS_LIMIT),
|
|
14893
|
+
loading: copy.some((entry) => entry.loading)
|
|
14894
|
+
};
|
|
14895
|
+
}
|
|
14896
|
+
};
|
|
14897
|
+
}
|
|
14898
|
+
|
|
14899
|
+
// src/work-refresh.js
|
|
14900
|
+
var DAY_MS4 = 864e5;
|
|
14901
|
+
var HOUR_MS2 = 36e5;
|
|
14902
|
+
function createWorkRefresh({ source, keep, maxAgeMs = DAY_MS4, retryMs = HOUR_MS2, parallel = 2, now = Date.now, logger }) {
|
|
14770
14903
|
const flying = /* @__PURE__ */ new Set();
|
|
14771
14904
|
const failedAt = /* @__PURE__ */ new Map();
|
|
14772
14905
|
const waiting = [];
|
|
@@ -14804,7 +14937,7 @@ ${entry.source.id}`;
|
|
|
14804
14937
|
}
|
|
14805
14938
|
|
|
14806
14939
|
// src/media.js
|
|
14807
|
-
var
|
|
14940
|
+
var HOUR_MS3 = 36e5;
|
|
14808
14941
|
var MIN_FREE_BYTES = 1e9;
|
|
14809
14942
|
var NO_CONVERTER = Object.freeze({ command: "", available: async () => false });
|
|
14810
14943
|
var hubError = (code, message) => Object.assign(new Error(message), { code });
|
|
@@ -14869,21 +15002,19 @@ function createMediaHub(options) {
|
|
|
14869
15002
|
cache.refresh(show).catch(() => {
|
|
14870
15003
|
});
|
|
14871
15004
|
});
|
|
14872
|
-
const
|
|
14873
|
-
|
|
14874
|
-
|
|
14875
|
-
|
|
14876
|
-
|
|
14877
|
-
|
|
14878
|
-
logger,
|
|
14879
|
-
now
|
|
15005
|
+
const copies = createCopies({ file: join16(stateDir, "discover.json"), changed: () => changes.notify("discover"), maxAgeMs: options.discoverMaxAgeMs, logger, now });
|
|
15006
|
+
const discover = createDiscover({
|
|
15007
|
+
copies,
|
|
15008
|
+
sources,
|
|
15009
|
+
covers,
|
|
15010
|
+
recommender: { command: options.recommender?.command ?? [], env: options.recommender?.env ?? {}, cwd: stateDir, hasSource: (id) => sources.has(id) }
|
|
14880
15011
|
});
|
|
14881
15012
|
const sweepTimer = setInterval(() => {
|
|
14882
15013
|
library.sweep().catch(() => {
|
|
14883
15014
|
});
|
|
14884
15015
|
cache.enforce().catch(() => {
|
|
14885
15016
|
});
|
|
14886
|
-
},
|
|
15017
|
+
}, HOUR_MS3);
|
|
14887
15018
|
async function onFiles(job) {
|
|
14888
15019
|
changes.notify("library");
|
|
14889
15020
|
await rooms.syncShow(job.dir);
|
|
@@ -15024,7 +15155,8 @@ ${work.id}`).digest("hex").slice(0, 8);
|
|
|
15024
15155
|
changes.notify("library");
|
|
15025
15156
|
return { ok: true };
|
|
15026
15157
|
},
|
|
15027
|
-
|
|
15158
|
+
trending: (sourceId, kind) => discover.trending(sourceId, kind),
|
|
15159
|
+
picks: (person, narrow) => discover.picks(person, narrow),
|
|
15028
15160
|
/** Keep a recap or suggested steps with a show (the tool's annotate). */
|
|
15029
15161
|
annotate(path, input) {
|
|
15030
15162
|
const show = library.annotate(path, parseAnnotation(input));
|
|
@@ -15250,7 +15382,7 @@ function createPersonRoutes({ hub, identity }) {
|
|
|
15250
15382
|
path: `${PERSON_PATH}/picks`,
|
|
15251
15383
|
methods: ["GET"],
|
|
15252
15384
|
requestBody: "buffered",
|
|
15253
|
-
fetch: handle(
|
|
15385
|
+
fetch: handle((request, current, person) => current.picks(person, { source: param(request, "source"), kind: param(request, "kind"), language: param(request, "language") }))
|
|
15254
15386
|
},
|
|
15255
15387
|
{
|
|
15256
15388
|
path: `${PERSON_PATH}/steps`,
|
|
@@ -15371,7 +15503,7 @@ function createShelfRoutes({ books, identity }) {
|
|
|
15371
15503
|
var name = "dsh-media-hub";
|
|
15372
15504
|
var inject = ["webServer", "connection"];
|
|
15373
15505
|
var ROOM_ID = /^[A-Za-z0-9_-]{6,32}$/;
|
|
15374
|
-
var
|
|
15506
|
+
var DAY_MS5 = 864e5;
|
|
15375
15507
|
function apply(ctx, config) {
|
|
15376
15508
|
const logger = ctx.logger("media-hub");
|
|
15377
15509
|
let current;
|
|
@@ -15407,7 +15539,7 @@ function apply(ctx, config) {
|
|
|
15407
15539
|
const prune = setInterval(() => {
|
|
15408
15540
|
service.pruneCache(config.cacheDays).catch(() => {
|
|
15409
15541
|
});
|
|
15410
|
-
},
|
|
15542
|
+
}, DAY_MS5);
|
|
15411
15543
|
const identity = () => ctx.get("requestIdentity");
|
|
15412
15544
|
const fetchRoutes = [
|
|
15413
15545
|
...createShelfRoutes({ books: () => current?.books, identity }),
|
package/locale/en.json
CHANGED
|
@@ -267,6 +267,13 @@
|
|
|
267
267
|
"ratings.unfinished": "Didn't finish",
|
|
268
268
|
"picks.heading": "Picks",
|
|
269
269
|
"picks.hint": "Each with why it was picked",
|
|
270
|
+
"feed.picks": "For you",
|
|
271
|
+
"feed.picksHint": "Each with why it was picked",
|
|
272
|
+
"feed.trending": "Trending",
|
|
273
|
+
"feed.updated": "Updated {when}",
|
|
274
|
+
"feed.all": "Show all",
|
|
275
|
+
"feed.fewer": "Show fewer",
|
|
276
|
+
"feed.loading": "Fetching more from the sources…",
|
|
270
277
|
"continue.joinOne": "Join {names}",
|
|
271
278
|
"continue.continueAt": "Continue at {time}",
|
|
272
279
|
"continue.play": "Play",
|
package/locale/fr.json
CHANGED
|
@@ -267,6 +267,13 @@
|
|
|
267
267
|
"ratings.unfinished": "Pas fini",
|
|
268
268
|
"picks.heading": "Suggestions",
|
|
269
269
|
"picks.hint": "Chacune avec la raison du choix",
|
|
270
|
+
"feed.picks": "Pour vous",
|
|
271
|
+
"feed.picksHint": "Chaque suggestion avec sa raison",
|
|
272
|
+
"feed.trending": "Tendances",
|
|
273
|
+
"feed.updated": "Mis à jour {when}",
|
|
274
|
+
"feed.all": "Tout afficher",
|
|
275
|
+
"feed.fewer": "Réduire",
|
|
276
|
+
"feed.loading": "Récupération d'autres résultats auprès des sources…",
|
|
270
277
|
"continue.joinOne": "Rejoindre {names}",
|
|
271
278
|
"continue.continueAt": "Reprendre à {time}",
|
|
272
279
|
"continue.play": "Lire",
|
package/locale/zh.json
CHANGED
|
@@ -267,6 +267,13 @@
|
|
|
267
267
|
"ratings.unfinished": "没看完",
|
|
268
268
|
"picks.heading": "推荐",
|
|
269
269
|
"picks.hint": "每部都写了推荐理由",
|
|
270
|
+
"feed.picks": "为你推荐",
|
|
271
|
+
"feed.picksHint": "每个都带着推荐的理由",
|
|
272
|
+
"feed.trending": "热门",
|
|
273
|
+
"feed.updated": "{when}更新",
|
|
274
|
+
"feed.all": "显示全部",
|
|
275
|
+
"feed.fewer": "收起",
|
|
276
|
+
"feed.loading": "正在从来源获取更多…",
|
|
270
277
|
"continue.joinOne": "加入{names}",
|
|
271
278
|
"continue.continueAt": "从 {time} 继续",
|
|
272
279
|
"continue.play": "播放",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soffits/dsh-media-hub",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.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/discover-view.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* pasting the address of a video or playlist on any site yt-dlp reads), under
|
|
4
4
|
* it that source's own categories, then search; Link looks the address up
|
|
5
5
|
* and shows it as one result. Book categories add a filter row (language, format, years, size).
|
|
6
|
-
*
|
|
6
|
+
* Before any search the area below shows what the sources put forward and the
|
|
7
|
+
* recommender's picks for the category (web/feed-view.js). Results are cards: a show or audiobook (web/result-card.js) is watched
|
|
7
8
|
* together right away, saved to the library (the episodes being watched and
|
|
8
9
|
* the next few are kept on disk), or downloaded whole to keep offline; a
|
|
9
10
|
* book (web/books-view.js) is downloaded in a format onto the person's shelf.
|
|
@@ -15,6 +16,7 @@
|
|
|
15
16
|
*/
|
|
16
17
|
import { BookCard, BookFilters } from './books-view.js'
|
|
17
18
|
import { browserStorage, isWebAddress, pickKind, pickSource, readMemory, remember, takesUrl, withAll } from './nav.js'
|
|
19
|
+
import { DiscoverFeed } from './feed-view.js'
|
|
18
20
|
import { Result } from './result-card.js'
|
|
19
21
|
import { sortModes, sortResults } from './sort.js'
|
|
20
22
|
import { infoOf } from './details.js'
|
|
@@ -171,6 +173,7 @@ export function DiscoverView({ t, nav, onNav, onOpen, onSaved, onBack }) {
|
|
|
171
173
|
!isLink && isBook(kind) && h(BookFilters, { t, filters, languages: languageChoices(t.language, shown ? results.items : [], filters.language), onChange: filter }),
|
|
172
174
|
error && h('p', { className: 'vsync-error', role: 'alert' }, error),
|
|
173
175
|
!searching && shown && results.failed.length > 0 && h('p', { className: 'vsync-note', role: 'status' }, results.failed.map(one => fill(t('search.sourceFailed'), { source: sourceOf(one.source)?.label ?? one.source, message: one.message })).join(' ')),
|
|
176
|
+
!isLink && source !== null && results === null && loading === null && h(DiscoverFeed, { t, sourceId: source.id, kind, sourceOf, isBook, onOpen, onSaved, onFocus }),
|
|
174
177
|
searching && h('div', { className: 'vsync-skeleton', role: 'status', 'aria-busy': 'true', 'aria-label': t('search.loading') },
|
|
175
178
|
[0, 1, 2].map(n => h('span', { key: n, className: 'vsync-skeletonRow' }))),
|
|
176
179
|
!searching && shown && results.items.length > 1 && modes.length > 1 && h('div', { className: 'vsync-tabs vsync-sort', role: 'group', 'aria-label': t('sort.label') },
|
package/web/feed-view.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
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
|
|
7
|
+
* (src/copies.js), so the page never waits on a site: while a copy is first
|
|
8
|
+
* 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.
|
|
10
|
+
*
|
|
11
|
+
* The works are the same cards as search results.
|
|
12
|
+
*/
|
|
13
|
+
import { BookCard } from './books-view.js'
|
|
14
|
+
import { pick } from './i18n.js'
|
|
15
|
+
import { Result } from './result-card.js'
|
|
16
|
+
import { Changes, K, Spinner, api, asPerson, fillNodes, h, query, React } from './ui.js'
|
|
17
|
+
|
|
18
|
+
/** Works of a list shown before "Show all". */
|
|
19
|
+
export const LIST_PREVIEW = 6
|
|
20
|
+
|
|
21
|
+
/** What the plugin has for one source and category: its trending lists and this person's picks. */
|
|
22
|
+
function useFeed(sourceId, kind, language) {
|
|
23
|
+
const { discover } = React.useContext(Changes)
|
|
24
|
+
const [feed, setFeed] = React.useState(null)
|
|
25
|
+
const key = `${sourceId}|${kind}|${language}`
|
|
26
|
+
React.useEffect(() => {
|
|
27
|
+
let live = true
|
|
28
|
+
const asked = query({ source: sourceId, kind })
|
|
29
|
+
Promise.all([api(`trending?${asked}`), asPerson(`picks?${asked}&${query({ language })}`)]).then(([trending, picks]) => {
|
|
30
|
+
if (!live) return
|
|
31
|
+
setFeed({
|
|
32
|
+
key,
|
|
33
|
+
trending: Array.isArray(trending.trending) ? trending.trending : [],
|
|
34
|
+
picks: Array.isArray(picks.picks) ? picks.picks : [],
|
|
35
|
+
loading: trending.loading === true || picks.loading === true,
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
return () => { live = false }
|
|
39
|
+
}, [key, discover])
|
|
40
|
+
return feed?.key === key ? feed : null
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function Skeleton({ t }) {
|
|
44
|
+
return h('div', { className: 'vsync-skeleton', role: 'status', 'aria-busy': 'true', 'aria-label': t('search.loading') },
|
|
45
|
+
[0, 1, 2].map(n => h('span', { key: n, className: 'vsync-skeletonRow' })))
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function FeedSection({ id, title, hint, children }) {
|
|
49
|
+
return h('section', { className: 'vsync-section vsync-feedSection', 'aria-labelledby': id },
|
|
50
|
+
h('div', { className: 'vsync-sectionHead vsync-sectionHeadInline' },
|
|
51
|
+
h('h2', { id }, title),
|
|
52
|
+
hint && h('span', { className: 'vsync-sectionMeta' }, hint)),
|
|
53
|
+
children)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function DiscoverFeed({ t, sourceId, kind, sourceOf, isBook, onOpen, onSaved, onFocus }) {
|
|
57
|
+
const feed = useFeed(sourceId, kind ?? '', t.language)
|
|
58
|
+
const [expanded, setExpanded] = React.useState(() => new Set())
|
|
59
|
+
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
|
|
62
|
+
|
|
63
|
+
const card = (work) => {
|
|
64
|
+
const from = sourceOf(work.source)
|
|
65
|
+
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 })
|
|
69
|
+
}
|
|
70
|
+
const merged = sourceId === 'all'
|
|
71
|
+
|
|
72
|
+
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
|
+
trending.flatMap(({ source: from, at, lists }) => lists.map((list) => {
|
|
78
|
+
const id = `${from}:${list.id}`
|
|
79
|
+
const name = pick(list.label, t.language).trim() || t('feed.trending')
|
|
80
|
+
const title = merged ? `${sourceOf(from)?.label ?? from} · ${name}` : name
|
|
81
|
+
const all = expanded.has(id)
|
|
82
|
+
const shown = all ? list.results : list.results.slice(0, LIST_PREVIEW)
|
|
83
|
+
return h(FeedSection, { key: id, id: `vsync-feed-${id}`, title, hint: fillNodes(t('feed.updated'), { when: h(K.TimeAgo, { at: new Date(at).toISOString() }) }) },
|
|
84
|
+
h('ul', { className: 'vsync-rows vsync-results' }, shown.map(card)),
|
|
85
|
+
list.results.length > LIST_PREVIEW && h('button', { type: 'button', className: 'vsync-btn vsync-more', 'aria-expanded': String(all), onClick: () => setExpanded((current) => { const next = new Set(current); if (all) next.delete(id); else next.add(id); return next }) },
|
|
86
|
+
all ? t('feed.fewer') : t('feed.all')))
|
|
87
|
+
})),
|
|
88
|
+
loading && h('p', { className: 'vsync-note', role: 'status' }, h(Spinner), ' ', t('feed.loading')))
|
|
89
|
+
}
|
package/web/page.js
CHANGED
|
@@ -118,15 +118,17 @@ export function Page({ t, initialRoom }) {
|
|
|
118
118
|
|
|
119
119
|
// 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.
|
|
120
120
|
const [shelf, setShelf] = React.useState(0)
|
|
121
|
+
const [discover, setDiscover] = React.useState(0)
|
|
121
122
|
const stream = K.useEventStream('api/media-hub/events', (message) => {
|
|
122
123
|
if (message.what?.includes('shelf')) setShelf(count => count + 1)
|
|
124
|
+
if (message.what?.includes('discover')) setDiscover(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 }), [shelf])
|
|
131
|
+
const changes = React.useMemo(() => ({ shelf, discover }), [shelf, discover])
|
|
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
|
@@ -355,6 +355,11 @@
|
|
|
355
355
|
@media (prefers-reduced-motion:reduce){.vsync-pickCard{transition:none}}
|
|
356
356
|
.vsync-pickWhy{display:flex;gap:6px;font-size:13px;line-height:19px;color:var(--dsw-alias-label-secondary)}
|
|
357
357
|
.vsync-pickWhy .uk-icon{margin-top:2px}
|
|
358
|
+
.vsync-feed{margin-top:8px}
|
|
359
|
+
.vsync-feedSection h2{color:var(--dsw-alias-label-primary);font-size:15px;font-weight:600;line-height:22px}
|
|
360
|
+
.vsync-feedPick{list-style:none;display:flex;flex-direction:column;gap:4px}
|
|
361
|
+
.vsync-feedPick .vsync-pickWhy{margin:0 4px}
|
|
362
|
+
.vsync-feedSection .vsync-more{display:flex;margin-top:0}
|
|
358
363
|
.vsync-pickActions{margin-top:auto;padding-top:6px}
|
|
359
364
|
@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%}}
|
|
360
365
|
/* Interface chrome is not selectable and pictures don't drag; titles, recaps and reasons stay selectable. */
|
package/web/presence-view.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { Picture } from './details.js'
|
|
8
8
|
import { FollowButton } from './follow.js'
|
|
9
|
-
import { Btn, Icon, K, P, React, asPerson, asPersonPaying, displayName, fillNodes, h } from './ui.js'
|
|
9
|
+
import { Btn, Changes, Icon, K, P, React, asPerson, asPersonPaying, displayName, fillNodes, h, query } from './ui.js'
|
|
10
10
|
|
|
11
11
|
/** The answers, in order, with the icon each one shows (DSH's own where it has one). */
|
|
12
12
|
const ANSWERS = [
|
|
@@ -89,7 +89,8 @@ function PickCard({ t, pick, onOpen, onOpenWork }) {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
export function PicksSection({ t, on, onOpen, onOpenWork }) {
|
|
92
|
-
const
|
|
92
|
+
const { discover } = React.useContext(Changes)
|
|
93
|
+
const [picks] = usePersonList(on, `picks?${query({ language: t.language })}`, 'picks', discover)
|
|
93
94
|
if (!picks || picks.length === 0) return null
|
|
94
95
|
return h(Section, { id: 'vsync-picks', title: t('picks.heading'), hint: t('picks.hint') },
|
|
95
96
|
h('ul', { className: 'vsync-cards vsync-pickGrid' }, picks.map(pick => h(PickCard, { key: `${pick.work.source}:${pick.work.id}`, t, pick, onOpen, onOpenWork }))))
|
package/web/ui.js
CHANGED
|
@@ -24,7 +24,7 @@ export function init(react, { primitives, kit }) {
|
|
|
24
24
|
h = react.createElement
|
|
25
25
|
P = primitives
|
|
26
26
|
K = kit
|
|
27
|
-
Changes = react.createContext({ shelf: 0 })
|
|
27
|
+
Changes = react.createContext({ shelf: 0, discover: 0 })
|
|
28
28
|
Known = react.createContext({ library: null, rooms: undefined, reload: () => {} })
|
|
29
29
|
}
|
|
30
30
|
|