@qontinui/ui-bridge-native 0.6.7 → 0.6.8
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/index.js +128 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +128 -0
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.js +128 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +128 -0
- package/dist/react/index.mjs.map +1 -1
- package/dist/server/handlers.d.ts.map +1 -1
- package/dist/server/http-server.d.ts.map +1 -1
- package/dist/server/index.js +128 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +128 -0
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/types.d.ts +16 -0
- package/dist/server/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/react/index.mjs
CHANGED
|
@@ -2043,6 +2043,35 @@ function diagnosePageHealth(elements, viewport) {
|
|
|
2043
2043
|
}
|
|
2044
2044
|
|
|
2045
2045
|
// src/server/handlers.ts
|
|
2046
|
+
function matchElementsByText(registry, text, opts) {
|
|
2047
|
+
const needle = text.toLowerCase();
|
|
2048
|
+
const contains = (v) => typeof v === "string" && v.toLowerCase().includes(needle);
|
|
2049
|
+
let all = registry.getAllElements();
|
|
2050
|
+
if (opts?.visibleOnly) {
|
|
2051
|
+
all = all.filter((e) => e.getState().visible);
|
|
2052
|
+
}
|
|
2053
|
+
const scored = [];
|
|
2054
|
+
for (const e of all) {
|
|
2055
|
+
let rank = Number.POSITIVE_INFINITY;
|
|
2056
|
+
if (contains(e.label)) rank = Math.min(rank, 0);
|
|
2057
|
+
const ident = e.getIdentifier();
|
|
2058
|
+
if (ident) {
|
|
2059
|
+
if (contains(ident.testId)) rank = Math.min(rank, 1);
|
|
2060
|
+
if (contains(ident.accessibilityLabel)) rank = Math.min(rank, 1);
|
|
2061
|
+
if (contains(ident.treePath)) rank = Math.min(rank, 1);
|
|
2062
|
+
if (contains(ident.uiId)) rank = Math.min(rank, 1);
|
|
2063
|
+
}
|
|
2064
|
+
if (rank === Number.POSITIVE_INFINITY) {
|
|
2065
|
+
const handlers = extractHandlerNames(e.props);
|
|
2066
|
+
if (handlers.some((h) => h.toLowerCase().includes(needle))) rank = 2;
|
|
2067
|
+
}
|
|
2068
|
+
if (rank !== Number.POSITIVE_INFINITY) {
|
|
2069
|
+
scored.push({ rank, element: { id: e.id, type: e.type, label: e.label } });
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
scored.sort((a, b) => a.rank - b.rank);
|
|
2073
|
+
return scored.map((s) => s.element);
|
|
2074
|
+
}
|
|
2046
2075
|
async function executeWorkflowStep(step, registry, executor) {
|
|
2047
2076
|
const startTime = Date.now();
|
|
2048
2077
|
try {
|
|
@@ -2639,6 +2668,89 @@ function createServerHandlers(registry, executor, config) {
|
|
|
2639
2668
|
const failedCount = results.length - succeededCount;
|
|
2640
2669
|
return success2({ results, succeededCount, failedCount });
|
|
2641
2670
|
},
|
|
2671
|
+
// ========================================================================
|
|
2672
|
+
// App-agnostic interaction parity (cross-platform `/control/page/*`)
|
|
2673
|
+
//
|
|
2674
|
+
// Mirrors the web/runner convenience endpoints so the SAME contract drives
|
|
2675
|
+
// mobile. Text/label interactions compose `executor.find` (registry-based
|
|
2676
|
+
// discovery) + `executor.executeAction` (press/type). Selector-only
|
|
2677
|
+
// variants have no React-Native analog and return NOT_SUPPORTED — the
|
|
2678
|
+
// mobile bridge's snapshot + `/control/find` (testID / accessibilityLabel)
|
|
2679
|
+
// cover what a selector would on web.
|
|
2680
|
+
// ========================================================================
|
|
2681
|
+
clickByText: async (ctx) => {
|
|
2682
|
+
const body = ctx.body;
|
|
2683
|
+
const text = typeof body?.text === "string" ? body.text.trim() : "";
|
|
2684
|
+
if (!text) {
|
|
2685
|
+
return error2("text is required and must not be empty", "INVALID_REQUEST");
|
|
2686
|
+
}
|
|
2687
|
+
const match = matchElementsByText(registry, text, { visibleOnly: body?.visibleOnly })[0];
|
|
2688
|
+
if (!match) {
|
|
2689
|
+
return error2(`No element found with text "${text}"`, "ELEMENT_NOT_FOUND");
|
|
2690
|
+
}
|
|
2691
|
+
const response = await executor.executeAction(match.id, { action: "press" });
|
|
2692
|
+
if (!response.success) {
|
|
2693
|
+
return error2(response.error || "Press failed", "ACTION_FAILED");
|
|
2694
|
+
}
|
|
2695
|
+
return success2({
|
|
2696
|
+
clicked: true,
|
|
2697
|
+
element: { id: match.id, type: match.type, label: match.label }
|
|
2698
|
+
});
|
|
2699
|
+
},
|
|
2700
|
+
clickBySelector: async () => {
|
|
2701
|
+
return error2(
|
|
2702
|
+
"clickBySelector is not supported on native platform \u2014 React Native has no CSS-selector DOM. Use clickByText, or /control/find with testIdPattern/accessibilityLabelPattern then /control/element/:id/action.",
|
|
2703
|
+
"NOT_SUPPORTED"
|
|
2704
|
+
);
|
|
2705
|
+
},
|
|
2706
|
+
typeInto: async (ctx) => {
|
|
2707
|
+
const body = ctx.body;
|
|
2708
|
+
const label = typeof body?.label === "string" ? body.label.trim() : "";
|
|
2709
|
+
if (!label) {
|
|
2710
|
+
return error2(
|
|
2711
|
+
"label is required on native (selector-based typeInto is web-only)",
|
|
2712
|
+
"INVALID_REQUEST"
|
|
2713
|
+
);
|
|
2714
|
+
}
|
|
2715
|
+
const text = typeof body?.text === "string" ? body.text : "";
|
|
2716
|
+
const match = matchElementsByText(registry, label, { visibleOnly: body?.visibleOnly })[0];
|
|
2717
|
+
if (!match) {
|
|
2718
|
+
return error2(`No input found for label "${label}"`, "ELEMENT_NOT_FOUND");
|
|
2719
|
+
}
|
|
2720
|
+
const response = await executor.executeAction(match.id, {
|
|
2721
|
+
action: "type",
|
|
2722
|
+
params: { text, clear: body?.clear === true }
|
|
2723
|
+
});
|
|
2724
|
+
if (!response.success) {
|
|
2725
|
+
return error2(response.error || "Type failed", "ACTION_FAILED");
|
|
2726
|
+
}
|
|
2727
|
+
return success2({
|
|
2728
|
+
typed: true,
|
|
2729
|
+
element: { id: match.id, type: match.type, label: match.label }
|
|
2730
|
+
});
|
|
2731
|
+
},
|
|
2732
|
+
readValue: async () => {
|
|
2733
|
+
return error2(
|
|
2734
|
+
"readValue is not supported on native platform \u2014 React Native has no CSS-selector DOM. Use /control/element/:id/state to read an element value.",
|
|
2735
|
+
"NOT_SUPPORTED"
|
|
2736
|
+
);
|
|
2737
|
+
},
|
|
2738
|
+
findByText: async (ctx) => {
|
|
2739
|
+
const body = ctx.body;
|
|
2740
|
+
const text = typeof body?.text === "string" ? body.text.trim() : "";
|
|
2741
|
+
if (!text) {
|
|
2742
|
+
return error2("text is required and must not be empty", "INVALID_REQUEST");
|
|
2743
|
+
}
|
|
2744
|
+
const matches = matchElementsByText(registry, text, { visibleOnly: body?.visibleOnly });
|
|
2745
|
+
return success2(
|
|
2746
|
+
matches.map((el, index) => ({
|
|
2747
|
+
index,
|
|
2748
|
+
id: el.id,
|
|
2749
|
+
type: el.type,
|
|
2750
|
+
label: el.label
|
|
2751
|
+
}))
|
|
2752
|
+
);
|
|
2753
|
+
},
|
|
2642
2754
|
// Coord-based tap
|
|
2643
2755
|
//
|
|
2644
2756
|
// Synthesizes a press at the given screen coordinates by scanning the
|
|
@@ -3245,6 +3357,17 @@ var WS_ROUTES = [
|
|
|
3245
3357
|
// Coord-based tap — synthesizes a press at the given screen coords by
|
|
3246
3358
|
// matching against registered elements' layout rects.
|
|
3247
3359
|
{ pattern: "control/tap", handler: "tapAt", httpMethods: ["POST"] },
|
|
3360
|
+
// App-agnostic interaction parity — mirrors the web/runner convenience
|
|
3361
|
+
// endpoints (`/control/page/click-by-text` etc.) so the SAME cross-platform
|
|
3362
|
+
// contract drives mobile. Text/label-based interactions compose
|
|
3363
|
+
// `executor.find` + `executor.executeAction` over the registry; the
|
|
3364
|
+
// DOM-selector-only variants (`click-by-selector`, `read-value`) have no RN
|
|
3365
|
+
// analog and return a structured NOT_SUPPORTED envelope.
|
|
3366
|
+
{ pattern: "control/page/click-by-text", handler: "clickByText", httpMethods: ["POST"] },
|
|
3367
|
+
{ pattern: "control/page/click-by-selector", handler: "clickBySelector", httpMethods: ["POST"] },
|
|
3368
|
+
{ pattern: "control/page/type-into", handler: "typeInto", httpMethods: ["POST"] },
|
|
3369
|
+
{ pattern: "control/page/read-value", handler: "readValue", httpMethods: ["POST"] },
|
|
3370
|
+
{ pattern: "control/page/find-by-text", handler: "findByText", httpMethods: ["POST"] },
|
|
3248
3371
|
// Test hooks — gated behind `features.testHooks`. Let external runners
|
|
3249
3372
|
// drive the ModalDetector over HTTP so tests can flip `snapshot.modalStack`
|
|
3250
3373
|
// without mounting React components.
|
|
@@ -3320,6 +3443,11 @@ var HANDLER_DESCRIPTIONS = {
|
|
|
3320
3443
|
aiChangeBufferEnable: "STUB \u2014 runner-only; mobile returns NOT_SUPPORTED. Use WS event subscriptions for change notifications.",
|
|
3321
3444
|
aiWaitForElement: "STUB \u2014 runner-only; mobile returns NOT_SUPPORTED. Use the WS waitForElement / waitForCondition JSON-RPC methods.",
|
|
3322
3445
|
tapAt: "Synthesize a press at given screen coords by matching registered element layout rects: body { x, y, action? }",
|
|
3446
|
+
clickByText: "App-agnostic: press the first element matching free-text (label/accessibilityLabel/testID): body { text, visibleOnly? }",
|
|
3447
|
+
clickBySelector: "STUB \u2014 selector-based; NOT_SUPPORTED on native (no DOM). Use clickByText or /control/find + /control/element/:id/action.",
|
|
3448
|
+
typeInto: "App-agnostic: type into the input matching a label: body { label, text, clear?, visibleOnly? }. (selector form is web-only)",
|
|
3449
|
+
readValue: "STUB \u2014 selector-based; NOT_SUPPORTED on native (no DOM). Use /control/element/:id/state to read a value.",
|
|
3450
|
+
findByText: "App-agnostic: list elements matching free-text (no press): body { text, visibleOnly? }",
|
|
3323
3451
|
getConsoleErrors: "TEST HOOK \u2014 last-N console.error/console.warn entries; ?since=<ms>&limit=<n>",
|
|
3324
3452
|
getNetworkRequests: "TEST HOOK \u2014 last-N fetch/XHR entries with status + duration; ?since=<ms>&limit=<n>",
|
|
3325
3453
|
pushModal: "TEST HOOK \u2014 push a modal onto the snapshot.modalStack via the registry ModalDetector",
|