phirepass-widgets 0.0.112 → 0.0.114
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/README.md +33 -0
- package/dist/cjs/{index-B8w6l0VL.js → index-BCgmMoIq.js} +103 -32
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/phirepass-downloader_3.cjs.entry.js +3717 -0
- package/dist/cjs/phirepass-rdp.cjs.entry.js +18 -6
- package/dist/cjs/phirepass-terminal.cjs.entry.js +6 -5
- package/dist/cjs/phirepass-widgets.cjs.js +3 -3
- package/dist/cjs/protocol-CYh109n2.js +1472 -0
- package/dist/collection/collection-manifest.json +3 -1
- package/dist/collection/common/channel.js +21 -1
- package/dist/collection/common/fetch.js +44 -0
- package/dist/collection/components/phirepass-downloader/form.js +69 -0
- package/dist/collection/components/phirepass-downloader/format.js +105 -0
- package/dist/collection/components/phirepass-downloader/jobs.js +373 -0
- package/dist/collection/components/phirepass-downloader/phirepass-downloader.css +1109 -0
- package/dist/collection/components/phirepass-downloader/phirepass-downloader.js +1455 -0
- package/dist/collection/components/phirepass-downloader/source.js +120 -0
- package/dist/collection/components/phirepass-downloader/views/dialogs.js +34 -0
- package/dist/collection/components/phirepass-downloader/views/fetch-form.js +65 -0
- package/dist/collection/components/phirepass-downloader/views/icons.js +33 -0
- package/dist/collection/components/phirepass-downloader/views/job-row.js +91 -0
- package/dist/collection/components/phirepass-downloader/views/notices.js +15 -0
- package/dist/collection/components/phirepass-downloader/views/states.js +19 -0
- package/dist/collection/components/phirepass-media-player/phirepass-media-player.css +216 -0
- package/dist/collection/components/phirepass-media-player/phirepass-media-player.js +473 -0
- package/dist/collection/components/phirepass-media-player/player.js +94 -0
- package/dist/collection/components/phirepass-rdp/phirepass-rdp.js +36 -13
- package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.css +122 -0
- package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.fetch.js +35 -0
- package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.js +181 -31
- package/dist/collection/components/phirepass-terminal/phirepass-terminal.js +2 -2
- package/dist/collection/phirepass-channel_bg.wasm +0 -0
- package/dist/collection/testing/fixtures.js +219 -0
- package/dist/collection/testing/mock-channel.js +410 -0
- package/dist/components/index.js +1 -1
- package/dist/components/p-BtMWUitf.js +1 -0
- package/dist/components/p-C4cmk3bS.js +1 -0
- package/dist/components/p-CKnb-oeB.js +1 -0
- package/dist/components/phirepass-downloader.d.ts +11 -0
- package/dist/components/phirepass-downloader.js +1 -0
- package/dist/components/phirepass-media-player.d.ts +11 -0
- package/dist/components/phirepass-media-player.js +1 -0
- package/dist/components/phirepass-rdp.js +1 -1
- package/dist/components/phirepass-sftp-client.js +1 -1
- package/dist/components/phirepass-terminal.js +2 -2
- package/dist/esm/{index-DGq2b7rM.js → index-Dd9o0CbU.js} +103 -32
- package/dist/esm/loader.js +3 -3
- package/dist/esm/phirepass-downloader_3.entry.js +3713 -0
- package/dist/esm/phirepass-rdp.entry.js +18 -6
- package/dist/esm/phirepass-terminal.entry.js +6 -5
- package/dist/esm/phirepass-widgets.js +4 -4
- package/dist/esm/protocol-BtMWUitf.js +1467 -0
- package/dist/phirepass-widgets/p-97d84225.entry.js +1 -0
- package/dist/phirepass-widgets/p-BtMWUitf.js +1 -0
- package/dist/phirepass-widgets/p-Dd9o0CbU.js +3 -0
- package/dist/phirepass-widgets/p-a4a5e5f5.entry.js +1 -0
- package/dist/phirepass-widgets/{p-1fef5b5f.entry.js → p-a5ce104d.entry.js} +2 -2
- package/dist/phirepass-widgets/phirepass-channel_bg.wasm +0 -0
- package/dist/phirepass-widgets/phirepass-widgets.esm.js +1 -1
- package/dist/types/common/channel.d.ts +30 -0
- package/dist/types/common/fetch.d.ts +167 -0
- package/dist/types/components/phirepass-downloader/form.d.ts +54 -0
- package/dist/types/components/phirepass-downloader/format.d.ts +17 -0
- package/dist/types/components/phirepass-downloader/jobs.d.ts +116 -0
- package/dist/types/components/phirepass-downloader/phirepass-downloader.d.ts +231 -0
- package/dist/types/components/phirepass-downloader/source.d.ts +61 -0
- package/dist/types/components/phirepass-downloader/views/dialogs.d.ts +52 -0
- package/dist/types/components/phirepass-downloader/views/fetch-form.d.ts +31 -0
- package/dist/types/components/phirepass-downloader/views/icons.d.ts +5 -0
- package/dist/types/components/phirepass-downloader/views/job-row.d.ts +21 -0
- package/dist/types/components/phirepass-downloader/views/notices.d.ts +18 -0
- package/dist/types/components/phirepass-downloader/views/states.d.ts +38 -0
- package/dist/types/components/phirepass-media-player/phirepass-media-player.d.ts +67 -0
- package/dist/types/components/phirepass-media-player/player.d.ts +43 -0
- package/dist/types/components/phirepass-rdp/phirepass-rdp.d.ts +10 -0
- package/dist/types/components/phirepass-sftp-client/phirepass-sftp-client.d.ts +30 -0
- package/dist/types/components/phirepass-sftp-client/phirepass-sftp-client.fetch.d.ts +40 -0
- package/dist/types/components.d.ts +426 -34
- package/dist/types/stencil-public-runtime.d.ts +1 -1
- package/dist/types/testing/fixtures.d.ts +25 -0
- package/dist/types/testing/mock-channel.d.ts +132 -0
- package/package.json +26 -12
- package/dist/cjs/phirepass-sftp-client.cjs.entry.js +0 -1469
- package/dist/cjs/protocol-COvteaUJ.js +0 -1044
- package/dist/components/p-Dur4cBX7.js +0 -1
- package/dist/esm/phirepass-sftp-client.entry.js +0 -1467
- package/dist/esm/protocol-Dur4cBX7.js +0 -1039
- package/dist/phirepass-widgets/p-8eb3ec24.entry.js +0 -1
- package/dist/phirepass-widgets/p-9a1f9b9f.entry.js +0 -1
- package/dist/phirepass-widgets/p-DGq2b7rM.js +0 -3
- package/dist/phirepass-widgets/p-Dur4cBX7.js +0 -1
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { FetchCaps, FetchFile, FetchJob, FetchState } from '../../common/fetch';
|
|
2
|
+
/**
|
|
3
|
+
* A row as the widget holds it: the node's latest `FetchJob`, plus what the
|
|
4
|
+
* widget itself is waiting on. `deleting` is set when this widget sent a
|
|
5
|
+
* Delete, or when the server says one is pending (a Delete sent from
|
|
6
|
+
* elsewhere, or while the node was offline).
|
|
7
|
+
*/
|
|
8
|
+
export type Row = FetchJob & {
|
|
9
|
+
/** Accepted by the server, but the node has not reported it yet (it may be offline). */
|
|
10
|
+
waitingForNode?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type JobMap = Record<string, Row>;
|
|
13
|
+
export declare function isFinished(state: FetchState): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Folds one `DownloadProgress` into the rows.
|
|
16
|
+
*
|
|
17
|
+
* `completed` is set only the first time a job reaches Completed or Seeding
|
|
18
|
+
* from anything else: a re-sent Completed (after a reconnect, or the snapshot a
|
|
19
|
+
* fresh subscription gets) is not a second completion. A job first seen already
|
|
20
|
+
* finished is not one either. `Deleted` removes the row.
|
|
21
|
+
*/
|
|
22
|
+
export declare function applyProgress(prev: JobMap, job: FetchJob): {
|
|
23
|
+
jobs: JobMap;
|
|
24
|
+
completed?: FetchJob;
|
|
25
|
+
first: boolean;
|
|
26
|
+
};
|
|
27
|
+
export type Tab = 'active' | 'finished' | 'retrying';
|
|
28
|
+
export declare function tabOf(row: Row): Tab;
|
|
29
|
+
/**
|
|
30
|
+
* Jobs working towards their bytes: what the badge and “N active” count.
|
|
31
|
+
* A Retrying job is waiting out its backoff, so it is not counted (mockup A
|
|
32
|
+
* shows 3 active beside a retrying row); it has its own tab instead.
|
|
33
|
+
*/
|
|
34
|
+
export declare function isRunning(row: Row): boolean;
|
|
35
|
+
/** Rows “Clear finished” deletes: Completed and Cancelled, never a seeding torrent. */
|
|
36
|
+
export declare function isClearable(row: Row): boolean;
|
|
37
|
+
/** Active work first, newest first within a state; finished rows by when they finished. */
|
|
38
|
+
export declare function sortRows(rows: Row[]): Row[];
|
|
39
|
+
export declare function summarize(rows: Row[]): {
|
|
40
|
+
active: number;
|
|
41
|
+
downBps: number;
|
|
42
|
+
done: number;
|
|
43
|
+
total: number;
|
|
44
|
+
percent: number | null;
|
|
45
|
+
};
|
|
46
|
+
export declare function isMediaName(name: string): boolean;
|
|
47
|
+
export declare function isAudioName(name: string): boolean;
|
|
48
|
+
/** The file a player opens: the largest media file, which is the one the in-order reader follows. */
|
|
49
|
+
export declare function mediaFile(row: Row): FetchFile | null;
|
|
50
|
+
export type PlayCheck = {
|
|
51
|
+
play: boolean;
|
|
52
|
+
file: FetchFile | null;
|
|
53
|
+
switchToInOrder: boolean;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Play appears only for video or audio whose size is known and whose download
|
|
57
|
+
* is finished or in order. A Fastest torrent offers “Switch to in order to
|
|
58
|
+
* watch” instead; the server refuses its stream anyway (409).
|
|
59
|
+
*/
|
|
60
|
+
export declare function playCheck(row: Row): PlayCheck;
|
|
61
|
+
export declare function streamUrl(base: string, nodeId: string, downloadId: string, fileIndex: number): string;
|
|
62
|
+
export declare function joinPath(...parts: Array<string | null | undefined>): string;
|
|
63
|
+
export declare function folderOf(row: Pick<FetchJob, 'dest_root' | 'sub_dir'>): string;
|
|
64
|
+
/** The path of a running link download's part file, as the SFTP listing shows it. */
|
|
65
|
+
export declare function partPath(row: Row): string;
|
|
66
|
+
export type Pill = {
|
|
67
|
+
text: string;
|
|
68
|
+
tone: 'dl' | 'meta' | 'mv' | 'ok' | 'err' | 'ps' | 'q' | 'sd';
|
|
69
|
+
};
|
|
70
|
+
export declare function statePill(row: Row): Pill;
|
|
71
|
+
/** The second pill on a torrent row: which order it downloads in. */
|
|
72
|
+
export declare function orderPill(row: Row): string | null;
|
|
73
|
+
export type Stat = {
|
|
74
|
+
text: string;
|
|
75
|
+
strong?: boolean;
|
|
76
|
+
error?: boolean;
|
|
77
|
+
};
|
|
78
|
+
/** The stats line under a row's bar, state by state, as mockups R and R2 draw it. */
|
|
79
|
+
export declare function statsLine(row: Row, ctx?: {
|
|
80
|
+
now?: number;
|
|
81
|
+
running?: number;
|
|
82
|
+
source?: string;
|
|
83
|
+
}): Stat[];
|
|
84
|
+
/** The line under a finished row in the standalone Finished tab (H4). */
|
|
85
|
+
export declare function finishedLine(row: Row, now?: number): string;
|
|
86
|
+
/** Default longest retry wait (node setting “Longest retry wait”). */
|
|
87
|
+
export declare const RETRY_MAX_SECS = 3600;
|
|
88
|
+
/**
|
|
89
|
+
* How long a job has been retrying, from its attempt count: 10 s doubling,
|
|
90
|
+
* capped at the node's longest wait. It ignores jitter and time spent
|
|
91
|
+
* downloading between attempts, which only makes it later, never earlier.
|
|
92
|
+
*/
|
|
93
|
+
export declare function retryingForSecs(attempt: number, maxSecs?: number): number;
|
|
94
|
+
export declare const STUCK_AFTER_SECS: number;
|
|
95
|
+
export declare function isStuck(row: Row, maxSecs?: number): boolean;
|
|
96
|
+
/** True when the node saved under another name than the one asked for (N4). */
|
|
97
|
+
export declare function renamedByNode(asked: string | undefined, used: string): boolean;
|
|
98
|
+
export type Blocker = {
|
|
99
|
+
id: 'too-old' | 'off' | 'blocked' | 'no-folder';
|
|
100
|
+
title: string;
|
|
101
|
+
body: string;
|
|
102
|
+
secondary?: string;
|
|
103
|
+
action?: string;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Why nothing can be started on this node, if anything stops it (B8, B9, L3).
|
|
107
|
+
* Order matters: an agent too old to download is the first thing to fix, an
|
|
108
|
+
* organisation block outranks the node's own switch.
|
|
109
|
+
*/
|
|
110
|
+
export declare function blockerFor(caps: FetchCaps, nodeName: string, canConfigure: boolean): Blocker | null;
|
|
111
|
+
/**
|
|
112
|
+
* Whether a Cancelled reason is the node's free-space check (K5), which gets
|
|
113
|
+
* its own dialog. The node words it as “needs X … has Y free” or “not enough
|
|
114
|
+
* space”; until the protocol carries a code for it, the wording decides.
|
|
115
|
+
*/
|
|
116
|
+
export declare function isNoSpace(reason: string | null | undefined): boolean;
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { EventEmitter } from '../../stencil-public-runtime';
|
|
2
|
+
import { DownloadChannelFactory, DownloadChannelLike } from '../../common/channel';
|
|
3
|
+
import { FetchCaps } from '../../common/fetch';
|
|
4
|
+
import { ProtocolMessage } from '../../common/protocol';
|
|
5
|
+
import { FormState, Note } from './form';
|
|
6
|
+
import { JobMap, Row, Tab } from './jobs';
|
|
7
|
+
import { Notice } from './views/notices';
|
|
8
|
+
type Connection = 'connecting' | 'ready' | 'unreachable' | 'signed-out' | 'unsupported';
|
|
9
|
+
type Confirm = {
|
|
10
|
+
kind: 'stop';
|
|
11
|
+
row: Row;
|
|
12
|
+
discard: boolean;
|
|
13
|
+
} | {
|
|
14
|
+
kind: 'delete';
|
|
15
|
+
row: Row;
|
|
16
|
+
deleteFile: boolean;
|
|
17
|
+
} | {
|
|
18
|
+
kind: 'fastest';
|
|
19
|
+
row: Row;
|
|
20
|
+
} | {
|
|
21
|
+
kind: 'torrent';
|
|
22
|
+
dontAsk: boolean;
|
|
23
|
+
} | {
|
|
24
|
+
kind: 'space';
|
|
25
|
+
reason: string;
|
|
26
|
+
};
|
|
27
|
+
type Starting = {
|
|
28
|
+
msgId: number;
|
|
29
|
+
askedName?: string;
|
|
30
|
+
downloadId?: string;
|
|
31
|
+
silence?: number;
|
|
32
|
+
};
|
|
33
|
+
type Picker = {
|
|
34
|
+
path: string[];
|
|
35
|
+
folders: string[] | null;
|
|
36
|
+
msgId: number;
|
|
37
|
+
error?: string;
|
|
38
|
+
newName: string | null;
|
|
39
|
+
};
|
|
40
|
+
type Player = {
|
|
41
|
+
src: string;
|
|
42
|
+
name: string;
|
|
43
|
+
downloadId: string;
|
|
44
|
+
mime?: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Remote Fetch: paste a link or a magnet, or drop a `.torrent`, and the node
|
|
48
|
+
* downloads it into its own download folder.
|
|
49
|
+
*
|
|
50
|
+
* Two forms, one component. **Embedded** in the SFTP browser (`compact`), it
|
|
51
|
+
* shares the host's channel, which forwards it the `Download*` frames through
|
|
52
|
+
* `receive()`, and saves into the folder on screen when the node can map it.
|
|
53
|
+
* **Standalone**, it builds its own channel, signs in with `token`, and saves
|
|
54
|
+
* into the download folder or a sub-folder of it. Either way it never asks for
|
|
55
|
+
* a login: the node writes its own files.
|
|
56
|
+
*
|
|
57
|
+
* The widget only sends events and shows progress. Downloads run on the node
|
|
58
|
+
* and carry on after the tab closes.
|
|
59
|
+
*/
|
|
60
|
+
export declare class PhirepassDownloader {
|
|
61
|
+
el: HTMLElement;
|
|
62
|
+
private ownChannel;
|
|
63
|
+
private msgId;
|
|
64
|
+
private noticeId;
|
|
65
|
+
private seenNotices;
|
|
66
|
+
private torrentAcked;
|
|
67
|
+
private noticeTimers;
|
|
68
|
+
private whereMsgId?;
|
|
69
|
+
nodeId: string;
|
|
70
|
+
/** What to call the node in sentences; the id is a uuid nobody reads. */
|
|
71
|
+
nodeLabel?: string;
|
|
72
|
+
/** Session token, for the standalone form. Not needed when `channel` is given. */
|
|
73
|
+
token?: string;
|
|
74
|
+
/**
|
|
75
|
+
* A channel to share instead of opening one: the SFTP client passes its
|
|
76
|
+
* own. The host must forward `Download*` frames (and `Error`s whose
|
|
77
|
+
* `msg_id` is at or above `DOWNLOADER_MSG_ID_BASE`) to `receive()`, and set
|
|
78
|
+
* `connected` once the channel is authenticated.
|
|
79
|
+
*/
|
|
80
|
+
channel?: DownloadChannelLike;
|
|
81
|
+
/** With an injected `channel`: whether it is authenticated and usable. */
|
|
82
|
+
connected: boolean;
|
|
83
|
+
/** Builds the channel in place of a WebSocket, for demos and tests (see `ChannelFactory`). */
|
|
84
|
+
channelFactory?: DownloadChannelFactory;
|
|
85
|
+
/** The SFTP/SSH service the host is browsing, so the node can map `browsingPath`. */
|
|
86
|
+
browsingService?: string;
|
|
87
|
+
/** The folder on screen in the host. Downloads land here when it lies inside the download folder. */
|
|
88
|
+
browsingPath?: string;
|
|
89
|
+
/** The drawer layout used inside the SFTP browser. */
|
|
90
|
+
compact: boolean;
|
|
91
|
+
/** Base URL for `/api/web/stream/…`. Defaults to the server the channel talks to. */
|
|
92
|
+
streamBase?: string;
|
|
93
|
+
/** Whether the viewer may configure this node, which only changes advice text (B9). */
|
|
94
|
+
canConfigure: boolean;
|
|
95
|
+
/** Open the built-in player on Play, unless a `phirepassPlay` listener calls `preventDefault()`. */
|
|
96
|
+
inlinePlayer: boolean;
|
|
97
|
+
serverHost: string;
|
|
98
|
+
serverPort: number;
|
|
99
|
+
serverId?: string;
|
|
100
|
+
allowInsecure: boolean;
|
|
101
|
+
heartbeatInterval: number;
|
|
102
|
+
/** A finished download, once per job. The SFTP client refreshes when it lands in the open folder. */
|
|
103
|
+
fetchCompleted: EventEmitter<{
|
|
104
|
+
download_id: string;
|
|
105
|
+
dest_root: string;
|
|
106
|
+
sub_dir: string | null;
|
|
107
|
+
name: string;
|
|
108
|
+
}>;
|
|
109
|
+
/** Play was pressed. Cancelable: prevent it to open your own player instead. */
|
|
110
|
+
play: EventEmitter<{
|
|
111
|
+
src: string;
|
|
112
|
+
name: string;
|
|
113
|
+
downloadId: string;
|
|
114
|
+
}>;
|
|
115
|
+
/** How many downloads are running, for a badge. */
|
|
116
|
+
activeCount: EventEmitter<{
|
|
117
|
+
n: number;
|
|
118
|
+
}>;
|
|
119
|
+
/** “Show in folder” on a finished row. */
|
|
120
|
+
showInFolder: EventEmitter<{
|
|
121
|
+
path: string;
|
|
122
|
+
name: string;
|
|
123
|
+
}>;
|
|
124
|
+
/** “Open node settings” (B9, no folder). */
|
|
125
|
+
openNodeSettings: EventEmitter<{
|
|
126
|
+
nodeId: string;
|
|
127
|
+
}>;
|
|
128
|
+
/** “Sign in” (X3). */
|
|
129
|
+
signIn: EventEmitter<void>;
|
|
130
|
+
connection: Connection;
|
|
131
|
+
caps: FetchCaps | null;
|
|
132
|
+
jobs: JobMap;
|
|
133
|
+
tab: Tab;
|
|
134
|
+
drawerOpen: boolean;
|
|
135
|
+
dialogOpen: boolean;
|
|
136
|
+
unread: number;
|
|
137
|
+
form: FormState;
|
|
138
|
+
where: {
|
|
139
|
+
saves_to: string;
|
|
140
|
+
mapped: boolean;
|
|
141
|
+
} | null;
|
|
142
|
+
starting: Starting | null;
|
|
143
|
+
refusal: Note | null;
|
|
144
|
+
confirm: Confirm | null;
|
|
145
|
+
notices: Notice[];
|
|
146
|
+
subDir: string | null;
|
|
147
|
+
picker: Picker | null;
|
|
148
|
+
player: Player | null;
|
|
149
|
+
private get name();
|
|
150
|
+
private get ch();
|
|
151
|
+
private ownedChannel?;
|
|
152
|
+
componentWillLoad(): Promise<void>;
|
|
153
|
+
disconnectedCallback(): void;
|
|
154
|
+
onChannel(): void;
|
|
155
|
+
onConnected(now: boolean, before: boolean): void;
|
|
156
|
+
onBrowsing(): void;
|
|
157
|
+
onNode(now: string, before: string): void;
|
|
158
|
+
private adoptChannel;
|
|
159
|
+
private endpoint;
|
|
160
|
+
private defaultStreamBase;
|
|
161
|
+
private openOwnChannel;
|
|
162
|
+
private reconnect;
|
|
163
|
+
/**
|
|
164
|
+
* Hands this widget a frame from a shared channel: `Download*` frames, and
|
|
165
|
+
* `Error`s answering one of its `msg_id`s. Anything else is ignored.
|
|
166
|
+
*/
|
|
167
|
+
receive(msg: ProtocolMessage | {
|
|
168
|
+
data: {
|
|
169
|
+
web: unknown;
|
|
170
|
+
};
|
|
171
|
+
}): Promise<void>;
|
|
172
|
+
private dispatch;
|
|
173
|
+
private handleError;
|
|
174
|
+
private subscribe;
|
|
175
|
+
private onProgress;
|
|
176
|
+
private onAccepted;
|
|
177
|
+
/** The server took it but the node has not spoken: it is offline, and the row says it waits. */
|
|
178
|
+
private nodeSilent;
|
|
179
|
+
private onFirstProgress;
|
|
180
|
+
private clearStarting;
|
|
181
|
+
private emitCount;
|
|
182
|
+
private notify;
|
|
183
|
+
private dismiss;
|
|
184
|
+
private showRetrying;
|
|
185
|
+
/** Opens the Fetch dialog (and the drawer behind it). `path` updates the folder on screen. */
|
|
186
|
+
openFetch(path?: string): Promise<void>;
|
|
187
|
+
/** Opens or closes the drawer (embedded). */
|
|
188
|
+
toggleDrawer(open?: boolean): Promise<void>;
|
|
189
|
+
/** The running download whose part file this is, so the SFTP client can offer K3 instead of a plain delete. */
|
|
190
|
+
jobForPath(path: string): Promise<{
|
|
191
|
+
download_id: string;
|
|
192
|
+
name: string;
|
|
193
|
+
} | null>;
|
|
194
|
+
/** Deletes a download (an unfinished one always loses its part file). */
|
|
195
|
+
deleteDownload(downloadId: string, deleteFile?: boolean): Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
* The path of a `.torrent` on the node relative to the download folder, or
|
|
198
|
+
* null when it lies outside it (then C's menu item is not offered).
|
|
199
|
+
*/
|
|
200
|
+
torrentPathFor(path: string): Promise<string | null>;
|
|
201
|
+
/** C: download the contents of a `.torrent` already on the node, into the folder it sits in. */
|
|
202
|
+
startTorrentPath(path: string, inOrder?: boolean): Promise<boolean>;
|
|
203
|
+
private nextMsgId;
|
|
204
|
+
private browsing;
|
|
205
|
+
private askWhere;
|
|
206
|
+
private destination;
|
|
207
|
+
private formReady;
|
|
208
|
+
private pickTorrent;
|
|
209
|
+
private start;
|
|
210
|
+
private closeDialog;
|
|
211
|
+
private sendStop;
|
|
212
|
+
private sendDelete;
|
|
213
|
+
private actions;
|
|
214
|
+
private sendOrder;
|
|
215
|
+
private playRow;
|
|
216
|
+
private clearFinished;
|
|
217
|
+
private canPickFolder;
|
|
218
|
+
private listFolders;
|
|
219
|
+
private savePicker;
|
|
220
|
+
private renderConfirm;
|
|
221
|
+
private renderForm;
|
|
222
|
+
private renderRows;
|
|
223
|
+
private renderStatus;
|
|
224
|
+
private renderCompact;
|
|
225
|
+
private renderStandalone;
|
|
226
|
+
render(): any;
|
|
227
|
+
private playerRow;
|
|
228
|
+
private playerStatus;
|
|
229
|
+
private playerReady;
|
|
230
|
+
}
|
|
231
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { SourceAuth } from '../../common/fetch';
|
|
2
|
+
export type DetectedSource = {
|
|
3
|
+
kind: 'empty';
|
|
4
|
+
} | {
|
|
5
|
+
kind: 'http';
|
|
6
|
+
url: string;
|
|
7
|
+
host: string;
|
|
8
|
+
name: string;
|
|
9
|
+
scheme: 'HTTP' | 'HTTPS';
|
|
10
|
+
}
|
|
11
|
+
/** An HTTP(S) link whose path ends in `.torrent`: fetched as a file, like any link. */
|
|
12
|
+
| {
|
|
13
|
+
kind: 'torrent-url';
|
|
14
|
+
url: string;
|
|
15
|
+
host: string;
|
|
16
|
+
name: string;
|
|
17
|
+
scheme: 'HTTP' | 'HTTPS';
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'magnet';
|
|
20
|
+
uri: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
infoHash?: string;
|
|
23
|
+
} | {
|
|
24
|
+
kind: 'invalid';
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Works out what was pasted into the Fetch field, as the person types.
|
|
28
|
+
*
|
|
29
|
+
* Only `http:`, `https:` and `magnet:` are links here; anything else is
|
|
30
|
+
* `invalid` (B4). The name is a guess for the Save as placeholder and the
|
|
31
|
+
* “Saved under another name” notice. The node has the last word.
|
|
32
|
+
*/
|
|
33
|
+
export declare function detectSource(text: string): DetectedSource;
|
|
34
|
+
/** Short form of a magnet for a row title before its metadata arrives: `magnet:?xt=urn:btih:9f2c…a41e`. */
|
|
35
|
+
export declare function shortMagnet(uri: string): string;
|
|
36
|
+
export type TorrentFileCheck = {
|
|
37
|
+
ok: boolean;
|
|
38
|
+
reason?: 'too-large' | 'not-torrent';
|
|
39
|
+
};
|
|
40
|
+
/** Refuses a `.torrent` in the browser, before anything is sent (B6). */
|
|
41
|
+
export declare function checkTorrentFile(file: {
|
|
42
|
+
name: string;
|
|
43
|
+
size: number;
|
|
44
|
+
}): TorrentFileCheck;
|
|
45
|
+
export type AuthForm = {
|
|
46
|
+
mode: 'none' | 'basic' | 'bearer' | 'header';
|
|
47
|
+
username: string;
|
|
48
|
+
password: string;
|
|
49
|
+
token: string;
|
|
50
|
+
headerName: string;
|
|
51
|
+
headerValue: string;
|
|
52
|
+
};
|
|
53
|
+
export declare const EMPTY_AUTH: AuthForm;
|
|
54
|
+
/**
|
|
55
|
+
* Turns the login fields into the `SourceAuth` the node seals, or explains
|
|
56
|
+
* what is missing. `null` with no error means no login.
|
|
57
|
+
*/
|
|
58
|
+
export declare function buildSourceAuth(form: AuthForm): {
|
|
59
|
+
auth: SourceAuth | null;
|
|
60
|
+
error?: string;
|
|
61
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Row } from '../jobs';
|
|
2
|
+
export declare const Modal: ({ label, onClose, wide }: {
|
|
3
|
+
label: string;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
wide?: boolean;
|
|
6
|
+
}, children: any) => any;
|
|
7
|
+
type ConfirmBase = {
|
|
8
|
+
onCancel: () => void;
|
|
9
|
+
onConfirm: () => void;
|
|
10
|
+
};
|
|
11
|
+
/** K1: ✕ on an unfinished row. Unticked → Stopped (resumable); ticked → Cancelled. */
|
|
12
|
+
export declare const ConfirmStop: ({ row, discard, onDiscard, ...b }: {
|
|
13
|
+
row: Row;
|
|
14
|
+
discard: boolean;
|
|
15
|
+
onDiscard: (v: boolean) => void;
|
|
16
|
+
} & ConfirmBase) => any;
|
|
17
|
+
/** K8: Delete on a finished, stopped or seeding row. */
|
|
18
|
+
export declare const ConfirmDelete: ({ row, deleteFile, onDeleteFile, nodeName, ...b }: {
|
|
19
|
+
row: Row;
|
|
20
|
+
deleteFile: boolean;
|
|
21
|
+
onDeleteFile: (v: boolean) => void;
|
|
22
|
+
nodeName: string;
|
|
23
|
+
} & ConfirmBase) => any;
|
|
24
|
+
/** K9: switching a torrent that is playing to Fastest stops playback. */
|
|
25
|
+
export declare const ConfirmFastest: ({ row, ...b }: {
|
|
26
|
+
row: Row;
|
|
27
|
+
} & ConfirmBase) => any;
|
|
28
|
+
/** K2: before the first magnet or .torrent on this browser. */
|
|
29
|
+
export declare const ConfirmTorrent: ({ nodeName, dontAsk, onDontAsk, ...b }: {
|
|
30
|
+
nodeName: string;
|
|
31
|
+
dontAsk: boolean;
|
|
32
|
+
onDontAsk: (v: boolean) => void;
|
|
33
|
+
} & ConfirmBase) => any;
|
|
34
|
+
/** K5: a notice, not a question. The node refused a Start that would not fit. */
|
|
35
|
+
export declare const NoSpace: ({ reason, onClose }: {
|
|
36
|
+
reason: string;
|
|
37
|
+
onClose: () => void;
|
|
38
|
+
}) => any;
|
|
39
|
+
/** H6: folders inside the node's download folder, listed by the agent. */
|
|
40
|
+
export declare const FolderPicker: (p: {
|
|
41
|
+
root: string;
|
|
42
|
+
path: string[];
|
|
43
|
+
folders: string[] | null;
|
|
44
|
+
error?: string;
|
|
45
|
+
newName: string | null;
|
|
46
|
+
onOpen: (name: string) => void;
|
|
47
|
+
onUp: (depth: number) => void;
|
|
48
|
+
onNewName: (name: string | null) => void;
|
|
49
|
+
onCancel: () => void;
|
|
50
|
+
onSave: () => void;
|
|
51
|
+
}) => any;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { FetchCaps } from '../../../common/fetch';
|
|
2
|
+
import { FormModel, FormState, Note } from '../form';
|
|
3
|
+
import { AuthForm } from '../source';
|
|
4
|
+
export type FetchFormProps = {
|
|
5
|
+
form: FormState;
|
|
6
|
+
model: FormModel;
|
|
7
|
+
caps: FetchCaps | null;
|
|
8
|
+
layout: 'dialog' | 'inline';
|
|
9
|
+
title: string;
|
|
10
|
+
destination: {
|
|
11
|
+
path: string;
|
|
12
|
+
hint?: string;
|
|
13
|
+
} | null;
|
|
14
|
+
starting: boolean;
|
|
15
|
+
refusal: Note | null;
|
|
16
|
+
onChange: (patch: Partial<FormState>) => void;
|
|
17
|
+
/** A change to one login field, merged into the current login (not a render-time copy of it). */
|
|
18
|
+
onAuth: (patch: Partial<AuthForm>) => void;
|
|
19
|
+
onPickTorrent: (file: File) => void;
|
|
20
|
+
onStart: () => void;
|
|
21
|
+
onCancel?: () => void;
|
|
22
|
+
onChooseFolder?: () => void;
|
|
23
|
+
};
|
|
24
|
+
export declare const NoteLine: ({ note }: {
|
|
25
|
+
note: Note;
|
|
26
|
+
}) => any;
|
|
27
|
+
/**
|
|
28
|
+
* The add form: mockup B and its states, used as the SFTP browser's Fetch
|
|
29
|
+
* dialog (`dialog`) and as the top of the standalone downloader (`inline`).
|
|
30
|
+
*/
|
|
31
|
+
export declare const FetchForm: (p: FetchFormProps) => any;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Row } from '../jobs';
|
|
2
|
+
export type RowActions = {
|
|
3
|
+
play: (row: Row) => void;
|
|
4
|
+
pause: (row: Row) => void;
|
|
5
|
+
resume: (row: Row, ignoreWindow?: boolean) => void;
|
|
6
|
+
stop: (row: Row) => void;
|
|
7
|
+
remove: (row: Row) => void;
|
|
8
|
+
setOrder: (row: Row, inOrder: boolean) => void;
|
|
9
|
+
showInFolder: (row: Row) => void;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* One download, in any state (mockups R and R2). Which buttons show is decided
|
|
13
|
+
* by the state alone; what a button sends is the host's business.
|
|
14
|
+
*/
|
|
15
|
+
export declare const JobRow: ({ row, actions, running, source, compact }: {
|
|
16
|
+
row: Row;
|
|
17
|
+
actions: RowActions;
|
|
18
|
+
running: number;
|
|
19
|
+
source?: string;
|
|
20
|
+
compact?: boolean;
|
|
21
|
+
}) => any;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type NoticeKind = 'started' | 'queued' | 'stuck' | 'renamed' | 'completed' | 'error';
|
|
2
|
+
export type Notice = {
|
|
3
|
+
id: number;
|
|
4
|
+
kind: NoticeKind;
|
|
5
|
+
title: string;
|
|
6
|
+
detail: string;
|
|
7
|
+
/** Stays until dismissed (N3); the others leave by themselves. */
|
|
8
|
+
sticky?: boolean;
|
|
9
|
+
action?: {
|
|
10
|
+
label: string;
|
|
11
|
+
run: () => void;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
/** Small, self-dismissing notices at the bottom of the widget (N1–N4, D). */
|
|
15
|
+
export declare const Notices: ({ notices, onDismiss }: {
|
|
16
|
+
notices: Notice[];
|
|
17
|
+
onDismiss: (id: number) => void;
|
|
18
|
+
}) => any;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Blocker } from '../jobs';
|
|
2
|
+
export declare const Empty: ({ icon, title, body, action }: {
|
|
3
|
+
icon: string;
|
|
4
|
+
title: string;
|
|
5
|
+
body: string;
|
|
6
|
+
action?: {
|
|
7
|
+
label: string;
|
|
8
|
+
onClick: () => void;
|
|
9
|
+
};
|
|
10
|
+
}) => any;
|
|
11
|
+
/** X1: embedded drawer with nothing in it. */
|
|
12
|
+
export declare const DrawerEmpty: () => any;
|
|
13
|
+
/** X2: standalone, first open. */
|
|
14
|
+
export declare const StandaloneEmpty: ({ nodeName, folder }: {
|
|
15
|
+
nodeName: string;
|
|
16
|
+
folder: string | null;
|
|
17
|
+
}) => any;
|
|
18
|
+
/** X3: no valid session. */
|
|
19
|
+
export declare const SignedOut: ({ onSignIn }: {
|
|
20
|
+
onSignIn: () => void;
|
|
21
|
+
}) => any;
|
|
22
|
+
/** X4: the node (or the server) cannot be reached. */
|
|
23
|
+
export declare const Unreachable: ({ nodeName, onRetry }: {
|
|
24
|
+
nodeName: string;
|
|
25
|
+
onRetry?: () => void;
|
|
26
|
+
}) => any;
|
|
27
|
+
/** The channel this page loaded predates Remote Fetch. */
|
|
28
|
+
export declare const Unsupported: () => any;
|
|
29
|
+
export declare const Loading: () => any;
|
|
30
|
+
/**
|
|
31
|
+
* Why nothing can be added on this node (B8, B9, L3). Shown in place of the
|
|
32
|
+
* form, in the dialog and in the standalone header alike.
|
|
33
|
+
*/
|
|
34
|
+
export declare const BlockerView: ({ blocker, onAction, onClose }: {
|
|
35
|
+
blocker: Blocker;
|
|
36
|
+
onAction?: () => void;
|
|
37
|
+
onClose?: () => void;
|
|
38
|
+
}) => any;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { EventEmitter } from '../../stencil-public-runtime';
|
|
2
|
+
import { PositionStore, RemotePlaybackLike, StoredPosition } from './player';
|
|
3
|
+
/**
|
|
4
|
+
* What the player is showing. `buffering` is before the first frame;
|
|
5
|
+
* `waiting` is a stall after it (a seek past what the node has, G2).
|
|
6
|
+
*/
|
|
7
|
+
export type PlayerPhase = 'prompt' | 'buffering' | 'playing' | 'waiting' | 'unsupported' | 'stopped' | 'casting';
|
|
8
|
+
/**
|
|
9
|
+
* Plays a file from the node with the browser's own `<video>` or `<audio>`.
|
|
10
|
+
*
|
|
11
|
+
* It knows nothing of channels or WASM: `src` is a stream URL the server turns
|
|
12
|
+
* into stream events towards the agent, and the browser's range requests do
|
|
13
|
+
* the rest. A download that is still arriving plays as far as `ready` bytes;
|
|
14
|
+
* past that the element waits, and so does the player, saying why.
|
|
15
|
+
*/
|
|
16
|
+
export declare class PhirepassMediaPlayer {
|
|
17
|
+
el: HTMLElement;
|
|
18
|
+
private media?;
|
|
19
|
+
private lastSave;
|
|
20
|
+
private resumeAt;
|
|
21
|
+
private everPlayed;
|
|
22
|
+
/** A stored position was offered (G6): then `startAt` plays, not `autoplay`. */
|
|
23
|
+
private positionPrompted;
|
|
24
|
+
private availabilityId?;
|
|
25
|
+
private onRemoteConnect;
|
|
26
|
+
private onRemoteDisconnect;
|
|
27
|
+
/** The stream URL: `/api/web/stream/{node}/{download}/{file}` or a listing token URL. */
|
|
28
|
+
src: string;
|
|
29
|
+
name: string;
|
|
30
|
+
/** Overrides the mime the extension implies. */
|
|
31
|
+
mime?: string;
|
|
32
|
+
/** The status line above the picture, from the job: “Downloading · 23.4%”, “On the node”. */
|
|
33
|
+
status?: string;
|
|
34
|
+
/** Bytes ready from the start of the file, while it is still downloading. */
|
|
35
|
+
ready?: number;
|
|
36
|
+
/** “Continue watching”. Without one, positions stay in this browser. */
|
|
37
|
+
positionStore?: PositionStore;
|
|
38
|
+
/** Key for the stored position: `dl:<download_id>:<file>` or `node:<node_id>:<path>`. */
|
|
39
|
+
positionKey?: string;
|
|
40
|
+
/** Stands in for `video.remote`, for demos and tests (like `channelFactory`). */
|
|
41
|
+
remotePlayback?: RemotePlaybackLike;
|
|
42
|
+
/** Shown while casting, when the host knows the device's name. */
|
|
43
|
+
castDevice?: string;
|
|
44
|
+
playerClose: EventEmitter<void>;
|
|
45
|
+
phase: PlayerPhase;
|
|
46
|
+
stored: StoredPosition | null;
|
|
47
|
+
castAvailable: boolean;
|
|
48
|
+
currentTime: number;
|
|
49
|
+
duration: number;
|
|
50
|
+
private get store();
|
|
51
|
+
private get audio();
|
|
52
|
+
componentWillLoad(): Promise<void>;
|
|
53
|
+
componentDidLoad(): void;
|
|
54
|
+
disconnectedCallback(): void;
|
|
55
|
+
onSrc(): void;
|
|
56
|
+
/** Closes the player, saving where it stopped. The download is not affected. */
|
|
57
|
+
close(): Promise<void>;
|
|
58
|
+
private remote;
|
|
59
|
+
private watchRemote;
|
|
60
|
+
private savePosition;
|
|
61
|
+
private startAt;
|
|
62
|
+
private retry;
|
|
63
|
+
private onError;
|
|
64
|
+
private bindMedia;
|
|
65
|
+
private renderStage;
|
|
66
|
+
render(): any;
|
|
67
|
+
}
|