@iwsdk/vite-plugin-dev 0.4.1 → 0.5.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.
@@ -4,4 +4,4 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- export { MCPWebSocketClient, initMCPClient } from './ws-client.js';
7
+ export { MCPWebSocketClient, initMCPBridge, initMCPClient, } from './ws-client.js';
@@ -5,6 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { XRDevice } from 'iwer';
8
+ type MCPPageRole = 'app' | 'editor' | 'preview';
8
9
  /**
9
10
  * Interface that any framework can implement to provide MCP tools.
10
11
  * The vite plugin will route requests to this runtime when available.
@@ -23,6 +24,10 @@ declare global {
23
24
  interface Window {
24
25
  FRAMEWORK_MCP_RUNTIME?: FrameworkMCPRuntime;
25
26
  __IWSDK_MCP_TRACE?: boolean;
27
+ __IWSDK_MCP_PAGE_ID?: string;
28
+ __IWSDK_MCP_PAGE_ROLE?: MCPPageRole;
29
+ __IWSDK_MCP_TAB_GENERATION?: number;
30
+ __IWSDK_SCENE_SESSION_ID?: string;
26
31
  }
27
32
  }
28
33
  /**
@@ -36,15 +41,22 @@ export declare class MCPWebSocketClient {
36
41
  private reconnectAttempts;
37
42
  private maxReconnectAttempts;
38
43
  private reconnectDelay;
44
+ private maxReconnectDelay;
39
45
  private reconnectTimer;
40
46
  private intentionalDisconnect;
41
47
  private verbose;
48
+ private readonly runtimeReadyListener;
42
49
  readonly tabId: string;
43
50
  readonly tabGeneration: number;
44
- constructor(device: XRDevice, options?: {
51
+ readonly pageRole: MCPPageRole;
52
+ readonly sceneSessionId: string | undefined;
53
+ constructor(device: XRDevice | null, options?: {
45
54
  verbose?: boolean;
46
55
  });
56
+ get connected(): boolean;
57
+ get connectionState(): 'connected' | 'connecting' | 'closing' | 'disconnected';
47
58
  private isTraceEnabled;
59
+ private detectPageRole;
48
60
  private trace;
49
61
  /**
50
62
  * Connect to the Vite dev server's WebSocket endpoint
@@ -56,6 +68,7 @@ export declare class MCPWebSocketClient {
56
68
  disconnect(): void;
57
69
  private getVitePort;
58
70
  private setupEventHandlers;
71
+ private announceCommandReady;
59
72
  private handleMessage;
60
73
  /**
61
74
  * Dispatch a method call to the appropriate handler.
@@ -75,4 +88,13 @@ export declare function initMCPClient(device: XRDevice, options?: {
75
88
  port?: number;
76
89
  verbose?: boolean;
77
90
  }): MCPWebSocketClient;
91
+ /**
92
+ * Connect a managed workspace/editor page without installing or requiring IWER.
93
+ * Framework-provided scene/workspace methods and page reload remain available;
94
+ * XR device methods return an explicit unsupported error.
95
+ */
96
+ export declare function initMCPBridge(options?: {
97
+ port?: number;
98
+ verbose?: boolean;
99
+ }): MCPWebSocketClient;
78
100
  export {};
@@ -12,8 +12,23 @@ export interface RelayWebSocket {
12
12
  readyState: number;
13
13
  send(data: string): void;
14
14
  }
15
+ export type RelayPageRole = 'app' | 'editor' | 'preview';
16
+ export interface RelayPageTarget {
17
+ role?: RelayPageRole;
18
+ pageId?: string;
19
+ tabGeneration?: number;
20
+ sceneSessionId?: string;
21
+ }
22
+ export interface RelayClientMetadata {
23
+ pageId: string;
24
+ role: RelayPageRole;
25
+ tabGeneration: number;
26
+ sceneSessionId?: string;
27
+ }
15
28
  export interface RelayOptions {
16
29
  verbose?: boolean;
30
+ /** Grace period for a role-only target to reconnect during page navigation. */
31
+ targetReconnectGraceMs?: number;
17
32
  }
18
33
  export interface RelayHandler {
19
34
  /**
@@ -22,6 +37,10 @@ export interface RelayHandler {
22
37
  * using first-response-wins semantics.
23
38
  */
24
39
  onMessage(senderWs: RelayWebSocket, data: string, clients: Set<RelayWebSocket>): void;
40
+ /** Register or update metadata for a browser/runtime bridge client. */
41
+ registerBrowserClient(ws: RelayWebSocket, metadata: RelayClientMetadata): void;
42
+ /** Remove a client and any associated metadata. */
43
+ unregisterClient(ws: RelayWebSocket): void;
25
44
  /** Number of pending (unresolved) relay requests. */
26
45
  pendingCount(): number;
27
46
  /** Clean up stale pending entries older than `maxAgeMs`. */