@buffcore/cli 0.8.45 → 0.8.47
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/CHANGELOG.md +63 -0
- package/dist/commands/change-merge-remove.d.ts +9 -2
- package/dist/commands/change-merge-remove.js +27 -15
- package/dist/commands/design/check.d.ts +1 -1
- package/dist/commands/design/check.js +2 -1
- package/dist/commands/design/contract-size.d.ts +7 -0
- package/dist/commands/design/contract-size.js +47 -0
- package/dist/commands/design/tells.en.d.ts +2 -0
- package/dist/commands/design/tells.en.js +2 -0
- package/dist/commands/design/tells.es.js +2 -0
- package/dist/commands/extension/places-approval.d.ts +4 -0
- package/dist/commands/process-paths.d.ts +14 -0
- package/dist/commands/process-paths.js +90 -0
- package/dist/commands/prototype/ai-approval.d.ts +27 -0
- package/dist/commands/prototype/ai-approval.js +60 -0
- package/dist/commands/prototype/approver.d.ts +71 -0
- package/dist/commands/prototype/approver.js +168 -0
- package/dist/commands/prototype/browser.d.ts +4 -24
- package/dist/commands/prototype/browser.js +13 -76
- package/dist/commands/prototype/critique-gate.d.ts +14 -0
- package/dist/commands/prototype/critique-gate.js +48 -0
- package/dist/commands/prototype/fence.d.ts +1 -0
- package/dist/commands/prototype/fence.js +12 -0
- package/dist/commands/prototype/final-approval-grant.js +18 -0
- package/dist/commands/prototype/final-approval.js +4 -1
- package/dist/commands/prototype/index.js +3 -0
- package/dist/commands/prototype/layout-hints.d.ts +34 -0
- package/dist/commands/prototype/layout-hints.js +194 -0
- package/dist/commands/prototype/layout-measure.d.ts +39 -0
- package/dist/commands/prototype/layout-measure.js +97 -0
- package/dist/commands/prototype/layout-words.d.ts +2 -0
- package/dist/commands/prototype/layout-words.js +11 -0
- package/dist/commands/prototype/layout.en.d.ts +6 -0
- package/dist/commands/prototype/layout.en.js +7 -0
- package/dist/commands/prototype/load-location.js +2 -3
- package/dist/commands/prototype/loaded-garbage.d.ts +10 -0
- package/dist/commands/prototype/loaded-garbage.js +20 -0
- package/dist/commands/prototype/media-ready.d.ts +9 -3
- package/dist/commands/prototype/media-ready.js +9 -4
- package/dist/commands/prototype/messages.en.d.ts +15 -0
- package/dist/commands/prototype/messages.en.js +15 -0
- package/dist/commands/prototype/messages.js +15 -0
- package/dist/commands/prototype/milestone-versions.d.ts +4 -0
- package/dist/commands/prototype/prune-command.d.ts +5 -0
- package/dist/commands/prototype/prune-command.js +25 -0
- package/dist/commands/prototype/prune-words.d.ts +1 -0
- package/dist/commands/prototype/prune-words.js +7 -0
- package/dist/commands/prototype/prune.d.ts +16 -0
- package/dist/commands/prototype/prune.en.d.ts +9 -0
- package/dist/commands/prototype/prune.en.js +9 -0
- package/dist/commands/prototype/prune.es.d.ts +2 -0
- package/dist/commands/prototype/prune.es.js +9 -0
- package/dist/commands/prototype/prune.js +140 -0
- package/dist/commands/prototype/reopen-messages.d.ts +9 -0
- package/dist/commands/prototype/reopen-messages.js +19 -0
- package/dist/commands/prototype/report.d.ts +14 -0
- package/dist/commands/prototype/report.js +5 -1
- package/dist/commands/prototype/scene-check.d.ts +37 -0
- package/dist/commands/prototype/scene-check.js +68 -0
- package/dist/commands/prototype/scene-layout.d.ts +17 -0
- package/dist/commands/prototype/scene-layout.js +57 -0
- package/dist/commands/prototype/scene-look.d.ts +14 -0
- package/dist/commands/prototype/scene-look.js +89 -0
- package/dist/commands/prototype/scene-ready.d.ts +46 -0
- package/dist/commands/prototype/scene-ready.js +122 -0
- package/dist/commands/prototype/scene.d.ts +37 -3
- package/dist/commands/prototype/scene.js +103 -36
- package/dist/commands/prototype/selector-answer.d.ts +43 -0
- package/dist/commands/prototype/selector-answer.js +73 -0
- package/dist/commands/prototype/selector-misses.d.ts +19 -0
- package/dist/commands/prototype/selector-misses.js +78 -0
- package/dist/commands/prototype/selector-prompt.d.ts +23 -0
- package/dist/commands/prototype/selector-prompt.js +32 -0
- package/dist/commands/prototype/selector-run.d.ts +13 -0
- package/dist/commands/prototype/selector-run.js +113 -0
- package/dist/commands/prototype/selector.d.ts +54 -0
- package/dist/commands/prototype/selector.js +96 -0
- package/dist/commands/prototype/snapshot-ancestor.js +2 -0
- package/dist/commands/prototype/snapshot-bundle.d.ts +17 -3
- package/dist/commands/prototype/snapshot-bundle.js +69 -7
- package/dist/commands/prototype/snapshot-check-files.d.ts +2 -0
- package/dist/commands/prototype/snapshot-check-files.js +41 -0
- package/dist/commands/prototype/snapshot-command.d.ts +2 -0
- package/dist/commands/prototype/snapshot-command.js +23 -10
- package/dist/commands/prototype/snapshot-completion.d.ts +4 -0
- package/dist/commands/prototype/snapshot-completion.js +30 -2
- package/dist/commands/prototype/snapshot-dependencies.d.ts +23 -2
- package/dist/commands/prototype/snapshot-dependencies.js +120 -14
- package/dist/commands/prototype/snapshot-hashes.d.ts +7 -0
- package/dist/commands/prototype/snapshot-hashes.js +28 -0
- package/dist/commands/prototype/snapshot-inputs.d.ts +15 -6
- package/dist/commands/prototype/snapshot-inputs.js +140 -190
- package/dist/commands/prototype/snapshot-matrix.d.ts +58 -0
- package/dist/commands/prototype/snapshot-matrix.js +95 -0
- package/dist/commands/prototype/snapshot-metro-inputs.d.ts +8 -0
- package/dist/commands/prototype/snapshot-metro-inputs.js +81 -0
- package/dist/commands/prototype/snapshot-owners.d.ts +6 -2
- package/dist/commands/prototype/snapshot-owners.js +12 -3
- package/dist/commands/prototype/snapshot-progress-entry.d.ts +14 -0
- package/dist/commands/prototype/snapshot-progress-entry.js +85 -0
- package/dist/commands/prototype/snapshot-progress.d.ts +19 -2
- package/dist/commands/prototype/snapshot-progress.js +54 -102
- package/dist/commands/prototype/snapshot-registry.d.ts +14 -0
- package/dist/commands/prototype/snapshot-registry.js +121 -0
- package/dist/commands/prototype/snapshot-report.d.ts +4 -0
- package/dist/commands/prototype/snapshot-report.js +77 -12
- package/dist/commands/prototype/snapshot-requests.d.ts +13 -3
- package/dist/commands/prototype/snapshot-requests.js +68 -30
- package/dist/commands/prototype/snapshot-reuse.d.ts +6 -1
- package/dist/commands/prototype/snapshot-reuse.js +17 -7
- package/dist/commands/prototype/snapshot-scene-inputs.d.ts +30 -0
- package/dist/commands/prototype/snapshot-scene-inputs.js +210 -0
- package/dist/commands/prototype/snapshot-served-inputs.d.ts +3 -0
- package/dist/commands/prototype/snapshot-served-inputs.js +12 -0
- package/dist/commands/prototype/snapshot-server-record.d.ts +26 -0
- package/dist/commands/prototype/snapshot-server-record.js +135 -0
- package/dist/commands/prototype/snapshot-servers.d.ts +3 -1
- package/dist/commands/prototype/snapshot-servers.js +54 -4
- package/dist/commands/prototype/snapshot-setup.d.ts +3 -1
- package/dist/commands/prototype/snapshot-setup.js +2 -1
- package/dist/commands/prototype/snapshot-surface-inputs.d.ts +23 -0
- package/dist/commands/prototype/snapshot-surface-inputs.js +161 -0
- package/dist/commands/prototype/snapshot-vite-inputs.d.ts +22 -0
- package/dist/commands/prototype/snapshot-vite-inputs.js +209 -0
- package/dist/commands/prototype/snapshot.d.ts +6 -0
- package/dist/commands/prototype/snapshot.js +73 -10
- package/dist/commands/prototype/version-commands.d.ts +4 -0
- package/dist/commands/prototype/version-commands.js +36 -8
- package/dist/commands/prototype/versions.d.ts +28 -2
- package/dist/commands/prototype/versions.js +25 -1
- package/dist/commands/prototype/vite-fs-path.d.ts +4 -0
- package/dist/commands/prototype/vite-fs-path.js +15 -0
- package/dist/commands/remove-links.d.ts +6 -0
- package/dist/commands/remove-links.js +17 -0
- package/dist/commands/size-docs.d.ts +9 -0
- package/dist/commands/size-docs.en.d.ts +6 -0
- package/dist/commands/size-docs.en.js +6 -0
- package/dist/commands/size-docs.es.d.ts +2 -0
- package/dist/commands/size-docs.es.js +6 -0
- package/dist/commands/size-docs.js +28 -0
- package/dist/commands/size.d.ts +5 -2
- package/dist/commands/size.js +27 -9
- package/dist/commands/ui/approval-authority.d.ts +10 -2
- package/dist/commands/ui/approval-authority.js +1 -0
- package/dist/commands/ui/autopilot-ai-approve.d.ts +18 -0
- package/dist/commands/ui/autopilot-ai-approve.js +68 -0
- package/dist/commands/ui/autopilot-loop.js +5 -6
- package/dist/commands/ui/autopilot-merge.js +3 -0
- package/dist/commands/ui/autopilot.en.d.ts +23 -0
- package/dist/commands/ui/autopilot.en.js +23 -0
- package/dist/commands/ui/autopilot.es.d.ts +23 -0
- package/dist/commands/ui/autopilot.es.js +23 -0
- package/dist/commands/ui/chat/find.d.ts +2 -0
- package/dist/commands/ui/chat/find.js +13 -0
- package/dist/commands/ui/chat/fresh-codex.d.ts +39 -0
- package/dist/commands/ui/chat/fresh-codex.js +175 -0
- package/dist/commands/ui/chat/fresh-critique.js +13 -5
- package/dist/commands/ui/chat/fresh-launch.d.ts +19 -0
- package/dist/commands/ui/chat/fresh-launch.js +67 -11
- package/dist/commands/ui/chat/fresh-prompts.d.ts +2 -0
- package/dist/commands/ui/chat/fresh-prompts.js +2 -0
- package/dist/commands/ui/chat/fresh-secrets.d.ts +6 -0
- package/dist/commands/ui/chat/fresh-secrets.js +172 -0
- package/dist/commands/ui/chat/fresh.en.d.ts +1 -0
- package/dist/commands/ui/chat/fresh.en.js +2 -1
- package/dist/commands/ui/chat/fresh.es.d.ts +1 -0
- package/dist/commands/ui/chat/fresh.es.js +2 -1
- package/dist/commands/ui/chat/worktree.js +25 -5
- package/dist/commands/ui/index.js +3 -0
- package/dist/commands/ui/loop-approve.d.ts +30 -1
- package/dist/commands/ui/loop-approve.js +2 -2
- package/dist/commands/ui/merge-route.js +3 -0
- package/dist/commands/ui/places-change.d.ts +4 -0
- package/dist/commands/ui/prototype-main.d.ts +4 -0
- package/dist/commands/ui/reopen-route.d.ts +117 -0
- package/dist/commands/ui/reopen-route.js +97 -0
- package/dist/commands/ui/save-route.d.ts +2 -0
- package/dist/commands/ui/save-route.js +4 -0
- package/dist/commands/ui/studio-routes.js +2 -0
- package/dist/commands/ui/studio-state.d.ts +33 -0
- package/dist/commands/ui/studio-versions.d.ts +24 -0
- package/dist/commands/ui/worktrees.d.ts +1 -1
- package/dist/commands/ui/worktrees.js +19 -3
- package/dist/commands/worktree-sweep.d.ts +45 -0
- package/dist/commands/worktree-sweep.js +188 -0
- package/dist/commands/worktrees-command.d.ts +32 -0
- package/dist/commands/worktrees-command.en.d.ts +25 -0
- package/dist/commands/worktrees-command.en.js +55 -0
- package/dist/commands/worktrees-command.js +96 -0
- package/dist/main.js +2 -0
- package/dist/ui/page.js +82 -82
- package/docs/PROTOTYPE.md +6 -3
- package/docs/WORKBENCH.md +11 -6
- package/package.json +11 -11
- package/skills/ape-critique/SKILL.md +41 -6
- package/skills/ape-design-system/SKILL.md +3 -0
- package/skills/ape-plan-change/SKILL.md +6 -0
- package/skills/ape-prototype/SKILL.md +8 -4
- package/templates/product/apps/app/app.json +3 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Why a committed folder stays. */
|
|
2
|
+
export type KeptBecause = 'version' | 'newest' | 'head' | 'unsaved';
|
|
3
|
+
export interface PruneResult {
|
|
4
|
+
ok: true;
|
|
5
|
+
dryRun: boolean;
|
|
6
|
+
/** The folders removed (with `--dry-run`, the ones that would be), under `prototype/snapshots/`. */
|
|
7
|
+
removed: string[];
|
|
8
|
+
kept: {
|
|
9
|
+
folder: string;
|
|
10
|
+
because: KeptBecause;
|
|
11
|
+
}[];
|
|
12
|
+
}
|
|
13
|
+
/** Remove (or, with `dryRun`, list) the committed snapshot folders nothing needs. */
|
|
14
|
+
export declare function pruneSnapshots(root: string, { dryRun }?: {
|
|
15
|
+
dryRun?: boolean | undefined;
|
|
16
|
+
}): PruneResult;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const en = {
|
|
2
|
+
'prune.help': 'Remove committed snapshot folders no version names (keeps the newest, HEAD’s and unsaved ones); their history stays in git',
|
|
3
|
+
'prune.dryRunHelp': 'list what would be removed, and remove nothing',
|
|
4
|
+
'prune.jsonHelp': 'the result as JSON; exit 0 done, 2 could not run',
|
|
5
|
+
'prune.unreadable': 'Could not read {file}: fix it, then prune again.',
|
|
6
|
+
'prune.nothing': 'Nothing to remove: every committed snapshot folder is named by a version, the newest, HEAD’s or unsaved.',
|
|
7
|
+
'prune.wouldRemove': '{count, plural, one {Would remove # snapshot folder} other {Would remove # snapshot folders}} no version names: {folders}. Run without --dry-run to remove them.',
|
|
8
|
+
'prune.removed': '{count, plural, one {Removed # snapshot folder} other {Removed # snapshot folders}} no version names: {folders}. Commit the deletion: their history stays in git.',
|
|
9
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const es = {
|
|
2
|
+
'prune.help': 'Quita las carpetas de capturas guardadas que ninguna versión nombra (conserva la más reciente, la de HEAD y las que tienen cambios sin guardar); su historial queda en git',
|
|
3
|
+
'prune.dryRunHelp': 'lista lo que se quitaría, sin quitar nada',
|
|
4
|
+
'prune.jsonHelp': 'el resultado en JSON; sale con 0 si terminó, 2 si no pudo ejecutarse',
|
|
5
|
+
'prune.unreadable': 'No se pudo leer {file}: corrígelo y vuelve a ejecutar prune.',
|
|
6
|
+
'prune.nothing': 'No hay nada que quitar: cada carpeta de capturas guardada la nombra una versión, es la más reciente, la de HEAD o tiene cambios sin guardar.',
|
|
7
|
+
'prune.wouldRemove': '{count, plural, one {Se quitaría # carpeta de capturas} other {Se quitarían # carpetas de capturas}} que ninguna versión nombra: {folders}. Ejecuta sin --dry-run para quitarlas.',
|
|
8
|
+
'prune.removed': '{count, plural, one {Se quitó # carpeta de capturas} other {Se quitaron # carpetas de capturas}} que ninguna versión nombra: {folders}. Guarda el borrado en un commit: su historial queda en git.',
|
|
9
|
+
};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// `ape prototype prune`: committed snapshot folders under `prototype/snapshots/` that no version
|
|
2
|
+
// names are dead weight (about 2 MB of data each), and git keeps them in history. Prune removes
|
|
3
|
+
// them from the working tree; the person commits the deletion. It keeps every folder a record in
|
|
4
|
+
// `prototype/versions/` (or `design/approval.json`) names by its source commit or its report's
|
|
5
|
+
// fingerprint, the newest committed snapshot, HEAD's, any folder with unsaved changes, and `comp/`.
|
|
6
|
+
import { createHash } from 'node:crypto';
|
|
7
|
+
import { existsSync, readdirSync, readFileSync, rmSync } from 'node:fs';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
import { pruneText } from './prune-words.js';
|
|
10
|
+
import { git, gitBytes, snapshotsDir } from './report.js';
|
|
11
|
+
const SNAPSHOTS = 'prototype/snapshots/';
|
|
12
|
+
const HASH = /^[0-9a-f]{7,40}$/;
|
|
13
|
+
/** The commit-named folders git tracks under `prototype/snapshots/` (never `comp/`). */
|
|
14
|
+
function committedFolders(root) {
|
|
15
|
+
const listed = gitBytes(root, ['ls-files', '-z', '--', SNAPSHOTS]).toString('utf8');
|
|
16
|
+
const folders = new Set();
|
|
17
|
+
for (const path of listed.split('\0')) {
|
|
18
|
+
const [folder, file] = path.slice(SNAPSHOTS.length).split('/');
|
|
19
|
+
if (path.startsWith(SNAPSHOTS) && folder && file && HASH.test(folder))
|
|
20
|
+
folders.add(folder);
|
|
21
|
+
}
|
|
22
|
+
return [...folders].sort();
|
|
23
|
+
}
|
|
24
|
+
/** Every `commit` and `report` string anywhere in a record. */
|
|
25
|
+
function collect(value, into) {
|
|
26
|
+
if (Array.isArray(value))
|
|
27
|
+
for (const item of value)
|
|
28
|
+
collect(item, into);
|
|
29
|
+
else if (value && typeof value === 'object')
|
|
30
|
+
for (const [key, item] of Object.entries(value)) {
|
|
31
|
+
if (key === 'commit' && typeof item === 'string')
|
|
32
|
+
into.commits.add(item.toLowerCase());
|
|
33
|
+
else if (key === 'report' && typeof item === 'string')
|
|
34
|
+
into.reports.add(item);
|
|
35
|
+
else
|
|
36
|
+
collect(item, into);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** The JSON files under a folder, at any depth. */
|
|
40
|
+
function jsonFiles(dir) {
|
|
41
|
+
if (!existsSync(dir))
|
|
42
|
+
return [];
|
|
43
|
+
return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
|
|
44
|
+
const path = join(dir, entry.name);
|
|
45
|
+
if (entry.isDirectory())
|
|
46
|
+
return jsonFiles(path);
|
|
47
|
+
return entry.name.endsWith('.json') ? [path] : [];
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/** What the records name: source commits and report fingerprints. A record that won't parse refuses. */
|
|
51
|
+
function references(root) {
|
|
52
|
+
const into = { commits: new Set(), reports: new Set() };
|
|
53
|
+
const files = jsonFiles(join(root, 'prototype', 'versions'));
|
|
54
|
+
const approval = join(root, 'design', 'approval.json');
|
|
55
|
+
if (existsSync(approval))
|
|
56
|
+
files.push(approval);
|
|
57
|
+
for (const file of files) {
|
|
58
|
+
try {
|
|
59
|
+
collect(JSON.parse(readFileSync(file, 'utf8')), into);
|
|
60
|
+
}
|
|
61
|
+
catch (cause) {
|
|
62
|
+
throw new Error(pruneText('prune.unreadable', { file }), { cause });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return into;
|
|
66
|
+
}
|
|
67
|
+
const readReport = (root, folder) => {
|
|
68
|
+
try {
|
|
69
|
+
return readFileSync(join(snapshotsDir(root), folder, 'report.json'));
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const createdAt = (bytes) => {
|
|
76
|
+
try {
|
|
77
|
+
const at = JSON.parse(bytes?.toString('utf8') ?? '').createdAt;
|
|
78
|
+
return typeof at === 'string' ? at : '';
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return '';
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
/** The folders under `prototype/snapshots/` with unsaved changes, as `git status` lists them. */
|
|
85
|
+
function unsavedFolders(root) {
|
|
86
|
+
const status = gitBytes(root, [
|
|
87
|
+
'status',
|
|
88
|
+
'--porcelain=v1',
|
|
89
|
+
'-z',
|
|
90
|
+
'--no-renames',
|
|
91
|
+
'--',
|
|
92
|
+
SNAPSHOTS,
|
|
93
|
+
]);
|
|
94
|
+
const prefix = `${git(root, ['rev-parse', '--show-prefix'])}${SNAPSHOTS}`;
|
|
95
|
+
const folders = new Set();
|
|
96
|
+
for (const entry of status.toString('utf8').split('\0')) {
|
|
97
|
+
const path = entry.slice(3);
|
|
98
|
+
if (path.startsWith(prefix))
|
|
99
|
+
folders.add(path.slice(prefix.length).split('/')[0] ?? '');
|
|
100
|
+
}
|
|
101
|
+
return folders;
|
|
102
|
+
}
|
|
103
|
+
/** Remove (or, with `dryRun`, list) the committed snapshot folders nothing needs. */
|
|
104
|
+
export function pruneSnapshots(root, { dryRun = false } = {}) {
|
|
105
|
+
const folders = committedFolders(root);
|
|
106
|
+
const { commits, reports } = references(root);
|
|
107
|
+
const head = git(root, ['rev-parse', 'HEAD']).toLowerCase();
|
|
108
|
+
const unsaved = unsavedFolders(root);
|
|
109
|
+
const bytes = new Map(folders.map((folder) => [folder, readReport(root, folder)]));
|
|
110
|
+
const newest = [...folders].sort((a, b) => createdAt(bytes.get(b)).localeCompare(createdAt(bytes.get(a))))[0];
|
|
111
|
+
const named = (folder) => {
|
|
112
|
+
const report = bytes.get(folder);
|
|
113
|
+
const digest = report && createHash('sha256').update(report).digest('hex');
|
|
114
|
+
return ((digest !== undefined && reports.has(digest)) ||
|
|
115
|
+
[...commits].some((commit) => commit.startsWith(folder) || folder.startsWith(commit)));
|
|
116
|
+
};
|
|
117
|
+
const because = (folder) => {
|
|
118
|
+
if (named(folder))
|
|
119
|
+
return 'version';
|
|
120
|
+
if (head.startsWith(folder))
|
|
121
|
+
return 'head';
|
|
122
|
+
if (unsaved.has(folder))
|
|
123
|
+
return 'unsaved';
|
|
124
|
+
if (folder === newest)
|
|
125
|
+
return 'newest';
|
|
126
|
+
return undefined;
|
|
127
|
+
};
|
|
128
|
+
const result = { ok: true, dryRun, removed: [], kept: [] };
|
|
129
|
+
for (const folder of folders) {
|
|
130
|
+
const kept = because(folder);
|
|
131
|
+
if (kept)
|
|
132
|
+
result.kept.push({ folder, because: kept });
|
|
133
|
+
else
|
|
134
|
+
result.removed.push(folder);
|
|
135
|
+
}
|
|
136
|
+
if (!dryRun)
|
|
137
|
+
for (const folder of result.removed)
|
|
138
|
+
rmSync(join(snapshotsDir(root), folder), { recursive: true, force: true });
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const en: {
|
|
2
|
+
'reopen.none': string;
|
|
3
|
+
'reopen.help': string;
|
|
4
|
+
'reopen.done': string;
|
|
5
|
+
'reopen.aiMark': string;
|
|
6
|
+
'reopen.host': string;
|
|
7
|
+
};
|
|
8
|
+
export declare const reopenT: (key: keyof typeof en, values?: Record<string, unknown>) => string;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Words for reopening an AI approval (S4), in English and Spanish.
|
|
2
|
+
import { createI18n } from '@buffcore/i18n';
|
|
3
|
+
import { locale } from './messages.js';
|
|
4
|
+
const en = {
|
|
5
|
+
'reopen.none': '{change} has no AI approval to reopen.',
|
|
6
|
+
'reopen.help': 'Reopen an AI approval so the version waits for a person (a person only)',
|
|
7
|
+
'reopen.done': '{change}: the AI approval is reopened; the version waits for a person.',
|
|
8
|
+
'reopen.aiMark': ' (approved by AI, a person may reopen it)',
|
|
9
|
+
'reopen.host': 'This host cannot reopen an AI approval from the studio. Ask whoever runs it.',
|
|
10
|
+
};
|
|
11
|
+
const es = {
|
|
12
|
+
'reopen.none': '{change} no tiene una aprobación de IA que reabrir.',
|
|
13
|
+
'reopen.help': 'Reabre una aprobación de IA para que la versión espere a una persona (solo una persona)',
|
|
14
|
+
'reopen.done': '{change}: la aprobación de IA está reabierta; la versión espera a una persona.',
|
|
15
|
+
'reopen.aiMark': ' (aprobada por IA, una persona puede reabrirla)',
|
|
16
|
+
'reopen.host': 'Este servidor no puede reabrir una aprobación de IA desde el estudio. Pregunta a quien lo gestiona.',
|
|
17
|
+
};
|
|
18
|
+
const translator = createI18n({ catalogs: [{ en, es }] });
|
|
19
|
+
export const reopenT = (key, values) => translator.t(locale(), key, values);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Frame, Surface } from '@buffcore/config';
|
|
2
2
|
import type { PrototypeProblem } from '@buffcore/contracts/prototype';
|
|
3
3
|
import type { LoadFailure } from './scene-errors.ts';
|
|
4
|
+
import type { SelectorRecord } from './selector.ts';
|
|
5
|
+
import type { Matrix, MatrixReason } from './snapshot-matrix.ts';
|
|
4
6
|
export interface SnapshotHint {
|
|
5
7
|
scene: string;
|
|
6
8
|
theme: string;
|
|
@@ -32,6 +34,14 @@ export interface SnapshotReport {
|
|
|
32
34
|
api?: 'stand-in';
|
|
33
35
|
themes: string[];
|
|
34
36
|
locales: string[];
|
|
37
|
+
/** The looks the run drew (S3b): absent in an older report, which drew the full matrix. */
|
|
38
|
+
matrix?: Matrix;
|
|
39
|
+
/** Why it drew them: the default, `--full`, or a shared input changed since the last full report. */
|
|
40
|
+
matrixReason?: MatrixReason;
|
|
41
|
+
/** The shared inputs (F113c) of the last full report: this one's own when it is full. */
|
|
42
|
+
fullInputs?: string;
|
|
43
|
+
/** The selector's turns, picks with reasons, drops, or why it didn't run (S3c); absent: not asked. */
|
|
44
|
+
selector?: SelectorRecord;
|
|
35
45
|
scenes: {
|
|
36
46
|
key: string;
|
|
37
47
|
title: string;
|
|
@@ -56,6 +66,10 @@ export interface SnapshotReport {
|
|
|
56
66
|
scriptError?: LoadFailure;
|
|
57
67
|
/** The ancestor snapshot's folder (its source commit). */
|
|
58
68
|
reusedFrom?: string;
|
|
69
|
+
/** The looks this scene was drawn in (a reused scene keeps its own); absent: full. */
|
|
70
|
+
matrix?: Matrix;
|
|
71
|
+
/** The looks the selector added beyond the floor for this scene (S3c), `<theme>.<mode>.<locale>`. */
|
|
72
|
+
extraLooks?: string[];
|
|
59
73
|
}[];
|
|
60
74
|
/** The ancestor commit that holds the exact report used for every reused scene. */
|
|
61
75
|
reuseReport?: string;
|
|
@@ -5,6 +5,7 @@ import { existsSync } from 'node:fs';
|
|
|
5
5
|
import { readdir, readFile } from 'node:fs/promises';
|
|
6
6
|
import { join } from 'node:path';
|
|
7
7
|
import { hostGitBytes } from '../safe-git.js';
|
|
8
|
+
import { MISSES_FILE } from './selector-misses.js';
|
|
8
9
|
import { recoverSnapshots } from './snapshot-storage.js';
|
|
9
10
|
/** The scenes drawn again after a render error (a timeout leaves no line). */
|
|
10
11
|
export const renderRetries = (scenes) => scenes.flatMap(({ key, retryError }) => (retryError ? [{ scene: key, error: retryError }] : []));
|
|
@@ -58,7 +59,10 @@ export function unsavedEntries(dir, output) {
|
|
|
58
59
|
return gitBytes(dir, ['status', '--porcelain=v1', '-z', '--untracked-files=all', '--no-renames'])
|
|
59
60
|
.toString('utf8')
|
|
60
61
|
.split('\0')
|
|
61
|
-
.filter((entry) => entry !== '' &&
|
|
62
|
+
.filter((entry) => entry !== '' &&
|
|
63
|
+
!(entry.startsWith('?? ') && entry.slice(3).startsWith(output)) &&
|
|
64
|
+
// The selector's misses (S3c) are learning, not work: committed or not, never unsaved.
|
|
65
|
+
entry.slice(3) !== `${output}${MISSES_FILE}`);
|
|
62
66
|
}
|
|
63
67
|
/** Refuse uncommitted changes: what follows must match the commit checked out. */
|
|
64
68
|
export function requireCommitted(dir, why) {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Scene } from '@buffcore/config';
|
|
2
|
+
import type { PrototypeProblem } from '@buffcore/contracts/prototype';
|
|
3
|
+
import type { Browser, Page } from 'playwright-core';
|
|
4
|
+
import type { checkLook, Run } from './scene.ts';
|
|
5
|
+
type Look = {
|
|
6
|
+
theme: string;
|
|
7
|
+
mode: string;
|
|
8
|
+
locale: string;
|
|
9
|
+
};
|
|
10
|
+
/** The scene's last look as drawn: where it is and whether its media was late. */
|
|
11
|
+
export interface LastLook {
|
|
12
|
+
look: Look;
|
|
13
|
+
url: string;
|
|
14
|
+
mediaWait: number | undefined;
|
|
15
|
+
late: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** One look's picture and findings, from a found list of its own. */
|
|
18
|
+
export interface LookEvidence {
|
|
19
|
+
picture: Buffer;
|
|
20
|
+
problems: PrototypeProblem[];
|
|
21
|
+
late: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** The page as it shows `last` now: its picture and the findings `check` gives on it. */
|
|
24
|
+
export declare function lookEvidence(page: Page, last: LastLook, run: Run, scene: Scene, check: typeof checkLook): Promise<LookEvidence>;
|
|
25
|
+
/** True when a fresh load of the last look, in a new context, matches the in-place evidence. */
|
|
26
|
+
export declare function freshLoadAgrees(browser: Browser, scene: Scene, run: Run, signal: AbortSignal, last: LastLook, inPlace: LookEvidence, check: typeof checkLook): Promise<boolean>;
|
|
27
|
+
/** A look drawn in place and its evidence, to be compared with a fresh load. */
|
|
28
|
+
export type SceneCheck = {
|
|
29
|
+
last: LastLook;
|
|
30
|
+
evidence: LookEvidence;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Every check agrees with its fresh load, within the time the draw left of the scene timeout.
|
|
34
|
+
* An error other than an abort (a timeout, a page that failed) counts as a disagreement.
|
|
35
|
+
*/
|
|
36
|
+
export declare function freshLoadsAgree(browser: Browser, scene: Scene, run: Run, signal: AbortSignal, checks: readonly SceneCheck[], started: number, check: typeof checkLook): Promise<boolean>;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// The check a scene drawn with in-place looks must pass: its last look, which carries the most
|
|
2
|
+
// state left by earlier looks, drawn again by a fresh load in a new context must give the same
|
|
3
|
+
// picture and the same findings. Otherwise the scene is drawn again with full loads.
|
|
4
|
+
import { mkdtemp, readFile, rm } from 'node:fs/promises';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
8
|
+
import { openScene } from './browser.js';
|
|
9
|
+
import { dataWords } from './checks.js';
|
|
10
|
+
import { fullShot } from './full-shot.js';
|
|
11
|
+
import { renderScene, SCENE_TIMEOUT_MS } from './scene-render.js';
|
|
12
|
+
import { sceneRequests } from './snapshot-requests.js';
|
|
13
|
+
/** The page as it shows `last` now: its picture and the findings `check` gives on it. */
|
|
14
|
+
export async function lookEvidence(page, last, run, scene, check) {
|
|
15
|
+
const out = await mkdtemp(join(tmpdir(), 'ape-look-check-'));
|
|
16
|
+
try {
|
|
17
|
+
const found = {
|
|
18
|
+
scene,
|
|
19
|
+
data: dataWords(scene.props),
|
|
20
|
+
screenshots: {},
|
|
21
|
+
cut: [],
|
|
22
|
+
problems: [],
|
|
23
|
+
hints: [],
|
|
24
|
+
pairs: new Set(),
|
|
25
|
+
};
|
|
26
|
+
await check(page, last.look, { ...run, out }, found);
|
|
27
|
+
const path = join(out, 'look.png');
|
|
28
|
+
await fullShot(page, path);
|
|
29
|
+
return { picture: await readFile(path), problems: found.problems, late: last.late };
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
await rm(out, { recursive: true, force: true });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** True when a fresh load of the last look, in a new context, matches the in-place evidence. */
|
|
36
|
+
export async function freshLoadAgrees(browser, scene, run, signal, last, inPlace, check) {
|
|
37
|
+
const fresh = await renderScene(browser, run.frames[scene.frame], scene.key, run.sceneTimeout, async (page) => {
|
|
38
|
+
// Requests this load makes count too: the scene's facts stay a union over every load.
|
|
39
|
+
sceneRequests(page, run, scene);
|
|
40
|
+
const late = await openScene(page, last.url, last.look.locale, last.mediaWait);
|
|
41
|
+
return lookEvidence(page, { ...last, late }, run, scene, check);
|
|
42
|
+
}, signal, run);
|
|
43
|
+
return (fresh.late === inPlace.late &&
|
|
44
|
+
fresh.picture.equals(inPlace.picture) &&
|
|
45
|
+
isDeepStrictEqual(fresh.problems, inPlace.problems));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Every check agrees with its fresh load, within the time the draw left of the scene timeout.
|
|
49
|
+
* An error other than an abort (a timeout, a page that failed) counts as a disagreement.
|
|
50
|
+
*/
|
|
51
|
+
export async function freshLoadsAgree(browser, scene, run, signal, checks, started, check) {
|
|
52
|
+
const deadline = started + (run.sceneTimeout ?? SCENE_TIMEOUT_MS);
|
|
53
|
+
for (const { last, evidence } of checks) {
|
|
54
|
+
const left = deadline - performance.now();
|
|
55
|
+
if (left <= 0)
|
|
56
|
+
return false;
|
|
57
|
+
try {
|
|
58
|
+
const fresh = { ...run, sceneTimeout: left };
|
|
59
|
+
if (!(await freshLoadAgrees(browser, scene, fresh, signal, last, evidence, check)))
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
signal.throwIfAborted();
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { LayoutException, Scene } from '@buffcore/config';
|
|
2
|
+
import type { Theme } from '@buffcore/tokens';
|
|
3
|
+
import type { Page } from 'playwright-core';
|
|
4
|
+
import { type LayoutFinding } from './layout-hints.ts';
|
|
5
|
+
import type { SnapshotHint } from './report.ts';
|
|
6
|
+
/** A scene's layout hints in the report, at most: past this, its layout wants a look as a whole. */
|
|
7
|
+
export declare const MAX_LAYOUT_HINTS = 20;
|
|
8
|
+
/** True when the scene marks this finding as meant. */
|
|
9
|
+
export declare function setAside(finding: LayoutFinding, exceptions?: readonly LayoutException[]): boolean;
|
|
10
|
+
/** The finding in the reader's words. */
|
|
11
|
+
export declare function layoutDetail(scene: string, finding: LayoutFinding): string;
|
|
12
|
+
/** Measure the page as it shows `look` and add its new layout hints to the scene's `hints`. */
|
|
13
|
+
export declare function addLayoutHints(page: Page, scene: Scene, theme: Theme | undefined, look: {
|
|
14
|
+
theme: string;
|
|
15
|
+
mode: string;
|
|
16
|
+
locale: string;
|
|
17
|
+
}, hints: SnapshotHint[]): Promise<void>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { layoutFindings, spacingSteps } from './layout-hints.js';
|
|
2
|
+
import { measureLayout } from './layout-measure.js';
|
|
3
|
+
import { layoutText } from './layout-words.js';
|
|
4
|
+
import { number } from './messages.js';
|
|
5
|
+
/** A scene's layout hints in the report, at most: past this, its layout wants a look as a whole. */
|
|
6
|
+
export const MAX_LAYOUT_HINTS = 20;
|
|
7
|
+
/** True when the scene marks this finding as meant. */
|
|
8
|
+
export function setAside(finding, exceptions = []) {
|
|
9
|
+
const names = [finding.element, 'other' in finding ? finding.other : ''];
|
|
10
|
+
return exceptions.some((one) => one.kind === finding.kind &&
|
|
11
|
+
(!one.element || names.some((n) => n.includes(one.element ?? ''))));
|
|
12
|
+
}
|
|
13
|
+
/** The finding in the reader's words. */
|
|
14
|
+
export function layoutDetail(scene, finding) {
|
|
15
|
+
switch (finding.kind) {
|
|
16
|
+
case 'overlap':
|
|
17
|
+
return layoutText('layout.overlap', {
|
|
18
|
+
scene,
|
|
19
|
+
element: finding.element,
|
|
20
|
+
other: finding.other,
|
|
21
|
+
width: number(finding.width),
|
|
22
|
+
height: number(finding.height),
|
|
23
|
+
});
|
|
24
|
+
case 'edge':
|
|
25
|
+
return layoutText('layout.edge', {
|
|
26
|
+
scene,
|
|
27
|
+
element: finding.element,
|
|
28
|
+
offset: number(finding.offset),
|
|
29
|
+
count: number(finding.count),
|
|
30
|
+
});
|
|
31
|
+
case 'padding':
|
|
32
|
+
return layoutText('layout.padding', { scene, ...finding, count: number(finding.count) });
|
|
33
|
+
case 'gap':
|
|
34
|
+
return layoutText('layout.gap', {
|
|
35
|
+
scene,
|
|
36
|
+
...finding,
|
|
37
|
+
gap: number(finding.gap),
|
|
38
|
+
value: number(finding.value),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Measure the page as it shows `look` and add its new layout hints to the scene's `hints`. */
|
|
43
|
+
export async function addLayoutHints(page, scene, theme, look, hints) {
|
|
44
|
+
if (!theme)
|
|
45
|
+
return;
|
|
46
|
+
const boxes = JSON.parse(await page.evaluate(measureLayout));
|
|
47
|
+
const scale = scene.surface === 'app' ? (scene.scale ?? 1) : 1;
|
|
48
|
+
for (const finding of layoutFindings(boxes, spacingSteps(theme.space, scale))) {
|
|
49
|
+
if (hints.length >= MAX_LAYOUT_HINTS)
|
|
50
|
+
return;
|
|
51
|
+
if (setAside(finding, scene.layoutExceptions))
|
|
52
|
+
continue;
|
|
53
|
+
const detail = layoutDetail(scene.key, finding);
|
|
54
|
+
if (!hints.some((hint) => hint.detail === detail))
|
|
55
|
+
hints.push({ scene: scene.key, ...look, detail });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Page } from 'playwright-core';
|
|
2
|
+
/** Counts a look drawn by a full load instead of in place, or a scene drawn again fresh. */
|
|
3
|
+
export type FallbackCounter = (kind: 'look' | 'scene') => void;
|
|
4
|
+
/** The attempt may have had side effects. Discard its context before replaying the scene. */
|
|
5
|
+
export declare class LookMoveFailed extends Error {
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A fresh navigation starts the scene; its later looks move in place. A picture is shot only once
|
|
9
|
+
* `mediaReady` says all is ready, so warm media draws the same picture; only a media finding could
|
|
10
|
+
* differ. So a later look loads fresh when the first look got one (late or failed), or when its
|
|
11
|
+
* wait used more than half the later look's allowance (a cold load near the limit). A cold load
|
|
12
|
+
* well within the allowance means a warm one is too, so the findings are equal.
|
|
13
|
+
*/
|
|
14
|
+
export declare function sceneLookLoader(page: Page, onFallback?: FallbackCounter, inPlace?: boolean, onMove?: () => void): (url: string, locale: string, mediaWait?: number) => Promise<boolean>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/// <reference lib="dom" />
|
|
2
|
+
import { SCENE_LOOK_ATTR, SCENE_LOOK_CHANGE, SCENE_LOOK_REUSABLE, } from '@buffcore/contracts/prototype';
|
|
3
|
+
import { openScene, sceneFrames, waitForScene } from './browser.js';
|
|
4
|
+
import { MEDIA_WAIT } from './media-ready.js';
|
|
5
|
+
import { SCENE_FOCUS_KEPT } from './scene-ready.js';
|
|
6
|
+
const LOOK_WAIT = 5_000;
|
|
7
|
+
/** The attempt may have had side effects. Discard its context before replaying the scene. */
|
|
8
|
+
export class LookMoveFailed extends Error {
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The head's stylesheets, by element: one added or removed by a look would stay on the kept page.
|
|
12
|
+
* A sheet's text may change, since a styling library (Unistyles) rewrites its one sheet for the
|
|
13
|
+
* look on screen; the proof's equal pictures cover that.
|
|
14
|
+
*/
|
|
15
|
+
function headStyles() {
|
|
16
|
+
return [...document.head.querySelectorAll('style, link[rel="stylesheet"]')]
|
|
17
|
+
.map((node) => node.cloneNode(false).outerHTML)
|
|
18
|
+
.join('\n');
|
|
19
|
+
}
|
|
20
|
+
/** False means the current document was left untouched. */
|
|
21
|
+
async function moveLook(page, url, locale, mediaWait, onMove) {
|
|
22
|
+
try {
|
|
23
|
+
if ((await sceneFrames(page, locale)).length)
|
|
24
|
+
return false;
|
|
25
|
+
const eligible = await page.evaluate(({ url, attr, reusable, kept }) => {
|
|
26
|
+
const html = document.documentElement;
|
|
27
|
+
const current = new URL(location.href);
|
|
28
|
+
const next = new URL(url);
|
|
29
|
+
return (current.origin === next.origin &&
|
|
30
|
+
current.pathname === next.pathname &&
|
|
31
|
+
current.searchParams.get('key') === next.searchParams.get('key') &&
|
|
32
|
+
html.getAttribute(attr) === location.search &&
|
|
33
|
+
html.hasAttribute(reusable) &&
|
|
34
|
+
(document.activeElement === document.body ||
|
|
35
|
+
document.activeElement === html ||
|
|
36
|
+
html.hasAttribute(kept)));
|
|
37
|
+
}, { url, attr: SCENE_LOOK_ATTR, reusable: SCENE_LOOK_REUSABLE, kept: SCENE_FOCUS_KEPT });
|
|
38
|
+
if (!eligible)
|
|
39
|
+
return false;
|
|
40
|
+
const styles = await page.evaluate(headStyles);
|
|
41
|
+
onMove?.();
|
|
42
|
+
await page.evaluate(({ url, event, attr }) => {
|
|
43
|
+
document.documentElement.removeAttribute(attr);
|
|
44
|
+
history.replaceState(history.state, '', url);
|
|
45
|
+
window.dispatchEvent(new Event(event));
|
|
46
|
+
}, { url, event: SCENE_LOOK_CHANGE, attr: SCENE_LOOK_ATTR });
|
|
47
|
+
await page.waitForFunction(({ attr, search }) => location.search === search && document.documentElement.getAttribute(attr) === search, { attr: SCENE_LOOK_ATTR, search: new URL(url).search }, { timeout: LOOK_WAIT });
|
|
48
|
+
const late = await waitForScene(page, locale, {
|
|
49
|
+
unframed: true,
|
|
50
|
+
readyWait: LOOK_WAIT,
|
|
51
|
+
...(mediaWait === undefined ? {} : { mediaWait }),
|
|
52
|
+
});
|
|
53
|
+
if (late)
|
|
54
|
+
throw new LookMoveFailed('Media was late after the move');
|
|
55
|
+
if (styles !== (await page.evaluate(headStyles)))
|
|
56
|
+
throw new LookMoveFailed('The move added or removed a stylesheet');
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
catch (cause) {
|
|
60
|
+
throw new LookMoveFailed(undefined, { cause });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A fresh navigation starts the scene; its later looks move in place. A picture is shot only once
|
|
65
|
+
* `mediaReady` says all is ready, so warm media draws the same picture; only a media finding could
|
|
66
|
+
* differ. So a later look loads fresh when the first look got one (late or failed), or when its
|
|
67
|
+
* wait used more than half the later look's allowance (a cold load near the limit). A cold load
|
|
68
|
+
* well within the allowance means a warm one is too, so the findings are equal.
|
|
69
|
+
*/
|
|
70
|
+
export function sceneLookLoader(page, onFallback, inPlace = true, onMove) {
|
|
71
|
+
let opened = false;
|
|
72
|
+
let found = false;
|
|
73
|
+
let elapsed = 0;
|
|
74
|
+
const observe = (media) => {
|
|
75
|
+
found ||= !media.ready || media.failed;
|
|
76
|
+
elapsed = Math.max(elapsed, media.elapsed);
|
|
77
|
+
};
|
|
78
|
+
return async (url, locale, mediaWait) => {
|
|
79
|
+
if (opened) {
|
|
80
|
+
const warmSafe = !found && elapsed <= (mediaWait ?? MEDIA_WAIT) / 2;
|
|
81
|
+
if (inPlace && warmSafe && (await moveLook(page, url, locale, mediaWait, onMove)))
|
|
82
|
+
return false;
|
|
83
|
+
onFallback?.('look');
|
|
84
|
+
}
|
|
85
|
+
const late = await openScene(page, url, locale, mediaWait, inPlace ? observe : undefined);
|
|
86
|
+
opened = true;
|
|
87
|
+
return late;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Frame, Page } from 'playwright-core';
|
|
2
|
+
import { type MediaState } from './media-ready.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Runs inside the page (Playwright sends its source): paints two frames, then resolves when the
|
|
5
|
+
* animations have finished, so a sheet fading in is not caught half way, or after `timeout` ms.
|
|
6
|
+
* An animation that never ends (a spinner) is not waited for. Chromium paints no frame in a framed
|
|
7
|
+
* page from another origin while it is off screen, so the wait for a paint ends after a second.
|
|
8
|
+
*/
|
|
9
|
+
export declare function animationsDone(timeout: number): Promise<void>;
|
|
10
|
+
/** Set on `<html>` when the view took the focus back on purpose (`unfocused`). */
|
|
11
|
+
export declare const SCENE_FOCUS_KEPT = "data-scene-focus-kept";
|
|
12
|
+
/**
|
|
13
|
+
* Runs inside the page, after `animationsDone` has painted two frames (so the view's mount effects
|
|
14
|
+
* and autofocus have had their chance): blur whatever has focus, and again after each frame until
|
|
15
|
+
* nothing does, for up to `timeout` ms. A field that autofocuses late (Expo's router can commit the
|
|
16
|
+
* root before the view) then shows no focus ring on any path. An element that takes the focus back
|
|
17
|
+
* after its blur does so on purpose (a sheet that focuses its field): it keeps the focus, as a plain
|
|
18
|
+
* load shows it, and `<html>` is marked with `data-scene-focus-kept`. True when nothing has focus.
|
|
19
|
+
*/
|
|
20
|
+
export declare function unfocused(timeout: number): Promise<boolean>;
|
|
21
|
+
/** How long a scene page waits: for its animations, and for its fonts and pictures. */
|
|
22
|
+
type Waits = {
|
|
23
|
+
animationWait: number;
|
|
24
|
+
mediaWait: number;
|
|
25
|
+
readyWait?: number | undefined;
|
|
26
|
+
onMedia?: ((media: MediaState) => void) | undefined;
|
|
27
|
+
};
|
|
28
|
+
/** The console can show an app scene in an iframe of its own. */
|
|
29
|
+
export declare function sceneFrames(page: Page, locale: string): Promise<{
|
|
30
|
+
frame: Frame;
|
|
31
|
+
index: number;
|
|
32
|
+
locale: string;
|
|
33
|
+
}[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Wait for the current scene and its framed scenes to finish drawing. True when a font or picture
|
|
36
|
+
* was still loading as its allowance ran out: the page is shot as it is.
|
|
37
|
+
*/
|
|
38
|
+
export declare function waitForScene(page: Page, locale: string, { live, animationWait, mediaWait, readyWait, unframed, onMedia, }?: {
|
|
39
|
+
live?: () => boolean;
|
|
40
|
+
animationWait?: number;
|
|
41
|
+
mediaWait?: number;
|
|
42
|
+
readyWait?: number;
|
|
43
|
+
unframed?: boolean;
|
|
44
|
+
onMedia?: Waits['onMedia'];
|
|
45
|
+
}): Promise<boolean>;
|
|
46
|
+
export {};
|