phirepass-widgets 0.0.117 → 0.0.118
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 +1 -12
- package/dist/cjs/{index-DehquNXP.js → index-C3v5xmUo.js} +2 -74
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/phirepass-rdp.cjs.entry.js +5 -16
- package/dist/cjs/phirepass-sftp-client.cjs.entry.js +1470 -0
- package/dist/cjs/phirepass-terminal.cjs.entry.js +4 -4
- package/dist/cjs/phirepass-widgets.cjs.js +2 -2
- package/dist/cjs/{protocol-BjOgJZ9-.js → protocol-DCBMfc2u.js} +21 -277
- package/dist/collection/collection-manifest.json +0 -2
- package/dist/collection/common/channel.js +1 -21
- package/dist/collection/components/phirepass-rdp/phirepass-rdp.js +13 -36
- package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.css +0 -122
- package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.js +31 -181
- package/dist/collection/components/phirepass-terminal/phirepass-terminal.js +2 -2
- package/dist/collection/phirepass-channel_bg.wasm +0 -0
- package/dist/components/index.js +1 -1
- package/dist/components/p-CsYQJXY2.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 +5 -5
- package/dist/esm/{index-BinptKL7.js → index-BVOulYtW.js} +2 -74
- package/dist/esm/loader.js +3 -3
- package/dist/esm/phirepass-rdp.entry.js +5 -16
- package/dist/esm/phirepass-sftp-client.entry.js +1468 -0
- package/dist/esm/phirepass-terminal.entry.js +4 -4
- package/dist/esm/phirepass-widgets.js +3 -3
- package/dist/esm/{protocol-BekUePpu.js → protocol-CsYQJXY2.js} +20 -276
- package/dist/phirepass-widgets/{p-9e6f9220.entry.js → p-7ea2fdbc.entry.js} +5 -5
- package/dist/phirepass-widgets/p-BVOulYtW.js +3 -0
- package/dist/phirepass-widgets/p-CsYQJXY2.js +1 -0
- package/dist/phirepass-widgets/p-c1c616ca.entry.js +1 -0
- package/dist/phirepass-widgets/p-f1bc04a8.entry.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 +0 -30
- package/dist/types/components/phirepass-rdp/phirepass-rdp.d.ts +0 -10
- package/dist/types/components/phirepass-sftp-client/phirepass-sftp-client.d.ts +0 -30
- package/dist/types/components.d.ts +34 -434
- package/package.json +4 -18
- package/dist/cjs/phirepass-downloader_3.cjs.entry.js +0 -3823
- package/dist/collection/common/fetch.js +0 -44
- package/dist/collection/components/phirepass-downloader/form.js +0 -69
- package/dist/collection/components/phirepass-downloader/format.js +0 -105
- package/dist/collection/components/phirepass-downloader/jobs.js +0 -393
- package/dist/collection/components/phirepass-downloader/phirepass-downloader.css +0 -1109
- package/dist/collection/components/phirepass-downloader/phirepass-downloader.js +0 -1466
- package/dist/collection/components/phirepass-downloader/source.js +0 -120
- package/dist/collection/components/phirepass-downloader/views/dialogs.js +0 -34
- package/dist/collection/components/phirepass-downloader/views/fetch-form.js +0 -65
- package/dist/collection/components/phirepass-downloader/views/icons.js +0 -34
- package/dist/collection/components/phirepass-downloader/views/job-row.js +0 -91
- package/dist/collection/components/phirepass-downloader/views/notices.js +0 -15
- package/dist/collection/components/phirepass-downloader/views/states.js +0 -19
- package/dist/collection/components/phirepass-media-player/phirepass-media-player.css +0 -225
- package/dist/collection/components/phirepass-media-player/phirepass-media-player.js +0 -549
- package/dist/collection/components/phirepass-media-player/player.js +0 -118
- package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.fetch.js +0 -35
- package/dist/collection/testing/fixtures.js +0 -219
- package/dist/collection/testing/mock-channel.js +0 -410
- package/dist/components/p-B4kFfbHE.js +0 -1
- package/dist/components/p-BekUePpu.js +0 -1
- package/dist/components/p-DIf-Ru26.js +0 -1
- package/dist/components/phirepass-downloader.d.ts +0 -11
- package/dist/components/phirepass-downloader.js +0 -1
- package/dist/components/phirepass-media-player.d.ts +0 -11
- package/dist/components/phirepass-media-player.js +0 -1
- package/dist/esm/phirepass-downloader_3.entry.js +0 -3819
- package/dist/phirepass-widgets/p-6a192c8d.entry.js +0 -1
- package/dist/phirepass-widgets/p-BekUePpu.js +0 -1
- package/dist/phirepass-widgets/p-BinptKL7.js +0 -3
- package/dist/phirepass-widgets/p-fe1ce8da.entry.js +0 -1
- package/dist/types/common/fetch.d.ts +0 -167
- package/dist/types/components/phirepass-downloader/form.d.ts +0 -54
- package/dist/types/components/phirepass-downloader/format.d.ts +0 -17
- package/dist/types/components/phirepass-downloader/jobs.d.ts +0 -123
- package/dist/types/components/phirepass-downloader/phirepass-downloader.d.ts +0 -238
- package/dist/types/components/phirepass-downloader/source.d.ts +0 -61
- package/dist/types/components/phirepass-downloader/views/dialogs.d.ts +0 -52
- package/dist/types/components/phirepass-downloader/views/fetch-form.d.ts +0 -31
- package/dist/types/components/phirepass-downloader/views/icons.d.ts +0 -5
- package/dist/types/components/phirepass-downloader/views/job-row.d.ts +0 -21
- package/dist/types/components/phirepass-downloader/views/notices.d.ts +0 -18
- package/dist/types/components/phirepass-downloader/views/states.d.ts +0 -38
- package/dist/types/components/phirepass-media-player/phirepass-media-player.d.ts +0 -82
- package/dist/types/components/phirepass-media-player/player.d.ts +0 -53
- package/dist/types/components/phirepass-sftp-client/phirepass-sftp-client.fetch.d.ts +0 -40
- package/dist/types/testing/fixtures.d.ts +0 -25
- package/dist/types/testing/mock-channel.d.ts +0 -132
|
@@ -1,1466 +0,0 @@
|
|
|
1
|
-
import { Host, h } from "@stencil/core";
|
|
2
|
-
import init, { Channel as PhirepassChannel } from "phirepass-channel";
|
|
3
|
-
import { supportsDownloads } from "../../common/channel";
|
|
4
|
-
import { DOWNLOADER_MSG_ID_BASE, isDownloadFrame } from "../../common/fetch";
|
|
5
|
-
import { ProtocolMessageError, ProtocolMessageType } from "../../common/protocol";
|
|
6
|
-
import { formatBytes, formatRate } from "./format";
|
|
7
|
-
import { EMPTY_FORM, buildStart, chooseTorrent, formModel } from "./form";
|
|
8
|
-
import { applyProgress, blockerFor, folderOf, isClearable, isFinished, isRunning, isStuck, joinPath, partPath, playCheck, renamedByNode, sortRows, streamUrl, summarize, isNoSpace, tabOf, } from "./jobs";
|
|
9
|
-
import { shortMagnet } from "./source";
|
|
10
|
-
import { ConfirmDelete, ConfirmFastest, ConfirmStop, ConfirmTorrent, FolderPicker, Modal, NoSpace } from "./views/dialogs";
|
|
11
|
-
import { FetchForm } from "./views/fetch-form";
|
|
12
|
-
import { Icon } from "./views/icons";
|
|
13
|
-
import { JobRow } from "./views/job-row";
|
|
14
|
-
import { Notices } from "./views/notices";
|
|
15
|
-
import { BlockerView, DrawerEmpty, Loading, SignedOut, StandaloneEmpty, Unreachable, Unsupported } from "./views/states";
|
|
16
|
-
/** After `DownloadAccepted`, how long the dialog waits for the node's first word before it closes anyway. */
|
|
17
|
-
const NODE_SILENCE_MS = 8_000;
|
|
18
|
-
const NOTICE_MS = 6_000;
|
|
19
|
-
const TORRENT_ACK_KEY = 'phirepass.downloader.torrent-ack';
|
|
20
|
-
function readTorrentAck() {
|
|
21
|
-
try {
|
|
22
|
-
return window.localStorage.getItem(TORRENT_ACK_KEY) === '1';
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function writeTorrentAck() {
|
|
29
|
-
try {
|
|
30
|
-
window.localStorage.setItem(TORRENT_ACK_KEY, '1');
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
// A private window keeps no storage: the question simply comes back next time.
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Remote Fetch: paste a link or a magnet, or drop a `.torrent`, and the node
|
|
38
|
-
* downloads it into its own download folder.
|
|
39
|
-
*
|
|
40
|
-
* Two forms, one component. **Embedded** in the SFTP browser (`compact`), it
|
|
41
|
-
* shares the host's channel, which forwards it the `Download*` frames through
|
|
42
|
-
* `receive()`, and saves into the folder on screen when the node can map it.
|
|
43
|
-
* **Standalone**, it builds its own channel, signs in with `token`, and saves
|
|
44
|
-
* into the download folder or a sub-folder of it. Either way it never asks for
|
|
45
|
-
* a login: the node writes its own files.
|
|
46
|
-
*
|
|
47
|
-
* The widget only sends events and shows progress. Downloads run on the node
|
|
48
|
-
* and carry on after the tab closes.
|
|
49
|
-
*/
|
|
50
|
-
export class PhirepassDownloader {
|
|
51
|
-
el;
|
|
52
|
-
ownChannel = false;
|
|
53
|
-
msgId = DOWNLOADER_MSG_ID_BASE;
|
|
54
|
-
noticeId = 1;
|
|
55
|
-
seenNotices = new Set();
|
|
56
|
-
torrentAcked = readTorrentAck();
|
|
57
|
-
noticeTimers = new Map();
|
|
58
|
-
whereMsgId;
|
|
59
|
-
nodeId;
|
|
60
|
-
/** What to call the node in sentences; the id is a uuid nobody reads. */
|
|
61
|
-
nodeLabel;
|
|
62
|
-
/** Session token, for the standalone form. Not needed when `channel` is given. */
|
|
63
|
-
token;
|
|
64
|
-
/**
|
|
65
|
-
* A channel to share instead of opening one: the SFTP client passes its
|
|
66
|
-
* own. The host must forward `Download*` frames (and `Error`s whose
|
|
67
|
-
* `msg_id` is at or above `DOWNLOADER_MSG_ID_BASE`) to `receive()`, and set
|
|
68
|
-
* `connected` once the channel is authenticated.
|
|
69
|
-
*/
|
|
70
|
-
channel;
|
|
71
|
-
/** With an injected `channel`: whether it is authenticated and usable. */
|
|
72
|
-
connected = false;
|
|
73
|
-
/** Builds the channel in place of a WebSocket, for demos and tests (see `ChannelFactory`). */
|
|
74
|
-
channelFactory;
|
|
75
|
-
/** The SFTP/SSH service the host is browsing, so the node can map `browsingPath`. */
|
|
76
|
-
browsingService;
|
|
77
|
-
/** The folder on screen in the host. Downloads land here when it lies inside the download folder. */
|
|
78
|
-
browsingPath;
|
|
79
|
-
/** The drawer layout used inside the SFTP browser. */
|
|
80
|
-
compact = false;
|
|
81
|
-
/** Base URL for `/api/web/stream/…`. Defaults to the server the channel talks to. */
|
|
82
|
-
streamBase;
|
|
83
|
-
/** Whether the viewer may configure this node, which only changes advice text (B9). */
|
|
84
|
-
canConfigure = false;
|
|
85
|
-
/** Open the built-in player on Play, unless a `phirepassPlay` listener calls `preventDefault()`. */
|
|
86
|
-
inlinePlayer = true;
|
|
87
|
-
serverHost = 'phirepass.com';
|
|
88
|
-
serverPort = 443;
|
|
89
|
-
serverId;
|
|
90
|
-
allowInsecure = false;
|
|
91
|
-
heartbeatInterval = 30_000;
|
|
92
|
-
/** A finished download, once per job. The SFTP client refreshes when it lands in the open folder. */
|
|
93
|
-
fetchCompleted;
|
|
94
|
-
/** Play was pressed. Cancelable: prevent it to open your own player instead. */
|
|
95
|
-
play;
|
|
96
|
-
/** How many downloads are running, for a badge. */
|
|
97
|
-
activeCount;
|
|
98
|
-
/** “Show in folder” on a finished row. */
|
|
99
|
-
showInFolder;
|
|
100
|
-
/** “Open node settings” (B9, no folder). */
|
|
101
|
-
openNodeSettings;
|
|
102
|
-
/** “Sign in” (X3). */
|
|
103
|
-
signIn;
|
|
104
|
-
connection = 'connecting';
|
|
105
|
-
caps = null;
|
|
106
|
-
jobs = {};
|
|
107
|
-
tab = 'active';
|
|
108
|
-
drawerOpen = false;
|
|
109
|
-
dialogOpen = false;
|
|
110
|
-
unread = 0;
|
|
111
|
-
form = EMPTY_FORM;
|
|
112
|
-
where = null;
|
|
113
|
-
starting = null;
|
|
114
|
-
refusal = null;
|
|
115
|
-
confirm = null;
|
|
116
|
-
notices = [];
|
|
117
|
-
subDir = null;
|
|
118
|
-
picker = null;
|
|
119
|
-
player = null;
|
|
120
|
-
get name() {
|
|
121
|
-
return this.nodeLabel || this.nodeId;
|
|
122
|
-
}
|
|
123
|
-
get ch() {
|
|
124
|
-
return this.channel ?? this.ownedChannel;
|
|
125
|
-
}
|
|
126
|
-
ownedChannel;
|
|
127
|
-
// ---------------------------------------------------------------- lifecycle
|
|
128
|
-
async componentWillLoad() {
|
|
129
|
-
if (this.channel) {
|
|
130
|
-
this.adoptChannel();
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
await this.openOwnChannel();
|
|
134
|
-
}
|
|
135
|
-
disconnectedCallback() {
|
|
136
|
-
this.noticeTimers.forEach(t => window.clearTimeout(t));
|
|
137
|
-
this.noticeTimers.clear();
|
|
138
|
-
if (this.starting?.silence) {
|
|
139
|
-
window.clearTimeout(this.starting.silence);
|
|
140
|
-
}
|
|
141
|
-
if (this.ownChannel && this.ownedChannel) {
|
|
142
|
-
this.ownedChannel.stop_heartbeat();
|
|
143
|
-
this.ownedChannel.disconnect();
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
onChannel() {
|
|
147
|
-
if (this.channel) {
|
|
148
|
-
this.adoptChannel();
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
onConnected(now, before) {
|
|
152
|
-
if (!this.channel) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
if (now && !before) {
|
|
156
|
-
this.subscribe();
|
|
157
|
-
}
|
|
158
|
-
else if (!now && before) {
|
|
159
|
-
this.connection = 'unreachable';
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
onBrowsing() {
|
|
163
|
-
this.where = null;
|
|
164
|
-
if (this.dialogOpen) {
|
|
165
|
-
this.askWhere();
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
onNode(now, before) {
|
|
169
|
-
if (now === before) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
this.jobs = {};
|
|
173
|
-
this.caps = null;
|
|
174
|
-
this.where = null;
|
|
175
|
-
if (this.channel) {
|
|
176
|
-
if (this.connected) {
|
|
177
|
-
this.subscribe();
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
else if (this.ownedChannel) {
|
|
181
|
-
this.ownedChannel.disconnect();
|
|
182
|
-
void this.openOwnChannel();
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
adoptChannel() {
|
|
186
|
-
this.ownChannel = false;
|
|
187
|
-
if (!supportsDownloads(this.channel)) {
|
|
188
|
-
this.connection = 'unsupported';
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
this.connection = 'connecting';
|
|
192
|
-
if (this.connected) {
|
|
193
|
-
this.subscribe();
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
endpoint() {
|
|
197
|
-
const protocol = this.allowInsecure ? 'ws' : 'wss';
|
|
198
|
-
const defaultPort = (!this.allowInsecure && this.serverPort === 443) || (this.allowInsecure && this.serverPort === 80);
|
|
199
|
-
return `${protocol}://${this.serverHost}${defaultPort ? '' : `:${this.serverPort}`}/api/web/ws`;
|
|
200
|
-
}
|
|
201
|
-
defaultStreamBase() {
|
|
202
|
-
const protocol = this.allowInsecure ? 'http' : 'https';
|
|
203
|
-
const defaultPort = (!this.allowInsecure && this.serverPort === 443) || (this.allowInsecure && this.serverPort === 80);
|
|
204
|
-
return `${protocol}://${this.serverHost}${defaultPort ? '' : `:${this.serverPort}`}`;
|
|
205
|
-
}
|
|
206
|
-
async openOwnChannel() {
|
|
207
|
-
this.ownChannel = true;
|
|
208
|
-
if (!this.token) {
|
|
209
|
-
this.connection = 'signed-out';
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
if (!this.nodeId) {
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
if (!this.channelFactory) {
|
|
216
|
-
await init();
|
|
217
|
-
}
|
|
218
|
-
const channel = this.channelFactory
|
|
219
|
-
? this.channelFactory(this.endpoint(), this.nodeId, this.serverId)
|
|
220
|
-
: this.serverId
|
|
221
|
-
? new PhirepassChannel(this.endpoint(), this.nodeId, this.serverId)
|
|
222
|
-
: new PhirepassChannel(this.endpoint(), this.nodeId);
|
|
223
|
-
this.ownedChannel = channel;
|
|
224
|
-
if (!supportsDownloads(channel)) {
|
|
225
|
-
this.connection = 'unsupported';
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
channel.on_connection_open(() => channel.authenticate(this.token, this.nodeId));
|
|
229
|
-
channel.on_connection_close(() => {
|
|
230
|
-
if (this.connection !== 'signed-out') {
|
|
231
|
-
this.connection = 'unreachable';
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
channel.on_connection_error(() => {
|
|
235
|
-
if (this.connection !== 'signed-out') {
|
|
236
|
-
this.connection = 'unreachable';
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
channel.on_connection_message(() => undefined);
|
|
240
|
-
channel.on_protocol_message((msg) => this.dispatch(msg.data.web));
|
|
241
|
-
this.connection = 'connecting';
|
|
242
|
-
channel.connect();
|
|
243
|
-
}
|
|
244
|
-
reconnect() {
|
|
245
|
-
if (this.ownChannel) {
|
|
246
|
-
this.ownedChannel?.disconnect();
|
|
247
|
-
void this.openOwnChannel();
|
|
248
|
-
}
|
|
249
|
-
else if (this.connected) {
|
|
250
|
-
this.subscribe();
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
// ---------------------------------------------------------------- inbound
|
|
254
|
-
/**
|
|
255
|
-
* Hands this widget a frame from a shared channel: `Download*` frames, and
|
|
256
|
-
* `Error`s answering one of its `msg_id`s. Anything else is ignored.
|
|
257
|
-
*/
|
|
258
|
-
async receive(msg) {
|
|
259
|
-
this.dispatch(msg.data.web);
|
|
260
|
-
}
|
|
261
|
-
dispatch(web) {
|
|
262
|
-
if (web.type === ProtocolMessageType.AuthSuccess) {
|
|
263
|
-
this.ownedChannel?.start_heartbeat(Math.max(30_000, this.heartbeatInterval));
|
|
264
|
-
this.subscribe();
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
if (web.type === ProtocolMessageType.Error) {
|
|
268
|
-
this.handleError(web);
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
if (!isDownloadFrame(web)) {
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
switch (web.type) {
|
|
275
|
-
case 'DownloadCaps':
|
|
276
|
-
if (web.node_id === this.nodeId) {
|
|
277
|
-
this.caps = web.caps;
|
|
278
|
-
this.connection = 'ready';
|
|
279
|
-
}
|
|
280
|
-
break;
|
|
281
|
-
case 'DownloadProgress':
|
|
282
|
-
if (web.node_id === this.nodeId) {
|
|
283
|
-
this.onProgress(web.job);
|
|
284
|
-
}
|
|
285
|
-
break;
|
|
286
|
-
case 'DownloadAccepted':
|
|
287
|
-
this.onAccepted(web.msg_id, web.download_id);
|
|
288
|
-
break;
|
|
289
|
-
case 'DownloadWhereAnswer':
|
|
290
|
-
if (web.msg_id === this.whereMsgId) {
|
|
291
|
-
this.where = { saves_to: web.saves_to, mapped: web.mapped };
|
|
292
|
-
}
|
|
293
|
-
break;
|
|
294
|
-
case 'DownloadFoldersAnswer':
|
|
295
|
-
if (this.picker && web.msg_id === this.picker.msgId) {
|
|
296
|
-
this.picker = { ...this.picker, folders: [...web.folders].sort((a, b) => a.localeCompare(b)) };
|
|
297
|
-
}
|
|
298
|
-
break;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
handleError(error) {
|
|
302
|
-
if (error.msg_id !== undefined && error.msg_id === this.starting?.msgId) {
|
|
303
|
-
this.clearStarting();
|
|
304
|
-
this.refusal = { tone: 'err', title: 'Refused', body: error.message || 'The server refused this download.' };
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
if (this.picker && error.msg_id === this.picker.msgId) {
|
|
308
|
-
this.picker = { ...this.picker, folders: [], error: error.message };
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
if (error.msg_id !== undefined && error.msg_id >= DOWNLOADER_MSG_ID_BASE) {
|
|
312
|
-
this.notify('error', 'That did not work', error.message || 'The server refused it.');
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
if (this.ownChannel && error.kind === ProtocolMessageError.Authentication) {
|
|
316
|
-
this.connection = 'signed-out';
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
subscribe() {
|
|
320
|
-
const ch = this.ch;
|
|
321
|
-
if (!supportsDownloads(ch)) {
|
|
322
|
-
this.connection = 'unsupported';
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
// A fresh subscription answers with caps and every current row.
|
|
326
|
-
this.jobs = {};
|
|
327
|
-
ch.send_download_subscribe({ Node: this.nodeId });
|
|
328
|
-
if (this.dialogOpen) {
|
|
329
|
-
this.askWhere();
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
onProgress(job) {
|
|
333
|
-
const before = this.jobs[job.download_id];
|
|
334
|
-
const { jobs, completed } = applyProgress(this.jobs, job);
|
|
335
|
-
this.jobs = jobs;
|
|
336
|
-
this.emitCount();
|
|
337
|
-
if (this.starting?.downloadId === job.download_id && !before) {
|
|
338
|
-
this.onFirstProgress(job);
|
|
339
|
-
}
|
|
340
|
-
if (completed) {
|
|
341
|
-
this.fetchCompleted.emit({ download_id: job.download_id, dest_root: job.dest_root, sub_dir: job.sub_dir, name: job.name });
|
|
342
|
-
if (!this.drawerOpen && this.compact) {
|
|
343
|
-
this.unread++;
|
|
344
|
-
}
|
|
345
|
-
this.notify('completed', 'Download complete', `${job.name} → ${folderOf(job)}`, {
|
|
346
|
-
label: 'Show',
|
|
347
|
-
run: () => this.showInFolder.emit({ path: folderOf(job), name: job.name }),
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
const row = this.jobs[job.download_id];
|
|
351
|
-
if (row && isStuck(row) && !this.seenNotices.has(`stuck:${job.download_id}`)) {
|
|
352
|
-
this.seenNotices.add(`stuck:${job.download_id}`);
|
|
353
|
-
this.notify('stuck', 'Still retrying after a day', `${job.name} · ${job.retry_reason ?? 'no answer'}`, { label: 'Show', run: () => this.showRetrying() }, true);
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
onAccepted(msgId, downloadId) {
|
|
357
|
-
if (!this.starting || this.starting.msgId !== msgId) {
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
if (this.jobs[downloadId]) {
|
|
361
|
-
// The node already answered: progress beat the acceptance here.
|
|
362
|
-
this.onFirstProgress(this.jobs[downloadId]);
|
|
363
|
-
return;
|
|
364
|
-
}
|
|
365
|
-
const silence = window.setTimeout(() => this.nodeSilent(downloadId), NODE_SILENCE_MS);
|
|
366
|
-
this.starting = { ...this.starting, downloadId, silence };
|
|
367
|
-
}
|
|
368
|
-
/** The server took it but the node has not spoken: it is offline, and the row says it waits. */
|
|
369
|
-
nodeSilent(downloadId) {
|
|
370
|
-
if (this.starting?.downloadId !== downloadId || this.jobs[downloadId]) {
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
const name = this.starting.askedName ?? 'Download';
|
|
374
|
-
const now = Date.now();
|
|
375
|
-
const placeholder = {
|
|
376
|
-
download_id: downloadId,
|
|
377
|
-
kind: 'Unknown',
|
|
378
|
-
name,
|
|
379
|
-
dest_root: this.where?.saves_to ?? this.caps?.folder ?? '',
|
|
380
|
-
sub_dir: null,
|
|
381
|
-
state: 'Queued',
|
|
382
|
-
done_bytes: 0,
|
|
383
|
-
total_bytes: null,
|
|
384
|
-
down_bps: 0,
|
|
385
|
-
up_bps: 0,
|
|
386
|
-
peers: 0,
|
|
387
|
-
in_order: true,
|
|
388
|
-
started_at: now,
|
|
389
|
-
finished_at: null,
|
|
390
|
-
reason: null,
|
|
391
|
-
requested_by: null,
|
|
392
|
-
files: [],
|
|
393
|
-
up_total: 0,
|
|
394
|
-
pause_reason: null,
|
|
395
|
-
seeding_since: null,
|
|
396
|
-
info_hash: null,
|
|
397
|
-
retry_reason: null,
|
|
398
|
-
attempt: 0,
|
|
399
|
-
next_attempt_at: null,
|
|
400
|
-
restarted_from_zero: false,
|
|
401
|
-
waitingForNode: true,
|
|
402
|
-
};
|
|
403
|
-
this.jobs = { ...this.jobs, [downloadId]: placeholder };
|
|
404
|
-
this.clearStarting();
|
|
405
|
-
this.closeDialog(true);
|
|
406
|
-
this.notify('queued', `Waiting for ${this.name}`, `${name} starts when the node reports in.`);
|
|
407
|
-
}
|
|
408
|
-
onFirstProgress(job) {
|
|
409
|
-
const asked = this.starting?.askedName;
|
|
410
|
-
this.clearStarting();
|
|
411
|
-
if (job.state === 'Cancelled') {
|
|
412
|
-
const reason = job.reason ?? 'The node refused this download.';
|
|
413
|
-
if (isNoSpace(reason)) {
|
|
414
|
-
this.confirm = { kind: 'space', reason };
|
|
415
|
-
}
|
|
416
|
-
else if (this.dialogOpen || !this.compact) {
|
|
417
|
-
this.refusal = { tone: 'err', title: 'Refused', body: reason };
|
|
418
|
-
}
|
|
419
|
-
return;
|
|
420
|
-
}
|
|
421
|
-
this.closeDialog(true);
|
|
422
|
-
if (job.state === 'Queued') {
|
|
423
|
-
const running = Object.values(this.jobs).filter(r => r.state === 'Downloading').length;
|
|
424
|
-
this.notify('queued', 'Added to the queue', `${running} ${running === 1 ? 'download is' : 'downloads are'} already running on this node`);
|
|
425
|
-
}
|
|
426
|
-
else {
|
|
427
|
-
this.notify('started', 'Download started', `${job.name} → ${folderOf(job)}`);
|
|
428
|
-
}
|
|
429
|
-
if (renamedByNode(asked, job.name)) {
|
|
430
|
-
this.notify('renamed', `Saved as ${job.name}`, `A file named ${asked} was already in ${folderOf(job)}`);
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
clearStarting() {
|
|
434
|
-
if (this.starting?.silence) {
|
|
435
|
-
window.clearTimeout(this.starting.silence);
|
|
436
|
-
}
|
|
437
|
-
this.starting = null;
|
|
438
|
-
}
|
|
439
|
-
emitCount() {
|
|
440
|
-
this.activeCount.emit({ n: Object.values(this.jobs).filter(isRunning).length });
|
|
441
|
-
}
|
|
442
|
-
notify(kind, title, detail, action, sticky = false) {
|
|
443
|
-
const id = this.noticeId++;
|
|
444
|
-
this.notices = [...this.notices.slice(-2), { id, kind, title, detail, action, sticky }];
|
|
445
|
-
if (!sticky) {
|
|
446
|
-
this.noticeTimers.set(id, window.setTimeout(() => this.dismiss(id), NOTICE_MS));
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
dismiss(id) {
|
|
450
|
-
const t = this.noticeTimers.get(id);
|
|
451
|
-
if (t) {
|
|
452
|
-
window.clearTimeout(t);
|
|
453
|
-
this.noticeTimers.delete(id);
|
|
454
|
-
}
|
|
455
|
-
this.notices = this.notices.filter(n => n.id !== id);
|
|
456
|
-
}
|
|
457
|
-
showRetrying() {
|
|
458
|
-
this.tab = 'retrying';
|
|
459
|
-
this.drawerOpen = true;
|
|
460
|
-
}
|
|
461
|
-
// ---------------------------------------------------------------- public methods
|
|
462
|
-
/** Opens the Fetch dialog (and the drawer behind it). `path` updates the folder on screen. */
|
|
463
|
-
async openFetch(path) {
|
|
464
|
-
if (path !== undefined && path !== this.browsingPath) {
|
|
465
|
-
this.browsingPath = path;
|
|
466
|
-
}
|
|
467
|
-
this.drawerOpen = true;
|
|
468
|
-
this.unread = 0;
|
|
469
|
-
this.dialogOpen = true;
|
|
470
|
-
this.refusal = null;
|
|
471
|
-
this.askWhere();
|
|
472
|
-
}
|
|
473
|
-
/** Opens or closes the drawer (embedded). */
|
|
474
|
-
async toggleDrawer(open) {
|
|
475
|
-
this.drawerOpen = open ?? !this.drawerOpen;
|
|
476
|
-
if (this.drawerOpen) {
|
|
477
|
-
this.unread = 0;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
/** The running download whose part file this is, so the SFTP client can offer K3 instead of a plain delete. */
|
|
481
|
-
async jobForPath(path) {
|
|
482
|
-
const row = Object.values(this.jobs).find(r => !isFinished(r.state) && r.state !== 'Cancelled' && partPath(r) === path);
|
|
483
|
-
return row ? { download_id: row.download_id, name: row.name } : null;
|
|
484
|
-
}
|
|
485
|
-
/** Deletes a download (an unfinished one always loses its part file). */
|
|
486
|
-
async deleteDownload(downloadId, deleteFile = false) {
|
|
487
|
-
const row = this.jobs[downloadId];
|
|
488
|
-
if (row) {
|
|
489
|
-
this.sendDelete(row, deleteFile);
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* The path of a `.torrent` on the node relative to the download folder, or
|
|
494
|
-
* null when it lies outside it (then C's menu item is not offered).
|
|
495
|
-
*/
|
|
496
|
-
async torrentPathFor(path) {
|
|
497
|
-
const root = this.caps?.folder;
|
|
498
|
-
if (!root || !this.caps?.torrents || !/\.torrent$/i.test(path) || blockerFor(this.caps, this.name, this.canConfigure)) {
|
|
499
|
-
return null;
|
|
500
|
-
}
|
|
501
|
-
const prefix = root.endsWith('/') ? root : `${root}/`;
|
|
502
|
-
return path.startsWith(prefix) ? path.slice(prefix.length) : null;
|
|
503
|
-
}
|
|
504
|
-
/** C: download the contents of a `.torrent` already on the node, into the folder it sits in. */
|
|
505
|
-
async startTorrentPath(path, inOrder = false) {
|
|
506
|
-
const rel = await this.torrentPathFor(path);
|
|
507
|
-
const ch = this.ch;
|
|
508
|
-
if (rel === null || !supportsDownloads(ch)) {
|
|
509
|
-
return false;
|
|
510
|
-
}
|
|
511
|
-
const msgId = this.nextMsgId();
|
|
512
|
-
this.starting = { msgId, askedName: rel.split('/').pop()?.replace(/\.torrent$/i, '') };
|
|
513
|
-
const dir = rel.includes('/') ? rel.slice(0, rel.lastIndexOf('/')) : null;
|
|
514
|
-
ch.send_download_start(this.nodeId, { TorrentPath: { path: rel } }, dir, null, inOrder, { source_auth: null, ignore_window: false }, msgId);
|
|
515
|
-
this.drawerOpen = true;
|
|
516
|
-
return true;
|
|
517
|
-
}
|
|
518
|
-
// ---------------------------------------------------------------- outbound
|
|
519
|
-
nextMsgId() {
|
|
520
|
-
this.msgId = this.msgId >= 0xffff_fff0 ? DOWNLOADER_MSG_ID_BASE : this.msgId + 1;
|
|
521
|
-
return this.msgId;
|
|
522
|
-
}
|
|
523
|
-
browsing() {
|
|
524
|
-
return this.compact && this.browsingService && this.browsingPath ? { service_id: this.browsingService, path: this.browsingPath } : null;
|
|
525
|
-
}
|
|
526
|
-
askWhere() {
|
|
527
|
-
const browsing = this.browsing();
|
|
528
|
-
const ch = this.ch;
|
|
529
|
-
if (!browsing || !supportsDownloads(ch) || this.connection !== 'ready') {
|
|
530
|
-
return;
|
|
531
|
-
}
|
|
532
|
-
this.whereMsgId = this.nextMsgId();
|
|
533
|
-
ch.send_download_where(this.nodeId, browsing, this.whereMsgId);
|
|
534
|
-
}
|
|
535
|
-
destination() {
|
|
536
|
-
if (this.browsing()) {
|
|
537
|
-
if (!this.where) {
|
|
538
|
-
return { path: this.browsingPath, hint: 'Asking the node where this lands…' };
|
|
539
|
-
}
|
|
540
|
-
return this.where.mapped
|
|
541
|
-
? { path: this.where.saves_to }
|
|
542
|
-
: { path: this.where.saves_to, hint: `This folder is outside ${this.name}'s download folder. The file will be saved to ${this.where.saves_to}.` };
|
|
543
|
-
}
|
|
544
|
-
const root = this.caps?.folder;
|
|
545
|
-
return root ? { path: joinPath(root, this.subDir) } : null;
|
|
546
|
-
}
|
|
547
|
-
formReady() {
|
|
548
|
-
if (this.starting || this.connection !== 'ready') {
|
|
549
|
-
return false;
|
|
550
|
-
}
|
|
551
|
-
return this.browsing() ? !!this.where : true;
|
|
552
|
-
}
|
|
553
|
-
async pickTorrent(file) {
|
|
554
|
-
const chosen = chooseTorrent(file);
|
|
555
|
-
if (!chosen.error) {
|
|
556
|
-
chosen.contents = new Uint8Array(await file.arrayBuffer());
|
|
557
|
-
}
|
|
558
|
-
this.form = { ...this.form, torrent: chosen, text: '', order: null };
|
|
559
|
-
this.refusal = null;
|
|
560
|
-
}
|
|
561
|
-
start(skipTorrentAsk = false) {
|
|
562
|
-
const model = formModel(this.form, this.caps, this.formReady());
|
|
563
|
-
const plan = buildStart(this.form);
|
|
564
|
-
const ch = this.ch;
|
|
565
|
-
if (!model.canStart || !plan || !supportsDownloads(ch)) {
|
|
566
|
-
return;
|
|
567
|
-
}
|
|
568
|
-
if (model.isTorrent && !this.torrentAcked && !skipTorrentAsk) {
|
|
569
|
-
this.confirm = { kind: 'torrent', dontAsk: false };
|
|
570
|
-
return;
|
|
571
|
-
}
|
|
572
|
-
const msgId = this.nextMsgId();
|
|
573
|
-
const askedName = model.askedName ?? (this.form.torrent ? this.form.torrent.name.replace(/\.torrent$/i, '') : model.detected.kind === 'magnet' ? shortMagnet(model.detected.uri) : undefined);
|
|
574
|
-
this.starting = { msgId, askedName };
|
|
575
|
-
this.refusal = null;
|
|
576
|
-
const browsing = this.browsing();
|
|
577
|
-
ch.send_download_start(this.nodeId, plan.source, browsing ? null : this.subDir, browsing, plan.inOrder, plan.options, msgId);
|
|
578
|
-
}
|
|
579
|
-
closeDialog(started = false) {
|
|
580
|
-
this.dialogOpen = false;
|
|
581
|
-
this.refusal = null;
|
|
582
|
-
if (started) {
|
|
583
|
-
this.form = EMPTY_FORM;
|
|
584
|
-
this.drawerOpen = true;
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
sendStop(row, discard) {
|
|
588
|
-
const ch = this.ch;
|
|
589
|
-
if (supportsDownloads(ch)) {
|
|
590
|
-
ch.send_download_stop(row.download_id, discard, this.nextMsgId());
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
sendDelete(row, deleteFile) {
|
|
594
|
-
const ch = this.ch;
|
|
595
|
-
if (!supportsDownloads(ch)) {
|
|
596
|
-
return;
|
|
597
|
-
}
|
|
598
|
-
ch.send_download_delete(row.download_id, deleteFile, this.nextMsgId());
|
|
599
|
-
this.jobs = { ...this.jobs, [row.download_id]: { ...row, deleting: true } };
|
|
600
|
-
}
|
|
601
|
-
actions = {
|
|
602
|
-
play: row => this.playRow(row),
|
|
603
|
-
pause: row => this.sendStop(row, false),
|
|
604
|
-
resume: (row, ignoreWindow = false) => {
|
|
605
|
-
const ch = this.ch;
|
|
606
|
-
if (supportsDownloads(ch)) {
|
|
607
|
-
ch.send_download_resume(row.download_id, ignoreWindow, this.nextMsgId());
|
|
608
|
-
}
|
|
609
|
-
},
|
|
610
|
-
stop: row => (this.confirm = { kind: 'stop', row, discard: false }),
|
|
611
|
-
remove: row => {
|
|
612
|
-
if (row.state === 'Completed' || row.state === 'Seeding' || row.state === 'Stopped') {
|
|
613
|
-
this.confirm = { kind: 'delete', row, deleteFile: false };
|
|
614
|
-
}
|
|
615
|
-
else {
|
|
616
|
-
// Cancelled: its part is already gone, so there is nothing to lose.
|
|
617
|
-
this.sendDelete(row, false);
|
|
618
|
-
}
|
|
619
|
-
},
|
|
620
|
-
setOrder: (row, inOrder) => {
|
|
621
|
-
if (!inOrder && this.player?.downloadId === row.download_id) {
|
|
622
|
-
this.confirm = { kind: 'fastest', row };
|
|
623
|
-
return;
|
|
624
|
-
}
|
|
625
|
-
this.sendOrder(row, inOrder);
|
|
626
|
-
},
|
|
627
|
-
showInFolder: row => this.showInFolder.emit({ path: folderOf(row), name: row.name }),
|
|
628
|
-
};
|
|
629
|
-
sendOrder(row, inOrder) {
|
|
630
|
-
const ch = this.ch;
|
|
631
|
-
if (supportsDownloads(ch)) {
|
|
632
|
-
ch.send_download_set_order(row.download_id, inOrder, this.nextMsgId());
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
playRow(row) {
|
|
636
|
-
const check = playCheck(row);
|
|
637
|
-
if (!check.play || !check.file) {
|
|
638
|
-
return;
|
|
639
|
-
}
|
|
640
|
-
const src = streamUrl(this.streamBase || this.defaultStreamBase(), this.nodeId, row.download_id, check.file.index);
|
|
641
|
-
const event = this.play.emit({ src, name: check.file.name, downloadId: row.download_id });
|
|
642
|
-
if (!event.defaultPrevented && this.inlinePlayer) {
|
|
643
|
-
this.player = { src, name: check.file.name, downloadId: row.download_id };
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
clearFinished() {
|
|
647
|
-
Object.values(this.jobs)
|
|
648
|
-
.filter(isClearable)
|
|
649
|
-
.forEach(row => this.sendDelete(row, false));
|
|
650
|
-
}
|
|
651
|
-
// ---------------------------------------------------------------- folder picker (H6)
|
|
652
|
-
canPickFolder() {
|
|
653
|
-
return !!this.caps?.folder && typeof this.ch?.send_download_folders === 'function';
|
|
654
|
-
}
|
|
655
|
-
listFolders(path) {
|
|
656
|
-
const msgId = this.nextMsgId();
|
|
657
|
-
this.picker = { path, folders: null, msgId, newName: null };
|
|
658
|
-
this.ch?.send_download_folders?.(this.nodeId, path.length ? path.join('/') : null, msgId);
|
|
659
|
-
}
|
|
660
|
-
savePicker() {
|
|
661
|
-
if (!this.picker) {
|
|
662
|
-
return;
|
|
663
|
-
}
|
|
664
|
-
const segs = [...this.picker.path];
|
|
665
|
-
const fresh = this.picker.newName?.trim();
|
|
666
|
-
if (fresh) {
|
|
667
|
-
segs.push(fresh);
|
|
668
|
-
}
|
|
669
|
-
this.subDir = segs.length ? segs.join('/') : null;
|
|
670
|
-
this.picker = null;
|
|
671
|
-
}
|
|
672
|
-
// ---------------------------------------------------------------- render
|
|
673
|
-
/**
|
|
674
|
-
* The dialog's state as it is now, not as it was when the dialog last rendered.
|
|
675
|
-
* Handlers run between a state change and the re-render it schedules (tick a box,
|
|
676
|
-
* then click confirm before the frame), so reading `c` from the render closure
|
|
677
|
-
* would act on the stale value.
|
|
678
|
-
*/
|
|
679
|
-
latest(c) {
|
|
680
|
-
return this.confirm?.kind === c.kind ? this.confirm : c;
|
|
681
|
-
}
|
|
682
|
-
renderConfirm() {
|
|
683
|
-
const c = this.confirm;
|
|
684
|
-
if (!c) {
|
|
685
|
-
return null;
|
|
686
|
-
}
|
|
687
|
-
const cancel = () => (this.confirm = null);
|
|
688
|
-
switch (c.kind) {
|
|
689
|
-
case 'stop':
|
|
690
|
-
return (h(ConfirmStop, { row: c.row, discard: c.discard, onDiscard: discard => (this.confirm = { ...this.latest(c), discard }), onCancel: cancel, onConfirm: () => {
|
|
691
|
-
const cur = this.latest(c);
|
|
692
|
-
this.sendStop(cur.row, cur.discard);
|
|
693
|
-
this.confirm = null;
|
|
694
|
-
} }));
|
|
695
|
-
case 'delete':
|
|
696
|
-
return (h(ConfirmDelete, { row: c.row, nodeName: this.name, deleteFile: c.deleteFile, onDeleteFile: deleteFile => (this.confirm = { ...this.latest(c), deleteFile }), onCancel: cancel, onConfirm: () => {
|
|
697
|
-
const cur = this.latest(c);
|
|
698
|
-
this.sendDelete(cur.row, cur.deleteFile);
|
|
699
|
-
this.confirm = null;
|
|
700
|
-
} }));
|
|
701
|
-
case 'fastest':
|
|
702
|
-
return (h(ConfirmFastest, { row: c.row, onCancel: cancel, onConfirm: () => {
|
|
703
|
-
this.player = null;
|
|
704
|
-
this.sendOrder(c.row, false);
|
|
705
|
-
this.confirm = null;
|
|
706
|
-
} }));
|
|
707
|
-
case 'torrent':
|
|
708
|
-
return (h(ConfirmTorrent, { nodeName: this.name, dontAsk: c.dontAsk, onDontAsk: dontAsk => (this.confirm = { ...this.latest(c), dontAsk }), onCancel: cancel, onConfirm: () => {
|
|
709
|
-
if (this.latest(c).dontAsk) {
|
|
710
|
-
writeTorrentAck();
|
|
711
|
-
this.torrentAcked = true;
|
|
712
|
-
}
|
|
713
|
-
this.confirm = null;
|
|
714
|
-
this.start(true);
|
|
715
|
-
} }));
|
|
716
|
-
case 'space':
|
|
717
|
-
return h(NoSpace, { reason: c.reason, onClose: cancel });
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
renderForm(layout) {
|
|
721
|
-
const blocker = this.caps ? blockerFor(this.caps, this.name, this.canConfigure) : null;
|
|
722
|
-
const onAction = () => this.openNodeSettings.emit({ nodeId: this.nodeId });
|
|
723
|
-
if (blocker) {
|
|
724
|
-
return layout === 'dialog' ? (h("div", { class: "dlg" }, h("div", { class: "dlg-h" }, h(Icon, { name: "fetch" }), h("h4", null, "Fetch into this folder")), h(BlockerView, { blocker: blocker, onAction: onAction, onClose: () => this.closeDialog() }))) : (h(BlockerView, { blocker: blocker, onAction: onAction }));
|
|
725
|
-
}
|
|
726
|
-
const model = formModel(this.form, this.caps, this.formReady());
|
|
727
|
-
return (h(FetchForm, { form: this.form, model: model, caps: this.caps, layout: layout, title: this.browsing() ? 'Fetch into this folder' : 'Add download', destination: layout === 'dialog' || this.browsing() ? this.destination() : null, starting: !!this.starting, refusal: this.refusal, onChange: patch => {
|
|
728
|
-
this.form = { ...this.form, ...patch };
|
|
729
|
-
if ('text' in patch || 'torrent' in patch) {
|
|
730
|
-
this.refusal = null;
|
|
731
|
-
}
|
|
732
|
-
}, onAuth: patch => (this.form = { ...this.form, auth: { ...this.form.auth, ...patch } }), onPickTorrent: file => void this.pickTorrent(file), onStart: () => this.start(), onCancel: () => this.closeDialog() }));
|
|
733
|
-
}
|
|
734
|
-
renderRows(rows) {
|
|
735
|
-
const running = rows.filter(r => r.state === 'Downloading').length;
|
|
736
|
-
return (h("div", { class: "jobs", role: "list" }, sortRows(rows).map(row => (h(JobRow, { row: row, actions: this.actions, running: running, compact: this.compact })))));
|
|
737
|
-
}
|
|
738
|
-
renderStatus() {
|
|
739
|
-
switch (this.connection) {
|
|
740
|
-
case 'unsupported':
|
|
741
|
-
return h(Unsupported, null);
|
|
742
|
-
case 'signed-out':
|
|
743
|
-
return h(SignedOut, { onSignIn: () => this.signIn.emit() });
|
|
744
|
-
case 'unreachable':
|
|
745
|
-
return h(Unreachable, { nodeName: this.name, onRetry: () => this.reconnect() });
|
|
746
|
-
case 'connecting':
|
|
747
|
-
return h(Loading, null);
|
|
748
|
-
default:
|
|
749
|
-
return null;
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
renderCompact() {
|
|
753
|
-
const rows = Object.values(this.jobs);
|
|
754
|
-
const sum = summarize(rows);
|
|
755
|
-
const status = this.renderStatus();
|
|
756
|
-
if (this.connection === 'unsupported') {
|
|
757
|
-
return null;
|
|
758
|
-
}
|
|
759
|
-
const finished = rows.some(isClearable);
|
|
760
|
-
const showStrip = !this.drawerOpen && (sum.active > 0 || this.unread > 0);
|
|
761
|
-
const summary = [`${sum.active} active`, sum.percent !== null && !this.drawerOpen ? `${Math.round(sum.percent)}%` : '', formatRate(sum.downBps)].filter(Boolean).join(' · ');
|
|
762
|
-
return [
|
|
763
|
-
this.drawerOpen && (h("section", { class: "drawer", "aria-label": "Transfers" }, h("div", { class: "drawer-h" }, h("h4", null, "Transfers"), h("span", { class: "sum" }, summary), h("span", { class: "sp" }), finished && (h("button", { type: "button", class: "lnk", onClick: () => this.clearFinished() }, "Clear finished")), h("button", { type: "button", class: "ib", "aria-label": "Collapse transfers", title: "Collapse", onClick: () => (this.drawerOpen = false) }, h(Icon, { name: "chevron", size: 12 }))), h("div", { class: "drawer-b" }, status ?? (rows.length ? this.renderRows(rows) : h(DrawerEmpty, null))))),
|
|
764
|
-
showStrip && (h("button", { type: "button", class: "strip", "aria-label": "Show transfers", onClick: () => this.toggleDrawer(true) }, h("h4", null, "Transfers"), h("span", { class: "bar" }, h("i", { style: { width: `${sum.percent ?? 0}%` } })), h("span", { class: "sum" }, this.unread && !sum.active ? `${this.unread} finished` : summary), h(Icon, { name: "up", size: 12 }))),
|
|
765
|
-
this.dialogOpen && (h(Modal, { label: "Fetch into this folder", onClose: () => this.closeDialog() }, status && this.connection !== 'ready' ? (h("div", { class: "dlg" }, status, h("div", { class: "dlg-f" }, h("button", { type: "button", class: "btn", onClick: () => this.closeDialog() }, "Close")))) : (this.renderForm('dialog')))),
|
|
766
|
-
];
|
|
767
|
-
}
|
|
768
|
-
renderStandalone() {
|
|
769
|
-
const status = this.renderStatus();
|
|
770
|
-
const rows = Object.values(this.jobs);
|
|
771
|
-
const byTab = { active: [], finished: [], retrying: [] };
|
|
772
|
-
rows.forEach(r => byTab[tabOf(r)].push(r));
|
|
773
|
-
const sum = summarize(rows);
|
|
774
|
-
const shown = byTab[this.tab];
|
|
775
|
-
const folder = this.caps?.folder ? joinPath(this.caps.folder, this.subDir) : null;
|
|
776
|
-
return (h("section", { class: "standalone" }, h("header", { class: "sa-head" }, h("div", { class: "sa-title" }, h("h3", null, "Downloads"), h("span", { class: "node" }, this.name), sum.downBps > 0 && h("span", { class: "sum" }, formatRate(sum.downBps))), folder && (h("span", { class: "saving" }, "saving to ", h("code", null, folder), this.caps && this.caps.folder_free_bytes > 0 && h("span", { class: "free" }, " \u00B7 ", formatBytes(this.caps.folder_free_bytes), " free")))), status ?? [
|
|
777
|
-
h("div", { class: "sa-add" }, this.renderForm('inline'), folder && !blockerFor(this.caps, this.name, this.canConfigure) && (h("div", { class: "sa-dest" }, h("span", { class: "dest" }, h(Icon, { name: "folder", size: 14 }), h("span", null, folder)), this.canPickFolder() && (h("button", { type: "button", class: "btn", onClick: () => this.listFolders(this.subDir ? this.subDir.split('/') : []) }, "Choose folder\u2026"))))),
|
|
778
|
-
h("div", { class: "tabs", role: "tablist", "aria-label": "Downloads" }, [
|
|
779
|
-
['active', 'Active'],
|
|
780
|
-
['finished', 'Finished'],
|
|
781
|
-
['retrying', 'Retrying'],
|
|
782
|
-
].map(([id, label]) => (h("button", { type: "button", role: "tab", "aria-selected": this.tab === id ? 'true' : 'false', class: { on: this.tab === id }, onClick: () => (this.tab = id) }, label, h("b", null, byTab[id].length))))),
|
|
783
|
-
this.tab === 'finished' && byTab.finished.length > 0 && (h("div", { class: "tab-h" }, h("span", null, byTab.finished.length, " finished"), byTab.finished.some(isClearable) && (h("button", { type: "button", class: "lnk", onClick: () => this.clearFinished() }, "Clear finished")))),
|
|
784
|
-
shown.length ? (this.renderRows(shown)) : rows.length === 0 ? (h(StandaloneEmpty, { nodeName: this.name, folder: folder })) : (h("div", { class: "muted pad" }, this.tab === 'retrying' ? 'Nothing is retrying.' : this.tab === 'finished' ? 'Nothing has finished yet.' : 'Nothing is running.')),
|
|
785
|
-
]));
|
|
786
|
-
}
|
|
787
|
-
render() {
|
|
788
|
-
return (h(Host, { key: 'b7f751d7107ff8f00d791e5c54f4261e2d7cd580', class: { compact: this.compact, standalone: !this.compact } }, this.compact ? this.renderCompact() : this.renderStandalone(), this.renderConfirm(), this.picker && (h(FolderPicker, { key: '538f0f433863e0fbd79a8e66c0b7a45c93a8bd28', root: this.caps?.folder ?? '', path: this.picker.path, folders: this.picker.folders, error: this.picker.error, newName: this.picker.newName, onOpen: name => this.listFolders([...this.picker.path, name]), onUp: depth => this.listFolders(this.picker.path.slice(0, depth)), onNewName: newName => (this.picker = { ...this.picker, newName }), onCancel: () => (this.picker = null), onSave: () => this.savePicker() })), this.player && (h("div", { key: 'b9d3ade696c6079d6a2e3bc2206c19a6bdd7d640', class: "overlay player" }, h("phirepass-media-player", { key: 'c5fa1244ea9766ff37d08478dbc2d096430f2081', src: this.player.src, name: this.player.name, status: this.playerStatus(), ready: this.playerReady(), positionKey: `dl:${this.player.downloadId}`, onPhirepassPlayerClose: () => (this.player = null) }))), h(Notices, { key: '34a34a810001815a890a0995aab44f29f34aab61', notices: this.notices, onDismiss: id => this.dismiss(id) })));
|
|
789
|
-
}
|
|
790
|
-
playerRow() {
|
|
791
|
-
return this.player ? this.jobs[this.player.downloadId] : undefined;
|
|
792
|
-
}
|
|
793
|
-
playerStatus() {
|
|
794
|
-
const row = this.playerRow();
|
|
795
|
-
if (!row) {
|
|
796
|
-
return this.player ? 'On the node' : undefined;
|
|
797
|
-
}
|
|
798
|
-
if (isFinished(row.state)) {
|
|
799
|
-
return 'On the node';
|
|
800
|
-
}
|
|
801
|
-
const pct = row.total_bytes ? ` · ${((row.done_bytes / row.total_bytes) * 100).toFixed(1)}%` : '';
|
|
802
|
-
return `${row.state === 'Downloading' ? 'Downloading' : row.state}${pct}`;
|
|
803
|
-
}
|
|
804
|
-
playerReady() {
|
|
805
|
-
const row = this.playerRow();
|
|
806
|
-
if (!row || isFinished(row.state)) {
|
|
807
|
-
return undefined;
|
|
808
|
-
}
|
|
809
|
-
const file = playCheck(row);
|
|
810
|
-
return file.file?.ready_from_start;
|
|
811
|
-
}
|
|
812
|
-
static get is() { return "phirepass-downloader"; }
|
|
813
|
-
static get encapsulation() { return "shadow"; }
|
|
814
|
-
static get originalStyleUrls() {
|
|
815
|
-
return {
|
|
816
|
-
"$": ["phirepass-downloader.css"]
|
|
817
|
-
};
|
|
818
|
-
}
|
|
819
|
-
static get styleUrls() {
|
|
820
|
-
return {
|
|
821
|
-
"$": ["phirepass-downloader.css"]
|
|
822
|
-
};
|
|
823
|
-
}
|
|
824
|
-
static get properties() {
|
|
825
|
-
return {
|
|
826
|
-
"nodeId": {
|
|
827
|
-
"type": "string",
|
|
828
|
-
"mutable": false,
|
|
829
|
-
"complexType": {
|
|
830
|
-
"original": "string",
|
|
831
|
-
"resolved": "string",
|
|
832
|
-
"references": {}
|
|
833
|
-
},
|
|
834
|
-
"required": true,
|
|
835
|
-
"optional": false,
|
|
836
|
-
"docs": {
|
|
837
|
-
"tags": [],
|
|
838
|
-
"text": ""
|
|
839
|
-
},
|
|
840
|
-
"getter": false,
|
|
841
|
-
"setter": false,
|
|
842
|
-
"reflect": false,
|
|
843
|
-
"attribute": "node-id"
|
|
844
|
-
},
|
|
845
|
-
"nodeLabel": {
|
|
846
|
-
"type": "string",
|
|
847
|
-
"mutable": false,
|
|
848
|
-
"complexType": {
|
|
849
|
-
"original": "string",
|
|
850
|
-
"resolved": "string",
|
|
851
|
-
"references": {}
|
|
852
|
-
},
|
|
853
|
-
"required": false,
|
|
854
|
-
"optional": true,
|
|
855
|
-
"docs": {
|
|
856
|
-
"tags": [],
|
|
857
|
-
"text": "What to call the node in sentences; the id is a uuid nobody reads."
|
|
858
|
-
},
|
|
859
|
-
"getter": false,
|
|
860
|
-
"setter": false,
|
|
861
|
-
"reflect": false,
|
|
862
|
-
"attribute": "node-label"
|
|
863
|
-
},
|
|
864
|
-
"token": {
|
|
865
|
-
"type": "string",
|
|
866
|
-
"mutable": false,
|
|
867
|
-
"complexType": {
|
|
868
|
-
"original": "string",
|
|
869
|
-
"resolved": "string",
|
|
870
|
-
"references": {}
|
|
871
|
-
},
|
|
872
|
-
"required": false,
|
|
873
|
-
"optional": true,
|
|
874
|
-
"docs": {
|
|
875
|
-
"tags": [],
|
|
876
|
-
"text": "Session token, for the standalone form. Not needed when `channel` is given."
|
|
877
|
-
},
|
|
878
|
-
"getter": false,
|
|
879
|
-
"setter": false,
|
|
880
|
-
"reflect": false,
|
|
881
|
-
"attribute": "token"
|
|
882
|
-
},
|
|
883
|
-
"channel": {
|
|
884
|
-
"type": "unknown",
|
|
885
|
-
"mutable": false,
|
|
886
|
-
"complexType": {
|
|
887
|
-
"original": "DownloadChannelLike",
|
|
888
|
-
"resolved": "Pick<ChannelLike, \"connect\" | \"disconnect\" | \"is_connected\" | \"authenticate\" | \"start_heartbeat\" | \"stop_heartbeat\" | \"on_connection_open\" | \"on_connection_close\" | \"on_connection_error\" | \"on_connection_message\" | \"on_protocol_message\"> & Partial<DownloadChannelMethods>",
|
|
889
|
-
"references": {
|
|
890
|
-
"DownloadChannelLike": {
|
|
891
|
-
"location": "import",
|
|
892
|
-
"path": "../../common/channel",
|
|
893
|
-
"id": "src/common/channel.ts::DownloadChannelLike",
|
|
894
|
-
"referenceLocation": "DownloadChannelLike"
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
},
|
|
898
|
-
"required": false,
|
|
899
|
-
"optional": true,
|
|
900
|
-
"docs": {
|
|
901
|
-
"tags": [],
|
|
902
|
-
"text": "A channel to share instead of opening one: the SFTP client passes its\nown. The host must forward `Download*` frames (and `Error`s whose\n`msg_id` is at or above `DOWNLOADER_MSG_ID_BASE`) to `receive()`, and set\n`connected` once the channel is authenticated."
|
|
903
|
-
},
|
|
904
|
-
"getter": false,
|
|
905
|
-
"setter": false
|
|
906
|
-
},
|
|
907
|
-
"connected": {
|
|
908
|
-
"type": "boolean",
|
|
909
|
-
"mutable": false,
|
|
910
|
-
"complexType": {
|
|
911
|
-
"original": "boolean",
|
|
912
|
-
"resolved": "boolean",
|
|
913
|
-
"references": {}
|
|
914
|
-
},
|
|
915
|
-
"required": false,
|
|
916
|
-
"optional": false,
|
|
917
|
-
"docs": {
|
|
918
|
-
"tags": [],
|
|
919
|
-
"text": "With an injected `channel`: whether it is authenticated and usable."
|
|
920
|
-
},
|
|
921
|
-
"getter": false,
|
|
922
|
-
"setter": false,
|
|
923
|
-
"reflect": false,
|
|
924
|
-
"attribute": "connected",
|
|
925
|
-
"defaultValue": "false"
|
|
926
|
-
},
|
|
927
|
-
"channelFactory": {
|
|
928
|
-
"type": "unknown",
|
|
929
|
-
"mutable": false,
|
|
930
|
-
"complexType": {
|
|
931
|
-
"original": "DownloadChannelFactory",
|
|
932
|
-
"resolved": "(endpoint: string, nodeId: string, serverId?: string) => DownloadChannelLike",
|
|
933
|
-
"references": {
|
|
934
|
-
"DownloadChannelFactory": {
|
|
935
|
-
"location": "import",
|
|
936
|
-
"path": "../../common/channel",
|
|
937
|
-
"id": "src/common/channel.ts::DownloadChannelFactory",
|
|
938
|
-
"referenceLocation": "DownloadChannelFactory"
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
},
|
|
942
|
-
"required": false,
|
|
943
|
-
"optional": true,
|
|
944
|
-
"docs": {
|
|
945
|
-
"tags": [],
|
|
946
|
-
"text": "Builds the channel in place of a WebSocket, for demos and tests (see `ChannelFactory`)."
|
|
947
|
-
},
|
|
948
|
-
"getter": false,
|
|
949
|
-
"setter": false
|
|
950
|
-
},
|
|
951
|
-
"browsingService": {
|
|
952
|
-
"type": "string",
|
|
953
|
-
"mutable": false,
|
|
954
|
-
"complexType": {
|
|
955
|
-
"original": "string",
|
|
956
|
-
"resolved": "string",
|
|
957
|
-
"references": {}
|
|
958
|
-
},
|
|
959
|
-
"required": false,
|
|
960
|
-
"optional": true,
|
|
961
|
-
"docs": {
|
|
962
|
-
"tags": [],
|
|
963
|
-
"text": "The SFTP/SSH service the host is browsing, so the node can map `browsingPath`."
|
|
964
|
-
},
|
|
965
|
-
"getter": false,
|
|
966
|
-
"setter": false,
|
|
967
|
-
"reflect": false,
|
|
968
|
-
"attribute": "browsing-service"
|
|
969
|
-
},
|
|
970
|
-
"browsingPath": {
|
|
971
|
-
"type": "string",
|
|
972
|
-
"mutable": true,
|
|
973
|
-
"complexType": {
|
|
974
|
-
"original": "string",
|
|
975
|
-
"resolved": "string",
|
|
976
|
-
"references": {}
|
|
977
|
-
},
|
|
978
|
-
"required": false,
|
|
979
|
-
"optional": true,
|
|
980
|
-
"docs": {
|
|
981
|
-
"tags": [],
|
|
982
|
-
"text": "The folder on screen in the host. Downloads land here when it lies inside the download folder."
|
|
983
|
-
},
|
|
984
|
-
"getter": false,
|
|
985
|
-
"setter": false,
|
|
986
|
-
"reflect": false,
|
|
987
|
-
"attribute": "browsing-path"
|
|
988
|
-
},
|
|
989
|
-
"compact": {
|
|
990
|
-
"type": "boolean",
|
|
991
|
-
"mutable": false,
|
|
992
|
-
"complexType": {
|
|
993
|
-
"original": "boolean",
|
|
994
|
-
"resolved": "boolean",
|
|
995
|
-
"references": {}
|
|
996
|
-
},
|
|
997
|
-
"required": false,
|
|
998
|
-
"optional": false,
|
|
999
|
-
"docs": {
|
|
1000
|
-
"tags": [],
|
|
1001
|
-
"text": "The drawer layout used inside the SFTP browser."
|
|
1002
|
-
},
|
|
1003
|
-
"getter": false,
|
|
1004
|
-
"setter": false,
|
|
1005
|
-
"reflect": true,
|
|
1006
|
-
"attribute": "compact",
|
|
1007
|
-
"defaultValue": "false"
|
|
1008
|
-
},
|
|
1009
|
-
"streamBase": {
|
|
1010
|
-
"type": "string",
|
|
1011
|
-
"mutable": false,
|
|
1012
|
-
"complexType": {
|
|
1013
|
-
"original": "string",
|
|
1014
|
-
"resolved": "string",
|
|
1015
|
-
"references": {}
|
|
1016
|
-
},
|
|
1017
|
-
"required": false,
|
|
1018
|
-
"optional": true,
|
|
1019
|
-
"docs": {
|
|
1020
|
-
"tags": [],
|
|
1021
|
-
"text": "Base URL for `/api/web/stream/\u2026`. Defaults to the server the channel talks to."
|
|
1022
|
-
},
|
|
1023
|
-
"getter": false,
|
|
1024
|
-
"setter": false,
|
|
1025
|
-
"reflect": false,
|
|
1026
|
-
"attribute": "stream-base"
|
|
1027
|
-
},
|
|
1028
|
-
"canConfigure": {
|
|
1029
|
-
"type": "boolean",
|
|
1030
|
-
"mutable": false,
|
|
1031
|
-
"complexType": {
|
|
1032
|
-
"original": "boolean",
|
|
1033
|
-
"resolved": "boolean",
|
|
1034
|
-
"references": {}
|
|
1035
|
-
},
|
|
1036
|
-
"required": false,
|
|
1037
|
-
"optional": false,
|
|
1038
|
-
"docs": {
|
|
1039
|
-
"tags": [],
|
|
1040
|
-
"text": "Whether the viewer may configure this node, which only changes advice text (B9)."
|
|
1041
|
-
},
|
|
1042
|
-
"getter": false,
|
|
1043
|
-
"setter": false,
|
|
1044
|
-
"reflect": false,
|
|
1045
|
-
"attribute": "can-configure",
|
|
1046
|
-
"defaultValue": "false"
|
|
1047
|
-
},
|
|
1048
|
-
"inlinePlayer": {
|
|
1049
|
-
"type": "boolean",
|
|
1050
|
-
"mutable": false,
|
|
1051
|
-
"complexType": {
|
|
1052
|
-
"original": "boolean",
|
|
1053
|
-
"resolved": "boolean",
|
|
1054
|
-
"references": {}
|
|
1055
|
-
},
|
|
1056
|
-
"required": false,
|
|
1057
|
-
"optional": false,
|
|
1058
|
-
"docs": {
|
|
1059
|
-
"tags": [],
|
|
1060
|
-
"text": "Open the built-in player on Play, unless a `phirepassPlay` listener calls `preventDefault()`."
|
|
1061
|
-
},
|
|
1062
|
-
"getter": false,
|
|
1063
|
-
"setter": false,
|
|
1064
|
-
"reflect": false,
|
|
1065
|
-
"attribute": "inline-player",
|
|
1066
|
-
"defaultValue": "true"
|
|
1067
|
-
},
|
|
1068
|
-
"serverHost": {
|
|
1069
|
-
"type": "string",
|
|
1070
|
-
"mutable": false,
|
|
1071
|
-
"complexType": {
|
|
1072
|
-
"original": "string",
|
|
1073
|
-
"resolved": "string",
|
|
1074
|
-
"references": {}
|
|
1075
|
-
},
|
|
1076
|
-
"required": false,
|
|
1077
|
-
"optional": false,
|
|
1078
|
-
"docs": {
|
|
1079
|
-
"tags": [],
|
|
1080
|
-
"text": ""
|
|
1081
|
-
},
|
|
1082
|
-
"getter": false,
|
|
1083
|
-
"setter": false,
|
|
1084
|
-
"reflect": false,
|
|
1085
|
-
"attribute": "server-host",
|
|
1086
|
-
"defaultValue": "'phirepass.com'"
|
|
1087
|
-
},
|
|
1088
|
-
"serverPort": {
|
|
1089
|
-
"type": "number",
|
|
1090
|
-
"mutable": false,
|
|
1091
|
-
"complexType": {
|
|
1092
|
-
"original": "number",
|
|
1093
|
-
"resolved": "number",
|
|
1094
|
-
"references": {}
|
|
1095
|
-
},
|
|
1096
|
-
"required": false,
|
|
1097
|
-
"optional": false,
|
|
1098
|
-
"docs": {
|
|
1099
|
-
"tags": [],
|
|
1100
|
-
"text": ""
|
|
1101
|
-
},
|
|
1102
|
-
"getter": false,
|
|
1103
|
-
"setter": false,
|
|
1104
|
-
"reflect": false,
|
|
1105
|
-
"attribute": "server-port",
|
|
1106
|
-
"defaultValue": "443"
|
|
1107
|
-
},
|
|
1108
|
-
"serverId": {
|
|
1109
|
-
"type": "string",
|
|
1110
|
-
"mutable": false,
|
|
1111
|
-
"complexType": {
|
|
1112
|
-
"original": "string",
|
|
1113
|
-
"resolved": "string",
|
|
1114
|
-
"references": {}
|
|
1115
|
-
},
|
|
1116
|
-
"required": false,
|
|
1117
|
-
"optional": true,
|
|
1118
|
-
"docs": {
|
|
1119
|
-
"tags": [],
|
|
1120
|
-
"text": ""
|
|
1121
|
-
},
|
|
1122
|
-
"getter": false,
|
|
1123
|
-
"setter": false,
|
|
1124
|
-
"reflect": false,
|
|
1125
|
-
"attribute": "server-id"
|
|
1126
|
-
},
|
|
1127
|
-
"allowInsecure": {
|
|
1128
|
-
"type": "boolean",
|
|
1129
|
-
"mutable": false,
|
|
1130
|
-
"complexType": {
|
|
1131
|
-
"original": "boolean",
|
|
1132
|
-
"resolved": "boolean",
|
|
1133
|
-
"references": {}
|
|
1134
|
-
},
|
|
1135
|
-
"required": false,
|
|
1136
|
-
"optional": false,
|
|
1137
|
-
"docs": {
|
|
1138
|
-
"tags": [],
|
|
1139
|
-
"text": ""
|
|
1140
|
-
},
|
|
1141
|
-
"getter": false,
|
|
1142
|
-
"setter": false,
|
|
1143
|
-
"reflect": false,
|
|
1144
|
-
"attribute": "allow-insecure",
|
|
1145
|
-
"defaultValue": "false"
|
|
1146
|
-
},
|
|
1147
|
-
"heartbeatInterval": {
|
|
1148
|
-
"type": "number",
|
|
1149
|
-
"mutable": false,
|
|
1150
|
-
"complexType": {
|
|
1151
|
-
"original": "number",
|
|
1152
|
-
"resolved": "number",
|
|
1153
|
-
"references": {}
|
|
1154
|
-
},
|
|
1155
|
-
"required": false,
|
|
1156
|
-
"optional": false,
|
|
1157
|
-
"docs": {
|
|
1158
|
-
"tags": [],
|
|
1159
|
-
"text": ""
|
|
1160
|
-
},
|
|
1161
|
-
"getter": false,
|
|
1162
|
-
"setter": false,
|
|
1163
|
-
"reflect": false,
|
|
1164
|
-
"attribute": "heartbeat-interval",
|
|
1165
|
-
"defaultValue": "30_000"
|
|
1166
|
-
}
|
|
1167
|
-
};
|
|
1168
|
-
}
|
|
1169
|
-
static get states() {
|
|
1170
|
-
return {
|
|
1171
|
-
"connection": {},
|
|
1172
|
-
"caps": {},
|
|
1173
|
-
"jobs": {},
|
|
1174
|
-
"tab": {},
|
|
1175
|
-
"drawerOpen": {},
|
|
1176
|
-
"dialogOpen": {},
|
|
1177
|
-
"unread": {},
|
|
1178
|
-
"form": {},
|
|
1179
|
-
"where": {},
|
|
1180
|
-
"starting": {},
|
|
1181
|
-
"refusal": {},
|
|
1182
|
-
"confirm": {},
|
|
1183
|
-
"notices": {},
|
|
1184
|
-
"subDir": {},
|
|
1185
|
-
"picker": {},
|
|
1186
|
-
"player": {}
|
|
1187
|
-
};
|
|
1188
|
-
}
|
|
1189
|
-
static get events() {
|
|
1190
|
-
return [{
|
|
1191
|
-
"method": "fetchCompleted",
|
|
1192
|
-
"name": "phirepassFetchCompleted",
|
|
1193
|
-
"bubbles": true,
|
|
1194
|
-
"cancelable": true,
|
|
1195
|
-
"composed": true,
|
|
1196
|
-
"docs": {
|
|
1197
|
-
"tags": [],
|
|
1198
|
-
"text": "A finished download, once per job. The SFTP client refreshes when it lands in the open folder."
|
|
1199
|
-
},
|
|
1200
|
-
"complexType": {
|
|
1201
|
-
"original": "{ download_id: string; dest_root: string; sub_dir: string | null; name: string }",
|
|
1202
|
-
"resolved": "{ download_id: string; dest_root: string; sub_dir: string; name: string; }",
|
|
1203
|
-
"references": {}
|
|
1204
|
-
}
|
|
1205
|
-
}, {
|
|
1206
|
-
"method": "play",
|
|
1207
|
-
"name": "phirepassPlay",
|
|
1208
|
-
"bubbles": true,
|
|
1209
|
-
"cancelable": true,
|
|
1210
|
-
"composed": true,
|
|
1211
|
-
"docs": {
|
|
1212
|
-
"tags": [],
|
|
1213
|
-
"text": "Play was pressed. Cancelable: prevent it to open your own player instead."
|
|
1214
|
-
},
|
|
1215
|
-
"complexType": {
|
|
1216
|
-
"original": "{ src: string; name: string; downloadId: string }",
|
|
1217
|
-
"resolved": "{ src: string; name: string; downloadId: string; }",
|
|
1218
|
-
"references": {}
|
|
1219
|
-
}
|
|
1220
|
-
}, {
|
|
1221
|
-
"method": "activeCount",
|
|
1222
|
-
"name": "phirepassActiveCount",
|
|
1223
|
-
"bubbles": true,
|
|
1224
|
-
"cancelable": true,
|
|
1225
|
-
"composed": true,
|
|
1226
|
-
"docs": {
|
|
1227
|
-
"tags": [],
|
|
1228
|
-
"text": "How many downloads are running, for a badge."
|
|
1229
|
-
},
|
|
1230
|
-
"complexType": {
|
|
1231
|
-
"original": "{ n: number }",
|
|
1232
|
-
"resolved": "{ n: number; }",
|
|
1233
|
-
"references": {}
|
|
1234
|
-
}
|
|
1235
|
-
}, {
|
|
1236
|
-
"method": "showInFolder",
|
|
1237
|
-
"name": "phirepassShowInFolder",
|
|
1238
|
-
"bubbles": true,
|
|
1239
|
-
"cancelable": true,
|
|
1240
|
-
"composed": true,
|
|
1241
|
-
"docs": {
|
|
1242
|
-
"tags": [],
|
|
1243
|
-
"text": "\u201CShow in folder\u201D on a finished row."
|
|
1244
|
-
},
|
|
1245
|
-
"complexType": {
|
|
1246
|
-
"original": "{ path: string; name: string }",
|
|
1247
|
-
"resolved": "{ path: string; name: string; }",
|
|
1248
|
-
"references": {}
|
|
1249
|
-
}
|
|
1250
|
-
}, {
|
|
1251
|
-
"method": "openNodeSettings",
|
|
1252
|
-
"name": "phirepassOpenNodeSettings",
|
|
1253
|
-
"bubbles": true,
|
|
1254
|
-
"cancelable": true,
|
|
1255
|
-
"composed": true,
|
|
1256
|
-
"docs": {
|
|
1257
|
-
"tags": [],
|
|
1258
|
-
"text": "\u201COpen node settings\u201D (B9, no folder)."
|
|
1259
|
-
},
|
|
1260
|
-
"complexType": {
|
|
1261
|
-
"original": "{ nodeId: string }",
|
|
1262
|
-
"resolved": "{ nodeId: string; }",
|
|
1263
|
-
"references": {}
|
|
1264
|
-
}
|
|
1265
|
-
}, {
|
|
1266
|
-
"method": "signIn",
|
|
1267
|
-
"name": "phirepassSignIn",
|
|
1268
|
-
"bubbles": true,
|
|
1269
|
-
"cancelable": true,
|
|
1270
|
-
"composed": true,
|
|
1271
|
-
"docs": {
|
|
1272
|
-
"tags": [],
|
|
1273
|
-
"text": "\u201CSign in\u201D (X3)."
|
|
1274
|
-
},
|
|
1275
|
-
"complexType": {
|
|
1276
|
-
"original": "void",
|
|
1277
|
-
"resolved": "void",
|
|
1278
|
-
"references": {}
|
|
1279
|
-
}
|
|
1280
|
-
}];
|
|
1281
|
-
}
|
|
1282
|
-
static get methods() {
|
|
1283
|
-
return {
|
|
1284
|
-
"receive": {
|
|
1285
|
-
"complexType": {
|
|
1286
|
-
"signature": "(msg: ProtocolMessage | { data: { web: unknown; }; }) => Promise<void>",
|
|
1287
|
-
"parameters": [{
|
|
1288
|
-
"name": "msg",
|
|
1289
|
-
"type": "ProtocolMessage | { data: { web: unknown; }; }",
|
|
1290
|
-
"docs": ""
|
|
1291
|
-
}],
|
|
1292
|
-
"references": {
|
|
1293
|
-
"Promise": {
|
|
1294
|
-
"location": "global",
|
|
1295
|
-
"id": "global::Promise"
|
|
1296
|
-
},
|
|
1297
|
-
"ProtocolMessage": {
|
|
1298
|
-
"location": "import",
|
|
1299
|
-
"path": "../../common/protocol",
|
|
1300
|
-
"id": "src/common/protocol.ts::ProtocolMessage",
|
|
1301
|
-
"referenceLocation": "ProtocolMessage"
|
|
1302
|
-
}
|
|
1303
|
-
},
|
|
1304
|
-
"return": "Promise<void>"
|
|
1305
|
-
},
|
|
1306
|
-
"docs": {
|
|
1307
|
-
"text": "Hands this widget a frame from a shared channel: `Download*` frames, and\n`Error`s answering one of its `msg_id`s. Anything else is ignored.",
|
|
1308
|
-
"tags": []
|
|
1309
|
-
}
|
|
1310
|
-
},
|
|
1311
|
-
"openFetch": {
|
|
1312
|
-
"complexType": {
|
|
1313
|
-
"signature": "(path?: string) => Promise<void>",
|
|
1314
|
-
"parameters": [{
|
|
1315
|
-
"name": "path",
|
|
1316
|
-
"type": "string",
|
|
1317
|
-
"docs": ""
|
|
1318
|
-
}],
|
|
1319
|
-
"references": {
|
|
1320
|
-
"Promise": {
|
|
1321
|
-
"location": "global",
|
|
1322
|
-
"id": "global::Promise"
|
|
1323
|
-
}
|
|
1324
|
-
},
|
|
1325
|
-
"return": "Promise<void>"
|
|
1326
|
-
},
|
|
1327
|
-
"docs": {
|
|
1328
|
-
"text": "Opens the Fetch dialog (and the drawer behind it). `path` updates the folder on screen.",
|
|
1329
|
-
"tags": []
|
|
1330
|
-
}
|
|
1331
|
-
},
|
|
1332
|
-
"toggleDrawer": {
|
|
1333
|
-
"complexType": {
|
|
1334
|
-
"signature": "(open?: boolean) => Promise<void>",
|
|
1335
|
-
"parameters": [{
|
|
1336
|
-
"name": "open",
|
|
1337
|
-
"type": "boolean",
|
|
1338
|
-
"docs": ""
|
|
1339
|
-
}],
|
|
1340
|
-
"references": {
|
|
1341
|
-
"Promise": {
|
|
1342
|
-
"location": "global",
|
|
1343
|
-
"id": "global::Promise"
|
|
1344
|
-
}
|
|
1345
|
-
},
|
|
1346
|
-
"return": "Promise<void>"
|
|
1347
|
-
},
|
|
1348
|
-
"docs": {
|
|
1349
|
-
"text": "Opens or closes the drawer (embedded).",
|
|
1350
|
-
"tags": []
|
|
1351
|
-
}
|
|
1352
|
-
},
|
|
1353
|
-
"jobForPath": {
|
|
1354
|
-
"complexType": {
|
|
1355
|
-
"signature": "(path: string) => Promise<{ download_id: string; name: string; } | null>",
|
|
1356
|
-
"parameters": [{
|
|
1357
|
-
"name": "path",
|
|
1358
|
-
"type": "string",
|
|
1359
|
-
"docs": ""
|
|
1360
|
-
}],
|
|
1361
|
-
"references": {
|
|
1362
|
-
"Promise": {
|
|
1363
|
-
"location": "global",
|
|
1364
|
-
"id": "global::Promise"
|
|
1365
|
-
}
|
|
1366
|
-
},
|
|
1367
|
-
"return": "Promise<{ download_id: string; name: string; }>"
|
|
1368
|
-
},
|
|
1369
|
-
"docs": {
|
|
1370
|
-
"text": "The running download whose part file this is, so the SFTP client can offer K3 instead of a plain delete.",
|
|
1371
|
-
"tags": []
|
|
1372
|
-
}
|
|
1373
|
-
},
|
|
1374
|
-
"deleteDownload": {
|
|
1375
|
-
"complexType": {
|
|
1376
|
-
"signature": "(downloadId: string, deleteFile?: boolean) => Promise<void>",
|
|
1377
|
-
"parameters": [{
|
|
1378
|
-
"name": "downloadId",
|
|
1379
|
-
"type": "string",
|
|
1380
|
-
"docs": ""
|
|
1381
|
-
}, {
|
|
1382
|
-
"name": "deleteFile",
|
|
1383
|
-
"type": "boolean",
|
|
1384
|
-
"docs": ""
|
|
1385
|
-
}],
|
|
1386
|
-
"references": {
|
|
1387
|
-
"Promise": {
|
|
1388
|
-
"location": "global",
|
|
1389
|
-
"id": "global::Promise"
|
|
1390
|
-
}
|
|
1391
|
-
},
|
|
1392
|
-
"return": "Promise<void>"
|
|
1393
|
-
},
|
|
1394
|
-
"docs": {
|
|
1395
|
-
"text": "Deletes a download (an unfinished one always loses its part file).",
|
|
1396
|
-
"tags": []
|
|
1397
|
-
}
|
|
1398
|
-
},
|
|
1399
|
-
"torrentPathFor": {
|
|
1400
|
-
"complexType": {
|
|
1401
|
-
"signature": "(path: string) => Promise<string | null>",
|
|
1402
|
-
"parameters": [{
|
|
1403
|
-
"name": "path",
|
|
1404
|
-
"type": "string",
|
|
1405
|
-
"docs": ""
|
|
1406
|
-
}],
|
|
1407
|
-
"references": {
|
|
1408
|
-
"Promise": {
|
|
1409
|
-
"location": "global",
|
|
1410
|
-
"id": "global::Promise"
|
|
1411
|
-
}
|
|
1412
|
-
},
|
|
1413
|
-
"return": "Promise<string>"
|
|
1414
|
-
},
|
|
1415
|
-
"docs": {
|
|
1416
|
-
"text": "The path of a `.torrent` on the node relative to the download folder, or\nnull when it lies outside it (then C's menu item is not offered).",
|
|
1417
|
-
"tags": []
|
|
1418
|
-
}
|
|
1419
|
-
},
|
|
1420
|
-
"startTorrentPath": {
|
|
1421
|
-
"complexType": {
|
|
1422
|
-
"signature": "(path: string, inOrder?: boolean) => Promise<boolean>",
|
|
1423
|
-
"parameters": [{
|
|
1424
|
-
"name": "path",
|
|
1425
|
-
"type": "string",
|
|
1426
|
-
"docs": ""
|
|
1427
|
-
}, {
|
|
1428
|
-
"name": "inOrder",
|
|
1429
|
-
"type": "boolean",
|
|
1430
|
-
"docs": ""
|
|
1431
|
-
}],
|
|
1432
|
-
"references": {
|
|
1433
|
-
"Promise": {
|
|
1434
|
-
"location": "global",
|
|
1435
|
-
"id": "global::Promise"
|
|
1436
|
-
}
|
|
1437
|
-
},
|
|
1438
|
-
"return": "Promise<boolean>"
|
|
1439
|
-
},
|
|
1440
|
-
"docs": {
|
|
1441
|
-
"text": "C: download the contents of a `.torrent` already on the node, into the folder it sits in.",
|
|
1442
|
-
"tags": []
|
|
1443
|
-
}
|
|
1444
|
-
}
|
|
1445
|
-
};
|
|
1446
|
-
}
|
|
1447
|
-
static get elementRef() { return "el"; }
|
|
1448
|
-
static get watchers() {
|
|
1449
|
-
return [{
|
|
1450
|
-
"propName": "channel",
|
|
1451
|
-
"methodName": "onChannel"
|
|
1452
|
-
}, {
|
|
1453
|
-
"propName": "connected",
|
|
1454
|
-
"methodName": "onConnected"
|
|
1455
|
-
}, {
|
|
1456
|
-
"propName": "browsingPath",
|
|
1457
|
-
"methodName": "onBrowsing"
|
|
1458
|
-
}, {
|
|
1459
|
-
"propName": "browsingService",
|
|
1460
|
-
"methodName": "onBrowsing"
|
|
1461
|
-
}, {
|
|
1462
|
-
"propName": "nodeId",
|
|
1463
|
-
"methodName": "onNode"
|
|
1464
|
-
}];
|
|
1465
|
-
}
|
|
1466
|
-
}
|