overmux 0.0.2 → 0.0.3

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.
@@ -1,18 +1,9 @@
1
+ import "./desktop-host";
1
2
  import { notificationEventSchema } from "../../shared/index";
2
3
 
3
4
  import type { WebSocketTransport } from "../transport";
4
5
 
5
6
  // Forwards server notifications to the optional desktop host injected at window.overmuxHost.
6
- type NotificationHost = {
7
- notifications?: { show: (notification: unknown) => void; version: 1 };
8
- };
9
-
10
- declare global {
11
- interface Window {
12
- overmuxHost?: NotificationHost;
13
- }
14
- }
15
-
16
7
  export const installNotificationForwarding = (transport: WebSocketTransport) =>
17
8
  transport.subscribeNotification((event) => {
18
9
  const notification = notificationEventSchema.safeParse(event);
@@ -335,6 +335,10 @@ export const createWebSocketTransport = ({
335
335
  onOpen,
336
336
  streamName,
337
337
  }) => {
338
+ if (!active || disposed) {
339
+ onError(disconnected());
340
+ return { close: () => {}, send: () => false };
341
+ }
338
342
  const streamId = operationId();
339
343
  const stream: Stream = {
340
344
  input,
@@ -347,15 +351,19 @@ export const createWebSocketTransport = ({
347
351
  streamName,
348
352
  };
349
353
  streams.set(streamId, stream);
350
- stream.status = send({
351
- input,
352
- operationId: streamId,
353
- streamId,
354
- streamName,
355
- type: "stream-open",
356
- })
357
- ? "opening"
358
- : "disconnected";
354
+ // Initial connection is not a failure: restore sends stream-open when the socket
355
+ // opens, then stream-opened flushes queued messages. Actual failures still reject.
356
+ stream.status =
357
+ socket?.readyState === WebSocket.CONNECTING ||
358
+ send({
359
+ input,
360
+ operationId: streamId,
361
+ streamId,
362
+ streamName,
363
+ type: "stream-open",
364
+ })
365
+ ? "opening"
366
+ : "disconnected";
359
367
  if (stream.status === "disconnected") {
360
368
  onError(disconnected());
361
369
  }
@@ -2,6 +2,10 @@ export {
2
2
  disableBackgroundNotifications,
3
3
  enableBackgroundNotifications,
4
4
  } from "../internal/client/background-notifications";
5
+ export {
6
+ readClipboardText,
7
+ writeClipboardText,
8
+ } from "../internal/client/clipboard";
5
9
  export type { OvermuxServerApi } from "../internal/client/browser-api";
6
10
  export {
7
11
  createOvermuxHooks,