phirepass-widgets 0.0.104 → 0.0.106
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/dist/cjs/phirepass-rdp.cjs.entry.js +1 -1
- package/dist/cjs/phirepass-sftp-client.cjs.entry.js +1 -1
- package/dist/cjs/phirepass-terminal.cjs.entry.js +118 -7
- package/dist/cjs/{protocol-9IbZ-NTW.js → protocol-CrMtxghg.js} +3 -3
- package/dist/collection/components/phirepass-terminal/phirepass-terminal.js +117 -6
- package/dist/collection/phirepass-channel_bg.wasm +0 -0
- package/dist/components/{p-D4vz9Xu4.js → p-YZKVM0AX.js} +1 -1
- 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/phirepass-rdp.entry.js +1 -1
- package/dist/esm/phirepass-sftp-client.entry.js +1 -1
- package/dist/esm/phirepass-terminal.entry.js +118 -7
- package/dist/esm/{protocol-D4vz9Xu4.js → protocol-YZKVM0AX.js} +2 -2
- package/dist/phirepass-widgets/{p-944c0f09.entry.js → p-0f7d5b4b.entry.js} +1 -1
- package/dist/phirepass-widgets/{p-151b957b.entry.js → p-2b696bc3.entry.js} +5 -5
- package/dist/phirepass-widgets/{p-D4vz9Xu4.js → p-YZKVM0AX.js} +1 -1
- package/dist/phirepass-widgets/{p-a6f2b860.entry.js → p-c976ff11.entry.js} +1 -1
- package/dist/phirepass-widgets/phirepass-channel_bg.wasm +0 -0
- package/dist/phirepass-widgets/phirepass-widgets.esm.js +1 -1
- package/dist/types/components/phirepass-terminal/phirepass-terminal.d.ts +42 -0
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var index = require('./index-CbZdPuPQ.js');
|
|
4
|
-
var protocol = require('./protocol-
|
|
4
|
+
var protocol = require('./protocol-CrMtxghg.js');
|
|
5
5
|
|
|
6
6
|
const phirepassSftpClientLogoSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoNDYsIDE4NCwgMTM4KSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiCiAgICBjbGFzcz0ibHVjaWRlIGx1Y2lkZS10ZXJtaW5hbCB3LTMuNSBoLTMuNSB0ZXh0LXByaW1hcnkiPgogICAgPHBvbHlsaW5lIHBvaW50cz0iNCAxNyAxMCAxMSA0IDUiPjwvcG9seWxpbmU+CiAgICA8bGluZSB4MT0iMTIiIHgyPSIyMCIgeTE9IjE5IiB5Mj0iMTkiPjwvbGluZT4KPC9zdmc+Cg==';
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var index = require('./index-CbZdPuPQ.js');
|
|
4
|
-
var protocol = require('./protocol-
|
|
4
|
+
var protocol = require('./protocol-CrMtxghg.js');
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
@@ -240,6 +240,24 @@ function control_char(key) {
|
|
|
240
240
|
return '\u007f';
|
|
241
241
|
return null;
|
|
242
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* How many frames to keep re-trying a fit before leaving it to the observer.
|
|
245
|
+
*
|
|
246
|
+
* Generous, because what is being waited on is a font load and a layout pass,
|
|
247
|
+
* not a network round trip — and cheap, because each attempt is one measurement
|
|
248
|
+
* that stops the moment it succeeds.
|
|
249
|
+
*/
|
|
250
|
+
const FIT_MAX_ATTEMPTS = 60;
|
|
251
|
+
/**
|
|
252
|
+
* How much of the container the session may leave unfilled and still count as
|
|
253
|
+
* fitted.
|
|
254
|
+
*
|
|
255
|
+
* There is always a remainder: rows are whole, so the last partial row's worth
|
|
256
|
+
* of pixels belongs to nobody. One cell is normal and invisible; half a panel is
|
|
257
|
+
* the bug this guards. Sized above any realistic cell height so a correctly
|
|
258
|
+
* fitted terminal is never retried, and far below the gap a stale fit leaves.
|
|
259
|
+
*/
|
|
260
|
+
const FIT_SLACK_PX = 48;
|
|
243
261
|
/** The bar, left to right. `label` is what is drawn; `hint` is for a screen reader. */
|
|
244
262
|
const KEY_BAR_KEYS = [
|
|
245
263
|
{ id: 'esc', label: 'esc', hint: 'Escape', data: '\u001b' },
|
|
@@ -269,6 +287,7 @@ const PhirepassTerminal = class {
|
|
|
269
287
|
inputMode = protocol.InputMode.Default;
|
|
270
288
|
resizeObserver;
|
|
271
289
|
resizeDebounceHandle;
|
|
290
|
+
fitRetryHandle;
|
|
272
291
|
session_id;
|
|
273
292
|
usernameBuffer = "";
|
|
274
293
|
passwordBuffer = "";
|
|
@@ -403,6 +422,10 @@ const PhirepassTerminal = class {
|
|
|
403
422
|
clearTimeout(this.resizeDebounceHandle);
|
|
404
423
|
this.resizeDebounceHandle = undefined;
|
|
405
424
|
}
|
|
425
|
+
if (this.fitRetryHandle !== undefined) {
|
|
426
|
+
cancelAnimationFrame(this.fitRetryHandle);
|
|
427
|
+
this.fitRetryHandle = undefined;
|
|
428
|
+
}
|
|
406
429
|
if (this.resizeObserver) {
|
|
407
430
|
this.resizeObserver.disconnect();
|
|
408
431
|
}
|
|
@@ -415,16 +438,76 @@ const PhirepassTerminal = class {
|
|
|
415
438
|
is_terminal_open() {
|
|
416
439
|
return Boolean(this.connected && this.containerEl && this.terminal.element);
|
|
417
440
|
}
|
|
441
|
+
/**
|
|
442
|
+
* Size the session to its container, and **keep trying until it works**.
|
|
443
|
+
*
|
|
444
|
+
* The bug this replaces: a fit could be skipped — the renderer not ready
|
|
445
|
+
* yet, `connected` not yet set, `fit()` throwing on dimensions that do not
|
|
446
|
+
* exist for another frame — and nothing ever retried it. The only other
|
|
447
|
+
* thing that fits is the `ResizeObserver`, so a terminal opened into a
|
|
448
|
+
* container that never changes size again stayed at whatever number of rows
|
|
449
|
+
* it happened to have. On a panel the user does not resize, that is
|
|
450
|
+
* permanent: the session renders at a fraction of the height it was given
|
|
451
|
+
* and the dead space below it is not part of the terminal at all.
|
|
452
|
+
*
|
|
453
|
+
* Retrying on `requestAnimationFrame` rather than a timer because what is
|
|
454
|
+
* being waited for *is* a frame: xterm computes its cell metrics from a
|
|
455
|
+
* measured element, and that measurement is only meaningful once the
|
|
456
|
+
* browser has laid the container out and the font it will actually use has
|
|
457
|
+
* loaded. The attempt cap keeps a container that is genuinely zero-sized —
|
|
458
|
+
* a hidden tab, a collapsed panel — from spinning a frame loop forever;
|
|
459
|
+
* the observer will call this again when it gains a size.
|
|
460
|
+
*/
|
|
461
|
+
schedule_fit() {
|
|
462
|
+
if (this.fitRetryHandle !== undefined) {
|
|
463
|
+
cancelAnimationFrame(this.fitRetryHandle);
|
|
464
|
+
this.fitRetryHandle = undefined;
|
|
465
|
+
}
|
|
466
|
+
let attempts = 0;
|
|
467
|
+
const attempt = () => {
|
|
468
|
+
this.fitRetryHandle = undefined;
|
|
469
|
+
if (this.fit_terminal_safely()) {
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
attempts += 1;
|
|
473
|
+
if (attempts >= FIT_MAX_ATTEMPTS) {
|
|
474
|
+
console.warn('Giving up fitting the terminal; waiting for a resize instead');
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
this.fitRetryHandle = requestAnimationFrame(attempt);
|
|
478
|
+
};
|
|
479
|
+
attempt();
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* One attempt. `true` when the session is now sized to its container.
|
|
483
|
+
*
|
|
484
|
+
* A container with no height yet counts as a failure rather than a success,
|
|
485
|
+
* which is what makes the retry above worth having: `fit()` on a zero-height
|
|
486
|
+
* parent does not throw, it computes one row and returns happily.
|
|
487
|
+
*/
|
|
418
488
|
fit_terminal_safely() {
|
|
419
489
|
if (!this.fitAddon || !this.is_terminal_open()) {
|
|
420
|
-
return;
|
|
490
|
+
return false;
|
|
491
|
+
}
|
|
492
|
+
const height = this.containerEl?.clientHeight ?? 0;
|
|
493
|
+
const width = this.containerEl?.clientWidth ?? 0;
|
|
494
|
+
if (height <= 0 || width <= 0) {
|
|
495
|
+
return false;
|
|
421
496
|
}
|
|
422
497
|
try {
|
|
423
498
|
this.fitAddon.fit();
|
|
424
499
|
}
|
|
425
500
|
catch (err) {
|
|
426
501
|
console.warn('Skipping terminal fit before renderer is ready:', err);
|
|
502
|
+
return false;
|
|
427
503
|
}
|
|
504
|
+
// Fitted, but to the right thing? `proposeDimensions` can be answered
|
|
505
|
+
// from stale cell metrics — most often when a web font finishes loading
|
|
506
|
+
// after the first measurement — and the symptom is a session that fills
|
|
507
|
+
// half its panel. Compare what we got against what there was to fill.
|
|
508
|
+
const rows = this.terminal?.rows ?? 0;
|
|
509
|
+
const rendered = this.terminal.element?.clientHeight ?? 0;
|
|
510
|
+
return rows > 0 && rendered > 0 && height - rendered < FIT_SLACK_PX;
|
|
428
511
|
}
|
|
429
512
|
try_connect() {
|
|
430
513
|
if (this.connected || !this.domReady || !this.runtimeReady) {
|
|
@@ -612,7 +695,7 @@ const PhirepassTerminal = class {
|
|
|
612
695
|
handle_tunnel_opened(web) {
|
|
613
696
|
this.session_id = web.sid;
|
|
614
697
|
this.terminal.reset();
|
|
615
|
-
this.
|
|
698
|
+
this.schedule_fit();
|
|
616
699
|
this.send_ssh_terminal_resize();
|
|
617
700
|
}
|
|
618
701
|
handle_tunnel_data(web) {
|
|
@@ -633,14 +716,42 @@ const PhirepassTerminal = class {
|
|
|
633
716
|
this.terminal.open(container);
|
|
634
717
|
console.log('Terminal opened in container');
|
|
635
718
|
this.connected = true;
|
|
636
|
-
|
|
719
|
+
// Scheduled, not attempted once: `open()` has only just handed the
|
|
720
|
+
// renderer its element, so the first measurement is routinely the
|
|
721
|
+
// one that is too early.
|
|
722
|
+
this.schedule_fit();
|
|
637
723
|
this.terminal.focus();
|
|
638
724
|
this.terminal.onData(this.handle_terminal_data.bind(this));
|
|
639
725
|
this.channel.connect();
|
|
640
726
|
this.setup_resize_observer();
|
|
727
|
+
this.refit_when_fonts_settle();
|
|
641
728
|
console.log('Terminal connected and ready');
|
|
642
729
|
}
|
|
643
730
|
}
|
|
731
|
+
/**
|
|
732
|
+
* Fit again once the web fonts have actually loaded.
|
|
733
|
+
*
|
|
734
|
+
* xterm measures one character to derive its cell size, and if that
|
|
735
|
+
* measurement happens while the browser is still falling back — "Berkeley
|
|
736
|
+
* Mono" and "Fira Code" are both remote — every row is sized from the wrong
|
|
737
|
+
* font. The container does not change size when the real font arrives, so
|
|
738
|
+
* the `ResizeObserver` never fires and nothing else would ever correct it.
|
|
739
|
+
*
|
|
740
|
+
* Guarded because `document.fonts` is absent in some embedding contexts, and
|
|
741
|
+
* a missing font API is not a reason to fail to open a shell.
|
|
742
|
+
*/
|
|
743
|
+
refit_when_fonts_settle() {
|
|
744
|
+
const fonts = document.fonts;
|
|
745
|
+
if (!fonts?.ready) {
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
void fonts.ready.then(() => {
|
|
749
|
+
if (this.connected) {
|
|
750
|
+
this.schedule_fit();
|
|
751
|
+
this.send_ssh_terminal_resize();
|
|
752
|
+
}
|
|
753
|
+
});
|
|
754
|
+
}
|
|
644
755
|
setup_resize_observer() {
|
|
645
756
|
this.resizeObserver = new ResizeObserver(() => {
|
|
646
757
|
console.log('Container resized, fitting terminal');
|
|
@@ -648,7 +759,7 @@ const PhirepassTerminal = class {
|
|
|
648
759
|
clearTimeout(this.resizeDebounceHandle);
|
|
649
760
|
}
|
|
650
761
|
this.resizeDebounceHandle = setTimeout(() => {
|
|
651
|
-
this.
|
|
762
|
+
this.schedule_fit();
|
|
652
763
|
this.send_ssh_terminal_resize();
|
|
653
764
|
}, 100);
|
|
654
765
|
});
|
|
@@ -831,13 +942,13 @@ const PhirepassTerminal = class {
|
|
|
831
942
|
return (index.h("button", { key: id, type: "button", class: { key: true, armed: !!armed }, "aria-label": hint, "aria-pressed": armed === undefined ? undefined : String(armed), onPointerDown: (event) => event.preventDefault(), onMouseDown: (event) => event.preventDefault(), onClick: onPress }, label));
|
|
832
943
|
}
|
|
833
944
|
render() {
|
|
834
|
-
return (index.h(index.Host, { key: '
|
|
945
|
+
return (index.h(index.Host, { key: 'a4e7018d85dc6ac27abfb46e199c1d2d947e57c6', class: { 'keys-on': this.keyBar === 'on', 'keys-off': this.keyBar === 'off' } }, index.h("div", { key: '0603c1fd65d7c70c0d48d45c4b85a7ad14c913bf', id: "ccc", ref: el => (this.containerEl = el) }), index.h("div", { key: '30bc8d4e31816e3c83d422133bbe9c1ced323141', class: "keys", role: "toolbar", "aria-label": "Terminal keys" }, this.key_button('ctrl', 'ctrl', 'Control', () => {
|
|
835
946
|
this.ctrlArmed = !this.ctrlArmed;
|
|
836
947
|
this.terminal?.focus();
|
|
837
948
|
}, this.ctrlArmed), this.key_button('alt', 'alt', 'Alt', () => {
|
|
838
949
|
this.altArmed = !this.altArmed;
|
|
839
950
|
this.terminal?.focus();
|
|
840
|
-
}, this.altArmed), KEY_BAR_KEYS.map(entry => this.key_button(entry.id, entry.label, entry.hint, () => this.press(entry.data))), index.h("span", { key: '
|
|
951
|
+
}, this.altArmed), KEY_BAR_KEYS.map(entry => this.key_button(entry.id, entry.label, entry.hint, () => this.press(entry.data))), index.h("span", { key: '117e1718e8f4bc7451dd95222733ef3f841600db', class: "spacer" }), this.key_button('left', '←', 'Left arrow', () => this.press(this.arrow('D'))), this.key_button('down', '↓', 'Down arrow', () => this.press(this.arrow('B'))), this.key_button('up', '↑', 'Up arrow', () => this.press(this.arrow('A'))), this.key_button('right', '→', 'Right arrow', () => this.press(this.arrow('C'))))));
|
|
841
952
|
}
|
|
842
953
|
static get watchers() { return {
|
|
843
954
|
"nodeId": [{
|
|
@@ -552,7 +552,7 @@ function __wbg_get_imports() {
|
|
|
552
552
|
const ret = Reflect.get(getObject(arg0), getObject(arg1));
|
|
553
553
|
return addHeapObject(ret);
|
|
554
554
|
}, arguments); },
|
|
555
|
-
|
|
555
|
+
__wbg_info_c923009936ad8385: function(arg0, arg1) {
|
|
556
556
|
console.info(getStringFromWasm0(arg0, arg1));
|
|
557
557
|
},
|
|
558
558
|
__wbg_instanceof_ArrayBuffer_d4ff01f8247925ae: function(arg0) {
|
|
@@ -624,7 +624,7 @@ function __wbg_get_imports() {
|
|
|
624
624
|
__wbg_set_onopen_e91e64af99b7966d: function(arg0, arg1) {
|
|
625
625
|
getObject(arg0).onopen = getObject(arg1);
|
|
626
626
|
},
|
|
627
|
-
|
|
627
|
+
__wbg_warn_5936938922985853: function(arg0, arg1) {
|
|
628
628
|
console.warn(getStringFromWasm0(arg0, arg1));
|
|
629
629
|
},
|
|
630
630
|
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
@@ -998,7 +998,7 @@ async function __wbg_init(module_or_path) {
|
|
|
998
998
|
}
|
|
999
999
|
|
|
1000
1000
|
if (module_or_path === undefined) {
|
|
1001
|
-
module_or_path = new URL('phirepass-channel_bg.wasm', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('protocol-
|
|
1001
|
+
module_or_path = new URL('phirepass-channel_bg.wasm', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('protocol-CrMtxghg.js', document.baseURI).href)));
|
|
1002
1002
|
}
|
|
1003
1003
|
const imports = __wbg_get_imports();
|
|
1004
1004
|
|
|
@@ -32,6 +32,24 @@ function control_char(key) {
|
|
|
32
32
|
return '\u007f';
|
|
33
33
|
return null;
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* How many frames to keep re-trying a fit before leaving it to the observer.
|
|
37
|
+
*
|
|
38
|
+
* Generous, because what is being waited on is a font load and a layout pass,
|
|
39
|
+
* not a network round trip — and cheap, because each attempt is one measurement
|
|
40
|
+
* that stops the moment it succeeds.
|
|
41
|
+
*/
|
|
42
|
+
const FIT_MAX_ATTEMPTS = 60;
|
|
43
|
+
/**
|
|
44
|
+
* How much of the container the session may leave unfilled and still count as
|
|
45
|
+
* fitted.
|
|
46
|
+
*
|
|
47
|
+
* There is always a remainder: rows are whole, so the last partial row's worth
|
|
48
|
+
* of pixels belongs to nobody. One cell is normal and invisible; half a panel is
|
|
49
|
+
* the bug this guards. Sized above any realistic cell height so a correctly
|
|
50
|
+
* fitted terminal is never retried, and far below the gap a stale fit leaves.
|
|
51
|
+
*/
|
|
52
|
+
const FIT_SLACK_PX = 48;
|
|
35
53
|
/** The bar, left to right. `label` is what is drawn; `hint` is for a screen reader. */
|
|
36
54
|
const KEY_BAR_KEYS = [
|
|
37
55
|
{ id: 'esc', label: 'esc', hint: 'Escape', data: '\u001b' },
|
|
@@ -57,6 +75,7 @@ export class PhirepassTerminal {
|
|
|
57
75
|
inputMode = InputMode.Default;
|
|
58
76
|
resizeObserver;
|
|
59
77
|
resizeDebounceHandle;
|
|
78
|
+
fitRetryHandle;
|
|
60
79
|
session_id;
|
|
61
80
|
usernameBuffer = "";
|
|
62
81
|
passwordBuffer = "";
|
|
@@ -191,6 +210,10 @@ export class PhirepassTerminal {
|
|
|
191
210
|
clearTimeout(this.resizeDebounceHandle);
|
|
192
211
|
this.resizeDebounceHandle = undefined;
|
|
193
212
|
}
|
|
213
|
+
if (this.fitRetryHandle !== undefined) {
|
|
214
|
+
cancelAnimationFrame(this.fitRetryHandle);
|
|
215
|
+
this.fitRetryHandle = undefined;
|
|
216
|
+
}
|
|
194
217
|
if (this.resizeObserver) {
|
|
195
218
|
this.resizeObserver.disconnect();
|
|
196
219
|
}
|
|
@@ -203,16 +226,76 @@ export class PhirepassTerminal {
|
|
|
203
226
|
is_terminal_open() {
|
|
204
227
|
return Boolean(this.connected && this.containerEl && this.terminal.element);
|
|
205
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* Size the session to its container, and **keep trying until it works**.
|
|
231
|
+
*
|
|
232
|
+
* The bug this replaces: a fit could be skipped — the renderer not ready
|
|
233
|
+
* yet, `connected` not yet set, `fit()` throwing on dimensions that do not
|
|
234
|
+
* exist for another frame — and nothing ever retried it. The only other
|
|
235
|
+
* thing that fits is the `ResizeObserver`, so a terminal opened into a
|
|
236
|
+
* container that never changes size again stayed at whatever number of rows
|
|
237
|
+
* it happened to have. On a panel the user does not resize, that is
|
|
238
|
+
* permanent: the session renders at a fraction of the height it was given
|
|
239
|
+
* and the dead space below it is not part of the terminal at all.
|
|
240
|
+
*
|
|
241
|
+
* Retrying on `requestAnimationFrame` rather than a timer because what is
|
|
242
|
+
* being waited for *is* a frame: xterm computes its cell metrics from a
|
|
243
|
+
* measured element, and that measurement is only meaningful once the
|
|
244
|
+
* browser has laid the container out and the font it will actually use has
|
|
245
|
+
* loaded. The attempt cap keeps a container that is genuinely zero-sized —
|
|
246
|
+
* a hidden tab, a collapsed panel — from spinning a frame loop forever;
|
|
247
|
+
* the observer will call this again when it gains a size.
|
|
248
|
+
*/
|
|
249
|
+
schedule_fit() {
|
|
250
|
+
if (this.fitRetryHandle !== undefined) {
|
|
251
|
+
cancelAnimationFrame(this.fitRetryHandle);
|
|
252
|
+
this.fitRetryHandle = undefined;
|
|
253
|
+
}
|
|
254
|
+
let attempts = 0;
|
|
255
|
+
const attempt = () => {
|
|
256
|
+
this.fitRetryHandle = undefined;
|
|
257
|
+
if (this.fit_terminal_safely()) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
attempts += 1;
|
|
261
|
+
if (attempts >= FIT_MAX_ATTEMPTS) {
|
|
262
|
+
console.warn('Giving up fitting the terminal; waiting for a resize instead');
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
this.fitRetryHandle = requestAnimationFrame(attempt);
|
|
266
|
+
};
|
|
267
|
+
attempt();
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* One attempt. `true` when the session is now sized to its container.
|
|
271
|
+
*
|
|
272
|
+
* A container with no height yet counts as a failure rather than a success,
|
|
273
|
+
* which is what makes the retry above worth having: `fit()` on a zero-height
|
|
274
|
+
* parent does not throw, it computes one row and returns happily.
|
|
275
|
+
*/
|
|
206
276
|
fit_terminal_safely() {
|
|
207
277
|
if (!this.fitAddon || !this.is_terminal_open()) {
|
|
208
|
-
return;
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
const height = this.containerEl?.clientHeight ?? 0;
|
|
281
|
+
const width = this.containerEl?.clientWidth ?? 0;
|
|
282
|
+
if (height <= 0 || width <= 0) {
|
|
283
|
+
return false;
|
|
209
284
|
}
|
|
210
285
|
try {
|
|
211
286
|
this.fitAddon.fit();
|
|
212
287
|
}
|
|
213
288
|
catch (err) {
|
|
214
289
|
console.warn('Skipping terminal fit before renderer is ready:', err);
|
|
290
|
+
return false;
|
|
215
291
|
}
|
|
292
|
+
// Fitted, but to the right thing? `proposeDimensions` can be answered
|
|
293
|
+
// from stale cell metrics — most often when a web font finishes loading
|
|
294
|
+
// after the first measurement — and the symptom is a session that fills
|
|
295
|
+
// half its panel. Compare what we got against what there was to fill.
|
|
296
|
+
const rows = this.terminal?.rows ?? 0;
|
|
297
|
+
const rendered = this.terminal.element?.clientHeight ?? 0;
|
|
298
|
+
return rows > 0 && rendered > 0 && height - rendered < FIT_SLACK_PX;
|
|
216
299
|
}
|
|
217
300
|
try_connect() {
|
|
218
301
|
if (this.connected || !this.domReady || !this.runtimeReady) {
|
|
@@ -400,7 +483,7 @@ export class PhirepassTerminal {
|
|
|
400
483
|
handle_tunnel_opened(web) {
|
|
401
484
|
this.session_id = web.sid;
|
|
402
485
|
this.terminal.reset();
|
|
403
|
-
this.
|
|
486
|
+
this.schedule_fit();
|
|
404
487
|
this.send_ssh_terminal_resize();
|
|
405
488
|
}
|
|
406
489
|
handle_tunnel_data(web) {
|
|
@@ -421,14 +504,42 @@ export class PhirepassTerminal {
|
|
|
421
504
|
this.terminal.open(container);
|
|
422
505
|
console.log('Terminal opened in container');
|
|
423
506
|
this.connected = true;
|
|
424
|
-
|
|
507
|
+
// Scheduled, not attempted once: `open()` has only just handed the
|
|
508
|
+
// renderer its element, so the first measurement is routinely the
|
|
509
|
+
// one that is too early.
|
|
510
|
+
this.schedule_fit();
|
|
425
511
|
this.terminal.focus();
|
|
426
512
|
this.terminal.onData(this.handle_terminal_data.bind(this));
|
|
427
513
|
this.channel.connect();
|
|
428
514
|
this.setup_resize_observer();
|
|
515
|
+
this.refit_when_fonts_settle();
|
|
429
516
|
console.log('Terminal connected and ready');
|
|
430
517
|
}
|
|
431
518
|
}
|
|
519
|
+
/**
|
|
520
|
+
* Fit again once the web fonts have actually loaded.
|
|
521
|
+
*
|
|
522
|
+
* xterm measures one character to derive its cell size, and if that
|
|
523
|
+
* measurement happens while the browser is still falling back — "Berkeley
|
|
524
|
+
* Mono" and "Fira Code" are both remote — every row is sized from the wrong
|
|
525
|
+
* font. The container does not change size when the real font arrives, so
|
|
526
|
+
* the `ResizeObserver` never fires and nothing else would ever correct it.
|
|
527
|
+
*
|
|
528
|
+
* Guarded because `document.fonts` is absent in some embedding contexts, and
|
|
529
|
+
* a missing font API is not a reason to fail to open a shell.
|
|
530
|
+
*/
|
|
531
|
+
refit_when_fonts_settle() {
|
|
532
|
+
const fonts = document.fonts;
|
|
533
|
+
if (!fonts?.ready) {
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
void fonts.ready.then(() => {
|
|
537
|
+
if (this.connected) {
|
|
538
|
+
this.schedule_fit();
|
|
539
|
+
this.send_ssh_terminal_resize();
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
}
|
|
432
543
|
setup_resize_observer() {
|
|
433
544
|
this.resizeObserver = new ResizeObserver(() => {
|
|
434
545
|
console.log('Container resized, fitting terminal');
|
|
@@ -436,7 +547,7 @@ export class PhirepassTerminal {
|
|
|
436
547
|
clearTimeout(this.resizeDebounceHandle);
|
|
437
548
|
}
|
|
438
549
|
this.resizeDebounceHandle = setTimeout(() => {
|
|
439
|
-
this.
|
|
550
|
+
this.schedule_fit();
|
|
440
551
|
this.send_ssh_terminal_resize();
|
|
441
552
|
}, 100);
|
|
442
553
|
});
|
|
@@ -619,13 +730,13 @@ export class PhirepassTerminal {
|
|
|
619
730
|
return (h("button", { key: id, type: "button", class: { key: true, armed: !!armed }, "aria-label": hint, "aria-pressed": armed === undefined ? undefined : String(armed), onPointerDown: (event) => event.preventDefault(), onMouseDown: (event) => event.preventDefault(), onClick: onPress }, label));
|
|
620
731
|
}
|
|
621
732
|
render() {
|
|
622
|
-
return (h(Host, { key: '
|
|
733
|
+
return (h(Host, { key: 'a4e7018d85dc6ac27abfb46e199c1d2d947e57c6', class: { 'keys-on': this.keyBar === 'on', 'keys-off': this.keyBar === 'off' } }, h("div", { key: '0603c1fd65d7c70c0d48d45c4b85a7ad14c913bf', id: "ccc", ref: el => (this.containerEl = el) }), h("div", { key: '30bc8d4e31816e3c83d422133bbe9c1ced323141', class: "keys", role: "toolbar", "aria-label": "Terminal keys" }, this.key_button('ctrl', 'ctrl', 'Control', () => {
|
|
623
734
|
this.ctrlArmed = !this.ctrlArmed;
|
|
624
735
|
this.terminal?.focus();
|
|
625
736
|
}, this.ctrlArmed), this.key_button('alt', 'alt', 'Alt', () => {
|
|
626
737
|
this.altArmed = !this.altArmed;
|
|
627
738
|
this.terminal?.focus();
|
|
628
|
-
}, this.altArmed), KEY_BAR_KEYS.map(entry => this.key_button(entry.id, entry.label, entry.hint, () => this.press(entry.data))), h("span", { key: '
|
|
739
|
+
}, this.altArmed), KEY_BAR_KEYS.map(entry => this.key_button(entry.id, entry.label, entry.hint, () => this.press(entry.data))), h("span", { key: '117e1718e8f4bc7451dd95222733ef3f841600db', class: "spacer" }), this.key_button('left', '←', 'Left arrow', () => this.press(this.arrow('D'))), this.key_button('down', '↓', 'Down arrow', () => this.press(this.arrow('B'))), this.key_button('up', '↑', 'Up arrow', () => this.press(this.arrow('A'))), this.key_button('right', '→', 'Right arrow', () => this.press(this.arrow('C'))))));
|
|
629
740
|
}
|
|
630
741
|
static get is() { return "phirepass-terminal"; }
|
|
631
742
|
static get encapsulation() { return "shadow"; }
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
class n{__destroy_into_raw(){const n=this.__wbg_ptr;return this.__wbg_ptr=0,_.unregister(this),n}free(){const n=this.__destroy_into_raw();j.__wbg_channel_free(n,0)}authenticate(n,t,e){const r=N(n,j.__wbindgen_export,j.__wbindgen_export2),o=k,i=N(t,j.__wbindgen_export,j.__wbindgen_export2);j.channel_authenticate(this.__wbg_ptr,r,o,i,k,R(e)?Number.MAX_SAFE_INTEGER:e>>>0)}connect(){j.channel_connect(this.__wbg_ptr)}create_service(n,t,e,r,o,i,c,s,_){const u=N(n,j.__wbindgen_export,j.__wbindgen_export2),a=k,f=N(t,j.__wbindgen_export,j.__wbindgen_export2),b=k;var l=R(e)?0:N(e,j.__wbindgen_export,j.__wbindgen_export2),d=k;const w=N(r,j.__wbindgen_export,j.__wbindgen_export2),g=k;var h=R(i)?0:N(i,j.__wbindgen_export,j.__wbindgen_export2),p=k,m=R(c)?0:N(c,j.__wbindgen_export,j.__wbindgen_export2),y=k,v=R(s)?0:N(s,j.__wbindgen_export,j.__wbindgen_export2);j.channel_create_service(this.__wbg_ptr,u,a,f,b,l,d,w,g,o,h,p,m,y,v,k,R(_)?Number.MAX_SAFE_INTEGER:_>>>0)}delete_service(n,t,e){const r=N(n,j.__wbindgen_export,j.__wbindgen_export2),o=k,i=N(t,j.__wbindgen_export,j.__wbindgen_export2);j.channel_delete_service(this.__wbg_ptr,r,o,i,k,R(e)?Number.MAX_SAFE_INTEGER:e>>>0)}disconnect(){j.channel_disconnect(this.__wbg_ptr)}is_connected(){return 0!==j.channel_is_connected(this.__wbg_ptr)}is_disconnected(){return 0!==j.channel_is_disconnected(this.__wbg_ptr)}constructor(n,t,e){const r=N(n,j.__wbindgen_export,j.__wbindgen_export2),o=k,i=N(t,j.__wbindgen_export,j.__wbindgen_export2),c=k;var s=R(e)?0:N(e,j.__wbindgen_export,j.__wbindgen_export2);const u=j.channel_new(r,o,i,c,s,k);return this.__wbg_ptr=u,_.register(this,this.__wbg_ptr,this),this}on_connection_close(n){j.channel_on_connection_close(this.__wbg_ptr,R(n)?0:u(n))}on_connection_error(n){j.channel_on_connection_error(this.__wbg_ptr,R(n)?0:u(n))}on_connection_message(n){j.channel_on_connection_message(this.__wbg_ptr,R(n)?0:u(n))}on_connection_open(n){j.channel_on_connection_open(this.__wbg_ptr,R(n)?0:u(n))}on_protocol_message(n){j.channel_on_protocol_message(this.__wbg_ptr,R(n)?0:u(n))}on_protocol_message_type(n,t){const e=N(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_on_protocol_message_type(this.__wbg_ptr,e,k,R(t)?0:u(t))}open_rdp_tunnel(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(t,j.__wbindgen_export,j.__wbindgen_export2),_=k;var u=R(e)?0:N(e,j.__wbindgen_export,j.__wbindgen_export2),a=k,f=R(r)?0:N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_open_rdp_tunnel(this.__wbg_ptr,i,c,s,_,u,a,f,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}open_sftp_tunnel(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(t,j.__wbindgen_export,j.__wbindgen_export2),_=k;var u=R(e)?0:N(e,j.__wbindgen_export,j.__wbindgen_export2),a=k,f=R(r)?0:N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_open_sftp_tunnel(this.__wbg_ptr,i,c,s,_,u,a,f,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}open_ssh_tunnel(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(t,j.__wbindgen_export,j.__wbindgen_export2),_=k;var u=R(e)?0:N(e,j.__wbindgen_export,j.__wbindgen_export2),a=k,f=R(r)?0:N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_open_ssh_tunnel(this.__wbg_ptr,i,c,s,_,u,a,f,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_chmod(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_chmod(this.__wbg_ptr,i,c,t,s,k,r,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_delete(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_delete(this.__wbg_ptr,i,c,t,s,_,u,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_download_ack(n,t,e,r){const o=N(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_download_ack(this.__wbg_ptr,o,k,t,e,r)}send_sftp_download_chunk(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_download_chunk(this.__wbg_ptr,i,k,t,e,r,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_download_start(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_download_start(this.__wbg_ptr,i,c,t,s,_,u,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_list_data(n,t,e,r){const o=N(n,j.__wbindgen_export,j.__wbindgen_export2),i=k,c=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_list_data(this.__wbg_ptr,o,i,t,c,k,R(r)?Number.MAX_SAFE_INTEGER:r>>>0)}send_sftp_mkdir(n,t,e,r){const o=N(n,j.__wbindgen_export,j.__wbindgen_export2),i=k,c=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_mkdir(this.__wbg_ptr,o,i,t,c,k,R(r)?Number.MAX_SAFE_INTEGER:r>>>0)}send_sftp_read_file(n,t,e,r){const o=N(n,j.__wbindgen_export,j.__wbindgen_export2),i=k,c=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_read_file(this.__wbg_ptr,o,i,t,c,k,R(r)?Number.MAX_SAFE_INTEGER:r>>>0)}send_sftp_remove(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_remove(this.__wbg_ptr,i,c,t,s,k,r,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_rename(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_rename(this.__wbg_ptr,i,c,t,s,_,u,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_upload_chunk(n,t,e,r,o,i,c){const s=N(n,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=S(i,j.__wbindgen_export);j.channel_send_sftp_upload_chunk(this.__wbg_ptr,s,_,t,e,r,o,u,k,R(c)?Number.MAX_SAFE_INTEGER:c>>>0)}send_sftp_upload_start(n,t,e,r,o,i,c){const s=N(n,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=N(e,j.__wbindgen_export,j.__wbindgen_export2),a=k,f=N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_upload_start(this.__wbg_ptr,s,_,t,u,a,f,k,o,i,R(c)?Number.MAX_SAFE_INTEGER:c>>>0)}send_sftp_write_file(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=S(r,j.__wbindgen_export);j.channel_send_sftp_write_file(this.__wbg_ptr,i,c,t,s,_,u,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_ssh_terminal_resize(n,t,e,r,o,i){const c=N(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_ssh_terminal_resize(this.__wbg_ptr,c,k,t,e,r,o,i)}send_ssh_tunnel_data(n,t,e){const r=N(n,j.__wbindgen_export,j.__wbindgen_export2),o=k,i=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_ssh_tunnel_data(this.__wbg_ptr,r,o,t,i,k)}start_heartbeat(n){j.channel_start_heartbeat(this.__wbg_ptr,n)}stop_heartbeat(){j.channel_stop_heartbeat(this.__wbg_ptr)}update_service(n,t,e,r,o,i,c,s,_,u){const a=N(n,j.__wbindgen_export,j.__wbindgen_export2),f=k,b=N(t,j.__wbindgen_export,j.__wbindgen_export2),l=k,d=N(e,j.__wbindgen_export,j.__wbindgen_export2),w=k;var g=R(r)?0:N(r,j.__wbindgen_export,j.__wbindgen_export2),h=k;const p=N(o,j.__wbindgen_export,j.__wbindgen_export2),m=k;var y=R(c)?0:N(c,j.__wbindgen_export,j.__wbindgen_export2),v=k,A=R(s)?0:N(s,j.__wbindgen_export,j.__wbindgen_export2),S=k,T=R(_)?0:N(_,j.__wbindgen_export,j.__wbindgen_export2);j.channel_update_service(this.__wbg_ptr,a,f,b,l,d,w,g,h,p,m,i,y,v,A,S,T,k,R(u)?Number.MAX_SAFE_INTEGER:u>>>0)}}Symbol.dispose&&(n.prototype[Symbol.dispose]=n.prototype.free);const t=Object.freeze({Generic:0,0:"Generic",Authentication:10,10:"Authentication",RequiresUsername:100,100:"RequiresUsername",RequiresPassword:110,110:"RequiresPassword",RequiresUsernamePassword:120,120:"RequiresUsernamePassword"});function e(){const n={__proto__:null,__wbg_Error_67e7344beaa85059:function(n,t){return u(Error(w(n,t)))},__wbg_String_8564e559799eccda:function(n,t){const e=N(String(p(t)),j.__wbindgen_export,j.__wbindgen_export2),r=k;d().setInt32(n+4,r,!0),d().setInt32(n+0,e,!0)},__wbg___wbindgen_debug_string_0e68cf47c9cbd9b0:function(n,t){const e=N(f(p(t)),j.__wbindgen_export,j.__wbindgen_export2),r=k;d().setInt32(n+4,r,!0),d().setInt32(n+0,e,!0)},__wbg___wbindgen_string_get_92ab86bb19cbc12f:function(n,t){const e=p(t),r="string"==typeof e?e:void 0;var o=R(r)?0:N(r,j.__wbindgen_export,j.__wbindgen_export2),i=k;d().setInt32(n+4,i,!0),d().setInt32(n+0,o,!0)},__wbg___wbindgen_throw_5d9e815e6fdf150f:function(n,t){throw new Error(w(n,t))},__wbg__wbg_cb_unref_997e73d32238e655:function(n){p(n)._wbg_cb_unref()},__wbg_call_269c5566fbede3eb:function(){return m((function(n,t){return u(p(n).call(p(t)))}),arguments)},__wbg_call_6bcf8d3e20937e46:function(){return m((function(n,t,e){return u(p(n).call(p(t),p(e)))}),arguments)},__wbg_call_7bbd9cceba9949ad:function(){return m((function(n,t,e,r){return u(p(n).call(p(t),p(e),p(r)))}),arguments)},__wbg_clearInterval_26ba580547547579:function(n){return u(clearInterval(T(n)))},__wbg_close_a009f540ff811039:function(){return m((function(n){p(n).close()}),arguments)},__wbg_data_aa7ba49b34c0d883:function(n){return u(p(n).data)},__wbg_from_a39669ce566077da:function(n){return u(Array.from(p(n)))},__wbg_getRandomValues_a608c4436c19407a:function(){return m((function(n,t){globalThis.crypto.getRandomValues(b(n,t))}),arguments)},__wbg_get_989d0a1309644f2b:function(){return m((function(n,t){return u(Reflect.get(p(n),p(t)))}),arguments)},__wbg_info_1ec3bd19a05d875f:function(n,t){console.info(w(n,t))},__wbg_instanceof_ArrayBuffer_d4ff01f8247925ae:function(n){let t;try{t=p(n)instanceof ArrayBuffer}catch(n){t=!1}return t},__wbg_length_31bdaf014f5fbde2:function(n){return p(n).length},__wbg_new_1da3429bc3c4541c:function(n){return u(new Uint8Array(p(n)))},__wbg_new_bebc3f4757acf305:function(){return u(new Object)},__wbg_new_ffa92086ea89f79c:function(){return u(new Array)},__wbg_new_with_str_sequence_9ab4875494df9d99:function(){return m((function(n,t,e){return u(new WebSocket(w(n,t),p(e)))}),arguments)},__wbg_prototypesetcall_ae9f5e7459250748:function(n,t,e){Uint8Array.prototype.set.call(b(n,t),p(e))},__wbg_push_bfdf956ba476f65b:function(n,t){return p(n).push(p(t))},__wbg_readyState_83df235b27cf257f:function(n){return p(n).readyState},__wbg_send_af811d92e7aea5c4:function(){return m((function(n,t,e){p(n).send(b(t,e))}),arguments)},__wbg_setInterval_cbf1c35c6a692d37:function(){return m((function(n,t){return u(setInterval(p(n),t))}),arguments)},__wbg_set_13d25b81ab403f5e:function(n,t,e){p(n)[t>>>0]=T(e)},__wbg_set_6be42768c690e380:function(n,t,e){p(n)[T(t)]=T(e)},__wbg_set_binaryType_f88804219cea0f9e:function(n,t){p(n).binaryType=s[t]},__wbg_set_onclose_97aab74a1c2662f7:function(n,t){p(n).onclose=p(t)},__wbg_set_onerror_88cb2134dca3aba2:function(n,t){p(n).onerror=p(t)},__wbg_set_onmessage_0f0d391465909a45:function(n,t){p(n).onmessage=p(t)},__wbg_set_onopen_e91e64af99b7966d:function(n,t){p(n).onopen=p(t)},__wbg_warn_496b1176d7c30f44:function(n,t){console.warn(w(n,t))},__wbindgen_generic_0000000000000001:function(n,t){return u(A(n,t,o))},__wbindgen_generic_0000000000000002:function(n,t){return u(A(n,t,i))},__wbindgen_generic_0000000000000003:function(n,t){return u(A(n,t,c))},__wbindgen_generic_0000000000000004:function(n,t){return u(A(n,t,r))},__wbindgen_generic_0000000000000005:function(n){return u(n)},__wbindgen_generic_0000000000000006:function(n,t){return u(b(n,t))},__wbindgen_generic_0000000000000007:function(n,t){return u(w(n,t))},__wbindgen_generic_0000000000000008:function(n){return u(BigInt.asUintN(64,n))},__wbindgen_object_clone_ref:function(n){return u(p(n))},__wbindgen_object_drop_ref:function(n){T(n)}};return{__proto__:null,"./phirepass-channel_bg.js":n}}function r(n,t){j.__wasm_bindgen_func_elem_64(n,t)}function o(n,t,e){j.__wasm_bindgen_func_elem_60(n,t,u(e))}function i(n,t,e){j.__wasm_bindgen_func_elem_60_37(n,t,u(e))}function c(n,t,e){j.__wasm_bindgen_func_elem_60_38(n,t,u(e))}const s=["blob","arraybuffer"],_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((n=>j.__wbg_channel_free(n,1)));function u(n){v===y.length&&y.push(y.length+1);const t=v;return v=y[t],y[t]=n,t}const a="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((n=>j.__wbindgen_export4(n.a,n.b)));function f(n){const t=typeof n;if("number"==t||"boolean"==t||null==n)return`${n}`;if("string"==t)return`"${n}"`;if("symbol"==t){const t=n.description;return null==t?"Symbol":`Symbol(${t})`}if("function"==t){const t=n.name;return"string"==typeof t&&t.length>0?`Function(${t})`:"Function"}if(Array.isArray(n)){const t=n.length;let e="[";t>0&&(e+=f(n[0]));for(let r=1;r<t;r++)e+=", "+f(n[r]);return e+="]",e}const e=/\[object ([^\]]+)\]/.exec(toString.call(n));let r;if(!(e&&e.length>1))return toString.call(n);if(r=e[1],"Object"==r)try{return"Object("+JSON.stringify(n)+")"}catch(n){return"Object"}return n instanceof Error?`${n.name}: ${n.message}\n${n.stack}`:r}function b(n,t){return n>>>=0,h().subarray(n/1,n/1+t)}let l=null;function d(){return(null===l||!0===l.buffer.detached||void 0===l.buffer.detached&&l.buffer!==j.memory.buffer)&&(l=new DataView(j.memory.buffer)),l}function w(n,t){return function(n,t){return P+=t,P>=O&&(F=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),F.decode(),P=t),F.decode(h().subarray(n,n+t))}(n>>>0,t)}let g=null;function h(){return null!==g&&0!==g.byteLength||(g=new Uint8Array(j.memory.buffer)),g}function p(n){return y[n]}function m(n,t){try{return n.apply(this,t)}catch(n){j.__wbindgen_export3(u(n))}}let y=new Array(1024).fill(void 0);y.push(void 0,null,!0,!1);let v=y.length;function R(n){return null==n}function A(n,t,e){const r={a:n,b:t,cnt:1},o=(...n)=>{r.cnt++;const t=r.a;r.a=0;try{return e(t,r.b,...n)}finally{r.a=t,o._wbg_cb_unref()}};return o._wbg_cb_unref=()=>{0==--r.cnt&&(j.__wbindgen_export4(r.a,r.b),r.a=0,a.unregister(r))},a.register(o,r,r),o}function S(n,t){const e=t(1*n.length,1)>>>0;return h().set(n,e/1),k=n.length,e}function N(n,t,e){if(void 0===e){const e=U.encode(n),r=t(e.length,1)>>>0;return h().subarray(r,r+e.length).set(e),k=e.length,r}let r=n.length,o=t(r,1)>>>0;const i=h();let c=0;for(;c<r;c++){const t=n.charCodeAt(c);if(t>127)break;i[o+c]=t}if(c!==r){0!==c&&(n=n.slice(c)),o=e(o,r,r=c+3*n.length,1)>>>0;const t=h().subarray(o+c,o+r);c+=U.encodeInto(n,t).written,o=e(o,r,c,1)>>>0}return k=c,o}function T(n){const t=p(n);return function(n){n<1028||(y[n]=v,v=n)}(n),t}let F=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});F.decode();const O=2146435072;let P=0;const U=new TextEncoder;"encodeInto"in U||(U.encodeInto=function(n,t){const e=U.encode(n);return t.set(e),{read:n.length,written:e.length}});let j,k=0;async function W(n){if(void 0!==j)return j;void 0!==n&&(Object.getPrototypeOf(n)===Object.prototype?({module_or_path:n}=n):console.warn("using deprecated parameters for the initialization function; pass a single object instead")),void 0===n&&(n=new URL("phirepass-channel_bg.wasm",import.meta.url));const t=e();("string"==typeof n||"function"==typeof Request&&n instanceof Request||"function"==typeof URL&&n instanceof URL)&&(n=fetch(n));const{instance:r}=await async function(n,t){if("function"==typeof Response&&n instanceof Response){if(!n.ok)throw new Error(`failed to fetch Wasm: ${n.status} ${n.statusText} fetching '${n.url}'`);if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(n,t)}catch(t){if(!function(n){switch(n){case"basic":case"cors":case"default":return!0}return!1}(n.type)||"application/wasm"===n.headers.get("Content-Type"))throw t;console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",t)}const e=await n.arrayBuffer();return await WebAssembly.instantiate(e,t)}{const e=await WebAssembly.instantiate(n,t);return e instanceof WebAssembly.Instance?{instance:e,module:n}:e}}(await n,t);return function(n){return j=n.exports,l=null,g=null,j}(r)}var $,q,E;!function(n){n.Error="Error",n.AuthSuccess="AuthSuccess",n.TunnelOpened="TunnelOpened",n.TunnelClosed="TunnelClosed",n.TunnelData="TunnelData",n.RDPAuthorized="RDPAuthorized",n.SFTPListItems="SFTPListItems",n.SFTPDownloadStartResponse="SFTPDownloadStartResponse",n.SFTPDownloadChunk="SFTPDownloadChunk",n.SFTPUploadStartResponse="SFTPUploadStartResponse",n.SFTPUploadChunkAck="SFTPUploadChunkAck",n.SFTPOpResult="SFTPOpResult"}($||($={})),function(n){n[n.Username=0]="Username",n[n.Password=1]="Password",n[n.Default=2]="Default"}(q||(q={})),function(n){n.Disconnected="disconnected",n.Connected="connected",n.Error="error"}(E||(E={}));export{n as C,t as E,q as I,$ as P,W as _,E as a}
|
|
1
|
+
class n{__destroy_into_raw(){const n=this.__wbg_ptr;return this.__wbg_ptr=0,_.unregister(this),n}free(){const n=this.__destroy_into_raw();j.__wbg_channel_free(n,0)}authenticate(n,t,e){const r=N(n,j.__wbindgen_export,j.__wbindgen_export2),o=k,i=N(t,j.__wbindgen_export,j.__wbindgen_export2);j.channel_authenticate(this.__wbg_ptr,r,o,i,k,R(e)?Number.MAX_SAFE_INTEGER:e>>>0)}connect(){j.channel_connect(this.__wbg_ptr)}create_service(n,t,e,r,o,i,c,s,_){const u=N(n,j.__wbindgen_export,j.__wbindgen_export2),a=k,f=N(t,j.__wbindgen_export,j.__wbindgen_export2),b=k;var l=R(e)?0:N(e,j.__wbindgen_export,j.__wbindgen_export2),d=k;const w=N(r,j.__wbindgen_export,j.__wbindgen_export2),g=k;var h=R(i)?0:N(i,j.__wbindgen_export,j.__wbindgen_export2),p=k,m=R(c)?0:N(c,j.__wbindgen_export,j.__wbindgen_export2),y=k,v=R(s)?0:N(s,j.__wbindgen_export,j.__wbindgen_export2);j.channel_create_service(this.__wbg_ptr,u,a,f,b,l,d,w,g,o,h,p,m,y,v,k,R(_)?Number.MAX_SAFE_INTEGER:_>>>0)}delete_service(n,t,e){const r=N(n,j.__wbindgen_export,j.__wbindgen_export2),o=k,i=N(t,j.__wbindgen_export,j.__wbindgen_export2);j.channel_delete_service(this.__wbg_ptr,r,o,i,k,R(e)?Number.MAX_SAFE_INTEGER:e>>>0)}disconnect(){j.channel_disconnect(this.__wbg_ptr)}is_connected(){return 0!==j.channel_is_connected(this.__wbg_ptr)}is_disconnected(){return 0!==j.channel_is_disconnected(this.__wbg_ptr)}constructor(n,t,e){const r=N(n,j.__wbindgen_export,j.__wbindgen_export2),o=k,i=N(t,j.__wbindgen_export,j.__wbindgen_export2),c=k;var s=R(e)?0:N(e,j.__wbindgen_export,j.__wbindgen_export2);const u=j.channel_new(r,o,i,c,s,k);return this.__wbg_ptr=u,_.register(this,this.__wbg_ptr,this),this}on_connection_close(n){j.channel_on_connection_close(this.__wbg_ptr,R(n)?0:u(n))}on_connection_error(n){j.channel_on_connection_error(this.__wbg_ptr,R(n)?0:u(n))}on_connection_message(n){j.channel_on_connection_message(this.__wbg_ptr,R(n)?0:u(n))}on_connection_open(n){j.channel_on_connection_open(this.__wbg_ptr,R(n)?0:u(n))}on_protocol_message(n){j.channel_on_protocol_message(this.__wbg_ptr,R(n)?0:u(n))}on_protocol_message_type(n,t){const e=N(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_on_protocol_message_type(this.__wbg_ptr,e,k,R(t)?0:u(t))}open_rdp_tunnel(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(t,j.__wbindgen_export,j.__wbindgen_export2),_=k;var u=R(e)?0:N(e,j.__wbindgen_export,j.__wbindgen_export2),a=k,f=R(r)?0:N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_open_rdp_tunnel(this.__wbg_ptr,i,c,s,_,u,a,f,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}open_sftp_tunnel(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(t,j.__wbindgen_export,j.__wbindgen_export2),_=k;var u=R(e)?0:N(e,j.__wbindgen_export,j.__wbindgen_export2),a=k,f=R(r)?0:N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_open_sftp_tunnel(this.__wbg_ptr,i,c,s,_,u,a,f,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}open_ssh_tunnel(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(t,j.__wbindgen_export,j.__wbindgen_export2),_=k;var u=R(e)?0:N(e,j.__wbindgen_export,j.__wbindgen_export2),a=k,f=R(r)?0:N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_open_ssh_tunnel(this.__wbg_ptr,i,c,s,_,u,a,f,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_chmod(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_chmod(this.__wbg_ptr,i,c,t,s,k,r,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_delete(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_delete(this.__wbg_ptr,i,c,t,s,_,u,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_download_ack(n,t,e,r){const o=N(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_download_ack(this.__wbg_ptr,o,k,t,e,r)}send_sftp_download_chunk(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_download_chunk(this.__wbg_ptr,i,k,t,e,r,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_download_start(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_download_start(this.__wbg_ptr,i,c,t,s,_,u,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_list_data(n,t,e,r){const o=N(n,j.__wbindgen_export,j.__wbindgen_export2),i=k,c=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_list_data(this.__wbg_ptr,o,i,t,c,k,R(r)?Number.MAX_SAFE_INTEGER:r>>>0)}send_sftp_mkdir(n,t,e,r){const o=N(n,j.__wbindgen_export,j.__wbindgen_export2),i=k,c=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_mkdir(this.__wbg_ptr,o,i,t,c,k,R(r)?Number.MAX_SAFE_INTEGER:r>>>0)}send_sftp_read_file(n,t,e,r){const o=N(n,j.__wbindgen_export,j.__wbindgen_export2),i=k,c=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_read_file(this.__wbg_ptr,o,i,t,c,k,R(r)?Number.MAX_SAFE_INTEGER:r>>>0)}send_sftp_remove(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_remove(this.__wbg_ptr,i,c,t,s,k,r,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_rename(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_rename(this.__wbg_ptr,i,c,t,s,_,u,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_upload_chunk(n,t,e,r,o,i,c){const s=N(n,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=S(i,j.__wbindgen_export);j.channel_send_sftp_upload_chunk(this.__wbg_ptr,s,_,t,e,r,o,u,k,R(c)?Number.MAX_SAFE_INTEGER:c>>>0)}send_sftp_upload_start(n,t,e,r,o,i,c){const s=N(n,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=N(e,j.__wbindgen_export,j.__wbindgen_export2),a=k,f=N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_upload_start(this.__wbg_ptr,s,_,t,u,a,f,k,o,i,R(c)?Number.MAX_SAFE_INTEGER:c>>>0)}send_sftp_write_file(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=S(r,j.__wbindgen_export);j.channel_send_sftp_write_file(this.__wbg_ptr,i,c,t,s,_,u,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_ssh_terminal_resize(n,t,e,r,o,i){const c=N(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_ssh_terminal_resize(this.__wbg_ptr,c,k,t,e,r,o,i)}send_ssh_tunnel_data(n,t,e){const r=N(n,j.__wbindgen_export,j.__wbindgen_export2),o=k,i=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_ssh_tunnel_data(this.__wbg_ptr,r,o,t,i,k)}start_heartbeat(n){j.channel_start_heartbeat(this.__wbg_ptr,n)}stop_heartbeat(){j.channel_stop_heartbeat(this.__wbg_ptr)}update_service(n,t,e,r,o,i,c,s,_,u){const a=N(n,j.__wbindgen_export,j.__wbindgen_export2),f=k,b=N(t,j.__wbindgen_export,j.__wbindgen_export2),l=k,d=N(e,j.__wbindgen_export,j.__wbindgen_export2),w=k;var g=R(r)?0:N(r,j.__wbindgen_export,j.__wbindgen_export2),h=k;const p=N(o,j.__wbindgen_export,j.__wbindgen_export2),m=k;var y=R(c)?0:N(c,j.__wbindgen_export,j.__wbindgen_export2),v=k,A=R(s)?0:N(s,j.__wbindgen_export,j.__wbindgen_export2),S=k,T=R(_)?0:N(_,j.__wbindgen_export,j.__wbindgen_export2);j.channel_update_service(this.__wbg_ptr,a,f,b,l,d,w,g,h,p,m,i,y,v,A,S,T,k,R(u)?Number.MAX_SAFE_INTEGER:u>>>0)}}Symbol.dispose&&(n.prototype[Symbol.dispose]=n.prototype.free);const t=Object.freeze({Generic:0,0:"Generic",Authentication:10,10:"Authentication",RequiresUsername:100,100:"RequiresUsername",RequiresPassword:110,110:"RequiresPassword",RequiresUsernamePassword:120,120:"RequiresUsernamePassword"});function e(){const n={__proto__:null,__wbg_Error_67e7344beaa85059:function(n,t){return u(Error(w(n,t)))},__wbg_String_8564e559799eccda:function(n,t){const e=N(String(p(t)),j.__wbindgen_export,j.__wbindgen_export2),r=k;d().setInt32(n+4,r,!0),d().setInt32(n+0,e,!0)},__wbg___wbindgen_debug_string_0e68cf47c9cbd9b0:function(n,t){const e=N(f(p(t)),j.__wbindgen_export,j.__wbindgen_export2),r=k;d().setInt32(n+4,r,!0),d().setInt32(n+0,e,!0)},__wbg___wbindgen_string_get_92ab86bb19cbc12f:function(n,t){const e=p(t),r="string"==typeof e?e:void 0;var o=R(r)?0:N(r,j.__wbindgen_export,j.__wbindgen_export2),i=k;d().setInt32(n+4,i,!0),d().setInt32(n+0,o,!0)},__wbg___wbindgen_throw_5d9e815e6fdf150f:function(n,t){throw new Error(w(n,t))},__wbg__wbg_cb_unref_997e73d32238e655:function(n){p(n)._wbg_cb_unref()},__wbg_call_269c5566fbede3eb:function(){return m((function(n,t){return u(p(n).call(p(t)))}),arguments)},__wbg_call_6bcf8d3e20937e46:function(){return m((function(n,t,e){return u(p(n).call(p(t),p(e)))}),arguments)},__wbg_call_7bbd9cceba9949ad:function(){return m((function(n,t,e,r){return u(p(n).call(p(t),p(e),p(r)))}),arguments)},__wbg_clearInterval_26ba580547547579:function(n){return u(clearInterval(T(n)))},__wbg_close_a009f540ff811039:function(){return m((function(n){p(n).close()}),arguments)},__wbg_data_aa7ba49b34c0d883:function(n){return u(p(n).data)},__wbg_from_a39669ce566077da:function(n){return u(Array.from(p(n)))},__wbg_getRandomValues_a608c4436c19407a:function(){return m((function(n,t){globalThis.crypto.getRandomValues(b(n,t))}),arguments)},__wbg_get_989d0a1309644f2b:function(){return m((function(n,t){return u(Reflect.get(p(n),p(t)))}),arguments)},__wbg_info_c923009936ad8385:function(n,t){console.info(w(n,t))},__wbg_instanceof_ArrayBuffer_d4ff01f8247925ae:function(n){let t;try{t=p(n)instanceof ArrayBuffer}catch(n){t=!1}return t},__wbg_length_31bdaf014f5fbde2:function(n){return p(n).length},__wbg_new_1da3429bc3c4541c:function(n){return u(new Uint8Array(p(n)))},__wbg_new_bebc3f4757acf305:function(){return u(new Object)},__wbg_new_ffa92086ea89f79c:function(){return u(new Array)},__wbg_new_with_str_sequence_9ab4875494df9d99:function(){return m((function(n,t,e){return u(new WebSocket(w(n,t),p(e)))}),arguments)},__wbg_prototypesetcall_ae9f5e7459250748:function(n,t,e){Uint8Array.prototype.set.call(b(n,t),p(e))},__wbg_push_bfdf956ba476f65b:function(n,t){return p(n).push(p(t))},__wbg_readyState_83df235b27cf257f:function(n){return p(n).readyState},__wbg_send_af811d92e7aea5c4:function(){return m((function(n,t,e){p(n).send(b(t,e))}),arguments)},__wbg_setInterval_cbf1c35c6a692d37:function(){return m((function(n,t){return u(setInterval(p(n),t))}),arguments)},__wbg_set_13d25b81ab403f5e:function(n,t,e){p(n)[t>>>0]=T(e)},__wbg_set_6be42768c690e380:function(n,t,e){p(n)[T(t)]=T(e)},__wbg_set_binaryType_f88804219cea0f9e:function(n,t){p(n).binaryType=s[t]},__wbg_set_onclose_97aab74a1c2662f7:function(n,t){p(n).onclose=p(t)},__wbg_set_onerror_88cb2134dca3aba2:function(n,t){p(n).onerror=p(t)},__wbg_set_onmessage_0f0d391465909a45:function(n,t){p(n).onmessage=p(t)},__wbg_set_onopen_e91e64af99b7966d:function(n,t){p(n).onopen=p(t)},__wbg_warn_5936938922985853:function(n,t){console.warn(w(n,t))},__wbindgen_generic_0000000000000001:function(n,t){return u(A(n,t,o))},__wbindgen_generic_0000000000000002:function(n,t){return u(A(n,t,i))},__wbindgen_generic_0000000000000003:function(n,t){return u(A(n,t,c))},__wbindgen_generic_0000000000000004:function(n,t){return u(A(n,t,r))},__wbindgen_generic_0000000000000005:function(n){return u(n)},__wbindgen_generic_0000000000000006:function(n,t){return u(b(n,t))},__wbindgen_generic_0000000000000007:function(n,t){return u(w(n,t))},__wbindgen_generic_0000000000000008:function(n){return u(BigInt.asUintN(64,n))},__wbindgen_object_clone_ref:function(n){return u(p(n))},__wbindgen_object_drop_ref:function(n){T(n)}};return{__proto__:null,"./phirepass-channel_bg.js":n}}function r(n,t){j.__wasm_bindgen_func_elem_64(n,t)}function o(n,t,e){j.__wasm_bindgen_func_elem_60(n,t,u(e))}function i(n,t,e){j.__wasm_bindgen_func_elem_60_37(n,t,u(e))}function c(n,t,e){j.__wasm_bindgen_func_elem_60_38(n,t,u(e))}const s=["blob","arraybuffer"],_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((n=>j.__wbg_channel_free(n,1)));function u(n){v===y.length&&y.push(y.length+1);const t=v;return v=y[t],y[t]=n,t}const a="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((n=>j.__wbindgen_export4(n.a,n.b)));function f(n){const t=typeof n;if("number"==t||"boolean"==t||null==n)return`${n}`;if("string"==t)return`"${n}"`;if("symbol"==t){const t=n.description;return null==t?"Symbol":`Symbol(${t})`}if("function"==t){const t=n.name;return"string"==typeof t&&t.length>0?`Function(${t})`:"Function"}if(Array.isArray(n)){const t=n.length;let e="[";t>0&&(e+=f(n[0]));for(let r=1;r<t;r++)e+=", "+f(n[r]);return e+="]",e}const e=/\[object ([^\]]+)\]/.exec(toString.call(n));let r;if(!(e&&e.length>1))return toString.call(n);if(r=e[1],"Object"==r)try{return"Object("+JSON.stringify(n)+")"}catch(n){return"Object"}return n instanceof Error?`${n.name}: ${n.message}\n${n.stack}`:r}function b(n,t){return n>>>=0,h().subarray(n/1,n/1+t)}let l=null;function d(){return(null===l||!0===l.buffer.detached||void 0===l.buffer.detached&&l.buffer!==j.memory.buffer)&&(l=new DataView(j.memory.buffer)),l}function w(n,t){return function(n,t){return P+=t,P>=O&&(F=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),F.decode(),P=t),F.decode(h().subarray(n,n+t))}(n>>>0,t)}let g=null;function h(){return null!==g&&0!==g.byteLength||(g=new Uint8Array(j.memory.buffer)),g}function p(n){return y[n]}function m(n,t){try{return n.apply(this,t)}catch(n){j.__wbindgen_export3(u(n))}}let y=new Array(1024).fill(void 0);y.push(void 0,null,!0,!1);let v=y.length;function R(n){return null==n}function A(n,t,e){const r={a:n,b:t,cnt:1},o=(...n)=>{r.cnt++;const t=r.a;r.a=0;try{return e(t,r.b,...n)}finally{r.a=t,o._wbg_cb_unref()}};return o._wbg_cb_unref=()=>{0==--r.cnt&&(j.__wbindgen_export4(r.a,r.b),r.a=0,a.unregister(r))},a.register(o,r,r),o}function S(n,t){const e=t(1*n.length,1)>>>0;return h().set(n,e/1),k=n.length,e}function N(n,t,e){if(void 0===e){const e=U.encode(n),r=t(e.length,1)>>>0;return h().subarray(r,r+e.length).set(e),k=e.length,r}let r=n.length,o=t(r,1)>>>0;const i=h();let c=0;for(;c<r;c++){const t=n.charCodeAt(c);if(t>127)break;i[o+c]=t}if(c!==r){0!==c&&(n=n.slice(c)),o=e(o,r,r=c+3*n.length,1)>>>0;const t=h().subarray(o+c,o+r);c+=U.encodeInto(n,t).written,o=e(o,r,c,1)>>>0}return k=c,o}function T(n){const t=p(n);return function(n){n<1028||(y[n]=v,v=n)}(n),t}let F=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});F.decode();const O=2146435072;let P=0;const U=new TextEncoder;"encodeInto"in U||(U.encodeInto=function(n,t){const e=U.encode(n);return t.set(e),{read:n.length,written:e.length}});let j,k=0;async function W(n){if(void 0!==j)return j;void 0!==n&&(Object.getPrototypeOf(n)===Object.prototype?({module_or_path:n}=n):console.warn("using deprecated parameters for the initialization function; pass a single object instead")),void 0===n&&(n=new URL("phirepass-channel_bg.wasm",import.meta.url));const t=e();("string"==typeof n||"function"==typeof Request&&n instanceof Request||"function"==typeof URL&&n instanceof URL)&&(n=fetch(n));const{instance:r}=await async function(n,t){if("function"==typeof Response&&n instanceof Response){if(!n.ok)throw new Error(`failed to fetch Wasm: ${n.status} ${n.statusText} fetching '${n.url}'`);if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(n,t)}catch(t){if(!function(n){switch(n){case"basic":case"cors":case"default":return!0}return!1}(n.type)||"application/wasm"===n.headers.get("Content-Type"))throw t;console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",t)}const e=await n.arrayBuffer();return await WebAssembly.instantiate(e,t)}{const e=await WebAssembly.instantiate(n,t);return e instanceof WebAssembly.Instance?{instance:e,module:n}:e}}(await n,t);return function(n){return j=n.exports,l=null,g=null,j}(r)}var $,q,E;!function(n){n.Error="Error",n.AuthSuccess="AuthSuccess",n.TunnelOpened="TunnelOpened",n.TunnelClosed="TunnelClosed",n.TunnelData="TunnelData",n.RDPAuthorized="RDPAuthorized",n.SFTPListItems="SFTPListItems",n.SFTPDownloadStartResponse="SFTPDownloadStartResponse",n.SFTPDownloadChunk="SFTPDownloadChunk",n.SFTPUploadStartResponse="SFTPUploadStartResponse",n.SFTPUploadChunkAck="SFTPUploadChunkAck",n.SFTPOpResult="SFTPOpResult"}($||($={})),function(n){n[n.Username=0]="Username",n[n.Password=1]="Password",n[n.Default=2]="Default"}(q||(q={})),function(n){n.Disconnected="disconnected",n.Connected="connected",n.Error="error"}(E||(E={}));export{n as C,t as E,q as I,$ as P,W as _,E as a}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t,p as e,H as s,c as i,h as o,a as n}from"./index.js";import{_ as r,C as h,a,P as c}from"./p-D4vz9Xu4.js";const d=200;function u(t){return!Number.isFinite(t)||t<=0?d:Math.min(8192,Math.max(d,Math.floor(t)))}function l(t){return t-t%2}function p(t){const e=t.getBoundingClientRect();return function(t,e){return{width:l(u(t)),height:l(u(e))}}(e.width,e.height)}class m{onResize;debounceMs;observer;handle;reported;constructor(t,e=250){this.onResize=t,this.debounceMs=e}observe(t,e){this.disconnect(),this.reported=e,this.report(p(t)),"undefined"!=typeof ResizeObserver&&(this.observer=new ResizeObserver((()=>{clearTimeout(this.handle),this.handle=setTimeout((()=>this.report(p(t))),this.debounceMs)})),this.observer.observe(t))}disconnect(){clearTimeout(this.handle),this.handle=void 0,this.observer?.disconnect(),this.observer=void 0,this.reported=void 0}report(t){(function(t,e){return!!t&&!!e&&t.width===e.width&&t.height===e.height})(t,this.reported)||(this.reported=t,this.onResize(t))}}function f(){return navigator.keyboard}function b(){return"function"==typeof f()?.lock}function y(t){return document.fullscreenElement===t}function w(t){return document.fullscreenElement?.contains(t)??!1}function g(){if(b())try{f().unlock()}catch(t){console.warn("Failed to release the keyboard lock:",t)}}const v=e(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.connectionStateChanged=i(this,"connectionStateChanged")}channel;containerEl;ironEl;userInteraction;viewport;domReady=!1;runtimeReady=!1;connected=!1;disposed=!1;session_id;onFullscreenChange=()=>this.sync_keyboard_lock();credentials;credentialsPrompt=!1;statusMessage;usernameBuffer="";passwordBuffer="";get el(){return this}serverHost="phirepass.com";serverPort=443;allowInsecure=!1;heartbeatInterval=3e4;nodeId;serviceId;token;username;password;destination;scale="fit";dynamicResize=!0;captureKeyboard=!0;clipboard=!0;onNodeIdChange(t,e){this.reset_session_state(),this.channel&&this.channel.is_connected()&&this.close_comms(),t&&(this.open_comms(),this.channel.connect())}serverId;onServerIdChange(t,e){this.onNodeIdChange(this.nodeId,this.nodeId)}connectionStateChanged;create_web_socket_endpoint(){const t=this.allowInsecure?"ws":"wss";return this.allowInsecure||443!==this.serverPort?this.allowInsecure&&80===this.serverPort?`${t}://${this.serverHost}`:`${t}://${this.serverHost}:${this.serverPort}`:`${t}://${this.serverHost}`}async connectedCallback(){document.addEventListener("fullscreenchange",this.onFullscreenChange),this.disposed=!1,await r(),this.open_comms(),this.runtimeReady=!0,this.nodeId?this.try_connect():console.warn("Prop node_id is not set. Cannot connect to RDP.")}componentDidLoad(){this.domReady=!0,this.try_connect()}async disconnectedCallback(){document.removeEventListener("fullscreenchange",this.onFullscreenChange),this.disposed=!0,this.session_id=void 0,this.connected=!1,this.domReady=!1,this.runtimeReady=!1,this.close_comms()}async toggleFullscreen(){const t=await async function(t){try{return y(t)?(await document.exitFullscreen(),!1):(await t.requestFullscreen({navigationUI:"hide"}),!0)}catch(e){return console.warn("Failed to change the fullscreen state of the RDP session:",e),y(t)}}(this.el);return this.focus_desktop(),t}async keyboardLockSupported(){return b()}async focusDesktop(){this.focus_desktop()}async sendCtrlAltDel(){return!!this.userInteraction&&(this.userInteraction.ctrlAltDel(),this.focus_desktop(),!0)}async sendMetaKey(){return!!this.userInteraction&&(this.userInteraction.metaKey(),this.focus_desktop(),!0)}try_connect(){!this.connected&&this.domReady&&this.runtimeReady&&this.containerEl&&this.channel&&this.connect()}connect(){this.connected=!0,this.channel.connect()}open_comms(){this.channel=this.serverId?new h(this.create_web_socket_endpoint()+"/api/web/ws",this.nodeId,this.serverId):new h(this.create_web_socket_endpoint()+"/api/web/ws",this.nodeId),this.channel.on_connection_open((()=>{this.connectionStateChanged.emit([a.Connected]),this.channel.authenticate(this.token,this.nodeId)})),this.channel.on_connection_close((()=>{this.connectionStateChanged.emit([a.Disconnected]),this.teardown_client()})),this.channel.on_connection_error((t=>{this.connectionStateChanged.emit([a.Error,t])})),this.channel.on_connection_message((()=>{})),this.channel.on_protocol_message((t=>{const{web:e}=t.data;switch(e.type){case c.Error:this.handle_error(e);break;case c.AuthSuccess:this.handle_auth_success(e);break;case c.RDPAuthorized:this.handle_rdp_authorized(e);break;case c.TunnelClosed:this.handle_tunnel_closed(e);break;default:console.warn("Unknown protocol message type:",e)}}))}close_comms(){this.teardown_client(),this.channel&&(this.channel.stop_heartbeat(),this.channel.disconnect())}reset_session_state(){this.session_id=void 0,this.credentials=void 0,this.credentialsPrompt=!1,this.usernameBuffer="",this.passwordBuffer="",this.statusMessage=void 0}handle_auth_success(t){if(this.channel.start_heartbeat(this.heartbeatInterval<=15e3?3e4:this.heartbeatInterval),this.username&&this.password)return this.credentials={username:this.username,password:this.password},void this.request_tunnel();this.credentialsPrompt=!0}request_tunnel(){this.credentials&&(this.statusMessage=void 0,this.channel.open_rdp_tunnel(this.nodeId,this.serviceId,this.credentials.username,this.credentials.password))}async handle_rdp_authorized(t){this.session_id=t.sid,this.statusMessage="Connecting…";const[e]=await Promise.all([import("@devolutions/iron-remote-desktop-rdp"),import("@devolutions/iron-remote-desktop")]);if(this.disposed||!this.containerEl||this.session_id!==t.sid)return;if(await e.init("info"),this.disposed||!this.containerEl||this.session_id!==t.sid)return;const s=document.createElement("iron-remote-desktop");s.module=e.Backend,s.scale=this.scale,s.flexcenter=!0,s.verbose=!1;const i=[e.enableCredssp(!0)];this.dynamicResize&&i.push(e.displayControl(!0)),s.addEventListener("ready",(e=>{this.start_session(e.detail.irgUserInteraction,t.ticket,i)})),this.ironEl=s,this.mount_client(s)}mount_client(t){this.el.appendChild(t)}async start_session(t,e,s){this.userInteraction=t,this.clipboard||t.setEnableClipboard(!1),t.onWarningCallback((t=>{console.warn("The remote desktop client reported a problem:",t)}));const i=t.configBuilder().withUsername(this.credentials?.username??"").withPassword(this.credentials?.password??"").withDestination(this.destination??this.nodeId).withProxyAddress(`${this.create_web_socket_endpoint()}/api/web/rdp/${this.nodeId}`).withAuthToken(e);for(const t of s)i.withExtension(t);let o;this.dynamicResize&&(o=function(t){const e=t.getBoundingClientRect();if(Number.isFinite(e.width)&&Number.isFinite(e.height)&&!(e.width<d||e.height<d))return{width:l(Math.min(Math.floor(e.width),4096)),height:l(Math.min(Math.floor(e.height),4096))}}(this.el),o&&i.withDesktopSize(o));try{const e=await t.connect(i.build());if(this.disposed)return this.shutdown_session(t),void await e.run();t.setVisibility(!0),this.statusMessage=void 0,this.focus_desktop(),this.sync_keyboard_lock();const s=e.run();this.start_viewport_sync(o);const n=await s;this.statusMessage=n.reason()}catch(t){const e=this.describe_error(t);this.statusMessage=e,this.connectionStateChanged.emit([a.Error,t])}}start_viewport_sync(t){this.dynamicResize&&(this.viewport=new m((t=>this.resize_desktop(t))),this.viewport.observe(this.el,t))}stop_viewport_sync(){this.viewport?.disconnect(),this.viewport=void 0}resize_desktop(t){try{this.userInteraction?.resize(t.width,t.height)}catch(t){console.warn("The remote host would not resize its desktop:",t)}}focus_desktop(){!function(t){t?.focus({preventScroll:!0})}(this.ironEl)}async sync_keyboard_lock(){this.captureKeyboard&&w(this.el)?(await async function(t){if(b()&&w(t))try{await f().lock()}catch(t){console.warn("Failed to lock the keyboard for the RDP session:",t)}}(this.el),this.focus_desktop()):g()}describe_error(t){return t&&"function"==typeof t.backtrace?t.backtrace():t instanceof Error?t.message:"Connection failed."}handle_tunnel_closed(t){this.session_id=void 0,this.statusMessage=this.statusMessage??"Connection closed.",this.teardown_client(),this.close_comms()}handle_error(t){this.statusMessage=t.message,this.connectionStateChanged.emit([a.Error,t])}shutdown_session(t){try{t.shutdown()}catch(t){console.warn("Failed to shut the RDP session down cleanly:",t)}}teardown_client(){this.stop_viewport_sync(),g(),this.userInteraction&&(this.shutdown_session(this.userInteraction),this.userInteraction=void 0),this.ironEl?.remove(),this.ironEl=void 0,this.credentialsPrompt=!1,this.usernameBuffer="",this.passwordBuffer=""}submit_credentials(t){t.preventDefault(),this.credentialsPrompt=!1,this.credentials={username:this.usernameBuffer,password:this.passwordBuffer},this.usernameBuffer="",this.passwordBuffer="",this.request_tunnel()}render(){return o(n,{key:"56354df7bd0d3f01fcd5ff65ca5618ceb6af1b91"},o("div",{key:"446dc83e41a29c3bc2c341a26092ed3581565967",class:"screen",ref:t=>this.containerEl=t},o("slot",{key:"2beafc92d81662dfac5c7b41356f6c6c802643b9"})),this.credentialsPrompt&&o("form",{key:"dcc29b21fba03bb97526ec3d1cf5a1fb51b483e9",class:"prompt",onSubmit:t=>this.submit_credentials(t)},o("label",{key:"b5a3e302089b2282aedbdbefd4fb5eaca7c34455",htmlFor:"rdp-username"},"Username"),o("input",{key:"3bd1c902a6bc41bc7e69c16258cac78035a949bd",id:"rdp-username",type:"text",autocomplete:"off",autofocus:!0,onInput:t=>this.usernameBuffer=t.target.value}),o("label",{key:"2defe12d73b609cbad27c06447c3c3221ff3e5aa",htmlFor:"rdp-password"},"Password"),o("input",{key:"55935891f24f0c1db71a14c42b2fc7a96c0c0ba6",id:"rdp-password",type:"password",autocomplete:"off",onInput:t=>this.passwordBuffer=t.target.value}),o("button",{key:"83439c0e8756001c7042fc3b6754889d62a8eada",type:"submit"},"Connect")),this.statusMessage&&!this.credentialsPrompt&&o("div",{key:"294262625f44a3f45d54bcd492875a9b6fd03219",class:"status"},this.statusMessage))}static get watchers(){return{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}}static get style(){return':host{display:block;width:100%;height:100%;min-width:0;min-height:0;overflow:hidden;position:relative;background:#0b1021;container-type:inline-size}.screen{width:100%;height:100%;display:flex}::slotted(iron-remote-desktop){display:block;flex:1 1 auto;min-width:0;min-height:0;width:100%;height:100%}:host(:fullscreen){width:100vw;height:100vh;background:#000}.prompt{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:0.5rem;background:rgba(11, 16, 33, 0.92);color:#e2e8f0;font-family:"Berkeley Mono", "Fira Code", "SFMono-Regular", Menlo, monospace;font-size:0.875rem}.prompt input{padding:0.5rem 0.75rem;border:1px solid #334155;border-radius:0.375rem;background:#0f172a;color:inherit;font:inherit;min-width:16rem}.prompt input:focus{outline:2px solid #67e8f9;outline-offset:1px}.prompt button{margin-top:0.5rem;padding:0.5rem 1.25rem;border:0;border-radius:0.375rem;background:#67e8f9;color:#0b1021;font:inherit;font-weight:600;cursor:pointer}.status{position:absolute;inset-inline:0;bottom:0;padding:0.5rem 0.75rem;background:rgba(11, 16, 33, 0.92);color:#e2e8f0;font-family:"Berkeley Mono", "Fira Code", "SFMono-Regular", Menlo, monospace;font-size:0.8125rem;text-align:center}@container (max-width: 640px){.prompt{padding:1rem;gap:0.4rem}.prompt input{min-width:0;width:100%;max-width:22rem;font-size:16px;padding:0.625rem 0.75rem}.prompt button{width:100%;max-width:22rem;padding:0.75rem 1.25rem}.status{font-size:0.75rem;padding:0.5rem;padding-bottom:calc(0.5rem + env(safe-area-inset-bottom))}}'}},[769,"phirepass-rdp",{serverHost:[1,"server-host"],serverPort:[2,"server-port"],allowInsecure:[4,"allow-insecure"],heartbeatInterval:[2,"heartbeat-interval"],nodeId:[1,"node-id"],serviceId:[1,"service-id"],token:[1],username:[1],password:[1],destination:[1],scale:[1],dynamicResize:[4,"dynamic-resize"],captureKeyboard:[4,"capture-keyboard"],clipboard:[4],serverId:[1,"server-id"],credentialsPrompt:[32],statusMessage:[32],toggleFullscreen:[64],keyboardLockSupported:[64],focusDesktop:[64],sendCtrlAltDel:[64],sendMetaKey:[64]},void 0,{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}]);function k(){"undefined"!=typeof customElements&&["phirepass-rdp"].forEach((e=>{"phirepass-rdp"===e&&(customElements.get(t(e))||customElements.define(t(e),v))}))}k();const _=v,I=k;export{_ as PhirepassRdp,I as defineCustomElement}
|
|
1
|
+
import{t,p as e,H as s,c as i,h as o,a as n}from"./index.js";import{_ as r,C as h,a,P as c}from"./p-YZKVM0AX.js";const d=200;function u(t){return!Number.isFinite(t)||t<=0?d:Math.min(8192,Math.max(d,Math.floor(t)))}function l(t){return t-t%2}function p(t){const e=t.getBoundingClientRect();return function(t,e){return{width:l(u(t)),height:l(u(e))}}(e.width,e.height)}class m{onResize;debounceMs;observer;handle;reported;constructor(t,e=250){this.onResize=t,this.debounceMs=e}observe(t,e){this.disconnect(),this.reported=e,this.report(p(t)),"undefined"!=typeof ResizeObserver&&(this.observer=new ResizeObserver((()=>{clearTimeout(this.handle),this.handle=setTimeout((()=>this.report(p(t))),this.debounceMs)})),this.observer.observe(t))}disconnect(){clearTimeout(this.handle),this.handle=void 0,this.observer?.disconnect(),this.observer=void 0,this.reported=void 0}report(t){(function(t,e){return!!t&&!!e&&t.width===e.width&&t.height===e.height})(t,this.reported)||(this.reported=t,this.onResize(t))}}function f(){return navigator.keyboard}function b(){return"function"==typeof f()?.lock}function y(t){return document.fullscreenElement===t}function w(t){return document.fullscreenElement?.contains(t)??!1}function g(){if(b())try{f().unlock()}catch(t){console.warn("Failed to release the keyboard lock:",t)}}const v=e(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.connectionStateChanged=i(this,"connectionStateChanged")}channel;containerEl;ironEl;userInteraction;viewport;domReady=!1;runtimeReady=!1;connected=!1;disposed=!1;session_id;onFullscreenChange=()=>this.sync_keyboard_lock();credentials;credentialsPrompt=!1;statusMessage;usernameBuffer="";passwordBuffer="";get el(){return this}serverHost="phirepass.com";serverPort=443;allowInsecure=!1;heartbeatInterval=3e4;nodeId;serviceId;token;username;password;destination;scale="fit";dynamicResize=!0;captureKeyboard=!0;clipboard=!0;onNodeIdChange(t,e){this.reset_session_state(),this.channel&&this.channel.is_connected()&&this.close_comms(),t&&(this.open_comms(),this.channel.connect())}serverId;onServerIdChange(t,e){this.onNodeIdChange(this.nodeId,this.nodeId)}connectionStateChanged;create_web_socket_endpoint(){const t=this.allowInsecure?"ws":"wss";return this.allowInsecure||443!==this.serverPort?this.allowInsecure&&80===this.serverPort?`${t}://${this.serverHost}`:`${t}://${this.serverHost}:${this.serverPort}`:`${t}://${this.serverHost}`}async connectedCallback(){document.addEventListener("fullscreenchange",this.onFullscreenChange),this.disposed=!1,await r(),this.open_comms(),this.runtimeReady=!0,this.nodeId?this.try_connect():console.warn("Prop node_id is not set. Cannot connect to RDP.")}componentDidLoad(){this.domReady=!0,this.try_connect()}async disconnectedCallback(){document.removeEventListener("fullscreenchange",this.onFullscreenChange),this.disposed=!0,this.session_id=void 0,this.connected=!1,this.domReady=!1,this.runtimeReady=!1,this.close_comms()}async toggleFullscreen(){const t=await async function(t){try{return y(t)?(await document.exitFullscreen(),!1):(await t.requestFullscreen({navigationUI:"hide"}),!0)}catch(e){return console.warn("Failed to change the fullscreen state of the RDP session:",e),y(t)}}(this.el);return this.focus_desktop(),t}async keyboardLockSupported(){return b()}async focusDesktop(){this.focus_desktop()}async sendCtrlAltDel(){return!!this.userInteraction&&(this.userInteraction.ctrlAltDel(),this.focus_desktop(),!0)}async sendMetaKey(){return!!this.userInteraction&&(this.userInteraction.metaKey(),this.focus_desktop(),!0)}try_connect(){!this.connected&&this.domReady&&this.runtimeReady&&this.containerEl&&this.channel&&this.connect()}connect(){this.connected=!0,this.channel.connect()}open_comms(){this.channel=this.serverId?new h(this.create_web_socket_endpoint()+"/api/web/ws",this.nodeId,this.serverId):new h(this.create_web_socket_endpoint()+"/api/web/ws",this.nodeId),this.channel.on_connection_open((()=>{this.connectionStateChanged.emit([a.Connected]),this.channel.authenticate(this.token,this.nodeId)})),this.channel.on_connection_close((()=>{this.connectionStateChanged.emit([a.Disconnected]),this.teardown_client()})),this.channel.on_connection_error((t=>{this.connectionStateChanged.emit([a.Error,t])})),this.channel.on_connection_message((()=>{})),this.channel.on_protocol_message((t=>{const{web:e}=t.data;switch(e.type){case c.Error:this.handle_error(e);break;case c.AuthSuccess:this.handle_auth_success(e);break;case c.RDPAuthorized:this.handle_rdp_authorized(e);break;case c.TunnelClosed:this.handle_tunnel_closed(e);break;default:console.warn("Unknown protocol message type:",e)}}))}close_comms(){this.teardown_client(),this.channel&&(this.channel.stop_heartbeat(),this.channel.disconnect())}reset_session_state(){this.session_id=void 0,this.credentials=void 0,this.credentialsPrompt=!1,this.usernameBuffer="",this.passwordBuffer="",this.statusMessage=void 0}handle_auth_success(t){if(this.channel.start_heartbeat(this.heartbeatInterval<=15e3?3e4:this.heartbeatInterval),this.username&&this.password)return this.credentials={username:this.username,password:this.password},void this.request_tunnel();this.credentialsPrompt=!0}request_tunnel(){this.credentials&&(this.statusMessage=void 0,this.channel.open_rdp_tunnel(this.nodeId,this.serviceId,this.credentials.username,this.credentials.password))}async handle_rdp_authorized(t){this.session_id=t.sid,this.statusMessage="Connecting…";const[e]=await Promise.all([import("@devolutions/iron-remote-desktop-rdp"),import("@devolutions/iron-remote-desktop")]);if(this.disposed||!this.containerEl||this.session_id!==t.sid)return;if(await e.init("info"),this.disposed||!this.containerEl||this.session_id!==t.sid)return;const s=document.createElement("iron-remote-desktop");s.module=e.Backend,s.scale=this.scale,s.flexcenter=!0,s.verbose=!1;const i=[e.enableCredssp(!0)];this.dynamicResize&&i.push(e.displayControl(!0)),s.addEventListener("ready",(e=>{this.start_session(e.detail.irgUserInteraction,t.ticket,i)})),this.ironEl=s,this.mount_client(s)}mount_client(t){this.el.appendChild(t)}async start_session(t,e,s){this.userInteraction=t,this.clipboard||t.setEnableClipboard(!1),t.onWarningCallback((t=>{console.warn("The remote desktop client reported a problem:",t)}));const i=t.configBuilder().withUsername(this.credentials?.username??"").withPassword(this.credentials?.password??"").withDestination(this.destination??this.nodeId).withProxyAddress(`${this.create_web_socket_endpoint()}/api/web/rdp/${this.nodeId}`).withAuthToken(e);for(const t of s)i.withExtension(t);let o;this.dynamicResize&&(o=function(t){const e=t.getBoundingClientRect();if(Number.isFinite(e.width)&&Number.isFinite(e.height)&&!(e.width<d||e.height<d))return{width:l(Math.min(Math.floor(e.width),4096)),height:l(Math.min(Math.floor(e.height),4096))}}(this.el),o&&i.withDesktopSize(o));try{const e=await t.connect(i.build());if(this.disposed)return this.shutdown_session(t),void await e.run();t.setVisibility(!0),this.statusMessage=void 0,this.focus_desktop(),this.sync_keyboard_lock();const s=e.run();this.start_viewport_sync(o);const n=await s;this.statusMessage=n.reason()}catch(t){const e=this.describe_error(t);this.statusMessage=e,this.connectionStateChanged.emit([a.Error,t])}}start_viewport_sync(t){this.dynamicResize&&(this.viewport=new m((t=>this.resize_desktop(t))),this.viewport.observe(this.el,t))}stop_viewport_sync(){this.viewport?.disconnect(),this.viewport=void 0}resize_desktop(t){try{this.userInteraction?.resize(t.width,t.height)}catch(t){console.warn("The remote host would not resize its desktop:",t)}}focus_desktop(){!function(t){t?.focus({preventScroll:!0})}(this.ironEl)}async sync_keyboard_lock(){this.captureKeyboard&&w(this.el)?(await async function(t){if(b()&&w(t))try{await f().lock()}catch(t){console.warn("Failed to lock the keyboard for the RDP session:",t)}}(this.el),this.focus_desktop()):g()}describe_error(t){return t&&"function"==typeof t.backtrace?t.backtrace():t instanceof Error?t.message:"Connection failed."}handle_tunnel_closed(t){this.session_id=void 0,this.statusMessage=this.statusMessage??"Connection closed.",this.teardown_client(),this.close_comms()}handle_error(t){this.statusMessage=t.message,this.connectionStateChanged.emit([a.Error,t])}shutdown_session(t){try{t.shutdown()}catch(t){console.warn("Failed to shut the RDP session down cleanly:",t)}}teardown_client(){this.stop_viewport_sync(),g(),this.userInteraction&&(this.shutdown_session(this.userInteraction),this.userInteraction=void 0),this.ironEl?.remove(),this.ironEl=void 0,this.credentialsPrompt=!1,this.usernameBuffer="",this.passwordBuffer=""}submit_credentials(t){t.preventDefault(),this.credentialsPrompt=!1,this.credentials={username:this.usernameBuffer,password:this.passwordBuffer},this.usernameBuffer="",this.passwordBuffer="",this.request_tunnel()}render(){return o(n,{key:"56354df7bd0d3f01fcd5ff65ca5618ceb6af1b91"},o("div",{key:"446dc83e41a29c3bc2c341a26092ed3581565967",class:"screen",ref:t=>this.containerEl=t},o("slot",{key:"2beafc92d81662dfac5c7b41356f6c6c802643b9"})),this.credentialsPrompt&&o("form",{key:"dcc29b21fba03bb97526ec3d1cf5a1fb51b483e9",class:"prompt",onSubmit:t=>this.submit_credentials(t)},o("label",{key:"b5a3e302089b2282aedbdbefd4fb5eaca7c34455",htmlFor:"rdp-username"},"Username"),o("input",{key:"3bd1c902a6bc41bc7e69c16258cac78035a949bd",id:"rdp-username",type:"text",autocomplete:"off",autofocus:!0,onInput:t=>this.usernameBuffer=t.target.value}),o("label",{key:"2defe12d73b609cbad27c06447c3c3221ff3e5aa",htmlFor:"rdp-password"},"Password"),o("input",{key:"55935891f24f0c1db71a14c42b2fc7a96c0c0ba6",id:"rdp-password",type:"password",autocomplete:"off",onInput:t=>this.passwordBuffer=t.target.value}),o("button",{key:"83439c0e8756001c7042fc3b6754889d62a8eada",type:"submit"},"Connect")),this.statusMessage&&!this.credentialsPrompt&&o("div",{key:"294262625f44a3f45d54bcd492875a9b6fd03219",class:"status"},this.statusMessage))}static get watchers(){return{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}}static get style(){return':host{display:block;width:100%;height:100%;min-width:0;min-height:0;overflow:hidden;position:relative;background:#0b1021;container-type:inline-size}.screen{width:100%;height:100%;display:flex}::slotted(iron-remote-desktop){display:block;flex:1 1 auto;min-width:0;min-height:0;width:100%;height:100%}:host(:fullscreen){width:100vw;height:100vh;background:#000}.prompt{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:0.5rem;background:rgba(11, 16, 33, 0.92);color:#e2e8f0;font-family:"Berkeley Mono", "Fira Code", "SFMono-Regular", Menlo, monospace;font-size:0.875rem}.prompt input{padding:0.5rem 0.75rem;border:1px solid #334155;border-radius:0.375rem;background:#0f172a;color:inherit;font:inherit;min-width:16rem}.prompt input:focus{outline:2px solid #67e8f9;outline-offset:1px}.prompt button{margin-top:0.5rem;padding:0.5rem 1.25rem;border:0;border-radius:0.375rem;background:#67e8f9;color:#0b1021;font:inherit;font-weight:600;cursor:pointer}.status{position:absolute;inset-inline:0;bottom:0;padding:0.5rem 0.75rem;background:rgba(11, 16, 33, 0.92);color:#e2e8f0;font-family:"Berkeley Mono", "Fira Code", "SFMono-Regular", Menlo, monospace;font-size:0.8125rem;text-align:center}@container (max-width: 640px){.prompt{padding:1rem;gap:0.4rem}.prompt input{min-width:0;width:100%;max-width:22rem;font-size:16px;padding:0.625rem 0.75rem}.prompt button{width:100%;max-width:22rem;padding:0.75rem 1.25rem}.status{font-size:0.75rem;padding:0.5rem;padding-bottom:calc(0.5rem + env(safe-area-inset-bottom))}}'}},[769,"phirepass-rdp",{serverHost:[1,"server-host"],serverPort:[2,"server-port"],allowInsecure:[4,"allow-insecure"],heartbeatInterval:[2,"heartbeat-interval"],nodeId:[1,"node-id"],serviceId:[1,"service-id"],token:[1],username:[1],password:[1],destination:[1],scale:[1],dynamicResize:[4,"dynamic-resize"],captureKeyboard:[4,"capture-keyboard"],clipboard:[4],serverId:[1,"server-id"],credentialsPrompt:[32],statusMessage:[32],toggleFullscreen:[64],keyboardLockSupported:[64],focusDesktop:[64],sendCtrlAltDel:[64],sendMetaKey:[64]},void 0,{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}]);function k(){"undefined"!=typeof customElements&&["phirepass-rdp"].forEach((e=>{"phirepass-rdp"===e&&(customElements.get(t(e))||customElements.define(t(e),v))}))}k();const _=v,I=k;export{_ as PhirepassRdp,I as defineCustomElement}
|