@qontinui/ui-bridge-native 0.6.4 → 0.6.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.
@@ -1 +1 @@
1
- {"version":3,"file":"UIBridgeNativeProvider.d.ts","sourceRoot":"","sources":["../../src/react/UIBridgeNativeProvider.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAQN,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EACV,sBAAsB,EACtB,oBAAoB,EACpB,uBAAuB,EACvB,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,sBAAsB,EAA0C,MAAM,kBAAkB,CAAC;AAElG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGxE,OAAO,EAAoB,KAAK,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,oBAAoB;IACpB,QAAQ,EAAE,sBAAsB,CAAC;IACjC,oBAAoB;IACpB,MAAM,EAAE,oBAAoB,CAAC;IAC7B,uBAAuB;IACvB,QAAQ,EAAE,sBAAsB,CAAC;IACjC,sBAAsB;IACtB,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,+DAA+D;IAC/D,aAAa,EAAE,aAAa,CAAC;IAC7B,oEAAoE;IACpE,YAAY,EAAE,YAAY,CAAC;IAC3B,2CAA2C;IAC3C,WAAW,EAAE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C;IAC5E;;;OAGG;IACH,kBAAkB,CAAC,EAAE;QACnB,OAAO,EAAE,MAAM,OAAO,CAAC;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAC3E,CAAC;IACF;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;IAC5D;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,QAAQ,EACR,QAAa,EACb,MAAW,EACX,OAAO,EACP,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,QAAQ,GACT,EAAE,2BAA2B,2CA4X7B;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,0BAA0B,CAM9D;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,IAAI,0BAA0B,GAAG,IAAI,CAE7E;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,0BAAoB,CAAC"}
1
+ {"version":3,"file":"UIBridgeNativeProvider.d.ts","sourceRoot":"","sources":["../../src/react/UIBridgeNativeProvider.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAQN,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EACV,sBAAsB,EACtB,oBAAoB,EACpB,uBAAuB,EACvB,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACpB,MAAM,eAAe,CAAC;AACvB,OAAO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C,EAAE,OAAO,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,QAAQ,EACR,QAAa,EACb,MAAW,EACX,OAAO,EACP,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,QAAQ,GACT,EAAE,2BAA2B,2CA0Y7B;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,0BAA0B,CAM9D;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,IAAI,0BAA0B,GAAG,IAAI,CAE7E;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,0BAAoB,CAAC"}
@@ -16,6 +16,10 @@ function extractHandlerNames(props) {
16
16
  if (!props) return [];
17
17
  return Object.keys(props).filter((k) => typeof props[k] === "function");
18
18
  }
19
+ function matchesCurrentRoute(registrationRoute, currentRoute) {
20
+ if (registrationRoute == null || registrationRoute === "") return true;
21
+ return registrationRoute === currentRoute;
22
+ }
19
23
  function inferActions(type) {
20
24
  const baseActions = ["focus", "blur"];
21
25
  switch (type) {
@@ -221,13 +225,20 @@ var NativeUIBridgeRegistry = class {
221
225
  if (this.config.verbose) {
222
226
  console.log(`[ui-bridge-native] Registered element: ${id} (${type})`);
223
227
  }
224
- this.updateElementState(id, {
228
+ const seededState = {
225
229
  mounted: true,
226
230
  visible: true,
227
231
  enabled: true,
228
232
  focused: false,
229
233
  layout: null
230
- });
234
+ };
235
+ if (type === "input" && typeof props?.value === "string") {
236
+ seededState.value = props.value;
237
+ }
238
+ if (type === "text" && typeof label === "string") {
239
+ seededState.value = label;
240
+ }
241
+ this.updateElementState(id, seededState);
231
242
  return registered;
232
243
  }
233
244
  /**
@@ -389,6 +400,9 @@ var NativeUIBridgeRegistry = class {
389
400
  })
390
401
  };
391
402
  this.elements.set(id, updated);
403
+ if (element.type === "text" && labelChanged && typeof nextLabel === "string") {
404
+ this.updateElementState(id, { value: nextLabel });
405
+ }
392
406
  this.emit("element:registered", {
393
407
  id,
394
408
  type: element.type,
@@ -397,7 +411,22 @@ var NativeUIBridgeRegistry = class {
397
411
  return true;
398
412
  }
399
413
  /**
400
- * Update element props (for action execution)
414
+ * Update element props (for action execution).
415
+ *
416
+ * Side effect for `type: 'input'` elements: when `props.value` is a string,
417
+ * mirror it into `state.value` so AI drivers reading the registry don't see
418
+ * `state.value === undefined` until the user types. Before this mirror,
419
+ * controlled-input consumers (`<TextInput value={x} onChangeText={setX} />`
420
+ * with `captureProps({ value: x, onChangeText: setX })`) registered an
421
+ * input whose `state.value` only became defined after the FIRST
422
+ * `onChangeText` call — bridge consumers couldn't read the default value
423
+ * (e.g. a pre-populated API-URL input) until someone typed into it.
424
+ *
425
+ * Re-runs on every `updateElementProps` so a parent passing a fresh
426
+ * `value` prop (controlled re-render) keeps the registry in sync. The
427
+ * mirror is gated on `type === 'input'` to avoid touching non-input
428
+ * elements that may carry an unrelated `value` prop (e.g. a Switch's
429
+ * boolean value, which lives on `state.checked`).
401
430
  */
402
431
  updateElementProps(id, props) {
403
432
  const element = this.elements.get(id);
@@ -407,6 +436,12 @@ var NativeUIBridgeRegistry = class {
407
436
  props: { ...element.props, ...props }
408
437
  };
409
438
  this.elements.set(id, updated);
439
+ if (element.type === "input" && Object.prototype.hasOwnProperty.call(props, "value") && typeof props.value === "string") {
440
+ const currentState = updated.getState();
441
+ if (currentState.value !== props.value) {
442
+ this.updateElementState(id, { value: props.value });
443
+ }
444
+ }
410
445
  }
411
446
  }
412
447
  /**
@@ -617,7 +652,7 @@ var NativeUIBridgeRegistry = class {
617
652
  let elements = options?.visibleOnly ? this.getMountedVisibleElements() : this.getAllElements();
618
653
  if (options?.currentRouteOnly && resolvedRoute.currentRoute) {
619
654
  const currentRoute = resolvedRoute.currentRoute;
620
- elements = elements.filter((e) => e.registrationRoute === currentRoute);
655
+ elements = elements.filter((e) => matchesCurrentRoute(e.registrationRoute, currentRoute));
621
656
  }
622
657
  const snapshot = {
623
658
  timestamp: Date.now(),
@@ -1556,15 +1591,9 @@ function success(data) {
1556
1591
  function error(message, code) {
1557
1592
  return { success: false, error: message, code, timestamp: Date.now() };
1558
1593
  }
1559
- function createDesignHandlers(registry) {
1594
+ function createDesignHandlers(registry, viewportProvider) {
1560
1595
  function getScreenDimensions() {
1561
- try {
1562
- const { Dimensions } = __require("react-native");
1563
- const screen = Dimensions.get("screen");
1564
- return { width: screen.width, height: screen.height };
1565
- } catch {
1566
- return { width: 0, height: 0 };
1567
- }
1596
+ return viewportProvider?.() ?? { width: 0, height: 0 };
1568
1597
  }
1569
1598
  return {
1570
1599
  // 1. GET /design/element/:id/styles
@@ -2194,15 +2223,6 @@ async function executeWorkflowStep(step, registry, executor) {
2194
2223
  };
2195
2224
  }
2196
2225
  }
2197
- function getWindowDimensions() {
2198
- try {
2199
- const { Dimensions } = __require("react-native");
2200
- const win = Dimensions.get("window");
2201
- return { width: win.width, height: win.height };
2202
- } catch {
2203
- return { width: 0, height: 0 };
2204
- }
2205
- }
2206
2226
  function success2(data) {
2207
2227
  return {
2208
2228
  success: true,
@@ -2219,7 +2239,7 @@ function error2(message, code) {
2219
2239
  };
2220
2240
  }
2221
2241
  function createServerHandlers(registry, executor, config) {
2222
- const designHandlers = createDesignHandlers(registry);
2242
+ const designHandlers = createDesignHandlers(registry, config?.viewportProvider);
2223
2243
  return {
2224
2244
  // Elements
2225
2245
  getElements: async (ctx) => {
@@ -2227,7 +2247,7 @@ function createServerHandlers(registry, executor, config) {
2227
2247
  const forRoute = ctx.query?.route || ctx.body?.route;
2228
2248
  let allElements = visibleOnly ? registry.getMountedVisibleElements() : registry.getAllElements();
2229
2249
  if (forRoute) {
2230
- allElements = allElements.filter((e) => e.registrationRoute === forRoute);
2250
+ allElements = allElements.filter((e) => matchesCurrentRoute(e.registrationRoute, forRoute));
2231
2251
  }
2232
2252
  const elements = allElements.map((e) => {
2233
2253
  const handlers = extractHandlerNames(e.props);
@@ -2410,7 +2430,7 @@ function createServerHandlers(registry, executor, config) {
2410
2430
  },
2411
2431
  getPageHealth: async (ctx) => {
2412
2432
  const bodyViewport = ctx.body?.viewport;
2413
- const viewport = bodyViewport ?? getWindowDimensions();
2433
+ const viewport = bodyViewport ?? config?.viewportProvider?.() ?? { width: 0, height: 0 };
2414
2434
  const elements = registry.getAllElements().map((e) => ({
2415
2435
  type: e.type,
2416
2436
  state: e.getState()
@@ -3381,7 +3401,8 @@ var NativeUIBridgeServer = class {
3381
3401
  this.handlers = createServerHandlers(registry, executor, {
3382
3402
  appInfo: this.config.appInfo,
3383
3403
  consoleErrorBuffer: this.consoleErrorBuffer,
3384
- networkRequestBuffer: this.networkRequestBuffer
3404
+ networkRequestBuffer: this.networkRequestBuffer,
3405
+ viewportProvider: this.config.viewportProvider
3385
3406
  });
3386
3407
  this.handlers.getMethods = async () => {
3387
3408
  const testHooks = this.config.testHooks === true;
@@ -5147,7 +5168,17 @@ function UIBridgeNativeProvider({
5147
5168
  serverPort: config.serverPort || 8087,
5148
5169
  cors: true,
5149
5170
  appInfo: config.appInfo,
5150
- testHooks: features.testHooks === true
5171
+ testHooks: features.testHooks === true,
5172
+ // Injected device-viewport getter for POST /control/page-health. The
5173
+ // server doesn't import `react-native` itself — the require/import
5174
+ // pattern there crashed the host RN app in 0.6.3/0.6.4 (Metro/Hermes
5175
+ // raised `unknownModuleError` past every try/catch). This provider
5176
+ // already has a live react-native import, so it's the safe injection
5177
+ // point. See feedback_metro_require_gotcha for the full incident.
5178
+ viewportProvider: () => {
5179
+ const win = reactNative.Dimensions.get("window");
5180
+ return { width: win.width, height: win.height };
5181
+ }
5151
5182
  });
5152
5183
  server.setAdapter(serverAdapter);
5153
5184
  if (navigationProvider) {
@@ -5242,7 +5273,11 @@ function UIBridgeNativeProvider({
5242
5273
  serverPort: config.serverPort || 8087,
5243
5274
  cors: true,
5244
5275
  appInfo: config.appInfo,
5245
- testHooks: features.testHooks === true
5276
+ testHooks: features.testHooks === true,
5277
+ viewportProvider: () => {
5278
+ const win = reactNative.Dimensions.get("window");
5279
+ return { width: win.width, height: win.height };
5280
+ }
5246
5281
  });
5247
5282
  if (navigationProvider) bareServer.setNavigationProvider(navigationProvider);
5248
5283
  if (screenshotProvider) bareServer.setScreenshotProvider(screenshotProvider);