@rstreamlabs/react 1.8.2 → 1.10.0

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 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 and tunnel list-only resources. Do not embed
153
- personal access tokens or application client secrets in React code.
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
 
@@ -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 ressources. Retrying...",
145
+ message: "Failed to fetch rstream resources. Retrying...",
146
146
  type: "warning"
147
147
  });
148
148
  }, errorTimeout);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useRstream
3
- } from "./chunk-G47GUMJ6.mjs";
3
+ } from "./chunk-I4FMNQJD.mjs";
4
4
 
5
5
  // src/providers/rstream.tsx
6
6
  import * as React from "react";
@@ -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 { Terminal } from "@xterm/xterm";
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 { WebTTY } from "@rstreamlabs/webtty";
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
- workdir
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
- { heartbeatIntervalMs, sendHeartbeat, url: connectionURL },
131
- { cmdArgs, envVars, allocateTty, interactive, username, workdir },
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
- try {
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
- onErrorEvent(err);
198
+ const message = formatError ? formatError(err) : err;
199
+ onErrorEvent(message);
173
200
  terminal.write(`\r
174
- [ERROR] ${err}`);
201
+ [ERROR] ${message}`);
175
202
  terminal.write("\x1B[?25l");
176
203
  clear();
177
204
  }
@@ -20,6 +20,11 @@ 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
29
  declare function WebTTYTerminal(props: WebTTYTerminalProps): react_jsx_runtime.JSX.Element;
25
30
 
@@ -20,6 +20,11 @@ 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
29
  declare function WebTTYTerminal(props: WebTTYTerminalProps): react_jsx_runtime.JSX.Element;
25
30
 
@@ -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 import_xterm2 = require("@xterm/xterm");
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 import_webtty2 = require("@rstreamlabs/webtty");
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
- workdir
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
- { heartbeatIntervalMs, sendHeartbeat, url: connectionURL },
167
- { cmdArgs, envVars, allocateTty, interactive, username, workdir },
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
- try {
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
- onErrorEvent(err);
234
+ const message = formatError ? formatError(err) : err;
235
+ onErrorEvent(message);
209
236
  terminal.write(`\r
210
- [ERROR] ${err}`);
237
+ [ERROR] ${message}`);
211
238
  terminal.write("\x1B[?25l");
212
239
  clear();
213
240
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  WebTTYTerminal
3
- } from "../chunk-4YJETBAE.mjs";
3
+ } from "../chunk-SVAMATWT.mjs";
4
4
  export {
5
5
  WebTTYTerminal
6
6
  };
@@ -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;
@@ -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;
@@ -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 ressources. Retrying...",
181
+ message: "Failed to fetch rstream resources. Retrying...",
182
182
  type: "warning"
183
183
  });
184
184
  }, errorTimeout);
@@ -1,7 +1,7 @@
1
1
  import "../chunk-2JFL7TS5.mjs";
2
2
  import {
3
3
  useRstream
4
- } from "../chunk-G47GUMJ6.mjs";
4
+ } from "../chunk-I4FMNQJD.mjs";
5
5
  export {
6
6
  useRstream
7
7
  };
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 import_xterm2 = require("@xterm/xterm");
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 import_webtty2 = require("@rstreamlabs/webtty");
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
- workdir
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
- { heartbeatIntervalMs, sendHeartbeat, url: connectionURL },
170
- { cmdArgs, envVars, allocateTty, interactive, username, workdir },
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
- try {
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
- onErrorEvent(err);
237
+ const message = formatError ? formatError(err) : err;
238
+ onErrorEvent(message);
212
239
  terminal.write(`\r
213
- [ERROR] ${err}`);
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 ressources. Retrying...",
410
+ message: "Failed to fetch rstream resources. Retrying...",
384
411
  type: "warning"
385
412
  });
386
413
  }, errorTimeout);
package/dist/index.mjs CHANGED
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  WebTTYTerminal
3
- } from "./chunk-4YJETBAE.mjs";
3
+ } from "./chunk-SVAMATWT.mjs";
4
4
  import "./chunk-2JFL7TS5.mjs";
5
5
  import {
6
6
  RstreamProvider,
7
7
  useRstreamContext
8
- } from "./chunk-DFYVJASW.mjs";
8
+ } from "./chunk-SSAIWCGG.mjs";
9
9
  import {
10
10
  useRstream
11
- } from "./chunk-G47GUMJ6.mjs";
11
+ } from "./chunk-I4FMNQJD.mjs";
12
12
  export {
13
13
  RstreamProvider,
14
14
  WebTTYTerminal,
@@ -25,7 +25,7 @@ declare function useRstreamContext(): {
25
25
  name?: string | undefined;
26
26
  type?: "bytestream" | "datagram" | undefined;
27
27
  publish?: boolean | undefined;
28
- protocol?: "tls" | "dtls" | "quic" | "http" | undefined;
28
+ protocol?: "tls" | "dtls" | "quic" | "http" | "webtty" | undefined;
29
29
  labels?: Record<string, string> | undefined;
30
30
  geo_ip?: string[] | undefined;
31
31
  trusted_ips?: string[] | undefined;
@@ -25,7 +25,7 @@ declare function useRstreamContext(): {
25
25
  name?: string | undefined;
26
26
  type?: "bytestream" | "datagram" | undefined;
27
27
  publish?: boolean | undefined;
28
- protocol?: "tls" | "dtls" | "quic" | "http" | undefined;
28
+ protocol?: "tls" | "dtls" | "quic" | "http" | "webtty" | undefined;
29
29
  labels?: Record<string, string> | undefined;
30
30
  geo_ip?: string[] | undefined;
31
31
  trusted_ips?: string[] | undefined;
@@ -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 ressources. Retrying...",
182
+ message: "Failed to fetch rstream resources. Retrying...",
183
183
  type: "warning"
184
184
  });
185
185
  }, errorTimeout);
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  RstreamProvider,
3
3
  useRstreamContext
4
- } from "../chunk-DFYVJASW.mjs";
5
- import "../chunk-G47GUMJ6.mjs";
4
+ } from "../chunk-SSAIWCGG.mjs";
5
+ import "../chunk-I4FMNQJD.mjs";
6
6
  export {
7
7
  RstreamProvider,
8
8
  useRstreamContext
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rstreamlabs/react",
3
- "version": "1.8.2",
3
+ "version": "1.10.0",
4
4
  "description": "React hooks and components for building rstream-enabled UIs.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -55,9 +55,9 @@
55
55
  "typescript": "5.9.3"
56
56
  },
57
57
  "dependencies": {
58
- "@rstreamlabs/rstream": "3.1.0",
59
- "@rstreamlabs/tunnels": "3.2.1",
60
- "@rstreamlabs/webtty": "1.7.0",
58
+ "@rstreamlabs/rstream": "3.3.0",
59
+ "@rstreamlabs/tunnels": "3.4.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",