@khorsheed/dsh-reader 0.2.1 → 0.3.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 +27 -0
- package/README.en.md +26 -121
- package/README.i18n.yaml +3 -3
- package/README.md +26 -121
- package/cordis.patch.yml +7 -0
- package/lib/client.js +30580 -6892
- package/lib/index.js +4189 -621
- package/lib/typert.host.js +2265 -319
- package/lib/typert.remote-client.d.ts +99 -3
- package/lib/typert.remote-client.js +1618 -240
- package/lib/types/captions.d.ts +99 -0
- package/lib/types/captions.js +236 -0
- package/lib/types/client/MediaPlayer.d.ts +55 -0
- package/lib/types/client/MediaPlayer.js +106 -0
- package/lib/types/client/NotesView.d.ts +57 -0
- package/lib/types/client/NotesView.js +124 -0
- package/lib/types/client/ReaderPane.d.ts +20 -3
- package/lib/types/client/ReaderPane.js +905 -164
- package/lib/types/client/SpeakerLegend.d.ts +18 -0
- package/lib/types/client/SpeakerLegend.js +26 -0
- package/lib/types/client/canvas-sync.d.ts +84 -0
- package/lib/types/client/canvas-sync.js +59 -0
- package/lib/types/client/contract.d.ts +138 -3
- package/lib/types/client/extract-article.d.ts +38 -1
- package/lib/types/client/extract-article.js +501 -28
- package/lib/types/client/icons.d.ts +1 -1
- package/lib/types/client/icons.js +1 -1
- package/lib/types/client/index.js +82 -2
- package/lib/types/client/locales.d.ts +279 -11
- package/lib/types/client/locales.js +278 -10
- package/lib/types/client/notes.d.ts +142 -0
- package/lib/types/client/notes.js +334 -0
- package/lib/types/client/parse-rss.js +40 -0
- package/lib/types/client/preset-visibility.d.ts +93 -0
- package/lib/types/client/preset-visibility.js +115 -0
- package/lib/types/client/selectors.d.ts +5 -0
- package/lib/types/client/selectors.js +5 -0
- package/lib/types/client/session.d.ts +21 -1
- package/lib/types/client/session.js +12 -0
- package/lib/types/client/store.js +4 -1
- package/lib/types/client/translate.d.ts +26 -1
- package/lib/types/client/translate.js +29 -12
- package/lib/types/client/useLocalTranscript.d.ts +43 -0
- package/lib/types/client/useLocalTranscript.js +129 -0
- package/lib/types/client/useMedia.d.ts +68 -0
- package/lib/types/client/useMedia.js +299 -0
- package/lib/types/client/useMediaStates.d.ts +9 -0
- package/lib/types/client/useMediaStates.js +43 -0
- package/lib/types/client/useNotes.d.ts +110 -0
- package/lib/types/client/useNotes.js +423 -0
- package/lib/types/client/usePolish.d.ts +47 -0
- package/lib/types/client/usePolish.js +162 -0
- package/lib/types/image-fetch.d.ts +81 -0
- package/lib/types/image-fetch.js +385 -0
- package/lib/types/index.d.ts +6 -0
- package/lib/types/index.js +3 -0
- package/lib/types/local-transcribe.d.ts +171 -0
- package/lib/types/local-transcribe.js +473 -0
- package/lib/types/media-host.d.ts +91 -0
- package/lib/types/media-host.js +230 -0
- package/lib/types/media.d.ts +100 -0
- package/lib/types/media.js +207 -0
- package/lib/types/notes-types.d.ts +158 -0
- package/lib/types/notes-types.js +8 -0
- package/lib/types/notes.d.ts +213 -0
- package/lib/types/notes.js +718 -0
- package/lib/types/polish.d.ts +41 -0
- package/lib/types/polish.js +136 -0
- package/lib/types/remote.d.ts +127 -1
- package/lib/types/remote.js +162 -1
- package/lib/types/service.d.ts +100 -1
- package/lib/types/service.js +320 -59
- package/lib/types/skill.d.ts +20 -0
- package/lib/types/skill.js +78 -0
- package/lib/types/store.js +30 -8
- package/lib/types/tool.d.ts +23 -0
- package/lib/types/tool.js +40 -0
- package/lib/types/tools.d.ts +69 -0
- package/lib/types/tools.js +400 -0
- package/lib/types/types.d.ts +106 -0
- package/lib/types/types.js +66 -0
- package/lib/types/xiaoyuzhou.d.ts +43 -0
- package/lib/types/xiaoyuzhou.js +134 -0
- package/lib/types/ytdlp.d.ts +111 -0
- package/lib/types/ytdlp.js +269 -0
- package/package.json +29 -20
- package/lib/invariant.js +0 -38
- package/lib/types/invariant.d.ts +0 -29
- package/lib/types/invariant.js +0 -38
package/lib/types/service.d.ts
CHANGED
|
@@ -35,7 +35,9 @@
|
|
|
35
35
|
* @module @khorsheed/dsh-reader/service
|
|
36
36
|
*/
|
|
37
37
|
import type { Context } from '@deepseek-ai/cordis';
|
|
38
|
-
import { type ReaderAddFailure, type ReaderAddOutcome, type ReaderAddRefusal, type ReaderAnnotationOutcome, type ReaderBackfillCandidate, type ReaderEntryBodyView, type ReaderBody, type ReaderCapabilities, type ReaderMutationOutcome, type ReaderEntryFetchState, type ReaderEntryTranslationView, type ReaderPreviewFailure, type ReaderPreviewFailureCode, type ReaderRecentEntry, type ReaderRefreshResult, type ReaderSentenceLearn, type ReaderSourceSummary, type ReaderStorageStats, type ReaderTag } from './types.ts';
|
|
38
|
+
import { type ReaderAddFailure, type ReaderAddOutcome, type ReaderAddRefusal, type ReaderAnnotationOutcome, type ReaderBackfillCandidate, type ReaderEntryBodyView, type ReaderBody, type ReaderCapabilities, type ReaderMutationOutcome, type ReaderEntryFetchState, type ReaderEntryTranslationView, type ReaderPreviewFailure, type ReaderPreviewFailureCode, type ReaderImageResult, type ReaderRecentEntry, type ReaderRefreshResult, type ReaderSentenceLearn, type ReaderSourceSummary, type ReaderStorageStats, type ReaderTag, type MediaCardStates } from './types.ts';
|
|
39
|
+
import { LocalTranscriber } from './local-transcribe.ts';
|
|
40
|
+
import { ReaderMediaHost } from './media-host.ts';
|
|
39
41
|
/**
|
|
40
42
|
* How many entries one automatic backfill run may fetch.
|
|
41
43
|
*
|
|
@@ -46,6 +48,15 @@ import { type ReaderAddFailure, type ReaderAddOutcome, type ReaderAddRefusal, ty
|
|
|
46
48
|
export declare const BACKFILL_MAX_PER_RUN = 8;
|
|
47
49
|
/** How long a FAILED fetch is left alone before it may be retried (6 hours). */
|
|
48
50
|
export declare const BACKFILL_RETRY_MS: number;
|
|
51
|
+
/**
|
|
52
|
+
* How many sources one refresh fetches at once.
|
|
53
|
+
*
|
|
54
|
+
* A strictly sequential loop made one dead source (a full 30 s timeout) stall
|
|
55
|
+
* every source behind it — the "refresh takes minutes" half of the slow-load
|
|
56
|
+
* report. Three at a time is the politeness ceiling this package applies to
|
|
57
|
+
* other people's servers everywhere (the backfill runs at two).
|
|
58
|
+
*/
|
|
59
|
+
export declare const REFRESH_CONCURRENCY = 3;
|
|
49
60
|
/**
|
|
50
61
|
* Thrown when the FETCH itself failed — a refused connection, a timeout, a
|
|
51
62
|
* response over the seam's byte cap. Carries the seam's own message: the
|
|
@@ -73,17 +84,24 @@ export declare function classifyPayload(raw: string): 'feed' | 'page';
|
|
|
73
84
|
/** The reader service. */
|
|
74
85
|
export declare class ReaderService {
|
|
75
86
|
private readonly store;
|
|
87
|
+
/** Video and audio entries: synthetic pages, channel feeds, transcripts. */
|
|
88
|
+
readonly media: ReaderMediaHost;
|
|
89
|
+
/** Local transcription of entries without captions (the optional `transcribe` engine). */
|
|
90
|
+
readonly local: LocalTranscriber;
|
|
76
91
|
private readonly ctx;
|
|
77
92
|
private timer;
|
|
78
93
|
private disposed;
|
|
79
94
|
/** The document of record when no filesystem is mounted. */
|
|
80
95
|
private memoryDoc;
|
|
96
|
+
/** Rescued images, by URL — a pane remount re-fails every blocked image, and this is what keeps that a memory read. */
|
|
97
|
+
private readonly imageCache;
|
|
81
98
|
/**
|
|
82
99
|
* @param ctx - owning context.
|
|
83
100
|
* @param config - optional state-root override.
|
|
84
101
|
*/
|
|
85
102
|
constructor(ctx: Context, config?: {
|
|
86
103
|
stateRoot?: string;
|
|
104
|
+
ytdlpPath?: string;
|
|
87
105
|
});
|
|
88
106
|
/** Capabilities the browser may rely on. */
|
|
89
107
|
capabilities(): Promise<ReaderCapabilities>;
|
|
@@ -230,6 +248,33 @@ export declare class ReaderService {
|
|
|
230
248
|
truncated?: boolean;
|
|
231
249
|
error?: string;
|
|
232
250
|
}>;
|
|
251
|
+
/**
|
|
252
|
+
* One image the browser could not load cross-origin, fetched host-side.
|
|
253
|
+
*
|
|
254
|
+
* The pane calls this only for an `<img>` that already FAILED: the page's
|
|
255
|
+
* bytes arrived fine (a direct fetch gets a 200) but the origin answers them
|
|
256
|
+
* with `Cross-Origin-Resource-Policy: same-origin`, so the browser withholds
|
|
257
|
+
* them from this page no matter what the tag asks — measured on claude.dev's
|
|
258
|
+
* `/media/*` figures (2026-09-29), which broke with the alt text showing.
|
|
259
|
+
* CORP is an embedder-side check, so a host-process fetch is the way through.
|
|
260
|
+
*
|
|
261
|
+
* This deliberately does NOT ride `ctx.web.fetch`: the seam's decoded body is
|
|
262
|
+
* a closed html|text union and its provider refuses binary content types
|
|
263
|
+
* outright. The image fetch re-implements the seam's hardening at image
|
|
264
|
+
* scope instead (public-address validation with the connection pinned to the
|
|
265
|
+
* validated answers, a byte cap, a timeout, per-hop re-validation, and an
|
|
266
|
+
* image/* content-type gate) — see `image-fetch.ts`.
|
|
267
|
+
*
|
|
268
|
+
* Rescued bytes are kept in an in-memory LRU under a byte budget: the
|
|
269
|
+
* sidebar unmounts wholesale when another panel takes over, and a remount
|
|
270
|
+
* re-fails every blocked image before this cache can answer it.
|
|
271
|
+
*
|
|
272
|
+
* @param request - the image URL the pane failed on.
|
|
273
|
+
* @returns the bytes and their declared type, or why there are none.
|
|
274
|
+
*/
|
|
275
|
+
fetchImage(request: {
|
|
276
|
+
url: string;
|
|
277
|
+
}): Promise<ReaderImageResult>;
|
|
233
278
|
/**
|
|
234
279
|
* Which entries have a body, a stored raw payload, or a recorded failure.
|
|
235
280
|
*
|
|
@@ -294,6 +339,8 @@ export declare class ReaderService {
|
|
|
294
339
|
title?: string;
|
|
295
340
|
/** A short excerpt (abstract / first paragraph), with the title. */
|
|
296
341
|
excerpt?: string;
|
|
342
|
+
/** Keep regardless of the cache TTL (a transcript costs a yt-dlp run, not a page fetch). */
|
|
343
|
+
keep?: boolean;
|
|
297
344
|
}): Promise<ReaderEntryBodyView>;
|
|
298
345
|
/**
|
|
299
346
|
* Which entries still need their full text, and which may be retried.
|
|
@@ -562,6 +609,58 @@ export declare class ReaderService {
|
|
|
562
609
|
* @returns the final URL and its decoded payload.
|
|
563
610
|
*/
|
|
564
611
|
private fetchFollowing;
|
|
612
|
+
/**
|
|
613
|
+
* Fetch a source's payload, media-aware (media-host.ts).
|
|
614
|
+
*
|
|
615
|
+
* A YouTube channel is fetched as YouTube's own channel feed; a Xiaoyuzhou
|
|
616
|
+
* podcast page as the RSS document it is turned into; a single video or
|
|
617
|
+
* Xiaoyuzhou episode as a synthetic page carrying its media description.
|
|
618
|
+
* Everything else is the ordinary {@link fetchFollowing}.
|
|
619
|
+
*
|
|
620
|
+
* @param url - the source URL.
|
|
621
|
+
*/
|
|
622
|
+
private fetchSource;
|
|
623
|
+
/**
|
|
624
|
+
* A video entry's transcript: the stored one, else the platform captions
|
|
625
|
+
* fetched now and kept (no TTL — it costs a yt-dlp run). A video known to
|
|
626
|
+
* have no captions answers so without running yt-dlp again.
|
|
627
|
+
*
|
|
628
|
+
* @param request - the entry and its video page URL.
|
|
629
|
+
* @returns the transcript markup, `none`, or why it failed.
|
|
630
|
+
*/
|
|
631
|
+
mediaTranscript(request: {
|
|
632
|
+
entryId: string;
|
|
633
|
+
url: string;
|
|
634
|
+
}): Promise<{
|
|
635
|
+
entryId: string;
|
|
636
|
+
html?: string;
|
|
637
|
+
captions: 'platform' | 'none' | 'failed';
|
|
638
|
+
language?: string;
|
|
639
|
+
error?: string;
|
|
640
|
+
}>;
|
|
641
|
+
/** The reader's names for an entry's speakers, by index. */
|
|
642
|
+
speakerNames(request: {
|
|
643
|
+
entryId: string;
|
|
644
|
+
}): Record<string, string>;
|
|
645
|
+
/**
|
|
646
|
+
* Name one speaker of an entry's transcript (an empty name restores the default).
|
|
647
|
+
*
|
|
648
|
+
* @param request - the entry, the speaker's index, the name.
|
|
649
|
+
*/
|
|
650
|
+
nameSpeaker(request: {
|
|
651
|
+
entryId: string;
|
|
652
|
+
speaker: number;
|
|
653
|
+
name: string;
|
|
654
|
+
}): Record<string, string>;
|
|
655
|
+
/**
|
|
656
|
+
* The wall's media cards: a live local job first, else what the captions
|
|
657
|
+
* record says (platform captions, a stored local transcript, none).
|
|
658
|
+
*
|
|
659
|
+
* @param request - the card ids on screen.
|
|
660
|
+
*/
|
|
661
|
+
mediaStates(request: {
|
|
662
|
+
entryIds: readonly string[];
|
|
663
|
+
}): MediaCardStates;
|
|
565
664
|
/** Arm (or re-arm) the daily refresh timer against the current document. */
|
|
566
665
|
private armSchedule;
|
|
567
666
|
}
|