@qontinui/ui-bridge-native 0.3.1 → 0.4.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/dist/control/{index.d.mts → action-executor.d.ts} +6 -10
- package/dist/control/action-executor.d.ts.map +1 -0
- package/dist/control/index.d.ts +5 -95
- package/dist/control/index.d.ts.map +1 -0
- package/dist/{types-CjEKTDYT.d.ts → control/types.d.ts} +17 -20
- package/dist/control/types.d.ts.map +1 -0
- package/dist/core/element-identifier.d.ts +41 -0
- package/dist/core/element-identifier.d.ts.map +1 -0
- package/dist/core/index.d.ts +6 -43
- package/dist/core/index.d.ts.map +1 -0
- package/dist/{registry-pAUpQq2O.d.ts → core/registry.d.ts} +10 -13
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/{types-CGVut7mc.d.mts → core/types.d.ts} +41 -41
- package/dist/core/types.d.ts.map +1 -0
- package/dist/debug/index.d.ts +4 -44
- package/dist/debug/index.d.ts.map +1 -0
- package/dist/debug/index.js +1 -1
- package/dist/debug/index.js.map +1 -1
- package/dist/debug/index.mjs +2 -2
- package/dist/debug/index.mjs.map +1 -1
- package/dist/debug/{index.d.mts → inspector.d.ts} +3 -6
- package/dist/debug/inspector.d.ts.map +1 -0
- package/dist/design/{index.d.mts → design-inspector-native.d.ts} +7 -11
- package/dist/design/design-inspector-native.d.ts.map +1 -0
- package/dist/{design-types-BHr6Q1FX.d.mts → design/design-types.d.ts} +10 -11
- package/dist/design/design-types.d.ts.map +1 -0
- package/dist/design/index.d.ts +5 -60
- package/dist/design/index.d.ts.map +1 -0
- package/dist/index.d.ts +37 -86
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/dist/modal/index.d.ts +2 -0
- package/dist/modal/index.d.ts.map +1 -0
- package/dist/modal/modal-detector.d.ts +29 -0
- package/dist/modal/modal-detector.d.ts.map +1 -0
- package/dist/react/StateAnnotation.d.ts +30 -0
- package/dist/react/StateAnnotation.d.ts.map +1 -0
- package/dist/react/UIBridgeNativeProvider.d.ts +156 -0
- package/dist/react/UIBridgeNativeProvider.d.ts.map +1 -0
- package/dist/react/index.d.ts +14 -69
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +3 -3
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +4 -4
- package/dist/react/index.mjs.map +1 -1
- package/dist/react/{index.d.mts → useAutoRegister.d.ts} +7 -15
- package/dist/react/useAutoRegister.d.ts.map +1 -0
- package/dist/react/useUIBridge.d.ts +103 -0
- package/dist/react/useUIBridge.d.ts.map +1 -0
- package/dist/react/useUIBridgeModal.d.ts +14 -0
- package/dist/react/useUIBridgeModal.d.ts.map +1 -0
- package/dist/react/useUIBridgeToast.d.ts +25 -0
- package/dist/react/useUIBridgeToast.d.ts.map +1 -0
- package/dist/react/useUIComponent.d.ts +112 -0
- package/dist/react/useUIComponent.d.ts.map +1 -0
- package/dist/react/useUIElement.d.ts +162 -0
- package/dist/react/useUIElement.d.ts.map +1 -0
- package/dist/server/design-handlers.d.ts +47 -0
- package/dist/server/design-handlers.d.ts.map +1 -0
- package/dist/server/handlers.d.ts +25 -0
- package/dist/server/handlers.d.ts.map +1 -0
- package/dist/server/http-server.d.ts +262 -0
- package/dist/server/http-server.d.ts.map +1 -0
- package/dist/server/index.d.ts +14 -176
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/observability.d.ts +55 -0
- package/dist/server/observability.d.ts.map +1 -0
- package/dist/server/types.d.ts +368 -0
- package/dist/server/types.d.ts.map +1 -0
- package/dist/server/ws-connection.d.ts +48 -0
- package/dist/server/ws-connection.d.ts.map +1 -0
- package/dist/server/ws-event-bridge.d.ts +113 -0
- package/dist/server/ws-event-bridge.d.ts.map +1 -0
- package/dist/server/ws-protocol.d.ts +48 -0
- package/dist/server/ws-protocol.d.ts.map +1 -0
- package/dist/server/ws-types.d.ts +65 -0
- package/dist/server/ws-types.d.ts.map +1 -0
- package/dist/toast/index.d.ts +2 -0
- package/dist/toast/index.d.ts.map +1 -0
- package/dist/toast/toast-capture.d.ts +27 -0
- package/dist/toast/toast-capture.d.ts.map +1 -0
- package/dist/transport/CloudRelayClient.d.ts +51 -0
- package/dist/transport/CloudRelayClient.d.ts.map +1 -0
- package/dist/transport/DeviceAnnouncer.d.ts +75 -0
- package/dist/transport/DeviceAnnouncer.d.ts.map +1 -0
- package/dist/transport/index.d.ts +3 -0
- package/dist/transport/index.d.ts.map +1 -0
- package/dist/transport/logger.d.ts +23 -0
- package/dist/transport/logger.d.ts.map +1 -0
- package/dist/undo/index.d.ts +3 -0
- package/dist/undo/index.d.ts.map +1 -0
- package/dist/undo/undo-tracker.d.ts +59 -0
- package/dist/undo/undo-tracker.d.ts.map +1 -0
- package/package.json +3 -3
- package/dist/StateAnnotation--zm0Jfqj.d.ts +0 -755
- package/dist/StateAnnotation-BgFoVWFy.d.mts +0 -755
- package/dist/core/index.d.mts +0 -46
- package/dist/design-types-BHr6Q1FX.d.ts +0 -205
- package/dist/http-server--550eD1F.d.mts +0 -805
- package/dist/http-server-C9NaNBEP.d.ts +0 -805
- package/dist/index.d.mts +0 -89
- package/dist/registry-B5JadBN9.d.mts +0 -300
- package/dist/server/index.d.mts +0 -178
- package/dist/types-B0XA4vOF.d.mts +0 -197
- package/dist/types-CGVut7mc.d.ts +0 -567
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI Bridge Native HTTP Server
|
|
3
|
+
*
|
|
4
|
+
* Abstract HTTP server implementation for React Native.
|
|
5
|
+
* This provides a framework-agnostic server interface that can be
|
|
6
|
+
* implemented using various React Native HTTP server libraries.
|
|
7
|
+
*
|
|
8
|
+
* Supported libraries:
|
|
9
|
+
* - react-native-http-bridge (recommended)
|
|
10
|
+
* - @aspect/react-native-http-server
|
|
11
|
+
* - Custom implementations
|
|
12
|
+
*/
|
|
13
|
+
import type { NativeUIBridgeRegistry } from '../core/registry';
|
|
14
|
+
import type { NativeActionExecutor } from '../control/types';
|
|
15
|
+
import type { NativeServerConfig, NavigationProvider, RouteProvider, ScreenshotProvider } from './types';
|
|
16
|
+
import type { WebSocketEventBridge } from './ws-event-bridge';
|
|
17
|
+
import type { JsonRpcRequest, JsonRpcResponse } from './ws-types';
|
|
18
|
+
/**
|
|
19
|
+
* HTTP Request interface (library-agnostic)
|
|
20
|
+
*/
|
|
21
|
+
export interface HTTPRequest {
|
|
22
|
+
method: string;
|
|
23
|
+
path: string;
|
|
24
|
+
headers: Record<string, string>;
|
|
25
|
+
query: Record<string, string>;
|
|
26
|
+
body?: unknown;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* HTTP Response interface (library-agnostic)
|
|
30
|
+
*/
|
|
31
|
+
export interface HTTPResponse {
|
|
32
|
+
status: number;
|
|
33
|
+
headers: Record<string, string>;
|
|
34
|
+
body: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Request handler type
|
|
38
|
+
*/
|
|
39
|
+
export type RequestHandler = (request: HTTPRequest) => Promise<HTTPResponse>;
|
|
40
|
+
/**
|
|
41
|
+
* Server adapter interface
|
|
42
|
+
*
|
|
43
|
+
* Implement this interface to integrate with your chosen HTTP server library.
|
|
44
|
+
*/
|
|
45
|
+
export interface ServerAdapter {
|
|
46
|
+
/** Start the server */
|
|
47
|
+
start(port: number, handler: RequestHandler): Promise<void>;
|
|
48
|
+
/** Stop the server */
|
|
49
|
+
stop(): Promise<void>;
|
|
50
|
+
/** Check if server is running */
|
|
51
|
+
isRunning(): boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* WebSocket-aware server adapter interface.
|
|
55
|
+
*
|
|
56
|
+
* Extends ServerAdapter with callbacks for WebSocket connections.
|
|
57
|
+
* The adapter manages the raw TCP/WS layer; these callbacks let the
|
|
58
|
+
* UI Bridge server handle message routing and event broadcasting.
|
|
59
|
+
*/
|
|
60
|
+
export interface WebSocketServerAdapter extends ServerAdapter {
|
|
61
|
+
/** Called when a JSON text frame is received from a WS client. Returns response string or null. */
|
|
62
|
+
onWebSocketMessage?: (connId: string, message: string) => Promise<string | null>;
|
|
63
|
+
/** Called when a new WS connection is established after the HTTP 101 upgrade. */
|
|
64
|
+
onWebSocketConnect?: (connId: string) => void;
|
|
65
|
+
/** Called when a WS connection is closed or drops. */
|
|
66
|
+
onWebSocketDisconnect?: (connId: string) => void;
|
|
67
|
+
/** Send a message to a specific WS connection by ID. */
|
|
68
|
+
sendToConnection?: (connId: string, message: string) => void;
|
|
69
|
+
/** Send a message to all connected WS clients. */
|
|
70
|
+
broadcast?: (message: string) => void;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Native UI Bridge HTTP Server
|
|
74
|
+
*/
|
|
75
|
+
export declare class NativeUIBridgeServer {
|
|
76
|
+
private registry;
|
|
77
|
+
private executor;
|
|
78
|
+
private config;
|
|
79
|
+
private handlers;
|
|
80
|
+
private adapter?;
|
|
81
|
+
private running;
|
|
82
|
+
/**
|
|
83
|
+
* Per-connection cleanup thunks for in-flight waiters (waitForElement,
|
|
84
|
+
* waitForCondition, ...). Aborted when a client disconnects so the
|
|
85
|
+
* underlying timers/listeners don't leak.
|
|
86
|
+
*/
|
|
87
|
+
private pendingWaiters;
|
|
88
|
+
/**
|
|
89
|
+
* Observability ring buffers backing `/control/console-errors` and
|
|
90
|
+
* `/sdk/network-requests`. Allocated unconditionally so the handler can
|
|
91
|
+
* always read them, but the global patches (`install()`) only fire on
|
|
92
|
+
* `start()` when `testHooks` is set — production builds don't monkey-patch.
|
|
93
|
+
*/
|
|
94
|
+
private consoleErrorBuffer;
|
|
95
|
+
private networkRequestBuffer;
|
|
96
|
+
constructor(registry: NativeUIBridgeRegistry, executor: NativeActionExecutor, config?: NativeServerConfig);
|
|
97
|
+
/**
|
|
98
|
+
* Set the server adapter
|
|
99
|
+
*/
|
|
100
|
+
setAdapter(adapter: ServerAdapter): void;
|
|
101
|
+
/**
|
|
102
|
+
* Set a navigation provider for programmatic route navigation.
|
|
103
|
+
* This enables `control/page/navigate` and `control/page/back` on native.
|
|
104
|
+
*/
|
|
105
|
+
setNavigationProvider(provider: NavigationProvider): void;
|
|
106
|
+
/**
|
|
107
|
+
* Set a route provider for reporting the current navigation route.
|
|
108
|
+
* When set, `control/snapshot` responses include `currentRoute` and `segments`.
|
|
109
|
+
*
|
|
110
|
+
* Also forwards the provider into the registry so the *default*
|
|
111
|
+
* `getSnapshot` handler (and any other call site of
|
|
112
|
+
* `registry.createSnapshot`) reads the route too — without this the
|
|
113
|
+
* cloud-relay/bare-server path returned `currentRoute: null` even when
|
|
114
|
+
* a `RouteTracker` was wired, because that path never installed the
|
|
115
|
+
* server-level handler override below.
|
|
116
|
+
*/
|
|
117
|
+
setRouteProvider(provider: RouteProvider): void;
|
|
118
|
+
/**
|
|
119
|
+
* Set a screenshot provider for native screen capture.
|
|
120
|
+
* This enables `control/screenshot` on native.
|
|
121
|
+
*/
|
|
122
|
+
setScreenshotProvider(provider: ScreenshotProvider): void;
|
|
123
|
+
/**
|
|
124
|
+
* Start the HTTP server
|
|
125
|
+
*/
|
|
126
|
+
start(): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Stop the HTTP server
|
|
129
|
+
*/
|
|
130
|
+
stop(): Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* Check if server is running
|
|
133
|
+
*/
|
|
134
|
+
isRunning(): boolean;
|
|
135
|
+
private eventBridge?;
|
|
136
|
+
/**
|
|
137
|
+
* Set the event bridge for WebSocket event broadcasting and subscriptions.
|
|
138
|
+
*/
|
|
139
|
+
setEventBridge(bridge: WebSocketEventBridge): void;
|
|
140
|
+
/**
|
|
141
|
+
* Handle a JSON-RPC message from a WebSocket client.
|
|
142
|
+
* Parses the message, routes to the appropriate handler, and returns
|
|
143
|
+
* a JSON string response (or null for events that need no response).
|
|
144
|
+
*/
|
|
145
|
+
handleWebSocketMessage(connId: string, rawMessage: string): Promise<string | null>;
|
|
146
|
+
/**
|
|
147
|
+
* Execute a batch of JSON-RPC requests concurrently.
|
|
148
|
+
*/
|
|
149
|
+
handleBatchRequest(batch: JsonRpcRequest[]): Promise<JsonRpcResponse[]>;
|
|
150
|
+
/**
|
|
151
|
+
* Register an in-flight waiter's cleanup thunk under the given connection.
|
|
152
|
+
* Returns an `unregister` thunk that the natural-resolution path should
|
|
153
|
+
* call so the cleanup isn't re-invoked on disconnect.
|
|
154
|
+
*/
|
|
155
|
+
private registerWaiter;
|
|
156
|
+
/**
|
|
157
|
+
* Abort all pending waiters associated with a connection. Called by the
|
|
158
|
+
* provider's WS disconnect handler so timers/listeners don't leak after
|
|
159
|
+
* the client goes away.
|
|
160
|
+
*/
|
|
161
|
+
abortWaitersForConnection(connId: string): void;
|
|
162
|
+
/**
|
|
163
|
+
* Wait for an element to be registered, or resolve immediately if it already exists.
|
|
164
|
+
* Returns a JsonRpcResponse JSON string.
|
|
165
|
+
*/
|
|
166
|
+
private handleWaitForElement;
|
|
167
|
+
/**
|
|
168
|
+
* Wait for an arbitrary element-state predicate to become true.
|
|
169
|
+
*
|
|
170
|
+
* Supported `condition` shapes:
|
|
171
|
+
* {field: "mounted"|"visible"|"enabled"|"focused", equals: boolean}
|
|
172
|
+
* {field: "layout", exists: true}
|
|
173
|
+
* {field: string, equals: unknown} // generic: state[field] === equals
|
|
174
|
+
*
|
|
175
|
+
* Resolves immediately with `waited:false` if the predicate already
|
|
176
|
+
* holds. Otherwise subscribes to `element:registered` and
|
|
177
|
+
* `element:stateChanged` until the predicate matches or timeout fires.
|
|
178
|
+
*/
|
|
179
|
+
private handleWaitForCondition;
|
|
180
|
+
/**
|
|
181
|
+
* Execute a sequence of JSON-RPC steps in order, stopping on first failure.
|
|
182
|
+
* Returns a JsonRpcResponse JSON string with per-step results.
|
|
183
|
+
*/
|
|
184
|
+
private handleSequence;
|
|
185
|
+
/**
|
|
186
|
+
* Route a JSON-RPC method string to the appropriate handler using path-style matching.
|
|
187
|
+
*
|
|
188
|
+
* Method strings mirror HTTP routes but without the /ui-bridge/ prefix.
|
|
189
|
+
* Path params are extracted from :name placeholders in the route pattern.
|
|
190
|
+
*
|
|
191
|
+
* Examples:
|
|
192
|
+
* "health" → handlers.health
|
|
193
|
+
* "control/snapshot" → handlers.getSnapshot
|
|
194
|
+
* "control/element/tab-runs/action" → handlers.executeAction ({id:'tab-runs'})
|
|
195
|
+
* "control/component/my-comp/action/submit" → handlers.executeComponentAction
|
|
196
|
+
*/
|
|
197
|
+
private routeMethodToHandler;
|
|
198
|
+
/**
|
|
199
|
+
* Handle incoming HTTP request
|
|
200
|
+
*
|
|
201
|
+
* Exposed as public so that CloudRelayClient can call it directly (without
|
|
202
|
+
* loopback TCP overhead) when processing tunneled requests.
|
|
203
|
+
*/
|
|
204
|
+
handleRequest(request: HTTPRequest): Promise<HTTPResponse>;
|
|
205
|
+
/**
|
|
206
|
+
* Route an HTTP request to the appropriate handler using WS_ROUTES.
|
|
207
|
+
*
|
|
208
|
+
* Strips the `/ui-bridge/` prefix from the path, then iterates the shared
|
|
209
|
+
* WS_ROUTES table. Each route's `pattern` is matched against the stripped
|
|
210
|
+
* path via the module-level `parsePath` helper; path params are merged
|
|
211
|
+
* with the request body into a HandlerContext.
|
|
212
|
+
*
|
|
213
|
+
* `httpMethods` disambiguates routes that share a pattern but differ
|
|
214
|
+
* by verb (e.g. GET vs DELETE on `design/style-guide`). A route without
|
|
215
|
+
* `httpMethods` is WS-only and will not be matched on HTTP.
|
|
216
|
+
*/
|
|
217
|
+
private routeRequest;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Create a UI Bridge Native server
|
|
221
|
+
*/
|
|
222
|
+
export declare function createNativeServer(registry: NativeUIBridgeRegistry, executor: NativeActionExecutor, config?: NativeServerConfig): NativeUIBridgeServer;
|
|
223
|
+
/**
|
|
224
|
+
* Example adapter using react-native-http-bridge
|
|
225
|
+
*
|
|
226
|
+
* To use this adapter:
|
|
227
|
+
* 1. Install: npm install react-native-http-bridge
|
|
228
|
+
* 2. Link native modules
|
|
229
|
+
* 3. Create adapter and pass to server
|
|
230
|
+
*
|
|
231
|
+
* ```tsx
|
|
232
|
+
* import httpBridge from 'react-native-http-bridge';
|
|
233
|
+
*
|
|
234
|
+
* const adapter: ServerAdapter = {
|
|
235
|
+
* start: async (port, handler) => {
|
|
236
|
+
* httpBridge.start(port, 'ui-bridge', async (request) => {
|
|
237
|
+
* const response = await handler({
|
|
238
|
+
* method: request.type,
|
|
239
|
+
* path: request.url,
|
|
240
|
+
* headers: request.headers || {},
|
|
241
|
+
* query: parseQuery(request.url),
|
|
242
|
+
* body: request.postData ? JSON.parse(request.postData) : undefined,
|
|
243
|
+
* });
|
|
244
|
+
* httpBridge.respond(
|
|
245
|
+
* request.requestId,
|
|
246
|
+
* response.status,
|
|
247
|
+
* response.headers['Content-Type'],
|
|
248
|
+
* response.body
|
|
249
|
+
* );
|
|
250
|
+
* });
|
|
251
|
+
* },
|
|
252
|
+
* stop: async () => {
|
|
253
|
+
* httpBridge.stop();
|
|
254
|
+
* },
|
|
255
|
+
* isRunning: () => true,
|
|
256
|
+
* };
|
|
257
|
+
*
|
|
258
|
+
* server.setAdapter(adapter);
|
|
259
|
+
* await server.start();
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
//# sourceMappingURL=http-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-server.d.ts","sourceRoot":"","sources":["../../src/server/http-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAA0B,MAAM,kBAAkB,CAAC;AACrF,OAAO,KAAK,EACV,kBAAkB,EAElB,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAGnB,MAAM,SAAS,CAAC;AAIjB,OAAO,KAAK,EAAE,oBAAoB,EAA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AAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IA4IxF;;OAEG;IACG,kBAAkB,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAwB7E;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAetB;;;;OAIG;IACH,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAa/C;;;OAGG;YACW,oBAAoB;IAwHlC;;;;;;;;;;;OAWG;YACW,sBAAsB;IAmJpC;;;OAGG;YACW,cAAc;IA6E5B;;;;;;;;;;;OAWG;YACW,oBAAoB;IAgClC;;;;;OAKG;IACG,aAAa,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAyChE;;;;;;;;;;;OAWG;YACW,YAAY;CAuE3B;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,sBAAsB,EAChC,QAAQ,EAAE,oBAAoB,EAC9B,MAAM,CAAC,EAAE,kBAAkB,GAC1B,oBAAoB,CAEtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG"}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,178 +1,16 @@
|
|
|
1
|
-
import { C as ConsoleErrorEntry, u as NetworkRequestEntry, k as NativeServerHandlers, e as HandlerContext, A as APIResponse } from '../http-server-C9NaNBEP.js';
|
|
2
|
-
export { v as ConsoleErrorsResponse, D as DismissModalResponse, F as FillFormFieldInput, a as FillFormFieldResult, b as FillFormRequest, c as FillFormResponse, H as HTTPRequest, d as HTTPResponse, f as HandlerFunction, J as JsonRpcBatchRequest, g as JsonRpcBatchResponse, w as JsonRpcClientMessage, h as JsonRpcEvent, i as JsonRpcRequest, j as JsonRpcResponse, x as JsonRpcServerMessage, y as JsonRpcSubscribe, z as JsonRpcUnsubscribe, N as NativeServerConfig, l as NativeUIBridgeServer, m as NavigationProvider, B as NetworkRequestsResponse, P as PushModalRequest, E as PushModalResponse, R as RequestHandler, n as RouteDefinition, o as RouteProvider, S as ScreenshotProvider, p as ServerAdapter, T as TapAtRequest, G as TapAtResponse, U as UI_BRIDGE_NATIVE_ROUTES, W as WebSocketConnection, q as WebSocketEventBridge, r as WebSocketMessageHandler, s as WebSocketServerAdapter, t as createNativeServer, I as isBatchRequest, K as isSubscribe, L as isUnsubscribe } from '../http-server-C9NaNBEP.js';
|
|
3
|
-
import { a as NativeUIBridgeRegistry } from '../registry-pAUpQq2O.js';
|
|
4
|
-
import { N as NativeActionExecutor } from '../types-CjEKTDYT.js';
|
|
5
|
-
import { E as ElementDesignData, S as StateStyles, R as ResponsiveSnapshot } from '../design-types-BHr6Q1FX.js';
|
|
6
|
-
import '../types-CGVut7mc.js';
|
|
7
|
-
|
|
8
1
|
/**
|
|
9
|
-
* UI Bridge Native
|
|
2
|
+
* UI Bridge Native - Server
|
|
10
3
|
*
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
* - Patches only restore the *original* function captured at install time;
|
|
25
|
-
* if other code wraps `console.error` / `fetch` between install and
|
|
26
|
-
* uninstall, those wrappers will be lost. Acceptable for test hooks.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
declare class ConsoleErrorBuffer {
|
|
30
|
-
private buffer;
|
|
31
|
-
private installed;
|
|
32
|
-
private originalError?;
|
|
33
|
-
private originalWarn?;
|
|
34
|
-
constructor(capacity?: number);
|
|
35
|
-
install(): void;
|
|
36
|
-
uninstall(): void;
|
|
37
|
-
entries(opts?: {
|
|
38
|
-
since?: number;
|
|
39
|
-
limit?: number;
|
|
40
|
-
}): ConsoleErrorEntry[];
|
|
41
|
-
size(): number;
|
|
42
|
-
clear(): void;
|
|
43
|
-
isInstalled(): boolean;
|
|
44
|
-
}
|
|
45
|
-
declare class NetworkRequestBuffer {
|
|
46
|
-
private buffer;
|
|
47
|
-
private installed;
|
|
48
|
-
private originalFetch?;
|
|
49
|
-
private originalXhrOpen?;
|
|
50
|
-
private originalXhrSend?;
|
|
51
|
-
constructor(capacity?: number);
|
|
52
|
-
install(): void;
|
|
53
|
-
uninstall(): void;
|
|
54
|
-
entries(opts?: {
|
|
55
|
-
since?: number;
|
|
56
|
-
limit?: number;
|
|
57
|
-
}): NetworkRequestEntry[];
|
|
58
|
-
size(): number;
|
|
59
|
-
clear(): void;
|
|
60
|
-
isInstalled(): boolean;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* UI Bridge Native Server Handlers
|
|
65
|
-
*
|
|
66
|
-
* Request handlers for the HTTP API endpoints.
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Create server handlers
|
|
71
|
-
*/
|
|
72
|
-
declare function createServerHandlers(registry: NativeUIBridgeRegistry, executor: NativeActionExecutor, config?: {
|
|
73
|
-
appInfo?: {
|
|
74
|
-
appId: string;
|
|
75
|
-
appName: string;
|
|
76
|
-
appType: string;
|
|
77
|
-
framework?: string;
|
|
78
|
-
};
|
|
79
|
-
/** Optional console-error ring buffer powering `GET /control/console-errors`. */
|
|
80
|
-
consoleErrorBuffer?: ConsoleErrorBuffer;
|
|
81
|
-
/** Optional network-request ring buffer powering `GET /sdk/network-requests`. */
|
|
82
|
-
networkRequestBuffer?: NetworkRequestBuffer;
|
|
83
|
-
}): NativeServerHandlers;
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Pure-JS RFC 6455 WebSocket protocol implementation.
|
|
87
|
-
*
|
|
88
|
-
* Provides frame encoding/decoding and handshake utilities for running
|
|
89
|
-
* a WebSocket server on react-native-tcp-socket without native crypto deps.
|
|
90
|
-
*/
|
|
91
|
-
declare const OPCODE_CONTINUATION = 0;
|
|
92
|
-
declare const OPCODE_TEXT = 1;
|
|
93
|
-
declare const OPCODE_BINARY = 2;
|
|
94
|
-
declare const OPCODE_CLOSE = 8;
|
|
95
|
-
declare const OPCODE_PING = 9;
|
|
96
|
-
declare const OPCODE_PONG = 10;
|
|
97
|
-
interface DecodedFrame {
|
|
98
|
-
opcode: number;
|
|
99
|
-
fin: boolean;
|
|
100
|
-
payload: Uint8Array;
|
|
101
|
-
masked: boolean;
|
|
102
|
-
}
|
|
103
|
-
interface DecodeResult {
|
|
104
|
-
frames: DecodedFrame[];
|
|
105
|
-
remainder: Uint8Array<any>;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Compute the Sec-WebSocket-Accept value from the client's Sec-WebSocket-Key.
|
|
109
|
-
*/
|
|
110
|
-
declare function computeAcceptKey(clientKey: string): string;
|
|
111
|
-
/**
|
|
112
|
-
* Build the HTTP 101 Switching Protocols response for a WebSocket upgrade.
|
|
113
|
-
*/
|
|
114
|
-
declare function buildUpgradeResponse(clientKey: string): string;
|
|
115
|
-
/** Encode a text message as a WebSocket frame. */
|
|
116
|
-
declare function encodeTextFrame(text: string): Uint8Array;
|
|
117
|
-
/** Encode a PING frame with optional payload. */
|
|
118
|
-
declare function encodePingFrame(payload?: Uint8Array): Uint8Array;
|
|
119
|
-
/** Encode a PONG frame with the payload from the PING. */
|
|
120
|
-
declare function encodePongFrame(payload: Uint8Array): Uint8Array;
|
|
121
|
-
/** Encode a CLOSE frame with optional status code and reason. */
|
|
122
|
-
declare function encodeCloseFrame(code?: number, reason?: string): Uint8Array;
|
|
123
|
-
/**
|
|
124
|
-
* Decode one or more WebSocket frames from a byte buffer.
|
|
125
|
-
* Returns decoded frames and any unconsumed bytes (for partial frames).
|
|
126
|
-
*/
|
|
127
|
-
declare function decodeFrames(buffer: Uint8Array): DecodeResult;
|
|
128
|
-
/**
|
|
129
|
-
* Decode a text payload from a Uint8Array.
|
|
130
|
-
*/
|
|
131
|
-
declare function decodeTextPayload(payload: Uint8Array): string;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* UI Bridge Native Design Review Handlers
|
|
135
|
-
*
|
|
136
|
-
* HTTP handlers for the 8 design review endpoints.
|
|
137
|
-
* Maps registered element styles to the web SDK's design data format.
|
|
138
|
-
*/
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Design handler interface (subset of NativeServerHandlers)
|
|
142
|
-
*/
|
|
143
|
-
interface NativeDesignHandlers {
|
|
144
|
-
getElementStyles: (ctx: HandlerContext) => Promise<APIResponse<ElementDesignData>>;
|
|
145
|
-
getElementStateStyles: (ctx: HandlerContext) => Promise<APIResponse<{
|
|
146
|
-
elementId: string;
|
|
147
|
-
stateStyles: StateStyles[];
|
|
148
|
-
}>>;
|
|
149
|
-
getDesignSnapshot: (ctx: HandlerContext) => Promise<APIResponse<{
|
|
150
|
-
elements: ElementDesignData[];
|
|
151
|
-
timestamp: number;
|
|
152
|
-
}>>;
|
|
153
|
-
getResponsiveSnapshots: (ctx: HandlerContext) => Promise<APIResponse<ResponsiveSnapshot[]>>;
|
|
154
|
-
runDesignAudit: (ctx: HandlerContext) => Promise<APIResponse<unknown>>;
|
|
155
|
-
loadStyleGuide: (ctx: HandlerContext) => Promise<APIResponse<{
|
|
156
|
-
loaded: boolean;
|
|
157
|
-
}>>;
|
|
158
|
-
getStyleGuide: (ctx: HandlerContext) => Promise<APIResponse<unknown>>;
|
|
159
|
-
clearStyleGuide: (ctx: HandlerContext) => Promise<APIResponse<{
|
|
160
|
-
cleared: boolean;
|
|
161
|
-
}>>;
|
|
162
|
-
evaluateQuality: (ctx: HandlerContext) => Promise<APIResponse<unknown>>;
|
|
163
|
-
getQualityContexts: (ctx: HandlerContext) => Promise<APIResponse<Array<{
|
|
164
|
-
name: string;
|
|
165
|
-
description: string;
|
|
166
|
-
}>>>;
|
|
167
|
-
saveBaseline: (ctx: HandlerContext) => Promise<APIResponse<{
|
|
168
|
-
saved: boolean;
|
|
169
|
-
elementCount: number;
|
|
170
|
-
}>>;
|
|
171
|
-
diffBaseline: (ctx: HandlerContext) => Promise<APIResponse<unknown>>;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Create design review handlers.
|
|
175
|
-
*/
|
|
176
|
-
declare function createDesignHandlers(registry: NativeUIBridgeRegistry): NativeDesignHandlers;
|
|
177
|
-
|
|
178
|
-
export { APIResponse, ConsoleErrorBuffer, ConsoleErrorEntry, type DecodeResult, type DecodedFrame, HandlerContext, type NativeDesignHandlers, NativeServerHandlers, NetworkRequestBuffer, NetworkRequestEntry, OPCODE_BINARY, OPCODE_CLOSE, OPCODE_CONTINUATION, OPCODE_PING, OPCODE_PONG, OPCODE_TEXT, buildUpgradeResponse, computeAcceptKey, createDesignHandlers, createServerHandlers, decodeFrames, decodeTextPayload, encodeCloseFrame, encodePingFrame, encodePongFrame, encodeTextFrame };
|
|
4
|
+
* HTTP and WebSocket server for external control of native apps.
|
|
5
|
+
*/
|
|
6
|
+
export * from './types';
|
|
7
|
+
export * from './handlers';
|
|
8
|
+
export * from './design-handlers';
|
|
9
|
+
export * from './http-server';
|
|
10
|
+
export * from './ws-protocol';
|
|
11
|
+
export * from './ws-types';
|
|
12
|
+
export { WebSocketConnection } from './ws-connection';
|
|
13
|
+
export type { WebSocketMessageHandler } from './ws-connection';
|
|
14
|
+
export { WebSocketEventBridge } from './ws-event-bridge';
|
|
15
|
+
export { ConsoleErrorBuffer, NetworkRequestBuffer } from './observability';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,YAAY,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI Bridge Native — observability ring buffers.
|
|
3
|
+
*
|
|
4
|
+
* Two small last-N buffers backing the `/control/console-errors` and
|
|
5
|
+
* `/sdk/network-requests` endpoints. Each buffer monkey-patches the relevant
|
|
6
|
+
* global on `install()` and restores the original on `uninstall()`, so they
|
|
7
|
+
* can be installed/torn-down with the server's lifecycle.
|
|
8
|
+
*
|
|
9
|
+
* Both buffers are gated behind `features.testHooks` by the caller (see
|
|
10
|
+
* NativeUIBridgeServer). Production builds default to `testHooks: false`,
|
|
11
|
+
* so these patches never run on real users' devices.
|
|
12
|
+
*
|
|
13
|
+
* Implementation notes:
|
|
14
|
+
* - Buffers default to capacity 100 entries and drop oldest on overflow.
|
|
15
|
+
* - Patches are idempotent: `install()` is a no-op when already installed;
|
|
16
|
+
* `uninstall()` is a no-op when not installed.
|
|
17
|
+
* - Patches only restore the *original* function captured at install time;
|
|
18
|
+
* if other code wraps `console.error` / `fetch` between install and
|
|
19
|
+
* uninstall, those wrappers will be lost. Acceptable for test hooks.
|
|
20
|
+
*/
|
|
21
|
+
import type { ConsoleErrorEntry, NetworkRequestEntry } from './types';
|
|
22
|
+
export declare class ConsoleErrorBuffer {
|
|
23
|
+
private buffer;
|
|
24
|
+
private installed;
|
|
25
|
+
private originalError?;
|
|
26
|
+
private originalWarn?;
|
|
27
|
+
constructor(capacity?: number);
|
|
28
|
+
install(): void;
|
|
29
|
+
uninstall(): void;
|
|
30
|
+
entries(opts?: {
|
|
31
|
+
since?: number;
|
|
32
|
+
limit?: number;
|
|
33
|
+
}): ConsoleErrorEntry[];
|
|
34
|
+
size(): number;
|
|
35
|
+
clear(): void;
|
|
36
|
+
isInstalled(): boolean;
|
|
37
|
+
}
|
|
38
|
+
export declare class NetworkRequestBuffer {
|
|
39
|
+
private buffer;
|
|
40
|
+
private installed;
|
|
41
|
+
private originalFetch?;
|
|
42
|
+
private originalXhrOpen?;
|
|
43
|
+
private originalXhrSend?;
|
|
44
|
+
constructor(capacity?: number);
|
|
45
|
+
install(): void;
|
|
46
|
+
uninstall(): void;
|
|
47
|
+
entries(opts?: {
|
|
48
|
+
since?: number;
|
|
49
|
+
limit?: number;
|
|
50
|
+
}): NetworkRequestEntry[];
|
|
51
|
+
size(): number;
|
|
52
|
+
clear(): void;
|
|
53
|
+
isInstalled(): boolean;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=observability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observability.d.ts","sourceRoot":"","sources":["../../src/server/observability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AA2EtE,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAgC;IAC9C,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,aAAa,CAAC,CAA0B;IAChD,OAAO,CAAC,YAAY,CAAC,CAAyB;gBAElC,QAAQ,SAAM;IAI1B,OAAO,IAAI,IAAI;IA4Cf,SAAS,IAAI,IAAI;IAYjB,OAAO,CAAC,IAAI,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,iBAAiB,EAAE;IAI3E,IAAI,IAAI,MAAM;IAId,KAAK,IAAI,IAAI;IAIb,WAAW,IAAI,OAAO;CAGvB;AA2CD,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,aAAa,CAAC,CAAU;IAChC,OAAO,CAAC,eAAe,CAAC,CAAuC;IAC/D,OAAO,CAAC,eAAe,CAAC,CAAuC;gBAEnD,QAAQ,SAAM;IAI1B,OAAO,IAAI,IAAI;IA0Hf,SAAS,IAAI,IAAI;IAqBjB,OAAO,CAAC,IAAI,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,mBAAmB,EAAE;IAI7E,IAAI,IAAI,MAAM;IAId,KAAK,IAAI,IAAI;IAIb,WAAW,IAAI,OAAO;CAGvB"}
|