@rstreamlabs/react 1.8.2 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/{chunk-4YJETBAE.mjs → chunk-SVAMATWT.mjs} +40 -13
- package/dist/{chunk-DFYVJASW.mjs → chunk-UQDRDSGV.mjs} +1 -1
- package/dist/{chunk-G47GUMJ6.mjs → chunk-YZQKMOHW.mjs} +10 -5
- package/dist/components/index.d.mts +7 -2
- package/dist/components/index.d.ts +7 -2
- package/dist/components/index.js +40 -13
- package/dist/components/index.mjs +1 -1
- package/dist/hooks/index.d.mts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +10 -5
- package/dist/hooks/index.mjs +1 -1
- package/dist/index.d.mts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +50 -18
- package/dist/index.mjs +3 -3
- package/dist/providers/index.d.mts +2 -3
- package/dist/providers/index.d.ts +2 -3
- package/dist/providers/index.js +10 -5
- package/dist/providers/index.mjs +2 -2
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -149,8 +149,9 @@ inventory, pass the advertised `exec_path` value as `execPath`.
|
|
|
149
149
|
Browser watch streams should receive a fresh short-lived watch token from a
|
|
150
150
|
backend endpoint for each connection attempt. The token is sent to the engine as
|
|
151
151
|
`rstream.token` on `/api/sse` or `/api/websocket`, so it must be an `auth` or
|
|
152
|
-
`app` token with bounded lifetime
|
|
153
|
-
personal access tokens or application
|
|
152
|
+
`app` token with bounded lifetime, explicit read-only watch permissions, and
|
|
153
|
+
list-only tunnel resources. Do not embed personal access tokens or application
|
|
154
|
+
client secrets in React code.
|
|
154
155
|
|
|
155
156
|
## Development
|
|
156
157
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// src/components/webtty.tsx
|
|
2
2
|
import "@xterm/xterm/css/xterm.css";
|
|
3
|
-
import { FitAddon } from "@xterm/addon-fit";
|
|
4
3
|
import { resolveWebTTYExecutionURL } from "@rstreamlabs/webtty";
|
|
5
|
-
import {
|
|
4
|
+
import { WebTTY } from "@rstreamlabs/webtty";
|
|
5
|
+
import { FitAddon } from "@xterm/addon-fit";
|
|
6
6
|
import { Unicode11Addon } from "@xterm/addon-unicode11";
|
|
7
|
-
import { WebglAddon } from "@xterm/addon-webgl";
|
|
8
7
|
import { WebLinksAddon } from "@xterm/addon-web-links";
|
|
9
|
-
import {
|
|
8
|
+
import { WebglAddon } from "@xterm/addon-webgl";
|
|
9
|
+
import { Terminal } from "@xterm/xterm";
|
|
10
10
|
import * as React from "react";
|
|
11
11
|
import { jsx } from "react/jsx-runtime";
|
|
12
12
|
function WebTTYTerminal(props) {
|
|
@@ -48,13 +48,22 @@ function WebTTYTerminal(props) {
|
|
|
48
48
|
cmdArgs,
|
|
49
49
|
envVars,
|
|
50
50
|
execPath,
|
|
51
|
+
endpointIdentity,
|
|
52
|
+
expectedServerIdentity,
|
|
51
53
|
heartbeatIntervalMs,
|
|
52
54
|
interactive,
|
|
55
|
+
payloadCrypto,
|
|
53
56
|
sendHeartbeat,
|
|
54
57
|
terminalOptions,
|
|
58
|
+
transport,
|
|
55
59
|
url,
|
|
56
60
|
username,
|
|
57
|
-
|
|
61
|
+
webTransportOptions,
|
|
62
|
+
workdir,
|
|
63
|
+
clientBrowserId,
|
|
64
|
+
clientDeviceId,
|
|
65
|
+
clientPrincipalId,
|
|
66
|
+
formatError
|
|
58
67
|
} = initialPropsRef.current;
|
|
59
68
|
const runtime = {
|
|
60
69
|
connected: false,
|
|
@@ -127,8 +136,27 @@ function WebTTYTerminal(props) {
|
|
|
127
136
|
});
|
|
128
137
|
const connectionURL = execPath === void 0 ? url : resolveWebTTYExecutionURL(url, execPath);
|
|
129
138
|
const webtty = new WebTTY(
|
|
130
|
-
{
|
|
131
|
-
|
|
139
|
+
{
|
|
140
|
+
clientBrowserId,
|
|
141
|
+
clientDeviceId,
|
|
142
|
+
clientPrincipalId,
|
|
143
|
+
endpointIdentity,
|
|
144
|
+
expectedServerIdentity,
|
|
145
|
+
heartbeatIntervalMs,
|
|
146
|
+
sendHeartbeat,
|
|
147
|
+
transport,
|
|
148
|
+
url: connectionURL,
|
|
149
|
+
webTransportOptions
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
cmdArgs,
|
|
153
|
+
envVars,
|
|
154
|
+
allocateTty,
|
|
155
|
+
interactive,
|
|
156
|
+
payloadCrypto,
|
|
157
|
+
username,
|
|
158
|
+
workdir
|
|
159
|
+
},
|
|
132
160
|
{
|
|
133
161
|
onStdout: (chunk) => {
|
|
134
162
|
onStdoutEvent(chunk);
|
|
@@ -151,11 +179,9 @@ function WebTTYTerminal(props) {
|
|
|
151
179
|
fit();
|
|
152
180
|
syncRemoteSize(terminal.rows, terminal.cols);
|
|
153
181
|
runtime.disposeOnData = terminal.onData((data) => {
|
|
154
|
-
|
|
155
|
-
webtty.writeStdin(textEncoder.encode(data));
|
|
156
|
-
} catch (e) {
|
|
182
|
+
void webtty.writeStdinAsync(textEncoder.encode(data)).catch((e) => {
|
|
157
183
|
console.error("Cannot writeStdin:", e);
|
|
158
|
-
}
|
|
184
|
+
});
|
|
159
185
|
});
|
|
160
186
|
runtime.disposeOnResize = terminal.onResize((size) => {
|
|
161
187
|
syncRemoteSize(size.rows, size.cols);
|
|
@@ -169,9 +195,10 @@ Process exited with code ${code}.`);
|
|
|
169
195
|
clear();
|
|
170
196
|
},
|
|
171
197
|
onError: (err) => {
|
|
172
|
-
|
|
198
|
+
const message = formatError ? formatError(err) : err;
|
|
199
|
+
onErrorEvent(message);
|
|
173
200
|
terminal.write(`\r
|
|
174
|
-
[ERROR] ${
|
|
201
|
+
[ERROR] ${message}`);
|
|
175
202
|
terminal.write("\x1B[?25l");
|
|
176
203
|
clear();
|
|
177
204
|
}
|
|
@@ -142,7 +142,7 @@ function useRstream(options) {
|
|
|
142
142
|
if (state !== "connected") {
|
|
143
143
|
const timeout = setTimeout(() => {
|
|
144
144
|
setError({
|
|
145
|
-
message: "Failed to fetch rstream
|
|
145
|
+
message: "Failed to fetch rstream resources. Retrying...",
|
|
146
146
|
type: "warning"
|
|
147
147
|
});
|
|
148
148
|
}, errorTimeout);
|
|
@@ -150,16 +150,21 @@ function useRstream(options) {
|
|
|
150
150
|
clearTimeout(timeout);
|
|
151
151
|
};
|
|
152
152
|
} else if (state === "connected") {
|
|
153
|
-
setError(null);
|
|
153
|
+
const timeout = setTimeout(() => setError(null), 0);
|
|
154
|
+
return () => clearTimeout(timeout);
|
|
154
155
|
}
|
|
155
156
|
} else {
|
|
156
|
-
setError(null);
|
|
157
|
+
const timeout = setTimeout(() => setError(null), 0);
|
|
158
|
+
return () => clearTimeout(timeout);
|
|
157
159
|
}
|
|
158
160
|
}, [authEnabled, state, error, errorTimeout]);
|
|
159
161
|
React.useEffect(() => {
|
|
160
162
|
if (!authEnabled || state !== "connected") {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
+
const timeout = setTimeout(() => {
|
|
164
|
+
setClients([]);
|
|
165
|
+
setTunnels([]);
|
|
166
|
+
}, 0);
|
|
167
|
+
return () => clearTimeout(timeout);
|
|
163
168
|
}
|
|
164
169
|
}, [authEnabled, connectionKey, state]);
|
|
165
170
|
return { state, error, tunnels, clients };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import { ITerminalOptions, Terminal } from '@xterm/xterm';
|
|
2
|
+
import * as React from 'react';
|
|
3
3
|
import { WebTTYClientConfig, WebTTYExecutionConfig, WebTTYEvents } from '@rstreamlabs/webtty';
|
|
4
4
|
|
|
5
5
|
interface WebTTYTerminalProps extends WebTTYClientConfig, WebTTYExecutionConfig, WebTTYEvents {
|
|
@@ -20,7 +20,12 @@ interface WebTTYTerminalProps extends WebTTYClientConfig, WebTTYExecutionConfig,
|
|
|
20
20
|
* Called whenever the terminal title changes.
|
|
21
21
|
*/
|
|
22
22
|
onTitleChange?: (title: string) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Formats terminal-visible errors before they are written to xterm and passed
|
|
25
|
+
* to `onError`.
|
|
26
|
+
*/
|
|
27
|
+
formatError?: (message: string) => string;
|
|
23
28
|
}
|
|
24
|
-
declare function WebTTYTerminal(props: WebTTYTerminalProps):
|
|
29
|
+
declare function WebTTYTerminal(props: WebTTYTerminalProps): React.JSX.Element;
|
|
25
30
|
|
|
26
31
|
export { WebTTYTerminal, type WebTTYTerminalProps };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import { ITerminalOptions, Terminal } from '@xterm/xterm';
|
|
2
|
+
import * as React from 'react';
|
|
3
3
|
import { WebTTYClientConfig, WebTTYExecutionConfig, WebTTYEvents } from '@rstreamlabs/webtty';
|
|
4
4
|
|
|
5
5
|
interface WebTTYTerminalProps extends WebTTYClientConfig, WebTTYExecutionConfig, WebTTYEvents {
|
|
@@ -20,7 +20,12 @@ interface WebTTYTerminalProps extends WebTTYClientConfig, WebTTYExecutionConfig,
|
|
|
20
20
|
* Called whenever the terminal title changes.
|
|
21
21
|
*/
|
|
22
22
|
onTitleChange?: (title: string) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Formats terminal-visible errors before they are written to xterm and passed
|
|
25
|
+
* to `onError`.
|
|
26
|
+
*/
|
|
27
|
+
formatError?: (message: string) => string;
|
|
23
28
|
}
|
|
24
|
-
declare function WebTTYTerminal(props: WebTTYTerminalProps):
|
|
29
|
+
declare function WebTTYTerminal(props: WebTTYTerminalProps): React.JSX.Element;
|
|
25
30
|
|
|
26
31
|
export { WebTTYTerminal, type WebTTYTerminalProps };
|
package/dist/components/index.js
CHANGED
|
@@ -36,13 +36,13 @@ module.exports = __toCommonJS(components_exports);
|
|
|
36
36
|
|
|
37
37
|
// src/components/webtty.tsx
|
|
38
38
|
var import_xterm = require("@xterm/xterm/css/xterm.css");
|
|
39
|
-
var import_addon_fit = require("@xterm/addon-fit");
|
|
40
39
|
var import_webtty = require("@rstreamlabs/webtty");
|
|
41
|
-
var
|
|
40
|
+
var import_webtty2 = require("@rstreamlabs/webtty");
|
|
41
|
+
var import_addon_fit = require("@xterm/addon-fit");
|
|
42
42
|
var import_addon_unicode11 = require("@xterm/addon-unicode11");
|
|
43
|
-
var import_addon_webgl = require("@xterm/addon-webgl");
|
|
44
43
|
var import_addon_web_links = require("@xterm/addon-web-links");
|
|
45
|
-
var
|
|
44
|
+
var import_addon_webgl = require("@xterm/addon-webgl");
|
|
45
|
+
var import_xterm2 = require("@xterm/xterm");
|
|
46
46
|
var React = __toESM(require("react"));
|
|
47
47
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
48
48
|
function WebTTYTerminal(props) {
|
|
@@ -84,13 +84,22 @@ function WebTTYTerminal(props) {
|
|
|
84
84
|
cmdArgs,
|
|
85
85
|
envVars,
|
|
86
86
|
execPath,
|
|
87
|
+
endpointIdentity,
|
|
88
|
+
expectedServerIdentity,
|
|
87
89
|
heartbeatIntervalMs,
|
|
88
90
|
interactive,
|
|
91
|
+
payloadCrypto,
|
|
89
92
|
sendHeartbeat,
|
|
90
93
|
terminalOptions,
|
|
94
|
+
transport,
|
|
91
95
|
url,
|
|
92
96
|
username,
|
|
93
|
-
|
|
97
|
+
webTransportOptions,
|
|
98
|
+
workdir,
|
|
99
|
+
clientBrowserId,
|
|
100
|
+
clientDeviceId,
|
|
101
|
+
clientPrincipalId,
|
|
102
|
+
formatError
|
|
94
103
|
} = initialPropsRef.current;
|
|
95
104
|
const runtime = {
|
|
96
105
|
connected: false,
|
|
@@ -163,8 +172,27 @@ function WebTTYTerminal(props) {
|
|
|
163
172
|
});
|
|
164
173
|
const connectionURL = execPath === void 0 ? url : (0, import_webtty.resolveWebTTYExecutionURL)(url, execPath);
|
|
165
174
|
const webtty = new import_webtty2.WebTTY(
|
|
166
|
-
{
|
|
167
|
-
|
|
175
|
+
{
|
|
176
|
+
clientBrowserId,
|
|
177
|
+
clientDeviceId,
|
|
178
|
+
clientPrincipalId,
|
|
179
|
+
endpointIdentity,
|
|
180
|
+
expectedServerIdentity,
|
|
181
|
+
heartbeatIntervalMs,
|
|
182
|
+
sendHeartbeat,
|
|
183
|
+
transport,
|
|
184
|
+
url: connectionURL,
|
|
185
|
+
webTransportOptions
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
cmdArgs,
|
|
189
|
+
envVars,
|
|
190
|
+
allocateTty,
|
|
191
|
+
interactive,
|
|
192
|
+
payloadCrypto,
|
|
193
|
+
username,
|
|
194
|
+
workdir
|
|
195
|
+
},
|
|
168
196
|
{
|
|
169
197
|
onStdout: (chunk) => {
|
|
170
198
|
onStdoutEvent(chunk);
|
|
@@ -187,11 +215,9 @@ function WebTTYTerminal(props) {
|
|
|
187
215
|
fit();
|
|
188
216
|
syncRemoteSize(terminal.rows, terminal.cols);
|
|
189
217
|
runtime.disposeOnData = terminal.onData((data) => {
|
|
190
|
-
|
|
191
|
-
webtty.writeStdin(textEncoder.encode(data));
|
|
192
|
-
} catch (e) {
|
|
218
|
+
void webtty.writeStdinAsync(textEncoder.encode(data)).catch((e) => {
|
|
193
219
|
console.error("Cannot writeStdin:", e);
|
|
194
|
-
}
|
|
220
|
+
});
|
|
195
221
|
});
|
|
196
222
|
runtime.disposeOnResize = terminal.onResize((size) => {
|
|
197
223
|
syncRemoteSize(size.rows, size.cols);
|
|
@@ -205,9 +231,10 @@ Process exited with code ${code}.`);
|
|
|
205
231
|
clear();
|
|
206
232
|
},
|
|
207
233
|
onError: (err) => {
|
|
208
|
-
|
|
234
|
+
const message = formatError ? formatError(err) : err;
|
|
235
|
+
onErrorEvent(message);
|
|
209
236
|
terminal.write(`\r
|
|
210
|
-
[ERROR] ${
|
|
237
|
+
[ERROR] ${message}`);
|
|
211
238
|
terminal.write("\x1B[?25l");
|
|
212
239
|
clear();
|
|
213
240
|
}
|
package/dist/hooks/index.d.mts
CHANGED
|
@@ -50,7 +50,7 @@ declare function useRstream(options?: UseRstreamOptions): {
|
|
|
50
50
|
name?: string | undefined;
|
|
51
51
|
type?: "bytestream" | "datagram" | undefined;
|
|
52
52
|
publish?: boolean | undefined;
|
|
53
|
-
protocol?: "tls" | "dtls" | "quic" | "http" | undefined;
|
|
53
|
+
protocol?: "tls" | "dtls" | "quic" | "http" | "webtty" | undefined;
|
|
54
54
|
labels?: Record<string, string> | undefined;
|
|
55
55
|
geo_ip?: string[] | undefined;
|
|
56
56
|
trusted_ips?: string[] | undefined;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ declare function useRstream(options?: UseRstreamOptions): {
|
|
|
50
50
|
name?: string | undefined;
|
|
51
51
|
type?: "bytestream" | "datagram" | undefined;
|
|
52
52
|
publish?: boolean | undefined;
|
|
53
|
-
protocol?: "tls" | "dtls" | "quic" | "http" | undefined;
|
|
53
|
+
protocol?: "tls" | "dtls" | "quic" | "http" | "webtty" | undefined;
|
|
54
54
|
labels?: Record<string, string> | undefined;
|
|
55
55
|
geo_ip?: string[] | undefined;
|
|
56
56
|
trusted_ips?: string[] | undefined;
|
package/dist/hooks/index.js
CHANGED
|
@@ -178,7 +178,7 @@ function useRstream(options) {
|
|
|
178
178
|
if (state !== "connected") {
|
|
179
179
|
const timeout = setTimeout(() => {
|
|
180
180
|
setError({
|
|
181
|
-
message: "Failed to fetch rstream
|
|
181
|
+
message: "Failed to fetch rstream resources. Retrying...",
|
|
182
182
|
type: "warning"
|
|
183
183
|
});
|
|
184
184
|
}, errorTimeout);
|
|
@@ -186,16 +186,21 @@ function useRstream(options) {
|
|
|
186
186
|
clearTimeout(timeout);
|
|
187
187
|
};
|
|
188
188
|
} else if (state === "connected") {
|
|
189
|
-
setError(null);
|
|
189
|
+
const timeout = setTimeout(() => setError(null), 0);
|
|
190
|
+
return () => clearTimeout(timeout);
|
|
190
191
|
}
|
|
191
192
|
} else {
|
|
192
|
-
setError(null);
|
|
193
|
+
const timeout = setTimeout(() => setError(null), 0);
|
|
194
|
+
return () => clearTimeout(timeout);
|
|
193
195
|
}
|
|
194
196
|
}, [authEnabled, state, error, errorTimeout]);
|
|
195
197
|
React.useEffect(() => {
|
|
196
198
|
if (!authEnabled || state !== "connected") {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
+
const timeout = setTimeout(() => {
|
|
200
|
+
setClients([]);
|
|
201
|
+
setTunnels([]);
|
|
202
|
+
}, 0);
|
|
203
|
+
return () => clearTimeout(timeout);
|
|
199
204
|
}
|
|
200
205
|
}, [authEnabled, connectionKey, state]);
|
|
201
206
|
return { state, error, tunnels, clients };
|
package/dist/hooks/index.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export { WebTTYTerminal, WebTTYTerminalProps } from './components/index.mjs';
|
|
2
2
|
export { UseRstreamOptions, useRstream } from './hooks/index.mjs';
|
|
3
3
|
export { RstreamProvider, useRstreamContext } from './providers/index.mjs';
|
|
4
|
-
import 'react/jsx-runtime';
|
|
5
4
|
import '@xterm/xterm';
|
|
5
|
+
import 'react';
|
|
6
6
|
import '@rstreamlabs/webtty';
|
|
7
7
|
import '@rstreamlabs/tunnels';
|
|
8
|
-
import 'react';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export { WebTTYTerminal, WebTTYTerminalProps } from './components/index.js';
|
|
2
2
|
export { UseRstreamOptions, useRstream } from './hooks/index.js';
|
|
3
3
|
export { RstreamProvider, useRstreamContext } from './providers/index.js';
|
|
4
|
-
import 'react/jsx-runtime';
|
|
5
4
|
import '@xterm/xterm';
|
|
5
|
+
import 'react';
|
|
6
6
|
import '@rstreamlabs/webtty';
|
|
7
7
|
import '@rstreamlabs/tunnels';
|
|
8
|
-
import 'react';
|
package/dist/index.js
CHANGED
|
@@ -39,13 +39,13 @@ module.exports = __toCommonJS(src_exports);
|
|
|
39
39
|
|
|
40
40
|
// src/components/webtty.tsx
|
|
41
41
|
var import_xterm = require("@xterm/xterm/css/xterm.css");
|
|
42
|
-
var import_addon_fit = require("@xterm/addon-fit");
|
|
43
42
|
var import_webtty = require("@rstreamlabs/webtty");
|
|
44
|
-
var
|
|
43
|
+
var import_webtty2 = require("@rstreamlabs/webtty");
|
|
44
|
+
var import_addon_fit = require("@xterm/addon-fit");
|
|
45
45
|
var import_addon_unicode11 = require("@xterm/addon-unicode11");
|
|
46
|
-
var import_addon_webgl = require("@xterm/addon-webgl");
|
|
47
46
|
var import_addon_web_links = require("@xterm/addon-web-links");
|
|
48
|
-
var
|
|
47
|
+
var import_addon_webgl = require("@xterm/addon-webgl");
|
|
48
|
+
var import_xterm2 = require("@xterm/xterm");
|
|
49
49
|
var React = __toESM(require("react"));
|
|
50
50
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
51
51
|
function WebTTYTerminal(props) {
|
|
@@ -87,13 +87,22 @@ function WebTTYTerminal(props) {
|
|
|
87
87
|
cmdArgs,
|
|
88
88
|
envVars,
|
|
89
89
|
execPath,
|
|
90
|
+
endpointIdentity,
|
|
91
|
+
expectedServerIdentity,
|
|
90
92
|
heartbeatIntervalMs,
|
|
91
93
|
interactive,
|
|
94
|
+
payloadCrypto,
|
|
92
95
|
sendHeartbeat,
|
|
93
96
|
terminalOptions,
|
|
97
|
+
transport,
|
|
94
98
|
url,
|
|
95
99
|
username,
|
|
96
|
-
|
|
100
|
+
webTransportOptions,
|
|
101
|
+
workdir,
|
|
102
|
+
clientBrowserId,
|
|
103
|
+
clientDeviceId,
|
|
104
|
+
clientPrincipalId,
|
|
105
|
+
formatError
|
|
97
106
|
} = initialPropsRef.current;
|
|
98
107
|
const runtime = {
|
|
99
108
|
connected: false,
|
|
@@ -166,8 +175,27 @@ function WebTTYTerminal(props) {
|
|
|
166
175
|
});
|
|
167
176
|
const connectionURL = execPath === void 0 ? url : (0, import_webtty.resolveWebTTYExecutionURL)(url, execPath);
|
|
168
177
|
const webtty = new import_webtty2.WebTTY(
|
|
169
|
-
{
|
|
170
|
-
|
|
178
|
+
{
|
|
179
|
+
clientBrowserId,
|
|
180
|
+
clientDeviceId,
|
|
181
|
+
clientPrincipalId,
|
|
182
|
+
endpointIdentity,
|
|
183
|
+
expectedServerIdentity,
|
|
184
|
+
heartbeatIntervalMs,
|
|
185
|
+
sendHeartbeat,
|
|
186
|
+
transport,
|
|
187
|
+
url: connectionURL,
|
|
188
|
+
webTransportOptions
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
cmdArgs,
|
|
192
|
+
envVars,
|
|
193
|
+
allocateTty,
|
|
194
|
+
interactive,
|
|
195
|
+
payloadCrypto,
|
|
196
|
+
username,
|
|
197
|
+
workdir
|
|
198
|
+
},
|
|
171
199
|
{
|
|
172
200
|
onStdout: (chunk) => {
|
|
173
201
|
onStdoutEvent(chunk);
|
|
@@ -190,11 +218,9 @@ function WebTTYTerminal(props) {
|
|
|
190
218
|
fit();
|
|
191
219
|
syncRemoteSize(terminal.rows, terminal.cols);
|
|
192
220
|
runtime.disposeOnData = terminal.onData((data) => {
|
|
193
|
-
|
|
194
|
-
webtty.writeStdin(textEncoder.encode(data));
|
|
195
|
-
} catch (e) {
|
|
221
|
+
void webtty.writeStdinAsync(textEncoder.encode(data)).catch((e) => {
|
|
196
222
|
console.error("Cannot writeStdin:", e);
|
|
197
|
-
}
|
|
223
|
+
});
|
|
198
224
|
});
|
|
199
225
|
runtime.disposeOnResize = terminal.onResize((size) => {
|
|
200
226
|
syncRemoteSize(size.rows, size.cols);
|
|
@@ -208,9 +234,10 @@ Process exited with code ${code}.`);
|
|
|
208
234
|
clear();
|
|
209
235
|
},
|
|
210
236
|
onError: (err) => {
|
|
211
|
-
|
|
237
|
+
const message = formatError ? formatError(err) : err;
|
|
238
|
+
onErrorEvent(message);
|
|
212
239
|
terminal.write(`\r
|
|
213
|
-
[ERROR] ${
|
|
240
|
+
[ERROR] ${message}`);
|
|
214
241
|
terminal.write("\x1B[?25l");
|
|
215
242
|
clear();
|
|
216
243
|
}
|
|
@@ -380,7 +407,7 @@ function useRstream(options) {
|
|
|
380
407
|
if (state !== "connected") {
|
|
381
408
|
const timeout = setTimeout(() => {
|
|
382
409
|
setError({
|
|
383
|
-
message: "Failed to fetch rstream
|
|
410
|
+
message: "Failed to fetch rstream resources. Retrying...",
|
|
384
411
|
type: "warning"
|
|
385
412
|
});
|
|
386
413
|
}, errorTimeout);
|
|
@@ -388,16 +415,21 @@ function useRstream(options) {
|
|
|
388
415
|
clearTimeout(timeout);
|
|
389
416
|
};
|
|
390
417
|
} else if (state === "connected") {
|
|
391
|
-
setError(null);
|
|
418
|
+
const timeout = setTimeout(() => setError(null), 0);
|
|
419
|
+
return () => clearTimeout(timeout);
|
|
392
420
|
}
|
|
393
421
|
} else {
|
|
394
|
-
setError(null);
|
|
422
|
+
const timeout = setTimeout(() => setError(null), 0);
|
|
423
|
+
return () => clearTimeout(timeout);
|
|
395
424
|
}
|
|
396
425
|
}, [authEnabled, state, error, errorTimeout]);
|
|
397
426
|
React2.useEffect(() => {
|
|
398
427
|
if (!authEnabled || state !== "connected") {
|
|
399
|
-
|
|
400
|
-
|
|
428
|
+
const timeout = setTimeout(() => {
|
|
429
|
+
setClients([]);
|
|
430
|
+
setTunnels([]);
|
|
431
|
+
}, 0);
|
|
432
|
+
return () => clearTimeout(timeout);
|
|
401
433
|
}
|
|
402
434
|
}, [authEnabled, connectionKey, state]);
|
|
403
435
|
return { state, error, tunnels, clients };
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WebTTYTerminal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SVAMATWT.mjs";
|
|
4
4
|
import "./chunk-2JFL7TS5.mjs";
|
|
5
5
|
import {
|
|
6
6
|
RstreamProvider,
|
|
7
7
|
useRstreamContext
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-UQDRDSGV.mjs";
|
|
9
9
|
import {
|
|
10
10
|
useRstream
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-YZQKMOHW.mjs";
|
|
12
12
|
export {
|
|
13
13
|
RstreamProvider,
|
|
14
14
|
WebTTYTerminal,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import { UseRstreamOptions, useRstream } from '../hooks/index.mjs';
|
|
3
2
|
import * as React from 'react';
|
|
4
3
|
import '@rstreamlabs/tunnels';
|
|
@@ -25,7 +24,7 @@ declare function useRstreamContext(): {
|
|
|
25
24
|
name?: string | undefined;
|
|
26
25
|
type?: "bytestream" | "datagram" | undefined;
|
|
27
26
|
publish?: boolean | undefined;
|
|
28
|
-
protocol?: "tls" | "dtls" | "quic" | "http" | undefined;
|
|
27
|
+
protocol?: "tls" | "dtls" | "quic" | "http" | "webtty" | undefined;
|
|
29
28
|
labels?: Record<string, string> | undefined;
|
|
30
29
|
geo_ip?: string[] | undefined;
|
|
31
30
|
trusted_ips?: string[] | undefined;
|
|
@@ -67,6 +66,6 @@ interface RstreamProviderProps {
|
|
|
67
66
|
options?: UseRstreamOptions;
|
|
68
67
|
children: React.ReactNode | ((value: RstreamContextValue) => React.ReactNode);
|
|
69
68
|
}
|
|
70
|
-
declare function RstreamProvider({ options, children }: RstreamProviderProps):
|
|
69
|
+
declare function RstreamProvider({ options, children }: RstreamProviderProps): React.JSX.Element;
|
|
71
70
|
|
|
72
71
|
export { RstreamProvider, useRstreamContext };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import { UseRstreamOptions, useRstream } from '../hooks/index.js';
|
|
3
2
|
import * as React from 'react';
|
|
4
3
|
import '@rstreamlabs/tunnels';
|
|
@@ -25,7 +24,7 @@ declare function useRstreamContext(): {
|
|
|
25
24
|
name?: string | undefined;
|
|
26
25
|
type?: "bytestream" | "datagram" | undefined;
|
|
27
26
|
publish?: boolean | undefined;
|
|
28
|
-
protocol?: "tls" | "dtls" | "quic" | "http" | undefined;
|
|
27
|
+
protocol?: "tls" | "dtls" | "quic" | "http" | "webtty" | undefined;
|
|
29
28
|
labels?: Record<string, string> | undefined;
|
|
30
29
|
geo_ip?: string[] | undefined;
|
|
31
30
|
trusted_ips?: string[] | undefined;
|
|
@@ -67,6 +66,6 @@ interface RstreamProviderProps {
|
|
|
67
66
|
options?: UseRstreamOptions;
|
|
68
67
|
children: React.ReactNode | ((value: RstreamContextValue) => React.ReactNode);
|
|
69
68
|
}
|
|
70
|
-
declare function RstreamProvider({ options, children }: RstreamProviderProps):
|
|
69
|
+
declare function RstreamProvider({ options, children }: RstreamProviderProps): React.JSX.Element;
|
|
71
70
|
|
|
72
71
|
export { RstreamProvider, useRstreamContext };
|
package/dist/providers/index.js
CHANGED
|
@@ -179,7 +179,7 @@ function useRstream(options) {
|
|
|
179
179
|
if (state !== "connected") {
|
|
180
180
|
const timeout = setTimeout(() => {
|
|
181
181
|
setError({
|
|
182
|
-
message: "Failed to fetch rstream
|
|
182
|
+
message: "Failed to fetch rstream resources. Retrying...",
|
|
183
183
|
type: "warning"
|
|
184
184
|
});
|
|
185
185
|
}, errorTimeout);
|
|
@@ -187,16 +187,21 @@ function useRstream(options) {
|
|
|
187
187
|
clearTimeout(timeout);
|
|
188
188
|
};
|
|
189
189
|
} else if (state === "connected") {
|
|
190
|
-
setError(null);
|
|
190
|
+
const timeout = setTimeout(() => setError(null), 0);
|
|
191
|
+
return () => clearTimeout(timeout);
|
|
191
192
|
}
|
|
192
193
|
} else {
|
|
193
|
-
setError(null);
|
|
194
|
+
const timeout = setTimeout(() => setError(null), 0);
|
|
195
|
+
return () => clearTimeout(timeout);
|
|
194
196
|
}
|
|
195
197
|
}, [authEnabled, state, error, errorTimeout]);
|
|
196
198
|
React.useEffect(() => {
|
|
197
199
|
if (!authEnabled || state !== "connected") {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
+
const timeout = setTimeout(() => {
|
|
201
|
+
setClients([]);
|
|
202
|
+
setTunnels([]);
|
|
203
|
+
}, 0);
|
|
204
|
+
return () => clearTimeout(timeout);
|
|
200
205
|
}
|
|
201
206
|
}, [authEnabled, connectionKey, state]);
|
|
202
207
|
return { state, error, tunnels, clients };
|
package/dist/providers/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rstreamlabs/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.1",
|
|
4
4
|
"description": "React hooks and components for building rstream-enabled UIs.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -45,26 +45,26 @@
|
|
|
45
45
|
"type-check": "tsc --noEmit"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@turbo/gen": "^2.
|
|
49
|
-
"@types/node": "^
|
|
48
|
+
"@turbo/gen": "^2.10.0",
|
|
49
|
+
"@types/node": "^26.0.1",
|
|
50
50
|
"@types/react-dom": "19.2.3",
|
|
51
|
-
"@types/react": "19.2.
|
|
51
|
+
"@types/react": "19.2.17",
|
|
52
52
|
"eslint-config": "*",
|
|
53
53
|
"tsup": "^8.5.1",
|
|
54
54
|
"typescript-config": "*",
|
|
55
55
|
"typescript": "5.9.3"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@rstreamlabs/rstream": "3.
|
|
59
|
-
"@rstreamlabs/tunnels": "3.
|
|
60
|
-
"@rstreamlabs/webtty": "1.
|
|
58
|
+
"@rstreamlabs/rstream": "3.3.0",
|
|
59
|
+
"@rstreamlabs/tunnels": "3.5.0",
|
|
60
|
+
"@rstreamlabs/webtty": "1.9.0",
|
|
61
61
|
"@xterm/addon-fit": "^0.11.0",
|
|
62
62
|
"@xterm/addon-unicode11": "^0.9.0",
|
|
63
63
|
"@xterm/addon-web-links": "^0.12.0",
|
|
64
64
|
"@xterm/addon-webgl": "^0.19.0",
|
|
65
65
|
"@xterm/xterm": "^6.0.0",
|
|
66
|
-
"react-dom": "^19.2.
|
|
67
|
-
"react": "^19.2.
|
|
66
|
+
"react-dom": "^19.2.7",
|
|
67
|
+
"react": "^19.2.7"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"@types/react": "*",
|