@buffcore/cli 0.8.46 → 0.8.48
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 +74 -0
- package/dist/commands/build/server-text.en.d.ts +5 -0
- package/dist/commands/build/server-text.en.js +5 -0
- package/dist/commands/build/server-text.js +5 -0
- package/dist/commands/build/server.d.ts +4 -0
- package/dist/commands/build/server.js +10 -1
- package/dist/commands/change-merge-remove.d.ts +9 -2
- package/dist/commands/change-merge-remove.js +27 -15
- package/dist/commands/change-merge.d.ts +2 -2
- 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/dev.d.ts +9 -2
- package/dist/commands/dev.js +24 -5
- package/dist/commands/extension/places-approval.d.ts +4 -0
- package/dist/commands/hardening.d.ts +3 -0
- package/dist/commands/hardening.en.d.ts +3 -0
- package/dist/commands/hardening.en.js +3 -0
- package/dist/commands/hardening.es.d.ts +2 -0
- package/dist/commands/hardening.es.js +3 -0
- package/dist/commands/hardening.js +19 -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/comp-record.d.ts +5 -0
- package/dist/commands/prototype/comp-record.js +22 -0
- 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/messages.en.d.ts +14 -0
- package/dist/commands/prototype/messages.en.js +15 -1
- package/dist/commands/prototype/messages.js +15 -1
- 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-layout.d.ts +17 -0
- package/dist/commands/prototype/scene-layout.js +57 -0
- package/dist/commands/prototype/scene-ready.js +8 -2
- package/dist/commands/prototype/scene.d.ts +15 -2
- package/dist/commands/prototype/scene.js +54 -42
- 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 +3 -0
- 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 -197
- 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 +50 -2
- 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 +5 -0
- package/dist/commands/prototype/snapshot.js +72 -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/server/build.d.ts +2 -1
- package/dist/commands/server/build.js +10 -2
- package/dist/commands/server/deploy-local.d.ts +3 -0
- package/dist/commands/server/deploy-local.js +9 -0
- package/dist/commands/server/deploy-plan.d.ts +5 -0
- package/dist/commands/server/deploy-plan.js +56 -0
- package/dist/commands/server/deploy-result.d.ts +7 -0
- package/dist/commands/server/deploy-result.js +1 -0
- package/dist/commands/server/deploy-script.d.ts +2 -0
- package/dist/commands/server/deploy-script.js +3 -2
- package/dist/commands/server/deploy.d.ts +9 -6
- package/dist/commands/server/deploy.js +39 -61
- package/dist/commands/server/files.d.ts +9 -1
- package/dist/commands/server/files.js +25 -5
- package/dist/commands/server/image.d.ts +4 -2
- package/dist/commands/server/image.js +6 -5
- package/dist/commands/server/setup.js +4 -0
- package/dist/commands/server/system-packages.d.ts +29 -0
- package/dist/commands/server/system-packages.js +103 -0
- package/dist/commands/services/compose.d.ts +1 -1
- package/dist/commands/services/compose.js +5 -3
- 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/agents-route.js +2 -0
- package/dist/commands/ui/approval-authority.d.ts +10 -2
- package/dist/commands/ui/approval-authority.en.d.ts +1 -0
- package/dist/commands/ui/approval-authority.en.js +1 -0
- package/dist/commands/ui/approval-authority.es.d.ts +1 -0
- package/dist/commands/ui/approval-authority.es.js +1 -0
- package/dist/commands/ui/approval-authority.js +8 -2
- package/dist/commands/ui/approve.js +2 -4
- 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-records.d.ts +2 -0
- package/dist/commands/ui/autopilot-records.js +5 -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/brand-approval.js +5 -1
- 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/permissions.js +1 -1
- package/dist/commands/ui/chat/routes.js +4 -0
- package/dist/commands/ui/chat/worktree.js +25 -5
- package/dist/commands/ui/comp-approval.d.ts +14 -2
- package/dist/commands/ui/comp-approval.js +45 -8
- package/dist/commands/ui/index.js +3 -0
- package/dist/commands/ui/level-route.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-authority.d.ts +4 -1
- package/dist/commands/ui/merge-authority.en.d.ts +4 -0
- package/dist/commands/ui/merge-authority.en.js +5 -1
- package/dist/commands/ui/merge-authority.es.d.ts +4 -0
- package/dist/commands/ui/merge-authority.es.js +5 -1
- package/dist/commands/ui/merge-authority.js +6 -3
- package/dist/commands/ui/merge-claims.d.ts +7 -0
- package/dist/commands/ui/merge-claims.js +21 -0
- package/dist/commands/ui/merge-delegation.js +8 -3
- package/dist/commands/ui/merge-hold-name.d.ts +5 -0
- package/dist/commands/ui/merge-hold-name.js +5 -0
- package/dist/commands/ui/merge-hold.d.ts +6 -1
- package/dist/commands/ui/merge-hold.js +23 -5
- package/dist/commands/ui/merge-publish-host.d.ts +1 -0
- package/dist/commands/ui/merge-publish-host.js +2 -2
- package/dist/commands/ui/merge-record.d.ts +2 -0
- package/dist/commands/ui/merge-record.js +1 -1
- package/dist/commands/ui/merge-route.js +20 -1
- package/dist/commands/ui/merge-settle.d.ts +32 -0
- package/dist/commands/ui/merge-settle.js +133 -0
- package/dist/commands/ui/merge-state.d.ts +5 -0
- package/dist/commands/ui/merge-state.js +7 -1
- package/dist/commands/ui/merge-withdraw.d.ts +9 -0
- package/dist/commands/ui/merge-withdraw.js +29 -0
- package/dist/commands/ui/places-change.d.ts +4 -0
- package/dist/commands/ui/plan-files.js +5 -2
- package/dist/commands/ui/plan-structure.js +5 -7
- package/dist/commands/ui/prototype-comp-route.d.ts +12 -3
- package/dist/commands/ui/prototype-comp-route.js +35 -17
- package/dist/commands/ui/prototype-main.d.ts +4 -0
- package/dist/commands/ui/real-file.d.ts +11 -0
- package/dist/commands/ui/real-file.js +84 -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 +8 -1
- package/dist/commands/ui/server.d.ts +1 -0
- package/dist/commands/ui/server.js +1 -0
- package/dist/commands/ui/studio-routes.js +2 -0
- package/dist/commands/ui/studio-state.d.ts +34 -0
- package/dist/commands/ui/studio-versions.d.ts +24 -0
- package/dist/commands/ui/studio-versions.js +19 -3
- 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 +89 -89
- package/docs/PROTOTYPE.md +19 -3
- package/docs/WORKBENCH.md +41 -6
- package/package.json +11 -11
- package/skills/ape-critique/SKILL.md +41 -6
- package/skills/ape-deploy/SKILL.md +4 -2
- 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
|
@@ -1,216 +1,171 @@
|
|
|
1
|
-
import { existsSync
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { SURFACES } from '@buffcore/config';
|
|
5
|
-
import { pageOptions } from './browser.js';
|
|
6
|
-
import { surfaceDir } from './export.js';
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { SURFACES, sceneUrl } from '@buffcore/config';
|
|
7
4
|
import { locale } from './messages.js';
|
|
8
|
-
import {
|
|
9
|
-
import { isStock } from './milestone-stock.js';
|
|
10
|
-
import { loaders } from './snapshot-bundle.js';
|
|
11
|
-
import { dependencyVersion, snapshotDependencies } from './snapshot-dependencies.js';
|
|
5
|
+
import { dependencyVersion, pathIn, snapshotDependencies } from './snapshot-dependencies.js';
|
|
12
6
|
import { plainData, sha256 } from './snapshot-hashes.js';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
'full-shot',
|
|
19
|
-
'measure',
|
|
20
|
-
'media-ready',
|
|
21
|
-
'module-errors',
|
|
22
|
-
'readable',
|
|
23
|
-
'scene',
|
|
24
|
-
'scene-check',
|
|
25
|
-
'scene-load',
|
|
26
|
-
'scene-look',
|
|
27
|
-
'scene-ready',
|
|
28
|
-
'scene-render',
|
|
29
|
-
'snapshot-recovery',
|
|
30
|
-
'snapshot-requests',
|
|
31
|
-
'snapshot-themes',
|
|
32
|
-
];
|
|
33
|
-
const SURFACE_ROOTS = {
|
|
34
|
-
admin: ['src/main.tsx', 'src/prototype/index.tsx'],
|
|
35
|
-
app: ['src/app/_scene.tsx', 'src/app/_layout.tsx', 'src/prototype/scene.tsx', 'src/fonts.ts'],
|
|
36
|
-
};
|
|
37
|
-
const SETTINGS = [
|
|
38
|
-
'package.json',
|
|
39
|
-
'tsconfig.json',
|
|
40
|
-
'jsconfig.json',
|
|
41
|
-
'app.json',
|
|
42
|
-
'index.html',
|
|
43
|
-
'public/console.json',
|
|
44
|
-
'.env',
|
|
45
|
-
'.env.local',
|
|
46
|
-
'.env.development',
|
|
47
|
-
'.env.development.local',
|
|
48
|
-
];
|
|
49
|
-
const existing = (dir, paths) => paths.map((path) => join(dir, path)).filter(existsSync);
|
|
50
|
-
const TOOLCHAINS = ['vite.config', 'metro.config', 'babel.config', 'postcss.config', 'app.config']
|
|
51
|
-
.flatMap((name) => ['ts', 'js', 'mts', 'mjs', 'cts', 'cjs'].map((ext) => `${name}.${ext}`))
|
|
52
|
-
.concat(['.babelrc', '.babelrc.json', '.postcssrc', '.postcssrc.json']);
|
|
53
|
-
// The in-repository dev configs use the same resolvers as the product templates.
|
|
54
|
-
const BUNDLED_TOOLCHAINS = {
|
|
55
|
-
'apps/admin/vite.config.ts': '0fe0ec6d310d92e37ab052f230ecb6b9ff7a19241061300eebf85920018a6638',
|
|
56
|
-
'apps/app/metro.config.js': 'd2261b4852313fdf42fa63d97d162c691cc89757df4de8ecdff1d8bac939b117',
|
|
57
|
-
'apps/app/babel.config.js': '51ba161016afa8ae07b41bb4305f1c6e71ff30d007e58fbebe0cf383bbce67c0',
|
|
58
|
-
};
|
|
59
|
-
/** esbuild can model the shipped surface configuration. A product loader may resolve differently. */
|
|
60
|
-
async function toolchains(dir, surface, read) {
|
|
61
|
-
try {
|
|
62
|
-
const files = existing(dir, TOOLCHAINS);
|
|
63
|
-
for (const file of files) {
|
|
64
|
-
const name = `apps/${surface}/${relative(dir, file)}`;
|
|
65
|
-
const text = (await read(file)).toString('utf8').replaceAll('\r\n', '\n');
|
|
66
|
-
if (!isStock(name, text) && BUNDLED_TOOLCHAINS[name] !== sha256(text))
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
return files;
|
|
70
|
-
}
|
|
71
|
-
catch {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
/** A product inside a workspace uses the enclosing lockfile when it has none of its own. */
|
|
76
|
-
function lockfile(root) {
|
|
77
|
-
for (let dir = root;; dir = dirname(dir)) {
|
|
78
|
-
const files = existing(dir, ['pnpm-lock.yaml', 'package-lock.json', 'yarn.lock']);
|
|
79
|
-
if (files.length || dirname(dir) === dir)
|
|
80
|
-
return files;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
const publicEnvironment = (env) => Object.entries(env)
|
|
84
|
-
.filter(([key]) => /^(VITE_|EXPO_PUBLIC_)/.test(key))
|
|
85
|
-
.sort();
|
|
86
|
-
async function settingHashes(root, files, dependencies) {
|
|
87
|
-
return Promise.all(files.map(async (file) => {
|
|
88
|
-
const name = relative(root, file);
|
|
89
|
-
if (!/^\.env(?:\.|$)/.test(basename(file)))
|
|
90
|
-
return [name, await dependencies.digest(file)];
|
|
91
|
-
await dependencies.digest(file);
|
|
92
|
-
const environment = publicEnvironment(parseEnv((await dependencies.read(file)).toString('utf8')));
|
|
93
|
-
if (environment.some(([, value]) => value?.includes('$')))
|
|
94
|
-
throw new Error();
|
|
95
|
-
return [name, sha256(JSON.stringify(environment))];
|
|
96
|
-
}));
|
|
97
|
-
}
|
|
98
|
-
/** The design system's font files the console serves under `_fonts/`, as its Vite plugin lists them. */
|
|
99
|
-
function designFonts(root) {
|
|
100
|
-
const dir = join(root, 'design', 'fonts');
|
|
101
|
-
try {
|
|
102
|
-
return readdirSync(dir, { withFileTypes: true })
|
|
103
|
-
.filter((entry) => entry.isFile() && /\.(?:woff2?|ttf|otf)$/i.test(entry.name))
|
|
104
|
-
.map((entry) => join(dir, entry.name))
|
|
105
|
-
.sort();
|
|
106
|
-
}
|
|
107
|
-
catch {
|
|
108
|
-
return [];
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
/** The HTML can load public fonts or images without a JavaScript import. */
|
|
112
|
-
async function pageAssets(dir, read) {
|
|
113
|
-
const page = join(dir, 'index.html');
|
|
114
|
-
if (!existsSync(page))
|
|
115
|
-
return [];
|
|
116
|
-
const links = references('page', (await read(page)).toString('utf8'), page);
|
|
117
|
-
if (typeof links === 'string')
|
|
118
|
-
throw new Error();
|
|
119
|
-
const publicDir = join(dir, 'public');
|
|
120
|
-
return links.flatMap(([kind, url]) => {
|
|
121
|
-
if (kind !== 'page' || /^(?:[\w+.-]+:|\/\/|#)/.test(url))
|
|
122
|
-
return [];
|
|
123
|
-
const file = resolve(publicDir, decodeURIComponent(url.split(/[?#]/, 1)[0] ?? '').replace(/^\//, ''));
|
|
124
|
-
const path = relative(publicDir, file);
|
|
125
|
-
if (isAbsolute(path) || path === '..' || path.startsWith(`..${sep}`))
|
|
126
|
-
return [];
|
|
127
|
-
return loaders[extname(file).toLowerCase()] === 'file' && existsSync(file) ? [file] : [];
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
async function surfaceEntry(root, surface, dependencies) {
|
|
131
|
-
const dir = surfaceDir(root, surface);
|
|
132
|
-
const registry = dir && join(dir, 'src', 'prototype', 'views.ts');
|
|
133
|
-
if (!dir || !registry || !existsSync(registry))
|
|
134
|
-
return;
|
|
135
|
-
const configuration = await toolchains(dir, surface, dependencies.read);
|
|
136
|
-
if (!configuration)
|
|
137
|
-
return;
|
|
138
|
-
const page = await pageAssets(dir, dependencies.read).catch(() => undefined);
|
|
139
|
-
if (!page)
|
|
140
|
-
return;
|
|
141
|
-
const assets = [...page, ...(surface === 'admin' ? designFonts(root) : [])];
|
|
142
|
-
const entry = {
|
|
143
|
-
surface,
|
|
144
|
-
dir,
|
|
145
|
-
registry,
|
|
146
|
-
roots: [...existing(dir, SURFACE_ROOTS[surface]), ...existing(root, ['design/theme.ts'])],
|
|
147
|
-
};
|
|
148
|
-
const settings = await settingHashes(root, [...existing(dir, SETTINGS), ...configuration, ...assets], dependencies).catch(() => undefined);
|
|
149
|
-
if (settings)
|
|
150
|
-
return { entry, settings, assets };
|
|
151
|
-
}
|
|
152
|
-
function hasSurfaceAsset(surface, url) {
|
|
153
|
-
if (!surface)
|
|
154
|
-
return false;
|
|
155
|
-
const path = decodeURIComponent(url.pathname);
|
|
156
|
-
const { fonts } = surface;
|
|
157
|
-
if (fonts && path.startsWith(fonts.path))
|
|
158
|
-
return surface.assets.has(join(fonts.dir, path.slice(fonts.path.length)));
|
|
159
|
-
if (path.startsWith('/@fs/'))
|
|
160
|
-
return surface.assets.has(resolve(path.slice(5)));
|
|
161
|
-
const metroAsset = url.searchParams.get('unstable_path');
|
|
162
|
-
if (path === '/assets/' && metroAsset)
|
|
163
|
-
return surface.assets.has(resolve(surface.dir, metroAsset));
|
|
164
|
-
return (surface.assets.has(resolve(surface.dir, `.${path}`)) ||
|
|
165
|
-
surface.assets.has(resolve(surface.dir, 'public', `.${path}`)));
|
|
166
|
-
}
|
|
7
|
+
import { metroInputs } from './snapshot-metro-inputs.js';
|
|
8
|
+
import { sceneCandidates, sceneGraph, scenePage } from './snapshot-scene-inputs.js';
|
|
9
|
+
import { matchesBytes } from './snapshot-served-inputs.js';
|
|
10
|
+
import { designFont, lockfile, publicEnvironment, sharedSettings, surfaceEntry, } from './snapshot-surface-inputs.js';
|
|
11
|
+
import { surfaceFile, viteRequests } from './snapshot-vite-inputs.js';
|
|
167
12
|
/** The console's `_fonts/` under the base its address names (`/`, or `/s/abc/`). */
|
|
168
13
|
function fontPath(address) {
|
|
169
14
|
const base = decodeURIComponent(URL.parse(address)?.pathname ?? '/');
|
|
170
15
|
return `${base.endsWith('/') ? base : `${base}/`}_fonts/`;
|
|
171
16
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const
|
|
17
|
+
export async function snapshotInputs(root, scenes, run, browser, design, environment = process.env) {
|
|
18
|
+
let version;
|
|
19
|
+
const browserVersion = async () => (version ??= await browser());
|
|
20
|
+
const read = () => readInputs(root, scenes, run, browserVersion, design, environment);
|
|
21
|
+
const start = await read();
|
|
22
|
+
return {
|
|
23
|
+
...start,
|
|
24
|
+
async same() {
|
|
25
|
+
// A fresh walk sees added resolution candidates and settings that were absent at the start.
|
|
26
|
+
return (await start.same()) && start.signature() === (await read()).signature();
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async function readInputs(root, scenes, run, browser, design, environment) {
|
|
31
|
+
const catalog = join(root, 'prototype', 'scenes.ts');
|
|
32
|
+
const dependencies = snapshotDependencies(root, catalog);
|
|
33
|
+
const catalogBytes = existsSync(catalog) && (await dependencies.digest(catalog));
|
|
177
34
|
const inputs = new Map();
|
|
178
35
|
const fingerprints = new Map();
|
|
36
|
+
const surfaces = new Map();
|
|
37
|
+
const candidates = sceneCandidates(root, scenes, run, dependencies);
|
|
38
|
+
let metro;
|
|
39
|
+
const probes = [];
|
|
179
40
|
const result = {
|
|
180
41
|
fingerprints,
|
|
181
|
-
|
|
182
|
-
|
|
42
|
+
surfaces,
|
|
43
|
+
reuse: candidates.reuse,
|
|
44
|
+
parts: () => candidates.parts,
|
|
45
|
+
signature: () => JSON.stringify([[...fingerprints], candidates.signature, catalogBytes]),
|
|
46
|
+
same: async () => (await dependencies.same()) &&
|
|
47
|
+
(await metro?.same()) !== false &&
|
|
48
|
+
(await inputs.get('admin')?.vite?.same()) !== false,
|
|
49
|
+
runtime: (force, surface) => {
|
|
50
|
+
const app = metro?.hash();
|
|
51
|
+
if (surface === 'app')
|
|
52
|
+
return app;
|
|
53
|
+
const vite = inputs.get('admin')?.vite?.hash(force);
|
|
54
|
+
if (surface === 'admin')
|
|
55
|
+
return vite;
|
|
56
|
+
return app ? sha256(JSON.stringify([vite, app])) : vite;
|
|
57
|
+
},
|
|
58
|
+
coversRequest: (async (scene, url, kind, response) => {
|
|
59
|
+
const surface = inputs.get(scene.surface);
|
|
60
|
+
const assets = candidates.assets.get(scene.key);
|
|
61
|
+
if (!surface || !assets)
|
|
62
|
+
return false;
|
|
63
|
+
if (scene.surface === 'app' && metro && ['document', 'websocket'].includes(kind))
|
|
64
|
+
return metro.covers(url, kind, response);
|
|
65
|
+
if (kind === 'document') {
|
|
66
|
+
if (url.pathname !== '/_scene')
|
|
67
|
+
return false;
|
|
68
|
+
return (surface.vite?.tracks(url, kind, response) ?? matchesBytes(surface.document, response));
|
|
69
|
+
}
|
|
70
|
+
if (metro && scene.surface === 'app' && url.pathname === '/assets/') {
|
|
71
|
+
const path = url.searchParams.get('unstable_path');
|
|
72
|
+
const file = path && resolve(surface.dir, path);
|
|
73
|
+
if (!file || url.searchParams.size !== 1 || !assets.has(file))
|
|
74
|
+
return false;
|
|
75
|
+
return matchesBytes(await dependencies.digest(file), response);
|
|
76
|
+
}
|
|
77
|
+
const font = surface.fonts && designFont(root, surface.fonts, url, assets);
|
|
78
|
+
if (font)
|
|
79
|
+
return matchesBytes(await dependencies.digest(font), response);
|
|
80
|
+
const file = kind !== 'websocket' && surfaceFile(surface.dir, url, assets);
|
|
81
|
+
if (file) {
|
|
82
|
+
if (surface.vite &&
|
|
83
|
+
['script', 'stylesheet'].includes(kind) &&
|
|
84
|
+
!pathIn(join(surface.dir, 'public'), file))
|
|
85
|
+
return !!response?.ok();
|
|
86
|
+
return matchesBytes(await dependencies.digest(file), response);
|
|
87
|
+
}
|
|
88
|
+
if (scene.surface === 'app')
|
|
89
|
+
return metro?.covers(url, kind, response) ?? false;
|
|
90
|
+
if (kind === 'script' && !response?.ok())
|
|
91
|
+
return false;
|
|
92
|
+
return surface.vite?.tracks(url, kind, response) ?? false;
|
|
93
|
+
}),
|
|
94
|
+
async prepare(launch) {
|
|
95
|
+
if (!probes.length)
|
|
96
|
+
return;
|
|
97
|
+
await launch?.(probes.map(({ scene }) => scene));
|
|
98
|
+
await Promise.all(probes.map(async ({ scene, read, hash }) => {
|
|
99
|
+
await read();
|
|
100
|
+
if (!hash())
|
|
101
|
+
for (const candidate of scenes)
|
|
102
|
+
if (candidate.surface === scene.surface)
|
|
103
|
+
candidates.reuse.delete(candidate.key);
|
|
104
|
+
}));
|
|
105
|
+
},
|
|
183
106
|
};
|
|
184
107
|
for (const surface of new Set(scenes.map((scene) => scene.surface))) {
|
|
108
|
+
if (surface === 'app' && environment.EXPO_METRO_NO_MAIN_FIELD_OVERRIDE)
|
|
109
|
+
continue;
|
|
185
110
|
const setup = await surfaceEntry(root, surface, dependencies);
|
|
186
111
|
if (!setup)
|
|
187
112
|
continue;
|
|
188
|
-
const
|
|
189
|
-
if (
|
|
113
|
+
const walked = await dependencies.walk(setup.entry);
|
|
114
|
+
if (walked) {
|
|
115
|
+
const graph = await sceneGraph(root, catalog, setup.entry, walked, dependencies, run.locales, !!setup.vite);
|
|
116
|
+
const first = scenes.find((scene) => scene.surface === surface);
|
|
117
|
+
// An owned server fills its address during launch, after the graph is resolved.
|
|
118
|
+
const page = new URL('http://127.0.0.1');
|
|
119
|
+
const readAfterLaunch = (read) => async () => {
|
|
120
|
+
if (!first)
|
|
121
|
+
return;
|
|
122
|
+
page.href = sceneUrl(run.urls[surface], first.key, {
|
|
123
|
+
theme: run.product,
|
|
124
|
+
mode: 'light',
|
|
125
|
+
locale: run.first,
|
|
126
|
+
});
|
|
127
|
+
return read();
|
|
128
|
+
};
|
|
129
|
+
const vite = setup.vite &&
|
|
130
|
+
graph &&
|
|
131
|
+
viteRequests(setup.entry.dir, setup.vite.runtime, new Set(graph.setup.map(([file]) => resolve(root, file))), new Set(setup.assets), setup.vite.files, page);
|
|
190
132
|
inputs.set(surface, {
|
|
191
133
|
dir: setup.entry.dir,
|
|
192
|
-
hash: sha256(JSON.stringify([setup.settings, files])),
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
134
|
+
hash: sha256(JSON.stringify([setup.settings, walked.files])),
|
|
135
|
+
graph,
|
|
136
|
+
vite,
|
|
137
|
+
whole: setup.metro,
|
|
138
|
+
document: setup.document,
|
|
139
|
+
settings: setup.settings,
|
|
140
|
+
pageAssets: setup.assets,
|
|
141
|
+
...(surface === 'admin' && { fonts: fontPath(run.urls.admin) }),
|
|
197
142
|
});
|
|
143
|
+
if (first && vite)
|
|
144
|
+
probes.push({ scene: first, read: readAfterLaunch(vite.prepare), hash: vite.proof });
|
|
145
|
+
if (setup.metro && graph && first) {
|
|
146
|
+
metro = metroInputs(setup.entry.dir, dirname(lockfile(root)[0] ?? join(root, 'package.json')), page);
|
|
147
|
+
probes.push({ scene: first, read: readAfterLaunch(metro.prepare), hash: metro.hash });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
198
150
|
}
|
|
199
|
-
|
|
151
|
+
for (const [surface, { hash }] of inputs)
|
|
152
|
+
surfaces.set(surface, hash);
|
|
153
|
+
if (!scenes.length)
|
|
200
154
|
return result;
|
|
201
155
|
const common = await sharedSettings(root, dependencies).catch(() => undefined);
|
|
202
156
|
if (!common)
|
|
203
157
|
return result;
|
|
204
158
|
const shared = sharedFingerprint(run, await browser(), common, design, environment);
|
|
159
|
+
result.shared = shared;
|
|
160
|
+
if (!inputs.size)
|
|
161
|
+
return result;
|
|
162
|
+
await candidates.compare(inputs, shared);
|
|
205
163
|
for (const scene of scenes) {
|
|
206
164
|
const surface = inputs.get(scene.surface);
|
|
207
165
|
if (!surface || typeof scene.view !== 'string' || !plainData(scene))
|
|
208
166
|
continue;
|
|
209
|
-
// Each scene holds its own frame's size
|
|
210
|
-
|
|
211
|
-
const { width, height } = run.frames[scene.frame];
|
|
212
|
-
const page = pageOptions({ width, height });
|
|
213
|
-
fingerprints.set(scene.key, sha256(JSON.stringify([shared, surface.hash, scene, page])));
|
|
167
|
+
// Each scene holds its own frame's size: a new desktop frame re-shoots only its scenes.
|
|
168
|
+
fingerprints.set(scene.key, sha256(JSON.stringify([shared, surface.hash, scene, scenePage(run, scene)])));
|
|
214
169
|
}
|
|
215
170
|
return result;
|
|
216
171
|
}
|
|
@@ -220,7 +175,7 @@ environment = process.env) {
|
|
|
220
175
|
*/
|
|
221
176
|
function sharedFingerprint(run, browser, common, design, environment) {
|
|
222
177
|
return sha256(JSON.stringify([
|
|
223
|
-
'snapshot-inputs-
|
|
178
|
+
'snapshot-inputs-v5',
|
|
224
179
|
dependencyVersion,
|
|
225
180
|
browser,
|
|
226
181
|
run.looks,
|
|
@@ -236,15 +191,3 @@ function sharedFingerprint(run, browser, common, design, environment) {
|
|
|
236
191
|
common,
|
|
237
192
|
]));
|
|
238
193
|
}
|
|
239
|
-
async function sharedSettings(root, dependencies) {
|
|
240
|
-
const ext = import.meta.url.endsWith('.ts') ? '.ts' : '.js';
|
|
241
|
-
const checks = [...CHECKS.map((name) => name + ext), 'drawn-text.js'];
|
|
242
|
-
// The root `.env` is not a file input: `loadEnv` puts its values into the environment the
|
|
243
|
-
// fingerprint reads, so main (which has one) and a worktree (which has none) agree.
|
|
244
|
-
const settings = SETTINGS.filter((name) => !name.startsWith('.env'));
|
|
245
|
-
const files = [...existing(root, [...settings, 'buffcore.config.ts']), ...lockfile(root)];
|
|
246
|
-
return Promise.all([
|
|
247
|
-
Promise.all(checks.map((file) => dependencies.digest(resolve(import.meta.dirname, file)))),
|
|
248
|
-
settingHashes(root, files, dependencies),
|
|
249
|
-
]);
|
|
250
|
-
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Theme } from '@buffcore/tokens';
|
|
2
|
+
import type { SnapshotReport } from './report.ts';
|
|
3
|
+
/**
|
|
4
|
+
* `floor`: the product's theme (the first starter when it names none), light and dark, its languages
|
|
5
|
+
* and `en-XA` (`ar-XB` too with a right-to-left language). `full`: every theme, mode and pseudo-locale.
|
|
6
|
+
*/
|
|
7
|
+
export type Matrix = 'floor' | 'full';
|
|
8
|
+
/** Why: the default, the `--full` switch, or a shared input changed since the last full report. */
|
|
9
|
+
export type MatrixReason = 'floor' | 'switch' | 'shared';
|
|
10
|
+
export interface MatrixRun {
|
|
11
|
+
looks: readonly Theme[];
|
|
12
|
+
product: string;
|
|
13
|
+
locales: readonly string[];
|
|
14
|
+
/** Unset: the full matrix (a caller that names none keeps what every run drew before). */
|
|
15
|
+
matrix?: Matrix | undefined;
|
|
16
|
+
/** The selector's added looks (S3c), by scene: drawn on top of the floor, never in its place. */
|
|
17
|
+
extraLooks?: ReadonlyMap<string, ReadonlySet<string>> | undefined;
|
|
18
|
+
}
|
|
19
|
+
/** The product's languages and `en-XA`, and `ar-XB` when one of them is written right to left. */
|
|
20
|
+
export declare function floorLocales(locales: readonly string[]): string[];
|
|
21
|
+
type Look = {
|
|
22
|
+
theme: Theme;
|
|
23
|
+
mode: string;
|
|
24
|
+
locale: string;
|
|
25
|
+
};
|
|
26
|
+
/** A look's name, `<theme>.<mode>.<locale>`, as the selector and the report name it. */
|
|
27
|
+
export declare const lookName: ({ theme, mode, locale }: Look) => string;
|
|
28
|
+
/**
|
|
29
|
+
* The looks a scene is drawn and checked in, in order: theme, then mode, then language. In the
|
|
30
|
+
* floor, a scene the selector added looks for draws those too, in the full matrix's order.
|
|
31
|
+
*/
|
|
32
|
+
export declare function drawnLooks(run: MatrixRun, scene?: string): Look[];
|
|
33
|
+
/** Whether a scene drawn in `had` covers a run that draws `wants` (an older report's scene: full). */
|
|
34
|
+
export declare const covers: (had: Matrix | undefined, wants: Matrix | undefined) => boolean;
|
|
35
|
+
/**
|
|
36
|
+
* The matrix a run draws: full with the switch; full when the shared inputs differ from those of the
|
|
37
|
+
* last full report (the nearest ancestor's `fullInputs`), or are unknown; else the floor.
|
|
38
|
+
*/
|
|
39
|
+
export declare function chooseMatrix(full: boolean | undefined, current: string | undefined, ancestor: Pick<SnapshotReport, 'fullInputs'> | undefined): {
|
|
40
|
+
matrix: Matrix;
|
|
41
|
+
reason: MatrixReason;
|
|
42
|
+
};
|
|
43
|
+
/** The run's matrix and what its report records, from the switch and the nearest ancestor report. */
|
|
44
|
+
export declare function runMatrix(full: boolean | undefined, parts: string | undefined, root?: string, commit?: string): {
|
|
45
|
+
matrix: Matrix;
|
|
46
|
+
matrixReason: MatrixReason;
|
|
47
|
+
fullInputs: string | undefined;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* What `ape prototype version` accepts, judged scene by scene on what was drawn: each scene's matrix
|
|
51
|
+
* is the floor or the full one, covers the report's (`covers`, as reuse: a full report holds no floor
|
|
52
|
+
* scene, reused or not), and its pictures are exactly that matrix's: the product's theme light and
|
|
53
|
+
* dark (the floor), or every theme light and the product's dark (full). The report's languages hold
|
|
54
|
+
* the floor's (`en-XA`, and `ar-XB` with a right-to-left language). A report written before S3b names
|
|
55
|
+
* no matrix and holds no floor scene: it is judged as before.
|
|
56
|
+
*/
|
|
57
|
+
export declare function meetsFloor(report: Pick<SnapshotReport, 'matrix' | 'scenes' | 'themes' | 'locales'>): boolean;
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Which looks a snapshot draws (F113b, F113c): the floor by default, the full matrix with `--full`
|
|
2
|
+
// or when an input every scene shares changed since the last full report.
|
|
3
|
+
import { isRtl, PSEUDO_LOCALES } from '@buffcore/i18n';
|
|
4
|
+
import { findAncestor } from './snapshot-ancestor.js';
|
|
5
|
+
import { lookKey, photographed } from './snapshot-themes.js';
|
|
6
|
+
const FLOOR_MODES = ['light', 'dark'];
|
|
7
|
+
/** The product's languages and `en-XA`, and `ar-XB` when one of them is written right to left. */
|
|
8
|
+
export function floorLocales(locales) {
|
|
9
|
+
const own = locales.filter((locale) => !PSEUDO_LOCALES.some((pseudo) => pseudo === locale));
|
|
10
|
+
return [...own, 'en-XA', ...(own.some(isRtl) ? ['ar-XB'] : [])];
|
|
11
|
+
}
|
|
12
|
+
/** A look's name, `<theme>.<mode>.<locale>`, as the selector and the report name it. */
|
|
13
|
+
export const lookName = ({ theme, mode, locale }) => `${theme.key}.${mode}.${locale}`;
|
|
14
|
+
/**
|
|
15
|
+
* The looks a scene is drawn and checked in, in order: theme, then mode, then language. In the
|
|
16
|
+
* floor, a scene the selector added looks for draws those too, in the full matrix's order.
|
|
17
|
+
*/
|
|
18
|
+
export function drawnLooks(run, scene) {
|
|
19
|
+
const extra = scene === undefined ? undefined : run.extraLooks?.get(scene);
|
|
20
|
+
if (run.matrix === 'floor' && extra?.size) {
|
|
21
|
+
const floor = new Set(drawnLooks({ ...run, extraLooks: undefined }).map(lookName));
|
|
22
|
+
return drawnLooks({ ...run, matrix: 'full' }).filter((look) => floor.has(lookName(look)) || extra.has(lookName(look)));
|
|
23
|
+
}
|
|
24
|
+
const floor = run.matrix === 'floor';
|
|
25
|
+
const own = run.looks.find((theme) => theme.key === run.product) ?? run.looks[0];
|
|
26
|
+
const themes = floor ? (own ? [own] : []) : run.looks;
|
|
27
|
+
const locales = floor ? floorLocales(run.locales) : run.locales;
|
|
28
|
+
return themes.flatMap((theme) => Object.keys(theme.color)
|
|
29
|
+
.filter((mode) => !floor || FLOOR_MODES.includes(mode))
|
|
30
|
+
.flatMap((mode) => locales.map((locale) => ({ theme, mode, locale }))));
|
|
31
|
+
}
|
|
32
|
+
/** Whether a scene drawn in `had` covers a run that draws `wants` (an older report's scene: full). */
|
|
33
|
+
export const covers = (had, wants) => (had ?? 'full') === 'full' || wants === 'floor';
|
|
34
|
+
/**
|
|
35
|
+
* The matrix a run draws: full with the switch; full when the shared inputs differ from those of the
|
|
36
|
+
* last full report (the nearest ancestor's `fullInputs`), or are unknown; else the floor.
|
|
37
|
+
*/
|
|
38
|
+
export function chooseMatrix(full, current, ancestor) {
|
|
39
|
+
if (full)
|
|
40
|
+
return { matrix: 'full', reason: 'switch' };
|
|
41
|
+
if (current === undefined || ancestor?.fullInputs !== current)
|
|
42
|
+
return { matrix: 'full', reason: 'shared' };
|
|
43
|
+
return { matrix: 'floor', reason: 'floor' };
|
|
44
|
+
}
|
|
45
|
+
/** The run's matrix and what its report records, from the switch and the nearest ancestor report. */
|
|
46
|
+
export function runMatrix(full, parts, root, commit) {
|
|
47
|
+
const ancestor = full || !root || !commit ? undefined : findAncestor(root, commit)?.report;
|
|
48
|
+
const { matrix, reason } = chooseMatrix(full, parts, ancestor);
|
|
49
|
+
return {
|
|
50
|
+
matrix,
|
|
51
|
+
matrixReason: reason,
|
|
52
|
+
fullInputs: matrix === 'full' ? parts : ancestor?.fullInputs,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const MATRICES = [undefined, 'floor', 'full'];
|
|
56
|
+
/**
|
|
57
|
+
* What `ape prototype version` accepts, judged scene by scene on what was drawn: each scene's matrix
|
|
58
|
+
* is the floor or the full one, covers the report's (`covers`, as reuse: a full report holds no floor
|
|
59
|
+
* scene, reused or not), and its pictures are exactly that matrix's: the product's theme light and
|
|
60
|
+
* dark (the floor), or every theme light and the product's dark (full). The report's languages hold
|
|
61
|
+
* the floor's (`en-XA`, and `ar-XB` with a right-to-left language). A report written before S3b names
|
|
62
|
+
* no matrix and holds no floor scene: it is judged as before.
|
|
63
|
+
*/
|
|
64
|
+
export function meetsFloor(report) {
|
|
65
|
+
if (!MATRICES.includes(report.matrix))
|
|
66
|
+
return false;
|
|
67
|
+
// An older ape's report names no matrix: it drew every scene in the full one, as it always did.
|
|
68
|
+
if (report.matrix === undefined)
|
|
69
|
+
return report.scenes.every((scene) => scene.matrix === undefined);
|
|
70
|
+
const locales = report.locales ?? [];
|
|
71
|
+
if (!floorLocales(locales).every((locale) => locales.includes(locale)))
|
|
72
|
+
return false;
|
|
73
|
+
const darks = report.scenes.flatMap((scene) => Object.keys(scene.screenshots).filter((look) => look.endsWith('.dark')));
|
|
74
|
+
const dark = darks[0];
|
|
75
|
+
const product = dark?.slice(0, -'.dark'.length);
|
|
76
|
+
if (!dark || !product || !report.themes?.includes(product))
|
|
77
|
+
return false;
|
|
78
|
+
return report.scenes.every((scene) => {
|
|
79
|
+
if (!MATRICES.includes(scene.matrix) || !covers(scene.matrix, report.matrix))
|
|
80
|
+
return false;
|
|
81
|
+
const want = [...(scene.matrix === 'floor' ? [product] : report.themes), dark].sort();
|
|
82
|
+
// A floor scene's selector picks (S3c) may add their own photos: the picked looks' keys, no other.
|
|
83
|
+
const extra = new Set(scene.matrix === 'floor'
|
|
84
|
+
? (scene.extraLooks ?? []).flatMap((look) => {
|
|
85
|
+
const [theme = '', mode = ''] = look.split('.');
|
|
86
|
+
return report.themes?.includes(theme) && photographed(theme, mode, product)
|
|
87
|
+
? [lookKey(theme, mode)]
|
|
88
|
+
: [];
|
|
89
|
+
})
|
|
90
|
+
: []);
|
|
91
|
+
const drawn = Object.keys(scene.screenshots).sort();
|
|
92
|
+
const own = drawn.filter((key) => !(extra.has(key) && !want.includes(key)));
|
|
93
|
+
return JSON.stringify(own) === JSON.stringify(want);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Response } from 'playwright-core';
|
|
2
|
+
/** An Expo bundle contains all its views. Bind the actual entry and document bytes as app inputs. */
|
|
3
|
+
export declare function metroInputs(dir: string, workspace: string, page: URL): {
|
|
4
|
+
prepare(): Promise<void>;
|
|
5
|
+
hash: () => string | undefined;
|
|
6
|
+
same(): Promise<boolean>;
|
|
7
|
+
covers(url: URL, kind: string, response?: Response): Promise<boolean>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { sha256 } from './snapshot-hashes.js';
|
|
3
|
+
import { matchesBytes, servedBytes } from './snapshot-served-inputs.js';
|
|
4
|
+
const webQuery = new URLSearchParams({
|
|
5
|
+
platform: 'web',
|
|
6
|
+
dev: 'true',
|
|
7
|
+
hot: 'false',
|
|
8
|
+
lazy: 'true',
|
|
9
|
+
'transform.engine': 'hermes',
|
|
10
|
+
'transform.routerRoot': 'src/app',
|
|
11
|
+
unstable_transformProfile: 'hermes-stable',
|
|
12
|
+
});
|
|
13
|
+
function bundleUrl(html, page, dir, workspace) {
|
|
14
|
+
const scripts = [...html.matchAll(/<script\b([^>]*)>/gi)];
|
|
15
|
+
const [script] = scripts;
|
|
16
|
+
if (scripts.length !== 1 || !script)
|
|
17
|
+
return;
|
|
18
|
+
const path = /^ src="(\/[^"\s]+)" defer$/.exec(script[1] ?? '')?.[1];
|
|
19
|
+
if (!path)
|
|
20
|
+
return;
|
|
21
|
+
const bundle = new URL(path, page);
|
|
22
|
+
if (bundle.origin !== page.origin || bundle.hash || !bundle.pathname.endsWith('.bundle'))
|
|
23
|
+
return;
|
|
24
|
+
const entry = decodeURIComponent(bundle.pathname.slice(0, -'.bundle'.length));
|
|
25
|
+
if (![dir, workspace].some((root) => resolve(root, `.${entry}`) === resolve(dir, 'index.ts')))
|
|
26
|
+
return;
|
|
27
|
+
if (bundle.searchParams.size !== webQuery.size)
|
|
28
|
+
return;
|
|
29
|
+
if ([...webQuery].some(([key, value]) => bundle.searchParams.get(key) !== value))
|
|
30
|
+
return;
|
|
31
|
+
return bundle;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The served text with every loopback address's port taken out: a run's ports are its own (a
|
|
35
|
+
* worktree's are new every time), and Metro writes them into the bundle (its links, and public
|
|
36
|
+
* values such as the API's address).
|
|
37
|
+
*/
|
|
38
|
+
const portless = (bytes) => bytes.toString('utf8').replace(/(127\.0\.0\.1|localhost|\[::1\]):\d+/g, '$1:port');
|
|
39
|
+
/** An Expo bundle contains all its views. Bind the actual entry and document bytes as app inputs. */
|
|
40
|
+
export function metroInputs(dir, workspace, page) {
|
|
41
|
+
async function read() {
|
|
42
|
+
const html = await servedBytes(page, 'html');
|
|
43
|
+
if (!html)
|
|
44
|
+
return;
|
|
45
|
+
const bundle = bundleUrl(html.toString('utf8'), page, dir, workspace);
|
|
46
|
+
if (!bundle)
|
|
47
|
+
return;
|
|
48
|
+
const js = await servedBytes(bundle, 'javascript');
|
|
49
|
+
if (!js)
|
|
50
|
+
return;
|
|
51
|
+
return {
|
|
52
|
+
path: bundle.pathname + bundle.search,
|
|
53
|
+
html: sha256(html),
|
|
54
|
+
js: sha256(js),
|
|
55
|
+
code: sha256(JSON.stringify([portless(html), portless(js)])),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
let prepared;
|
|
59
|
+
const safeRead = () => read().catch(() => undefined);
|
|
60
|
+
return {
|
|
61
|
+
async prepare() {
|
|
62
|
+
prepared = await safeRead();
|
|
63
|
+
},
|
|
64
|
+
hash: () => prepared && sha256(JSON.stringify([prepared.path, prepared.code])),
|
|
65
|
+
async same() {
|
|
66
|
+
return !prepared || JSON.stringify(prepared) === JSON.stringify(await safeRead());
|
|
67
|
+
},
|
|
68
|
+
async covers(url, kind, response) {
|
|
69
|
+
if (!prepared)
|
|
70
|
+
return false;
|
|
71
|
+
if (kind === 'websocket')
|
|
72
|
+
return !url.search && ['/hot', '/message'].includes(url.pathname);
|
|
73
|
+
const hash = kind === 'document' && url.pathname === '/_scene'
|
|
74
|
+
? prepared.html
|
|
75
|
+
: kind === 'script' && url.pathname + url.search === prepared.path
|
|
76
|
+
? prepared.js
|
|
77
|
+
: undefined;
|
|
78
|
+
return matchesBytes(hash, response);
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -13,8 +13,12 @@ export interface Owners {
|
|
|
13
13
|
export declare function parseNetstat(text: string, port: number): number[];
|
|
14
14
|
/** `lsof -Fp` lines: `p4242`. */
|
|
15
15
|
export declare function parseLsof(text: string): number[];
|
|
16
|
-
/**
|
|
17
|
-
|
|
16
|
+
/**
|
|
17
|
+
* `pid ppid` pairs, one per line, from either platform's process table. With `starts` (each
|
|
18
|
+
* process's start, in milliseconds), a child counts only when it started at or after its parent:
|
|
19
|
+
* Windows keeps a dead parent's id on its children, and that id can be given to a later process.
|
|
20
|
+
*/
|
|
21
|
+
export declare function descendants(table: string, root: number, starts?: ReadonlyMap<number, number>): Set<number>;
|
|
18
22
|
export declare const systemOwners: Owners;
|
|
19
23
|
/** Who has the port: `ours`, `foreign` (a listener outside the tree, or none), or `failed` (no answer). */
|
|
20
24
|
export declare function portOwner(port: number, pid: number, owners?: Owners): Promise<'ours' | 'foreign' | 'failed'>;
|