@qontinui/ui-bridge-native 0.1.5 → 0.1.6

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.
Files changed (92) hide show
  1. package/dist/control/{index.d.mts → action-executor.d.ts} +6 -10
  2. package/dist/control/action-executor.d.ts.map +1 -0
  3. package/dist/control/index.d.ts +5 -91
  4. package/dist/control/index.d.ts.map +1 -0
  5. package/dist/control/index.js +1 -1
  6. package/dist/control/index.js.map +1 -1
  7. package/dist/control/index.mjs +1 -1
  8. package/dist/control/index.mjs.map +1 -1
  9. package/dist/{types-BCYWwyVy.d.ts → control/types.d.ts} +17 -18
  10. package/dist/control/types.d.ts.map +1 -0
  11. package/dist/core/element-identifier.d.ts +41 -0
  12. package/dist/core/element-identifier.d.ts.map +1 -0
  13. package/dist/core/index.d.ts +6 -43
  14. package/dist/core/index.d.ts.map +1 -0
  15. package/dist/{registry-B8A_EoxS.d.ts → core/registry.d.ts} +10 -13
  16. package/dist/core/registry.d.ts.map +1 -0
  17. package/dist/{types-BPNuYxDx.d.ts → core/types.d.ts} +30 -30
  18. package/dist/core/types.d.ts.map +1 -0
  19. package/dist/debug/index.d.ts +4 -44
  20. package/dist/debug/index.d.ts.map +1 -0
  21. package/dist/debug/index.js.map +1 -1
  22. package/dist/debug/index.mjs.map +1 -1
  23. package/dist/debug/{index.d.mts → inspector.d.ts} +3 -6
  24. package/dist/debug/inspector.d.ts.map +1 -0
  25. package/dist/design/{index.d.mts → design-inspector-native.d.ts} +7 -11
  26. package/dist/design/design-inspector-native.d.ts.map +1 -0
  27. package/dist/{design-types-BHr6Q1FX.d.ts → design/design-types.d.ts} +10 -11
  28. package/dist/design/design-types.d.ts.map +1 -0
  29. package/dist/design/index.d.ts +5 -60
  30. package/dist/design/index.d.ts.map +1 -0
  31. package/dist/index.d.ts +28 -86
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +107 -4
  34. package/dist/index.js.map +1 -1
  35. package/dist/index.mjs +107 -4
  36. package/dist/index.mjs.map +1 -1
  37. package/dist/react/UIBridgeNativeProvider.d.ts +147 -0
  38. package/dist/react/UIBridgeNativeProvider.d.ts.map +1 -0
  39. package/dist/react/index.d.ts +8 -69
  40. package/dist/react/index.d.ts.map +1 -0
  41. package/dist/react/index.js +116 -4
  42. package/dist/react/index.js.map +1 -1
  43. package/dist/react/index.mjs +116 -4
  44. package/dist/react/index.mjs.map +1 -1
  45. package/dist/react/{index.d.mts → useAutoRegister.d.ts} +7 -15
  46. package/dist/react/useAutoRegister.d.ts.map +1 -0
  47. package/dist/react/useUIBridge.d.ts +103 -0
  48. package/dist/react/useUIBridge.d.ts.map +1 -0
  49. package/dist/react/useUIComponent.d.ts +112 -0
  50. package/dist/react/useUIComponent.d.ts.map +1 -0
  51. package/dist/react/useUIElement.d.ts +162 -0
  52. package/dist/react/useUIElement.d.ts.map +1 -0
  53. package/dist/server/design-handlers.d.ts +47 -0
  54. package/dist/server/design-handlers.d.ts.map +1 -0
  55. package/dist/server/handlers.d.ts +20 -0
  56. package/dist/server/handlers.d.ts.map +1 -0
  57. package/dist/server/http-server.d.ts +247 -0
  58. package/dist/server/http-server.d.ts.map +1 -0
  59. package/dist/server/index.d.ts +13 -117
  60. package/dist/server/index.d.ts.map +1 -0
  61. package/dist/server/index.js +102 -1
  62. package/dist/server/index.js.map +1 -1
  63. package/dist/server/index.mjs +102 -1
  64. package/dist/server/index.mjs.map +1 -1
  65. package/dist/server/types.d.ts +200 -0
  66. package/dist/server/types.d.ts.map +1 -0
  67. package/dist/server/ws-connection.d.ts +48 -0
  68. package/dist/server/ws-connection.d.ts.map +1 -0
  69. package/dist/server/ws-event-bridge.d.ts +113 -0
  70. package/dist/server/ws-event-bridge.d.ts.map +1 -0
  71. package/dist/server/ws-protocol.d.ts +48 -0
  72. package/dist/server/ws-protocol.d.ts.map +1 -0
  73. package/dist/server/ws-types.d.ts +65 -0
  74. package/dist/server/ws-types.d.ts.map +1 -0
  75. package/dist/transport/CloudRelayClient.d.ts +51 -0
  76. package/dist/transport/CloudRelayClient.d.ts.map +1 -0
  77. package/dist/transport/DeviceAnnouncer.d.ts +75 -0
  78. package/dist/transport/DeviceAnnouncer.d.ts.map +1 -0
  79. package/dist/transport/index.d.ts +3 -0
  80. package/dist/transport/index.d.ts.map +1 -0
  81. package/package.json +1 -1
  82. package/dist/core/index.d.mts +0 -46
  83. package/dist/design-types-BHr6Q1FX.d.mts +0 -205
  84. package/dist/http-server-B7KudcYJ.d.ts +0 -622
  85. package/dist/http-server-D7uVANBU.d.mts +0 -622
  86. package/dist/index.d.mts +0 -89
  87. package/dist/registry-DhbGbl9c.d.mts +0 -215
  88. package/dist/server/index.d.mts +0 -119
  89. package/dist/types-BPNuYxDx.d.mts +0 -383
  90. package/dist/types-Bcj7ji97.d.mts +0 -177
  91. package/dist/useUIBridge-CDZbWxII.d.ts +0 -571
  92. package/dist/useUIBridge-DfIEq9EQ.d.mts +0 -571
@@ -0,0 +1,200 @@
1
+ /**
2
+ * UI Bridge Native Server Types
3
+ *
4
+ * Types for the embedded HTTP server.
5
+ */
6
+ import type { NativeUIBridgeConfig, NativeActionResponse, NativeFindResponse, NativeBridgeSnapshot } from '../core/types';
7
+ import type { ComponentActionResponse, PageNavigationResponse } from '../control/types';
8
+ import type { ElementDesignData, StateStyles, ResponsiveSnapshot } from '../design/design-types';
9
+ /**
10
+ * Navigation provider for React Native apps.
11
+ *
12
+ * Apps supply this to enable programmatic navigation via the UI Bridge
13
+ * (e.g., `control/page/navigate` and `control/page/back`).
14
+ * For Expo Router: pass `router.push` and `router.back`.
15
+ */
16
+ export interface NavigationProvider {
17
+ navigate: (url: string) => void;
18
+ back?: () => void;
19
+ /** Replace current route (no back-stack entry). For Expo Router: router.replace */
20
+ replace?: (url: string) => void;
21
+ /** Refresh the current route. For Expo Router: router.replace(currentPath) */
22
+ refresh?: () => void;
23
+ }
24
+ /**
25
+ * Screenshot provider for React Native apps.
26
+ *
27
+ * Apps supply this to enable screen capture via the UI Bridge
28
+ * (`control/screenshot`). For react-native-view-shot: pass a function
29
+ * that calls `captureRef` on the root view and returns base64 PNG data.
30
+ */
31
+ export interface ScreenshotProvider {
32
+ /** Capture the current screen and return base64-encoded PNG data (no data: prefix). */
33
+ capture: () => Promise<{
34
+ base64: string;
35
+ width: number;
36
+ height: number;
37
+ }>;
38
+ }
39
+ /**
40
+ * Route provider for React Native apps.
41
+ *
42
+ * Apps supply this to expose the current navigation route in UI Bridge snapshots.
43
+ * For Expo Router: render a RouteTracker component inside the router context that
44
+ * calls `usePathname()` / `useSegments()` and writes the result to a module-level ref.
45
+ */
46
+ export interface RouteProvider {
47
+ /** Return the current route path (e.g. "/(tabs)/runs"), or null if unknown. */
48
+ getCurrentRoute: () => string | null;
49
+ /** Return the current route segments (e.g. ["(tabs)", "runs"]), if available. */
50
+ getSegments?: () => string[];
51
+ /**
52
+ * Subscribe to route changes. Required so the UI Bridge can clear stale
53
+ * layouts on route changes with zero lag.
54
+ *
55
+ * Implementers must invoke `listener` synchronously whenever the route
56
+ * changes, passing the new route (or null if unknown). The returned function
57
+ * must unsubscribe the listener.
58
+ *
59
+ * For Expo Router: wrap your RouteTracker component in a module-level
60
+ * listener set and call each listener from within the tracker's effect.
61
+ */
62
+ subscribe: (listener: (route: string | null) => void) => () => void;
63
+ }
64
+ /**
65
+ * Server configuration
66
+ */
67
+ export interface NativeServerConfig extends NativeUIBridgeConfig {
68
+ /** Enable CORS */
69
+ cors?: boolean;
70
+ /** Allowed origins for CORS */
71
+ allowedOrigins?: string[];
72
+ }
73
+ /**
74
+ * Route definition
75
+ */
76
+ export interface RouteDefinition {
77
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE';
78
+ path: string;
79
+ description: string;
80
+ }
81
+ /**
82
+ * All UI Bridge Native routes
83
+ */
84
+ export declare const UI_BRIDGE_NATIVE_ROUTES: Record<string, RouteDefinition>;
85
+ /**
86
+ * API response wrapper
87
+ */
88
+ export interface APIResponse<T = unknown> {
89
+ success: boolean;
90
+ data?: T;
91
+ error?: string;
92
+ code?: string;
93
+ timestamp: number;
94
+ }
95
+ /**
96
+ * Handler context
97
+ */
98
+ export interface HandlerContext {
99
+ params: Record<string, string>;
100
+ query: Record<string, string>;
101
+ body: unknown;
102
+ }
103
+ /**
104
+ * Handler function type
105
+ */
106
+ export type HandlerFunction<T = unknown> = (context: HandlerContext) => Promise<APIResponse<T>>;
107
+ /**
108
+ * Server handlers interface
109
+ */
110
+ export interface NativeServerHandlers {
111
+ getElements: HandlerFunction<{
112
+ elements: unknown[];
113
+ }>;
114
+ getElement: HandlerFunction<{
115
+ element: unknown;
116
+ }>;
117
+ getElementState: HandlerFunction<{
118
+ state: unknown;
119
+ }>;
120
+ executeAction: HandlerFunction<NativeActionResponse>;
121
+ getComponents: HandlerFunction<{
122
+ components: unknown[];
123
+ }>;
124
+ getComponent: HandlerFunction<{
125
+ component: unknown;
126
+ }>;
127
+ executeComponentAction: HandlerFunction<ComponentActionResponse>;
128
+ find: HandlerFunction<NativeFindResponse>;
129
+ getSnapshot: HandlerFunction<NativeBridgeSnapshot>;
130
+ getWorkflows: HandlerFunction<{
131
+ workflows: unknown[];
132
+ }>;
133
+ runWorkflow: HandlerFunction<{
134
+ runId: string;
135
+ status: string;
136
+ steps: Array<{
137
+ stepId: string;
138
+ type: string;
139
+ status: string;
140
+ result?: unknown;
141
+ error?: string;
142
+ durationMs: number;
143
+ }>;
144
+ totalSteps: number;
145
+ completedSteps: number;
146
+ failedSteps: number;
147
+ skippedSteps: number;
148
+ durationMs: number;
149
+ }>;
150
+ pageRefresh: HandlerFunction<PageNavigationResponse>;
151
+ pageNavigate: HandlerFunction<PageNavigationResponse>;
152
+ pageReplace: HandlerFunction<PageNavigationResponse>;
153
+ pageGoBack: HandlerFunction<PageNavigationResponse>;
154
+ pageGoForward: HandlerFunction<PageNavigationResponse>;
155
+ getScreenshot: HandlerFunction<{
156
+ screenshot: string;
157
+ width: number;
158
+ height: number;
159
+ }>;
160
+ getElementStyles: HandlerFunction<ElementDesignData>;
161
+ getElementStateStyles: HandlerFunction<{
162
+ elementId: string;
163
+ stateStyles: StateStyles[];
164
+ }>;
165
+ getDesignSnapshot: HandlerFunction<{
166
+ elements: ElementDesignData[];
167
+ timestamp: number;
168
+ }>;
169
+ getResponsiveSnapshots: HandlerFunction<ResponsiveSnapshot[]>;
170
+ runDesignAudit: HandlerFunction<unknown>;
171
+ loadStyleGuide: HandlerFunction<{
172
+ loaded: boolean;
173
+ }>;
174
+ getStyleGuide: HandlerFunction<unknown>;
175
+ clearStyleGuide: HandlerFunction<{
176
+ cleared: boolean;
177
+ }>;
178
+ evaluateQuality: HandlerFunction<unknown>;
179
+ getQualityContexts: HandlerFunction<Array<{
180
+ name: string;
181
+ description: string;
182
+ }>>;
183
+ saveBaseline: HandlerFunction<{
184
+ saved: boolean;
185
+ elementCount: number;
186
+ }>;
187
+ diffBaseline: HandlerFunction<unknown>;
188
+ getMethods: HandlerFunction<{
189
+ methods: Array<{
190
+ method: string;
191
+ httpMethods?: string[];
192
+ description?: string;
193
+ }>;
194
+ }>;
195
+ health: HandlerFunction<{
196
+ status: string;
197
+ timestamp: number;
198
+ }>;
199
+ }
200
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AACxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjG;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,IAA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AAC,CAAC;IACzC,cAAc,EAAE,eAAe,CAAC;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACrD,aAAa,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;IACxC,eAAe,EAAE,eAAe,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAGvD,eAAe,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;IAC1C,kBAAkB,EAAE,eAAe,CAAC,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IAClF,YAAY,EAAE,eAAe,CAAC;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxE,YAAY,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;IAGvC,UAAU,EAAE,eAAe,CAAC;QAC1B,OAAO,EAAE,KAAK,CAAC;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;YAAC,WAAW,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAClF,CAAC,CAAC;IAGH,MAAM,EAAE,eAAe,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChE"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * WebSocket connection wrapper for the UI Bridge server.
3
+ *
4
+ * Manages a single WebSocket connection after the HTTP upgrade handshake,
5
+ * handling frame-level I/O, heartbeat, and event subscriptions.
6
+ */
7
+ import type { JsonRpcEvent } from './ws-types';
8
+ /**
9
+ * Callback for text messages received from the client.
10
+ * Returns a response string to send back, or null for no response.
11
+ */
12
+ export type WebSocketMessageHandler = (connId: string, message: string) => Promise<string | null>;
13
+ export declare class WebSocketConnection {
14
+ readonly id: string;
15
+ readonly subscriptions: Set<string>;
16
+ /** Heartbeat liveness flag — set false before ping, set true on pong */
17
+ alive: boolean;
18
+ private socket;
19
+ private buffer;
20
+ private fragmentBuffer;
21
+ private fragmentOpcode;
22
+ private closed;
23
+ private onMessage;
24
+ private onClose;
25
+ constructor(id: string, socket: WebSocketConnection['socket'], onMessage: WebSocketMessageHandler, onClose: (connId: string) => void);
26
+ /** Send a text message to the client. */
27
+ send(message: string): void;
28
+ /**
29
+ * Send an event if the client is subscribed to it. Subscription patterns
30
+ * may be exact event names, `*` (all), or glob patterns containing `*`
31
+ * (e.g. `element:*`, `*:stateChanged`). Exact matches and `*` are checked
32
+ * via fast Set lookups; glob patterns fall through to a regex test.
33
+ */
34
+ sendEvent(event: JsonRpcEvent): void;
35
+ private matchesSubscription;
36
+ /** Send a ping frame for heartbeat. */
37
+ ping(): void;
38
+ /** Close the connection gracefully. */
39
+ close(code?: number, reason?: string): void;
40
+ /** Forcefully destroy the connection without a close frame. */
41
+ destroy(): void;
42
+ /** Whether the connection is still open. */
43
+ get isOpen(): boolean;
44
+ private writeRaw;
45
+ private handleData;
46
+ private handleFrame;
47
+ }
48
+ //# sourceMappingURL=ws-connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ws-connection.d.ts","sourceRoot":"","sources":["../../src/server/ws-connection.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgBH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAElG,qBAAa,mBAAmB;IAC9B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,aAAa,cAAqB;IAE3C,wEAAwE;IACxE,KAAK,UAAQ;IAEb,OAAO,CAAC,MAAM,CAMZ;IAGF,OAAO,CAAC,MAAM,CAAsC;IACpD,OAAO,CAAC,cAAc,CAAoB;IAC1C,OAAO,CAAC,cAAc,CAAK;IAC3B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAA0B;IAC3C,OAAO,CAAC,OAAO,CAA2B;gBAGxC,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,mBAAmB,CAAC,QAAQ,CAAC,EACrC,SAAS,EAAE,uBAAuB,EAClC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI;IAiCnC,yCAAyC;IACzC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAU3B;;;;;OAKG;IACH,SAAS,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAMpC,OAAO,CAAC,mBAAmB;IAa3B,uCAAuC;IACvC,IAAI,IAAI,IAAI;IASZ,uCAAuC;IACvC,KAAK,CAAC,IAAI,SAAO,EAAE,MAAM,SAAK,GAAG,IAAI;IAarC,+DAA+D;IAC/D,OAAO,IAAI,IAAI;IAWf,4CAA4C;IAC5C,IAAI,MAAM,IAAI,OAAO,CAEpB;IAID,OAAO,CAAC,QAAQ;IAchB,OAAO,CAAC,UAAU;IAgBlB,OAAO,CAAC,WAAW;CAwEpB"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Bridges NativeUIBridgeRegistry events to WebSocket clients.
3
+ *
4
+ * Subscribes to all registry event types and broadcasts them as
5
+ * JsonRpcEvent messages to connected WebSocket clients based on
6
+ * their per-connection subscription sets.
7
+ */
8
+ import type { NativeUIBridgeRegistry } from '../core/registry';
9
+ import type { WebSocketConnection } from './ws-connection';
10
+ import type { JsonRpcEvent } from './ws-types';
11
+ /**
12
+ * Convert a glob-style pattern (supports `*` / `**` wildcards) to a RegExp.
13
+ * All other regex metacharacters are escaped, so colons and other
14
+ * event-name characters pass through literally.
15
+ *
16
+ * globToRegex("*") → /^.*$/
17
+ * globToRegex("element:*") → /^element:.*$/
18
+ * globToRegex("*:stateChanged") → /^.*:stateChanged$/
19
+ */
20
+ export declare function globToRegex(pattern: string): RegExp;
21
+ /** Options for the WebSocketEventBridge constructor. */
22
+ export interface WebSocketEventBridgeOptions {
23
+ /** Heartbeat ping interval in ms (default 30000) */
24
+ heartbeatIntervalMs?: number;
25
+ /** Max number of events to retain in the replay history buffer (default 100, 0 disables) */
26
+ maxHistory?: number;
27
+ }
28
+ export declare class WebSocketEventBridge {
29
+ private connections;
30
+ private throttles;
31
+ private unsubscribers;
32
+ private heartbeatTimer;
33
+ private registry;
34
+ private heartbeatIntervalMs;
35
+ /**
36
+ * True ring buffer for event replay history.
37
+ *
38
+ * `historyBuf` is a fixed-capacity slot array; `historyHead` points at the
39
+ * NEXT write position; `historyCount` is the number of valid slots
40
+ * (clamped to capacity). Append is O(1) — no array shifting.
41
+ */
42
+ private historyBuf;
43
+ private historyHead;
44
+ private historyCount;
45
+ constructor(registry: NativeUIBridgeRegistry, optionsOrHeartbeatMs?: WebSocketEventBridgeOptions | number);
46
+ /** Effective ring buffer capacity. 0 means history is disabled. */
47
+ private get historyCapacity();
48
+ /**
49
+ * Start listening to registry events and broadcasting to WS clients.
50
+ * Also starts the heartbeat timer.
51
+ */
52
+ start(): void;
53
+ /** Stop listening to registry events and clear connections. */
54
+ stop(): void;
55
+ /** Register a new WebSocket connection. */
56
+ addConnection(conn: WebSocketConnection): void;
57
+ /** Remove a WebSocket connection (called on disconnect). */
58
+ removeConnection(connId: string): void;
59
+ /** Get the number of active connections. */
60
+ get connectionCount(): number;
61
+ /**
62
+ * Add event subscriptions for a connection.
63
+ *
64
+ * Event names are stored as glob patterns. Supported forms:
65
+ * - Exact: "element:registered"
66
+ * - Prefix: "element:*"
67
+ * - Suffix: "*:stateChanged"
68
+ * - All: "*"
69
+ *
70
+ * @param throttleMs — if >0, batch rapid events within this window before sending
71
+ */
72
+ handleSubscribe(connId: string, events: string[], throttleMs?: number): boolean;
73
+ /**
74
+ * Remove event subscriptions for a connection.
75
+ * If all subscriptions are cleared, also drops the throttle entry
76
+ * (and any pending flush timer) so a subsequent resubscribe starts clean.
77
+ */
78
+ handleUnsubscribe(connId: string, events: string[]): boolean;
79
+ /**
80
+ * Get the subscription set for a connection.
81
+ * Returns the original pattern strings (not compiled regexes).
82
+ */
83
+ getSubscriptions(connId: string): string[];
84
+ /**
85
+ * Check if a connection is subscribed to a specific event.
86
+ * Matches exact names first (fast path), then tests each stored
87
+ * pattern as a glob against the event type.
88
+ */
89
+ isSubscribed(connId: string, eventType: string): boolean;
90
+ /** Get the throttle window (in ms) configured for a connection, or undefined if none. */
91
+ getThrottleMs(connId: string): number | undefined;
92
+ /**
93
+ * Get recent events from the replay history buffer.
94
+ *
95
+ * @param filter.events — optional list of glob patterns to match event types against
96
+ * @param filter.since — optional timestamp (ms); only events at or after this time
97
+ */
98
+ getHistory(filter?: {
99
+ events?: string[];
100
+ since?: number;
101
+ }): JsonRpcEvent[];
102
+ /**
103
+ * Configure the max history buffer size at runtime. 0 disables history.
104
+ * Reallocates the ring buffer, preserving the most recent
105
+ * min(historyCount, newCapacity) events in chronological order.
106
+ */
107
+ setMaxHistory(maxHistory: number): void;
108
+ private broadcastEvent;
109
+ /** Queue an event for throttled delivery, flushing after the throttle window. */
110
+ private enqueueThrottled;
111
+ private startHeartbeat;
112
+ }
113
+ //# sourceMappingURL=ws-event-bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ws-event-bridge.d.ts","sourceRoot":"","sources":["../../src/server/ws-event-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAgC/C;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAanD;AAED,wDAAwD;AACxD,MAAM,WAAW,2BAA2B;IAC1C,o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,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIjD;;;;;OAKG;IACH,UAAU,CAAC,MAAM,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,YAAY,EAAE;IAoB1E;;;;OAIG;IACH,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IA6BvC,OAAO,CAAC,cAAc;IAyBtB,iFAAiF;IACjF,OAAO,CAAC,gBAAgB;IAoBxB,OAAO,CAAC,cAAc;CAsBvB"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Pure-JS RFC 6455 WebSocket protocol implementation.
3
+ *
4
+ * Provides frame encoding/decoding and handshake utilities for running
5
+ * a WebSocket server on react-native-tcp-socket without native crypto deps.
6
+ */
7
+ export declare const OPCODE_CONTINUATION = 0;
8
+ export declare const OPCODE_TEXT = 1;
9
+ export declare const OPCODE_BINARY = 2;
10
+ export declare const OPCODE_CLOSE = 8;
11
+ export declare const OPCODE_PING = 9;
12
+ export declare const OPCODE_PONG = 10;
13
+ export interface DecodedFrame {
14
+ opcode: number;
15
+ fin: boolean;
16
+ payload: Uint8Array;
17
+ masked: boolean;
18
+ }
19
+ export interface DecodeResult {
20
+ frames: DecodedFrame[];
21
+ remainder: Uint8Array<any>;
22
+ }
23
+ /**
24
+ * Compute the Sec-WebSocket-Accept value from the client's Sec-WebSocket-Key.
25
+ */
26
+ export declare function computeAcceptKey(clientKey: string): string;
27
+ /**
28
+ * Build the HTTP 101 Switching Protocols response for a WebSocket upgrade.
29
+ */
30
+ export declare function buildUpgradeResponse(clientKey: string): string;
31
+ /** Encode a text message as a WebSocket frame. */
32
+ export declare function encodeTextFrame(text: string): Uint8Array;
33
+ /** Encode a PING frame with optional payload. */
34
+ export declare function encodePingFrame(payload?: Uint8Array): Uint8Array;
35
+ /** Encode a PONG frame with the payload from the PING. */
36
+ export declare function encodePongFrame(payload: Uint8Array): Uint8Array;
37
+ /** Encode a CLOSE frame with optional status code and reason. */
38
+ export declare function encodeCloseFrame(code?: number, reason?: string): Uint8Array;
39
+ /**
40
+ * Decode one or more WebSocket frames from a byte buffer.
41
+ * Returns decoded frames and any unconsumed bytes (for partial frames).
42
+ */
43
+ export declare function decodeFrames(buffer: Uint8Array): DecodeResult;
44
+ /**
45
+ * Decode a text payload from a Uint8Array.
46
+ */
47
+ export declare function decodeTextPayload(payload: Uint8Array): string;
48
+ //# sourceMappingURL=ws-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ws-protocol.d.ts","sourceRoot":"","sources":["../../src/server/ws-protocol.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,eAAO,MAAM,mBAAmB,IAAO,CAAC;AACxC,eAAO,MAAM,WAAW,IAAO,CAAC;AAChC,eAAO,MAAM,aAAa,IAAO,CAAC;AAClC,eAAO,MAAM,YAAY,IAAO,CAAC;AACjC,eAAO,MAAM,WAAW,IAAO,CAAC;AAChC,eAAO,MAAM,WAAW,KAAO,CAAC;AAIhC,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,EAAE,UAAU,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,YAAY,EAAE,CAAC;IAEvB,SAAS,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;CAC5B;AA8GD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAK1D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAS9D;AAqCD,kDAAkD;AAClD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAGxD;AAED,iDAAiD;AACjD,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,UAAU,CAEhE;AAED,0DAA0D;AAC1D,wBAAgB,eAAe,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU,CAE/D;AAED,iEAAiE;AACjE,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAU3E;AAID;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,YAAY,CA0D7D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAE7D"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * WebSocket JSON-RPC message types for the UI Bridge protocol.
3
+ */
4
+ /** Standard JSON-RPC request */
5
+ export interface JsonRpcRequest {
6
+ id: number | string;
7
+ method: string;
8
+ params?: Record<string, unknown>;
9
+ }
10
+ /** Batch request — execute multiple requests concurrently */
11
+ export interface JsonRpcBatchRequest {
12
+ id: number | string;
13
+ batch: JsonRpcRequest[];
14
+ }
15
+ /** Subscribe to registry events */
16
+ export interface JsonRpcSubscribe {
17
+ id: number | string;
18
+ method: 'subscribe';
19
+ params: {
20
+ events: string[];
21
+ /** Optional throttle in ms — batch rapid events within this window */
22
+ throttleMs?: number;
23
+ };
24
+ }
25
+ /** Unsubscribe from registry events */
26
+ export interface JsonRpcUnsubscribe {
27
+ id: number | string;
28
+ method: 'unsubscribe';
29
+ params: {
30
+ events: string[];
31
+ };
32
+ }
33
+ /** Any client message */
34
+ export type JsonRpcClientMessage = JsonRpcRequest | JsonRpcBatchRequest | JsonRpcSubscribe | JsonRpcUnsubscribe;
35
+ /** Standard JSON-RPC response */
36
+ export interface JsonRpcResponse {
37
+ id: number | string;
38
+ result?: {
39
+ success: boolean;
40
+ data?: unknown;
41
+ error?: string;
42
+ code?: string;
43
+ timestamp?: number;
44
+ };
45
+ }
46
+ /** Batch response */
47
+ export interface JsonRpcBatchResponse {
48
+ id: number | string;
49
+ results: JsonRpcResponse[];
50
+ }
51
+ /** Server-pushed event (no id — not a response to a request) */
52
+ export interface JsonRpcEvent {
53
+ event: string;
54
+ data: unknown;
55
+ timestamp: number;
56
+ }
57
+ /** Any server message */
58
+ export type JsonRpcServerMessage = JsonRpcResponse | JsonRpcBatchResponse | JsonRpcEvent;
59
+ /** Check if a message is a batch request */
60
+ export declare function isBatchRequest(msg: unknown): msg is JsonRpcBatchRequest;
61
+ /** Check if a message is a subscribe request */
62
+ export declare function isSubscribe(msg: unknown): msg is JsonRpcSubscribe;
63
+ /** Check if a message is an unsubscribe request */
64
+ export declare function isUnsubscribe(msg: unknown): msg is JsonRpcUnsubscribe;
65
+ //# sourceMappingURL=ws-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ws-types.d.ts","sourceRoot":"","sources":["../../src/server/ws-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,gCAAgC;AAChC,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,6DAA6D;AAC7D,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,EAAE,cAAc,EAAE,CAAC;CACzB;AAED,mCAAmC;AACnC,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,EAAE,CAAC;QACjB,sEAAsE;QACtE,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,uCAAuC;AACvC,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;CAC9B;AAED,yBAAyB;AACzB,MAAM,MAAM,oBAAoB,GAC5B,cAAc,GACd,mBAAmB,GACnB,gBAAgB,GAChB,kBAAkB,CAAC;AAIvB,iCAAiC;AACjC,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE;QACP,OAAO,EAAE,OAAO,CAAC;QACjB,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,qBAAqB;AACrB,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B;AAED,gEAAgE;AAChE,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,yBAAyB;AACzB,MAAM,MAAM,oBAAoB,GAAG,eAAe,GAAG,oBAAoB,GAAG,YAAY,CAAC;AAIzF,4CAA4C;AAC5C,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,mBAAmB,CAOvE;AAED,gDAAgD;AAChD,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,gBAAgB,CAIjE;AAED,mDAAmD;AACnD,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,kBAAkB,CAIrE"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Cloud Relay Client — WebSocket tunnel from mobile device to backend
3
+ *
4
+ * Maintains a persistent WebSocket connection to the qontinui.io backend.
5
+ * Receives tunneled HTTP requests from runners, calls the local NativeUIBridgeServer,
6
+ * and sends responses back through the tunnel.
7
+ */
8
+ import type { NativeUIBridgeServer } from '../server/http-server';
9
+ export interface CloudRelayConfig {
10
+ /** WebSocket URL for the device bridge endpoint */
11
+ relayUrl: string;
12
+ /** Stable device identifier */
13
+ deviceId: string;
14
+ /** Authentication token */
15
+ authToken: string;
16
+ /** Reference to the local UI Bridge server for processing requests */
17
+ uiBridgeServer: NativeUIBridgeServer;
18
+ }
19
+ /**
20
+ * Manages a WebSocket tunnel from the mobile device to the qontinui.io backend.
21
+ *
22
+ * When a runner sends an HTTP request to a cloud device it is serialised as a
23
+ * `TunnelRequest` JSON frame by the backend and forwarded here. This client
24
+ * deserializes it, calls `NativeUIBridgeServer.handleRequest()` directly
25
+ * (avoiding loopback TCP overhead), and sends the `TunnelResponse` back.
26
+ */
27
+ export declare class CloudRelayClient {
28
+ private ws;
29
+ private config;
30
+ private reconnectDelay;
31
+ private maxReconnectDelay;
32
+ private stopped;
33
+ private _isConnected;
34
+ private reconnectTimer;
35
+ constructor(config: CloudRelayConfig);
36
+ /** Whether the relay WebSocket is currently connected */
37
+ get isConnected(): boolean;
38
+ /** Connect to the relay and start processing tunneled requests. */
39
+ start(): void;
40
+ /** Disconnect and stop reconnecting. */
41
+ stop(): void;
42
+ private connect;
43
+ private onMessage;
44
+ /**
45
+ * Process a tunneled HTTP request by calling the local NativeUIBridgeServer
46
+ * directly (no loopback TCP involved).
47
+ */
48
+ private handleTunneledRequest;
49
+ private scheduleReconnect;
50
+ }
51
+ //# sourceMappingURL=CloudRelayClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CloudRelayClient.d.ts","sourceRoot":"","sources":["../../src/transport/CloudRelayClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAElE,MAAM,WAAW,gBAAgB;IAC/B,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,sEAAsE;IACtE,cAAc,EAAE,oBAAoB,CAAC;CACtC;AAoBD;;;;;;;GAOG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,EAAE,CAA0B;IACpC,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,cAAc,CAA8B;IACpD,OAAO,CAAC,iBAAiB,CAA0B;IACnD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,cAAc,CAA8C;gBAExD,MAAM,EAAE,gBAAgB;IAIpC,yDAAyD;IACzD,IAAI,WAAW,IAAI,OAAO,CAEzB;IAID,mEAAmE;IACnE,KAAK,IAAI,IAAI;IAKb,wCAAwC;IACxC,IAAI,IAAI,IAAI;IAkBZ,OAAO,CAAC,OAAO;YA8CD,SAAS;IAsCvB;;;OAGG;YACW,qBAAqB;IAuCnC,OAAO,CAAC,iBAAiB;CAY1B"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Device Announcer — mDNS + Cloud registration for physical device discovery
3
+ *
4
+ * Announces the UI Bridge service on the local network via mDNS (when
5
+ * react-native-zeroconf is available) and optionally registers with the
6
+ * cloud relay backend.
7
+ */
8
+ export interface AnnouncerConfig {
9
+ /** Stable device identifier */
10
+ deviceId: string;
11
+ /** App bundle/package ID */
12
+ appId: string;
13
+ /** UI Bridge server port (default 8087) */
14
+ port?: number;
15
+ /** Cloud relay WebSocket URL for registration */
16
+ cloudRelayUrl?: string;
17
+ /** Auth token for cloud relay */
18
+ cloudToken?: string;
19
+ /** UI Bridge SDK version */
20
+ version?: string;
21
+ }
22
+ export interface DeviceAnnouncerState {
23
+ mdnsActive: boolean;
24
+ cloudConnected: boolean;
25
+ }
26
+ /** Minimal interface for the react-native-zeroconf Zeroconf instance */
27
+ interface ZeroconfService {
28
+ publishService(type: string, protocol: string, domain: string, name: string, port: number, txtRecord: Record<string, string>): void;
29
+ unpublishService(name: string): void;
30
+ }
31
+ /**
32
+ * Announces the UI Bridge server on the local network (mDNS) and optionally
33
+ * registers with the qontinui.io cloud relay for remote discovery.
34
+ */
35
+ export declare class DeviceAnnouncer {
36
+ private config;
37
+ private state;
38
+ private cloudWs;
39
+ private reconnectTimer;
40
+ private reconnectDelay;
41
+ private stopped;
42
+ /** Zeroconf instance, set when mDNS is successfully started */
43
+ private zeroconf;
44
+ /** Rotated pairing token for mDNS TXT records */
45
+ private pairingToken;
46
+ constructor(config: AnnouncerConfig);
47
+ /**
48
+ * Start mDNS advertisement.
49
+ *
50
+ * The consumer must pass the `Zeroconf` constructor (from `react-native-zeroconf`)
51
+ * explicitly; otherwise this is a no-op.
52
+ *
53
+ * Rationale: Metro's `require()` throws an uncatchable module-load error if the
54
+ * bundle doesn't include the named package. That error escapes async try/catch
55
+ * boundaries and crashes the app. We avoid it by never calling `require()`
56
+ * ourselves — the consumer imports the package when they know it's installed.
57
+ *
58
+ * @param ZeroconfCtor - constructor from `import Zeroconf from 'react-native-zeroconf'`
59
+ */
60
+ startMdnsAdvertise(ZeroconfCtor?: new () => ZeroconfService): Promise<void>;
61
+ /**
62
+ * Connect to the cloud relay WebSocket and send a device_register message.
63
+ *
64
+ * Reconnects automatically with exponential backoff (2 s → 60 s) if the
65
+ * connection drops.
66
+ */
67
+ connectCloudRelay(): Promise<void>;
68
+ /** Stop all advertising and registration. */
69
+ stop(): Promise<void>;
70
+ /** Return a copy of the current announcer state. */
71
+ getState(): DeviceAnnouncerState;
72
+ private scheduleReconnect;
73
+ }
74
+ export {};
75
+ //# sourceMappingURL=DeviceAnnouncer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeviceAnnouncer.d.ts","sourceRoot":"","sources":["../../src/transport/DeviceAnnouncer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,WAAW,eAAe;IAC9B,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,4BAA4B;IAC5B,KAA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,OAAO,CAAC,iBAAiB;CAa1B"}
@@ -0,0 +1,3 @@
1
+ export { DeviceAnnouncer, type AnnouncerConfig, type DeviceAnnouncerState, } from './DeviceAnnouncer';
2
+ export { CloudRelayClient, type CloudRelayConfig } from './CloudRelayClient';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transport/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,oBAAoB,GAC1B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qontinui/ui-bridge-native",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "UI Bridge Framework for React Native - Hooks and providers for UI observation and control in mobile apps",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",