@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.
- package/dist/control/action-executor.d.ts.map +1 -1
- package/dist/control/index.js +2 -1
- package/dist/control/index.js.map +1 -1
- package/dist/control/index.mjs +2 -1
- package/dist/control/index.mjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +61 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -11
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.js +19 -10
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +19 -10
- package/dist/react/index.mjs.map +1 -1
- package/dist/server/bind-retry.d.ts +64 -0
- package/dist/server/bind-retry.d.ts.map +1 -0
- package/dist/server/handlers.d.ts.map +1 -1
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +59 -9
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +58 -10
- package/dist/server/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -987,9 +987,10 @@ var DefaultNativeActionExecutor = class {
|
|
|
987
987
|
requestId: request.requestId,
|
|
988
988
|
durationMs: successTime - startTime
|
|
989
989
|
});
|
|
990
|
+
const fresh = this.registry.getElement(registered.id) ?? registered;
|
|
990
991
|
return {
|
|
991
992
|
success: true,
|
|
992
|
-
elementState:
|
|
993
|
+
elementState: fresh.getState(),
|
|
993
994
|
result,
|
|
994
995
|
durationMs: successTime - startTime,
|
|
995
996
|
timestamp: successTime,
|
|
@@ -2160,6 +2161,13 @@ function matchElementsByText(registry, text, opts) {
|
|
|
2160
2161
|
scored.sort((a, b) => a.rank - b.rank);
|
|
2161
2162
|
return scored.map((s) => s.element);
|
|
2162
2163
|
}
|
|
2164
|
+
function resolveElementState(element) {
|
|
2165
|
+
const state = element.getState();
|
|
2166
|
+
if (element.type === "input" && state.value === void 0 && typeof element.props?.value === "string") {
|
|
2167
|
+
return { ...state, value: element.props.value };
|
|
2168
|
+
}
|
|
2169
|
+
return state;
|
|
2170
|
+
}
|
|
2163
2171
|
async function executeWorkflowStep(step, registry, executor) {
|
|
2164
2172
|
const startTime = Date.now();
|
|
2165
2173
|
try {
|
|
@@ -2396,7 +2404,7 @@ function createServerHandlers(registry, executor, config) {
|
|
|
2396
2404
|
type: element.type,
|
|
2397
2405
|
label: element.label,
|
|
2398
2406
|
identifier: element.getIdentifier(),
|
|
2399
|
-
state: element
|
|
2407
|
+
state: resolveElementState(element),
|
|
2400
2408
|
actions: element.actions,
|
|
2401
2409
|
customActions: element.customActions ? Object.keys(element.customActions) : void 0,
|
|
2402
2410
|
registeredHandlers: handlers.length > 0 ? handlers : void 0,
|
|
@@ -2410,18 +2418,19 @@ function createServerHandlers(registry, executor, config) {
|
|
|
2410
2418
|
if (!element) {
|
|
2411
2419
|
return error2(`Element not found: ${id}`, "ELEMENT_NOT_FOUND");
|
|
2412
2420
|
}
|
|
2413
|
-
return success2({ state: element
|
|
2421
|
+
return success2({ state: resolveElementState(element) });
|
|
2414
2422
|
},
|
|
2415
2423
|
executeAction: async (ctx) => {
|
|
2416
|
-
const
|
|
2417
|
-
const
|
|
2418
|
-
|
|
2424
|
+
const rawBody = ctx.body ?? {};
|
|
2425
|
+
const envelope = rawBody.request && typeof rawBody.request === "object" ? rawBody.request : rawBody;
|
|
2426
|
+
const id = ctx.params.id ?? rawBody.id ?? "";
|
|
2427
|
+
if (!envelope?.action) {
|
|
2419
2428
|
return error2("Action is required", "INVALID_REQUEST");
|
|
2420
2429
|
}
|
|
2421
2430
|
const response = await executor.executeAction(id, {
|
|
2422
|
-
action:
|
|
2423
|
-
params:
|
|
2424
|
-
waitOptions:
|
|
2431
|
+
action: envelope.action,
|
|
2432
|
+
params: envelope.params,
|
|
2433
|
+
waitOptions: envelope.waitOptions
|
|
2425
2434
|
});
|
|
2426
2435
|
if (!response.success) {
|
|
2427
2436
|
return error2(response.error || "Action failed", "ACTION_FAILED");
|
|
@@ -3060,7 +3069,7 @@ function createServerHandlers(registry, executor, config) {
|
|
|
3060
3069
|
};
|
|
3061
3070
|
if (config?.appInfo) {
|
|
3062
3071
|
response.uiBridge = {
|
|
3063
|
-
version: "0.
|
|
3072
|
+
version: "0.6.10",
|
|
3064
3073
|
...config.appInfo,
|
|
3065
3074
|
capabilities: ["elements", "components", "actions", "design"],
|
|
3066
3075
|
elementCount: stats.elements,
|
|
@@ -6632,6 +6641,46 @@ function decodeTextPayload(payload) {
|
|
|
6632
6641
|
return new TextDecoder().decode(payload);
|
|
6633
6642
|
}
|
|
6634
6643
|
|
|
6644
|
+
// src/server/bind-retry.ts
|
|
6645
|
+
function isAddrInUseError(err) {
|
|
6646
|
+
const message = err instanceof Error ? err.message : typeof err === "string" ? err : String(err);
|
|
6647
|
+
const code = err?.code;
|
|
6648
|
+
return message.includes("EADDRINUSE") || message.toLowerCase().includes("address already in use") || code === "EADDRINUSE";
|
|
6649
|
+
}
|
|
6650
|
+
var defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
6651
|
+
async function bindWithRetry(attempt, options = {}) {
|
|
6652
|
+
const {
|
|
6653
|
+
minTotalMs = 3e4,
|
|
6654
|
+
initialDelayMs = 500,
|
|
6655
|
+
maxDelayMs = 5e3,
|
|
6656
|
+
backoffFactor = 2,
|
|
6657
|
+
logger = console,
|
|
6658
|
+
sleep: sleep2 = defaultSleep,
|
|
6659
|
+
now = Date.now
|
|
6660
|
+
} = options;
|
|
6661
|
+
const startedAt = now();
|
|
6662
|
+
let delay = initialDelayMs;
|
|
6663
|
+
let attemptIndex = 0;
|
|
6664
|
+
for (; ; ) {
|
|
6665
|
+
try {
|
|
6666
|
+
await attempt(attemptIndex);
|
|
6667
|
+
return;
|
|
6668
|
+
} catch (err) {
|
|
6669
|
+
const elapsed = now() - startedAt;
|
|
6670
|
+
const budgetExhausted = elapsed + delay >= minTotalMs;
|
|
6671
|
+
if (!isAddrInUseError(err) || budgetExhausted) {
|
|
6672
|
+
throw err;
|
|
6673
|
+
}
|
|
6674
|
+
logger.warn(
|
|
6675
|
+
`[ui-bridge-native] bind failed with EADDRINUSE (attempt ${attemptIndex + 1}); retrying in ${delay}ms (elapsed ${elapsed}ms / budget ${minTotalMs === Infinity ? "\u221E" : minTotalMs}ms)`
|
|
6676
|
+
);
|
|
6677
|
+
await sleep2(delay);
|
|
6678
|
+
delay = Math.min(delay * backoffFactor, maxDelayMs);
|
|
6679
|
+
attemptIndex += 1;
|
|
6680
|
+
}
|
|
6681
|
+
}
|
|
6682
|
+
}
|
|
6683
|
+
|
|
6635
6684
|
// src/server/ws-connection.ts
|
|
6636
6685
|
var WebSocketConnection = class {
|
|
6637
6686
|
constructor(id, socket, onMessage, onClose) {
|
|
@@ -7213,6 +7262,7 @@ exports.UI_BRIDGE_NATIVE_ROUTES = UI_BRIDGE_NATIVE_ROUTES;
|
|
|
7213
7262
|
exports.UndoTracker = UndoTracker;
|
|
7214
7263
|
exports.WebSocketConnection = WebSocketConnection;
|
|
7215
7264
|
exports.WebSocketEventBridge = WebSocketEventBridge;
|
|
7265
|
+
exports.bindWithRetry = bindWithRetry;
|
|
7216
7266
|
exports.buildTreePath = buildTreePath;
|
|
7217
7267
|
exports.buildUpgradeResponse = buildUpgradeResponse;
|
|
7218
7268
|
exports.captureNativeResponsiveSnapshot = captureNativeResponsiveSnapshot;
|
|
@@ -7228,6 +7278,7 @@ exports.findAllByPattern = findAllByPattern;
|
|
|
7228
7278
|
exports.findElementByIdentifier = findElementByIdentifier;
|
|
7229
7279
|
exports.getGlobalRegistry = getGlobalRegistry;
|
|
7230
7280
|
exports.getNativeElementDesignData = getNativeElementDesignData;
|
|
7281
|
+
exports.isAddrInUseError = isAddrInUseError;
|
|
7231
7282
|
exports.mapNativeStyleToExtended = mapNativeStyleToExtended;
|
|
7232
7283
|
exports.matchesIdentifier = matchesIdentifier;
|
|
7233
7284
|
exports.parseTreePath = parseTreePath;
|