@qontinui/ui-bridge-native 0.6.9 → 0.6.10

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.
@@ -958,6 +958,13 @@ function matchElementsByText(registry, text, opts) {
958
958
  scored.sort((a, b) => a.rank - b.rank);
959
959
  return scored.map((s) => s.element);
960
960
  }
961
+ function resolveElementState(element) {
962
+ const state = element.getState();
963
+ if (element.type === "input" && state.value === void 0 && typeof element.props?.value === "string") {
964
+ return { ...state, value: element.props.value };
965
+ }
966
+ return state;
967
+ }
961
968
  async function executeWorkflowStep(step, registry, executor) {
962
969
  const startTime = Date.now();
963
970
  try {
@@ -1194,7 +1201,7 @@ function createServerHandlers(registry, executor, config) {
1194
1201
  type: element.type,
1195
1202
  label: element.label,
1196
1203
  identifier: element.getIdentifier(),
1197
- state: element.getState(),
1204
+ state: resolveElementState(element),
1198
1205
  actions: element.actions,
1199
1206
  customActions: element.customActions ? Object.keys(element.customActions) : void 0,
1200
1207
  registeredHandlers: handlers.length > 0 ? handlers : void 0,
@@ -1208,18 +1215,19 @@ function createServerHandlers(registry, executor, config) {
1208
1215
  if (!element) {
1209
1216
  return error2(`Element not found: ${id}`, "ELEMENT_NOT_FOUND");
1210
1217
  }
1211
- return success2({ state: element.getState() });
1218
+ return success2({ state: resolveElementState(element) });
1212
1219
  },
1213
1220
  executeAction: async (ctx) => {
1214
- const { id } = ctx.params;
1215
- const body = ctx.body;
1216
- if (!body?.action) {
1221
+ const rawBody = ctx.body ?? {};
1222
+ const envelope = rawBody.request && typeof rawBody.request === "object" ? rawBody.request : rawBody;
1223
+ const id = ctx.params.id ?? rawBody.id ?? "";
1224
+ if (!envelope?.action) {
1217
1225
  return error2("Action is required", "INVALID_REQUEST");
1218
1226
  }
1219
1227
  const response = await executor.executeAction(id, {
1220
- action: body.action,
1221
- params: body.params,
1222
- waitOptions: body.waitOptions
1228
+ action: envelope.action,
1229
+ params: envelope.params,
1230
+ waitOptions: envelope.waitOptions
1223
1231
  });
1224
1232
  if (!response.success) {
1225
1233
  return error2(response.error || "Action failed", "ACTION_FAILED");
@@ -1858,7 +1866,7 @@ function createServerHandlers(registry, executor, config) {
1858
1866
  };
1859
1867
  if (config?.appInfo) {
1860
1868
  response.uiBridge = {
1861
- version: "0.3.0",
1869
+ version: "0.6.10",
1862
1870
  ...config.appInfo,
1863
1871
  capabilities: ["elements", "components", "actions", "design"],
1864
1872
  elementCount: stats.elements,
@@ -3984,6 +3992,46 @@ var WebSocketConnection = class {
3984
3992
  }
3985
3993
  };
3986
3994
 
3987
- export { ConsoleErrorBuffer, NativeUIBridgeServer, NetworkRequestBuffer, OPCODE_BINARY, OPCODE_CLOSE, OPCODE_CONTINUATION, OPCODE_PING, OPCODE_PONG, OPCODE_TEXT, UI_BRIDGE_NATIVE_ROUTES, WebSocketConnection, WebSocketEventBridge, buildUpgradeResponse, computeAcceptKey, createDesignHandlers, createNativeServer, createServerHandlers, decodeFrames, decodeTextPayload, encodeCloseFrame, encodePingFrame, encodePongFrame, encodeTextFrame, isBatchRequest, isSubscribe, isUnsubscribe };
3995
+ // src/server/bind-retry.ts
3996
+ function isAddrInUseError(err) {
3997
+ const message = err instanceof Error ? err.message : typeof err === "string" ? err : String(err);
3998
+ const code = err?.code;
3999
+ return message.includes("EADDRINUSE") || message.toLowerCase().includes("address already in use") || code === "EADDRINUSE";
4000
+ }
4001
+ var defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
4002
+ async function bindWithRetry(attempt, options = {}) {
4003
+ const {
4004
+ minTotalMs = 3e4,
4005
+ initialDelayMs = 500,
4006
+ maxDelayMs = 5e3,
4007
+ backoffFactor = 2,
4008
+ logger = console,
4009
+ sleep = defaultSleep,
4010
+ now = Date.now
4011
+ } = options;
4012
+ const startedAt = now();
4013
+ let delay = initialDelayMs;
4014
+ let attemptIndex = 0;
4015
+ for (; ; ) {
4016
+ try {
4017
+ await attempt(attemptIndex);
4018
+ return;
4019
+ } catch (err) {
4020
+ const elapsed = now() - startedAt;
4021
+ const budgetExhausted = elapsed + delay >= minTotalMs;
4022
+ if (!isAddrInUseError(err) || budgetExhausted) {
4023
+ throw err;
4024
+ }
4025
+ logger.warn(
4026
+ `[ui-bridge-native] bind failed with EADDRINUSE (attempt ${attemptIndex + 1}); retrying in ${delay}ms (elapsed ${elapsed}ms / budget ${minTotalMs === Infinity ? "\u221E" : minTotalMs}ms)`
4027
+ );
4028
+ await sleep(delay);
4029
+ delay = Math.min(delay * backoffFactor, maxDelayMs);
4030
+ attemptIndex += 1;
4031
+ }
4032
+ }
4033
+ }
4034
+
4035
+ export { ConsoleErrorBuffer, NativeUIBridgeServer, NetworkRequestBuffer, OPCODE_BINARY, OPCODE_CLOSE, OPCODE_CONTINUATION, OPCODE_PING, OPCODE_PONG, OPCODE_TEXT, UI_BRIDGE_NATIVE_ROUTES, WebSocketConnection, WebSocketEventBridge, bindWithRetry, buildUpgradeResponse, computeAcceptKey, createDesignHandlers, createNativeServer, createServerHandlers, decodeFrames, decodeTextPayload, encodeCloseFrame, encodePingFrame, encodePongFrame, encodeTextFrame, isAddrInUseError, isBatchRequest, isSubscribe, isUnsubscribe };
3988
4036
  //# sourceMappingURL=index.mjs.map
3989
4037
  //# sourceMappingURL=index.mjs.map