@rstreamlabs/react 2.0.1 → 2.1.2

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
@@ -1,6 +1,6 @@
1
1
  # `@rstreamlabs/react`
2
2
 
3
- React hooks, providers, and terminal components for rstream-enabled UIs.
3
+ rstream connects services and devices through outbound tunnels and exposes their live state through engine APIs. This package brings that state and remote terminal access into a React application through hooks, providers and components.
4
4
 
5
5
  Use this package in browser applications and dashboards that need live tunnel
6
6
  state or embedded WebTTY sessions. It builds on
@@ -14,7 +14,7 @@ protocol.
14
14
  npm install @rstreamlabs/react
15
15
  ```
16
16
 
17
- The package has a peer dependency on React 18 or 19.
17
+ The package requires React 19.2.8 or newer within React 19. It uses the application's React instance; React 18, 19.0 and 19.1 are not supported.
18
18
 
19
19
  ## Exports
20
20
 
@@ -153,6 +153,18 @@ rendering. It forwards WebTTY stdout/stderr events and keeps terminal resize
153
153
  state synchronized with the remote session. When the terminal comes from WebTTY
154
154
  inventory, pass the advertised `exec_path` value as `execPath`.
155
155
 
156
+ For an existing managed execution, pass `attach` with the authorized participant
157
+ grant and `managed={{ capabilities }}` with capabilities fetched from the same
158
+ Engine. The component forwards these options to WebTTY and joins with Attach,
159
+ without launching another command. Use `interactive={false}` and
160
+ `allocateTty={false}` for a reader that should send neither input nor resize.
161
+
162
+ `onSessionReady(session)` receives the acknowledged WebTTY handle. Its
163
+ `managedSessionId` identifies the execution, and `canTerminate()` reports native
164
+ and Engine support. An authorized controller can call `requestTermination()`;
165
+ only `onComplete` confirms the native result. Unmounting disconnects the reader
166
+ without requesting termination. Other terminal components retain their sessions.
167
+
156
168
  ## Security Notes
157
169
 
158
170
  Browser watch streams should receive a fresh short-lived watch token from a
@@ -27,6 +27,9 @@ function WebTTYTerminal(props) {
27
27
  const onConnectEvent = React.useEffectEvent(() => {
28
28
  props.onConnect?.();
29
29
  });
30
+ const onSessionReadyEvent = React.useEffectEvent((session) => {
31
+ props.onSessionReady?.(session);
32
+ });
30
33
  const onCompleteEvent = React.useEffectEvent((code) => {
31
34
  props.onComplete?.(code);
32
35
  });
@@ -45,6 +48,8 @@ function WebTTYTerminal(props) {
45
48
  }
46
49
  const {
47
50
  allocateTty,
51
+ attach,
52
+ clientCredential,
48
53
  cmdArgs,
49
54
  envVars,
50
55
  execPath,
@@ -52,12 +57,15 @@ function WebTTYTerminal(props) {
52
57
  expectedServerIdentity,
53
58
  heartbeatIntervalMs,
54
59
  interactive,
60
+ managed,
61
+ maxMessageSize,
55
62
  payloadCrypto,
56
63
  sendHeartbeat,
57
64
  terminalOptions,
58
65
  transport,
59
66
  url,
60
67
  username,
68
+ webSocketFactory,
61
69
  webTransportOptions,
62
70
  workdir,
63
71
  clientBrowserId,
@@ -119,7 +127,7 @@ function WebTTYTerminal(props) {
119
127
  return true;
120
128
  };
121
129
  const syncRemoteSize = (rows, cols) => {
122
- if (!runtime.connected) return;
130
+ if (!runtime.connected || allocateTty === false) return;
123
131
  if (rows < 1 || cols < 1) return;
124
132
  if (rows === runtime.syncedRows && cols === runtime.syncedCols) return;
125
133
  runtime.syncedRows = rows;
@@ -137,15 +145,20 @@ function WebTTYTerminal(props) {
137
145
  const connectionURL = execPath === void 0 ? url : resolveWebTTYExecutionURL(url, execPath);
138
146
  const webtty = new WebTTY(
139
147
  {
148
+ attach,
140
149
  clientBrowserId,
150
+ clientCredential,
141
151
  clientDeviceId,
142
152
  clientPrincipalId,
143
153
  endpointIdentity,
144
154
  expectedServerIdentity,
145
155
  heartbeatIntervalMs,
156
+ managed,
157
+ maxMessageSize,
146
158
  sendHeartbeat,
147
159
  transport,
148
160
  url: connectionURL,
161
+ webSocketFactory,
149
162
  webTransportOptions
150
163
  },
151
164
  {
@@ -175,14 +188,17 @@ function WebTTYTerminal(props) {
175
188
  onConnect: () => {
176
189
  runtime.connected = true;
177
190
  onConnectEvent();
191
+ onSessionReadyEvent(webtty);
178
192
  terminal.focus();
179
193
  fit();
180
194
  syncRemoteSize(terminal.rows, terminal.cols);
181
- runtime.disposeOnData = terminal.onData((data) => {
182
- void webtty.writeStdinAsync(textEncoder.encode(data)).catch((e) => {
183
- console.error("Cannot writeStdin:", e);
195
+ if (interactive !== false) {
196
+ runtime.disposeOnData = terminal.onData((data) => {
197
+ void webtty.writeStdinAsync(textEncoder.encode(data)).catch((e) => {
198
+ console.error("Cannot writeStdin:", e);
199
+ });
184
200
  });
185
- });
201
+ }
186
202
  runtime.disposeOnResize = terminal.onResize((size) => {
187
203
  syncRemoteSize(size.rows, size.cols);
188
204
  });
@@ -1,6 +1,6 @@
1
+ import { WebTTYClientConfig, WebTTYExecutionConfig, WebTTYEvents, WebTTY } from '@rstreamlabs/webtty';
1
2
  import { ITerminalOptions, Terminal } from '@xterm/xterm';
2
3
  import * as React from 'react';
3
- import { WebTTYClientConfig, WebTTYExecutionConfig, WebTTYEvents } from '@rstreamlabs/webtty';
4
4
 
5
5
  interface WebTTYTerminalProps extends WebTTYClientConfig, WebTTYExecutionConfig, WebTTYEvents {
6
6
  /**
@@ -16,6 +16,8 @@ interface WebTTYTerminalProps extends WebTTYClientConfig, WebTTYExecutionConfig,
16
16
  * Can be used to add your own add-ons or manipulate the Terminal instance.
17
17
  */
18
18
  onTerminalCreated?: (terminal: Terminal) => void;
19
+ /** Receives the acknowledged session for explicit stop or identity lookup. */
20
+ onSessionReady?: (session: WebTTY) => void;
19
21
  /**
20
22
  * Called whenever the terminal title changes.
21
23
  */
@@ -1,6 +1,6 @@
1
+ import { WebTTYClientConfig, WebTTYExecutionConfig, WebTTYEvents, WebTTY } from '@rstreamlabs/webtty';
1
2
  import { ITerminalOptions, Terminal } from '@xterm/xterm';
2
3
  import * as React from 'react';
3
- import { WebTTYClientConfig, WebTTYExecutionConfig, WebTTYEvents } from '@rstreamlabs/webtty';
4
4
 
5
5
  interface WebTTYTerminalProps extends WebTTYClientConfig, WebTTYExecutionConfig, WebTTYEvents {
6
6
  /**
@@ -16,6 +16,8 @@ interface WebTTYTerminalProps extends WebTTYClientConfig, WebTTYExecutionConfig,
16
16
  * Can be used to add your own add-ons or manipulate the Terminal instance.
17
17
  */
18
18
  onTerminalCreated?: (terminal: Terminal) => void;
19
+ /** Receives the acknowledged session for explicit stop or identity lookup. */
20
+ onSessionReady?: (session: WebTTY) => void;
19
21
  /**
20
22
  * Called whenever the terminal title changes.
21
23
  */
@@ -63,6 +63,9 @@ function WebTTYTerminal(props) {
63
63
  const onConnectEvent = React.useEffectEvent(() => {
64
64
  props.onConnect?.();
65
65
  });
66
+ const onSessionReadyEvent = React.useEffectEvent((session) => {
67
+ props.onSessionReady?.(session);
68
+ });
66
69
  const onCompleteEvent = React.useEffectEvent((code) => {
67
70
  props.onComplete?.(code);
68
71
  });
@@ -81,6 +84,8 @@ function WebTTYTerminal(props) {
81
84
  }
82
85
  const {
83
86
  allocateTty,
87
+ attach,
88
+ clientCredential,
84
89
  cmdArgs,
85
90
  envVars,
86
91
  execPath,
@@ -88,12 +93,15 @@ function WebTTYTerminal(props) {
88
93
  expectedServerIdentity,
89
94
  heartbeatIntervalMs,
90
95
  interactive,
96
+ managed,
97
+ maxMessageSize,
91
98
  payloadCrypto,
92
99
  sendHeartbeat,
93
100
  terminalOptions,
94
101
  transport,
95
102
  url,
96
103
  username,
104
+ webSocketFactory,
97
105
  webTransportOptions,
98
106
  workdir,
99
107
  clientBrowserId,
@@ -155,7 +163,7 @@ function WebTTYTerminal(props) {
155
163
  return true;
156
164
  };
157
165
  const syncRemoteSize = (rows, cols) => {
158
- if (!runtime.connected) return;
166
+ if (!runtime.connected || allocateTty === false) return;
159
167
  if (rows < 1 || cols < 1) return;
160
168
  if (rows === runtime.syncedRows && cols === runtime.syncedCols) return;
161
169
  runtime.syncedRows = rows;
@@ -173,15 +181,20 @@ function WebTTYTerminal(props) {
173
181
  const connectionURL = execPath === void 0 ? url : (0, import_webtty.resolveWebTTYExecutionURL)(url, execPath);
174
182
  const webtty = new import_webtty2.WebTTY(
175
183
  {
184
+ attach,
176
185
  clientBrowserId,
186
+ clientCredential,
177
187
  clientDeviceId,
178
188
  clientPrincipalId,
179
189
  endpointIdentity,
180
190
  expectedServerIdentity,
181
191
  heartbeatIntervalMs,
192
+ managed,
193
+ maxMessageSize,
182
194
  sendHeartbeat,
183
195
  transport,
184
196
  url: connectionURL,
197
+ webSocketFactory,
185
198
  webTransportOptions
186
199
  },
187
200
  {
@@ -211,14 +224,17 @@ function WebTTYTerminal(props) {
211
224
  onConnect: () => {
212
225
  runtime.connected = true;
213
226
  onConnectEvent();
227
+ onSessionReadyEvent(webtty);
214
228
  terminal.focus();
215
229
  fit();
216
230
  syncRemoteSize(terminal.rows, terminal.cols);
217
- runtime.disposeOnData = terminal.onData((data) => {
218
- void webtty.writeStdinAsync(textEncoder.encode(data)).catch((e) => {
219
- console.error("Cannot writeStdin:", e);
231
+ if (interactive !== false) {
232
+ runtime.disposeOnData = terminal.onData((data) => {
233
+ void webtty.writeStdinAsync(textEncoder.encode(data)).catch((e) => {
234
+ console.error("Cannot writeStdin:", e);
235
+ });
220
236
  });
221
- });
237
+ }
222
238
  runtime.disposeOnResize = terminal.onResize((size) => {
223
239
  syncRemoteSize(size.rows, size.cols);
224
240
  });
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  WebTTYTerminal
3
- } from "../chunk-SVAMATWT.mjs";
3
+ } from "../chunk-WSSCCXEE.mjs";
4
4
  export {
5
5
  WebTTYTerminal
6
6
  };
package/dist/index.d.mts CHANGED
@@ -1,7 +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 '@rstreamlabs/webtty';
4
5
  import '@xterm/xterm';
5
6
  import 'react';
6
- import '@rstreamlabs/webtty';
7
7
  import '@rstreamlabs/tunnels';
package/dist/index.d.ts CHANGED
@@ -1,7 +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 '@rstreamlabs/webtty';
4
5
  import '@xterm/xterm';
5
6
  import 'react';
6
- import '@rstreamlabs/webtty';
7
7
  import '@rstreamlabs/tunnels';
package/dist/index.js CHANGED
@@ -66,6 +66,9 @@ function WebTTYTerminal(props) {
66
66
  const onConnectEvent = React.useEffectEvent(() => {
67
67
  props.onConnect?.();
68
68
  });
69
+ const onSessionReadyEvent = React.useEffectEvent((session) => {
70
+ props.onSessionReady?.(session);
71
+ });
69
72
  const onCompleteEvent = React.useEffectEvent((code) => {
70
73
  props.onComplete?.(code);
71
74
  });
@@ -84,6 +87,8 @@ function WebTTYTerminal(props) {
84
87
  }
85
88
  const {
86
89
  allocateTty,
90
+ attach,
91
+ clientCredential,
87
92
  cmdArgs,
88
93
  envVars,
89
94
  execPath,
@@ -91,12 +96,15 @@ function WebTTYTerminal(props) {
91
96
  expectedServerIdentity,
92
97
  heartbeatIntervalMs,
93
98
  interactive,
99
+ managed,
100
+ maxMessageSize,
94
101
  payloadCrypto,
95
102
  sendHeartbeat,
96
103
  terminalOptions,
97
104
  transport,
98
105
  url,
99
106
  username,
107
+ webSocketFactory,
100
108
  webTransportOptions,
101
109
  workdir,
102
110
  clientBrowserId,
@@ -158,7 +166,7 @@ function WebTTYTerminal(props) {
158
166
  return true;
159
167
  };
160
168
  const syncRemoteSize = (rows, cols) => {
161
- if (!runtime.connected) return;
169
+ if (!runtime.connected || allocateTty === false) return;
162
170
  if (rows < 1 || cols < 1) return;
163
171
  if (rows === runtime.syncedRows && cols === runtime.syncedCols) return;
164
172
  runtime.syncedRows = rows;
@@ -176,15 +184,20 @@ function WebTTYTerminal(props) {
176
184
  const connectionURL = execPath === void 0 ? url : (0, import_webtty.resolveWebTTYExecutionURL)(url, execPath);
177
185
  const webtty = new import_webtty2.WebTTY(
178
186
  {
187
+ attach,
179
188
  clientBrowserId,
189
+ clientCredential,
180
190
  clientDeviceId,
181
191
  clientPrincipalId,
182
192
  endpointIdentity,
183
193
  expectedServerIdentity,
184
194
  heartbeatIntervalMs,
195
+ managed,
196
+ maxMessageSize,
185
197
  sendHeartbeat,
186
198
  transport,
187
199
  url: connectionURL,
200
+ webSocketFactory,
188
201
  webTransportOptions
189
202
  },
190
203
  {
@@ -214,14 +227,17 @@ function WebTTYTerminal(props) {
214
227
  onConnect: () => {
215
228
  runtime.connected = true;
216
229
  onConnectEvent();
230
+ onSessionReadyEvent(webtty);
217
231
  terminal.focus();
218
232
  fit();
219
233
  syncRemoteSize(terminal.rows, terminal.cols);
220
- runtime.disposeOnData = terminal.onData((data) => {
221
- void webtty.writeStdinAsync(textEncoder.encode(data)).catch((e) => {
222
- console.error("Cannot writeStdin:", e);
234
+ if (interactive !== false) {
235
+ runtime.disposeOnData = terminal.onData((data) => {
236
+ void webtty.writeStdinAsync(textEncoder.encode(data)).catch((e) => {
237
+ console.error("Cannot writeStdin:", e);
238
+ });
223
239
  });
224
- });
240
+ }
225
241
  runtime.disposeOnResize = terminal.onResize((size) => {
226
242
  syncRemoteSize(size.rows, size.cols);
227
243
  });
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  WebTTYTerminal
3
- } from "./chunk-SVAMATWT.mjs";
3
+ } from "./chunk-WSSCCXEE.mjs";
4
4
  import "./chunk-2JFL7TS5.mjs";
5
5
  import {
6
6
  RstreamProvider,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rstreamlabs/react",
3
- "version": "2.0.1",
3
+ "version": "2.1.2",
4
4
  "description": "React hooks and components for building rstream-enabled UIs.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -46,30 +46,30 @@
46
46
  "test": "node --test test/*.test.cjs"
47
47
  },
48
48
  "devDependencies": {
49
- "@turbo/gen": "^2.10.11",
50
- "@types/node": "^26.2.0",
51
- "@types/react": "19.2.18",
52
- "@types/react-dom": "19.2.4",
49
+ "@turbo/gen": "^2.11.11",
50
+ "@types/node": "^26.6.6",
51
+ "@types/react": "19.3.0",
52
+ "@types/react-dom": "19.3.0",
53
53
  "eslint-config": "*",
54
54
  "tsup": "^8.5.1",
55
55
  "typescript": "6.0.3",
56
- "typescript-config": "*"
56
+ "typescript-config": "*",
57
+ "react": "^19.3.1",
58
+ "react-dom": "^19.3.1"
57
59
  },
58
60
  "dependencies": {
59
- "@rstreamlabs/rstream": "3.11.1",
60
- "@rstreamlabs/tunnels": "4.0.1",
61
- "@rstreamlabs/webtty": "1.11.2",
61
+ "@rstreamlabs/rstream": "3.12.0",
62
+ "@rstreamlabs/tunnels": "4.1.0",
63
+ "@rstreamlabs/webtty": "1.12.2",
62
64
  "@xterm/addon-fit": "^0.11.0",
63
65
  "@xterm/addon-unicode11": "^0.9.0",
64
66
  "@xterm/addon-web-links": "^0.12.0",
65
67
  "@xterm/addon-webgl": "^0.19.0",
66
- "@xterm/xterm": "^6.0.0",
67
- "react": "^18.0 || ^19.0",
68
- "react-dom": "^19.2.8"
68
+ "@xterm/xterm": "^6.0.0"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "@types/react": "*",
72
- "react": "^18.0 || ^19.0"
72
+ "react": "^19.2.8"
73
73
  },
74
74
  "peerDependenciesMeta": {
75
75
  "@types/react": {