@qontinui/ui-bridge-native 0.1.5 → 0.2.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.
Files changed (45) hide show
  1. package/dist/control/index.d.mts +9 -5
  2. package/dist/control/index.d.ts +9 -5
  3. package/dist/control/index.js +75 -12
  4. package/dist/control/index.js.map +1 -1
  5. package/dist/control/index.mjs +75 -12
  6. package/dist/control/index.mjs.map +1 -1
  7. package/dist/core/index.d.mts +3 -3
  8. package/dist/core/index.d.ts +3 -3
  9. package/dist/core/index.js +69 -1
  10. package/dist/core/index.js.map +1 -1
  11. package/dist/core/index.mjs +69 -1
  12. package/dist/core/index.mjs.map +1 -1
  13. package/dist/debug/index.js.map +1 -1
  14. package/dist/debug/index.mjs.map +1 -1
  15. package/dist/design/index.d.mts +1 -1
  16. package/dist/design/index.d.ts +1 -1
  17. package/dist/{http-server-D7uVANBU.d.mts → http-server-DCdR8WlL.d.mts} +3 -3
  18. package/dist/{http-server-B7KudcYJ.d.ts → http-server-Dj3grQW4.d.ts} +3 -3
  19. package/dist/index.d.mts +5 -5
  20. package/dist/index.d.ts +5 -5
  21. package/dist/index.js +498 -16
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.mjs +493 -17
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/react/index.d.mts +5 -5
  26. package/dist/react/index.d.ts +5 -5
  27. package/dist/react/index.js +504 -16
  28. package/dist/react/index.js.map +1 -1
  29. package/dist/react/index.mjs +502 -17
  30. package/dist/react/index.mjs.map +1 -1
  31. package/dist/{registry-DhbGbl9c.d.mts → registry-Cahd8Gn2.d.mts} +16 -1
  32. package/dist/{registry-B8A_EoxS.d.ts → registry-z-3WJsxp.d.ts} +16 -1
  33. package/dist/server/index.d.mts +5 -5
  34. package/dist/server/index.d.ts +5 -5
  35. package/dist/server/index.js +102 -1
  36. package/dist/server/index.js.map +1 -1
  37. package/dist/server/index.mjs +102 -1
  38. package/dist/server/index.mjs.map +1 -1
  39. package/dist/{types-Bcj7ji97.d.mts → types-DAfCeWXc.d.mts} +22 -2
  40. package/dist/{types-BPNuYxDx.d.mts → types-Oz13YLZq.d.mts} +95 -1
  41. package/dist/{types-BPNuYxDx.d.ts → types-Oz13YLZq.d.ts} +95 -1
  42. package/dist/{types-BCYWwyVy.d.ts → types-ajakyp-l.d.ts} +22 -2
  43. package/dist/{useUIBridge-CDZbWxII.d.ts → useUIBridgeToast-D32KXyL1.d.ts} +154 -5
  44. package/dist/{useUIBridge-DfIEq9EQ.d.mts → useUIBridgeToast-GmT1TzUe.d.mts} +154 -5
  45. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { a as BridgeEventListener, i as NativeElementRef, k as NativeElementType, o as NativeStandardAction, g as NativeCustomAction, r as RegisteredNativeElement, j as NativeElementState, R as RegisteredNativeComponent, s as Workflow, b as BridgeEventType, e as NativeBridgeSnapshot } from './types-BPNuYxDx.mjs';
1
+ import { a as BridgeEventListener, r as NativeSnapshotEnrichers, q as NativeSnapshotEnricher, j as NativeElementRef, l as NativeElementType, v as NativeStandardAction, h as NativeCustomAction, y as RegisteredNativeElement, k as NativeElementState, R as RegisteredNativeComponent, z as Workflow, b as BridgeEventType, e as NativeBridgeSnapshot } from './types-Oz13YLZq.mjs';
2
2
 
3
3
  /**
4
4
  * Native Element and Component Registry
@@ -67,7 +67,22 @@ declare class NativeUIBridgeRegistry {
67
67
  private workflows;
68
68
  private eventListeners;
69
69
  private config;
70
+ private enrichers;
71
+ private snapshotExtras;
70
72
  constructor(config?: NativeRegistryConfig);
73
+ /**
74
+ * Register/replace canonical enrichers (modal/toast/undo). HMR-safe — calling
75
+ * with a partial set merges into existing slots instead of clobbering them.
76
+ */
77
+ setEnrichers(e: Partial<NativeSnapshotEnrichers>): void;
78
+ /**
79
+ * Register a custom snapshot enricher. The returned object will be
80
+ * `Object.assign`ed onto the snapshot, so use unique top-level keys to avoid
81
+ * clobbering canonical fields. Returns a disposer.
82
+ */
83
+ registerSnapshotEnricher(name: string, fn: NativeSnapshotEnricher): () => void;
84
+ /** Remove a custom snapshot enricher by name */
85
+ unregisterSnapshotEnricher(name: string): void;
71
86
  /**
72
87
  * Register a native element
73
88
  */
@@ -1,4 +1,4 @@
1
- import { a as BridgeEventListener, i as NativeElementRef, k as NativeElementType, o as NativeStandardAction, g as NativeCustomAction, r as RegisteredNativeElement, j as NativeElementState, R as RegisteredNativeComponent, s as Workflow, b as BridgeEventType, e as NativeBridgeSnapshot } from './types-BPNuYxDx.js';
1
+ import { a as BridgeEventListener, r as NativeSnapshotEnrichers, q as NativeSnapshotEnricher, j as NativeElementRef, l as NativeElementType, v as NativeStandardAction, h as NativeCustomAction, y as RegisteredNativeElement, k as NativeElementState, R as RegisteredNativeComponent, z as Workflow, b as BridgeEventType, e as NativeBridgeSnapshot } from './types-Oz13YLZq.js';
2
2
 
3
3
  /**
4
4
  * Native Element and Component Registry
@@ -67,7 +67,22 @@ declare class NativeUIBridgeRegistry {
67
67
  private workflows;
68
68
  private eventListeners;
69
69
  private config;
70
+ private enrichers;
71
+ private snapshotExtras;
70
72
  constructor(config?: NativeRegistryConfig);
73
+ /**
74
+ * Register/replace canonical enrichers (modal/toast/undo). HMR-safe — calling
75
+ * with a partial set merges into existing slots instead of clobbering them.
76
+ */
77
+ setEnrichers(e: Partial<NativeSnapshotEnrichers>): void;
78
+ /**
79
+ * Register a custom snapshot enricher. The returned object will be
80
+ * `Object.assign`ed onto the snapshot, so use unique top-level keys to avoid
81
+ * clobbering canonical fields. Returns a disposer.
82
+ */
83
+ registerSnapshotEnricher(name: string, fn: NativeSnapshotEnricher): () => void;
84
+ /** Remove a custom snapshot enricher by name */
85
+ unregisterSnapshotEnricher(name: string): void;
71
86
  /**
72
87
  * Register a native element
73
88
  */
@@ -1,9 +1,9 @@
1
- import { h as NativeServerHandlers, b as HandlerContext, A as APIResponse } from '../http-server-D7uVANBU.mjs';
2
- export { H as HTTPRequest, a as HTTPResponse, c as HandlerFunction, J as JsonRpcBatchRequest, d as JsonRpcBatchResponse, r as JsonRpcClientMessage, e as JsonRpcEvent, f as JsonRpcRequest, g as JsonRpcResponse, s as JsonRpcServerMessage, t as JsonRpcSubscribe, u as JsonRpcUnsubscribe, N as NativeServerConfig, i as NativeUIBridgeServer, j as NavigationProvider, R as RequestHandler, k as RouteDefinition, l as RouteProvider, S as ScreenshotProvider, m as ServerAdapter, U as UI_BRIDGE_NATIVE_ROUTES, W as WebSocketConnection, n as WebSocketEventBridge, o as WebSocketMessageHandler, p as WebSocketServerAdapter, q as createNativeServer, v as isBatchRequest, w as isSubscribe, x as isUnsubscribe } from '../http-server-D7uVANBU.mjs';
3
- import { a as NativeUIBridgeRegistry } from '../registry-DhbGbl9c.mjs';
4
- import { N as NativeActionExecutor } from '../types-Bcj7ji97.mjs';
1
+ import { h as NativeServerHandlers, b as HandlerContext, A as APIResponse } from '../http-server-DCdR8WlL.mjs';
2
+ export { H as HTTPRequest, a as HTTPResponse, c as HandlerFunction, J as JsonRpcBatchRequest, d as JsonRpcBatchResponse, r as JsonRpcClientMessage, e as JsonRpcEvent, f as JsonRpcRequest, g as JsonRpcResponse, s as JsonRpcServerMessage, t as JsonRpcSubscribe, u as JsonRpcUnsubscribe, N as NativeServerConfig, i as NativeUIBridgeServer, j as NavigationProvider, R as RequestHandler, k as RouteDefinition, l as RouteProvider, S as ScreenshotProvider, m as ServerAdapter, U as UI_BRIDGE_NATIVE_ROUTES, W as WebSocketConnection, n as WebSocketEventBridge, o as WebSocketMessageHandler, p as WebSocketServerAdapter, q as createNativeServer, v as isBatchRequest, w as isSubscribe, x as isUnsubscribe } from '../http-server-DCdR8WlL.mjs';
3
+ import { a as NativeUIBridgeRegistry } from '../registry-Cahd8Gn2.mjs';
4
+ import { N as NativeActionExecutor } from '../types-DAfCeWXc.mjs';
5
5
  import { E as ElementDesignData, S as StateStyles, R as ResponsiveSnapshot } from '../design-types-BHr6Q1FX.mjs';
6
- import '../types-BPNuYxDx.mjs';
6
+ import '../types-Oz13YLZq.mjs';
7
7
 
8
8
  /**
9
9
  * UI Bridge Native Server Handlers
@@ -1,9 +1,9 @@
1
- import { h as NativeServerHandlers, b as HandlerContext, A as APIResponse } from '../http-server-B7KudcYJ.js';
2
- export { H as HTTPRequest, a as HTTPResponse, c as HandlerFunction, J as JsonRpcBatchRequest, d as JsonRpcBatchResponse, r as JsonRpcClientMessage, e as JsonRpcEvent, f as JsonRpcRequest, g as JsonRpcResponse, s as JsonRpcServerMessage, t as JsonRpcSubscribe, u as JsonRpcUnsubscribe, N as NativeServerConfig, i as NativeUIBridgeServer, j as NavigationProvider, R as RequestHandler, k as RouteDefinition, l as RouteProvider, S as ScreenshotProvider, m as ServerAdapter, U as UI_BRIDGE_NATIVE_ROUTES, W as WebSocketConnection, n as WebSocketEventBridge, o as WebSocketMessageHandler, p as WebSocketServerAdapter, q as createNativeServer, v as isBatchRequest, w as isSubscribe, x as isUnsubscribe } from '../http-server-B7KudcYJ.js';
3
- import { a as NativeUIBridgeRegistry } from '../registry-B8A_EoxS.js';
4
- import { N as NativeActionExecutor } from '../types-BCYWwyVy.js';
1
+ import { h as NativeServerHandlers, b as HandlerContext, A as APIResponse } from '../http-server-Dj3grQW4.js';
2
+ export { H as HTTPRequest, a as HTTPResponse, c as HandlerFunction, J as JsonRpcBatchRequest, d as JsonRpcBatchResponse, r as JsonRpcClientMessage, e as JsonRpcEvent, f as JsonRpcRequest, g as JsonRpcResponse, s as JsonRpcServerMessage, t as JsonRpcSubscribe, u as JsonRpcUnsubscribe, N as NativeServerConfig, i as NativeUIBridgeServer, j as NavigationProvider, R as RequestHandler, k as RouteDefinition, l as RouteProvider, S as ScreenshotProvider, m as ServerAdapter, U as UI_BRIDGE_NATIVE_ROUTES, W as WebSocketConnection, n as WebSocketEventBridge, o as WebSocketMessageHandler, p as WebSocketServerAdapter, q as createNativeServer, v as isBatchRequest, w as isSubscribe, x as isUnsubscribe } from '../http-server-Dj3grQW4.js';
3
+ import { a as NativeUIBridgeRegistry } from '../registry-z-3WJsxp.js';
4
+ import { N as NativeActionExecutor } from '../types-ajakyp-l.js';
5
5
  import { E as ElementDesignData, S as StateStyles, R as ResponsiveSnapshot } from '../design-types-BHr6Q1FX.js';
6
- import '../types-BPNuYxDx.js';
6
+ import '../types-Oz13YLZq.js';
7
7
 
8
8
  /**
9
9
  * UI Bridge Native Server Handlers
@@ -1104,6 +1104,10 @@ var WS_ROUTES = [
1104
1104
  { pattern: "health", handler: "health", httpMethods: ["GET"] },
1105
1105
  // Elements
1106
1106
  { pattern: "control/elements", handler: "getElements", httpMethods: ["GET"] },
1107
+ // Flat alias — matches the runner UI Bridge's `/ui-bridge/elements` path so
1108
+ // agents can use the same URL across runner + mobile without remembering
1109
+ // the `control/` prefix. Delegates to the same handler.
1110
+ { pattern: "elements", handler: "getElements", httpMethods: ["GET"] },
1107
1111
  { pattern: "control/element/:id", handler: "getElement", httpMethods: ["GET"] },
1108
1112
  { pattern: "control/element/:id/state", handler: "getElementState", httpMethods: ["GET"] },
1109
1113
  { pattern: "control/element/:id/action", handler: "executeAction", httpMethods: ["POST"] },
@@ -1154,6 +1158,87 @@ var WS_ROUTES = [
1154
1158
  // Meta / Introspection
1155
1159
  { pattern: "meta/methods", handler: "getMethods", httpMethods: ["GET"] }
1156
1160
  ];
1161
+ var HANDLER_DESCRIPTIONS = {
1162
+ health: "Liveness probe; returns app metadata + element count",
1163
+ getElements: "Flat list of registered UI elements",
1164
+ getElement: "Single element by id",
1165
+ getElementState: "Dynamic state (value, focused, checked) for one element",
1166
+ executeAction: 'Run an action on an element (see "actions" below for names)',
1167
+ getComponents: "Higher-level components with action schemas",
1168
+ getComponent: "Component detail + per-action paramSchema",
1169
+ executeComponentAction: "Invoke a component action directly (preferred over button clicks)",
1170
+ find: "AI-powered element search by natural-language query",
1171
+ getSnapshot: "Full snapshot: elements + route + state. Supports ?visibleOnly=true and ?currentRouteOnly=true",
1172
+ getWorkflows: "List registered workflows",
1173
+ runWorkflow: "Trigger a workflow by id",
1174
+ pageRefresh: "Reload the current route",
1175
+ pageNavigate: "Imperative router.push(url) \u2014 preferred over tapping tab buttons",
1176
+ pageReplace: "router.replace(url)",
1177
+ pageGoBack: "router.back()",
1178
+ pageGoForward: "router.forward()",
1179
+ getScreenshot: "PNG screenshot of the current screen",
1180
+ getElementStyles: "Computed styles for an element (design review)",
1181
+ getElementStateStyles: "Computed styles per interaction state (hover/focus/disabled)",
1182
+ getDesignSnapshot: "Visual + style snapshot for design review",
1183
+ getResponsiveSnapshots: "Screenshots at multiple viewport widths",
1184
+ runDesignAudit: "Accessibility + visual audit",
1185
+ loadStyleGuide: "Load a design system style guide",
1186
+ getStyleGuide: "Fetch the currently loaded style guide",
1187
+ clearStyleGuide: "Unload the style guide",
1188
+ evaluateQuality: "Score the current UI against a quality context",
1189
+ getQualityContexts: "List available quality evaluation contexts",
1190
+ saveBaseline: "Save a quality baseline snapshot",
1191
+ diffBaseline: "Diff current UI against a saved baseline",
1192
+ getMethods: "List every handler name (legacy introspection)"
1193
+ };
1194
+ var ACTION_REFERENCE = [
1195
+ { name: "press", aliases: ["click"], params: "PressActionParams (optional position)" },
1196
+ { name: "longPress", params: "PressActionParams (optional position)" },
1197
+ { name: "doubleTap", params: "none" },
1198
+ {
1199
+ name: "type",
1200
+ params: "TypeActionParams { text, delay?, clear? | clearFirst? } \u2014 `clear:true` replaces content atomically"
1201
+ },
1202
+ { name: "clear", params: "none \u2014 empties the input" },
1203
+ { name: "focus", params: "none" },
1204
+ { name: "blur", params: "none" },
1205
+ { name: "scroll", params: "ScrollActionParams { offset? {x,y}, to? }" },
1206
+ { name: "swipe", params: "SwipeActionParams { direction, distance }" },
1207
+ { name: "toggle", params: "none \u2014 flips boolean controls" }
1208
+ ];
1209
+ function buildRoutesPayload() {
1210
+ const entries = [];
1211
+ for (const r of WS_ROUTES) {
1212
+ if (!r.httpMethods) continue;
1213
+ for (const m of r.httpMethods) {
1214
+ entries.push({ method: m, path: `/ui-bridge/${r.pattern}` });
1215
+ }
1216
+ }
1217
+ entries.push({ method: "GET", path: "/ui-bridge/_help" });
1218
+ entries.push({ method: "GET", path: "/ui-bridge/_routes" });
1219
+ entries.sort((a, b) => a.path.localeCompare(b.path) || a.method.localeCompare(b.method));
1220
+ return { routes: entries, count: entries.length };
1221
+ }
1222
+ function buildHelpPayload() {
1223
+ return {
1224
+ version: 1,
1225
+ description: "UI Bridge Native HTTP surface. Prefix every path with /ui-bridge/.",
1226
+ routes: WS_ROUTES.map((r) => ({
1227
+ pattern: r.pattern,
1228
+ httpMethods: r.httpMethods ?? [],
1229
+ wsOnly: !r.httpMethods,
1230
+ handler: r.handler,
1231
+ description: HANDLER_DESCRIPTIONS[r.handler] ?? ""
1232
+ })),
1233
+ actions: ACTION_REFERENCE,
1234
+ tips: [
1235
+ "Start with `GET /ui-bridge/control/snapshot?visibleOnly=true` to see what the user actually sees.",
1236
+ "Prefer `control/component/:id/action/:actionId` over button presses \u2014 typed paramSchema, no button-id guessing.",
1237
+ "Use `pageNavigate` for tab switches instead of pressing tab buttons; gesture state often swallows clicks.",
1238
+ "The `type` action supports `clear:true` to replace existing text atomically in one call."
1239
+ ]
1240
+ };
1241
+ }
1157
1242
  var NativeUIBridgeServer = class {
1158
1243
  constructor(registry, executor, config = {}) {
1159
1244
  this.registry = registry;
@@ -1170,7 +1255,9 @@ var NativeUIBridgeServer = class {
1170
1255
  cors: true,
1171
1256
  ...config
1172
1257
  };
1173
- this.handlers = createServerHandlers(registry, executor);
1258
+ this.handlers = createServerHandlers(registry, executor, {
1259
+ appInfo: this.config.appInfo
1260
+ });
1174
1261
  this.handlers.getMethods = async () => {
1175
1262
  const methods = WS_ROUTES.map((r) => ({
1176
1263
  method: r.pattern,
@@ -1974,6 +2061,20 @@ var NativeUIBridgeServer = class {
1974
2061
  };
1975
2062
  }
1976
2063
  const stripped = path.slice(PREFIX.length);
2064
+ if (method === "GET" && stripped === "_help") {
2065
+ return {
2066
+ success: true,
2067
+ data: buildHelpPayload(),
2068
+ timestamp: Date.now()
2069
+ };
2070
+ }
2071
+ if (method === "GET" && stripped === "_routes") {
2072
+ return {
2073
+ success: true,
2074
+ data: buildRoutesPayload(),
2075
+ timestamp: Date.now()
2076
+ };
2077
+ }
1977
2078
  let patternMatchedButWrongVerb = false;
1978
2079
  for (const route of WS_ROUTES) {
1979
2080
  const pathParams = parsePath(route.pattern, stripped);