autokap 2.0.1 → 2.0.2
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.
|
@@ -41,3 +41,13 @@ export declare function resolveTarget(page: Page, options: ResolveOptions): Prom
|
|
|
41
41
|
* language subtag → base field → first non-empty map value.
|
|
42
42
|
*/
|
|
43
43
|
export declare function localizeSemanticTarget(target: SemanticTarget, locale?: string): SemanticTarget;
|
|
44
|
+
/**
|
|
45
|
+
* Emits a one-line warning when the active locale has NO entry in any of the
|
|
46
|
+
* target's `*ByLocale` maps, so the resolver is about to fall back to another
|
|
47
|
+
* language's string. This is the failure mode behind captures that pass in
|
|
48
|
+
* every language whose text was captured and fail in the ones that were only
|
|
49
|
+
* guessed (or never translated): the fallback string doesn't match the
|
|
50
|
+
* localized UI, and the CLICK/TYPE fails deep in the run instead of surfacing
|
|
51
|
+
* the real cause. Silent otherwise — no maps or a matching entry logs nothing.
|
|
52
|
+
*/
|
|
53
|
+
export declare function warnOnMissingLocaleEntry(target: SemanticTarget, locale?: string): void;
|
|
Binary file
|
|
@@ -8,7 +8,7 @@ import fs from 'node:fs/promises';
|
|
|
8
8
|
import os from 'node:os';
|
|
9
9
|
import path from 'node:path';
|
|
10
10
|
import { humanType, moveMouse, } from './mouse-animation.js';
|
|
11
|
-
import { resolveTarget } from './semantic-resolver.js';
|
|
11
|
+
import { resolveTarget, localizeSemanticTarget } from './semantic-resolver.js';
|
|
12
12
|
import { logger } from './logger.js';
|
|
13
13
|
import { ClipCaptureLoop } from './clip-capture-loop.js';
|
|
14
14
|
import { FfmpegX11Recorder } from './ffmpeg-x11-recorder.js';
|
|
@@ -1369,18 +1369,44 @@ export class WebPlaywrightLocal {
|
|
|
1369
1369
|
}
|
|
1370
1370
|
}
|
|
1371
1371
|
}
|
|
1372
|
-
function describeResolveOptions(opts) {
|
|
1372
|
+
export function describeResolveOptions(opts) {
|
|
1373
1373
|
const parts = [];
|
|
1374
1374
|
if (opts.selector)
|
|
1375
1375
|
parts.push(`selector="${opts.selector}"`);
|
|
1376
|
-
if (opts.target
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1376
|
+
if (opts.target) {
|
|
1377
|
+
// Project the target onto the active locale so the message reports what was
|
|
1378
|
+
// actually searched: the `*ByLocale` maps collapse onto their base field.
|
|
1379
|
+
// Without this, a target expressed purely through `textByLocale` (no role,
|
|
1380
|
+
// no plain text) rendered as the misleading "no target specified" even
|
|
1381
|
+
// though a localized string was attempted — which sends debugging down the
|
|
1382
|
+
// wrong path (it looks like the opcode carries no target at all).
|
|
1383
|
+
const projected = localizeSemanticTarget(opts.target, opts.locale);
|
|
1384
|
+
if (projected.role)
|
|
1385
|
+
parts.push(`role="${projected.role}"`);
|
|
1386
|
+
if (projected.text)
|
|
1387
|
+
parts.push(`text="${projected.text}"`);
|
|
1388
|
+
if (projected.label)
|
|
1389
|
+
parts.push(`label="${projected.label}"`);
|
|
1390
|
+
if (projected.placeholder)
|
|
1391
|
+
parts.push(`placeholder="${projected.placeholder}"`);
|
|
1392
|
+
if (projected.near)
|
|
1393
|
+
parts.push(`near="${projected.near}"`);
|
|
1394
|
+
if (opts.locale)
|
|
1395
|
+
parts.push(`locale="${opts.locale}"`);
|
|
1396
|
+
// Echo the raw locale maps so a missing or mistranslated entry for the
|
|
1397
|
+
// active locale is obvious at a glance (e.g. `fr` guessed as "Nouvelle
|
|
1398
|
+
// capture" when the deployed UI reads "Nouveau programme de capture").
|
|
1399
|
+
const describeMap = (name, map) => {
|
|
1400
|
+
const entries = Object.entries(map ?? {});
|
|
1401
|
+
if (entries.length > 0) {
|
|
1402
|
+
parts.push(`${name}={${entries.map(([k, v]) => `${k}:"${v}"`).join(', ')}}`);
|
|
1403
|
+
}
|
|
1404
|
+
};
|
|
1405
|
+
describeMap('textByLocale', opts.target.textByLocale);
|
|
1406
|
+
describeMap('labelByLocale', opts.target.labelByLocale);
|
|
1407
|
+
describeMap('placeholderByLocale', opts.target.placeholderByLocale);
|
|
1408
|
+
describeMap('nearByLocale', opts.target.nearByLocale);
|
|
1409
|
+
}
|
|
1384
1410
|
return parts.join(', ') || 'no target specified';
|
|
1385
1411
|
}
|
|
1386
1412
|
async function captureSurfaceMatches(page, expected) {
|