@qontinui/ui-bridge-native 0.6.5 → 0.6.7

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.
@@ -42,6 +42,26 @@ export interface NativeDesignHandlers {
42
42
  }
43
43
  /**
44
44
  * Create design review handlers.
45
+ *
46
+ * @param registry - the registered native element registry
47
+ * @param viewportProvider - optional injected viewport getter. Same shape as
48
+ * the `viewportProvider` consumed by `handlers.ts`/`getPageHealth`. This is
49
+ * injected by `createServerHandlers` from the `NativeServerConfig` the host
50
+ * passes to `UIBridgeNativeProvider`/`NativeUIBridgeServer`, which in turn
51
+ * reads `Dimensions.get('screen')` (or `'window'`). The indirection exists
52
+ * because `require('react-native')` from this file crashes the host RN
53
+ * app the moment any design endpoint is invoked: Metro/Hermes raise
54
+ * `unknownModuleError` past every try/catch and tear down the JS thread.
55
+ * This was the same latent crash that took out 0.6.3/0.6.4 page-health
56
+ * handler — the design handlers had it too, just hiding on unused
57
+ * endpoints until `POST /design/responsive` was first called.
58
+ *
59
+ * When the injected provider is absent (tests, custom hosts) the design
60
+ * handlers fall back to `{width:0, height:0}` — the responsive snapshot
61
+ * degenerates to "zero-dimension viewport" rather than crashing.
45
62
  */
46
- export declare function createDesignHandlers(registry: NativeUIBridgeRegistry): NativeDesignHandlers;
63
+ export declare function createDesignHandlers(registry: NativeUIBridgeRegistry, viewportProvider?: () => {
64
+ width: number;
65
+ height: number;
66
+ }): NativeDesignHandlers;
47
67
  //# sourceMappingURL=design-handlers.d.ts.map
@@ -1 +1 @@
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,EA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CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACzD,oBAAoB,CAwStB"}
@@ -1 +1 @@
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;AAQpF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,KAAK,EAQV,oBAAoB,EAKrB,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAiQhF;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,sBAAsB,EAChC,QAAQ,EAAE,oBAAoB,EAC9B,MAAM,CAAC,EAAE;IACP,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,CAAC;IAClF,iFAAiF;IACjF,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,iFAAiF;IACjF,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C;;;;;;;;;OASG;IACH,gBAAgB,CAAC,EAAE,MAAM;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5D,GACA,oBAAoB,CA80BtB"}
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/server/handlers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,KAAK,sBAAsB,EAG5B,MAAM,kBAAkB,CAAC;AAQ1B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,KAAK,EAQV,oBAAoB,EAKrB,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAiQhF;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,sBAAsB,EAChC,QAAQ,EAAE,oBAAoB,EAC9B,MAAM,CAAC,EAAE;IACP,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,CAAC;IAClF,iFAAiF;IACjF,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,iFAAiF;IACjF,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C;;;;;;;;;OASG;IACH,gBAAgB,CAAC,EAAE,MAAM;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5D,GACA,oBAAoB,CAy1BtB"}
@@ -197,6 +197,10 @@ function extractHandlerNames(props) {
197
197
  if (!props) return [];
198
198
  return Object.keys(props).filter((k) => typeof props[k] === "function");
199
199
  }
200
+ function matchesCurrentRoute(registrationRoute, currentRoute) {
201
+ if (registrationRoute == null || registrationRoute === "") return true;
202
+ return registrationRoute === currentRoute;
203
+ }
200
204
 
201
205
  // src/design/design-inspector-native.ts
202
206
  function toCssValue(value) {
@@ -456,15 +460,9 @@ function success(data) {
456
460
  function error(message, code) {
457
461
  return { success: false, error: message, code, timestamp: Date.now() };
458
462
  }
459
- function createDesignHandlers(registry) {
463
+ function createDesignHandlers(registry, viewportProvider) {
460
464
  function getScreenDimensions() {
461
- try {
462
- const { Dimensions } = __require("react-native");
463
- const screen = Dimensions.get("screen");
464
- return { width: screen.width, height: screen.height };
465
- } catch {
466
- return { width: 0, height: 0 };
467
- }
465
+ return viewportProvider?.() ?? { width: 0, height: 0 };
468
466
  }
469
467
  return {
470
468
  // 1. GET /design/element/:id/styles
@@ -892,7 +890,7 @@ function diagnosePageHealth(elements, viewport) {
892
890
  let outsideViewport = 0;
893
891
  for (const { rect } of visible) {
894
892
  if (rect.width === 0 || rect.height === 0) zeroSize++;
895
- if (rect.x + rect.width < 0 || rect.y + rect.height < 0 || rect.x > 1 || rect.y > 1) {
893
+ if (rect.x + rect.width < 0 || rect.x > 1) {
896
894
  outsideViewport++;
897
895
  }
898
896
  }
@@ -900,7 +898,7 @@ function diagnosePageHealth(elements, viewport) {
900
898
  findings.push({
901
899
  check: "visual_anomalies",
902
900
  severity: anomalySeverity,
903
- detail: `zero_size=${zeroSize}, outside_viewport=${outsideViewport}`,
901
+ detail: `zero_size=${zeroSize}, outside_viewport=${outsideViewport} (horizontal-overflow only; below/above-fold scrollable content is not an anomaly)`,
904
902
  data: { zero_size: zeroSize, outside_viewport: outsideViewport }
905
903
  });
906
904
  const heatmap = grid.map(
@@ -1110,7 +1108,7 @@ function error2(message, code) {
1110
1108
  };
1111
1109
  }
1112
1110
  function createServerHandlers(registry, executor, config) {
1113
- const designHandlers = createDesignHandlers(registry);
1111
+ const designHandlers = createDesignHandlers(registry, config?.viewportProvider);
1114
1112
  return {
1115
1113
  // Elements
1116
1114
  getElements: async (ctx) => {
@@ -1118,7 +1116,7 @@ function createServerHandlers(registry, executor, config) {
1118
1116
  const forRoute = ctx.query?.route || ctx.body?.route;
1119
1117
  let allElements = visibleOnly ? registry.getMountedVisibleElements() : registry.getAllElements();
1120
1118
  if (forRoute) {
1121
- allElements = allElements.filter((e) => e.registrationRoute === forRoute);
1119
+ allElements = allElements.filter((e) => matchesCurrentRoute(e.registrationRoute, forRoute));
1122
1120
  }
1123
1121
  const elements = allElements.map((e) => {
1124
1122
  const handlers = extractHandlerNames(e.props);