phirepass-widgets 0.0.112 → 0.0.113

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/README.md +33 -0
  2. package/dist/cjs/{index-B8w6l0VL.js → index-CurErEK7.js} +101 -30
  3. package/dist/cjs/loader.cjs.js +2 -2
  4. package/dist/cjs/phirepass-downloader_3.cjs.entry.js +3696 -0
  5. package/dist/cjs/phirepass-rdp.cjs.entry.js +18 -6
  6. package/dist/cjs/phirepass-terminal.cjs.entry.js +6 -5
  7. package/dist/cjs/phirepass-widgets.cjs.js +3 -3
  8. package/dist/cjs/{protocol-COvteaUJ.js → protocol-DCBMfc2u.js} +557 -360
  9. package/dist/collection/collection-manifest.json +3 -1
  10. package/dist/collection/common/channel.js +21 -1
  11. package/dist/collection/common/fetch.js +40 -0
  12. package/dist/collection/components/phirepass-downloader/form.js +69 -0
  13. package/dist/collection/components/phirepass-downloader/format.js +105 -0
  14. package/dist/collection/components/phirepass-downloader/jobs.js +370 -0
  15. package/dist/collection/components/phirepass-downloader/phirepass-downloader.css +1109 -0
  16. package/dist/collection/components/phirepass-downloader/phirepass-downloader.js +1455 -0
  17. package/dist/collection/components/phirepass-downloader/source.js +106 -0
  18. package/dist/collection/components/phirepass-downloader/views/dialogs.js +34 -0
  19. package/dist/collection/components/phirepass-downloader/views/fetch-form.js +65 -0
  20. package/dist/collection/components/phirepass-downloader/views/icons.js +33 -0
  21. package/dist/collection/components/phirepass-downloader/views/job-row.js +91 -0
  22. package/dist/collection/components/phirepass-downloader/views/notices.js +15 -0
  23. package/dist/collection/components/phirepass-downloader/views/states.js +19 -0
  24. package/dist/collection/components/phirepass-media-player/phirepass-media-player.css +216 -0
  25. package/dist/collection/components/phirepass-media-player/phirepass-media-player.js +473 -0
  26. package/dist/collection/components/phirepass-media-player/player.js +94 -0
  27. package/dist/collection/components/phirepass-rdp/phirepass-rdp.js +36 -13
  28. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.css +122 -0
  29. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.fetch.js +35 -0
  30. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.js +181 -31
  31. package/dist/collection/components/phirepass-terminal/phirepass-terminal.js +2 -2
  32. package/dist/collection/phirepass-channel_bg.wasm +0 -0
  33. package/dist/collection/testing/fixtures.js +219 -0
  34. package/dist/collection/testing/mock-channel.js +410 -0
  35. package/dist/components/index.js +1 -1
  36. package/dist/components/p-C4cmk3bS.js +1 -0
  37. package/dist/components/p-CsYQJXY2.js +1 -0
  38. package/dist/components/p-D6Geq8Rn.js +1 -0
  39. package/dist/components/phirepass-downloader.d.ts +11 -0
  40. package/dist/components/phirepass-downloader.js +1 -0
  41. package/dist/components/phirepass-media-player.d.ts +11 -0
  42. package/dist/components/phirepass-media-player.js +1 -0
  43. package/dist/components/phirepass-rdp.js +1 -1
  44. package/dist/components/phirepass-sftp-client.js +1 -1
  45. package/dist/components/phirepass-terminal.js +2 -2
  46. package/dist/esm/{index-DGq2b7rM.js → index-B9qUl6FW.js} +101 -30
  47. package/dist/esm/loader.js +3 -3
  48. package/dist/esm/phirepass-downloader_3.entry.js +3692 -0
  49. package/dist/esm/phirepass-rdp.entry.js +18 -6
  50. package/dist/esm/phirepass-terminal.entry.js +6 -5
  51. package/dist/esm/phirepass-widgets.js +4 -4
  52. package/dist/esm/{protocol-Dur4cBX7.js → protocol-CsYQJXY2.js} +556 -359
  53. package/dist/phirepass-widgets/p-1b84c526.entry.js +1 -0
  54. package/dist/phirepass-widgets/{p-1fef5b5f.entry.js → p-41dd1ac9.entry.js} +2 -2
  55. package/dist/phirepass-widgets/p-614ab3de.entry.js +1 -0
  56. package/dist/phirepass-widgets/p-B9qUl6FW.js +3 -0
  57. package/dist/phirepass-widgets/p-CsYQJXY2.js +1 -0
  58. package/dist/phirepass-widgets/phirepass-channel_bg.wasm +0 -0
  59. package/dist/phirepass-widgets/phirepass-widgets.esm.js +1 -1
  60. package/dist/types/common/channel.d.ts +30 -0
  61. package/dist/types/common/fetch.d.ts +161 -0
  62. package/dist/types/components/phirepass-downloader/form.d.ts +54 -0
  63. package/dist/types/components/phirepass-downloader/format.d.ts +17 -0
  64. package/dist/types/components/phirepass-downloader/jobs.d.ts +115 -0
  65. package/dist/types/components/phirepass-downloader/phirepass-downloader.d.ts +231 -0
  66. package/dist/types/components/phirepass-downloader/source.d.ts +61 -0
  67. package/dist/types/components/phirepass-downloader/views/dialogs.d.ts +52 -0
  68. package/dist/types/components/phirepass-downloader/views/fetch-form.d.ts +31 -0
  69. package/dist/types/components/phirepass-downloader/views/icons.d.ts +5 -0
  70. package/dist/types/components/phirepass-downloader/views/job-row.d.ts +21 -0
  71. package/dist/types/components/phirepass-downloader/views/notices.d.ts +18 -0
  72. package/dist/types/components/phirepass-downloader/views/states.d.ts +38 -0
  73. package/dist/types/components/phirepass-media-player/phirepass-media-player.d.ts +67 -0
  74. package/dist/types/components/phirepass-media-player/player.d.ts +43 -0
  75. package/dist/types/components/phirepass-rdp/phirepass-rdp.d.ts +10 -0
  76. package/dist/types/components/phirepass-sftp-client/phirepass-sftp-client.d.ts +30 -0
  77. package/dist/types/components/phirepass-sftp-client/phirepass-sftp-client.fetch.d.ts +40 -0
  78. package/dist/types/components.d.ts +426 -34
  79. package/dist/types/stencil-public-runtime.d.ts +1 -1
  80. package/dist/types/testing/fixtures.d.ts +25 -0
  81. package/dist/types/testing/mock-channel.d.ts +132 -0
  82. package/package.json +26 -12
  83. package/dist/cjs/phirepass-sftp-client.cjs.entry.js +0 -1469
  84. package/dist/components/p-Dur4cBX7.js +0 -1
  85. package/dist/esm/phirepass-sftp-client.entry.js +0 -1467
  86. package/dist/phirepass-widgets/p-8eb3ec24.entry.js +0 -1
  87. package/dist/phirepass-widgets/p-9a1f9b9f.entry.js +0 -1
  88. package/dist/phirepass-widgets/p-DGq2b7rM.js +0 -3
  89. package/dist/phirepass-widgets/p-Dur4cBX7.js +0 -1
@@ -0,0 +1,31 @@
1
+ import type { FetchCaps } from '../../../common/fetch';
2
+ import { FormModel, FormState, Note } from '../form';
3
+ import { AuthForm } from '../source';
4
+ export type FetchFormProps = {
5
+ form: FormState;
6
+ model: FormModel;
7
+ caps: FetchCaps | null;
8
+ layout: 'dialog' | 'inline';
9
+ title: string;
10
+ destination: {
11
+ path: string;
12
+ hint?: string;
13
+ } | null;
14
+ starting: boolean;
15
+ refusal: Note | null;
16
+ onChange: (patch: Partial<FormState>) => void;
17
+ /** A change to one login field, merged into the current login (not a render-time copy of it). */
18
+ onAuth: (patch: Partial<AuthForm>) => void;
19
+ onPickTorrent: (file: File) => void;
20
+ onStart: () => void;
21
+ onCancel?: () => void;
22
+ onChooseFolder?: () => void;
23
+ };
24
+ export declare const NoteLine: ({ note }: {
25
+ note: Note;
26
+ }) => any;
27
+ /**
28
+ * The add form: mockup B and its states, used as the SFTP browser's Fetch
29
+ * dialog (`dialog`) and as the top of the standalone downloader (`inline`).
30
+ */
31
+ export declare const FetchForm: (p: FetchFormProps) => any;
@@ -0,0 +1,5 @@
1
+ export declare const Icon: ({ name, size, label }: {
2
+ name: string;
3
+ size?: number;
4
+ label?: string;
5
+ }) => any;
@@ -0,0 +1,21 @@
1
+ import { Row } from '../jobs';
2
+ export type RowActions = {
3
+ play: (row: Row) => void;
4
+ pause: (row: Row) => void;
5
+ resume: (row: Row, ignoreWindow?: boolean) => void;
6
+ stop: (row: Row) => void;
7
+ remove: (row: Row) => void;
8
+ setOrder: (row: Row, inOrder: boolean) => void;
9
+ showInFolder: (row: Row) => void;
10
+ };
11
+ /**
12
+ * One download, in any state (mockups R and R2). Which buttons show is decided
13
+ * by the state alone; what a button sends is the host's business.
14
+ */
15
+ export declare const JobRow: ({ row, actions, running, source, compact }: {
16
+ row: Row;
17
+ actions: RowActions;
18
+ running: number;
19
+ source?: string;
20
+ compact?: boolean;
21
+ }) => any;
@@ -0,0 +1,18 @@
1
+ export type NoticeKind = 'started' | 'queued' | 'stuck' | 'renamed' | 'completed' | 'error';
2
+ export type Notice = {
3
+ id: number;
4
+ kind: NoticeKind;
5
+ title: string;
6
+ detail: string;
7
+ /** Stays until dismissed (N3); the others leave by themselves. */
8
+ sticky?: boolean;
9
+ action?: {
10
+ label: string;
11
+ run: () => void;
12
+ };
13
+ };
14
+ /** Small, self-dismissing notices at the bottom of the widget (N1–N4, D). */
15
+ export declare const Notices: ({ notices, onDismiss }: {
16
+ notices: Notice[];
17
+ onDismiss: (id: number) => void;
18
+ }) => any;
@@ -0,0 +1,38 @@
1
+ import type { Blocker } from '../jobs';
2
+ export declare const Empty: ({ icon, title, body, action }: {
3
+ icon: string;
4
+ title: string;
5
+ body: string;
6
+ action?: {
7
+ label: string;
8
+ onClick: () => void;
9
+ };
10
+ }) => any;
11
+ /** X1: embedded drawer with nothing in it. */
12
+ export declare const DrawerEmpty: () => any;
13
+ /** X2: standalone, first open. */
14
+ export declare const StandaloneEmpty: ({ nodeName, folder }: {
15
+ nodeName: string;
16
+ folder: string | null;
17
+ }) => any;
18
+ /** X3: no valid session. */
19
+ export declare const SignedOut: ({ onSignIn }: {
20
+ onSignIn: () => void;
21
+ }) => any;
22
+ /** X4: the node (or the server) cannot be reached. */
23
+ export declare const Unreachable: ({ nodeName, onRetry }: {
24
+ nodeName: string;
25
+ onRetry?: () => void;
26
+ }) => any;
27
+ /** The channel this page loaded predates Remote Fetch. */
28
+ export declare const Unsupported: () => any;
29
+ export declare const Loading: () => any;
30
+ /**
31
+ * Why nothing can be added on this node (B8, B9, L3). Shown in place of the
32
+ * form, in the dialog and in the standalone header alike.
33
+ */
34
+ export declare const BlockerView: ({ blocker, onAction, onClose }: {
35
+ blocker: Blocker;
36
+ onAction?: () => void;
37
+ onClose?: () => void;
38
+ }) => any;
@@ -0,0 +1,67 @@
1
+ import { EventEmitter } from '../../stencil-public-runtime';
2
+ import { PositionStore, RemotePlaybackLike, StoredPosition } from './player';
3
+ /**
4
+ * What the player is showing. `buffering` is before the first frame;
5
+ * `waiting` is a stall after it (a seek past what the node has, G2).
6
+ */
7
+ export type PlayerPhase = 'prompt' | 'buffering' | 'playing' | 'waiting' | 'unsupported' | 'stopped' | 'casting';
8
+ /**
9
+ * Plays a file from the node with the browser's own `<video>` or `<audio>`.
10
+ *
11
+ * It knows nothing of channels or WASM: `src` is a stream URL the server turns
12
+ * into stream events towards the agent, and the browser's range requests do
13
+ * the rest. A download that is still arriving plays as far as `ready` bytes;
14
+ * past that the element waits, and so does the player, saying why.
15
+ */
16
+ export declare class PhirepassMediaPlayer {
17
+ el: HTMLElement;
18
+ private media?;
19
+ private lastSave;
20
+ private resumeAt;
21
+ private everPlayed;
22
+ /** A stored position was offered (G6): then `startAt` plays, not `autoplay`. */
23
+ private positionPrompted;
24
+ private availabilityId?;
25
+ private onRemoteConnect;
26
+ private onRemoteDisconnect;
27
+ /** The stream URL: `/api/web/stream/{node}/{download}/{file}` or a listing token URL. */
28
+ src: string;
29
+ name: string;
30
+ /** Overrides the mime the extension implies. */
31
+ mime?: string;
32
+ /** The status line above the picture, from the job: “Downloading · 23.4%”, “On the node”. */
33
+ status?: string;
34
+ /** Bytes ready from the start of the file, while it is still downloading. */
35
+ ready?: number;
36
+ /** “Continue watching”. Without one, positions stay in this browser. */
37
+ positionStore?: PositionStore;
38
+ /** Key for the stored position: `dl:<download_id>:<file>` or `node:<node_id>:<path>`. */
39
+ positionKey?: string;
40
+ /** Stands in for `video.remote`, for demos and tests (like `channelFactory`). */
41
+ remotePlayback?: RemotePlaybackLike;
42
+ /** Shown while casting, when the host knows the device's name. */
43
+ castDevice?: string;
44
+ playerClose: EventEmitter<void>;
45
+ phase: PlayerPhase;
46
+ stored: StoredPosition | null;
47
+ castAvailable: boolean;
48
+ currentTime: number;
49
+ duration: number;
50
+ private get store();
51
+ private get audio();
52
+ componentWillLoad(): Promise<void>;
53
+ componentDidLoad(): void;
54
+ disconnectedCallback(): void;
55
+ onSrc(): void;
56
+ /** Closes the player, saving where it stopped. The download is not affected. */
57
+ close(): Promise<void>;
58
+ private remote;
59
+ private watchRemote;
60
+ private savePosition;
61
+ private startAt;
62
+ private retry;
63
+ private onError;
64
+ private bindMedia;
65
+ private renderStage;
66
+ render(): any;
67
+ }
@@ -0,0 +1,43 @@
1
+ /** A stored playback position. `at` is when it was saved (unix ms). */
2
+ export type StoredPosition = {
3
+ secs: number;
4
+ duration: number;
5
+ at: number;
6
+ };
7
+ /**
8
+ * Where “Continue watching” keeps positions. The dashboard implements it with
9
+ * `/api/playback`; with none given the player falls back to `localStorage`.
10
+ */
11
+ export type PositionStore = {
12
+ get(key: string): Promise<StoredPosition | null>;
13
+ set(key: string, secs: number, duration: number): Promise<void>;
14
+ clear?(key: string): Promise<void>;
15
+ };
16
+ export declare function extOf(name: string): string;
17
+ /** Mime from the extension, as the agent's stream server decides it. */
18
+ export declare function mimeFor(name: string): string;
19
+ export declare function isAudio(name: string, mime?: string): boolean;
20
+ export declare function isPlayableName(name: string): boolean;
21
+ /**
22
+ * Whether a Cast receiver can play this. The Default Media Receiver plays MP4
23
+ * (H.264/AAC), WebM and common audio, mostly not MKV or MOV.
24
+ */
25
+ export declare function castBlocker(name: string, mime?: string): string | null;
26
+ /** Nothing is saved in the first 30 seconds. */
27
+ export declare const SAVE_AFTER_SECS = 30;
28
+ export declare const SAVE_EVERY_MS = 10000;
29
+ /** Past 95%, or within the last two minutes, the file counts as watched and the position is cleared. */
30
+ export declare function isWatched(secs: number, duration: number): boolean;
31
+ export type PositionAction = 'skip' | 'save' | 'clear';
32
+ export declare function positionAction(secs: number, duration: number): PositionAction;
33
+ /** The fallback store, per browser. Every access is guarded: storage can be missing or refuse. */
34
+ export declare const localPositionStore: PositionStore;
35
+ /** The subset of `RemotePlayback` the player uses; a property seam for demos and tests. */
36
+ export type RemotePlaybackLike = {
37
+ state: 'disconnected' | 'connecting' | 'connected';
38
+ watchAvailability(cb: (available: boolean) => void): Promise<number>;
39
+ cancelWatchAvailability(id?: number): Promise<void>;
40
+ prompt(): Promise<void>;
41
+ addEventListener(type: 'connect' | 'connecting' | 'disconnect', cb: () => void): void;
42
+ removeEventListener(type: 'connect' | 'connecting' | 'disconnect', cb: () => void): void;
43
+ };
@@ -1,4 +1,5 @@
1
1
  import { EventEmitter } from '../../stencil-public-runtime';
2
+ import { Channel as PhirepassChannel } from 'phirepass-channel';
2
3
  import { ConnectionState } from '../../common/protocol';
3
4
  /**
4
5
  * Remote desktop over RDP.
@@ -10,6 +11,8 @@ import { ConnectionState } from '../../common/protocol';
10
11
  * headers nor a subprotocol on the socket it opens. See `RDP.md` in
11
12
  * `phirepass-rs` for why the session is split across two sockets.
12
13
  */
14
+ /** What the RDP widget calls on its channel. */
15
+ type RdpChannelLike = Pick<PhirepassChannel, 'connect' | 'disconnect' | 'is_connected' | 'authenticate' | 'start_heartbeat' | 'stop_heartbeat' | 'on_connection_open' | 'on_connection_close' | 'on_connection_error' | 'on_connection_message' | 'on_protocol_message' | 'open_rdp_tunnel'>;
13
16
  export declare class PhirepassRdp {
14
17
  private channel;
15
18
  private containerEl?;
@@ -90,6 +93,12 @@ export declare class PhirepassRdp {
90
93
  clipboard: boolean;
91
94
  onNodeIdChange(newValue?: string, _oldValue?: string): void;
92
95
  serverId?: string;
96
+ /**
97
+ * Supplies the channel instead of a WebSocket to the server — for demos,
98
+ * screenshots and tests, as on the terminal and SFTP client. A property
99
+ * only; read once, when the widget connects.
100
+ */
101
+ channelFactory?: (endpoint: string, nodeId: string, serverId?: string) => RdpChannelLike;
93
102
  onServerIdChange(_newValue?: string, _oldValue?: string): void;
94
103
  connectionStateChanged: EventEmitter<[ConnectionState, unknown?]>;
95
104
  private create_web_socket_endpoint;
@@ -199,3 +208,4 @@ export declare class PhirepassRdp {
199
208
  private submit_credentials;
200
209
  render(): any;
201
210
  }
211
+ export {};
@@ -1,10 +1,12 @@
1
1
  import { EventEmitter } from '../../stencil-public-runtime';
2
2
  import type { ChannelFactory } from '../../common/channel';
3
+ import { TorrentMenu } from './phirepass-sftp-client.fetch';
3
4
  import { ConnectionState, SFTPListItem } from '../../common/protocol';
4
5
  /** Which single-text-field dialog is open, if any. */
5
6
  type PromptKind = 'mkdir' | 'rename';
6
7
  type SortKey = 'name' | 'size' | 'modified';
7
8
  export declare class PhirepassSftpClient {
9
+ el_host: HTMLElement;
8
10
  private channel;
9
11
  private domReady;
10
12
  private runtimeReady;
@@ -102,6 +104,33 @@ export declare class PhirepassSftpClient {
102
104
  filter: string;
103
105
  sort_key: SortKey;
104
106
  sort_asc: boolean;
107
+ /** True once the channel is authenticated: the downloader shares it from then on. */
108
+ channel_ready: boolean;
109
+ /** Running downloads, for the Fetch button's badge. */
110
+ fetch_count: number;
111
+ /** Files a download just finished into the open folder, highlighted as new. */
112
+ fresh_names: Array<string>;
113
+ /** K3: a part file whose download a delete would end. */
114
+ part_delete: {
115
+ download_id: string;
116
+ name: string;
117
+ busy: boolean;
118
+ } | null;
119
+ torrent_menu: TorrentMenu | null;
120
+ /** A listing file open in the player (not a download). */
121
+ listing_player: {
122
+ src: string;
123
+ name: string;
124
+ key: string;
125
+ } | null;
126
+ private downloaderEl?;
127
+ private fetch_enabled;
128
+ private stream_base;
129
+ private on_fetch_completed;
130
+ private on_show_in_folder;
131
+ private on_row_context_menu;
132
+ private play_listing_file;
133
+ private listing_can_play;
105
134
  private toggle_max;
106
135
  connectedCallback(): Promise<void>;
107
136
  componentDidLoad(): void;
@@ -161,6 +190,7 @@ export declare class PhirepassSftpClient {
161
190
  private disconnect_session;
162
191
  private on_file_row_action;
163
192
  private on_file_delete_action;
193
+ private open_delete_prompt;
164
194
  private cancel_delete;
165
195
  private confirm_delete;
166
196
  private open_mkdir;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The SFTP browser's side of Remote Fetch, kept out of the component so it
3
+ * stays a host and nothing more: the downloads themselves are the
4
+ * `<phirepass-downloader>`'s, and nothing here goes over SFTP.
5
+ */
6
+ export declare const PART_SUFFIX = ".phirepass-part";
7
+ export declare function isPartFile(name: string): boolean;
8
+ export declare function isPlayableFile(name: string): boolean;
9
+ /** Whether a finished download's folder is the one on screen. */
10
+ export declare function sameFolder(a: string, b: string): boolean;
11
+ export declare function folderOfCompleted(detail: {
12
+ dest_root: string;
13
+ sub_dir: string | null;
14
+ }): string;
15
+ export declare const FetchButton: ({ count, onClick }: {
16
+ count: number;
17
+ onClick: () => void;
18
+ }) => any;
19
+ /** K3: replaces the plain delete prompt for a part file that belongs to a running download. */
20
+ export declare const PartDeleteDialog: ({ name, busy, onCancel, onConfirm }: {
21
+ name: string;
22
+ busy: boolean;
23
+ onCancel: () => void;
24
+ onConfirm: () => void;
25
+ }) => any;
26
+ export type TorrentMenu = {
27
+ x: number;
28
+ y: number;
29
+ path: string;
30
+ name: string;
31
+ };
32
+ /** C: right-click a `.torrent` that lies inside the node's download folder. */
33
+ export declare const TorrentContextMenu: ({ menu, onFetch, onDownload, onRename, onDelete, onClose, }: {
34
+ menu: TorrentMenu;
35
+ onFetch: () => void;
36
+ onDownload: () => void;
37
+ onRename: () => void;
38
+ onDelete: () => void;
39
+ onClose: () => void;
40
+ }) => any;