phirepass-widgets 0.0.111 → 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-CCD7cbHu.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-D4JeTIHt.js → protocol-CsYQJXY2.js} +556 -359
- package/dist/phirepass-widgets/p-1b84c526.entry.js +1 -0
- package/dist/phirepass-widgets/{p-9eebbf05.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-D4JeTIHt.js +0 -1
- package/dist/esm/phirepass-sftp-client.entry.js +0 -1467
- package/dist/phirepass-widgets/p-401631af.entry.js +0 -1
- package/dist/phirepass-widgets/p-5f27300b.entry.js +0 -1
- package/dist/phirepass-widgets/p-D4JeTIHt.js +0 -1
- package/dist/phirepass-widgets/p-DGq2b7rM.js +0 -3
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
import { Host, h } from "@stencil/core";
|
|
2
|
+
import { formatBytes, formatClock, formatDay } from "../phirepass-downloader/format";
|
|
3
|
+
import { Icon } from "../phirepass-downloader/views/icons";
|
|
4
|
+
import { SAVE_EVERY_MS, castBlocker, isAudio, localPositionStore, positionAction } from "./player";
|
|
5
|
+
/**
|
|
6
|
+
* Plays a file from the node with the browser's own `<video>` or `<audio>`.
|
|
7
|
+
*
|
|
8
|
+
* It knows nothing of channels or WASM: `src` is a stream URL the server turns
|
|
9
|
+
* into stream events towards the agent, and the browser's range requests do
|
|
10
|
+
* the rest. A download that is still arriving plays as far as `ready` bytes;
|
|
11
|
+
* past that the element waits, and so does the player, saying why.
|
|
12
|
+
*/
|
|
13
|
+
export class PhirepassMediaPlayer {
|
|
14
|
+
el;
|
|
15
|
+
media;
|
|
16
|
+
lastSave = 0;
|
|
17
|
+
resumeAt = 0;
|
|
18
|
+
everPlayed = false;
|
|
19
|
+
/** A stored position was offered (G6): then `startAt` plays, not `autoplay`. */
|
|
20
|
+
positionPrompted = false;
|
|
21
|
+
availabilityId;
|
|
22
|
+
onRemoteConnect = () => (this.phase = 'casting');
|
|
23
|
+
onRemoteDisconnect = () => {
|
|
24
|
+
if (this.phase === 'casting') {
|
|
25
|
+
this.phase = this.everPlayed ? 'playing' : 'buffering';
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
/** The stream URL: `/api/web/stream/{node}/{download}/{file}` or a listing token URL. */
|
|
29
|
+
src;
|
|
30
|
+
name;
|
|
31
|
+
/** Overrides the mime the extension implies. */
|
|
32
|
+
mime;
|
|
33
|
+
/** The status line above the picture, from the job: “Downloading · 23.4%”, “On the node”. */
|
|
34
|
+
status;
|
|
35
|
+
/** Bytes ready from the start of the file, while it is still downloading. */
|
|
36
|
+
ready;
|
|
37
|
+
/** “Continue watching”. Without one, positions stay in this browser. */
|
|
38
|
+
positionStore;
|
|
39
|
+
/** Key for the stored position: `dl:<download_id>:<file>` or `node:<node_id>:<path>`. */
|
|
40
|
+
positionKey;
|
|
41
|
+
/** Stands in for `video.remote`, for demos and tests (like `channelFactory`). */
|
|
42
|
+
remotePlayback;
|
|
43
|
+
/** Shown while casting, when the host knows the device's name. */
|
|
44
|
+
castDevice;
|
|
45
|
+
playerClose;
|
|
46
|
+
phase = 'buffering';
|
|
47
|
+
stored = null;
|
|
48
|
+
castAvailable = false;
|
|
49
|
+
currentTime = 0;
|
|
50
|
+
duration = 0;
|
|
51
|
+
get store() {
|
|
52
|
+
return this.positionStore ?? localPositionStore;
|
|
53
|
+
}
|
|
54
|
+
get audio() {
|
|
55
|
+
return isAudio(this.name, this.mime);
|
|
56
|
+
}
|
|
57
|
+
async componentWillLoad() {
|
|
58
|
+
if (this.positionKey) {
|
|
59
|
+
const stored = await this.store.get(this.positionKey).catch(() => null);
|
|
60
|
+
if (stored && positionAction(stored.secs, stored.duration) === 'save') {
|
|
61
|
+
this.stored = stored;
|
|
62
|
+
this.positionPrompted = true;
|
|
63
|
+
this.phase = 'prompt';
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
componentDidLoad() {
|
|
68
|
+
void this.watchRemote();
|
|
69
|
+
}
|
|
70
|
+
disconnectedCallback() {
|
|
71
|
+
void this.savePosition(true);
|
|
72
|
+
const remote = this.remote();
|
|
73
|
+
if (remote) {
|
|
74
|
+
remote.removeEventListener('connect', this.onRemoteConnect);
|
|
75
|
+
remote.removeEventListener('disconnect', this.onRemoteDisconnect);
|
|
76
|
+
if (this.availabilityId !== undefined) {
|
|
77
|
+
void remote.cancelWatchAvailability(this.availabilityId).catch(() => undefined);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
onSrc() {
|
|
82
|
+
this.everPlayed = false;
|
|
83
|
+
this.phase = 'buffering';
|
|
84
|
+
}
|
|
85
|
+
/** Closes the player, saving where it stopped. The download is not affected. */
|
|
86
|
+
async close() {
|
|
87
|
+
await this.savePosition(true);
|
|
88
|
+
this.media?.pause?.();
|
|
89
|
+
this.playerClose.emit();
|
|
90
|
+
}
|
|
91
|
+
remote() {
|
|
92
|
+
return this.remotePlayback ?? this.media?.remote;
|
|
93
|
+
}
|
|
94
|
+
async watchRemote() {
|
|
95
|
+
const remote = this.remote();
|
|
96
|
+
if (!remote || this.audio) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
remote.addEventListener('connect', this.onRemoteConnect);
|
|
100
|
+
remote.addEventListener('disconnect', this.onRemoteDisconnect);
|
|
101
|
+
if (remote.state === 'connected') {
|
|
102
|
+
this.phase = 'casting';
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
this.availabilityId = await remote.watchAvailability(available => (this.castAvailable = available));
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
// Browsers that cannot watch (Safari without a device, or a policy) still allow prompt() on click.
|
|
109
|
+
this.castAvailable = true;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async savePosition(force = false) {
|
|
113
|
+
const media = this.media;
|
|
114
|
+
if (!media || !this.positionKey || !this.everPlayed) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const now = Date.now();
|
|
118
|
+
if (!force && now - this.lastSave < SAVE_EVERY_MS) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
this.lastSave = now;
|
|
122
|
+
const action = positionAction(media.currentTime, media.duration);
|
|
123
|
+
if (action === 'save') {
|
|
124
|
+
await this.store.set(this.positionKey, media.currentTime, media.duration).catch(() => undefined);
|
|
125
|
+
}
|
|
126
|
+
else if (action === 'clear') {
|
|
127
|
+
await this.store.clear?.(this.positionKey).catch(() => undefined);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
startAt(secs) {
|
|
131
|
+
this.stored = null;
|
|
132
|
+
this.phase = 'buffering';
|
|
133
|
+
this.resumeAt = secs;
|
|
134
|
+
const media = this.media;
|
|
135
|
+
if (media) {
|
|
136
|
+
if (secs > 0) {
|
|
137
|
+
media.currentTime = secs;
|
|
138
|
+
}
|
|
139
|
+
void media.play?.()?.catch?.(() => undefined);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
retry() {
|
|
143
|
+
const media = this.media;
|
|
144
|
+
const at = media?.currentTime || this.resumeAt;
|
|
145
|
+
this.phase = 'buffering';
|
|
146
|
+
if (media) {
|
|
147
|
+
media.load?.();
|
|
148
|
+
this.startAt(at);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
onError() {
|
|
152
|
+
const code = this.media?.error?.code;
|
|
153
|
+
// 2: the network dropped (the node went away or the session ended). 3 and 4: the browser cannot decode it.
|
|
154
|
+
this.phase = code === 2 ? 'stopped' : 'unsupported';
|
|
155
|
+
}
|
|
156
|
+
bindMedia(el) {
|
|
157
|
+
if (!el || el === this.media) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
this.media = el;
|
|
161
|
+
}
|
|
162
|
+
renderStage() {
|
|
163
|
+
switch (this.phase) {
|
|
164
|
+
case 'prompt':
|
|
165
|
+
return (h("div", { class: "stage-msg", "data-phase": "prompt" }, h("b", null, "Resume from ", formatClock(this.stored.secs), "?"), h("span", null, "You stopped here on ", formatDay(this.stored.at), ". ", formatClock(this.stored.duration), " in total."), h("div", { class: "row" }, h("button", { type: "button", class: "btn", onClick: () => this.startAt(0) }, "Start over"), h("button", { type: "button", class: "btn pri", onClick: () => this.startAt(this.stored.secs) }, "Resume"))));
|
|
166
|
+
case 'buffering':
|
|
167
|
+
return (h("div", { class: "stage-msg overlay-msg", "data-phase": "buffering" }, h("span", { class: "spin", "aria-hidden": "true" }), h("b", null, "Buffering"), this.ready !== undefined && h("span", null, formatBytes(this.ready), " ready from the start")));
|
|
168
|
+
case 'waiting':
|
|
169
|
+
return (h("div", { class: "stage-msg overlay-msg", "data-phase": "waiting" }, h("span", { class: "spin", "aria-hidden": "true" }), h("b", null, "Waiting for this part to download"), h("span", null, "You skipped ahead of what the node has. Playback resumes by itself.")));
|
|
170
|
+
case 'unsupported':
|
|
171
|
+
return (h("div", { class: "stage-msg", "data-phase": "unsupported" }, h(Icon, { name: "warn", size: 28 }), h("b", null, "This browser cannot play this format"), h("span", null, "The download is not affected. Download the file to play it in another app."), h("a", { class: "btn pri", href: this.src, download: this.name }, "Download file")));
|
|
172
|
+
case 'stopped':
|
|
173
|
+
return (h("div", { class: "stage-msg", "data-phase": "stopped" }, h(Icon, { name: "signal", size: 28 }), h("b", null, "Playback stopped"), h("span", null, "The connection to the node was lost."), h("button", { type: "button", class: "btn pri", onClick: () => this.retry() }, "Try again")));
|
|
174
|
+
case 'casting':
|
|
175
|
+
return (h("div", { class: "stage-msg", "data-phase": "casting" }, h(Icon, { name: "cast", size: 28 }), h("b", null, "Playing on ", this.castDevice ?? 'your TV'), h("span", null, "The TV reads the file from the node. You can close this tab."), h("span", { class: "clock" }, formatClock(this.currentTime), " / ", formatClock(this.duration)), h("button", { type: "button", class: "btn", onClick: () => void this.remote()?.prompt().catch(() => undefined) }, "Stop casting")));
|
|
176
|
+
default:
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
render() {
|
|
181
|
+
const audio = this.audio;
|
|
182
|
+
const blocked = castBlocker(this.name, this.mime);
|
|
183
|
+
const airplay = typeof this.media?.webkitShowPlaybackTargetPicker === 'function';
|
|
184
|
+
const hideMedia = this.phase === 'prompt' || this.phase === 'unsupported' || this.phase === 'stopped' || this.phase === 'casting';
|
|
185
|
+
const common = {
|
|
186
|
+
ref: (el) => this.bindMedia(el),
|
|
187
|
+
src: this.src,
|
|
188
|
+
controls: true,
|
|
189
|
+
// Play was pressed to get here; a stored position asks first (G6).
|
|
190
|
+
preload: this.phase === 'prompt' ? 'metadata' : 'auto',
|
|
191
|
+
autoplay: !this.positionPrompted,
|
|
192
|
+
playsInline: true,
|
|
193
|
+
class: { hidden: hideMedia },
|
|
194
|
+
onCanPlay: () => {
|
|
195
|
+
if (this.phase === 'buffering' || this.phase === 'waiting') {
|
|
196
|
+
this.phase = 'playing';
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
onPlaying: () => {
|
|
200
|
+
this.everPlayed = true;
|
|
201
|
+
if (this.phase !== 'casting') {
|
|
202
|
+
this.phase = 'playing';
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
onWaiting: () => {
|
|
206
|
+
if (this.phase === 'playing') {
|
|
207
|
+
this.phase = this.everPlayed ? 'waiting' : 'buffering';
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
onTimeUpdate: (e) => {
|
|
211
|
+
const m = e.target;
|
|
212
|
+
this.currentTime = m.currentTime;
|
|
213
|
+
void this.savePosition();
|
|
214
|
+
},
|
|
215
|
+
onDurationChange: (e) => (this.duration = e.target.duration || 0),
|
|
216
|
+
onPause: () => void this.savePosition(true),
|
|
217
|
+
onError: () => this.onError(),
|
|
218
|
+
};
|
|
219
|
+
return (h(Host, { key: '941b4e81590e1144fc0bd424f4a5156ca047624d', class: { audio } }, h("header", { key: 'c1866c6dce284c49a17918c6d0e86d132ea9824a', class: "bar" }, h("span", { key: '645cf1ec23df722e4b479e2d0b9f78aad9c339f1', class: "nm", title: this.name }, this.name), this.status && h("span", { key: 'db77564456be6b4b52b78c709041924b97b930fc', class: "pill" }, this.status), h("span", { key: '4f3203babb8f002bf3b783947a01ff6b06cfdb13', class: "sp" }), !audio && (this.castAvailable || blocked) && (h("button", { key: '3174885867db39af25d328d1bf69879e2e9e5ea5', type: "button", class: "ib", disabled: !!blocked, title: blocked ?? 'Cast', "aria-label": blocked ? `Cast unavailable: ${blocked}` : 'Cast', onClick: () => void this.remote()?.prompt().catch(() => undefined) }, h(Icon, { key: 'c36b4847aa20e6b37da23b8b124bc5a679fcfdf1', name: "cast", size: 15 }))), !audio && airplay && (h("button", { key: '7f1932ac452b57518c608e4723329dac0b9c5698', type: "button", class: "ib", title: "AirPlay", "aria-label": "AirPlay", onClick: () => this.media.webkitShowPlaybackTargetPicker() }, h(Icon, { key: '6814c32ae5b0276260164131f7d017ce24c5063d', name: "cast", size: 15 }))), h("button", { key: 'dfcf1c345b01bd30f8274e637e03a0a7e97a0bb8', type: "button", class: "ib", "aria-label": "Close player", title: "Close", onClick: () => void this.close() }, h(Icon, { key: '2d056a662ae56d4e70ff90cd08ab05cb6c2cf386', name: "x", size: 14 }))), h("div", { key: 'bd610362589f488b395081ae4d12b06da92e8372', class: { stage: true, audio }, "data-phase": this.phase }, audio ? h("audio", { ...common }) : h("video", { ...common }), this.renderStage())));
|
|
220
|
+
}
|
|
221
|
+
static get is() { return "phirepass-media-player"; }
|
|
222
|
+
static get encapsulation() { return "shadow"; }
|
|
223
|
+
static get originalStyleUrls() {
|
|
224
|
+
return {
|
|
225
|
+
"$": ["phirepass-media-player.css"]
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
static get styleUrls() {
|
|
229
|
+
return {
|
|
230
|
+
"$": ["phirepass-media-player.css"]
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
static get properties() {
|
|
234
|
+
return {
|
|
235
|
+
"src": {
|
|
236
|
+
"type": "string",
|
|
237
|
+
"mutable": false,
|
|
238
|
+
"complexType": {
|
|
239
|
+
"original": "string",
|
|
240
|
+
"resolved": "string",
|
|
241
|
+
"references": {}
|
|
242
|
+
},
|
|
243
|
+
"required": true,
|
|
244
|
+
"optional": false,
|
|
245
|
+
"docs": {
|
|
246
|
+
"tags": [],
|
|
247
|
+
"text": "The stream URL: `/api/web/stream/{node}/{download}/{file}` or a listing token URL."
|
|
248
|
+
},
|
|
249
|
+
"getter": false,
|
|
250
|
+
"setter": false,
|
|
251
|
+
"reflect": false,
|
|
252
|
+
"attribute": "src"
|
|
253
|
+
},
|
|
254
|
+
"name": {
|
|
255
|
+
"type": "string",
|
|
256
|
+
"mutable": false,
|
|
257
|
+
"complexType": {
|
|
258
|
+
"original": "string",
|
|
259
|
+
"resolved": "string",
|
|
260
|
+
"references": {}
|
|
261
|
+
},
|
|
262
|
+
"required": true,
|
|
263
|
+
"optional": false,
|
|
264
|
+
"docs": {
|
|
265
|
+
"tags": [],
|
|
266
|
+
"text": ""
|
|
267
|
+
},
|
|
268
|
+
"getter": false,
|
|
269
|
+
"setter": false,
|
|
270
|
+
"reflect": false,
|
|
271
|
+
"attribute": "name"
|
|
272
|
+
},
|
|
273
|
+
"mime": {
|
|
274
|
+
"type": "string",
|
|
275
|
+
"mutable": false,
|
|
276
|
+
"complexType": {
|
|
277
|
+
"original": "string",
|
|
278
|
+
"resolved": "string",
|
|
279
|
+
"references": {}
|
|
280
|
+
},
|
|
281
|
+
"required": false,
|
|
282
|
+
"optional": true,
|
|
283
|
+
"docs": {
|
|
284
|
+
"tags": [],
|
|
285
|
+
"text": "Overrides the mime the extension implies."
|
|
286
|
+
},
|
|
287
|
+
"getter": false,
|
|
288
|
+
"setter": false,
|
|
289
|
+
"reflect": false,
|
|
290
|
+
"attribute": "mime"
|
|
291
|
+
},
|
|
292
|
+
"status": {
|
|
293
|
+
"type": "string",
|
|
294
|
+
"mutable": false,
|
|
295
|
+
"complexType": {
|
|
296
|
+
"original": "string",
|
|
297
|
+
"resolved": "string",
|
|
298
|
+
"references": {}
|
|
299
|
+
},
|
|
300
|
+
"required": false,
|
|
301
|
+
"optional": true,
|
|
302
|
+
"docs": {
|
|
303
|
+
"tags": [],
|
|
304
|
+
"text": "The status line above the picture, from the job: \u201CDownloading \u00B7 23.4%\u201D, \u201COn the node\u201D."
|
|
305
|
+
},
|
|
306
|
+
"getter": false,
|
|
307
|
+
"setter": false,
|
|
308
|
+
"reflect": false,
|
|
309
|
+
"attribute": "status"
|
|
310
|
+
},
|
|
311
|
+
"ready": {
|
|
312
|
+
"type": "number",
|
|
313
|
+
"mutable": false,
|
|
314
|
+
"complexType": {
|
|
315
|
+
"original": "number",
|
|
316
|
+
"resolved": "number",
|
|
317
|
+
"references": {}
|
|
318
|
+
},
|
|
319
|
+
"required": false,
|
|
320
|
+
"optional": true,
|
|
321
|
+
"docs": {
|
|
322
|
+
"tags": [],
|
|
323
|
+
"text": "Bytes ready from the start of the file, while it is still downloading."
|
|
324
|
+
},
|
|
325
|
+
"getter": false,
|
|
326
|
+
"setter": false,
|
|
327
|
+
"reflect": false,
|
|
328
|
+
"attribute": "ready"
|
|
329
|
+
},
|
|
330
|
+
"positionStore": {
|
|
331
|
+
"type": "unknown",
|
|
332
|
+
"mutable": false,
|
|
333
|
+
"complexType": {
|
|
334
|
+
"original": "PositionStore",
|
|
335
|
+
"resolved": "{ get(key: string): Promise<StoredPosition>; set(key: string, secs: number, duration: number): Promise<void>; clear?(key: string): Promise<void>; }",
|
|
336
|
+
"references": {
|
|
337
|
+
"PositionStore": {
|
|
338
|
+
"location": "import",
|
|
339
|
+
"path": "./player",
|
|
340
|
+
"id": "src/components/phirepass-media-player/player.ts::PositionStore",
|
|
341
|
+
"referenceLocation": "PositionStore"
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
"required": false,
|
|
346
|
+
"optional": true,
|
|
347
|
+
"docs": {
|
|
348
|
+
"tags": [],
|
|
349
|
+
"text": "\u201CContinue watching\u201D. Without one, positions stay in this browser."
|
|
350
|
+
},
|
|
351
|
+
"getter": false,
|
|
352
|
+
"setter": false
|
|
353
|
+
},
|
|
354
|
+
"positionKey": {
|
|
355
|
+
"type": "string",
|
|
356
|
+
"mutable": false,
|
|
357
|
+
"complexType": {
|
|
358
|
+
"original": "string",
|
|
359
|
+
"resolved": "string",
|
|
360
|
+
"references": {}
|
|
361
|
+
},
|
|
362
|
+
"required": false,
|
|
363
|
+
"optional": true,
|
|
364
|
+
"docs": {
|
|
365
|
+
"tags": [],
|
|
366
|
+
"text": "Key for the stored position: `dl:<download_id>:<file>` or `node:<node_id>:<path>`."
|
|
367
|
+
},
|
|
368
|
+
"getter": false,
|
|
369
|
+
"setter": false,
|
|
370
|
+
"reflect": false,
|
|
371
|
+
"attribute": "position-key"
|
|
372
|
+
},
|
|
373
|
+
"remotePlayback": {
|
|
374
|
+
"type": "unknown",
|
|
375
|
+
"mutable": false,
|
|
376
|
+
"complexType": {
|
|
377
|
+
"original": "RemotePlaybackLike",
|
|
378
|
+
"resolved": "{ state: \"connected\" | \"disconnected\" | \"connecting\"; watchAvailability(cb: (available: boolean) => void): Promise<number>; cancelWatchAvailability(id?: number): Promise<void>; prompt(): Promise<void>; addEventListener(type: \"connect\" | \"disconnect\" | \"connecting\", cb: () => void): void; removeEventListener(type: \"connect\" | \"disconnect\" | \"connecting\", cb: () => void): void; }",
|
|
379
|
+
"references": {
|
|
380
|
+
"RemotePlaybackLike": {
|
|
381
|
+
"location": "import",
|
|
382
|
+
"path": "./player",
|
|
383
|
+
"id": "src/components/phirepass-media-player/player.ts::RemotePlaybackLike",
|
|
384
|
+
"referenceLocation": "RemotePlaybackLike"
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
"required": false,
|
|
389
|
+
"optional": true,
|
|
390
|
+
"docs": {
|
|
391
|
+
"tags": [],
|
|
392
|
+
"text": "Stands in for `video.remote`, for demos and tests (like `channelFactory`)."
|
|
393
|
+
},
|
|
394
|
+
"getter": false,
|
|
395
|
+
"setter": false
|
|
396
|
+
},
|
|
397
|
+
"castDevice": {
|
|
398
|
+
"type": "string",
|
|
399
|
+
"mutable": false,
|
|
400
|
+
"complexType": {
|
|
401
|
+
"original": "string",
|
|
402
|
+
"resolved": "string",
|
|
403
|
+
"references": {}
|
|
404
|
+
},
|
|
405
|
+
"required": false,
|
|
406
|
+
"optional": true,
|
|
407
|
+
"docs": {
|
|
408
|
+
"tags": [],
|
|
409
|
+
"text": "Shown while casting, when the host knows the device's name."
|
|
410
|
+
},
|
|
411
|
+
"getter": false,
|
|
412
|
+
"setter": false,
|
|
413
|
+
"reflect": false,
|
|
414
|
+
"attribute": "cast-device"
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
static get states() {
|
|
419
|
+
return {
|
|
420
|
+
"phase": {},
|
|
421
|
+
"stored": {},
|
|
422
|
+
"castAvailable": {},
|
|
423
|
+
"currentTime": {},
|
|
424
|
+
"duration": {}
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
static get events() {
|
|
428
|
+
return [{
|
|
429
|
+
"method": "playerClose",
|
|
430
|
+
"name": "phirepassPlayerClose",
|
|
431
|
+
"bubbles": true,
|
|
432
|
+
"cancelable": true,
|
|
433
|
+
"composed": true,
|
|
434
|
+
"docs": {
|
|
435
|
+
"tags": [],
|
|
436
|
+
"text": ""
|
|
437
|
+
},
|
|
438
|
+
"complexType": {
|
|
439
|
+
"original": "void",
|
|
440
|
+
"resolved": "void",
|
|
441
|
+
"references": {}
|
|
442
|
+
}
|
|
443
|
+
}];
|
|
444
|
+
}
|
|
445
|
+
static get methods() {
|
|
446
|
+
return {
|
|
447
|
+
"close": {
|
|
448
|
+
"complexType": {
|
|
449
|
+
"signature": "() => Promise<void>",
|
|
450
|
+
"parameters": [],
|
|
451
|
+
"references": {
|
|
452
|
+
"Promise": {
|
|
453
|
+
"location": "global",
|
|
454
|
+
"id": "global::Promise"
|
|
455
|
+
}
|
|
456
|
+
},
|
|
457
|
+
"return": "Promise<void>"
|
|
458
|
+
},
|
|
459
|
+
"docs": {
|
|
460
|
+
"text": "Closes the player, saving where it stopped. The download is not affected.",
|
|
461
|
+
"tags": []
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
static get elementRef() { return "el"; }
|
|
467
|
+
static get watchers() {
|
|
468
|
+
return [{
|
|
469
|
+
"propName": "src",
|
|
470
|
+
"methodName": "onSrc"
|
|
471
|
+
}];
|
|
472
|
+
}
|
|
473
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
const MIME = {
|
|
2
|
+
mp4: 'video/mp4',
|
|
3
|
+
m4v: 'video/mp4',
|
|
4
|
+
webm: 'video/webm',
|
|
5
|
+
mkv: 'video/x-matroska',
|
|
6
|
+
mov: 'video/quicktime',
|
|
7
|
+
mp3: 'audio/mpeg',
|
|
8
|
+
m4a: 'audio/mp4',
|
|
9
|
+
flac: 'audio/flac',
|
|
10
|
+
ogg: 'audio/ogg',
|
|
11
|
+
oga: 'audio/ogg',
|
|
12
|
+
opus: 'audio/ogg',
|
|
13
|
+
wav: 'audio/wav',
|
|
14
|
+
};
|
|
15
|
+
export function extOf(name) {
|
|
16
|
+
const m = /\.([a-z0-9]+)$/i.exec(name);
|
|
17
|
+
return m ? m[1].toLowerCase() : '';
|
|
18
|
+
}
|
|
19
|
+
/** Mime from the extension, as the agent's stream server decides it. */
|
|
20
|
+
export function mimeFor(name) {
|
|
21
|
+
return MIME[extOf(name)] ?? 'application/octet-stream';
|
|
22
|
+
}
|
|
23
|
+
export function isAudio(name, mime) {
|
|
24
|
+
return (mime ?? mimeFor(name)).startsWith('audio/');
|
|
25
|
+
}
|
|
26
|
+
export function isPlayableName(name) {
|
|
27
|
+
return extOf(name) in MIME;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Whether a Cast receiver can play this. The Default Media Receiver plays MP4
|
|
31
|
+
* (H.264/AAC), WebM and common audio, mostly not MKV or MOV.
|
|
32
|
+
*/
|
|
33
|
+
export function castBlocker(name, mime) {
|
|
34
|
+
const m = mime ?? mimeFor(name);
|
|
35
|
+
if (m === 'video/x-matroska') {
|
|
36
|
+
return 'TVs cannot play MKV files. Download it and play it with VLC.';
|
|
37
|
+
}
|
|
38
|
+
if (m === 'video/quicktime') {
|
|
39
|
+
return 'TVs cannot play MOV files.';
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
/** Nothing is saved in the first 30 seconds. */
|
|
44
|
+
export const SAVE_AFTER_SECS = 30;
|
|
45
|
+
export const SAVE_EVERY_MS = 10_000;
|
|
46
|
+
/** Past 95%, or within the last two minutes, the file counts as watched and the position is cleared. */
|
|
47
|
+
export function isWatched(secs, duration) {
|
|
48
|
+
if (!Number.isFinite(duration) || duration <= 0) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return secs >= duration * 0.95 || duration - secs <= 120;
|
|
52
|
+
}
|
|
53
|
+
export function positionAction(secs, duration) {
|
|
54
|
+
if (isWatched(secs, duration)) {
|
|
55
|
+
return 'clear';
|
|
56
|
+
}
|
|
57
|
+
if (secs < SAVE_AFTER_SECS) {
|
|
58
|
+
return 'skip';
|
|
59
|
+
}
|
|
60
|
+
return 'save';
|
|
61
|
+
}
|
|
62
|
+
const LS_PREFIX = 'phirepass.player.position.';
|
|
63
|
+
/** The fallback store, per browser. Every access is guarded: storage can be missing or refuse. */
|
|
64
|
+
export const localPositionStore = {
|
|
65
|
+
async get(key) {
|
|
66
|
+
try {
|
|
67
|
+
const raw = window.localStorage.getItem(LS_PREFIX + key);
|
|
68
|
+
if (!raw) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const value = JSON.parse(raw);
|
|
72
|
+
return typeof value?.secs === 'number' ? value : null;
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
async set(key, secs, duration) {
|
|
79
|
+
try {
|
|
80
|
+
window.localStorage.setItem(LS_PREFIX + key, JSON.stringify({ secs, duration, at: Date.now() }));
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
// Nothing to do: the next visit starts from the beginning.
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
async clear(key) {
|
|
87
|
+
try {
|
|
88
|
+
window.localStorage.removeItem(LS_PREFIX + key);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// ignore
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
};
|
|
@@ -3,16 +3,6 @@ import init, { Channel as PhirepassChannel } from "phirepass-channel";
|
|
|
3
3
|
import { ConnectionState, ProtocolMessageType, } from "../../common/protocol";
|
|
4
4
|
import { measure_initial_desktop_size, ViewportSync } from "./phirepass-rdp.viewport";
|
|
5
5
|
import { focus_client, keyboard_lock_supported, lock_keyboard, shown_fullscreen, toggle_fullscreen, unlock_keyboard, } from "./phirepass-rdp.keyboard";
|
|
6
|
-
/**
|
|
7
|
-
* Remote desktop over RDP.
|
|
8
|
-
*
|
|
9
|
-
* Unlike the terminal and SFTP widgets this one does not pipe protocol bytes
|
|
10
|
-
* through the phirepass channel. The channel is used only to authorise the
|
|
11
|
-
* session; the actual RDP stream runs on a second WebSocket opened by IronRDP's
|
|
12
|
-
* own client, because that client speaks RDCleanPath and can set neither
|
|
13
|
-
* headers nor a subprotocol on the socket it opens. See `RDP.md` in
|
|
14
|
-
* `phirepass-rs` for why the session is split across two sockets.
|
|
15
|
-
*/
|
|
16
6
|
export class PhirepassRdp {
|
|
17
7
|
channel;
|
|
18
8
|
containerEl;
|
|
@@ -102,6 +92,12 @@ export class PhirepassRdp {
|
|
|
102
92
|
}
|
|
103
93
|
}
|
|
104
94
|
serverId;
|
|
95
|
+
/**
|
|
96
|
+
* Supplies the channel instead of a WebSocket to the server — for demos,
|
|
97
|
+
* screenshots and tests, as on the terminal and SFTP client. A property
|
|
98
|
+
* only; read once, when the widget connects.
|
|
99
|
+
*/
|
|
100
|
+
channelFactory;
|
|
105
101
|
onServerIdChange(_newValue, _oldValue) {
|
|
106
102
|
this.onNodeIdChange(this.nodeId, this.nodeId);
|
|
107
103
|
}
|
|
@@ -121,7 +117,9 @@ export class PhirepassRdp {
|
|
|
121
117
|
// A widget can be moved in the DOM rather than destroyed, which
|
|
122
118
|
// disconnects and reconnects it; the second life is a real one.
|
|
123
119
|
this.disposed = false;
|
|
124
|
-
|
|
120
|
+
if (!this.channelFactory) {
|
|
121
|
+
await init();
|
|
122
|
+
}
|
|
125
123
|
this.open_comms();
|
|
126
124
|
this.runtimeReady = true;
|
|
127
125
|
if (!this.nodeId) {
|
|
@@ -217,7 +215,10 @@ export class PhirepassRdp {
|
|
|
217
215
|
this.channel.connect();
|
|
218
216
|
}
|
|
219
217
|
open_comms() {
|
|
220
|
-
if (this.
|
|
218
|
+
if (this.channelFactory) {
|
|
219
|
+
this.channel = this.channelFactory(`${this.create_web_socket_endpoint()}/api/web/ws`, this.nodeId, this.serverId || undefined);
|
|
220
|
+
}
|
|
221
|
+
else if (this.serverId) {
|
|
221
222
|
this.channel = new PhirepassChannel(`${this.create_web_socket_endpoint()}/api/web/ws`, this.nodeId, this.serverId);
|
|
222
223
|
}
|
|
223
224
|
else {
|
|
@@ -536,7 +537,7 @@ export class PhirepassRdp {
|
|
|
536
537
|
this.request_tunnel();
|
|
537
538
|
}
|
|
538
539
|
render() {
|
|
539
|
-
return (h(Host, { key: '
|
|
540
|
+
return (h(Host, { key: '04896084a5e914a9e2a184ee7b560f4978da9bfd' }, h("div", { key: 'db5d3d0d4351aeb868ffe6956b86f22b62775e4b', class: "screen", ref: (el) => (this.containerEl = el) }, h("slot", { key: 'efafd5d8b1437687713aff0425c050413593d162' })), this.credentialsPrompt && (h("form", { key: 'ad6079b6db1d71e8eb60bef71cd808be22b7387c', class: "prompt", onSubmit: (event) => this.submit_credentials(event) }, h("label", { key: 'b976c7a3c01e4983fac39e1ef027e4307a6654c7', htmlFor: "rdp-username" }, "Username"), h("input", { key: '3a90a73a446015d708eaebec6a7d9bc1703ae5d0', id: "rdp-username", type: "text", autocomplete: "off", autofocus: true, onInput: (event) => (this.usernameBuffer = event.target.value) }), h("label", { key: 'eaf13aa5fe39e4576de052b15c85e6b60be466cb', htmlFor: "rdp-password" }, "Password"), h("input", { key: 'd53ec8c48b7826b011a07bcb57b7ae1fbe30160f', id: "rdp-password", type: "password", autocomplete: "off", onInput: (event) => (this.passwordBuffer = event.target.value) }), h("button", { key: 'd1616e75c1f37a853ec793a25ffc8919544c16d2', type: "submit" }, "Connect"))), this.statusMessage && !this.credentialsPrompt && (h("div", { key: '8e6deb9e32f0c416bf85666847f10e095f40e210', class: "status" }, this.statusMessage))));
|
|
540
541
|
}
|
|
541
542
|
static get is() { return "phirepass-rdp"; }
|
|
542
543
|
static get encapsulation() { return "shadow"; }
|
|
@@ -844,6 +845,28 @@ export class PhirepassRdp {
|
|
|
844
845
|
"setter": false,
|
|
845
846
|
"reflect": false,
|
|
846
847
|
"attribute": "server-id"
|
|
848
|
+
},
|
|
849
|
+
"channelFactory": {
|
|
850
|
+
"type": "unknown",
|
|
851
|
+
"mutable": false,
|
|
852
|
+
"complexType": {
|
|
853
|
+
"original": "(endpoint: string, nodeId: string, serverId?: string) => RdpChannelLike",
|
|
854
|
+
"resolved": "(endpoint: string, nodeId: string, serverId?: string) => RdpChannelLike",
|
|
855
|
+
"references": {
|
|
856
|
+
"RdpChannelLike": {
|
|
857
|
+
"location": "global",
|
|
858
|
+
"id": "global::RdpChannelLike"
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
},
|
|
862
|
+
"required": false,
|
|
863
|
+
"optional": true,
|
|
864
|
+
"docs": {
|
|
865
|
+
"tags": [],
|
|
866
|
+
"text": "Supplies the channel instead of a WebSocket to the server \u2014 for demos,\nscreenshots and tests, as on the terminal and SFTP client. A property\nonly; read once, when the widget connects."
|
|
867
|
+
},
|
|
868
|
+
"getter": false,
|
|
869
|
+
"setter": false
|
|
847
870
|
}
|
|
848
871
|
};
|
|
849
872
|
}
|