phirepass-widgets 0.0.112 → 0.0.113
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-CurErEK7.js} +101 -30
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/phirepass-downloader_3.cjs.entry.js +3696 -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-COvteaUJ.js → protocol-DCBMfc2u.js} +557 -360
- package/dist/collection/collection-manifest.json +3 -1
- package/dist/collection/common/channel.js +21 -1
- package/dist/collection/common/fetch.js +40 -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 +370 -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 +106 -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-C4cmk3bS.js +1 -0
- package/dist/components/p-CsYQJXY2.js +1 -0
- package/dist/components/p-D6Geq8Rn.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-B9qUl6FW.js} +101 -30
- package/dist/esm/loader.js +3 -3
- package/dist/esm/phirepass-downloader_3.entry.js +3692 -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-Dur4cBX7.js → protocol-CsYQJXY2.js} +556 -359
- package/dist/phirepass-widgets/p-1b84c526.entry.js +1 -0
- package/dist/phirepass-widgets/{p-1fef5b5f.entry.js → p-41dd1ac9.entry.js} +2 -2
- package/dist/phirepass-widgets/p-614ab3de.entry.js +1 -0
- package/dist/phirepass-widgets/p-B9qUl6FW.js +3 -0
- package/dist/phirepass-widgets/p-CsYQJXY2.js +1 -0
- 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 +161 -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 +115 -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/components/p-Dur4cBX7.js +0 -1
- package/dist/esm/phirepass-sftp-client.entry.js +0 -1467
- 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,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remote Fetch: the browser side of `common/src/protocol/fetch.rs` and the
|
|
3
|
+
* `Download*` web frames (codes 56–68).
|
|
4
|
+
*
|
|
5
|
+
* Shapes follow serde's defaults as the WASM channel hands them to JS: unit
|
|
6
|
+
* enums by name, data-carrying enums externally tagged (`{ Http: { … } }`).
|
|
7
|
+
* Unit enums that may grow end in `Unknown`, as on the Rust side, so a newer
|
|
8
|
+
* server never breaks an older widget.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* `msg_id`s `<phirepass-downloader>` mints start here, so a host sharing its
|
|
12
|
+
* channel (the SFTP client) can tell which `Error` frames to hand over
|
|
13
|
+
* without bookkeeping. `msg_id` is a u32 on the wire.
|
|
14
|
+
*/
|
|
15
|
+
export declare const DOWNLOADER_MSG_ID_BASE = 1073741824;
|
|
16
|
+
/** Largest `.torrent` accepted from the browser. Mirrors `FETCH_TORRENT_MAX_BYTES`. */
|
|
17
|
+
export declare const FETCH_TORRENT_MAX_BYTES: number;
|
|
18
|
+
export type FetchSource = {
|
|
19
|
+
Http: {
|
|
20
|
+
url: string;
|
|
21
|
+
save_as: string | null;
|
|
22
|
+
};
|
|
23
|
+
} | {
|
|
24
|
+
Magnet: {
|
|
25
|
+
uri: string;
|
|
26
|
+
};
|
|
27
|
+
} | {
|
|
28
|
+
TorrentFile: {
|
|
29
|
+
name: string;
|
|
30
|
+
contents: Uint8Array;
|
|
31
|
+
};
|
|
32
|
+
} | {
|
|
33
|
+
TorrentPath: {
|
|
34
|
+
path: string;
|
|
35
|
+
};
|
|
36
|
+
} | {
|
|
37
|
+
Node: {
|
|
38
|
+
from_node: string;
|
|
39
|
+
offer_id: string;
|
|
40
|
+
name: string;
|
|
41
|
+
size: number;
|
|
42
|
+
sha256: Uint8Array;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export type Browsing = {
|
|
46
|
+
service_id: string;
|
|
47
|
+
path: string;
|
|
48
|
+
};
|
|
49
|
+
export type FetchTarget = {
|
|
50
|
+
sub_dir: string | null;
|
|
51
|
+
browsing: Browsing | null;
|
|
52
|
+
};
|
|
53
|
+
export type SourceAuth = {
|
|
54
|
+
Basic: {
|
|
55
|
+
username: string;
|
|
56
|
+
password: string;
|
|
57
|
+
};
|
|
58
|
+
} | {
|
|
59
|
+
Bearer: {
|
|
60
|
+
token: string;
|
|
61
|
+
};
|
|
62
|
+
} | {
|
|
63
|
+
Header: {
|
|
64
|
+
name: string;
|
|
65
|
+
value: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
export type FetchOptions = {
|
|
69
|
+
source_auth: SourceAuth | null;
|
|
70
|
+
ignore_window: boolean;
|
|
71
|
+
};
|
|
72
|
+
export type FetchKind = 'Http' | 'Torrent' | 'Node' | 'Unknown';
|
|
73
|
+
export type PauseReason = 'Window' | 'DiskFull' | 'Unknown';
|
|
74
|
+
export type FetchLock = 'None' | 'Organisation' | 'NoFolder' | 'Unknown';
|
|
75
|
+
export type FetchState = 'Queued' | 'Scheduled' | 'Resolving' | 'FetchingMetadata' | 'Downloading' | 'Verifying' | 'Paused' | 'Retrying' | 'Seeding' | 'Completed' | 'Stopped' | 'Cancelled' | 'Deleted' | 'Unknown';
|
|
76
|
+
export type FetchFile = {
|
|
77
|
+
index: number;
|
|
78
|
+
name: string;
|
|
79
|
+
size: number;
|
|
80
|
+
done_bytes: number;
|
|
81
|
+
media: boolean;
|
|
82
|
+
/** Contiguous bytes from offset 0: how far a player can read without waiting. */
|
|
83
|
+
ready_from_start: number;
|
|
84
|
+
};
|
|
85
|
+
export type FetchJob = {
|
|
86
|
+
download_id: string;
|
|
87
|
+
kind: FetchKind;
|
|
88
|
+
name: string;
|
|
89
|
+
dest_root: string;
|
|
90
|
+
sub_dir: string | null;
|
|
91
|
+
state: FetchState;
|
|
92
|
+
done_bytes: number;
|
|
93
|
+
total_bytes: number | null;
|
|
94
|
+
down_bps: number;
|
|
95
|
+
up_bps: number;
|
|
96
|
+
peers: number;
|
|
97
|
+
in_order: boolean;
|
|
98
|
+
/** Unix ms. */
|
|
99
|
+
started_at: number;
|
|
100
|
+
finished_at: number | null;
|
|
101
|
+
reason: string | null;
|
|
102
|
+
requested_by: string | null;
|
|
103
|
+
files: FetchFile[];
|
|
104
|
+
up_total: number;
|
|
105
|
+
pause_reason: PauseReason | null;
|
|
106
|
+
seeding_since: number | null;
|
|
107
|
+
info_hash: string | null;
|
|
108
|
+
retry_reason: string | null;
|
|
109
|
+
attempt: number;
|
|
110
|
+
next_attempt_at: number | null;
|
|
111
|
+
restarted_from_zero: boolean;
|
|
112
|
+
};
|
|
113
|
+
export type FetchCaps = {
|
|
114
|
+
http: boolean;
|
|
115
|
+
torrents: boolean;
|
|
116
|
+
private_targets: boolean;
|
|
117
|
+
max_active: number;
|
|
118
|
+
lock: FetchLock;
|
|
119
|
+
folder: string | null;
|
|
120
|
+
folder_free_bytes: number;
|
|
121
|
+
agent_supported: boolean;
|
|
122
|
+
};
|
|
123
|
+
export type SubscribeScope = {
|
|
124
|
+
Node: string;
|
|
125
|
+
} | 'All';
|
|
126
|
+
export type ProtocolMessageWebDownloadProgress = {
|
|
127
|
+
type: 'DownloadProgress';
|
|
128
|
+
node_id: string;
|
|
129
|
+
job: FetchJob;
|
|
130
|
+
};
|
|
131
|
+
export type ProtocolMessageWebDownloadAccepted = {
|
|
132
|
+
type: 'DownloadAccepted';
|
|
133
|
+
msg_id: number;
|
|
134
|
+
download_id: string;
|
|
135
|
+
};
|
|
136
|
+
export type ProtocolMessageWebDownloadWhereAnswer = {
|
|
137
|
+
type: 'DownloadWhereAnswer';
|
|
138
|
+
msg_id: number;
|
|
139
|
+
saves_to: string;
|
|
140
|
+
mapped: boolean;
|
|
141
|
+
};
|
|
142
|
+
export type ProtocolMessageWebDownloadCaps = {
|
|
143
|
+
type: 'DownloadCaps';
|
|
144
|
+
node_id: string;
|
|
145
|
+
caps: FetchCaps;
|
|
146
|
+
};
|
|
147
|
+
export type ProtocolMessageWebDownloadFoldersAnswer = {
|
|
148
|
+
type: 'DownloadFoldersAnswer';
|
|
149
|
+
msg_id: number;
|
|
150
|
+
folders: string[];
|
|
151
|
+
};
|
|
152
|
+
export type ProtocolMessageWebDownload = ProtocolMessageWebDownloadProgress | ProtocolMessageWebDownloadAccepted | ProtocolMessageWebDownloadWhereAnswer | ProtocolMessageWebDownloadCaps | ProtocolMessageWebDownloadFoldersAnswer;
|
|
153
|
+
/** True for the frames a host should hand to `<phirepass-downloader>`. */
|
|
154
|
+
export declare function isDownloadFrame(web: {
|
|
155
|
+
type: string;
|
|
156
|
+
}): web is ProtocolMessageWebDownload;
|
|
157
|
+
/**
|
|
158
|
+
* Header names a link login may not set: they belong to the transfer itself or
|
|
159
|
+
* to the connection, and the agent refuses them too.
|
|
160
|
+
*/
|
|
161
|
+
export declare const DENIED_AUTH_HEADERS: Set<string>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { FetchCaps, FetchOptions, FetchSource } from '../../common/fetch';
|
|
2
|
+
import { AuthForm, DetectedSource } from './source';
|
|
3
|
+
export type ChosenTorrent = {
|
|
4
|
+
name: string;
|
|
5
|
+
size: number;
|
|
6
|
+
contents?: Uint8Array;
|
|
7
|
+
error?: 'too-large' | 'not-torrent';
|
|
8
|
+
};
|
|
9
|
+
export type FormState = {
|
|
10
|
+
text: string;
|
|
11
|
+
saveAs: string;
|
|
12
|
+
torrent: ChosenTorrent | null;
|
|
13
|
+
/** For a torrent: nothing until the person picks (plan: neither is preselected). */
|
|
14
|
+
order: 'in' | 'fast' | null;
|
|
15
|
+
auth: AuthForm;
|
|
16
|
+
authOpen: boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare const EMPTY_FORM: FormState;
|
|
19
|
+
export type Note = {
|
|
20
|
+
tone: 'err' | 'warn' | 'info';
|
|
21
|
+
title: string;
|
|
22
|
+
body: string;
|
|
23
|
+
};
|
|
24
|
+
export type FormModel = {
|
|
25
|
+
detected: DetectedSource;
|
|
26
|
+
isTorrent: boolean;
|
|
27
|
+
/** True when the In order / Fastest choice is shown (and required). */
|
|
28
|
+
needsOrder: boolean;
|
|
29
|
+
showSaveAs: boolean;
|
|
30
|
+
showAuth: boolean;
|
|
31
|
+
note: Note | null;
|
|
32
|
+
canStart: boolean;
|
|
33
|
+
/** The name the person expects, for “Saved under another name”. */
|
|
34
|
+
askedName?: string;
|
|
35
|
+
/** What is wrong with the link login, once something has been typed into it. */
|
|
36
|
+
authError?: string;
|
|
37
|
+
};
|
|
38
|
+
export declare function chooseTorrent(file: {
|
|
39
|
+
name: string;
|
|
40
|
+
size: number;
|
|
41
|
+
}): ChosenTorrent;
|
|
42
|
+
/**
|
|
43
|
+
* Everything the Fetch dialog shows that follows from what was typed or
|
|
44
|
+
* chosen: which fields appear, which note (B4–B7), and whether Start works.
|
|
45
|
+
* `ready` is false while the dialog still waits on something outside the form
|
|
46
|
+
* (where the file will land, or the Start already in flight).
|
|
47
|
+
*/
|
|
48
|
+
export declare function formModel(form: FormState, caps: FetchCaps | null, ready: boolean): FormModel;
|
|
49
|
+
/** The `FetchSource`, order and options a valid form starts. */
|
|
50
|
+
export declare function buildStart(form: FormState): {
|
|
51
|
+
source: FetchSource;
|
|
52
|
+
inOrder: boolean;
|
|
53
|
+
options: FetchOptions;
|
|
54
|
+
} | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** `356 MB`, `4.31 GB`, `2 KB`. Decimal units, as the mockups and disk tools use. */
|
|
2
|
+
export declare function formatBytes(bytes: number | null | undefined): string;
|
|
3
|
+
/** `↓ 11.8 MB/s`. A rate of zero shows nothing worth reading, so it returns ''. */
|
|
4
|
+
export declare function formatRate(bps: number, arrow?: '↓' | '↑'): string;
|
|
5
|
+
/** `48s`, `3m 40s`, `12m`, `2h 5m`. */
|
|
6
|
+
export declare function formatDuration(totalSeconds: number): string;
|
|
7
|
+
/** Time left at the current rate, or '' when it cannot be told. */
|
|
8
|
+
export declare function formatEta(done: number, total: number | null, bps: number): string;
|
|
9
|
+
/** `38.7%`. One decimal under 100, none at 100. */
|
|
10
|
+
export declare function formatPercent(done: number, total: number | null): string;
|
|
11
|
+
export declare function percent(done: number, total: number | null): number;
|
|
12
|
+
/** Media clock: `2:31`, `1:02:09`. */
|
|
13
|
+
export declare function formatClock(seconds: number): string;
|
|
14
|
+
/** `today 21:52`, `yesterday 09:10`, `13 Nov 21:52`. */
|
|
15
|
+
export declare function formatWhen(ms: number | null, now?: number): string;
|
|
16
|
+
/** `13 Nov`. */
|
|
17
|
+
export declare function formatDay(ms: number): string;
|
|
@@ -0,0 +1,115 @@
|
|
|
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 (a Delete sent but not yet confirmed).
|
|
5
|
+
*/
|
|
6
|
+
export type Row = FetchJob & {
|
|
7
|
+
deleting?: boolean;
|
|
8
|
+
/** Accepted by the server, but the node has not reported it yet (it may be offline). */
|
|
9
|
+
waitingForNode?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type JobMap = Record<string, Row>;
|
|
12
|
+
export declare function isFinished(state: FetchState): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Folds one `DownloadProgress` into the rows.
|
|
15
|
+
*
|
|
16
|
+
* `completed` is set only the first time a job reaches Completed or Seeding
|
|
17
|
+
* from anything else: a re-sent Completed (after a reconnect, or the snapshot a
|
|
18
|
+
* fresh subscription gets) is not a second completion. A job first seen already
|
|
19
|
+
* finished is not one either. `Deleted` removes the row.
|
|
20
|
+
*/
|
|
21
|
+
export declare function applyProgress(prev: JobMap, job: FetchJob): {
|
|
22
|
+
jobs: JobMap;
|
|
23
|
+
completed?: FetchJob;
|
|
24
|
+
first: boolean;
|
|
25
|
+
};
|
|
26
|
+
export type Tab = 'active' | 'finished' | 'retrying';
|
|
27
|
+
export declare function tabOf(row: Row): Tab;
|
|
28
|
+
/**
|
|
29
|
+
* Jobs working towards their bytes: what the badge and “N active” count.
|
|
30
|
+
* A Retrying job is waiting out its backoff, so it is not counted (mockup A
|
|
31
|
+
* shows 3 active beside a retrying row); it has its own tab instead.
|
|
32
|
+
*/
|
|
33
|
+
export declare function isRunning(row: Row): boolean;
|
|
34
|
+
/** Rows “Clear finished” deletes: Completed and Cancelled, never a seeding torrent. */
|
|
35
|
+
export declare function isClearable(row: Row): boolean;
|
|
36
|
+
/** Active work first, newest first within a state; finished rows by when they finished. */
|
|
37
|
+
export declare function sortRows(rows: Row[]): Row[];
|
|
38
|
+
export declare function summarize(rows: Row[]): {
|
|
39
|
+
active: number;
|
|
40
|
+
downBps: number;
|
|
41
|
+
done: number;
|
|
42
|
+
total: number;
|
|
43
|
+
percent: number | null;
|
|
44
|
+
};
|
|
45
|
+
export declare function isMediaName(name: string): boolean;
|
|
46
|
+
export declare function isAudioName(name: string): boolean;
|
|
47
|
+
/** The file a player opens: the largest media file, which is the one the in-order reader follows. */
|
|
48
|
+
export declare function mediaFile(row: Row): FetchFile | null;
|
|
49
|
+
export type PlayCheck = {
|
|
50
|
+
play: boolean;
|
|
51
|
+
file: FetchFile | null;
|
|
52
|
+
switchToInOrder: boolean;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Play appears only for video or audio whose size is known and whose download
|
|
56
|
+
* is finished or in order. A Fastest torrent offers “Switch to in order to
|
|
57
|
+
* watch” instead; the server refuses its stream anyway (409).
|
|
58
|
+
*/
|
|
59
|
+
export declare function playCheck(row: Row): PlayCheck;
|
|
60
|
+
export declare function streamUrl(base: string, nodeId: string, downloadId: string, fileIndex: number): string;
|
|
61
|
+
export declare function joinPath(...parts: Array<string | null | undefined>): string;
|
|
62
|
+
export declare function folderOf(row: Pick<FetchJob, 'dest_root' | 'sub_dir'>): string;
|
|
63
|
+
/** The path of a running link download's part file, as the SFTP listing shows it. */
|
|
64
|
+
export declare function partPath(row: Row): string;
|
|
65
|
+
export type Pill = {
|
|
66
|
+
text: string;
|
|
67
|
+
tone: 'dl' | 'meta' | 'mv' | 'ok' | 'err' | 'ps' | 'q' | 'sd';
|
|
68
|
+
};
|
|
69
|
+
export declare function statePill(row: Row): Pill;
|
|
70
|
+
/** The second pill on a torrent row: which order it downloads in. */
|
|
71
|
+
export declare function orderPill(row: Row): string | null;
|
|
72
|
+
export type Stat = {
|
|
73
|
+
text: string;
|
|
74
|
+
strong?: boolean;
|
|
75
|
+
error?: boolean;
|
|
76
|
+
};
|
|
77
|
+
/** The stats line under a row's bar, state by state, as mockups R and R2 draw it. */
|
|
78
|
+
export declare function statsLine(row: Row, ctx?: {
|
|
79
|
+
now?: number;
|
|
80
|
+
running?: number;
|
|
81
|
+
source?: string;
|
|
82
|
+
}): Stat[];
|
|
83
|
+
/** The line under a finished row in the standalone Finished tab (H4). */
|
|
84
|
+
export declare function finishedLine(row: Row, now?: number): string;
|
|
85
|
+
/** Default longest retry wait (node setting “Longest retry wait”). */
|
|
86
|
+
export declare const RETRY_MAX_SECS = 3600;
|
|
87
|
+
/**
|
|
88
|
+
* How long a job has been retrying, from its attempt count: 10 s doubling,
|
|
89
|
+
* capped at the node's longest wait. It ignores jitter and time spent
|
|
90
|
+
* downloading between attempts, which only makes it later, never earlier.
|
|
91
|
+
*/
|
|
92
|
+
export declare function retryingForSecs(attempt: number, maxSecs?: number): number;
|
|
93
|
+
export declare const STUCK_AFTER_SECS: number;
|
|
94
|
+
export declare function isStuck(row: Row, maxSecs?: number): boolean;
|
|
95
|
+
/** True when the node saved under another name than the one asked for (N4). */
|
|
96
|
+
export declare function renamedByNode(asked: string | undefined, used: string): boolean;
|
|
97
|
+
export type Blocker = {
|
|
98
|
+
id: 'too-old' | 'off' | 'blocked' | 'no-folder';
|
|
99
|
+
title: string;
|
|
100
|
+
body: string;
|
|
101
|
+
secondary?: string;
|
|
102
|
+
action?: string;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Why nothing can be started on this node, if anything stops it (B8, B9, L3).
|
|
106
|
+
* Order matters: an agent too old to download is the first thing to fix, an
|
|
107
|
+
* organisation block outranks the node's own switch.
|
|
108
|
+
*/
|
|
109
|
+
export declare function blockerFor(caps: FetchCaps, nodeName: string, canConfigure: boolean): Blocker | null;
|
|
110
|
+
/**
|
|
111
|
+
* Whether a Cancelled reason is the node's free-space check (K5), which gets
|
|
112
|
+
* its own dialog. The node words it as “needs X … has Y free” or “not enough
|
|
113
|
+
* space”; until the protocol carries a code for it, the wording decides.
|
|
114
|
+
*/
|
|
115
|
+
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 {};
|