@appilots/sdk 0.2.0 → 0.3.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/dist/{chunk-GEM6TPAK.mjs → chunk-BKFO4DHW.mjs} +32 -198
- package/dist/{chunk-KCDNL4HV.mjs → chunk-DUSYQXAQ.mjs} +1 -1
- package/dist/{chunk-SIBKF7AA.js → chunk-MCY5YFYD.js} +619 -65
- package/dist/{chunk-KGN3DNGX.js → chunk-N2I3CA7Q.js} +5 -5
- package/dist/{chunk-HDLZGXNF.mjs → chunk-QMSMXTED.mjs} +602 -66
- package/dist/{chunk-IASJ7YHC.js → chunk-XNKPS7W3.js} +173 -339
- package/dist/hooks/index.d.mts +2 -1
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/index.js +11 -11
- package/dist/hooks/index.mjs +2 -2
- package/dist/index-BYVRBzjJ.d.mts +619 -0
- package/dist/index-BYVRBzjJ.d.ts +619 -0
- package/dist/index.d.mts +109 -64
- package/dist/index.d.ts +109 -64
- package/dist/index.js +84 -462
- package/dist/index.mjs +10 -403
- package/dist/navigation/index.js +13 -13
- package/dist/navigation/index.mjs +2 -2
- package/package.json +16 -15
- package/dist/index-BDb1WVNo.d.mts +0 -1300
- package/dist/index-BDb1WVNo.d.ts +0 -1300
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getFiberRoot, getCurrentScreen, getActiveRouteNames, elementRegistry, useAppilotsContext, recordAppilotsDebugTrace, getCurrentScreenSignature, waitForScreenSettle, screenDepartedBaseline, routesBelongToSameFeature, appilotsDebugWarn, waitForLoadingSettle, probeLoadingState, StreamTransportError, StreamAbortError, getDefaultRegistry, getNavigationRef, getScreenMetadata, setCurrentScreen, useResolvedRegistry, listRegistry, componentRegistry, getNavigationStateSnapshot, getAllScreens } from './chunk-
|
|
1
|
+
import { getFiberRoot, getCurrentScreen, getActiveRouteNames, elementRegistry, useAppilotsContext, recordAppilotsDebugTrace, getCurrentScreenSignature, fingerprintAction, turnHasConfirmActions, waitForScreenSettle, screenDepartedBaseline, routesBelongToSameFeature, appilotsDebugWarn, waitForLoadingSettle, actionPressTargetId, isListItemPressTarget, probeLoadingState, buildContinuationFailureMessage, StreamTransportError, StreamAbortError, getDefaultRegistry, getNavigationRef, getScreenMetadata, setCurrentScreen, useResolvedRegistry, listRegistry, componentRegistry, getNavigationStateSnapshot, metadataMatchesComponentId, isOptionalStepAutomationFailure, OPTIONAL_STEP_AUTOMATION_HINT, normalize2, matchScore, getAllScreens, looksDestructiveActionLabel, isGenericSelectValue } from './chunk-QMSMXTED.mjs';
|
|
2
2
|
import { useRef, useState, useCallback, useEffect } from 'react';
|
|
3
3
|
import { Alert } from 'react-native';
|
|
4
4
|
|
|
@@ -1232,27 +1232,6 @@ function findInteractiveByIdentifier(query, options = {}) {
|
|
|
1232
1232
|
return bestHandle;
|
|
1233
1233
|
}
|
|
1234
1234
|
|
|
1235
|
-
// src/hooks/fingerprint.ts
|
|
1236
|
-
function fingerprintAction(action, screen) {
|
|
1237
|
-
const p = action.payload ?? {};
|
|
1238
|
-
const scope = `@${screen ?? "?"}`;
|
|
1239
|
-
switch (action.type) {
|
|
1240
|
-
case "navigate":
|
|
1241
|
-
return `navigate${scope}:${p.screenName ?? "?"}`;
|
|
1242
|
-
case "form_fill": {
|
|
1243
|
-
const fields = p.fields ?? [];
|
|
1244
|
-
const ids = fields.map((f) => String(f?.fieldId ?? "?")).sort();
|
|
1245
|
-
return `form_fill${scope}:${ids.join(",")}`;
|
|
1246
|
-
}
|
|
1247
|
-
case "ui_interaction":
|
|
1248
|
-
return `ui_interaction${scope}:${p.action ?? "?"}:${p.componentId ?? p.targetId ?? "?"}`;
|
|
1249
|
-
case "confirm":
|
|
1250
|
-
return `confirm${scope}:${p.message ?? p.title ?? "?"}`;
|
|
1251
|
-
default:
|
|
1252
|
-
return `${action.type}${scope}:${JSON.stringify(p)}`;
|
|
1253
|
-
}
|
|
1254
|
-
}
|
|
1255
|
-
|
|
1256
1235
|
// src/hooks/visibleMessages.ts
|
|
1257
1236
|
var INTERNAL_MARKER_RE = /^\[(?:Permission policy notice|Recovery exhausted|User rejected the proposed action)[^\]]*\]:\s*/i;
|
|
1258
1237
|
var TECHNICAL_TRACE_RE = /(^|\n)\s*(?:Results:|[-*]\s*[✓✗]\s+|(?:press|click|tap|navigate|form_fill|ui_interaction|scroll_list)\b|(?:Cliquei|Clicked)\s+em\s+(?:el:|list-\d+-item-\d+|[A-Za-z]+:))/i;
|
|
@@ -1279,61 +1258,6 @@ function isInternalTraceMessage(message) {
|
|
|
1279
1258
|
return TECHNICAL_TRACE_RE.test(content) || TECHNICAL_SELECTOR_RE.test(content);
|
|
1280
1259
|
}
|
|
1281
1260
|
|
|
1282
|
-
// src/hooks/continuationErrors.ts
|
|
1283
|
-
function normalize2(value) {
|
|
1284
|
-
return value.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[‘’]/g, "'").toLowerCase();
|
|
1285
|
-
}
|
|
1286
|
-
function detectLocaleFromUserTexts(texts) {
|
|
1287
|
-
for (const raw of texts) {
|
|
1288
|
-
const normalized = normalize2(raw);
|
|
1289
|
-
if (/[ãõáéíóúâêôç]/i.test(raw) || /\b(voce|voces|pra|assinatura|cancela|canela|segunda|certo|quais|tenho|pode|posso)\b/.test(
|
|
1290
|
-
normalized
|
|
1291
|
-
)) {
|
|
1292
|
-
return "pt";
|
|
1293
|
-
}
|
|
1294
|
-
if (/[áéíóúñ¿¡]/i.test(raw) || /\b(cancela|segunda|suscripcion|puedo|cuales|hola)\b/.test(normalized)) {
|
|
1295
|
-
return "es";
|
|
1296
|
-
}
|
|
1297
|
-
if (/[àâçéèêëîïôûùüÿœ]/i.test(raw) || /\b(annuler|deuxieme|abonnement|bonjour)\b/.test(normalized)) {
|
|
1298
|
-
return "fr";
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
return "en";
|
|
1302
|
-
}
|
|
1303
|
-
var copy = {
|
|
1304
|
-
pt: {
|
|
1305
|
-
rateLimit: "O provedor de IA atingiu o limite de uso durante a automa\xE7\xE3o. Aguarde um momento e pe\xE7a para continuar, ou aumente o limite de tokens por minuto.",
|
|
1306
|
-
invalidInput: "N\xE3o consegui continuar a automa\xE7\xE3o por um problema interno de sincroniza\xE7\xE3o. Pode tentar de novo ou fazer essa parte manualmente?",
|
|
1307
|
-
generic: (detail) => `Perdi o fio da automa\xE7\xE3o (${detail}). Pode continuar manualmente ou me pedir de novo?`
|
|
1308
|
-
},
|
|
1309
|
-
es: {
|
|
1310
|
-
rateLimit: "El proveedor de IA alcanz\xF3 su l\xEDmite de uso durante la automatizaci\xF3n. Espera un momento y p\xEDdeme continuar, o aumenta el l\xEDmite de tokens por minuto.",
|
|
1311
|
-
invalidInput: "No pude continuar la automatizaci\xF3n por un problema interno de sincronizaci\xF3n. \xBFPuedes intentarlo de nuevo o hacer esta parte manualmente?",
|
|
1312
|
-
generic: (detail) => `Perd\xED el hilo de la automatizaci\xF3n (${detail}). \xBFPuedes continuar manualmente o ped\xEDrmelo de nuevo?`
|
|
1313
|
-
},
|
|
1314
|
-
fr: {
|
|
1315
|
-
rateLimit: "Le fournisseur d'IA a atteint sa limite d'utilisation pendant l'automatisation. Attendez un instant et demandez-moi de continuer, ou augmentez la limite de tokens par minute.",
|
|
1316
|
-
invalidInput: "Je n'ai pas pu poursuivre l'automatisation \xE0 cause d'un probl\xE8me interne de synchronisation. Pouvez-vous r\xE9essayer ou faire cette \xE9tape manuellement ?",
|
|
1317
|
-
generic: (detail) => `J'ai perdu le fil de l'automatisation (${detail}). Vous pouvez continuer manuellement ou me redemander ?`
|
|
1318
|
-
},
|
|
1319
|
-
en: {
|
|
1320
|
-
rateLimit: "Your AI provider hit its rate limit during automation. Wait a moment and ask me to continue, or raise your TPM limit.",
|
|
1321
|
-
invalidInput: "I could not continue the automation because of an internal sync issue. You can try again or take over manually.",
|
|
1322
|
-
generic: (detail) => `I lost my footing during automation (${detail}). You can take over from here.`
|
|
1323
|
-
}
|
|
1324
|
-
};
|
|
1325
|
-
function buildContinuationFailureMessage(rawError, recentUserTexts) {
|
|
1326
|
-
const locale = detectLocaleFromUserTexts(recentUserTexts);
|
|
1327
|
-
const strings = copy[locale] ?? copy.en;
|
|
1328
|
-
if (/rate limit|tokens per min|tpm/i.test(rawError)) {
|
|
1329
|
-
return strings.rateLimit;
|
|
1330
|
-
}
|
|
1331
|
-
if (/invalid input|validation_error|422/i.test(rawError)) {
|
|
1332
|
-
return strings.invalidInput;
|
|
1333
|
-
}
|
|
1334
|
-
return strings.generic(rawError);
|
|
1335
|
-
}
|
|
1336
|
-
|
|
1337
1261
|
// src/executor/formWriteEffect.ts
|
|
1338
1262
|
var CREATE_FORM_ROUTE_RE = /vehiclecreate|subscriptioncreate|vehicleedit|subscriptionedit|maintenancecreate|create|cadastr|register|novo|edit/i;
|
|
1339
1263
|
var SUBMIT_BUTTON_RE = /cadastrar|registrar|salvar|submit|register|guardar|enviar|confirmar|save/i;
|
|
@@ -1381,32 +1305,6 @@ function formFillLackedWriteEffect(action, snap, activePath = []) {
|
|
|
1381
1305
|
return Array.isArray(payload?.fields) && payload.fields.length > 0;
|
|
1382
1306
|
}
|
|
1383
1307
|
|
|
1384
|
-
// src/introspection/actionTargets.ts
|
|
1385
|
-
var LIST_ITEM_TARGET_RE = /^list-\d+-item-\d+$/i;
|
|
1386
|
-
var DESTRUCTIVE_LABEL_RE = /\b(cancelar?\w*|cancel(?:ar|led|ation|amento)?|delete\w*|exclu\w*|delet\w*|remov\w*|remove|apag\w*|destroy\w*|unsubscribe\w*)\b/i;
|
|
1387
|
-
function isListItemPressTarget(value) {
|
|
1388
|
-
if (typeof value !== "string" || !value.trim()) return false;
|
|
1389
|
-
return LIST_ITEM_TARGET_RE.test(value.trim());
|
|
1390
|
-
}
|
|
1391
|
-
function looksDestructiveActionLabel(value) {
|
|
1392
|
-
if (typeof value !== "string" || !value.trim()) return false;
|
|
1393
|
-
return DESTRUCTIVE_LABEL_RE.test(value.trim());
|
|
1394
|
-
}
|
|
1395
|
-
|
|
1396
|
-
// src/hooks/turnContinuation.ts
|
|
1397
|
-
function actionPressTargetId(action) {
|
|
1398
|
-
if (action.type !== "ui_interaction") return null;
|
|
1399
|
-
const payload = action.payload;
|
|
1400
|
-
const componentId = payload?.componentId;
|
|
1401
|
-
if (typeof componentId === "string" && componentId.trim()) return componentId.trim();
|
|
1402
|
-
const targetId = payload?.targetId;
|
|
1403
|
-
if (typeof targetId === "string" && targetId.trim()) return targetId.trim();
|
|
1404
|
-
return null;
|
|
1405
|
-
}
|
|
1406
|
-
function turnHasConfirmActions(actions) {
|
|
1407
|
-
return actions.some((action) => action.type === "confirm");
|
|
1408
|
-
}
|
|
1409
|
-
|
|
1410
1308
|
// src/hooks/useAppilotsChat.ts
|
|
1411
1309
|
var ESCALATION_RECONNECT_MAX_MS = 3e4;
|
|
1412
1310
|
function resolveScreenMetadata() {
|
|
@@ -1423,6 +1321,7 @@ function resolveScreenMetadata() {
|
|
|
1423
1321
|
}
|
|
1424
1322
|
function buildAgentContext(extras = {}) {
|
|
1425
1323
|
const context = {};
|
|
1324
|
+
context.platform = "react-native";
|
|
1426
1325
|
const screen = getCurrentScreen();
|
|
1427
1326
|
if (screen) context.currentScreen = screen;
|
|
1428
1327
|
const navigationState = getNavigationStateSnapshot();
|
|
@@ -3182,27 +3081,6 @@ async function waitForPostSubmitOutcome(options) {
|
|
|
3182
3081
|
};
|
|
3183
3082
|
}
|
|
3184
3083
|
|
|
3185
|
-
// src/executor/handlers/formFillMatching.ts
|
|
3186
|
-
function normalize6(s) {
|
|
3187
|
-
return s.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9]/g, "");
|
|
3188
|
-
}
|
|
3189
|
-
function matchScore(needle, hay) {
|
|
3190
|
-
if (!needle || !hay) return 0;
|
|
3191
|
-
if (needle === hay) return 100;
|
|
3192
|
-
if (hay.startsWith(needle) || needle.startsWith(hay)) return 75;
|
|
3193
|
-
if (hay.endsWith(needle) || needle.endsWith(hay)) return 60;
|
|
3194
|
-
if (hay.includes(needle) || needle.includes(hay)) return 40;
|
|
3195
|
-
return 0;
|
|
3196
|
-
}
|
|
3197
|
-
function isGenericSelectValue(value) {
|
|
3198
|
-
if (value === void 0 || value === null || value === "") return true;
|
|
3199
|
-
const normalized = normalize6(String(value));
|
|
3200
|
-
if (!normalized) return true;
|
|
3201
|
-
return /^(any|qualquer|random|aleatorio|aleatoria|auto|automatico|automatica|mock|mockado|mockada|mockados|mockadas|dummy|sample|exemplo|default|padrao|teste|test)$/.test(
|
|
3202
|
-
normalized
|
|
3203
|
-
);
|
|
3204
|
-
}
|
|
3205
|
-
|
|
3206
3084
|
// ../shared/dist/chunk-ERITSWKE.mjs
|
|
3207
3085
|
var DEFAULT_FUZZY_FLOOR = 4;
|
|
3208
3086
|
function normalizeId(value) {
|
|
@@ -3288,39 +3166,6 @@ function resolveTarget(requested, candidates, opts = {}) {
|
|
|
3288
3166
|
return { status: "matched", id: ids[0], tier: "fuzzy" };
|
|
3289
3167
|
}
|
|
3290
3168
|
|
|
3291
|
-
// src/executor/interactionGuidance.ts
|
|
3292
|
-
var LIST_ORDINAL_RE2 = /^list-\d+-item-\d+$/i;
|
|
3293
|
-
function normalizeId2(value) {
|
|
3294
|
-
return value.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
|
|
3295
|
-
}
|
|
3296
|
-
function isOptionalCosmeticTargetId(targetId) {
|
|
3297
|
-
if (typeof targetId !== "string" || !targetId.trim()) return false;
|
|
3298
|
-
const id = normalizeId2(targetId);
|
|
3299
|
-
return /foto|photo|avatar|icone|icon|emoji|sheetaction|sheet-action|btn-foto/.test(id) || id.includes("photo-sheet");
|
|
3300
|
-
}
|
|
3301
|
-
function routeLooksLikeFormContext(route) {
|
|
3302
|
-
const haystack = normalizeId2(route ?? "");
|
|
3303
|
-
return /create|edit|form|cadastr|register|novo|vehiclecreate|subscriptioncreate|vehicleedit|subscriptioncreate/.test(
|
|
3304
|
-
haystack
|
|
3305
|
-
);
|
|
3306
|
-
}
|
|
3307
|
-
function screenPathParts(screen) {
|
|
3308
|
-
if (!screen) return [];
|
|
3309
|
-
return screen.split("/").map((part) => part.trim()).filter(Boolean);
|
|
3310
|
-
}
|
|
3311
|
-
function isMisappliedListOrdinalOnForm(targetId, screen, activePath) {
|
|
3312
|
-
if (typeof targetId !== "string" || !LIST_ORDINAL_RE2.test(targetId.trim())) {
|
|
3313
|
-
return false;
|
|
3314
|
-
}
|
|
3315
|
-
const routes = [...screenPathParts(screen), ...activePath ?? []];
|
|
3316
|
-
if (routes.length === 0) return routeLooksLikeFormContext(screen);
|
|
3317
|
-
return routes.some((route) => routeLooksLikeFormContext(route));
|
|
3318
|
-
}
|
|
3319
|
-
function isOptionalStepAutomationFailure(targetId, screen, activePath) {
|
|
3320
|
-
return isOptionalCosmeticTargetId(targetId) || isMisappliedListOrdinalOnForm(targetId, screen, activePath);
|
|
3321
|
-
}
|
|
3322
|
-
var OPTIONAL_STEP_AUTOMATION_HINT = "optional-step-automation-failed";
|
|
3323
|
-
|
|
3324
3169
|
// src/executor/handlers/uiInteractionHandler.ts
|
|
3325
3170
|
function findSnapshotButton(targetId) {
|
|
3326
3171
|
try {
|
|
@@ -3823,18 +3668,18 @@ function uiInteractionHandler(payload, context) {
|
|
|
3823
3668
|
// src/executor/formSubmitResolve.ts
|
|
3824
3669
|
var SUBMIT_LABEL_HINT_RE = /\b(submit|save|send|continue|next|sign\s*in|log\s*in|register|salvar|enviar|entrar|cadastrar|continuar|proximo|próximo|avancar|avançar|confirmar|guardar|registrarse|iniciar\s+sesi[óo]n|enregistrer|envoyer|valider|soumettre|confirmer|se\s+connecter|s['e]\s*inscrire)\b/i;
|
|
3825
3670
|
var AGENT_CHROME_TARGET_RE = /\b(fechar|close|dismiss|cancelar|cancel|limpar|clear|chat\s+do\s+assistente|assistant\s+chat)\b/i;
|
|
3826
|
-
function
|
|
3671
|
+
function normalize6(value) {
|
|
3827
3672
|
return value.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
|
|
3828
3673
|
}
|
|
3829
3674
|
function isAgentChromeTarget(id, label) {
|
|
3830
|
-
const hay =
|
|
3675
|
+
const hay = normalize6(`${id ?? ""} ${label ?? ""}`);
|
|
3831
3676
|
return AGENT_CHROME_TARGET_RE.test(hay);
|
|
3832
3677
|
}
|
|
3833
3678
|
function isSubmitLikeTarget(id, label) {
|
|
3834
3679
|
if (!id && !label) return false;
|
|
3835
3680
|
if (isAgentChromeTarget(id, label)) return false;
|
|
3836
|
-
const idNorm =
|
|
3837
|
-
|
|
3681
|
+
const idNorm = normalize6(id ?? "");
|
|
3682
|
+
normalize6(label ?? "");
|
|
3838
3683
|
if (/^submit[-_]/i.test(id ?? "")) return true;
|
|
3839
3684
|
if (submitLabelHintsSubmit(label ?? "")) return true;
|
|
3840
3685
|
if (submitLabelHintsSubmit(id ?? "")) return true;
|
|
@@ -3953,15 +3798,15 @@ function selectValueApplied(fieldId, requestedValue, currentValue, registry) {
|
|
|
3953
3798
|
if (!requested) return false;
|
|
3954
3799
|
const meta = getMetadataField(fieldId, registry);
|
|
3955
3800
|
const options = Array.isArray(meta?.options) ? meta.options : [];
|
|
3956
|
-
const requestedNorm =
|
|
3957
|
-
const currentNorm =
|
|
3801
|
+
const requestedNorm = normalize2(requested);
|
|
3802
|
+
const currentNorm = normalize2(currentValue);
|
|
3958
3803
|
if (currentNorm === requestedNorm) return true;
|
|
3959
3804
|
for (const option of options) {
|
|
3960
3805
|
const value = typeof option?.value === "string" ? option.value : "";
|
|
3961
3806
|
const label = typeof option?.label === "string" ? option.label : "";
|
|
3962
|
-
if (
|
|
3963
|
-
if (
|
|
3964
|
-
if (
|
|
3807
|
+
if (normalize2(value) === requestedNorm && normalize2(label) === currentNorm) return true;
|
|
3808
|
+
if (normalize2(label) === requestedNorm && normalize2(label) === currentNorm) return true;
|
|
3809
|
+
if (normalize2(value) === requestedNorm && normalize2(value) === currentNorm) return true;
|
|
3965
3810
|
}
|
|
3966
3811
|
return false;
|
|
3967
3812
|
}
|
|
@@ -3975,14 +3820,14 @@ function getMetadataField(fieldId, registry) {
|
|
|
3975
3820
|
if (comp.kind === "field" && comp.screen) screens.add(comp.screen);
|
|
3976
3821
|
}
|
|
3977
3822
|
}
|
|
3978
|
-
const needle =
|
|
3823
|
+
const needle = normalize2(fieldId);
|
|
3979
3824
|
for (const screenName of screens) {
|
|
3980
3825
|
const screenMeta = getScreenMetadata(screenName);
|
|
3981
3826
|
const fields = Array.isArray(screenMeta?.fields) ? screenMeta.fields : [];
|
|
3982
3827
|
const match = fields.find((field) => {
|
|
3983
3828
|
if (!field || typeof field !== "object") return false;
|
|
3984
|
-
const id = typeof field.id === "string" ?
|
|
3985
|
-
const label = typeof field.label === "string" ?
|
|
3829
|
+
const id = typeof field.id === "string" ? normalize2(field.id) : "";
|
|
3830
|
+
const label = typeof field.label === "string" ? normalize2(field.label) : "";
|
|
3986
3831
|
return id === needle || label === needle;
|
|
3987
3832
|
});
|
|
3988
3833
|
if (match) return match;
|
|
@@ -3994,11 +3839,11 @@ function resolveSelectOption(fieldId, value, registry) {
|
|
|
3994
3839
|
if (!requested) return void 0;
|
|
3995
3840
|
const meta = getMetadataField(fieldId, registry);
|
|
3996
3841
|
const options = Array.isArray(meta?.options) ? meta.options : [];
|
|
3997
|
-
const requestedNorm =
|
|
3842
|
+
const requestedNorm = normalize2(requested);
|
|
3998
3843
|
for (const option of options) {
|
|
3999
3844
|
const optionValue = typeof option?.value === "string" ? option.value : "";
|
|
4000
3845
|
const optionLabel = typeof option?.label === "string" ? option.label : "";
|
|
4001
|
-
if (
|
|
3846
|
+
if (normalize2(optionValue) === requestedNorm || normalize2(optionLabel) === requestedNorm) {
|
|
4002
3847
|
return { value: optionValue, label: optionLabel };
|
|
4003
3848
|
}
|
|
4004
3849
|
}
|
|
@@ -4053,7 +3898,7 @@ async function tryPressSelectOption(fieldId, value, registry, options = {}) {
|
|
|
4053
3898
|
}
|
|
4054
3899
|
function normalizeFieldType(type) {
|
|
4055
3900
|
if (typeof type !== "string") return void 0;
|
|
4056
|
-
const normalized =
|
|
3901
|
+
const normalized = normalize2(type);
|
|
4057
3902
|
if (normalized === "select" || normalized === "picker" || normalized === "dropdown") return "select";
|
|
4058
3903
|
if (normalized === "toggle" || normalized === "switch" || normalized === "checkbox") return "toggle";
|
|
4059
3904
|
if (normalized === "date") return "date";
|
|
@@ -4081,7 +3926,7 @@ function fieldCueTerms(fieldId, label) {
|
|
|
4081
3926
|
);
|
|
4082
3927
|
const terms = /* @__PURE__ */ new Set();
|
|
4083
3928
|
for (const value of raw) {
|
|
4084
|
-
const normalized =
|
|
3929
|
+
const normalized = normalize2(value);
|
|
4085
3930
|
if (normalized.length >= 3 && normalized !== "id") terms.add(normalized);
|
|
4086
3931
|
}
|
|
4087
3932
|
return [...terms];
|
|
@@ -4092,15 +3937,15 @@ function snapshotHasFieldCue(snap, fieldId, label) {
|
|
|
4092
3937
|
const visible = [
|
|
4093
3938
|
...snap.texts ?? [],
|
|
4094
3939
|
...(snap.buttons ?? []).map((b) => b.label ?? b.id ?? "")
|
|
4095
|
-
].map((text) =>
|
|
3940
|
+
].map((text) => normalize2(text)).filter(Boolean);
|
|
4096
3941
|
return visible.some((text) => terms.some((term) => text.includes(term) || term.includes(text)));
|
|
4097
3942
|
}
|
|
4098
3943
|
function scoreCandidateText(value, texts) {
|
|
4099
|
-
const valueNorm =
|
|
3944
|
+
const valueNorm = normalize2(String(value ?? ""));
|
|
4100
3945
|
if (!valueNorm) return 0;
|
|
4101
3946
|
let best = 0;
|
|
4102
3947
|
for (const text of texts) {
|
|
4103
|
-
const textNorm =
|
|
3948
|
+
const textNorm = normalize2(text);
|
|
4104
3949
|
if (!textNorm) continue;
|
|
4105
3950
|
best = Math.max(best, matchScore(valueNorm, textNorm));
|
|
4106
3951
|
}
|
|
@@ -4128,7 +3973,7 @@ function buildChoiceCandidates(snap, fieldId, value, allowFirstVisibleWhenNoCue,
|
|
|
4128
3973
|
const groupCueScore = Math.max(
|
|
4129
3974
|
globalCueScore,
|
|
4130
3975
|
...groupTexts.map((text) => {
|
|
4131
|
-
const normalized =
|
|
3976
|
+
const normalized = normalize2(text);
|
|
4132
3977
|
return fieldCueTerms(fieldId, fieldLabel).some(
|
|
4133
3978
|
(term) => normalized.includes(term) || term.includes(normalized)
|
|
4134
3979
|
) ? 80 : 0;
|
|
@@ -4165,7 +4010,7 @@ function buildChoiceCandidates(snap, fieldId, value, allowFirstVisibleWhenNoCue,
|
|
|
4165
4010
|
const elementCueScore = Math.max(
|
|
4166
4011
|
fieldCueVisible && elements.length <= 12 ? 50 : 0,
|
|
4167
4012
|
...cueTexts.map((text) => {
|
|
4168
|
-
const normalized =
|
|
4013
|
+
const normalized = normalize2(text);
|
|
4169
4014
|
return fieldTerms.some(
|
|
4170
4015
|
(term) => normalized.includes(term) || term.includes(normalized)
|
|
4171
4016
|
) ? 80 : 0;
|
|
@@ -4253,7 +4098,7 @@ async function selectVisibleChoiceAsync(fieldId, value, registry, options) {
|
|
|
4253
4098
|
}
|
|
4254
4099
|
function isContinuationButton(label) {
|
|
4255
4100
|
if (!label) return false;
|
|
4256
|
-
return /^(next|continue|proximo|prox|continuar|avancar|avançar)$/i.test(
|
|
4101
|
+
return /^(next|continue|proximo|prox|continuar|avancar|avançar)$/i.test(normalize2(label));
|
|
4257
4102
|
}
|
|
4258
4103
|
function pressContinuationButton(registry) {
|
|
4259
4104
|
const snap = captureSnapshot();
|
|
@@ -4287,14 +4132,14 @@ function findField(fieldId, registry) {
|
|
|
4287
4132
|
}
|
|
4288
4133
|
}
|
|
4289
4134
|
const currentScreenForTieBreak = getCurrentScreen();
|
|
4290
|
-
const needle =
|
|
4135
|
+
const needle = normalize2(fieldId);
|
|
4291
4136
|
let bestComp;
|
|
4292
4137
|
let bestScore = 0;
|
|
4293
4138
|
let bestOnCurrentScreen = false;
|
|
4294
4139
|
for (const comp of snapshot) {
|
|
4295
4140
|
if (comp.kind !== "field") continue;
|
|
4296
|
-
const candidates = [
|
|
4297
|
-
if (comp.label) candidates.push(
|
|
4141
|
+
const candidates = [normalize2(comp.id)];
|
|
4142
|
+
if (comp.label) candidates.push(normalize2(comp.label));
|
|
4298
4143
|
let candidateScore = 0;
|
|
4299
4144
|
for (const cand of candidates) {
|
|
4300
4145
|
const s = matchScore(needle, cand);
|
|
@@ -4325,12 +4170,12 @@ function findField(fieldId, registry) {
|
|
|
4325
4170
|
);
|
|
4326
4171
|
if (metaField && typeof metaField === "object" && metaField.label) {
|
|
4327
4172
|
const metaLabel = metaField.label;
|
|
4328
|
-
const metaNeedle =
|
|
4173
|
+
const metaNeedle = normalize2(metaLabel);
|
|
4329
4174
|
let mBest;
|
|
4330
4175
|
let mBestScore = 0;
|
|
4331
4176
|
for (const comp of snapshot) {
|
|
4332
4177
|
if (comp.kind !== "field" || !comp.label) continue;
|
|
4333
|
-
const score = matchScore(metaNeedle,
|
|
4178
|
+
const score = matchScore(metaNeedle, normalize2(comp.label));
|
|
4334
4179
|
if (score > mBestScore) {
|
|
4335
4180
|
mBestScore = score;
|
|
4336
4181
|
mBest = comp;
|
|
@@ -4835,7 +4680,7 @@ var FALLBACK_PAGE_PX = 600;
|
|
|
4835
4680
|
var PAGE_FRACTION = 0.85;
|
|
4836
4681
|
var POST_SCROLL_MOUNT_MS = 400;
|
|
4837
4682
|
var sleep3 = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
4838
|
-
function
|
|
4683
|
+
function normalizeId2(value) {
|
|
4839
4684
|
return String(value ?? "").toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9]+/g, "");
|
|
4840
4685
|
}
|
|
4841
4686
|
function buildDiagnose(category, targetId, candidates) {
|
|
@@ -4850,8 +4695,8 @@ function resolveListEntry(listId) {
|
|
|
4850
4695
|
const entries = listRegistry.snapshot();
|
|
4851
4696
|
if (entries.length === 0) return {};
|
|
4852
4697
|
if (listId) {
|
|
4853
|
-
const wanted =
|
|
4854
|
-
const match = entries.find((e) =>
|
|
4698
|
+
const wanted = normalizeId2(listId);
|
|
4699
|
+
const match = entries.find((e) => normalizeId2(e.id) === wanted);
|
|
4855
4700
|
if (match) return { entry: match };
|
|
4856
4701
|
return { candidates: entries.map((e) => e.id) };
|
|
4857
4702
|
}
|
|
@@ -5148,17 +4993,6 @@ async function executeAction(action, context) {
|
|
|
5148
4993
|
});
|
|
5149
4994
|
return result;
|
|
5150
4995
|
}
|
|
5151
|
-
|
|
5152
|
-
// src/hooks/confirmMatching.ts
|
|
5153
|
-
function metadataMatchesComponentId(metaId, componentId) {
|
|
5154
|
-
const norm = (s) => s.toLowerCase().replace(/^el:(button|link|input|toggle|listitem)[:_-]/, "").replace(/^(btn-|btn_|button-|button_|link-|link_)/, "").trim();
|
|
5155
|
-
const meta = norm(metaId);
|
|
5156
|
-
const comp = norm(componentId);
|
|
5157
|
-
if (!meta || !comp) return false;
|
|
5158
|
-
return meta === comp;
|
|
5159
|
-
}
|
|
5160
|
-
|
|
5161
|
-
// src/hooks/useAppilotsActions.ts
|
|
5162
4996
|
var DEFAULT_PERMISSIONS2 = {
|
|
5163
4997
|
canNavigate: true,
|
|
5164
4998
|
canFillForms: true,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useAppilotsContext, setNavigationRef, setCurrentScreen } from './chunk-
|
|
1
|
+
import { useAppilotsContext, setNavigationRef, setCurrentScreen } from './chunk-QMSMXTED.mjs';
|
|
2
2
|
import React, { useRef, useCallback, useEffect } from 'react';
|
|
3
3
|
|
|
4
4
|
function getActiveRouteName(state) {
|