@qontinui/ui-bridge-native 0.1.6 → 0.2.1

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 (98) hide show
  1. package/dist/control/{action-executor.d.ts → index.d.mts} +14 -6
  2. package/dist/control/index.d.ts +95 -5
  3. package/dist/control/index.js +74 -11
  4. package/dist/control/index.js.map +1 -1
  5. package/dist/control/index.mjs +74 -11
  6. package/dist/control/index.mjs.map +1 -1
  7. package/dist/core/index.d.mts +46 -0
  8. package/dist/core/index.d.ts +43 -6
  9. package/dist/core/index.js +108 -2
  10. package/dist/core/index.js.map +1 -1
  11. package/dist/core/index.mjs +108 -2
  12. package/dist/core/index.mjs.map +1 -1
  13. package/dist/debug/{inspector.d.ts → index.d.mts} +6 -3
  14. package/dist/debug/index.d.ts +44 -4
  15. package/dist/debug/index.js +2 -2
  16. package/dist/debug/index.js.map +1 -1
  17. package/dist/debug/index.mjs +2 -2
  18. package/dist/debug/index.mjs.map +1 -1
  19. package/dist/design/{design-inspector-native.d.ts → index.d.mts} +11 -7
  20. package/dist/design/index.d.ts +60 -5
  21. package/dist/{design/design-types.d.ts → design-types-BHr6Q1FX.d.mts} +11 -10
  22. package/dist/design-types-BHr6Q1FX.d.ts +205 -0
  23. package/dist/http-server-D2U1k48d.d.mts +703 -0
  24. package/dist/http-server-ck8clUsZ.d.ts +703 -0
  25. package/dist/index.d.mts +89 -0
  26. package/dist/index.d.ts +86 -28
  27. package/dist/index.js +754 -50
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +749 -51
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/react/{useAutoRegister.d.ts → index.d.mts} +15 -7
  32. package/dist/react/index.d.ts +69 -8
  33. package/dist/react/index.js +733 -50
  34. package/dist/react/index.js.map +1 -1
  35. package/dist/react/index.mjs +731 -51
  36. package/dist/react/index.mjs.map +1 -1
  37. package/dist/{core/registry.d.ts → registry-BxXaxmsT.d.ts} +51 -10
  38. package/dist/registry-KdUW_koV.d.mts +253 -0
  39. package/dist/server/index.d.mts +119 -0
  40. package/dist/server/index.d.ts +117 -13
  41. package/dist/server/index.js +272 -16
  42. package/dist/server/index.js.map +1 -1
  43. package/dist/server/index.mjs +272 -16
  44. package/dist/server/index.mjs.map +1 -1
  45. package/dist/{core/types.d.ts → types-BwdPNpII.d.mts} +172 -30
  46. package/dist/types-BwdPNpII.d.ts +525 -0
  47. package/dist/{control/types.d.ts → types-DCEv5qb6.d.ts} +36 -15
  48. package/dist/types-DjB0zJJH.d.mts +197 -0
  49. package/dist/useUIBridgeToast-BPIEbsEc.d.mts +726 -0
  50. package/dist/useUIBridgeToast-DD13oF3k.d.ts +726 -0
  51. package/package.json +2 -2
  52. package/dist/control/action-executor.d.ts.map +0 -1
  53. package/dist/control/index.d.ts.map +0 -1
  54. package/dist/control/types.d.ts.map +0 -1
  55. package/dist/core/element-identifier.d.ts +0 -41
  56. package/dist/core/element-identifier.d.ts.map +0 -1
  57. package/dist/core/index.d.ts.map +0 -1
  58. package/dist/core/registry.d.ts.map +0 -1
  59. package/dist/core/types.d.ts.map +0 -1
  60. package/dist/debug/index.d.ts.map +0 -1
  61. package/dist/debug/inspector.d.ts.map +0 -1
  62. package/dist/design/design-inspector-native.d.ts.map +0 -1
  63. package/dist/design/design-types.d.ts.map +0 -1
  64. package/dist/design/index.d.ts.map +0 -1
  65. package/dist/index.d.ts.map +0 -1
  66. package/dist/react/UIBridgeNativeProvider.d.ts +0 -147
  67. package/dist/react/UIBridgeNativeProvider.d.ts.map +0 -1
  68. package/dist/react/index.d.ts.map +0 -1
  69. package/dist/react/useAutoRegister.d.ts.map +0 -1
  70. package/dist/react/useUIBridge.d.ts +0 -103
  71. package/dist/react/useUIBridge.d.ts.map +0 -1
  72. package/dist/react/useUIComponent.d.ts +0 -112
  73. package/dist/react/useUIComponent.d.ts.map +0 -1
  74. package/dist/react/useUIElement.d.ts +0 -162
  75. package/dist/react/useUIElement.d.ts.map +0 -1
  76. package/dist/server/design-handlers.d.ts +0 -47
  77. package/dist/server/design-handlers.d.ts.map +0 -1
  78. package/dist/server/handlers.d.ts +0 -20
  79. package/dist/server/handlers.d.ts.map +0 -1
  80. package/dist/server/http-server.d.ts +0 -247
  81. package/dist/server/http-server.d.ts.map +0 -1
  82. package/dist/server/index.d.ts.map +0 -1
  83. package/dist/server/types.d.ts +0 -200
  84. package/dist/server/types.d.ts.map +0 -1
  85. package/dist/server/ws-connection.d.ts +0 -48
  86. package/dist/server/ws-connection.d.ts.map +0 -1
  87. package/dist/server/ws-event-bridge.d.ts +0 -113
  88. package/dist/server/ws-event-bridge.d.ts.map +0 -1
  89. package/dist/server/ws-protocol.d.ts +0 -48
  90. package/dist/server/ws-protocol.d.ts.map +0 -1
  91. package/dist/server/ws-types.d.ts +0 -65
  92. package/dist/server/ws-types.d.ts.map +0 -1
  93. package/dist/transport/CloudRelayClient.d.ts +0 -51
  94. package/dist/transport/CloudRelayClient.d.ts.map +0 -1
  95. package/dist/transport/DeviceAnnouncer.d.ts +0 -75
  96. package/dist/transport/DeviceAnnouncer.d.ts.map +0 -1
  97. package/dist/transport/index.d.ts +0 -3
  98. package/dist/transport/index.d.ts.map +0 -1
@@ -1,162 +0,0 @@
1
- /**
2
- * useUIElement Hook for React Native
3
- *
4
- * Register a native element with UI Bridge for control and observation.
5
- */
6
- import type { NativeElementType, NativeStandardAction, NativeCustomAction, NativeElementState, NativeElementIdentifier, RegisteredNativeElement, NativeElementRef } from '../core/types';
7
- /**
8
- * useUIElement options
9
- */
10
- export interface UseUIElementOptions {
11
- /** Unique identifier for the element */
12
- id: string;
13
- /** Element type (defaults to 'custom') */
14
- type?: NativeElementType;
15
- /** Human-readable label */
16
- label?: string;
17
- /** Override available actions */
18
- actions?: NativeStandardAction[];
19
- /** Custom actions */
20
- customActions?: Record<string, NativeCustomAction>;
21
- /** Whether to automatically register on mount */
22
- autoRegister?: boolean;
23
- /** Callback when state changes */
24
- onStateChange?: (state: NativeElementState) => void;
25
- /** Parent component path for tree path generation */
26
- parentPath?: string;
27
- /** RN style prop — will be flattened for design review */
28
- style?: unknown;
29
- /** State-specific style overrides for design review (pressed, focused, disabled) */
30
- stateStyles?: {
31
- pressed?: unknown;
32
- focused?: unknown;
33
- disabled?: unknown;
34
- };
35
- /**
36
- * Handler props to auto-register with the bridge for action execution.
37
- * When provided, the bridge can invoke these handlers via press/type/toggle actions
38
- * without the component needing a separate useEffect + updateElementProps call.
39
- *
40
- * @example
41
- * ```tsx
42
- * const { ref, onLayout, bridgeProps } = useUIElement({
43
- * id: 'my-button',
44
- * type: 'pressable',
45
- * handlers: { onPress: handlePress },
46
- * });
47
- * ```
48
- */
49
- handlers?: Record<string, ((...args: any[]) => any) | undefined>;
50
- }
51
- /**
52
- * Bridge props to spread onto the component
53
- */
54
- export interface UIBridgeProps {
55
- /** Test ID for automation */
56
- testID: string;
57
- /** Accessibility label */
58
- accessibilityLabel?: string;
59
- }
60
- /**
61
- * useUIElement return value
62
- */
63
- export interface UseUIElementReturn {
64
- /** Ref to attach to the element */
65
- ref: React.RefObject<NativeElementRef>;
66
- /** onLayout handler to spread onto the element - uses generic type for RN version compatibility */
67
- onLayout: (event: {
68
- nativeEvent: {
69
- layout: {
70
- x: number;
71
- y: number;
72
- width: number;
73
- height: number;
74
- };
75
- };
76
- }) => void;
77
- /** Props to spread onto the element for identification */
78
- bridgeProps: UIBridgeProps;
79
- /** Whether the element is registered */
80
- registered: boolean;
81
- /** Get current state */
82
- getState: () => NativeElementState | null;
83
- /** Get element identifier */
84
- getIdentifier: () => NativeElementIdentifier | null;
85
- /** Trigger an action on this element */
86
- trigger: (action: NativeStandardAction | string, params?: Record<string, unknown>) => Promise<void>;
87
- /** Manually register the element */
88
- register: () => void;
89
- /** Manually unregister the element */
90
- unregister: () => void;
91
- /** The registered element info */
92
- registeredElement: RegisteredNativeElement | null;
93
- /** Update style for design review (flattens and stores in registry) */
94
- updateStyle: (style: unknown, stateStyles?: {
95
- pressed?: unknown;
96
- focused?: unknown;
97
- disabled?: unknown;
98
- }) => void;
99
- }
100
- /**
101
- * useUIElement hook for React Native
102
- *
103
- * Registers a native element with UI Bridge for programmatic control.
104
- *
105
- * @example
106
- * ```tsx
107
- * function SubmitButton() {
108
- * const { ref, onLayout, bridgeProps, trigger } = useUIElement({
109
- * id: 'submit-btn',
110
- * type: 'button',
111
- * label: 'Submit Form',
112
- * });
113
- *
114
- * return (
115
- * <Pressable
116
- * ref={ref}
117
- * onLayout={onLayout}
118
- * {...bridgeProps}
119
- * onPress={() => handleSubmit()}
120
- * >
121
- * <Text>Submit</Text>
122
- * </Pressable>
123
- * );
124
- * }
125
- * ```
126
- */
127
- export declare function useUIElement(options: UseUIElementOptions): UseUIElementReturn;
128
- /**
129
- * useUIElementWithProps hook
130
- *
131
- * Extended version that also captures component props for action execution.
132
- * Useful when you need the bridge to be able to call onPress, onChangeText, etc.
133
- *
134
- * @example
135
- * ```tsx
136
- * function TextInputField({ onChangeText, value }) {
137
- * const { ref, onLayout, bridgeProps, captureProps } = useUIElementWithProps({
138
- * id: 'email-input',
139
- * type: 'input',
140
- * });
141
- *
142
- * // Capture props so bridge can call onChangeText
143
- * captureProps({ onChangeText, value });
144
- *
145
- * return (
146
- * <TextInput
147
- * ref={ref}
148
- * onLayout={onLayout}
149
- * {...bridgeProps}
150
- * value={value}
151
- * onChangeText={onChangeText}
152
- * />
153
- * );
154
- * }
155
- * ```
156
- */
157
- export interface UseUIElementWithPropsReturn extends UseUIElementReturn {
158
- /** Capture props for action execution */
159
- captureProps: (props: Record<string, unknown>) => void;
160
- }
161
- export declare function useUIElementWithProps(options: UseUIElementOptions): UseUIElementWithPropsReturn;
162
- //# sourceMappingURL=useUIElement.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useUIElement.d.ts","sourceRoot":"","sources":["../../src/react/useUIElement.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,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,yCAAyC;IACzC,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CACxD;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,mBAAmB,GAAG,2BAA2B,CAiB/F"}
@@ -1,47 +0,0 @@
1
- /**
2
- * UI Bridge Native Design Review Handlers
3
- *
4
- * HTTP handlers for the 8 design review endpoints.
5
- * Maps registered element styles to the web SDK's design data format.
6
- */
7
- import type { NativeUIBridgeRegistry } from '../core/registry';
8
- import type { APIResponse, HandlerContext } from './types';
9
- import type { ElementDesignData, StateStyles, ResponsiveSnapshot } from '../design/design-types';
10
- /**
11
- * Design handler interface (subset of NativeServerHandlers)
12
- */
13
- export interface NativeDesignHandlers {
14
- getElementStyles: (ctx: HandlerContext) => Promise<APIResponse<ElementDesignData>>;
15
- getElementStateStyles: (ctx: HandlerContext) => Promise<APIResponse<{
16
- elementId: string;
17
- stateStyles: StateStyles[];
18
- }>>;
19
- getDesignSnapshot: (ctx: HandlerContext) => Promise<APIResponse<{
20
- elements: ElementDesignData[];
21
- timestamp: number;
22
- }>>;
23
- getResponsiveSnapshots: (ctx: HandlerContext) => Promise<APIResponse<ResponsiveSnapshot[]>>;
24
- runDesignAudit: (ctx: HandlerContext) => Promise<APIResponse<unknown>>;
25
- loadStyleGuide: (ctx: HandlerContext) => Promise<APIResponse<{
26
- loaded: boolean;
27
- }>>;
28
- getStyleGuide: (ctx: HandlerContext) => Promise<APIResponse<unknown>>;
29
- clearStyleGuide: (ctx: HandlerContext) => Promise<APIResponse<{
30
- cleared: boolean;
31
- }>>;
32
- evaluateQuality: (ctx: HandlerContext) => Promise<APIResponse<unknown>>;
33
- getQualityContexts: (ctx: HandlerContext) => Promise<APIResponse<Array<{
34
- name: string;
35
- description: string;
36
- }>>>;
37
- saveBaseline: (ctx: HandlerContext) => Promise<APIResponse<{
38
- saved: boolean;
39
- elementCount: number;
40
- }>>;
41
- diffBaseline: (ctx: HandlerContext) => Promise<APIResponse<unknown>>;
42
- }
43
- /**
44
- * Create design review handlers.
45
- */
46
- export declare function createDesignHandlers(registry: NativeUIBridgeRegistry): NativeDesignHandlers;
47
- //# sourceMappingURL=design-handlers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"design-handlers.d.ts","sourceRoot":"","sources":["../../src/server/design-handlers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAqDjG;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,gBAAgB,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACnF,qBAAqB,EAAE,CACrB,GAAG,EAAE,cAAc,KAChB,OAAO,CAAC,WAAW,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,WAAW,EAAE,CAAA;KAAE,CAAC,CAAC,CAAC;IAC7E,iBAAiB,EAAE,CACjB,GAAG,EAAE,cAAc,KAChB,OAAO,CAAC,WAAW,CAAC;QAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IAChF,sBAAsB,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,WAAW,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC;IAC5F,cAAc,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;IACvE,cAAc,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,WAAW,CAAC;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC,CAAC;IACnF,aAAa,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;IACtE,eAAe,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,WAAW,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC,CAAC;IACrF,eAAe,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;IACxE,kBAAkB,EAAE,CAClB,GAAG,EAAE,cAAc,KAChB,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC,CAAC;IACxE,YAAY,EAAE,CACZ,GAAG,EAAE,cAAc,KAChB,OAAO,CAAC,WAAW,CAAC;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IACpE,YAAY,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;CACtE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,sBAAsB,GAAG,oBAAoB,CAwS3F"}
@@ -1,20 +0,0 @@
1
- /**
2
- * UI Bridge Native Server Handlers
3
- *
4
- * Request handlers for the HTTP API endpoints.
5
- */
6
- import { type NativeUIBridgeRegistry } from '../core/registry';
7
- import type { NativeActionExecutor } from '../control/types';
8
- import type { NativeServerHandlers } from './types';
9
- /**
10
- * Create server handlers
11
- */
12
- export declare function createServerHandlers(registry: NativeUIBridgeRegistry, executor: NativeActionExecutor, config?: {
13
- appInfo?: {
14
- appId: string;
15
- appName: string;
16
- appType: string;
17
- framework?: string;
18
- };
19
- }): NativeServerHandlers;
20
- //# sourceMappingURL=handlers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/server/handlers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,sBAAsB,EAAuB,MAAM,kBAAkB,CAAC;AAEpF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,KAAK,EAA+B,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAgQjF;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,sBAAsB,EAChC,QAAQ,EAAE,oBAAoB,EAC9B,MAAM,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GAC7F,oBAAoB,CA6TtB"}
@@ -1,247 +0,0 @@
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
- constructor(registry: NativeUIBridgeRegistry, executor: NativeActionExecutor, config?: NativeServerConfig);
89
- /**
90
- * Set the server adapter
91
- */
92
- setAdapter(adapter: ServerAdapter): void;
93
- /**
94
- * Set a navigation provider for programmatic route navigation.
95
- * This enables `control/page/navigate` and `control/page/back` on native.
96
- */
97
- setNavigationProvider(provider: NavigationProvider): void;
98
- /**
99
- * Set a route provider for reporting the current navigation route.
100
- * When set, `control/snapshot` responses include `currentRoute` and `segments`.
101
- */
102
- setRouteProvider(provider: RouteProvider): void;
103
- /**
104
- * Set a screenshot provider for native screen capture.
105
- * This enables `control/screenshot` on native.
106
- */
107
- setScreenshotProvider(provider: ScreenshotProvider): void;
108
- /**
109
- * Start the HTTP server
110
- */
111
- start(): Promise<void>;
112
- /**
113
- * Stop the HTTP server
114
- */
115
- stop(): Promise<void>;
116
- /**
117
- * Check if server is running
118
- */
119
- isRunning(): boolean;
120
- private eventBridge?;
121
- /**
122
- * Set the event bridge for WebSocket event broadcasting and subscriptions.
123
- */
124
- setEventBridge(bridge: WebSocketEventBridge): void;
125
- /**
126
- * Handle a JSON-RPC message from a WebSocket client.
127
- * Parses the message, routes to the appropriate handler, and returns
128
- * a JSON string response (or null for events that need no response).
129
- */
130
- handleWebSocketMessage(connId: string, rawMessage: string): Promise<string | null>;
131
- /**
132
- * Execute a batch of JSON-RPC requests concurrently.
133
- */
134
- handleBatchRequest(batch: JsonRpcRequest[]): Promise<JsonRpcResponse[]>;
135
- /**
136
- * Register an in-flight waiter's cleanup thunk under the given connection.
137
- * Returns an `unregister` thunk that the natural-resolution path should
138
- * call so the cleanup isn't re-invoked on disconnect.
139
- */
140
- private registerWaiter;
141
- /**
142
- * Abort all pending waiters associated with a connection. Called by the
143
- * provider's WS disconnect handler so timers/listeners don't leak after
144
- * the client goes away.
145
- */
146
- abortWaitersForConnection(connId: string): void;
147
- /**
148
- * Wait for an element to be registered, or resolve immediately if it already exists.
149
- * Returns a JsonRpcResponse JSON string.
150
- */
151
- private handleWaitForElement;
152
- /**
153
- * Wait for an arbitrary element-state predicate to become true.
154
- *
155
- * Supported `condition` shapes:
156
- * {field: "mounted"|"visible"|"enabled"|"focused", equals: boolean}
157
- * {field: "layout", exists: true}
158
- * {field: string, equals: unknown} // generic: state[field] === equals
159
- *
160
- * Resolves immediately with `waited:false` if the predicate already
161
- * holds. Otherwise subscribes to `element:registered` and
162
- * `element:stateChanged` until the predicate matches or timeout fires.
163
- */
164
- private handleWaitForCondition;
165
- /**
166
- * Execute a sequence of JSON-RPC steps in order, stopping on first failure.
167
- * Returns a JsonRpcResponse JSON string with per-step results.
168
- */
169
- private handleSequence;
170
- /**
171
- * Route a JSON-RPC method string to the appropriate handler using path-style matching.
172
- *
173
- * Method strings mirror HTTP routes but without the /ui-bridge/ prefix.
174
- * Path params are extracted from :name placeholders in the route pattern.
175
- *
176
- * Examples:
177
- * "health" → handlers.health
178
- * "control/snapshot" → handlers.getSnapshot
179
- * "control/element/tab-runs/action" → handlers.executeAction ({id:'tab-runs'})
180
- * "control/component/my-comp/action/submit" → handlers.executeComponentAction
181
- */
182
- private routeMethodToHandler;
183
- /**
184
- * Handle incoming HTTP request
185
- *
186
- * Exposed as public so that CloudRelayClient can call it directly (without
187
- * loopback TCP overhead) when processing tunneled requests.
188
- */
189
- handleRequest(request: HTTPRequest): Promise<HTTPResponse>;
190
- /**
191
- * Route an HTTP request to the appropriate handler using WS_ROUTES.
192
- *
193
- * Strips the `/ui-bridge/` prefix from the path, then iterates the shared
194
- * WS_ROUTES table. Each route's `pattern` is matched against the stripped
195
- * path via the module-level `parsePath` helper; path params are merged
196
- * with the request body into a HandlerContext.
197
- *
198
- * `httpMethods` disambiguates routes that share a pattern but differ
199
- * by verb (e.g. GET vs DELETE on `design/style-guide`). A route without
200
- * `httpMethods` is WS-only and will not be matched on HTTP.
201
- */
202
- private routeRequest;
203
- }
204
- /**
205
- * Create a UI Bridge Native server
206
- */
207
- export declare function createNativeServer(registry: NativeUIBridgeRegistry, executor: NativeActionExecutor, config?: NativeServerConfig): NativeUIBridgeServer;
208
- /**
209
- * Example adapter using react-native-http-bridge
210
- *
211
- * To use this adapter:
212
- * 1. Install: npm install react-native-http-bridge
213
- * 2. Link native modules
214
- * 3. Create adapter and pass to server
215
- *
216
- * ```tsx
217
- * import httpBridge from 'react-native-http-bridge';
218
- *
219
- * const adapter: ServerAdapter = {
220
- * start: async (port, handler) => {
221
- * httpBridge.start(port, 'ui-bridge', async (request) => {
222
- * const response = await handler({
223
- * method: request.type,
224
- * path: request.url,
225
- * headers: request.headers || {},
226
- * query: parseQuery(request.url),
227
- * body: request.postData ? JSON.parse(request.postData) : undefined,
228
- * });
229
- * httpBridge.respond(
230
- * request.requestId,
231
- * response.status,
232
- * response.headers['Content-Type'],
233
- * response.body
234
- * );
235
- * });
236
- * },
237
- * stop: async () => {
238
- * httpBridge.stop();
239
- * },
240
- * isRunning: () => true,
241
- * };
242
- *
243
- * server.setAdapter(adapter);
244
- * await server.start();
245
- * ```
246
- */
247
- //# sourceMappingURL=http-server.d.ts.map
@@ -1 +0,0 @@
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;AAGjB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAyOlE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,MAA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