@appilots/sdk 0.6.0 → 0.8.0
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/README.md +41 -0
- package/dist/{chunk-DZ7QRFHD.js → chunk-AYWMBMSN.js} +255 -17
- package/dist/{chunk-R4D34FEW.mjs → chunk-C2KVVJ5K.mjs} +253 -17
- package/dist/{chunk-KYFAXT6V.js → chunk-H7BMQTXH.js} +5 -5
- package/dist/{chunk-KUFWRJC4.mjs → chunk-MHWVRZYF.mjs} +100 -35
- package/dist/{chunk-HFRIB4YN.js → chunk-N7EAOLBP.js} +259 -194
- package/dist/{chunk-DR75QTYK.mjs → chunk-ZSEACJKU.mjs} +1 -1
- package/dist/hooks/index.d.mts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +11 -11
- package/dist/hooks/index.mjs +2 -2
- package/dist/{index-nI-s3Exg.d.mts → index-BdYY-dvG.d.mts} +63 -11
- package/dist/{index-nI-s3Exg.d.ts → index-BdYY-dvG.d.ts} +63 -11
- package/dist/index.d.mts +30 -12
- package/dist/index.d.ts +30 -12
- package/dist/index.js +73 -68
- package/dist/index.mjs +11 -6
- package/dist/navigation/index.js +13 -13
- package/dist/navigation/index.mjs +2 -2
- package/package.json +13 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkAYWMBMSN_js = require('./chunk-AYWMBMSN.js');
|
|
4
4
|
var react = require('react');
|
|
5
5
|
var reactNative = require('react-native');
|
|
6
6
|
|
|
@@ -495,7 +495,7 @@ function walkSubtree(root, detectLists, startInModal = false) {
|
|
|
495
495
|
}
|
|
496
496
|
function walkFiber(root) {
|
|
497
497
|
const snapshot = {
|
|
498
|
-
route:
|
|
498
|
+
route: chunkAYWMBMSN_js.getCurrentScreen(),
|
|
499
499
|
texts: [],
|
|
500
500
|
inputs: [],
|
|
501
501
|
buttons: [],
|
|
@@ -671,9 +671,9 @@ function fiberSliderMatches(fiber, registryId, registryLabel) {
|
|
|
671
671
|
function reconcileSliders(snapshot) {
|
|
672
672
|
const fiberSliders = snapshot.sliders;
|
|
673
673
|
const out = [];
|
|
674
|
-
for (const { id, kind } of
|
|
674
|
+
for (const { id, kind } of chunkAYWMBMSN_js.componentRegistry.snapshot()) {
|
|
675
675
|
if (kind !== "slider") continue;
|
|
676
|
-
const entry =
|
|
676
|
+
const entry = chunkAYWMBMSN_js.componentRegistry.getSlider(id);
|
|
677
677
|
if (!entry) continue;
|
|
678
678
|
const fiber = fiberSliders.find((s) => fiberSliderMatches(s, id, entry.label));
|
|
679
679
|
const visible = !!fiber || typeof entry.screen === "string" && entry.screen === snapshot.route;
|
|
@@ -697,7 +697,7 @@ function reconcileSliders(snapshot) {
|
|
|
697
697
|
snapshot.sliders = out;
|
|
698
698
|
}
|
|
699
699
|
function mergeRegisteredLists(snapshot) {
|
|
700
|
-
const registered =
|
|
700
|
+
const registered = chunkAYWMBMSN_js.listRegistry.snapshot();
|
|
701
701
|
if (registered.length === 0) return;
|
|
702
702
|
const byId = /* @__PURE__ */ new Map();
|
|
703
703
|
for (const list of snapshot.lists) {
|
|
@@ -745,14 +745,14 @@ function mergeRegisteredLists(snapshot) {
|
|
|
745
745
|
}
|
|
746
746
|
}
|
|
747
747
|
function captureSnapshot() {
|
|
748
|
-
const root =
|
|
748
|
+
const root = chunkAYWMBMSN_js.getFiberRoot();
|
|
749
749
|
if (!root) {
|
|
750
750
|
console.warn(
|
|
751
751
|
"[Appilots] captureSnapshot: fiber root not captured yet. Ensure <AppilotsProvider> has rendered before calling this."
|
|
752
752
|
);
|
|
753
|
-
|
|
753
|
+
chunkAYWMBMSN_js.recordIntrospectionFailure("never-mounted", null);
|
|
754
754
|
return {
|
|
755
|
-
route:
|
|
755
|
+
route: chunkAYWMBMSN_js.getCurrentScreen(),
|
|
756
756
|
texts: [],
|
|
757
757
|
inputs: [],
|
|
758
758
|
buttons: [],
|
|
@@ -767,17 +767,19 @@ function captureSnapshot() {
|
|
|
767
767
|
}
|
|
768
768
|
const start = Date.now();
|
|
769
769
|
const snapshot = walkFiber(root);
|
|
770
|
-
const activePath =
|
|
770
|
+
const activePath = chunkAYWMBMSN_js.getActiveRouteNames();
|
|
771
771
|
const deepestRoute = activePath[activePath.length - 1];
|
|
772
772
|
if (deepestRoute) snapshot.route = deepestRoute;
|
|
773
773
|
mergeRegisteredLists(snapshot);
|
|
774
774
|
reconcileSliders(snapshot);
|
|
775
|
-
|
|
776
|
-
snapshot.
|
|
775
|
+
chunkAYWMBMSN_js.clampSnapshotToWireLimits(snapshot);
|
|
776
|
+
snapshot.elements = chunkAYWMBMSN_js.deriveInteractionElements(snapshot);
|
|
777
|
+
snapshot.choiceGroups = chunkAYWMBMSN_js.attachElementIdsToChoiceGroups(
|
|
777
778
|
snapshot.choiceGroups,
|
|
778
779
|
snapshot.elements
|
|
779
780
|
);
|
|
780
|
-
|
|
781
|
+
chunkAYWMBMSN_js.clampSnapshotToWireLimits(snapshot);
|
|
782
|
+
chunkAYWMBMSN_js.elementRegistry.replaceAll(snapshot.elements);
|
|
781
783
|
const elapsed = Date.now() - start;
|
|
782
784
|
const totalListItems = snapshot.lists.reduce(
|
|
783
785
|
(acc, l) => acc + l.items.length,
|
|
@@ -788,7 +790,7 @@ function captureSnapshot() {
|
|
|
788
790
|
0
|
|
789
791
|
);
|
|
790
792
|
console.log(
|
|
791
|
-
`[Appilots] captureSnapshot: route="${snapshot.route}" texts=${snapshot.texts.length} inputs=${snapshot.inputs.length} buttons=${snapshot.buttons.length} toggles=${snapshot.toggles.length} sliders=${snapshot.sliders.length} loading=${snapshot.loading} modal=${snapshot.modalOpen} lists=${snapshot.lists.length}(visibleItems=${totalListItems}, dataItems=${totalListDataItems}) choices=${snapshot.choiceGroups.length} elements=${snapshot.elements.length} (walked ${snapshot.stats?.visitedFibers ?? 0} fibers, skipped ${snapshot.stats?.skippedHidden ?? 0} hidden, ${elapsed}ms)`
|
|
793
|
+
`[Appilots] captureSnapshot: route="${snapshot.route}" texts=${snapshot.texts.length} inputs=${snapshot.inputs.length} buttons=${snapshot.buttons.length} toggles=${snapshot.toggles.length} sliders=${snapshot.sliders.length} loading=${snapshot.loading} modal=${snapshot.modalOpen} lists=${snapshot.lists.length}(visibleItems=${totalListItems}, dataItems=${totalListDataItems}) choices=${snapshot.choiceGroups.length} elements=${snapshot.elements.length} ` + (snapshot.truncated ? "truncated=true " : "") + `(walked ${snapshot.stats?.visitedFibers ?? 0} fibers, skipped ${snapshot.stats?.skippedHidden ?? 0} hidden, ${elapsed}ms)`
|
|
792
794
|
);
|
|
793
795
|
console.log(
|
|
794
796
|
`[Appilots] captureSnapshot detail: lists=[${snapshot.lists.map((l) => `${l.containerType}:${l.id ?? l.label ?? "?"}(${l.items.map((it) => it.texts[0] ?? it.buttons[0]?.id ?? "?").join("|")})`).join(", ")}] inputs=[${snapshot.inputs.map((i) => i.id ?? i.label ?? "?").slice(0, 12).join(", ")}] buttons=[${snapshot.buttons.map((b) => b.id ?? b.label ?? "?").slice(0, 15).join(", ")}]`
|
|
@@ -970,7 +972,7 @@ function wrapTouchable(fiber, label) {
|
|
|
970
972
|
};
|
|
971
973
|
}
|
|
972
974
|
function findInteractiveByIdentifier(query, options = {}) {
|
|
973
|
-
const root =
|
|
975
|
+
const root = chunkAYWMBMSN_js.getFiberRoot();
|
|
974
976
|
if (!root) {
|
|
975
977
|
console.warn("[Appilots] findInteractiveByIdentifier: fiber root not captured yet");
|
|
976
978
|
return null;
|
|
@@ -1211,7 +1213,7 @@ function isPressableFiber(fiber) {
|
|
|
1211
1213
|
return TOUCHABLE_NAMES.has(typeName) || hasPressHandler3(fiber);
|
|
1212
1214
|
}
|
|
1213
1215
|
function findListContainers(options = {}) {
|
|
1214
|
-
const root =
|
|
1216
|
+
const root = chunkAYWMBMSN_js.getFiberRoot();
|
|
1215
1217
|
if (!root) return [];
|
|
1216
1218
|
const containers = [];
|
|
1217
1219
|
const visited = /* @__PURE__ */ new WeakSet();
|
|
@@ -1370,7 +1372,7 @@ function describeTouchable(fiber) {
|
|
|
1370
1372
|
}
|
|
1371
1373
|
function touchableLooksDestructive(fiber) {
|
|
1372
1374
|
const descriptor = describeTouchable(fiber);
|
|
1373
|
-
if (descriptor &&
|
|
1375
|
+
if (descriptor && chunkAYWMBMSN_js.looksDestructiveActionLabel(descriptor)) return true;
|
|
1374
1376
|
const props = fiber?.memoizedProps ?? {};
|
|
1375
1377
|
const haystack = [
|
|
1376
1378
|
props.testID,
|
|
@@ -1378,7 +1380,7 @@ function touchableLooksDestructive(fiber) {
|
|
|
1378
1380
|
props.accessibilityHint,
|
|
1379
1381
|
props.label
|
|
1380
1382
|
].filter((value) => typeof value === "string").join(" ");
|
|
1381
|
-
return
|
|
1383
|
+
return chunkAYWMBMSN_js.looksDestructiveActionLabel(haystack);
|
|
1382
1384
|
}
|
|
1383
1385
|
function describeItemCandidate(listIndex, zeroBasedIndex, item) {
|
|
1384
1386
|
const syntheticId = `list-${listIndex}-item-${zeroBasedIndex + 1}`;
|
|
@@ -1509,7 +1511,7 @@ function candidateLists(containers, locator) {
|
|
|
1509
1511
|
return containers.map((list, listIndex) => ({ list, listIndex }));
|
|
1510
1512
|
}
|
|
1511
1513
|
function pressListItemAtOrdinal(listIndex, itemIndex) {
|
|
1512
|
-
if (!
|
|
1514
|
+
if (!chunkAYWMBMSN_js.getFiberRoot()) return { ok: false, reason: "no-fiber-root" };
|
|
1513
1515
|
const containers = findListContainers({ allowSingleHeuristic: true });
|
|
1514
1516
|
if (listIndex < 0 || listIndex >= containers.length) {
|
|
1515
1517
|
return { ok: false, reason: "list-not-found" };
|
|
@@ -1523,7 +1525,7 @@ function pressListItemAtOrdinal(listIndex, itemIndex) {
|
|
|
1523
1525
|
return pressResolvedListItem(list, items[zeroBased], listIndex, itemIndex);
|
|
1524
1526
|
}
|
|
1525
1527
|
function pressListItemByIdentity(locator) {
|
|
1526
|
-
if (!
|
|
1528
|
+
if (!chunkAYWMBMSN_js.getFiberRoot()) return { ok: false, reason: "no-fiber-root" };
|
|
1527
1529
|
const parsed = locator.syntheticId ? parseSyntheticListItemId(locator.syntheticId) : null;
|
|
1528
1530
|
const effective = parsed ? { ...locator, listIndex: parsed.listIndex, itemIndex: parsed.itemIndex } : locator;
|
|
1529
1531
|
const containers = findListContainers({ allowSingleHeuristic: true });
|
|
@@ -1563,7 +1565,7 @@ function screenDiagnose(targetId, category = "component-not-found") {
|
|
|
1563
1565
|
return {
|
|
1564
1566
|
category,
|
|
1565
1567
|
targetId,
|
|
1566
|
-
screen:
|
|
1568
|
+
screen: chunkAYWMBMSN_js.getCurrentScreen() ?? void 0
|
|
1567
1569
|
};
|
|
1568
1570
|
}
|
|
1569
1571
|
function isPressLike(action) {
|
|
@@ -1580,10 +1582,10 @@ function elementLookupKey(value) {
|
|
|
1580
1582
|
return canonicalElementId(value).toLowerCase().replace(/[\s_]+/g, "-");
|
|
1581
1583
|
}
|
|
1582
1584
|
function findRegisteredElement(elementId) {
|
|
1583
|
-
const direct =
|
|
1585
|
+
const direct = chunkAYWMBMSN_js.elementRegistry.get(elementId) ?? chunkAYWMBMSN_js.elementRegistry.get(canonicalElementId(elementId));
|
|
1584
1586
|
if (direct) return direct;
|
|
1585
1587
|
const wanted = elementLookupKey(elementId);
|
|
1586
|
-
return
|
|
1588
|
+
return chunkAYWMBMSN_js.elementRegistry.snapshot().find((element) => elementLookupKey(element.id) === wanted);
|
|
1587
1589
|
}
|
|
1588
1590
|
function resolveInteractionElement(elementId) {
|
|
1589
1591
|
return getLatestElement(elementId);
|
|
@@ -1803,7 +1805,7 @@ function dispatchElement(element, registry, action) {
|
|
|
1803
1805
|
}
|
|
1804
1806
|
function dispatchStructuredElementId(identifier, action) {
|
|
1805
1807
|
if (!isElementIdentifier(identifier) || !isPressLike(action)) return null;
|
|
1806
|
-
const parsed =
|
|
1808
|
+
const parsed = chunkAYWMBMSN_js.parseStableElementId(identifier);
|
|
1807
1809
|
if (!parsed || parsed.role !== "option") return null;
|
|
1808
1810
|
if (!parsed.itemKey && !parsed.listId) return null;
|
|
1809
1811
|
const pressed = pressListItemByIdentity({
|
|
@@ -1843,20 +1845,20 @@ function normalize4(value) {
|
|
|
1843
1845
|
return value.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9]/g, "");
|
|
1844
1846
|
}
|
|
1845
1847
|
function resolveScreenForFormFields() {
|
|
1846
|
-
const activePath =
|
|
1848
|
+
const activePath = chunkAYWMBMSN_js.getActiveRouteNames();
|
|
1847
1849
|
for (let i = activePath.length - 1; i >= 0; i--) {
|
|
1848
1850
|
const name = activePath[i];
|
|
1849
|
-
const meta = name ?
|
|
1851
|
+
const meta = name ? chunkAYWMBMSN_js.getScreenMetadata(name) : void 0;
|
|
1850
1852
|
if (name && Array.isArray(meta?.fields) && meta.fields.length > 0) return name;
|
|
1851
1853
|
}
|
|
1852
|
-
return
|
|
1854
|
+
return chunkAYWMBMSN_js.getCurrentScreen();
|
|
1853
1855
|
}
|
|
1854
1856
|
function collectKnownFormFields(registry) {
|
|
1855
1857
|
const registryFields = registry.snapshot().filter((entry) => entry.kind === "field" || entry.kind === "slider").map((entry) => ({ id: entry.id, label: entry.label }));
|
|
1856
1858
|
if (registryFields.length >= 2) return registryFields;
|
|
1857
1859
|
const screen = resolveScreenForFormFields();
|
|
1858
1860
|
if (screen) {
|
|
1859
|
-
const metaFields =
|
|
1861
|
+
const metaFields = chunkAYWMBMSN_js.getScreenMetadata(screen)?.fields;
|
|
1860
1862
|
if (Array.isArray(metaFields) && metaFields.length > 0) {
|
|
1861
1863
|
return metaFields.filter((field) => !!field && typeof field.id === "string").map((field) => ({
|
|
1862
1864
|
id: field.id,
|
|
@@ -1866,7 +1868,7 @@ function collectKnownFormFields(registry) {
|
|
|
1866
1868
|
}));
|
|
1867
1869
|
}
|
|
1868
1870
|
}
|
|
1869
|
-
for (const meta of
|
|
1871
|
+
for (const meta of chunkAYWMBMSN_js.getAllScreens()) {
|
|
1870
1872
|
if (Array.isArray(meta.fields) && meta.fields.length > 0) {
|
|
1871
1873
|
return meta.fields.filter((field) => !!field && typeof field.id === "string").map((field) => ({
|
|
1872
1874
|
id: field.id,
|
|
@@ -1964,7 +1966,7 @@ function rewriteMisplacedFormFillFields(fields, registry) {
|
|
|
1964
1966
|
const inferred = inferFieldIdForValue(String(field.value ?? ""), knownFields, used);
|
|
1965
1967
|
if (!inferred) return field;
|
|
1966
1968
|
used.add(inferred);
|
|
1967
|
-
|
|
1969
|
+
chunkAYWMBMSN_js.appilotsDebugWarn(
|
|
1968
1970
|
`formFieldRewrite: ${field.fieldId} \u2192 ${inferred} (value=${JSON.stringify(field.value)})`
|
|
1969
1971
|
);
|
|
1970
1972
|
return { ...field, fieldId: inferred };
|
|
@@ -2002,7 +2004,7 @@ function readVisibleFormSuccess(snap) {
|
|
|
2002
2004
|
return (snap.texts ?? []).find((text) => text?.trim() && FORM_SUCCESS_TEXT_RE.test(text));
|
|
2003
2005
|
}
|
|
2004
2006
|
function submitAsyncStillPending(submitTargetId) {
|
|
2005
|
-
const probe =
|
|
2007
|
+
const probe = chunkAYWMBMSN_js.probeLoadingState(submitTargetId ?? null, chunkAYWMBMSN_js.getCurrentScreen());
|
|
2006
2008
|
if (probe.loading) return true;
|
|
2007
2009
|
if (submitTargetId && probe.pressedFound && probe.pressedDisabled) return true;
|
|
2008
2010
|
return false;
|
|
@@ -2014,7 +2016,7 @@ function evaluatePostSubmitSnapshot(snap, activePath) {
|
|
|
2014
2016
|
}
|
|
2015
2017
|
const successText = readVisibleFormSuccess(snap);
|
|
2016
2018
|
if (successText) return { status: "success", message: successText };
|
|
2017
|
-
if (!
|
|
2019
|
+
if (!chunkAYWMBMSN_js.snapshotShowsOpenCreateForm(snap, activePath)) {
|
|
2018
2020
|
return { status: "success" };
|
|
2019
2021
|
}
|
|
2020
2022
|
return void 0;
|
|
@@ -2030,7 +2032,7 @@ async function waitForPostSubmitOutcome(options) {
|
|
|
2030
2032
|
continue;
|
|
2031
2033
|
}
|
|
2032
2034
|
const snap2 = captureSnapshot();
|
|
2033
|
-
const activePath2 =
|
|
2035
|
+
const activePath2 = chunkAYWMBMSN_js.getActiveRouteNames();
|
|
2034
2036
|
const outcome2 = evaluatePostSubmitSnapshot(snap2, activePath2);
|
|
2035
2037
|
if (outcome2) return outcome2;
|
|
2036
2038
|
await sleep(pollMs);
|
|
@@ -2042,7 +2044,7 @@ async function waitForPostSubmitOutcome(options) {
|
|
|
2042
2044
|
};
|
|
2043
2045
|
}
|
|
2044
2046
|
const snap = captureSnapshot();
|
|
2045
|
-
const activePath =
|
|
2047
|
+
const activePath = chunkAYWMBMSN_js.getActiveRouteNames();
|
|
2046
2048
|
const outcome = evaluatePostSubmitSnapshot(snap, activePath);
|
|
2047
2049
|
if (outcome) return outcome;
|
|
2048
2050
|
return {
|
|
@@ -2148,16 +2150,16 @@ function findSnapshotButton(targetId) {
|
|
|
2148
2150
|
}
|
|
2149
2151
|
}
|
|
2150
2152
|
function buildUiDiagnose(targetId, cause) {
|
|
2151
|
-
const activePath =
|
|
2152
|
-
const screen = activePath[activePath.length - 1] ??
|
|
2153
|
+
const activePath = chunkAYWMBMSN_js.getActiveRouteNames();
|
|
2154
|
+
const screen = activePath[activePath.length - 1] ?? chunkAYWMBMSN_js.getCurrentScreen() ?? void 0;
|
|
2153
2155
|
const screenPath = activePath.length > 1 ? activePath.join("/") : screen;
|
|
2154
2156
|
const diagnose = {
|
|
2155
2157
|
category: cause === "not-found" ? "component-not-found" : cause === "disabled" ? "disabled" : "unknown",
|
|
2156
2158
|
targetId,
|
|
2157
2159
|
screen: screenPath
|
|
2158
2160
|
};
|
|
2159
|
-
if (
|
|
2160
|
-
diagnose.visibleMessage =
|
|
2161
|
+
if (chunkAYWMBMSN_js.isOptionalStepAutomationFailure(targetId, screenPath, activePath)) {
|
|
2162
|
+
diagnose.visibleMessage = chunkAYWMBMSN_js.OPTIONAL_STEP_AUTOMATION_HINT;
|
|
2161
2163
|
diagnose.recoverable = true;
|
|
2162
2164
|
}
|
|
2163
2165
|
return diagnose;
|
|
@@ -2219,9 +2221,9 @@ function resolveComponentId(componentId, registry, action) {
|
|
|
2219
2221
|
return comp.id;
|
|
2220
2222
|
}
|
|
2221
2223
|
}
|
|
2222
|
-
const currentScreen =
|
|
2224
|
+
const currentScreen = chunkAYWMBMSN_js.getCurrentScreen();
|
|
2223
2225
|
if (currentScreen) {
|
|
2224
|
-
const screenMeta =
|
|
2226
|
+
const screenMeta = chunkAYWMBMSN_js.getScreenMetadata(currentScreen);
|
|
2225
2227
|
const actions = screenMeta?.actions;
|
|
2226
2228
|
if (actions && Array.isArray(actions)) {
|
|
2227
2229
|
const metaAction = actions.find(
|
|
@@ -2375,7 +2377,7 @@ function checkModalOcclusion(rawComponentId, action) {
|
|
|
2375
2377
|
return null;
|
|
2376
2378
|
}
|
|
2377
2379
|
if (typeof rawComponentId !== "string" || rawComponentId.trim().length === 0) return null;
|
|
2378
|
-
const fiberRoot =
|
|
2380
|
+
const fiberRoot = chunkAYWMBMSN_js.getFiberRoot();
|
|
2379
2381
|
if (!fiberRoot) return null;
|
|
2380
2382
|
let snap;
|
|
2381
2383
|
try {
|
|
@@ -2438,7 +2440,7 @@ function checkModalOcclusion(rawComponentId, action) {
|
|
|
2438
2440
|
}
|
|
2439
2441
|
function uiInteractionHandler(payload, context) {
|
|
2440
2442
|
const { permissions } = context;
|
|
2441
|
-
const registry = context.registry ??
|
|
2443
|
+
const registry = context.registry ?? chunkAYWMBMSN_js.componentRegistry;
|
|
2442
2444
|
if (!permissions.canInteractUI) {
|
|
2443
2445
|
return {
|
|
2444
2446
|
success: false,
|
|
@@ -2497,7 +2499,7 @@ function uiInteractionHandler(payload, context) {
|
|
|
2497
2499
|
);
|
|
2498
2500
|
return { success: true };
|
|
2499
2501
|
}
|
|
2500
|
-
const screen =
|
|
2502
|
+
const screen = chunkAYWMBMSN_js.getCurrentScreen() ?? void 0;
|
|
2501
2503
|
if (result.reason === "list-not-found" || result.reason === "item-not-found") {
|
|
2502
2504
|
return {
|
|
2503
2505
|
success: false,
|
|
@@ -2662,7 +2664,7 @@ function submitLabelHintsSubmit(label) {
|
|
|
2662
2664
|
return SUBMIT_LABEL_HINT_RE.test(trimmed);
|
|
2663
2665
|
}
|
|
2664
2666
|
function screenDeclaresSubmitAction(screenName) {
|
|
2665
|
-
const meta =
|
|
2667
|
+
const meta = chunkAYWMBMSN_js.getScreenMetadata(screenName);
|
|
2666
2668
|
return Array.isArray(meta?.actions) && meta.actions.some(
|
|
2667
2669
|
(action) => typeof action === "object" && action !== null && action.type === "submit"
|
|
2668
2670
|
);
|
|
@@ -2695,7 +2697,7 @@ function resolveFormScreensForSubmit(screen, activePath, registry) {
|
|
|
2695
2697
|
} else {
|
|
2696
2698
|
push(screen);
|
|
2697
2699
|
}
|
|
2698
|
-
push(
|
|
2700
|
+
push(chunkAYWMBMSN_js.getCurrentScreen() ?? void 0);
|
|
2699
2701
|
const withSubmit = [];
|
|
2700
2702
|
const rest = [];
|
|
2701
2703
|
for (const name of ordered) {
|
|
@@ -2713,7 +2715,7 @@ function collectSubmitTargetCandidates(screens, registry) {
|
|
|
2713
2715
|
candidates.push(id);
|
|
2714
2716
|
};
|
|
2715
2717
|
for (const screenName of screens) {
|
|
2716
|
-
const meta =
|
|
2718
|
+
const meta = chunkAYWMBMSN_js.getScreenMetadata(screenName);
|
|
2717
2719
|
const submitMeta = Array.isArray(meta?.actions) ? meta.actions.find(
|
|
2718
2720
|
(action) => typeof action === "object" && action !== null && action.type === "submit"
|
|
2719
2721
|
) : void 0;
|
|
@@ -2759,8 +2761,8 @@ function readVisibleValidation(fieldId, label) {
|
|
|
2759
2761
|
return void 0;
|
|
2760
2762
|
}
|
|
2761
2763
|
function resolveScreenContext() {
|
|
2762
|
-
const activePath =
|
|
2763
|
-
const screen = activePath[activePath.length - 1] ??
|
|
2764
|
+
const activePath = chunkAYWMBMSN_js.getActiveRouteNames();
|
|
2765
|
+
const screen = activePath[activePath.length - 1] ?? chunkAYWMBMSN_js.getCurrentScreen() ?? void 0;
|
|
2764
2766
|
return { screen, activePath };
|
|
2765
2767
|
}
|
|
2766
2768
|
function selectValueApplied(fieldId, requestedValue, currentValue, registry) {
|
|
@@ -2768,36 +2770,36 @@ function selectValueApplied(fieldId, requestedValue, currentValue, registry) {
|
|
|
2768
2770
|
if (!requested) return false;
|
|
2769
2771
|
const meta = getMetadataField(fieldId, registry);
|
|
2770
2772
|
const options = Array.isArray(meta?.options) ? meta.options : [];
|
|
2771
|
-
const requestedNorm =
|
|
2772
|
-
const currentNorm =
|
|
2773
|
+
const requestedNorm = chunkAYWMBMSN_js.normalize3(requested);
|
|
2774
|
+
const currentNorm = chunkAYWMBMSN_js.normalize3(currentValue);
|
|
2773
2775
|
if (currentNorm === requestedNorm) return true;
|
|
2774
2776
|
for (const option of options) {
|
|
2775
2777
|
const value = typeof option?.value === "string" ? option.value : "";
|
|
2776
2778
|
const label = typeof option?.label === "string" ? option.label : "";
|
|
2777
|
-
if (
|
|
2778
|
-
if (
|
|
2779
|
-
if (
|
|
2779
|
+
if (chunkAYWMBMSN_js.normalize3(value) === requestedNorm && chunkAYWMBMSN_js.normalize3(label) === currentNorm) return true;
|
|
2780
|
+
if (chunkAYWMBMSN_js.normalize3(label) === requestedNorm && chunkAYWMBMSN_js.normalize3(label) === currentNorm) return true;
|
|
2781
|
+
if (chunkAYWMBMSN_js.normalize3(value) === requestedNorm && chunkAYWMBMSN_js.normalize3(value) === currentNorm) return true;
|
|
2780
2782
|
}
|
|
2781
2783
|
return false;
|
|
2782
2784
|
}
|
|
2783
2785
|
function getMetadataField(fieldId, registry) {
|
|
2784
2786
|
const screens = /* @__PURE__ */ new Set();
|
|
2785
|
-
for (const name of
|
|
2786
|
-
const current =
|
|
2787
|
+
for (const name of chunkAYWMBMSN_js.getActiveRouteNames()) screens.add(name);
|
|
2788
|
+
const current = chunkAYWMBMSN_js.getCurrentScreen();
|
|
2787
2789
|
if (current) screens.add(current);
|
|
2788
2790
|
if (registry) {
|
|
2789
2791
|
for (const comp of registry.snapshot()) {
|
|
2790
2792
|
if (comp.kind === "field" && comp.screen) screens.add(comp.screen);
|
|
2791
2793
|
}
|
|
2792
2794
|
}
|
|
2793
|
-
const needle =
|
|
2795
|
+
const needle = chunkAYWMBMSN_js.normalize3(fieldId);
|
|
2794
2796
|
for (const screenName of screens) {
|
|
2795
|
-
const screenMeta =
|
|
2797
|
+
const screenMeta = chunkAYWMBMSN_js.getScreenMetadata(screenName);
|
|
2796
2798
|
const fields = Array.isArray(screenMeta?.fields) ? screenMeta.fields : [];
|
|
2797
2799
|
const match = fields.find((field) => {
|
|
2798
2800
|
if (!field || typeof field !== "object") return false;
|
|
2799
|
-
const id = typeof field.id === "string" ?
|
|
2800
|
-
const label = typeof field.label === "string" ?
|
|
2801
|
+
const id = typeof field.id === "string" ? chunkAYWMBMSN_js.normalize3(field.id) : "";
|
|
2802
|
+
const label = typeof field.label === "string" ? chunkAYWMBMSN_js.normalize3(field.label) : "";
|
|
2801
2803
|
return id === needle || label === needle;
|
|
2802
2804
|
});
|
|
2803
2805
|
if (match) return match;
|
|
@@ -2809,11 +2811,11 @@ function resolveSelectOption(fieldId, value, registry) {
|
|
|
2809
2811
|
if (!requested) return void 0;
|
|
2810
2812
|
const meta = getMetadataField(fieldId, registry);
|
|
2811
2813
|
const options = Array.isArray(meta?.options) ? meta.options : [];
|
|
2812
|
-
const requestedNorm =
|
|
2814
|
+
const requestedNorm = chunkAYWMBMSN_js.normalize3(requested);
|
|
2813
2815
|
for (const option of options) {
|
|
2814
2816
|
const optionValue = typeof option?.value === "string" ? option.value : "";
|
|
2815
2817
|
const optionLabel = typeof option?.label === "string" ? option.label : "";
|
|
2816
|
-
if (
|
|
2818
|
+
if (chunkAYWMBMSN_js.normalize3(optionValue) === requestedNorm || chunkAYWMBMSN_js.normalize3(optionLabel) === requestedNorm) {
|
|
2817
2819
|
return { value: optionValue, label: optionLabel };
|
|
2818
2820
|
}
|
|
2819
2821
|
}
|
|
@@ -2863,12 +2865,12 @@ async function tryPressSelectOption(fieldId, value, registry, options = {}) {
|
|
|
2863
2865
|
return {
|
|
2864
2866
|
success: false,
|
|
2865
2867
|
error: `No pressable option found for select field "${fieldId}"`,
|
|
2866
|
-
diagnose: { category: "component-not-found", fieldId, screen:
|
|
2868
|
+
diagnose: { category: "component-not-found", fieldId, screen: chunkAYWMBMSN_js.getCurrentScreen() ?? void 0 }
|
|
2867
2869
|
};
|
|
2868
2870
|
}
|
|
2869
2871
|
function normalizeFieldType(type) {
|
|
2870
2872
|
if (typeof type !== "string") return void 0;
|
|
2871
|
-
const normalized =
|
|
2873
|
+
const normalized = chunkAYWMBMSN_js.normalize3(type);
|
|
2872
2874
|
if (normalized === "select" || normalized === "picker" || normalized === "dropdown") return "select";
|
|
2873
2875
|
if (normalized === "toggle" || normalized === "switch" || normalized === "checkbox") return "toggle";
|
|
2874
2876
|
if (normalized === "date") return "date";
|
|
@@ -2896,7 +2898,7 @@ function fieldCueTerms(fieldId, label) {
|
|
|
2896
2898
|
);
|
|
2897
2899
|
const terms = /* @__PURE__ */ new Set();
|
|
2898
2900
|
for (const value of raw) {
|
|
2899
|
-
const normalized =
|
|
2901
|
+
const normalized = chunkAYWMBMSN_js.normalize3(value);
|
|
2900
2902
|
if (normalized.length >= 3 && normalized !== "id") terms.add(normalized);
|
|
2901
2903
|
}
|
|
2902
2904
|
return [...terms];
|
|
@@ -2907,17 +2909,17 @@ function snapshotHasFieldCue(snap, fieldId, label) {
|
|
|
2907
2909
|
const visible = [
|
|
2908
2910
|
...snap.texts ?? [],
|
|
2909
2911
|
...(snap.buttons ?? []).map((b) => b.label ?? b.id ?? "")
|
|
2910
|
-
].map((text) =>
|
|
2912
|
+
].map((text) => chunkAYWMBMSN_js.normalize3(text)).filter(Boolean);
|
|
2911
2913
|
return visible.some((text) => terms.some((term) => text.includes(term) || term.includes(text)));
|
|
2912
2914
|
}
|
|
2913
2915
|
function scoreCandidateText(value, texts) {
|
|
2914
|
-
const valueNorm =
|
|
2916
|
+
const valueNorm = chunkAYWMBMSN_js.normalize3(String(value ?? ""));
|
|
2915
2917
|
if (!valueNorm) return 0;
|
|
2916
2918
|
let best = 0;
|
|
2917
2919
|
for (const text of texts) {
|
|
2918
|
-
const textNorm =
|
|
2920
|
+
const textNorm = chunkAYWMBMSN_js.normalize3(text);
|
|
2919
2921
|
if (!textNorm) continue;
|
|
2920
|
-
best = Math.max(best,
|
|
2922
|
+
best = Math.max(best, chunkAYWMBMSN_js.matchScore(valueNorm, textNorm));
|
|
2921
2923
|
}
|
|
2922
2924
|
return best;
|
|
2923
2925
|
}
|
|
@@ -2931,7 +2933,7 @@ function optionTexts(option) {
|
|
|
2931
2933
|
function buildChoiceCandidates(snap, fieldId, value, allowFirstVisibleWhenNoCue, registry) {
|
|
2932
2934
|
const fieldLabel = getFieldLabel(fieldId, registry);
|
|
2933
2935
|
const fieldCueVisible = snapshotHasFieldCue(snap, fieldId, fieldLabel);
|
|
2934
|
-
const genericValue =
|
|
2936
|
+
const genericValue = chunkAYWMBMSN_js.isGenericSelectValue(value);
|
|
2935
2937
|
const candidates = [];
|
|
2936
2938
|
let order = 0;
|
|
2937
2939
|
const choiceGroups = snap.choiceGroups ?? [];
|
|
@@ -2943,7 +2945,7 @@ function buildChoiceCandidates(snap, fieldId, value, allowFirstVisibleWhenNoCue,
|
|
|
2943
2945
|
const groupCueScore = Math.max(
|
|
2944
2946
|
globalCueScore,
|
|
2945
2947
|
...groupTexts.map((text) => {
|
|
2946
|
-
const normalized =
|
|
2948
|
+
const normalized = chunkAYWMBMSN_js.normalize3(text);
|
|
2947
2949
|
return fieldCueTerms(fieldId, fieldLabel).some(
|
|
2948
2950
|
(term) => normalized.includes(term) || term.includes(normalized)
|
|
2949
2951
|
) ? 80 : 0;
|
|
@@ -2980,7 +2982,7 @@ function buildChoiceCandidates(snap, fieldId, value, allowFirstVisibleWhenNoCue,
|
|
|
2980
2982
|
const elementCueScore = Math.max(
|
|
2981
2983
|
fieldCueVisible && elements.length <= 12 ? 50 : 0,
|
|
2982
2984
|
...cueTexts.map((text) => {
|
|
2983
|
-
const normalized =
|
|
2985
|
+
const normalized = chunkAYWMBMSN_js.normalize3(text);
|
|
2984
2986
|
return fieldTerms.some(
|
|
2985
2987
|
(term) => normalized.includes(term) || term.includes(normalized)
|
|
2986
2988
|
) ? 80 : 0;
|
|
@@ -3040,7 +3042,7 @@ async function selectVisibleChoiceAsync(fieldId, value, registry, options) {
|
|
|
3040
3042
|
return {
|
|
3041
3043
|
success: false,
|
|
3042
3044
|
error: err?.message ?? "Could not capture visible choices",
|
|
3043
|
-
diagnose: { category: "unknown", fieldId, screen:
|
|
3045
|
+
diagnose: { category: "unknown", fieldId, screen: chunkAYWMBMSN_js.getCurrentScreen() ?? void 0 }
|
|
3044
3046
|
};
|
|
3045
3047
|
}
|
|
3046
3048
|
const candidates = buildChoiceCandidates(
|
|
@@ -3055,7 +3057,7 @@ async function selectVisibleChoiceAsync(fieldId, value, registry, options) {
|
|
|
3055
3057
|
return {
|
|
3056
3058
|
success: false,
|
|
3057
3059
|
error: `No visible option found for select field "${fieldId}"`,
|
|
3058
|
-
diagnose: { category: "component-not-found", fieldId, screen:
|
|
3060
|
+
diagnose: { category: "component-not-found", fieldId, screen: chunkAYWMBMSN_js.getCurrentScreen() ?? void 0 }
|
|
3059
3061
|
};
|
|
3060
3062
|
}
|
|
3061
3063
|
const pressed = pressTargetByIdOrLabel(candidate.targetId, registry);
|
|
@@ -3068,7 +3070,7 @@ async function selectVisibleChoiceAsync(fieldId, value, registry, options) {
|
|
|
3068
3070
|
}
|
|
3069
3071
|
function isContinuationButton(label) {
|
|
3070
3072
|
if (!label) return false;
|
|
3071
|
-
return /^(next|continue|proximo|prox|continuar|avancar|avançar)$/i.test(
|
|
3073
|
+
return /^(next|continue|proximo|prox|continuar|avancar|avançar)$/i.test(chunkAYWMBMSN_js.normalize3(label));
|
|
3072
3074
|
}
|
|
3073
3075
|
function pressContinuationButton(registry) {
|
|
3074
3076
|
const snap = captureSnapshot();
|
|
@@ -3081,7 +3083,7 @@ function pressContinuationButton(registry) {
|
|
|
3081
3083
|
return {
|
|
3082
3084
|
success: false,
|
|
3083
3085
|
error: "No enabled continuation button is visible",
|
|
3084
|
-
diagnose: { category: "component-not-found", screen:
|
|
3086
|
+
diagnose: { category: "component-not-found", screen: chunkAYWMBMSN_js.getCurrentScreen() ?? void 0 }
|
|
3085
3087
|
};
|
|
3086
3088
|
}
|
|
3087
3089
|
return pressTargetByIdOrLabel(id, registry);
|
|
@@ -3101,18 +3103,18 @@ function findField(fieldId, registry) {
|
|
|
3101
3103
|
return registry.getField(comp.id);
|
|
3102
3104
|
}
|
|
3103
3105
|
}
|
|
3104
|
-
const currentScreenForTieBreak =
|
|
3105
|
-
const needle =
|
|
3106
|
+
const currentScreenForTieBreak = chunkAYWMBMSN_js.getCurrentScreen();
|
|
3107
|
+
const needle = chunkAYWMBMSN_js.normalize3(fieldId);
|
|
3106
3108
|
let bestComp;
|
|
3107
3109
|
let bestScore = 0;
|
|
3108
3110
|
let bestOnCurrentScreen = false;
|
|
3109
3111
|
for (const comp of snapshot) {
|
|
3110
3112
|
if (comp.kind !== "field") continue;
|
|
3111
|
-
const candidates = [
|
|
3112
|
-
if (comp.label) candidates.push(
|
|
3113
|
+
const candidates = [chunkAYWMBMSN_js.normalize3(comp.id)];
|
|
3114
|
+
if (comp.label) candidates.push(chunkAYWMBMSN_js.normalize3(comp.label));
|
|
3113
3115
|
let candidateScore = 0;
|
|
3114
3116
|
for (const cand of candidates) {
|
|
3115
|
-
const s =
|
|
3117
|
+
const s = chunkAYWMBMSN_js.matchScore(needle, cand);
|
|
3116
3118
|
if (s > candidateScore) candidateScore = s;
|
|
3117
3119
|
}
|
|
3118
3120
|
if (candidateScore === 0) continue;
|
|
@@ -3130,9 +3132,9 @@ function findField(fieldId, registry) {
|
|
|
3130
3132
|
);
|
|
3131
3133
|
return registry.getField(bestComp.id);
|
|
3132
3134
|
}
|
|
3133
|
-
const currentScreen =
|
|
3135
|
+
const currentScreen = chunkAYWMBMSN_js.getCurrentScreen();
|
|
3134
3136
|
if (currentScreen) {
|
|
3135
|
-
const screenMeta =
|
|
3137
|
+
const screenMeta = chunkAYWMBMSN_js.getScreenMetadata(currentScreen);
|
|
3136
3138
|
const fields = screenMeta?.fields;
|
|
3137
3139
|
if (fields && Array.isArray(fields)) {
|
|
3138
3140
|
const metaField = fields.find(
|
|
@@ -3140,12 +3142,12 @@ function findField(fieldId, registry) {
|
|
|
3140
3142
|
);
|
|
3141
3143
|
if (metaField && typeof metaField === "object" && metaField.label) {
|
|
3142
3144
|
const metaLabel = metaField.label;
|
|
3143
|
-
const metaNeedle =
|
|
3145
|
+
const metaNeedle = chunkAYWMBMSN_js.normalize3(metaLabel);
|
|
3144
3146
|
let mBest;
|
|
3145
3147
|
let mBestScore = 0;
|
|
3146
3148
|
for (const comp of snapshot) {
|
|
3147
3149
|
if (comp.kind !== "field" || !comp.label) continue;
|
|
3148
|
-
const score =
|
|
3150
|
+
const score = chunkAYWMBMSN_js.matchScore(metaNeedle, chunkAYWMBMSN_js.normalize3(comp.label));
|
|
3149
3151
|
if (score > mBestScore) {
|
|
3150
3152
|
mBestScore = score;
|
|
3151
3153
|
mBest = comp;
|
|
@@ -3166,7 +3168,7 @@ function findField(fieldId, registry) {
|
|
|
3166
3168
|
);
|
|
3167
3169
|
return registry.getField(bestComp.id);
|
|
3168
3170
|
}
|
|
3169
|
-
|
|
3171
|
+
chunkAYWMBMSN_js.appilotsDebugWarn(
|
|
3170
3172
|
`findField: NOT FOUND \u2014 fieldId="${fieldId}" not in registry. Available fields: ${snapshot.filter((c) => c.kind === "field").map((c) => `"${c.id}" (label: ${c.label})`).join(", ") || "none"}`
|
|
3171
3173
|
);
|
|
3172
3174
|
return void 0;
|
|
@@ -3186,7 +3188,7 @@ function findToggle(fieldId, registry) {
|
|
|
3186
3188
|
return registry.getToggle(comp.id);
|
|
3187
3189
|
}
|
|
3188
3190
|
}
|
|
3189
|
-
|
|
3191
|
+
chunkAYWMBMSN_js.appilotsDebugWarn(
|
|
3190
3192
|
`findToggle: NOT FOUND \u2014 fieldId="${fieldId}" not in registry. Available toggles: ${snapshot.filter((c) => c.kind === "toggle").map((c) => `"${c.id}"`).join(", ") || "none"}`
|
|
3191
3193
|
);
|
|
3192
3194
|
return void 0;
|
|
@@ -3206,7 +3208,7 @@ function findSlider(fieldId, registry) {
|
|
|
3206
3208
|
var sleep2 = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
3207
3209
|
async function formFillHandler(payload, context) {
|
|
3208
3210
|
const { permissions } = context;
|
|
3209
|
-
const registry = context.registry ??
|
|
3211
|
+
const registry = context.registry ?? chunkAYWMBMSN_js.componentRegistry;
|
|
3210
3212
|
const { screen, activePath } = resolveScreenContext();
|
|
3211
3213
|
const screenPath = activePath.length > 1 ? activePath.join("/") : screen;
|
|
3212
3214
|
if (!permissions.canFillForms) {
|
|
@@ -3225,7 +3227,7 @@ async function formFillHandler(payload, context) {
|
|
|
3225
3227
|
}
|
|
3226
3228
|
const registrySnapshot = registry.snapshot();
|
|
3227
3229
|
if (registrySnapshot.length === 0) {
|
|
3228
|
-
|
|
3230
|
+
chunkAYWMBMSN_js.appilotsDebugWarn(
|
|
3229
3231
|
"formFillHandler: registry is EMPTY \u2014 auto-tracking may not be active. Ensure enableAppilotsAutoTracking() runs before components mount."
|
|
3230
3232
|
);
|
|
3231
3233
|
} else {
|
|
@@ -3270,7 +3272,7 @@ async function formFillHandler(payload, context) {
|
|
|
3270
3272
|
const fieldEntry = findField(fieldId, registry);
|
|
3271
3273
|
if (fieldEntry) {
|
|
3272
3274
|
try {
|
|
3273
|
-
|
|
3275
|
+
chunkAYWMBMSN_js.appilotsDebugLog(
|
|
3274
3276
|
`formFillHandler: found field "${fieldId}" via registry, calling setValue(<${String(value).length} chars>)`
|
|
3275
3277
|
);
|
|
3276
3278
|
const beforeValue = effectiveFieldType === "date" ? fieldEntry.getValue?.() ?? "" : void 0;
|
|
@@ -3301,7 +3303,7 @@ async function formFillHandler(payload, context) {
|
|
|
3301
3303
|
after = fieldEntry.getValue?.() ?? "";
|
|
3302
3304
|
}
|
|
3303
3305
|
if (!selectValueApplied(fieldId, value, after, registry)) {
|
|
3304
|
-
|
|
3306
|
+
chunkAYWMBMSN_js.appilotsDebugWarn(
|
|
3305
3307
|
`formFillHandler: select field "${fieldId}" setValue did not stick (wrote <${String(value).length} chars>, current is <${String(after ?? "").length} chars>), trying visible choice fallback`
|
|
3306
3308
|
);
|
|
3307
3309
|
const selectResult = await selectVisibleChoice(fieldId, value, registry, {
|
|
@@ -3474,14 +3476,14 @@ async function formFillHandler(payload, context) {
|
|
|
3474
3476
|
if (payload.submitAfterFill === true) {
|
|
3475
3477
|
if (!allSuccess) {
|
|
3476
3478
|
const failedIds = fieldResults.filter((result) => !result.success).map((result) => result.fieldId);
|
|
3477
|
-
|
|
3479
|
+
chunkAYWMBMSN_js.appilotsDebugWarn(
|
|
3478
3480
|
"formFillHandler: submitAfterFill=true requested but some fields failed; NOT submitting" + (failedIds.length > 0 ? ` (failed: ${failedIds.join(", ")})` : "")
|
|
3479
3481
|
);
|
|
3480
3482
|
} else {
|
|
3481
3483
|
await sleep2(120);
|
|
3482
3484
|
const submitResult = pressSubmitButton({ screen, screenPath, activePath }, registry);
|
|
3483
3485
|
if (!submitResult.success) {
|
|
3484
|
-
|
|
3486
|
+
chunkAYWMBMSN_js.appilotsDebugWarn(`formFillHandler: submitAfterFill failed \u2014 ${submitResult.error}`);
|
|
3485
3487
|
return {
|
|
3486
3488
|
success: false,
|
|
3487
3489
|
error: submitResult.error,
|
|
@@ -3493,7 +3495,7 @@ async function formFillHandler(payload, context) {
|
|
|
3493
3495
|
submitTargetId: submitResult.pressedTargetId
|
|
3494
3496
|
});
|
|
3495
3497
|
if (postSubmit.status === "pending") {
|
|
3496
|
-
|
|
3498
|
+
chunkAYWMBMSN_js.appilotsDebugWarn(`formFillHandler: submit still pending \u2014 ${postSubmit.message}`);
|
|
3497
3499
|
return {
|
|
3498
3500
|
success: false,
|
|
3499
3501
|
error: postSubmit.message,
|
|
@@ -3502,7 +3504,7 @@ async function formFillHandler(payload, context) {
|
|
|
3502
3504
|
};
|
|
3503
3505
|
}
|
|
3504
3506
|
if (postSubmit.status === "failure") {
|
|
3505
|
-
|
|
3507
|
+
chunkAYWMBMSN_js.appilotsDebugWarn(
|
|
3506
3508
|
`formFillHandler: submit rejected by visible validation \u2014 ${postSubmit.message}`
|
|
3507
3509
|
);
|
|
3508
3510
|
return {
|
|
@@ -3529,10 +3531,10 @@ async function formFillHandler(payload, context) {
|
|
|
3529
3531
|
};
|
|
3530
3532
|
}
|
|
3531
3533
|
function pressSubmitButton(context, registry) {
|
|
3532
|
-
const activePath = context.activePath ??
|
|
3534
|
+
const activePath = context.activePath ?? chunkAYWMBMSN_js.getActiveRouteNames();
|
|
3533
3535
|
const hintScreen = context.screen ?? context.screenPath;
|
|
3534
3536
|
const formScreens = resolveFormScreensForSubmit(hintScreen, activePath, registry);
|
|
3535
|
-
const resolvedScreen = formScreens.find((name) => screenDeclaresSubmit(name)) ?? formScreens[0] ?? hintScreen ??
|
|
3537
|
+
const resolvedScreen = formScreens.find((name) => screenDeclaresSubmit(name)) ?? formScreens[0] ?? hintScreen ?? chunkAYWMBMSN_js.getCurrentScreen() ?? void 0;
|
|
3536
3538
|
const candidates = collectSubmitTargetCandidates(formScreens, registry);
|
|
3537
3539
|
for (const candidate of candidates) {
|
|
3538
3540
|
const target = registry.getTarget(candidate);
|
|
@@ -3553,7 +3555,7 @@ function pressSubmitButton(context, registry) {
|
|
|
3553
3555
|
}
|
|
3554
3556
|
}
|
|
3555
3557
|
for (const screenName of formScreens) {
|
|
3556
|
-
const screenMeta =
|
|
3558
|
+
const screenMeta = chunkAYWMBMSN_js.getScreenMetadata(screenName);
|
|
3557
3559
|
const submitMeta = Array.isArray(screenMeta?.actions) ? screenMeta.actions.find(
|
|
3558
3560
|
(action) => typeof action === "object" && action !== null && action.type === "submit"
|
|
3559
3561
|
) : void 0;
|
|
@@ -3659,12 +3661,12 @@ function buildDiagnose(category, targetId, candidates) {
|
|
|
3659
3661
|
return {
|
|
3660
3662
|
category,
|
|
3661
3663
|
targetId,
|
|
3662
|
-
screen:
|
|
3664
|
+
screen: chunkAYWMBMSN_js.getCurrentScreen() ?? void 0,
|
|
3663
3665
|
...candidates && candidates.length > 0 ? { candidates: candidates.slice(0, 8) } : {}
|
|
3664
3666
|
};
|
|
3665
3667
|
}
|
|
3666
3668
|
function resolveListEntry(listId) {
|
|
3667
|
-
const entries =
|
|
3669
|
+
const entries = chunkAYWMBMSN_js.listRegistry.snapshot();
|
|
3668
3670
|
if (entries.length === 0) return {};
|
|
3669
3671
|
if (listId) {
|
|
3670
3672
|
const wanted = normalizeId2(listId);
|
|
@@ -3775,23 +3777,23 @@ function targetIdFromPayload(payload) {
|
|
|
3775
3777
|
}
|
|
3776
3778
|
async function waitForPostInteractionSettle(payload) {
|
|
3777
3779
|
const targetId = targetIdFromPayload(payload);
|
|
3778
|
-
const fromScreen =
|
|
3779
|
-
const baseline =
|
|
3780
|
+
const fromScreen = chunkAYWMBMSN_js.getCurrentScreen();
|
|
3781
|
+
const baseline = chunkAYWMBMSN_js.probeLoadingState(targetId || null, fromScreen);
|
|
3780
3782
|
await sleepMs(100);
|
|
3781
|
-
const afterPress =
|
|
3783
|
+
const afterPress = chunkAYWMBMSN_js.probeLoadingState(targetId || null, chunkAYWMBMSN_js.getCurrentScreen());
|
|
3782
3784
|
const modalOrLoading = afterPress.modalOpen || afterPress.loading || afterPress.pressedDisabled;
|
|
3783
3785
|
const fingerprintChanged = afterPress.fingerprint !== baseline.fingerprint;
|
|
3784
|
-
const capMs =
|
|
3786
|
+
const capMs = chunkAYWMBMSN_js.isListItemPressTarget(targetId) ? 5e3 : 1e4;
|
|
3785
3787
|
if (modalOrLoading || fingerprintChanged) {
|
|
3786
|
-
await
|
|
3788
|
+
await chunkAYWMBMSN_js.waitForLoadingSettle({
|
|
3787
3789
|
pressedComponentId: targetId || null,
|
|
3788
3790
|
fromScreen,
|
|
3789
3791
|
maxMs: capMs
|
|
3790
3792
|
});
|
|
3791
3793
|
return;
|
|
3792
3794
|
}
|
|
3793
|
-
if (
|
|
3794
|
-
await
|
|
3795
|
+
if (chunkAYWMBMSN_js.isListItemPressTarget(targetId)) {
|
|
3796
|
+
await chunkAYWMBMSN_js.waitForLoadingSettle({
|
|
3795
3797
|
fromScreen,
|
|
3796
3798
|
maxMs: 3e3
|
|
3797
3799
|
});
|
|
@@ -3811,7 +3813,7 @@ function validateActionPayload(action) {
|
|
|
3811
3813
|
error: message,
|
|
3812
3814
|
diagnose: {
|
|
3813
3815
|
category: "validation",
|
|
3814
|
-
screen:
|
|
3816
|
+
screen: chunkAYWMBMSN_js.getCurrentScreen() ?? void 0,
|
|
3815
3817
|
...ids ?? {}
|
|
3816
3818
|
}
|
|
3817
3819
|
});
|
|
@@ -3878,7 +3880,7 @@ async function executeAction(action, context) {
|
|
|
3878
3880
|
let result;
|
|
3879
3881
|
const validationFailure = validateActionPayload(action);
|
|
3880
3882
|
if (validationFailure) {
|
|
3881
|
-
|
|
3883
|
+
chunkAYWMBMSN_js.appilotsDebugWarn(
|
|
3882
3884
|
`executeAction: payload validation failed for type="${action.type}" id="${action.id}": ${validationFailure.error}`
|
|
3883
3885
|
);
|
|
3884
3886
|
context.emit({
|
|
@@ -3905,13 +3907,13 @@ async function executeAction(action, context) {
|
|
|
3905
3907
|
case "form_fill":
|
|
3906
3908
|
result = await formFillHandler(action.payload, {
|
|
3907
3909
|
permissions,
|
|
3908
|
-
registry: context.registry ??
|
|
3910
|
+
registry: context.registry ?? chunkAYWMBMSN_js.getDefaultRegistry()
|
|
3909
3911
|
});
|
|
3910
3912
|
break;
|
|
3911
3913
|
case "ui_interaction":
|
|
3912
3914
|
result = uiInteractionHandler(action.payload, {
|
|
3913
3915
|
permissions,
|
|
3914
|
-
registry: context.registry ??
|
|
3916
|
+
registry: context.registry ?? chunkAYWMBMSN_js.getDefaultRegistry()
|
|
3915
3917
|
});
|
|
3916
3918
|
if (result.success) {
|
|
3917
3919
|
await waitForPostInteractionSettle(action.payload);
|
|
@@ -3941,7 +3943,7 @@ async function executeAction(action, context) {
|
|
|
3941
3943
|
};
|
|
3942
3944
|
}
|
|
3943
3945
|
} catch (err) {
|
|
3944
|
-
|
|
3946
|
+
chunkAYWMBMSN_js.appilotsDebugWarn(
|
|
3945
3947
|
`executeAction: exception during action type="${action.type}" id="${action.id}": ${err?.message}`
|
|
3946
3948
|
);
|
|
3947
3949
|
result = {
|
|
@@ -3965,37 +3967,126 @@ async function executeAction(action, context) {
|
|
|
3965
3967
|
});
|
|
3966
3968
|
return result;
|
|
3967
3969
|
}
|
|
3970
|
+
|
|
3971
|
+
// src/platform/confirmedDestructiveAlert.ts
|
|
3972
|
+
var SUPPRESSION_WINDOW_MS = 1e3;
|
|
3973
|
+
var _active = null;
|
|
3974
|
+
function resolveConfirmButton(buttons) {
|
|
3975
|
+
if (!buttons || buttons.length === 0) return void 0;
|
|
3976
|
+
const destructive = buttons.find(
|
|
3977
|
+
(button) => button.style === "destructive" && typeof button.onPress === "function"
|
|
3978
|
+
);
|
|
3979
|
+
if (destructive) return destructive;
|
|
3980
|
+
return buttons.find(
|
|
3981
|
+
(button) => button.style !== "cancel" && typeof button.onPress === "function"
|
|
3982
|
+
);
|
|
3983
|
+
}
|
|
3984
|
+
function restore(suppression) {
|
|
3985
|
+
if (suppression.timer) {
|
|
3986
|
+
clearTimeout(suppression.timer);
|
|
3987
|
+
suppression.timer = null;
|
|
3988
|
+
}
|
|
3989
|
+
if (_active !== suppression) return;
|
|
3990
|
+
if (suppression.host.alert === _patchedAlert) {
|
|
3991
|
+
suppression.host.alert = suppression.originalAlert;
|
|
3992
|
+
}
|
|
3993
|
+
_active = null;
|
|
3994
|
+
}
|
|
3995
|
+
var _patchedAlert = (title, message, buttons, options) => {
|
|
3996
|
+
const suppression = _active;
|
|
3997
|
+
if (!suppression) return;
|
|
3998
|
+
if (suppression.consumed) {
|
|
3999
|
+
return suppression.originalAlert(title, message, buttons, options);
|
|
4000
|
+
}
|
|
4001
|
+
const button = resolveConfirmButton(buttons);
|
|
4002
|
+
if (!button?.onPress) {
|
|
4003
|
+
return suppression.originalAlert(title, message, buttons, options);
|
|
4004
|
+
}
|
|
4005
|
+
suppression.consumed = true;
|
|
4006
|
+
console.log(
|
|
4007
|
+
"[Appilots] Suppressing native Alert during already-confirmed destructive agent action"
|
|
4008
|
+
);
|
|
4009
|
+
try {
|
|
4010
|
+
suppression.pending = Promise.resolve(button.onPress()).then(() => void 0).catch((err) => reportHandlerFailure(err));
|
|
4011
|
+
} catch (err) {
|
|
4012
|
+
reportHandlerFailure(err);
|
|
4013
|
+
suppression.pending = null;
|
|
4014
|
+
}
|
|
4015
|
+
};
|
|
4016
|
+
function reportHandlerFailure(err) {
|
|
4017
|
+
console.error("[Appilots] The app\u2019s Alert handler threw while being auto-confirmed", err);
|
|
4018
|
+
}
|
|
4019
|
+
async function runWithConfirmedDestructiveContext(enabled, host, fn) {
|
|
4020
|
+
if (!enabled) return fn();
|
|
4021
|
+
if (_active) {
|
|
4022
|
+
_active.depth += 1;
|
|
4023
|
+
const joined = _active;
|
|
4024
|
+
try {
|
|
4025
|
+
return await fn();
|
|
4026
|
+
} finally {
|
|
4027
|
+
joined.depth -= 1;
|
|
4028
|
+
if (joined.depth === 0) {
|
|
4029
|
+
if (joined.pending) await joined.pending.catch(() => void 0);
|
|
4030
|
+
restore(joined);
|
|
4031
|
+
}
|
|
4032
|
+
}
|
|
4033
|
+
}
|
|
4034
|
+
const suppression = {
|
|
4035
|
+
host,
|
|
4036
|
+
originalAlert: host.alert,
|
|
4037
|
+
depth: 1,
|
|
4038
|
+
consumed: false,
|
|
4039
|
+
pending: null,
|
|
4040
|
+
timer: null
|
|
4041
|
+
};
|
|
4042
|
+
_active = suppression;
|
|
4043
|
+
host.alert = _patchedAlert;
|
|
4044
|
+
suppression.timer = setTimeout(() => {
|
|
4045
|
+
if (!suppression.consumed) restore(suppression);
|
|
4046
|
+
}, SUPPRESSION_WINDOW_MS);
|
|
4047
|
+
suppression.timer?.unref?.();
|
|
4048
|
+
try {
|
|
4049
|
+
const result = await fn();
|
|
4050
|
+
if (suppression.pending) await suppression.pending.catch(() => void 0);
|
|
4051
|
+
return result;
|
|
4052
|
+
} finally {
|
|
4053
|
+
suppression.depth -= 1;
|
|
4054
|
+
if (suppression.depth === 0) restore(suppression);
|
|
4055
|
+
}
|
|
4056
|
+
}
|
|
4057
|
+
|
|
4058
|
+
// src/platform/reactNativeAdapter.ts
|
|
3968
4059
|
var POST_ACTION_LOADING_MAX_MS = 6e3;
|
|
3969
4060
|
function resolveScreenMetadata() {
|
|
3970
|
-
const activePath =
|
|
4061
|
+
const activePath = chunkAYWMBMSN_js.getActiveRouteNames();
|
|
3971
4062
|
for (let i = activePath.length - 1; i >= 0; i--) {
|
|
3972
4063
|
const name = activePath[i];
|
|
3973
|
-
const meta = name ?
|
|
4064
|
+
const meta = name ? chunkAYWMBMSN_js.getScreenMetadata(name) : void 0;
|
|
3974
4065
|
if (meta && (Array.isArray(meta.fields) && meta.fields.length > 0 || Array.isArray(meta.actions) && meta.actions.length > 0)) {
|
|
3975
4066
|
return meta;
|
|
3976
4067
|
}
|
|
3977
4068
|
}
|
|
3978
|
-
const screen =
|
|
3979
|
-
return screen ?
|
|
4069
|
+
const screen = chunkAYWMBMSN_js.getCurrentScreen();
|
|
4070
|
+
return screen ? chunkAYWMBMSN_js.getScreenMetadata(screen) : void 0;
|
|
3980
4071
|
}
|
|
3981
4072
|
function buildAgentContext(extras = {}) {
|
|
3982
4073
|
const context = {};
|
|
3983
4074
|
context.platform = "react-native";
|
|
3984
|
-
const screen =
|
|
4075
|
+
const screen = chunkAYWMBMSN_js.getCurrentScreen();
|
|
3985
4076
|
if (screen) context.currentScreen = screen;
|
|
3986
|
-
const navigationState =
|
|
4077
|
+
const navigationState = chunkAYWMBMSN_js.getNavigationStateSnapshot();
|
|
3987
4078
|
if (navigationState) context.navigationState = navigationState;
|
|
3988
4079
|
const screenMeta = resolveScreenMetadata();
|
|
3989
4080
|
if (screenMeta) context.screenMetadata = screenMeta;
|
|
3990
4081
|
try {
|
|
3991
4082
|
context.snapshot = captureSnapshot();
|
|
3992
4083
|
} catch (err) {
|
|
3993
|
-
|
|
4084
|
+
chunkAYWMBMSN_js.appilotsDebugWarn("buildAgentContext: captureSnapshot failed", err);
|
|
3994
4085
|
}
|
|
3995
|
-
const registry =
|
|
4086
|
+
const registry = chunkAYWMBMSN_js.componentRegistry.snapshot();
|
|
3996
4087
|
const filtered = screen ? registry.filter((c) => !c.screen || c.screen === screen) : registry;
|
|
3997
4088
|
if (filtered.length > 0) context.registeredComponents = filtered;
|
|
3998
|
-
const registeredLists =
|
|
4089
|
+
const registeredLists = chunkAYWMBMSN_js.listRegistry.snapshot();
|
|
3999
4090
|
if (registeredLists.length > 0) {
|
|
4000
4091
|
context.registeredLists = registeredLists.map(
|
|
4001
4092
|
({ scrollToIndex, scrollToOffset, getScrollMetrics, dataPreview, ...rest }) => rest
|
|
@@ -4012,12 +4103,12 @@ function resolveActionHints(screen, pressedComponentId, actionPayload) {
|
|
|
4012
4103
|
}
|
|
4013
4104
|
}
|
|
4014
4105
|
if (!screen || !pressedComponentId) return void 0;
|
|
4015
|
-
const meta =
|
|
4106
|
+
const meta = chunkAYWMBMSN_js.getScreenMetadata(screen);
|
|
4016
4107
|
const actions = meta?.actions;
|
|
4017
4108
|
if (!actions || actions.length === 0) return void 0;
|
|
4018
4109
|
for (const a of actions) {
|
|
4019
4110
|
if (typeof a === "string") continue;
|
|
4020
|
-
if (
|
|
4111
|
+
if (chunkAYWMBMSN_js.idLooselyMatches(a.id, pressedComponentId)) {
|
|
4021
4112
|
const inferred = a.appilotsInferred;
|
|
4022
4113
|
if (inferred && typeof inferred === "object") return inferred;
|
|
4023
4114
|
return void 0;
|
|
@@ -4032,7 +4123,7 @@ async function settleTurn(input) {
|
|
|
4032
4123
|
const successById = new Map(input.results.map((r) => [r.actionId, r.success]));
|
|
4033
4124
|
const typeById = new Map(input.results.map((r) => [r.actionId, r.type]));
|
|
4034
4125
|
if (input.hadNavigate) {
|
|
4035
|
-
const settle = await
|
|
4126
|
+
const settle = await chunkAYWMBMSN_js.waitForScreenSettle({
|
|
4036
4127
|
expectingChange: true,
|
|
4037
4128
|
fromScreen: input.preNavigateScreen ?? null,
|
|
4038
4129
|
fromSignature: input.preNavigateSignature ?? null,
|
|
@@ -4042,19 +4133,19 @@ async function settleTurn(input) {
|
|
|
4042
4133
|
console.log(
|
|
4043
4134
|
`[Appilots] settleTurn: post-navigate settle done \u2014 screen="${settle.screen}" transitioned=${settle.transitioned} timedOut=${settle.timedOut} waitedMs=${settle.waitedMs}`
|
|
4044
4135
|
);
|
|
4045
|
-
const navigationMoved = settle.transitioned ||
|
|
4136
|
+
const navigationMoved = settle.transitioned || chunkAYWMBMSN_js.screenDepartedBaseline(
|
|
4046
4137
|
input.preNavigateScreen ?? null,
|
|
4047
4138
|
input.preNavigateSignature ?? null
|
|
4048
|
-
) || !!navigateTargetScreen && !!settle.screen &&
|
|
4139
|
+
) || !!navigateTargetScreen && !!settle.screen && chunkAYWMBMSN_js.routesBelongToSameFeature(settle.screen, navigateTargetScreen);
|
|
4049
4140
|
if (!navigationMoved) {
|
|
4050
|
-
|
|
4141
|
+
chunkAYWMBMSN_js.appilotsDebugWarn(
|
|
4051
4142
|
`tool-without-effect: navigate emitted but screen did not change (stayed at "${input.preNavigateScreen ?? "unknown"}", waitedMs=${settle.waitedMs}). Likely causes: target screenName missing from MCP doc, nested-nav path absent, or React Navigation rejected the route.`
|
|
4052
4143
|
);
|
|
4053
4144
|
for (const [actionId, type] of typeById) {
|
|
4054
4145
|
if (type === "navigate") toolWithoutEffectIds.add(actionId);
|
|
4055
4146
|
}
|
|
4056
4147
|
}
|
|
4057
|
-
const loadSettle = await
|
|
4148
|
+
const loadSettle = await chunkAYWMBMSN_js.waitForLoadingSettle({
|
|
4058
4149
|
fromScreen: settle.screen ?? null,
|
|
4059
4150
|
maxMs: 3e3
|
|
4060
4151
|
});
|
|
@@ -4066,11 +4157,11 @@ async function settleTurn(input) {
|
|
|
4066
4157
|
const pressedAction = turnActions.find(
|
|
4067
4158
|
(a) => a.type === "ui_interaction" && a.payload?.componentId === pressedId
|
|
4068
4159
|
);
|
|
4069
|
-
const hints = resolveActionHints(
|
|
4160
|
+
const hints = resolveActionHints(chunkAYWMBMSN_js.getCurrentScreen(), pressedId, pressedAction?.payload);
|
|
4070
4161
|
const settleCapMs = hints?.isAsyncTrigger === true ? 1e4 : POST_ACTION_LOADING_MAX_MS;
|
|
4071
|
-
const loadSettle = await
|
|
4162
|
+
const loadSettle = await chunkAYWMBMSN_js.waitForLoadingSettle({
|
|
4072
4163
|
pressedComponentId: pressedId,
|
|
4073
|
-
fromScreen:
|
|
4164
|
+
fromScreen: chunkAYWMBMSN_js.getCurrentScreen(),
|
|
4074
4165
|
maxMs: settleCapMs
|
|
4075
4166
|
});
|
|
4076
4167
|
console.log(
|
|
@@ -4078,23 +4169,23 @@ async function settleTurn(input) {
|
|
|
4078
4169
|
);
|
|
4079
4170
|
if (loadSettle.loadingPending) loadingPending = true;
|
|
4080
4171
|
const listPressActions = turnActions.filter((action) => {
|
|
4081
|
-
const target =
|
|
4082
|
-
return target ?
|
|
4172
|
+
const target = chunkAYWMBMSN_js.actionPressTargetId(action);
|
|
4173
|
+
return target ? chunkAYWMBMSN_js.isListItemPressTarget(target) : false;
|
|
4083
4174
|
});
|
|
4084
4175
|
if (listPressActions.length > 0) {
|
|
4085
|
-
const baselineFingerprint =
|
|
4086
|
-
const postPressSettle = await
|
|
4176
|
+
const baselineFingerprint = chunkAYWMBMSN_js.probeLoadingState(pressedId, chunkAYWMBMSN_js.getCurrentScreen()).fingerprint;
|
|
4177
|
+
const postPressSettle = await chunkAYWMBMSN_js.waitForScreenSettle({
|
|
4087
4178
|
expectingChange: true,
|
|
4088
4179
|
fromScreen: input.preNavigateScreen ?? null,
|
|
4089
4180
|
fromSignature: input.preNavigateSignature ?? null,
|
|
4090
4181
|
maxMs: 2500
|
|
4091
4182
|
});
|
|
4092
|
-
await
|
|
4183
|
+
await chunkAYWMBMSN_js.waitForLoadingSettle({
|
|
4093
4184
|
pressedComponentId: pressedId,
|
|
4094
|
-
fromScreen:
|
|
4185
|
+
fromScreen: chunkAYWMBMSN_js.getCurrentScreen(),
|
|
4095
4186
|
maxMs: 4e3
|
|
4096
4187
|
});
|
|
4097
|
-
const afterFingerprint =
|
|
4188
|
+
const afterFingerprint = chunkAYWMBMSN_js.probeLoadingState(pressedId, chunkAYWMBMSN_js.getCurrentScreen()).fingerprint;
|
|
4098
4189
|
console.log(
|
|
4099
4190
|
`[Appilots] settleTurn: post-list-press settle \u2014 screen="${postPressSettle.screen}" transitioned=${postPressSettle.transitioned} timedOut=${postPressSettle.timedOut} waitedMs=${postPressSettle.waitedMs}`
|
|
4100
4191
|
);
|
|
@@ -4111,46 +4202,18 @@ async function settleTurn(input) {
|
|
|
4111
4202
|
}
|
|
4112
4203
|
var reactNativeChatAdapter = {
|
|
4113
4204
|
buildContext: buildAgentContext,
|
|
4114
|
-
getCurrentScreen:
|
|
4115
|
-
getCurrentScreenSignature:
|
|
4205
|
+
getCurrentScreen: chunkAYWMBMSN_js.getCurrentScreen,
|
|
4206
|
+
getCurrentScreenSignature: chunkAYWMBMSN_js.getCurrentScreenSignature,
|
|
4116
4207
|
settleTurn
|
|
4117
4208
|
};
|
|
4118
|
-
async function runWithConfirmedDestructiveContext(enabled, fn) {
|
|
4119
|
-
if (!enabled) return fn();
|
|
4120
|
-
const originalAlert = reactNative.Alert.alert;
|
|
4121
|
-
let consumed = false;
|
|
4122
|
-
let alertWork = null;
|
|
4123
|
-
reactNative.Alert.alert = (title, message, buttons, options) => {
|
|
4124
|
-
if (consumed) {
|
|
4125
|
-
return originalAlert(title, message, buttons, options);
|
|
4126
|
-
}
|
|
4127
|
-
const destructive = buttons?.find((button) => button.style === "destructive");
|
|
4128
|
-
const actionable = destructive ?? buttons?.find((button) => button.style !== "cancel" && typeof button.onPress === "function");
|
|
4129
|
-
if (actionable?.onPress) {
|
|
4130
|
-
consumed = true;
|
|
4131
|
-
console.log(
|
|
4132
|
-
"[Appilots] Suppressing native Alert during already-confirmed destructive agent action"
|
|
4133
|
-
);
|
|
4134
|
-
alertWork = Promise.resolve(actionable.onPress()).then(() => void 0);
|
|
4135
|
-
return;
|
|
4136
|
-
}
|
|
4137
|
-
return originalAlert(title, message, buttons, options);
|
|
4138
|
-
};
|
|
4139
|
-
try {
|
|
4140
|
-
const result = await fn();
|
|
4141
|
-
if (alertWork) await alertWork;
|
|
4142
|
-
return result;
|
|
4143
|
-
} finally {
|
|
4144
|
-
reactNative.Alert.alert = originalAlert;
|
|
4145
|
-
}
|
|
4146
|
-
}
|
|
4147
4209
|
function createReactNativeActionRunner(getOptions) {
|
|
4148
4210
|
return {
|
|
4149
4211
|
async execute(action, { confirmedDestructive }) {
|
|
4150
|
-
const { permissions, emit, navigationRef } = getOptions();
|
|
4151
|
-
const navRef = navigationRef?.current ? navigationRef : { current:
|
|
4212
|
+
const { permissions, emit, navigationRef, suppressNativeConfirm } = getOptions();
|
|
4213
|
+
const navRef = navigationRef?.current ? navigationRef : { current: chunkAYWMBMSN_js.getNavigationRef() };
|
|
4152
4214
|
return runWithConfirmedDestructiveContext(
|
|
4153
|
-
confirmedDestructive,
|
|
4215
|
+
confirmedDestructive && suppressNativeConfirm !== false,
|
|
4216
|
+
reactNative.Alert,
|
|
4154
4217
|
() => executeAction(action, {
|
|
4155
4218
|
navigationRef: navRef,
|
|
4156
4219
|
permissions,
|
|
@@ -4158,21 +4221,21 @@ function createReactNativeActionRunner(getOptions) {
|
|
|
4158
4221
|
})
|
|
4159
4222
|
);
|
|
4160
4223
|
},
|
|
4161
|
-
getCurrentScreen:
|
|
4162
|
-
getCurrentScreenSignature:
|
|
4224
|
+
getCurrentScreen: chunkAYWMBMSN_js.getCurrentScreen,
|
|
4225
|
+
getCurrentScreenSignature: chunkAYWMBMSN_js.getCurrentScreenSignature,
|
|
4163
4226
|
getScreenActionsMetadata(screen) {
|
|
4164
|
-
return
|
|
4227
|
+
return chunkAYWMBMSN_js.getScreenMetadata(screen)?.actions;
|
|
4165
4228
|
},
|
|
4166
|
-
waitForScreenSettle:
|
|
4229
|
+
waitForScreenSettle: chunkAYWMBMSN_js.waitForScreenSettle
|
|
4167
4230
|
};
|
|
4168
4231
|
}
|
|
4169
4232
|
|
|
4170
4233
|
// src/hooks/useAppilotsChat.ts
|
|
4171
4234
|
function useAppilotsChat(options = {}) {
|
|
4172
|
-
const { client, emit, subscribe } =
|
|
4235
|
+
const { client, emit, subscribe } = chunkAYWMBMSN_js.useAppilotsContext();
|
|
4173
4236
|
const machine = react.useMemo(
|
|
4174
|
-
() => new
|
|
4175
|
-
{ client, adapter: reactNativeChatAdapter, emit, warn:
|
|
4237
|
+
() => new chunkAYWMBMSN_js.ChatSessionMachine(
|
|
4238
|
+
{ client, adapter: reactNativeChatAdapter, emit, warn: chunkAYWMBMSN_js.appilotsDebugWarn },
|
|
4176
4239
|
options
|
|
4177
4240
|
),
|
|
4178
4241
|
// A new machine per client/provider instance — options are pushed in
|
|
@@ -4215,25 +4278,27 @@ var DEFAULT_PERMISSIONS2 = {
|
|
|
4215
4278
|
canSubmitForms: true
|
|
4216
4279
|
};
|
|
4217
4280
|
function useAppilotsActions(options = {}) {
|
|
4218
|
-
const { client, subscribe, config, emit } =
|
|
4281
|
+
const { client, subscribe, config, emit } = chunkAYWMBMSN_js.useAppilotsContext();
|
|
4219
4282
|
const { navigationRef, autoExecute = false } = options;
|
|
4220
4283
|
const runnerOptionsRef = react.useRef({
|
|
4221
4284
|
permissions: config.permissions ?? DEFAULT_PERMISSIONS2,
|
|
4222
4285
|
emit,
|
|
4223
|
-
navigationRef
|
|
4286
|
+
navigationRef,
|
|
4287
|
+
suppressNativeConfirm: config.suppressNativeConfirm
|
|
4224
4288
|
});
|
|
4225
4289
|
runnerOptionsRef.current = {
|
|
4226
4290
|
permissions: config.permissions ?? DEFAULT_PERMISSIONS2,
|
|
4227
4291
|
emit,
|
|
4228
|
-
navigationRef
|
|
4292
|
+
navigationRef,
|
|
4293
|
+
suppressNativeConfirm: config.suppressNativeConfirm
|
|
4229
4294
|
};
|
|
4230
4295
|
const machine = react.useMemo(
|
|
4231
|
-
() => new
|
|
4296
|
+
() => new chunkAYWMBMSN_js.ActionQueueMachine(
|
|
4232
4297
|
{
|
|
4233
4298
|
client,
|
|
4234
4299
|
adapter: createReactNativeActionRunner(() => runnerOptionsRef.current),
|
|
4235
4300
|
emit,
|
|
4236
|
-
warn:
|
|
4301
|
+
warn: chunkAYWMBMSN_js.appilotsDebugWarn
|
|
4237
4302
|
},
|
|
4238
4303
|
{ autoExecute }
|
|
4239
4304
|
),
|
|
@@ -4290,7 +4355,7 @@ function shouldShowSuggestedPrompts(args) {
|
|
|
4290
4355
|
|
|
4291
4356
|
// src/hooks/useSuggestedPrompts.ts
|
|
4292
4357
|
function useSuggestedPrompts(options) {
|
|
4293
|
-
const { client } =
|
|
4358
|
+
const { client } = chunkAYWMBMSN_js.useAppilotsContext();
|
|
4294
4359
|
const { enabled, limit = 4 } = options;
|
|
4295
4360
|
const [prompts, setPrompts] = react.useState([]);
|
|
4296
4361
|
const [isLoading, setIsLoading] = react.useState(false);
|
|
@@ -4300,8 +4365,8 @@ function useSuggestedPrompts(options) {
|
|
|
4300
4365
|
if (!enabled) return;
|
|
4301
4366
|
const requestId = ++requestIdRef.current;
|
|
4302
4367
|
let cancelled = false;
|
|
4303
|
-
const screen =
|
|
4304
|
-
const localDev = screen ? (
|
|
4368
|
+
const screen = chunkAYWMBMSN_js.getCurrentScreen() ?? void 0;
|
|
4369
|
+
const localDev = screen ? (chunkAYWMBMSN_js.getScreenMetadata(screen)?.suggestedPrompts ?? []).map((text) => ({
|
|
4305
4370
|
text,
|
|
4306
4371
|
source: "dev-defined"
|
|
4307
4372
|
})) : [];
|
|
@@ -4326,9 +4391,9 @@ function useSuggestedPrompts(options) {
|
|
|
4326
4391
|
}, [client, enabled, limit, refreshTick]);
|
|
4327
4392
|
react.useEffect(() => {
|
|
4328
4393
|
if (!enabled) return;
|
|
4329
|
-
let lastScreen =
|
|
4394
|
+
let lastScreen = chunkAYWMBMSN_js.getCurrentScreen();
|
|
4330
4395
|
const interval = setInterval(() => {
|
|
4331
|
-
const current =
|
|
4396
|
+
const current = chunkAYWMBMSN_js.getCurrentScreen();
|
|
4332
4397
|
if (current !== lastScreen) {
|
|
4333
4398
|
lastScreen = current;
|
|
4334
4399
|
setRefreshTick((t) => t + 1);
|
|
@@ -4343,14 +4408,14 @@ function useSuggestedPrompts(options) {
|
|
|
4343
4408
|
};
|
|
4344
4409
|
}
|
|
4345
4410
|
function useAppilotsNavigation() {
|
|
4346
|
-
const { emit } =
|
|
4411
|
+
const { emit } = chunkAYWMBMSN_js.useAppilotsContext();
|
|
4347
4412
|
const [currentScreen, setCurrentScreenState] = react.useState(null);
|
|
4348
4413
|
const [navigationHistory, setNavigationHistory] = react.useState([]);
|
|
4349
4414
|
const navigationRef = react.useRef(null);
|
|
4350
4415
|
const setCurrentScreen2 = react.useCallback(
|
|
4351
4416
|
(screenName) => {
|
|
4352
4417
|
setCurrentScreenState(screenName);
|
|
4353
|
-
|
|
4418
|
+
chunkAYWMBMSN_js.setCurrentScreen(screenName);
|
|
4354
4419
|
setNavigationHistory((prev) => [...prev, screenName]);
|
|
4355
4420
|
emit({
|
|
4356
4421
|
type: "navigation:change",
|
|
@@ -4381,7 +4446,7 @@ function useAppilotsNavigation() {
|
|
|
4381
4446
|
|
|
4382
4447
|
// src/hooks/useAppilots.ts
|
|
4383
4448
|
function useAppilots() {
|
|
4384
|
-
const { config, client } =
|
|
4449
|
+
const { config, client } = chunkAYWMBMSN_js.useAppilotsContext();
|
|
4385
4450
|
const chat = useAppilotsChat();
|
|
4386
4451
|
const navigation = useAppilotsNavigation();
|
|
4387
4452
|
const actions = useAppilotsActions();
|
|
@@ -4410,7 +4475,7 @@ function useAppilots() {
|
|
|
4410
4475
|
}
|
|
4411
4476
|
function useAppilotsField(id, options) {
|
|
4412
4477
|
const { value, onChangeText, ref, fieldType, label, screen } = options;
|
|
4413
|
-
const registry =
|
|
4478
|
+
const registry = chunkAYWMBMSN_js.useResolvedRegistry();
|
|
4414
4479
|
const valueRef = react.useRef(value);
|
|
4415
4480
|
const onChangeRef = react.useRef(onChangeText);
|
|
4416
4481
|
valueRef.current = value;
|
|
@@ -4438,7 +4503,7 @@ function useAppilotsField(id, options) {
|
|
|
4438
4503
|
}
|
|
4439
4504
|
function useAppilotsTarget(id, options) {
|
|
4440
4505
|
const { onPress, onLongPress, onScrollTo, label, screen } = options;
|
|
4441
|
-
const registry =
|
|
4506
|
+
const registry = chunkAYWMBMSN_js.useResolvedRegistry();
|
|
4442
4507
|
const onPressRef = react.useRef(onPress);
|
|
4443
4508
|
const onLongPressRef = react.useRef(onLongPress);
|
|
4444
4509
|
const onScrollToRef = react.useRef(onScrollTo);
|
|
@@ -4465,7 +4530,7 @@ function useAppilotsTarget(id, options) {
|
|
|
4465
4530
|
}
|
|
4466
4531
|
function useAppilotsToggle(id, options) {
|
|
4467
4532
|
const { value, onValueChange, label, screen } = options;
|
|
4468
|
-
const registry =
|
|
4533
|
+
const registry = chunkAYWMBMSN_js.useResolvedRegistry();
|
|
4469
4534
|
const valueRef = react.useRef(value);
|
|
4470
4535
|
const onChangeRef = react.useRef(onValueChange);
|
|
4471
4536
|
valueRef.current = value;
|
|
@@ -4488,7 +4553,7 @@ function useAppilotsToggle(id, options) {
|
|
|
4488
4553
|
}
|
|
4489
4554
|
function useAppilotsSlider(id, options) {
|
|
4490
4555
|
const { value, onValueChange, min, max, step, label, screen } = options;
|
|
4491
|
-
const registry =
|
|
4556
|
+
const registry = chunkAYWMBMSN_js.useResolvedRegistry();
|
|
4492
4557
|
const valueRef = react.useRef(value);
|
|
4493
4558
|
const onChangeRef = react.useRef(onValueChange);
|
|
4494
4559
|
valueRef.current = value;
|