@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.
@@ -195,6 +195,10 @@ function extractHandlerNames(props) {
195
195
  if (!props) return [];
196
196
  return Object.keys(props).filter((k) => typeof props[k] === "function");
197
197
  }
198
+ function matchesCurrentRoute(registrationRoute, currentRoute) {
199
+ if (registrationRoute == null || registrationRoute === "") return true;
200
+ return registrationRoute === currentRoute;
201
+ }
198
202
 
199
203
  // src/design/design-inspector-native.ts
200
204
  function toCssValue(value) {
@@ -454,15 +458,9 @@ function success(data) {
454
458
  function error(message, code) {
455
459
  return { success: false, error: message, code, timestamp: Date.now() };
456
460
  }
457
- function createDesignHandlers(registry) {
461
+ function createDesignHandlers(registry, viewportProvider) {
458
462
  function getScreenDimensions() {
459
- try {
460
- const { Dimensions } = __require("react-native");
461
- const screen = Dimensions.get("screen");
462
- return { width: screen.width, height: screen.height };
463
- } catch {
464
- return { width: 0, height: 0 };
465
- }
463
+ return viewportProvider?.() ?? { width: 0, height: 0 };
466
464
  }
467
465
  return {
468
466
  // 1. GET /design/element/:id/styles
@@ -1092,15 +1090,6 @@ async function executeWorkflowStep(step, registry, executor) {
1092
1090
  };
1093
1091
  }
1094
1092
  }
1095
- function getWindowDimensions() {
1096
- try {
1097
- const { Dimensions } = __require("react-native");
1098
- const win = Dimensions.get("window");
1099
- return { width: win.width, height: win.height };
1100
- } catch {
1101
- return { width: 0, height: 0 };
1102
- }
1103
- }
1104
1093
  function success2(data) {
1105
1094
  return {
1106
1095
  success: true,
@@ -1117,7 +1106,7 @@ function error2(message, code) {
1117
1106
  };
1118
1107
  }
1119
1108
  function createServerHandlers(registry, executor, config) {
1120
- const designHandlers = createDesignHandlers(registry);
1109
+ const designHandlers = createDesignHandlers(registry, config?.viewportProvider);
1121
1110
  return {
1122
1111
  // Elements
1123
1112
  getElements: async (ctx) => {
@@ -1125,7 +1114,7 @@ function createServerHandlers(registry, executor, config) {
1125
1114
  const forRoute = ctx.query?.route || ctx.body?.route;
1126
1115
  let allElements = visibleOnly ? registry.getMountedVisibleElements() : registry.getAllElements();
1127
1116
  if (forRoute) {
1128
- allElements = allElements.filter((e) => e.registrationRoute === forRoute);
1117
+ allElements = allElements.filter((e) => matchesCurrentRoute(e.registrationRoute, forRoute));
1129
1118
  }
1130
1119
  const elements = allElements.map((e) => {
1131
1120
  const handlers = extractHandlerNames(e.props);
@@ -1308,7 +1297,7 @@ function createServerHandlers(registry, executor, config) {
1308
1297
  },
1309
1298
  getPageHealth: async (ctx) => {
1310
1299
  const bodyViewport = ctx.body?.viewport;
1311
- const viewport = bodyViewport ?? getWindowDimensions();
1300
+ const viewport = bodyViewport ?? config?.viewportProvider?.() ?? { width: 0, height: 0 };
1312
1301
  const elements = registry.getAllElements().map((e) => ({
1313
1302
  type: e.type,
1314
1303
  state: e.getState()
@@ -2279,7 +2268,8 @@ var NativeUIBridgeServer = class {
2279
2268
  this.handlers = createServerHandlers(registry, executor, {
2280
2269
  appInfo: this.config.appInfo,
2281
2270
  consoleErrorBuffer: this.consoleErrorBuffer,
2282
- networkRequestBuffer: this.networkRequestBuffer
2271
+ networkRequestBuffer: this.networkRequestBuffer,
2272
+ viewportProvider: this.config.viewportProvider
2283
2273
  });
2284
2274
  this.handlers.getMethods = async () => {
2285
2275
  const testHooks = this.config.testHooks === true;